Skip to content

Commit

Permalink
feat(its): remove gateway token check for registerCanonicalInterchain…
Browse files Browse the repository at this point in the history
…Token (#285)
  • Loading branch information
ahramy authored Oct 1, 2024
1 parent 92cbbf1 commit c58ed5e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
14 changes: 1 addition & 13 deletions contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
*/
function registerCanonicalInterchainToken(address tokenAddress) external payable returns (bytes32 tokenId) {
bytes memory params = abi.encode('', tokenAddress);

if (_isGatewayToken(tokenAddress)) revert GatewayToken(tokenAddress);

bytes32 salt = canonicalInterchainTokenSalt(chainNameHash, tokenAddress);

tokenId = interchainTokenService.deployTokenManager(salt, '', TokenManagerType.LOCK_UNLOCK, params, 0);
}

Expand Down Expand Up @@ -338,14 +336,4 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M

tokenId = interchainTokenService.deployTokenManager(salt, '', TokenManagerType.GATEWAY, params, 0);
}

/**
* @notice Checks if a given token is a gateway token.
* @param token The address of the token to check.
* @return bool True if the token is a gateway token, false otherwise.
*/
function _isGatewayToken(address token) internal view returns (bool) {
string memory symbol = IInterchainToken(token).symbol();
return token == gateway.tokenAddresses(symbol);
}
}
40 changes: 0 additions & 40 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,46 +153,6 @@ describe('InterchainTokenFactory', () => {
.and.to.emit(gateway, 'ContractCall')
.withArgs(service.address, destinationChain, service.address, keccak256(payload), payload);
});

it('Should revert when trying to register a canonical lock/unlock gateway token', async () => {
const tokenCap = 0;
const mintLimit = 0;
const tokenAddress = token.address;

const params = defaultAbiCoder.encode(
['string', 'string', 'uint8', 'uint256', 'address', 'uint256'],
[name, symbol, decimals, tokenCap, tokenAddress, mintLimit],
);
await gateway.deployToken(params, getRandomBytes32()).then((tx) => tx.wait);

await expectRevert(
(gasOptions) => tokenFactory.registerCanonicalInterchainToken(tokenAddress, gasOptions),
tokenFactory,
'GatewayToken',
[tokenAddress],
);
});

it('Should revert when trying to register a canonical mint/burn gateway token', async () => {
const tokenCap = 0;
let tokenAddress = AddressZero;
const mintLimit = 0;
const newSymbol = 'NewSymbol';
const params = defaultAbiCoder.encode(
['string', 'string', 'uint8', 'uint256', 'address', 'uint256'],
[name, newSymbol, decimals, tokenCap, tokenAddress, mintLimit],
);
await gateway.deployToken(params, getRandomBytes32()).then((tx) => tx.wait);

tokenAddress = await gateway.tokenAddresses(newSymbol);

await expectRevert(
(gasOptions) => tokenFactory.registerCanonicalInterchainToken(tokenAddress, gasOptions),
tokenFactory,
'GatewayToken',
[tokenAddress],
);
});
});

describe('Gateway Interchain Token Factory', async () => {
Expand Down

0 comments on commit c58ed5e

Please sign in to comment.