Skip to content

Commit

Permalink
chore: remove unused things
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Oct 18, 2024
1 parent ddb0a19 commit f50036b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 49 deletions.
4 changes: 0 additions & 4 deletions sui/gmp.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -13,7 +11,6 @@ const {
broadcast,
parseGatewayInfo,
parseDiscoveryInfo,
broadcastFromTxBuilder,
broadcastExecuteApprovedMessage,
} = require('./utils');
const { ethers } = require('hardhat');
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion sui/its-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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`,
Expand Down
44 changes: 0 additions & 44 deletions sui/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -334,7 +291,6 @@ module.exports = {
getBagContentId,
moveDir,
getTransactionList,
parseExecuteDataFromTransaction,
checkTrustedAddresses,
parseDiscoveryInfo,
parseGatewayInfo,
Expand Down

0 comments on commit f50036b

Please sign in to comment.