Skip to content

Commit

Permalink
fix(its)!: restrict token deployments on ITS for Amplifier chains (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth authored Nov 18, 2024
1 parent 564800b commit 2da5b3a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hungry-bats-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/interchain-token-service': patch
---

ITS deployInterchainToken is restricted from being on ITS on Amplifier chains. The ITS Factory should be used instead
7 changes: 6 additions & 1 deletion contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ contract InterchainTokenService is
) external payable whenNotPaused returns (bytes32 tokenId) {
address deployer = msg.sender;

if (deployer == interchainTokenFactory) deployer = TOKEN_FACTORY_DEPLOYER;
if (deployer == interchainTokenFactory) {
deployer = TOKEN_FACTORY_DEPLOYER;
} else if (trustedAddressHash(chainName()) == ITS_HUB_ROUTING_IDENTIFIER_HASH) {
// Currently, deployments directly on ITS contract (instead of ITS Factory) are restricted for ITS contracts deployed on Amplifier, i.e registered with the Hub
revert NotSupported();
}

tokenId = interchainTokenId(deployer, salt);

Expand Down
15 changes: 15 additions & 0 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,21 @@ describe('Interchain Token Service', () => {
'EmptyTokenSymbol',
);
});

it('Should revert when deploying an interchain token on chain native to ITS hub', async () => {
await expect(service.setTrustedAddress(chainName, ITS_HUB_ROUTING_IDENTIFIER))
.to.emit(service, 'TrustedAddressSet')
.withArgs(chainName, ITS_HUB_ROUTING_IDENTIFIER);

await expectRevert(
(gasOptions) =>
service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, 0, gasOptions),
service,
'NotSupported',
);

await expect(service.removeTrustedAddress(chainName)).to.emit(service, 'TrustedAddressRemoved').withArgs(chainName);
});
});

describe('Deploy and Register remote Interchain Token', () => {
Expand Down

0 comments on commit 2da5b3a

Please sign in to comment.