Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions axelar-chains-config/info/devnet-amplifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,36 @@
"codeId": 854,
"address": "axelar1a4e4aful6hchmxd3cffurz24pca52wmt3pf78rsmzglzujnueqgq7eypgl"
},
"ton": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"serviceName": "validators",
"sourceGatewayAddress": "kQDXcLI49JhbipboxSbaKlhUU2YCi_AOSsaG7Fe0uLMF5drj",
"votingThreshold": [
"1",
"1"
],
"blockExpiry": 10,
"confirmationHeight": 1,
"msgIdFormat": "hex_tx_hash_and_event_index",
"addressFormat": "ton",
"codeId": 1291,
"address": "axelar1snc8xyp47cyh7jgvprcezz00r56plfh9vy669gznqu6pktwlez3skvfd0a"
},
"bitcoin-dev": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"serviceName": "validators",
"sourceGatewayAddress": "0xCa85f85C72df5f8428a440887CA7c449D94e0D0c",
"votingThreshold": [
"1",
"1"
],
"blockExpiry": 10,
"confirmationHeight": 1,
"msgIdFormat": "hex_tx_hash",
"addressFormat": "eip55",
"codeId": 854,
"address": "axelar1y46xz0x0dd2h29jynh0n9xudtmk0cg8jmxqr0cqv2pj6jfxw3s0qjq63me"
},
"storeCodeProposalId": "78",
"storeCodeProposalCodeHash": "d9412440820a51bc48bf41a77ae39cfb33101ddc6562323845627ea2042bf708"
},
Expand Down Expand Up @@ -1335,6 +1365,14 @@
"plume-2": {
"codeId": 848,
"address": "axelar1unafus3vpt7nawfzdjf7u26g2rl855lpkqussxmtl5r2njaz39mqrmyv7g"
},
"ton": {
"codeId": 1292,
"address": "axelar1lxgdq53a406k6ehv4yue04e7sxr7vfujkf44jfwgtx5xugzru0ssnsc03z"
},
"bitcoin-dev": {
"codeId": 848,
"address": "axelar1y6uwt6sma4ay7awdtecp47flapexq8cm6dd0csfuausupgw47mes3glt9f"
}
},
"XrplMultisigProver": {
Expand Down Expand Up @@ -1463,6 +1501,36 @@
"domainSeparator": "0x974a372dccb2a81196b546432ad388af9cb49d0a5e4567d444c51ea63edb62f9",
"address": "axelar1mfn6hevkpj54qkkdy2rznp2azgvqff0rt2cegmflxgqfm0nqx20q6aqnp5"
},
"ton": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"adminAddress": "axelar1fgg7mer9ljjj94jzxeha3svg8u3kp8sxqzygh7",
"destinationChainID": "43113",
"signingThreshold": [
"1",
"1"
],
"serviceName": "validators",
"verifierSetDiffThreshold": 1,
"encoder": "ton",
"keyType": "ed25519",
"domainSeparator": "0x6973c72935604464b28827141b0a463af8e3487616de69c5aa0c785392c9fb9f",
"codeId": 1312,
"address": "axelar1lxgdq53a406k6ehv4yue04e7sxr7vfujkf44jfwgtx5xugzru0ssnsc03z"
},
"bitcoin-dev": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"adminAddress": "axelar1880jp05pwxmfs30ynr9qvh6p63l54yl7nqr2dt",
"signingThreshold": [
"1",
"1"
],
"serviceName": "validators",
"verifierSetDiffThreshold": 1,
"keyType": "ecdsa",
"domainSeparator": "0xbe20bbed22c0d35d6116a8312fbe9c90411f96cfa7893aaa7437bf088413ed79",
"codeId": 855,
"address": "axelar18y9apg4wl8yu06ccqsfjf4ceezen7pwvnrqjwqn3ugqdzq5thhhsvfqu7h"
},
"storeCodeProposalId": "82",
"storeCodeProposalCodeHash": "00428ef0483f103a6e1a5853c4b29466a83e5b180cc53a00d1ff9d022bc2f03a"
},
Expand Down
90 changes: 90 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@mysten/ledgerjs-hw-app-sui": "^0.4.1",
"@mysten/sui": "^1.3.0",
"@stellar/stellar-sdk": "^13.0.0",
"@ton/ton": "^15.2.1",
"axios": "^1.7.2",
"csv-parser": "^3.0.0",
"path": "^0.12.7",
Expand Down
29 changes: 29 additions & 0 deletions ton/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# Ton operational scripts

This folder contains operational scripts for the Ton AxelarGateway. It assumes an already deployed AxelarGateway.fc and an Executable.fc.

Required enviroment variables

```
MNEMONIC=
TONCENTER_API_KEY=
TON_GATEWAY_ADDRESS=
```

## Appoving a message

Run this with the hex encoded payload procuded by the Ton MultisigProver.

