Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(its): add custom token support with auto scaling #311

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

milapsheth
Copy link
Member

@milapsheth milapsheth commented Dec 10, 2024

  • Update tests
  • Move custom token usage from ITS to ITS factory tests
  • Remove deployTokenManager to reduce ITS bytecode after tests are updated to use linkToken

Two new message types are introduced:

  • RegisterTokenMetadata: Sends a message to ITS hub to register token decimals by token address
  • LinkToken: Allows linking custom tokens across chains. LinkToken needs to be submitted from the same origin chain to other remote chains for the same tokenId. Existing custom tokens can still be linked by calling linkToken from a chain that has a registered token for that tokenId.

tokenId = linkToken(salt, destinationChain, destinationTokenAddress.toBytes(), tokenManagerType, false, linkParams, gasValue);
}

function linkToken(bytes32 salt, string calldata destinationChain, bytes memory destinationTokenAddress, TokenManagerType tokenManagerType, bool autoScaling, bytes memory linkParams, uint256 gasValue) public payable whenNotPaused returns (bytes32 tokenId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is to be used for local deployments too then linkToken is confusing.

// Restricted on ITS contracts deployed to Amplifier chains until ITS Hub adds support
revert NotSupported();
} else if (bytes(destinationChain).length == 0) {
// TODO: Only support linking new tokens via ITS factory, to include chain name in token id derivation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to already deployed custom tokens?

}

tokenId = interchainTokenId(deployer, salt);

emit InterchainTokenIdClaimed(tokenId, deployer, salt);

if (bytes(destinationChain).length == 0) {
_deployTokenManager(tokenId, tokenManagerType, params);
_deployTokenManager(tokenId, tokenManagerType, destinationTokenAddress.toAddress(), linkParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linkParams are just the operator for local deployments it seems.

);

if (tokenManagerType == TokenManagerType.NATIVE_INTERCHAIN_TOKEN) revert CannotDeploy(tokenManagerType);

_deployTokenManager(tokenId, tokenManagerType, params);
_deployTokenManager(tokenId, tokenManagerType, destinationTokenAddress.toAddress(), linkParams);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even if the only param left in EVM is the operator, we should have it be abi encoded when it is passed as params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants