diff --git a/contracts/interchain-token/InterchainToken.sol b/contracts/interchain-token/InterchainToken.sol index a1fc607a..0d8447e2 100644 --- a/contracts/interchain-token/InterchainToken.sol +++ b/contracts/interchain-token/InterchainToken.sol @@ -3,8 +3,6 @@ pragma solidity ^0.8.0; import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol'; -import { IImplementation } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IImplementation.sol'; -import { Implementation } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/Implementation.sol'; import { IInterchainToken } from '../interfaces/IInterchainToken.sol'; @@ -17,7 +15,7 @@ import { Distributable } from '../utils/Distributable.sol'; * @notice This contract implements a interchain token which extends InterchainToken functionality. * This contract also inherits Distributable and Implementation logic. */ -contract InterchainToken is BaseInterchainToken, ERC20Permit, Implementation, Distributable, IInterchainToken { +contract InterchainToken is BaseInterchainToken, ERC20Permit, Distributable, IInterchainToken { using AddressBytes for bytes; string public name; @@ -25,13 +23,30 @@ contract InterchainToken is BaseInterchainToken, ERC20Permit, Implementation, Di uint8 public decimals; address internal tokenManager_; - bytes32 private constant CONTRACT_ID = keccak256('interchain-token'); + // bytes32(uint256(keccak256('interchain-token-initialized')) - 1); + bytes32 internal constant INITIALIZED_SLOT = 0xc778385ecb3e8cecb82223fa1f343ec6865b2d64c65b0c15c7e8aef225d9e214; + + constructor() { + // Make the implementation act as if it has been setup already to disallow calls to init() (even though that wouldn't achieve anything really) + _initialize(); + } /** - * @notice Getter for the contract id. + * @notice returns true if the contract has be setup. */ - function contractId() external pure override returns (bytes32) { - return CONTRACT_ID; + function _isInitialized() internal view returns (bool initialized) { + assembly { + initialized := sload(INITIALIZED_SLOT) + } + } + + /** + * @notice sets initialized to true, to allow only a single init. + */ + function _initialize() internal { + assembly { + sstore(INITIALIZED_SLOT, true) + } } /** @@ -44,20 +59,30 @@ contract InterchainToken is BaseInterchainToken, ERC20Permit, Implementation, Di /** * @notice Setup function to initialize contract parameters - * @param params The setup parameters in bytes - * The setup params include tokenManager, distributor, tokenName, symbol, decimals, mintAmount and mintTo + * @param tokenManagerAddress The address of the token manager of this token + * @param distributor The address of the token distributor + * @param tokenName The name of the token + * @param tokenSymbol The symbopl of the token + * @param tokenDecimals The decimals of the token */ - function setup(bytes calldata params) external override(Implementation, IImplementation) onlyProxy { - address distributor; - address tokenManagerAddress; - string memory tokenName; - (tokenManagerAddress, distributor, tokenName, symbol, decimals) = abi.decode(params, (address, address, string, string, uint8)); + function init( + address tokenManagerAddress, + address distributor, + string calldata tokenName, + string calldata tokenSymbol, + uint8 tokenDecimals + ) external { + if (_isInitialized()) revert AlreadyInitialized(); + + _initialize(); if (tokenManagerAddress == address(0)) revert TokenManagerAddressZero(); if (bytes(tokenName).length == 0) revert TokenNameEmpty(); tokenManager_ = tokenManagerAddress; name = tokenName; + symbol = tokenSymbol; + decimals = tokenDecimals; if (distributor != address(0)) _addDistributor(distributor); _addDistributor(tokenManagerAddress); diff --git a/contracts/interfaces/IInterchainToken.sol b/contracts/interfaces/IInterchainToken.sol index 0c5c16a3..bca8c3a8 100644 --- a/contracts/interfaces/IInterchainToken.sol +++ b/contracts/interfaces/IInterchainToken.sol @@ -2,8 +2,6 @@ pragma solidity ^0.8.0; -import { IImplementation } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IImplementation.sol'; - import { IInterchainTokenStandard } from './IInterchainTokenStandard.sol'; import { IDistributable } from './IDistributable.sol'; import { IERC20MintableBurnable } from './IERC20MintableBurnable.sol'; @@ -12,9 +10,10 @@ import { IERC20Named } from './IERC20Named.sol'; /** * @title IInterchainToken */ -interface IInterchainToken is IInterchainTokenStandard, IDistributable, IERC20MintableBurnable, IERC20Named, IImplementation { +interface IInterchainToken is IInterchainTokenStandard, IDistributable, IERC20MintableBurnable, IERC20Named { error TokenManagerAddressZero(); error TokenNameEmpty(); + error AlreadyInitialized(); /** * @notice Getter for the tokenManager used for this token. @@ -22,4 +21,20 @@ interface IInterchainToken is IInterchainTokenStandard, IDistributable, IERC20Mi * @return tokenManager_ the TokenManager called to facilitate cross chain transfers. */ function tokenManager() external view returns (address tokenManager_); + + /** + * @notice Setup function to initialize contract parameters + * @param tokenManagerAddress The address of the token manager of this token + * @param distributor The address of the token distributor + * @param tokenName The name of the token + * @param tokenSymbol The symbopl of the token + * @param tokenDecimals The decimals of the token + */ + function init( + address tokenManagerAddress, + address distributor, + string calldata tokenName, + string calldata tokenSymbol, + uint8 tokenDecimals + ) external; } diff --git a/contracts/interfaces/IInterchainTokenDeployer.sol b/contracts/interfaces/IInterchainTokenDeployer.sol index a259a05e..7ee737f7 100644 --- a/contracts/interfaces/IInterchainTokenDeployer.sol +++ b/contracts/interfaces/IInterchainTokenDeployer.sol @@ -38,5 +38,5 @@ interface IInterchainTokenDeployer { string calldata name, string calldata symbol, uint8 decimals - ) external payable returns (address tokenAddress); + ) external returns (address tokenAddress); } diff --git a/contracts/proxies/InterchainTokenProxy.sol b/contracts/proxies/InterchainTokenProxy.sol deleted file mode 100644 index 76c0cdc1..00000000 --- a/contracts/proxies/InterchainTokenProxy.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.0; - -import { IImplementation } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IImplementation.sol'; -import { FixedProxy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/FixedProxy.sol'; - -/** - * @title InterchainTokenProxy - * @dev Proxy contract for InterchainToken contracts. Inherits from FixedProxy. - */ -contract InterchainTokenProxy is FixedProxy { - bytes32 private constant CONTRACT_ID = keccak256('interchain-token'); - - /** - * @dev Constructs the InterchainTokenProxy contract. - * @param implementationAddress Address of the InterchainToken implementation - * @param params Initialization parameters for the InterchainToken contract - */ - constructor(address implementationAddress, bytes memory params) FixedProxy(implementationAddress) { - if (implementationAddress == address(0)) revert InvalidImplementation(); - - (bool success, ) = implementationAddress.delegatecall(abi.encodeWithSelector(IImplementation.setup.selector, params)); - if (!success) revert SetupFailed(); - } - - /** - * @notice Getter for the contract id. - */ - function contractId() internal pure override returns (bytes32) { - return CONTRACT_ID; - } -} diff --git a/contracts/test/InterchainTokenTest.sol b/contracts/test/BaseInterchainTokenTest.sol similarity index 95% rename from contracts/test/InterchainTokenTest.sol rename to contracts/test/BaseInterchainTokenTest.sol index 1e68ad79..bd2e2847 100644 --- a/contracts/test/InterchainTokenTest.sol +++ b/contracts/test/BaseInterchainTokenTest.sol @@ -6,7 +6,7 @@ import { BaseInterchainToken } from '../interchain-token/BaseInterchainToken.sol import { Distributable } from '../utils/Distributable.sol'; import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; -contract InterchainTokenTest is BaseInterchainToken, Distributable, IERC20MintableBurnable { +contract BaseInterchainTokenTest is BaseInterchainToken, Distributable, IERC20MintableBurnable { address public tokenManager_; bool internal tokenManagerRequiresApproval_ = true; string public name; diff --git a/contracts/test/HardCodedConstantsTest.sol b/contracts/test/HardCodedConstantsTest.sol index 9c4bad32..eb80c612 100644 --- a/contracts/test/HardCodedConstantsTest.sol +++ b/contracts/test/HardCodedConstantsTest.sol @@ -4,36 +4,31 @@ pragma solidity ^0.8.0; import { TokenManagerLiquidityPool } from '../token-manager/TokenManagerLiquidityPool.sol'; -import { Distributable } from '../utils/Distributable.sol'; import { FlowLimit } from '../utils/FlowLimit.sol'; -import { Operatable } from '../utils/Operatable.sol'; +import { InterchainToken } from '../interchain-token/InterchainToken.sol'; error Invalid(); contract TestTokenManager is TokenManagerLiquidityPool { - string public constant NAME = 'TestTokenManager'; + string public placeholder; constructor(address interchainTokenService_) TokenManagerLiquidityPool(interchainTokenService_) { if (LIQUIDITY_POOL_SLOT != uint256(keccak256('liquidity-pool-slot')) - 1) revert Invalid(); } } -contract TestDistributable is Distributable { - string public constant NAME = 'TestDistributable'; - - constructor() {} -} - contract TestFlowLimit is FlowLimit { - string public constant NAME = 'TestFlowLimit'; + string public placeholder; constructor() { if (FLOW_LIMIT_SLOT != uint256(keccak256('flow-limit')) - 1) revert Invalid(); } } -contract TestOperatable is Operatable { - string public constant NAME = 'TestOperatable'; +contract TestInterchainToken is InterchainToken { + string public placeholder; - constructor() {} + constructor() { + if (INITIALIZED_SLOT != bytes32(uint256(keccak256('interchain-token-initialized')) - 1)) revert Invalid(); + } } diff --git a/contracts/test/utils/OperatableTest.sol b/contracts/test/utils/OperatableTest.sol index bf1ab158..d2455a74 100644 --- a/contracts/test/utils/OperatableTest.sol +++ b/contracts/test/utils/OperatableTest.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import { Operatable } from '../../utils/Operatable.sol'; -contract OperatorableTest is Operatable { +contract OperatableTest is Operatable { uint256 public nonce; constructor(address operator) { diff --git a/contracts/utils/InterchainTokenDeployer.sol b/contracts/utils/InterchainTokenDeployer.sol index ca66edb8..326bb79a 100644 --- a/contracts/utils/InterchainTokenDeployer.sol +++ b/contracts/utils/InterchainTokenDeployer.sol @@ -5,8 +5,7 @@ pragma solidity ^0.8.0; import { Create3 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Create3.sol'; import { IInterchainTokenDeployer } from '../interfaces/IInterchainTokenDeployer.sol'; - -import { InterchainTokenProxy } from '../proxies/InterchainTokenProxy.sol'; +import { IInterchainToken } from '../interfaces/IInterchainToken.sol'; /** * @title InterchainTokenDeployer @@ -21,6 +20,7 @@ contract InterchainTokenDeployer is IInterchainTokenDeployer, Create3 { */ constructor(address implementationAddress_) { if (implementationAddress_ == address(0)) revert AddressZero(); + implementationAddress = implementationAddress_; } @@ -34,7 +34,6 @@ contract InterchainTokenDeployer is IInterchainTokenDeployer, Create3 { * @param decimals Decimals of the token * @return tokenAddress Address of the deployed token */ - // slither-disable-next-line locked-ether function deployInterchainToken( bytes32 salt, address tokenManager, @@ -42,13 +41,27 @@ contract InterchainTokenDeployer is IInterchainTokenDeployer, Create3 { string calldata name, string calldata symbol, uint8 decimals - ) external payable returns (address tokenAddress) { - bytes memory params = abi.encode(tokenManager, distributor, name, symbol, decimals); - // slither-disable-next-line too-many-digits - bytes memory bytecode = bytes.concat(type(InterchainTokenProxy).creationCode, abi.encode(implementationAddress, params)); + ) external returns (address tokenAddress) { + // The minimal proxy bytecode is the same as https://github.com/OpenZeppelin/openzeppelin-contracts/blob/94697be8a3f0dfcd95dfb13ffbd39b5973f5c65d/contracts/proxy/Clones.sol#L28 + // The minimal proxy bytecode is 0x37 = 55 bytes long + bytes memory bytecode = new bytes(0x37); + address implementation = implementationAddress; + + /// @solidity memory-safe-assembly + assembly { + // The first 0x20 = 32 bytes (0x00 - 0x19) are reserved for the length. + // The next 0x14 = 20 bytes (0x20 - 0x33) are the ones below. + mstore(add(bytecode, 0x20), shl(0x60, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)) + // The next 0x14 = 20 bytes (0x34 - 0x47) are the implementation address. + mstore(add(bytecode, 0x34), shl(0x60, implementation)) + // The last 0x0f = 15 bytes (0x48 - 0x56) are the ones below. + mstore(add(bytecode, 0x48), shl(0x88, 0x5af43d82803e903d91602b57fd5bf3)) + } tokenAddress = _create3(bytecode, salt); if (tokenAddress.code.length == 0) revert TokenDeploymentFailed(); + + IInterchainToken(tokenAddress).init(tokenManager, distributor, name, symbol, decimals); } function deployedAddress(bytes32 salt) external view returns (address tokenAddress) { diff --git a/docs/index.md b/docs/index.md index 5b1f4b8f..e43d387f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3501,7 +3501,7 @@ string lastMessage function _executeWithInterchainToken(string sourceChain, bytes sourceAddress, bytes data, bytes32 tokenId, address token, uint256 amount) internal ``` -## InterchainTokenTest +## BaseInterchainTokenTest ### tokenManager_ @@ -3791,7 +3791,7 @@ fallback() external payable virtual receive() external payable virtual ``` -## OperatorableTest +## OperatableTest ### nonce diff --git a/test/InterchainToken.js b/test/InterchainToken.js index bc189eeb..8e3ef81d 100644 --- a/test/InterchainToken.js +++ b/test/InterchainToken.js @@ -1,13 +1,8 @@ 'use strict'; -const chai = require('chai'); const { ethers } = require('hardhat'); -const { - getContractAt, - utils: { keccak256, toUtf8Bytes }, -} = ethers; -const { expect } = chai; -const { getRandomBytes32, expectRevert, getGasOptions } = require('./utils'); +const { getContractAt } = ethers; +const { getRandomBytes32, expectRevert } = require('./utils'); const { deployContract } = require('../scripts/deploy'); describe('InterchainToken', () => { @@ -19,7 +14,6 @@ describe('InterchainToken', () => { const mintAmount = 123; let token; - let tokenProxy; let owner; @@ -35,7 +29,6 @@ describe('InterchainToken', () => { const tokenAddress = await interchainTokenDeployer.deployedAddress(salt); token = await getContractAt('InterchainToken', tokenAddress, owner); - tokenProxy = await getContractAt('InterchainTokenProxy', tokenAddress, owner); await interchainTokenDeployer .deployInterchainToken(salt, owner.address, owner.address, name, symbol, decimals) @@ -44,41 +37,21 @@ describe('InterchainToken', () => { await (await token.mint(owner.address, mintAmount)).wait(); }); - describe('Interchain Token Proxy', () => { - it('should revert if interchain token implementation is invalid', async () => { - const invalidInterchainToken = await deployContract(owner, 'InvalidInterchainToken'); - interchainTokenDeployer = await deployContract(owner, 'InterchainTokenDeployer', [invalidInterchainToken.address]); - - const salt = getRandomBytes32(); - - await expect( - interchainTokenDeployer.deployInterchainToken(salt, owner.address, owner.address, name, symbol, decimals, getGasOptions()), - ).to.be.reverted; - }); - - it('should revert if interchain token setup fails', async () => { - const params = '0x1234'; - await expectRevert( - (gasOptions) => deployContract(owner, 'InterchainTokenProxy', [interchainToken.address, params, gasOptions]), - tokenProxy, - 'SetupFailed', - ); - }); - - it('should return the correct contract ID', async () => { - const contractID = await token.contractId(); - const hash = keccak256(toUtf8Bytes('interchain-token')); - expect(contractID).to.equal(hash); - }); - }); - describe('Interchain Token', () => { - it('revert on setup if not called by the proxy', async () => { - const implementationAddress = await tokenProxy.implementation(); + it('revert on init if not called by the proxy', async () => { + const implementationAddress = await interchainTokenDeployer.implementationAddress(); const implementation = await getContractAt('InterchainToken', implementationAddress, owner); - const params = '0x'; - await expectRevert((gasOptions) => implementation.setup(params, gasOptions), token, 'NotProxy'); + const tokenManagerAddress = owner.address; + const distributor = owner.address; + const tokenName = 'name'; + const tokenSymbol = 'symbol'; + const tokenDecimals = 7; + await expectRevert( + (gasOptions) => implementation.init(tokenManagerAddress, distributor, tokenName, tokenSymbol, tokenDecimals, gasOptions), + implementation, + 'AlreadyInitialized', + ); }); }); }); diff --git a/test/InterchainTokenFactory.js b/test/InterchainTokenFactory.js index 7a01f5c1..27631cf2 100644 --- a/test/InterchainTokenFactory.js +++ b/test/InterchainTokenFactory.js @@ -44,7 +44,7 @@ describe('InterchainTokenFactory', () => { const tokenCap = BigInt(1e18); async function deployToken() { - token = await deployContract(wallet, 'InterchainTokenTest', [name, symbol, decimals, wallet.address]); + token = await deployContract(wallet, 'BaseInterchainTokenTest', [name, symbol, decimals, wallet.address]); tokenId = await tokenFactory.canonicalInterchainTokenId(token.address); tokenManagerAddress = await service.tokenManagerAddress(tokenId); await (await token.mint(wallet.address, tokenCap)).wait(); diff --git a/test/TokenService.js b/test/TokenService.js index c47567e1..56c43376 100644 --- a/test/TokenService.js +++ b/test/TokenService.js @@ -56,7 +56,12 @@ describe('Interchain Token Service', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManager.address, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); await (await service.deployTokenManager(salt, '', LOCK_UNLOCK, params, 0)).wait(); @@ -101,7 +106,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); @@ -654,7 +664,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const tx = service.deployTokenManager(salt, '', LOCK_UNLOCK, params, 0); @@ -677,7 +692,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const tx = service.deployTokenManager(salt, '', MINT_BURN, params, 0); @@ -700,7 +720,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const tx = service.deployTokenManager(salt, '', MINT_BURN_FROM, params, 0); @@ -755,7 +780,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const tx = service.deployTokenManager(salt, '', LOCK_UNLOCK, params, 0); @@ -781,7 +811,12 @@ describe('Interchain Token Service', () => { const salt = getRandomBytes32(); const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); await expectRevert((gasOptions) => service.deployTokenManager(salt, '', LOCK_UNLOCK, params, 0, gasOptions), service, 'Pause'); @@ -952,7 +987,12 @@ describe('Interchain Token Service', () => { const tokenDecimals = 13; const tokenId = getRandomBytes32(); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const payload = defaultAbiCoder.encode( @@ -976,7 +1016,12 @@ describe('Interchain Token Service', () => { const tokenDecimals = 13; const tokenId = getRandomBytes32(); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManagerAddress]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManagerAddress, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); const payload = defaultAbiCoder.encode( diff --git a/test/TokenServiceUpgradeFlow.js b/test/TokenServiceUpgradeFlow.js index 4a6fc3b5..a8dd2ac2 100644 --- a/test/TokenServiceUpgradeFlow.js +++ b/test/TokenServiceUpgradeFlow.js @@ -48,7 +48,12 @@ describe('Interchain Token Service Upgrade Flow', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); - const token = await deployContract(wallet, 'InterchainTokenTest', [tokenName, tokenSymbol, tokenDecimals, tokenManager.address]); + const token = await deployContract(wallet, 'BaseInterchainTokenTest', [ + tokenName, + tokenSymbol, + tokenDecimals, + tokenManager.address, + ]); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, token.address]); await expect(service.deployTokenManager(salt, '', 0, params, 0)) diff --git a/test/UtilsTest.js b/test/UtilsTest.js index 7435845b..a64e1e06 100644 --- a/test/UtilsTest.js +++ b/test/UtilsTest.js @@ -25,14 +25,10 @@ describe('Operatable', () => { let operatorRole; before(async () => { - test = await deployContract(ownerWallet, 'OperatorableTest', [ownerWallet.address]); + test = await deployContract(ownerWallet, 'OperatableTest', [ownerWallet.address]); operatorRole = await test.operatorRole(); }); - it('Should calculate hardcoded constants correctly', async () => { - await expect(deployContract(ownerWallet, `TestOperatable`, [])).to.not.be.reverted; - }); - it('Should be able to run the onlyOperatorable function as the operator', async () => { await (await test.testOperatorable()).wait(); @@ -103,10 +99,6 @@ describe('Distributable', () => { distributorRole = await test.distributorRole(); }); - it('Should calculate hardcoded constants correctly', async () => { - await expect(deployContract(ownerWallet, `TestDistributable`, [])).to.not.be.reverted; - }); - it('Should be able to run the onlyDistributor function as the distributor', async () => { await (await test.testDistributable()).wait(); @@ -266,7 +258,6 @@ describe('InterchainTokenDeployer', () => { const tokenAddress = await interchainTokenDeployer.deployedAddress(salt); const token = await getContractAt('InterchainToken', tokenAddress, ownerWallet); - const tokenProxy = await getContractAt('InterchainTokenProxy', tokenAddress, ownerWallet); await expect(interchainTokenDeployer.deployInterchainToken(salt, tokenManager, tokenManager, name, symbol, decimals)) .and.to.emit(token, 'RolesAdded') @@ -274,7 +265,6 @@ describe('InterchainTokenDeployer', () => { .to.emit(token, 'RolesAdded') .withArgs(tokenManager, 1 << DISTRIBUTOR_ROLE); - expect(await tokenProxy.implementation()).to.equal(interchainToken.address); expect(await token.name()).to.equal(name); expect(await token.symbol()).to.equal(symbol); expect(await token.decimals()).to.equal(decimals);