```bash
node ton/approveMessages.js b5ee9c7241020c0100018a000208000000280102016180000000000000000000000000000000800000000000000000000000000000000000000000000000000000000035f72a40030101c00400e2d0b0005189ac84d3a1d675847700777891dde751fa107d64837bf6337d32df6790000000000000000000000000000000018b92f5624a0587f7ed939e1c0fe4a6e4688d3a945402e2e51785d1bb98a5efe47b1d85c89fdc1920681e1d30b98c0ed4ecb64132f32b7bfcc76c58450fe7f0000102d005044035d25b76a49eebc07a7419b922fc11bd7bba1970b579d2a380ddd6606c5a1ff80607080900883078343737653062373438626132303064613436383963633836323965306431323363623862346139346132386333333537303661343032376465653766326261352d30001c6176616c616e6368652d66756a69005430783831653633654138463634464564423938353845423645323137364234333146426431306431654302000a0b00404a1a80a7b0326b22310dced59d8b52efddf313e77f9b48f226b69b8efedbe24d0006746f6e477e6fee
```


## Executing a message

Run this to execute an approve message

```bash
node ton/relayerExecute.js "0x477e0b748ba200da4689cc8629e0d123cb8b4a94a28c335706a4027dee7f2ba5-0" "avalanche-fuji" "0x81e63eA8F64FEdB9858EB6E2176B431FBd10d1eC" "48656c6c6f2066726f6d204176616c616e63686521" "0:4a1a80a7b0326b22310dced59d8b52efddf313e77f9b48f226b69b8efedbe24d" "ton" "0x35d25b76a49eebc07a7419b922fc11bd7bba1970b579d2a380ddd6606c5a1ff8"
```
57 changes: 57 additions & 0 deletions ton/approveMessages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const { Command } = require('commander');
const { Address, Cell, internal } = require('@ton/ton');
const { getTonClient, loadWallet, waitForTransaction, GATEWAY_ADDRESS } = require('./common');

// Constants
const APPROVE_MESSAGES_COST = '2';

function createApproveMessagesCell(encodedPayload) {
return Cell.fromBoc(Buffer.from(encodedPayload, 'hex'))[0];
}

async function run(encodedPayload) {
try {
const client = getTonClient();
const { contract, key } = await loadWallet(client);

const gateway = Address.parse(GATEWAY_ADDRESS);
const approveMessagesCell = createApproveMessagesCell(encodedPayload);

const message = internal({
to: gateway,
value: APPROVE_MESSAGES_COST,
body: approveMessagesCell,
});

const seqno = await contract.getSeqno();
console.log('Current wallet seqno:', seqno);

console.log('Sending approve messages transaction...');
const transfer = await contract.sendTransfer({
secretKey: key.secretKey,
messages: [message],
seqno: seqno,
amount: APPROVE_MESSAGES_COST,
});

console.log('Approve messages transaction sent successfully!');

await waitForTransaction(contract, seqno);

} catch (error) {
console.error('Error in approve messages:', error);
throw error;
}
}

// Set up command line interface
if (require.main === module) {
const program = new Command();
program
.name('approveMessages')
.description('Approve messages on TON gateway')
.argument('<encodedPayload>', 'Encoded payload in hex format')
.action(run);

program.parse();
}
55 changes: 55 additions & 0 deletions ton/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ton/common.js
const { TonClient, WalletContractV5R1 } = require('@ton/ton');
const { mnemonicToWalletKey } = require('@ton/crypto');
require('dotenv').config();

// Constants
const TONCENTER_ENDPOINT = 'https://testnet.toncenter.com/api/v2/jsonRPC';
const GATEWAY_ADDRESS = process.env.TON_GATEWAY_ADDRESS;

if (!GATEWAY_ADDRESS) {
throw new Error('Please set TON_GATEWAY_ADDRESS in your .env file');
}

// Helper function to initialize TON client
function getTonClient() {
if (!process.env.TONCENTER_API_KEY) {
throw new Error('Please set TONCENTER_API_KEY environment variable. Get it from https://t.me/tontestnetapibot');
}

return new TonClient({
endpoint: TONCENTER_ENDPOINT,
apiKey: process.env.TONCENTER_API_KEY,
});
}

// Helper function to load wallet
async function loadWallet(client) {
const mnemonic = process.env.MNEMONIC?.split(' ') || [];
if (mnemonic.length !== 24) {
throw new Error('Please set MNEMONIC environment variable with 24 words');
}

const key = await mnemonicToWalletKey(mnemonic);
const wallet = WalletContractV5R1.create({ publicKey: key.publicKey, workchain: 0 });
return { contract: client.open(wallet), key, wallet };
}

// Helper function to wait for transaction confirmation
async function waitForTransaction(contract, seqno) {
let currentSeqno = seqno;
while (currentSeqno === seqno) {
console.log('Waiting for transaction confirmation...');
await new Promise(resolve => setTimeout(resolve, 1500));
currentSeqno = await contract.getSeqno();
}
console.log('Transaction confirmed!');
}

module.exports = {
getTonClient,
loadWallet,
waitForTransaction,
TONCENTER_ENDPOINT,
GATEWAY_ADDRESS,
};
Loading
Loading