Skip to content

Commit

Permalink
feat: modify gmp send-call to send more params
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Aug 6, 2024
1 parent 218b366 commit 48bfc50
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 45 deletions.
31 changes: 6 additions & 25 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/axelarnetwork/axelar-contract-deployments#readme",
"dependencies": {
"@axelar-network/axelar-cgp-solidity": "6.3.1",
"@axelar-network/axelar-cgp-sui": "0.3.0",
"@axelar-network/axelar-cgp-sui": "^0.0.0-snapshot.08213e4",
"@axelar-network/axelar-gmp-sdk-solidity": "5.10.0",
"@axelar-network/interchain-token-service": "1.2.4",
"@cosmjs/cosmwasm-stargate": "^0.32.1",
Expand Down
41 changes: 22 additions & 19 deletions sui/gmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ async function sendCommand(keypair, client, contracts, args, options) {
const params = options.params;

const [testConfig, gasServiceConfig] = contracts;
const gasServicePackageId = gasServiceConfig.address;
const singletonObjectId = testConfig.objects.singleton;
const channelId = testConfig.objects.channelId;
const gasServiceObjectId = gasServiceConfig.objects.GasService;
const singletonObjectId = testConfig.objects.Singleton;

const unitAmount = getUnitAmount(feeAmount);
const walletAddress = keypair.toSuiAddress();
Expand All @@ -34,27 +33,31 @@ async function sendCommand(keypair, client, contracts, args, options) {
target: `${testConfig.address}::test::send_call`,
arguments: [
tx.object(singletonObjectId),
tx.object(gasServiceObjectId),
tx.pure(bcs.string().serialize(destinationChain).toBytes()),
tx.pure(bcs.string().serialize(destinationAddress).toBytes()),
tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(payload)).toBytes()),
tx.pure.address(refundAddress),
coin,
tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(params)).toBytes()),
],
});

if (gasServiceConfig) {
tx.moveCall({
target: `${gasServicePackageId}::gas_service::pay_gas`,
arguments: [
tx.object(gasServiceConfig.objects.GasService),
coin, // Coin<SUI>
tx.pure.address(channelId), // Channel address
tx.pure(bcs.string().serialize(destinationChain).toBytes()), // Destination chain
tx.pure(bcs.string().serialize(destinationAddress).toBytes()), // Destination address
tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(payload)).toBytes()), // Payload
tx.pure.address(refundAddress), // Refund address
tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(params)).toBytes()), // Params
],
});
}
// if (gasServiceConfig) {
// tx.moveCall({
// target: `${gasServicePackageId}::gas_service::pay_gas`,
// arguments: [
// tx.object(gasServiceConfig.objects.GasService),
// coin, // Coin<SUI>
// tx.pure.address(channelId), // Channel address
// tx.pure(bcs.string().serialize(destinationChain).toBytes()), // Destination chain
// tx.pure(bcs.string().serialize(destinationAddress).toBytes()), // Destination address
// tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(payload)).toBytes()), // Payload
// tx.pure.address(refundAddress), // Refund address
// tx.pure(bcs.vector(bcs.u8()).serialize(arrayify(params)).toBytes()), // Params
// ],
// });
// }

const receipt = await broadcast(client, keypair, tx);

Expand Down Expand Up @@ -160,7 +163,7 @@ async function processCommand(command, chain, args, options) {

await printWalletInfo(keypair, client, chain, options);

const contracts = [chain.contracts.test, chain.contracts.GasService, chain.contracts.axelar_gateway];
const contracts = [chain.contracts.Test, chain.contracts.GasService, chain.contracts.AxelarGateway];

await command(keypair, client, contracts, args, options);
}
Expand Down

0 comments on commit 48bfc50

Please sign in to comment.