Skip to content

Commit

Permalink
contract changes
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Dec 10, 2024
1 parent d06d6f1 commit c4b30ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 3 additions & 4 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,18 @@ contract InterchainTokenService is

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) {
if (destinationTokenAddress.length == 0) revert EmptyDestinationAddress();
if (linkParams.length == 0) revert EmptyParams();

// TODO: Should we only mint/burn or lock/unlock for remote linking for simplicity? Makes it easier for external chains
// Custom token managers can't be deployed with native interchain token type, which is reserved for interchain tokens
if (tokenManagerType == TokenManagerType.NATIVE_INTERCHAIN_TOKEN) revert CannotDeploy(tokenManagerType);

// TODO: Support linking existing custom tokens on remote chains
address deployer = msg.sender;

if (msg.sender == interchainTokenFactory) {
deployer = TOKEN_FACTORY_DEPLOYER;
} else if (bytes(destinationChain).length == 0) {
revert NotSupported();
// TODO: Only support linking new tokens via ITS factory, to include chain name in token id derivation
// revert NotSupported();
}

tokenId = interchainTokenId(deployer, salt);
Expand Down Expand Up @@ -923,7 +922,7 @@ contract InterchainTokenService is
// slither-disable-next-line unused-return
bytes memory sourceTokenAddress = registeredTokenAddress(tokenId).toBytes();

emit TokenManagerDeploymentStarted(tokenId, destinationChain, tokenManagerType, params);
emit LinkTokenStarted(tokenId, destinationChain, sourceTokenAddress, destinationTokenAddress, tokenManagerType, autoScaling, params);

bytes memory payload = abi.encode(MESSAGE_TYPE_LINK_TOKEN, tokenId, tokenManagerType, sourceTokenAddress, destinationTokenAddress, autoScaling, params);

Expand Down
5 changes: 4 additions & 1 deletion contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ interface IInterchainTokenService is
uint256 amount,
bytes32 dataHash
);
event TokenManagerDeploymentStarted(
event LinkTokenStarted(
bytes32 indexed tokenId,
string destinationChain,
bytes sourceTokenAddress,
bytes destinationTokenAddress,
TokenManagerType indexed tokenManagerType,
bool autoScaling,
bytes params
);
event InterchainTokenDeploymentStarted(
Expand Down

0 comments on commit c4b30ab

Please sign in to comment.