diff --git a/sui/gmp.js b/sui/gmp.js index da91499f..ceeaf138 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -1,10 +1,8 @@ const { Command } = require('commander'); const { Transaction } = require('@mysten/sui/transactions'); const { bcs } = require('@mysten/sui/bcs'); -const { bcsStructs } = require('@axelar-network/axelar-cgp-sui'); const { loadConfig, saveConfig } = require('../common/utils'); const { - getBcsBytesByObjectId, addBaseOptions, addOptionsToCommands, getUnitAmount, @@ -13,7 +11,6 @@ const { broadcast, parseGatewayInfo, parseDiscoveryInfo, - broadcastFromTxBuilder, broadcastExecuteApprovedMessage, } = require('./utils'); const { ethers } = require('hardhat'); @@ -58,7 +55,6 @@ async function execute(keypair, client, chain, args, options) { const { Example } = chain.contracts; - // Get the channel id from the options or use the channel id from the deployed Example contract object. const channelId = options.channelId || chain.contracts.Example.objects.GmpChannelId; if (!channelId) { diff --git a/sui/its-example.js b/sui/its-example.js index 5b7b4c0c..ec3afd09 100644 --- a/sui/its-example.js +++ b/sui/its-example.js @@ -142,7 +142,7 @@ async function handleReceivedMessage(keypair, client, contracts, args, options, message_id: messageId, source_address: sourceAddress, destination_id: ITS.objects.ChannelId, - payload: payload, + payload, }; await broadcastExecuteApprovedMessage(client, keypair, discoveryInfo, gatewayInfo, messageInfo, actionName); @@ -191,6 +191,7 @@ async function deployToken(keypair, client, contracts, args, options) { let tokenId; const postDeployTxBuilder = new TxBuilder(client); + if (options.origin) { await postDeployTxBuilder.moveCall({ target: `${Example.address}::its::register_coin`, diff --git a/sui/utils/utils.js b/sui/utils/utils.js index 709d91c0..fb0e4b32 100644 --- a/sui/utils/utils.js +++ b/sui/utils/utils.js @@ -262,49 +262,6 @@ const parseGatewayInfo = (suiConfig) => { }; }; -const parseExecuteDataFromTransaction = async (client, transaction, approvedMessage) => { - // Get the transaction object from the object id - const txObject = await client.getObject({ - id: transaction.objectId, - options: { - showContent: true, - }, - }); - - // Extract the fields from the transaction object - const txFields = txObject.data.content.fields.value.fields.move_calls[0].fields; - - // Build the arguments for the move call - // There're 5 types of arguments as mentioned in the following link https://github.com/axelarnetwork/axelar-cgp-sui/blob/72579e5c7735da61d215bd712627edad562cb82a/src/bcs.ts#L44-L49 - const txArgs = txFields.arguments.map(([argType, ...arg]) => { - if (argType === 0) { - return '0x' + Buffer.from(arg).toString('hex'); - } else if (argType === 1) { - // TODO: handle pures followed by the bcs encoded form of the pure - // throw new Error('Not implemented yet'); - } else if (argType === 2) { - return approvedMessage; - } else if (argType === 3) { - // TODO: handle the payload of the contract call (to be passed into the intermediate function) - throw new Error('Not implemented yet'); - } else if (argType === 4) { - // TODO: handle an argument returned from a previous move call, followed by a u8 specified which call to get the return of (0 for the first transaction AFTER the one that gets ApprovedMessage out), and then another u8 specifying which argument to input. - throw new Error('Not implemented yet'); - } - - throw new Error(`Unknown argument type: ${argType}`); - }); - - const { module_name: moduleName, name, package_id: packageId } = txFields.function.fields; - - return { - moduleName, - name, - packageId, - txArgs, - }; -}; - const checkTrustedAddresses = (trustedAddresses, destinationChain, destinationAddress) => { if (!trustedAddresses[destinationChain] || !trustedAddresses[destinationChain].includes(destinationAddress)) { throw new Error( @@ -334,7 +291,6 @@ module.exports = { getBagContentId, moveDir, getTransactionList, - parseExecuteDataFromTransaction, checkTrustedAddresses, parseDiscoveryInfo, parseGatewayInfo,