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

fix(its)!: restrict token deployments on ITS for Amplifier chains #304

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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