Skip to content

Commit

Permalink
feat(its-factory): allow minter to be arbitrary bytes for remote toke…
Browse files Browse the repository at this point in the history
…n deployment
  • Loading branch information
ahramy committed Nov 6, 2024
1 parent 19d27a4 commit 8731388
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
27 changes: 17 additions & 10 deletions contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,23 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
/**
* @notice Deploys a remote interchain token on a specified destination chain.
* @param salt The unique salt for deploying the token.
* @param minter The address to receive the minter and operator role of the token, in addition to ITS. If the address is `address(0)`,
* no additional minter is set on the token. Reverts if the minter does not have mint permission for the token.
* @param localMinter TBD
* @param remoteMinter TBD
* @param destinationChain The name of the destination chain.
* @param gasValue The amount of gas to send for the deployment.
* @return tokenId The tokenId corresponding to the deployed InterchainToken.
*/
function deployRemoteInterchainToken(
bytes32 salt,
address minter,
address localMinter,
address remoteMinter,
string memory destinationChain,
uint256 gasValue
) public payable returns (bytes32 tokenId) {
string memory tokenName;
string memory tokenSymbol;
uint8 tokenDecimals;
bytes memory minter_ = new bytes(0);
bytes memory remoteMinterBytes = new bytes(0);

salt = interchainTokenSalt(chainNameHash, msg.sender, salt);
tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt);
Expand All @@ -181,14 +182,19 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
tokenSymbol = token.symbol();
tokenDecimals = token.decimals();

if (minter != address(0)) {
if (!token.isMinter(minter)) revert NotMinter(minter);
if (minter == address(interchainTokenService)) revert InvalidMinter(minter);
if (localMinter != address(0)) {
if (!token.isMinter(localMinter)) revert NotMinter(localMinter);
if (localMinter == address(interchainTokenService)) revert InvalidMinter(localMinter);
}

minter_ = minter.toBytes();
// Prepare remote minter for deployment on the destination chain
if (remoteMinter != address(0)) {
if (!token.isMinter(remoteMinter)) revert NotMinter(remoteMinter);
if (remoteMinter == address(interchainTokenService)) revert InvalidMinter(remoteMinter);
remoteMinterBytes = remoteMinter.toBytes();
}

tokenId = _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, minter_, gasValue);
tokenId = _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, remoteMinterBytes, gasValue);
}

/**
Expand All @@ -204,6 +210,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
* @param gasValue The amount of gas to send for the deployment.
* @return tokenId The tokenId corresponding to the deployed InterchainToken.
*/
// This method is deprecated, should I remove it with the minter change or we want to keep it?
function deployRemoteInterchainToken(
string calldata originalChainName,
bytes32 salt,
Expand All @@ -213,7 +220,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
) external payable returns (bytes32 tokenId) {
if (bytes(originalChainName).length != 0) revert NotSupported();

tokenId = deployRemoteInterchainToken(salt, minter, destinationChain, gasValue);
tokenId = deployRemoteInterchainToken(salt, minter, address(0), destinationChain, gasValue);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions contracts/interfaces/IInterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ interface IInterchainTokenFactory is IUpgradable, IMulticall {
/**
* @notice Deploys a remote interchain token on a specified destination chain.
* @param salt The unique salt for deploying the token.
* @param minter The address to distribute the token on the destination chain.
* @param localMinter TBD
* @param remoteMinter TBD
* @param destinationChain The name of the destination chain.
* @param gasValue The amount of gas to send for the deployment.
* @return tokenId The tokenId corresponding to the deployed InterchainToken.
*/
function deployRemoteInterchainToken(
bytes32 salt,
address minter,
address localMinter,
address remoteMinter,
string memory destinationChain,
uint256 gasValue
) external payable returns (bytes32 tokenId);
Expand Down

0 comments on commit 8731388

Please sign in to comment.