Skip to content

Commit

Permalink
feat(evm): add legacy ITS custom token linkToken support
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Feb 25, 2025
1 parent 7c389c5 commit 8b8b4b5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
14 changes: 14 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,17 @@ To get details of options provided in the command run:
```bash
node evm/verify-contract.js --help
```

## Interchain Token Service

### Link Token

#### Legacy custom ITS tokens

Custom tokens that have already registered with ITS (via `deployTokenManager`) prior to ITS v2.1.0 release can continue being linked to new chains via the following approach. However, we do recommend registering them. Token manager type should be passed in via `--type` flag (e.g. `MINT_BURN`).

```bash
node evm/its.js linkToken --salt [deploy-salt] --destinationChain [destinationChain] --tokenAddress [tokenAddress] --type [type] --operator [operator] --gasValue [gasValue]
```

The raw `bytes32` salt can be provided via `--rawSalt [raw-salt]` instead of hashing the provided salt string.
45 changes: 45 additions & 0 deletions evm/its.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,50 @@ async function processCommand(config, chain, options) {
break;
}

case 'linkToken': {
const { destinationChain, type, operator, tokenAddress, gasValue } = options;

const deploymentSalt = getDeploymentSalt(options);
const tokenManagerType = tokenManagerImplementations[type];

validateParameters({
isString: { destinationChain },
isValidAddress: { tokenAddress, operator },
isValidNumber: { gasValue, tokenManagerType },
});
isValidDestinationChain(config, destinationChain);

const interchainTokenId = await interchainTokenService.interchainTokenId(wallet.address, deploymentSalt);
printInfo('Expected tokenId', interchainTokenId);

try {
const tokenManagerAddress = await interchainTokenService.deployedTokenManager(tokenId);
printInfo(`TokenManager for tokenId ${tokenId} exists on the current chain`, tokenManagerAddress);

const sourceTokenAddress = await interchainTokenService.registeredTokenAddress(tokenId);
printInfo(`Token address on current chain for tokenId ${tokenId}`, sourceTokenAddress);
} catch (error) {
printError(`TokenManager for tokenId ${tokenId} does not yet exist on the current chain.`);
return;
}

const linkParams = operator;

const tx = await interchainTokenService.linkToken(
deploymentSalt,
destinationChain,
tokenAddress,
tokenManagerType,
linkParams,
gasValue,
gasOptions,
);

await handleTx(tx, chain, interchainTokenService, options.action, 'LinkTokenStarted');

break;
}

default: {
throw new Error(`Unknown action ${action}`);
}
Expand Down Expand Up @@ -677,6 +721,7 @@ if (require.main === module) {
'migrateInterchainToken',
'registerTokenMetadata',
'transferMintership',
'linkToken',
])
.makeOptionMandatory(true),
);
Expand Down

0 comments on commit 8b8b4b5

Please sign in to comment.