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: addressed ackee's report #312

Merged
merged 16 commits into from
Jan 6, 2025
14 changes: 14 additions & 0 deletions contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,24 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
bytes32 deploySalt = canonicalInterchainTokenDeploySalt(tokenAddress);
string memory currentChain = '';
uint256 gasValue = 0;
_checkToken(tokenAddress);

tokenId = interchainTokenService.deployTokenManager(deploySalt, currentChain, TokenManagerType.LOCK_UNLOCK, params, gasValue);
}

function _checkToken(address tokenAddress) internal view {
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
IERC20Named token = IERC20Named(tokenAddress);
try token.name() {} catch {
revert NotToken(tokenAddress);
}
try token.symbol() {} catch {
revert NotToken(tokenAddress);
}
try token.decimals() {} catch {
revert NotToken(tokenAddress);
}
}

/**
* @notice Deploys a canonical interchain token on a remote chain.
* @param originalTokenAddress The address of the original token on the original chain.
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/IInterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface IInterchainTokenFactory is IUpgradable, IMulticall {
error RemoteDeploymentNotApproved();
error InvalidTokenId(bytes32 tokenId, bytes32 expectedTokenId);
error ZeroSupplyToken();
error NotToken(address tokenAddress);

/// @notice Emitted when a minter approves a deployer for a remote interchain token deployment that uses a custom destinationMinter address.
event DeployRemoteInterchainTokenApproval(
Expand Down
4 changes: 4 additions & 0 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ describe('InterchainTokenFactory', () => {
.withArgs(tokenId, tokenManagerAddress, LOCK_UNLOCK, params);
});

it('Should not register a non-existing token', async () => {
await expectRevert((gasOptions) => tokenFactory.registerCanonicalInterchainToken(tokenFactory.address, { gasOptions }), tokenFactory, "NotToken", [tokenFactory.address])
});

it('Should initiate a remote interchain token deployment with no original chain name provided', async () => {
const gasValue = 1234;
const payload = defaultAbiCoder.encode(
Expand Down
Loading