From a1720a981ba251bff4a9c7954321c9e268b9efed Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Dec 2023 19:00:37 -0500 Subject: [PATCH 1/3] fix: add missing imports to factory interface (#240) (#243) * fix: add missing imports to factory interface * update docs --- contracts/InterchainTokenFactory.sol | 40 +++++++------ .../interfaces/IInterchainTokenFactory.sol | 13 ++++- .../interfaces/IInterchainTokenService.sol | 8 ++- docs/index.md | 56 +++++++++++++++++-- package-lock.json | 4 +- package.json | 2 +- 6 files changed, 95 insertions(+), 28 deletions(-) diff --git a/contracts/InterchainTokenFactory.sol b/contracts/InterchainTokenFactory.sol index cb9f2e19..23106863 100644 --- a/contracts/InterchainTokenFactory.sol +++ b/contracts/InterchainTokenFactory.sol @@ -25,7 +25,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M using SafeTokenTransferFrom for IInterchainToken; using SafeTokenCall for IInterchainToken; - IInterchainTokenService public immutable service; + IInterchainTokenService public immutable interchainTokenService; bytes32 public immutable chainNameHash; IAxelarGateway public immutable gateway; @@ -36,14 +36,15 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M /** * @notice Constructs the InterchainTokenFactory contract. - * @param interchainTokenServiceAddress The address of the interchain token service. + * @param interchainTokenService_ The address of the interchain token service. */ - constructor(address interchainTokenServiceAddress) { - if (interchainTokenServiceAddress == address(0)) revert ZeroAddress(); - service = IInterchainTokenService(interchainTokenServiceAddress); + constructor(address interchainTokenService_) { + if (interchainTokenService_ == address(0)) revert ZeroAddress(); - chainNameHash = service.chainNameHash(); - gateway = service.gateway(); + interchainTokenService = IInterchainTokenService(interchainTokenService_); + + chainNameHash = interchainTokenService.chainNameHash(); + gateway = interchainTokenService.gateway(); } /** @@ -82,7 +83,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M * @return tokenId The ID of the interchain token. */ function interchainTokenId(address deployer, bytes32 salt) public view returns (bytes32 tokenId) { - tokenId = service.interchainTokenId(TOKEN_FACTORY_DEPLOYER, interchainTokenSalt(chainNameHash, deployer, salt)); + tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, interchainTokenSalt(chainNameHash, deployer, salt)); } /** @@ -91,7 +92,10 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M * @return tokenId The ID of the canonical interchain token. */ function canonicalInterchainTokenId(address tokenAddress) public view returns (bytes32 tokenId) { - tokenId = service.interchainTokenId(TOKEN_FACTORY_DEPLOYER, canonicalInterchainTokenSalt(chainNameHash, tokenAddress)); + tokenId = interchainTokenService.interchainTokenId( + TOKEN_FACTORY_DEPLOYER, + canonicalInterchainTokenSalt(chainNameHash, tokenAddress) + ); } /** @@ -101,7 +105,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M * @return tokenAddress The address of the interchain token. */ function interchainTokenAddress(address deployer, bytes32 salt) public view returns (address tokenAddress) { - tokenAddress = service.interchainTokenAddress(interchainTokenId(deployer, salt)); + tokenAddress = interchainTokenService.interchainTokenAddress(interchainTokenId(deployer, salt)); } /** @@ -136,8 +140,8 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M tokenId = _deployInterchainToken(salt, '', name, symbol, decimals, minterBytes, 0); if (initialSupply > 0) { - IInterchainToken token = IInterchainToken(service.interchainTokenAddress(tokenId)); - ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId)); + IInterchainToken token = IInterchainToken(interchainTokenService.interchainTokenAddress(tokenId)); + ITokenManager tokenManager = ITokenManager(interchainTokenService.tokenManagerAddress(tokenId)); token.mint(sender, initialSupply); @@ -182,9 +186,9 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M address sender = msg.sender; salt = interchainTokenSalt(chainNameHash_, sender, salt); - tokenId = service.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt); + tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt); - IInterchainToken token = IInterchainToken(service.interchainTokenAddress(tokenId)); + IInterchainToken token = IInterchainToken(interchainTokenService.interchainTokenAddress(tokenId)); tokenName = token.name(); tokenSymbol = token.symbol(); @@ -221,7 +225,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M uint256 gasValue ) internal returns (bytes32 tokenId) { // slither-disable-next-line arbitrary-send-eth - tokenId = service.deployInterchainToken{ value: gasValue }( + tokenId = interchainTokenService.deployInterchainToken{ value: gasValue }( salt, destinationChain, tokenName, @@ -243,7 +247,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M if (_isGatewayToken(tokenAddress)) revert GatewayToken(tokenAddress); bytes32 salt = canonicalInterchainTokenSalt(chainNameHash, tokenAddress); - tokenId = service.deployTokenManager(salt, '', TokenManagerType.LOCK_UNLOCK, params, 0); + tokenId = interchainTokenService.deployTokenManager(salt, '', TokenManagerType.LOCK_UNLOCK, params, 0); } /** @@ -272,8 +276,8 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M } // This ensures that the token manager has been deployed by this address, so it's safe to trust it. salt = canonicalInterchainTokenSalt(chainNameHash_, originalTokenAddress); - tokenId = service.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt); - token = IInterchainToken(service.validTokenAddress(tokenId)); + tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt); + token = IInterchainToken(interchainTokenService.validTokenAddress(tokenId)); } // The 3 lines below will revert if the token does not exist. diff --git a/contracts/interfaces/IInterchainTokenFactory.sol b/contracts/interfaces/IInterchainTokenFactory.sol index 6fc48eb7..3e792036 100644 --- a/contracts/interfaces/IInterchainTokenFactory.sol +++ b/contracts/interfaces/IInterchainTokenFactory.sol @@ -2,17 +2,28 @@ pragma solidity ^0.8.0; +import { IMulticall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IMulticall.sol'; +import { IUpgradable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IUpgradable.sol'; + +import { IInterchainTokenService } from './IInterchainTokenService.sol'; + /** * @title IInterchainTokenFactory Interface * @notice This interface defines functions for deploying new interchain tokens and managing their token managers. */ -interface IInterchainTokenFactory { +interface IInterchainTokenFactory is IUpgradable, IMulticall { error ZeroAddress(); error InvalidChainName(); error NotMinter(address minter); error NotOperator(address operator); error GatewayToken(address tokenAddress); + /** + * @notice Returns the address of the interchain token service. + * @return IInterchainTokenService The address of the interchain token service. + */ + function interchainTokenService() external view returns (IInterchainTokenService); + /** * @notice Returns the hash of the chain name. * @return bytes32 The hash of the chain name. diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index d3199f62..1e29b194 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import { IAxelarValuedExpressExecutable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarValuedExpressExecutable.sol'; -import { IContractIdentifier } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IContractIdentifier.sol'; import { IMulticall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IMulticall.sol'; import { IPausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IPausable.sol'; import { IUpgradable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IUpgradable.sol'; @@ -26,7 +25,6 @@ interface IInterchainTokenService is IOperator, IPausable, IMulticall, - IContractIdentifier, IAddressTracker, IUpgradable { @@ -115,6 +113,12 @@ interface IInterchainTokenService is */ function tokenHandler() external view returns (address tokenHandlerAddress); + /** + * @notice Returns the address of the interchain token factory. + * @return address The address of the interchain token factory. + */ + function interchainTokenFactory() external view returns (address); + /** * @notice Returns the hash of the chain name. * @return bytes32 The hash of the chain name. diff --git a/docs/index.md b/docs/index.md index 747bbf51..28d3a181 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,12 +4,19 @@ This contract is responsible for deploying new interchain tokens and managing their token managers. -### service +### interchainTokenService ```solidity -contract IInterchainTokenService service +contract IInterchainTokenService interchainTokenService ``` +Returns the address of the interchain token service. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | + ### chainNameHash ```solidity @@ -44,7 +51,7 @@ bytes32 PREFIX_INTERCHAIN_TOKEN_SALT ### constructor ```solidity -constructor(address interchainTokenServiceAddress) public +constructor(address interchainTokenService_) public ``` Constructs the InterchainTokenFactory contract. @@ -53,7 +60,7 @@ Constructs the InterchainTokenFactory contract. | Name | Type | Description | | ---- | ---- | ----------- | -| interchainTokenServiceAddress | address | The address of the interchain token service. | +| interchainTokenService_ | address | The address of the interchain token service. | ### contractId @@ -340,6 +347,13 @@ contract IAxelarGasService gasService address interchainTokenFactory ``` +Returns the address of the interchain token factory. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | + ### chainNameHash ```solidity @@ -2270,6 +2284,12 @@ error TokenIdZero() error TokenNameEmpty() ``` +### TokenSymbolEmpty + +```solidity +error TokenSymbolEmpty() +``` + ### AlreadyInitialized ```solidity @@ -2499,6 +2519,20 @@ error NotOperator(address operator) error GatewayToken(address tokenAddress) ``` +### interchainTokenService + +```solidity +function interchainTokenService() external view returns (contract IInterchainTokenService) +``` + +Returns the address of the interchain token service. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | contract IInterchainTokenService | IInterchainTokenService The address of the interchain token service. | + ### chainNameHash ```solidity @@ -2920,6 +2954,20 @@ Returns the address of TokenHandler implementation. | ---- | ---- | ----------- | | tokenHandlerAddress | address | The address of the token handler contract. | +### interchainTokenFactory + +```solidity +function interchainTokenFactory() external view returns (address) +``` + +Returns the address of the interchain token factory. + +#### Return Values + +| Name | Type | Description | +| ---- | ---- | ----------- | +| [0] | address | address The address of the interchain token factory. | + ### chainNameHash ```solidity diff --git a/package-lock.json b/package-lock.json index 3a18d0ac..8ccef5b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@axelar-network/interchain-token-service", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@axelar-network/interchain-token-service", - "version": "1.2.0", + "version": "1.2.1", "license": "MIT", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.2.1", diff --git a/package.json b/package.json index 79a1b2b2..0a3ba423 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@axelar-network/interchain-token-service", - "version": "1.2.0", + "version": "1.2.1", "repository": { "type": "git", "url": "https://github.com/axelarnetwork/interchain-token-service" From 50f946775b37b93f05bdc19a6e7354d02e78f766 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Sun, 17 Dec 2023 19:01:47 -0500 Subject: [PATCH 2/3] ci: backport ci fixes (#244) * ci: use env var setter in gh actions (#241) * fix: add missing imports to factory interface * ci: use env var setter in gh actions * ci: improve var reference in workflow (#242) * test: action * direct trigger * rename * improve var reference --- .github/workflows/publish-bytecode.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-bytecode.yaml b/.github/workflows/publish-bytecode.yaml index f9c51bb3..cff05355 100644 --- a/.github/workflows/publish-bytecode.yaml +++ b/.github/workflows/publish-bytecode.yaml @@ -1,4 +1,4 @@ -name: Publish Compiled Bytecode +name: 'Publish Bytecode' on: release: @@ -35,15 +35,20 @@ jobs: - name: Clean artifacts run: npm run clean:artifacts + - name: Get release tag + run: | + TAG=${{ github.ref }} + echo "release_tag=${TAG#refs/tags/}" >> "$GITHUB_ENV" + - name: Create zip file working-directory: ./artifacts run: | - zip -r Bytecode-${GITHUB_REF#refs/tags/}.zip * + zip -r Bytecode-${{ release_tag }}.zip * - name: Upload Bytecode to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ./artifacts/Bytecode-${GITHUB_REF#refs/tags/}.zip - tag: ${GITHUB_REF#refs/tags/} + file: ./artifacts/Bytecode-${{ release_tag }}.zip + tag: ${{ release_tag }} overwrite: true From 471d60de22ca2687b414969e1b7a43a79d245f65 Mon Sep 17 00:00:00 2001 From: axelar-cicd-bot Date: Mon, 18 Dec 2023 00:03:08 +0000 Subject: [PATCH 3/3] v1.2.1