From 237907e10b1032105e61fb22b1bb414bc21a4737 Mon Sep 17 00:00:00 2001 From: Foivos Date: Sat, 4 Nov 2023 17:55:14 +0200 Subject: [PATCH] feat: removed operator from interchain token payload (#149) * removed operator from interchain token payload * added a small fix * Update contracts/InterchainTokenFactory.sol --------- Co-authored-by: Milap Sheth --- contracts/InterchainTokenFactory.sol | 24 ++--- contracts/InterchainTokenService.sol | 25 ++---- .../interfaces/IInterchainTokenFactory.sol | 4 +- .../interfaces/IInterchainTokenService.sol | 2 - contracts/interfaces/ITokenManager.sol | 12 +++ test/InterchainTokenFactory.js | 73 +++++++++------- test/TokenService.js | 87 +++++-------------- 7 files changed, 96 insertions(+), 131 deletions(-) diff --git a/contracts/InterchainTokenFactory.sol b/contracts/InterchainTokenFactory.sol index cf769009..9ff815cf 100644 --- a/contracts/InterchainTokenFactory.sol +++ b/contracts/InterchainTokenFactory.sol @@ -67,8 +67,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M string calldata symbol, uint8 decimals, uint256 mintAmount, - address distributor, - address operator + address distributor ) external payable { address sender = msg.sender; salt = interchainTokenSalt(chainNameHash, sender, salt); @@ -80,13 +79,18 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M distributorBytes = distributor.toBytes(); } - _deployInterchainToken(salt, '', name, symbol, decimals, distributorBytes, operator.toBytes(), 0); + _deployInterchainToken(salt, '', name, symbol, decimals, distributorBytes, 0); if (mintAmount > 0) { bytes32 tokenId = service.interchainTokenId(address(this), salt); IInterchainToken token = IInterchainToken(service.interchainTokenAddress(tokenId)); token.mint(address(this), mintAmount); token.transferDistributorship(distributor); + + ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId)); + tokenManager.removeFlowLimiter(address(this)); + if (distributor != address(0)) tokenManager.addFlowLimiter(distributor); + tokenManager.transferOperatorship(distributor); } } @@ -94,7 +98,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M string calldata originalChainName, bytes32 salt, address additionalDistributor, - address optionalOperator, string memory destinationChain, uint256 gasValue ) external payable { @@ -102,7 +105,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M string memory tokenSymbol; uint8 tokenDecimals; bytes memory distributor = new bytes(0); - bytes memory operator = new bytes(0); { bytes32 chainNameHash_; @@ -116,7 +118,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M bytes32 tokenId = service.interchainTokenId(address(this), salt); IInterchainToken token = IInterchainToken(service.interchainTokenAddress(tokenId)); - ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId)); tokenName = token.name(); tokenSymbol = token.symbol(); @@ -125,14 +126,9 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M if (!token.isDistributor(additionalDistributor)) revert NotDistributor(additionalDistributor); distributor = additionalDistributor.toBytes(); } - - if (optionalOperator != address(0)) { - if (!tokenManager.isOperator(optionalOperator)) revert NotOperator(optionalOperator); - operator = optionalOperator.toBytes(); - } } - _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, distributor, operator, gasValue); + _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, distributor, gasValue); } function _deployInterchainToken( @@ -142,7 +138,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M string memory tokenSymbol, uint8 tokenDecimals, bytes memory distributor, - bytes memory operator, uint256 gasValue ) internal { // slither-disable-next-line arbitrary-send-eth @@ -153,7 +148,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M tokenSymbol, tokenDecimals, distributor, - operator, gasValue ); } @@ -191,7 +185,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M string memory tokenSymbol = token.symbol(); uint8 tokenDecimals = token.decimals(); - _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, '', '', gasValue); + _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, '', gasValue); } function interchainTransfer( diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index dfeee88c..b686fef8 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -307,7 +307,6 @@ contract InterchainTokenService is string memory symbol, uint8 decimals, bytes memory distributor, - bytes memory operator, uint256 gasValue ) external payable whenNotPaused { bytes32 tokenId = interchainTokenId(msg.sender, salt); @@ -315,9 +314,9 @@ contract InterchainTokenService is if (bytes(destinationChain).length == 0) { address tokenAddress_ = _deployInterchainToken(tokenId, distributor, name, symbol, decimals); - _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(operator, tokenAddress_)); + _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(distributor, tokenAddress_)); } else { - _deployRemoteInterchainToken(tokenId, name, symbol, decimals, distributor, operator, destinationChain, gasValue); + _deployRemoteInterchainToken(tokenId, name, symbol, decimals, distributor, destinationChain, gasValue); } } @@ -642,20 +641,15 @@ contract InterchainTokenService is * @param payload The encoded data payload to be processed */ function _processDeployInterchainTokenPayload(bytes calldata payload) internal { - ( - , - bytes32 tokenId, - string memory name, - string memory symbol, - uint8 decimals, - bytes memory distributorBytes, - bytes memory operatorBytes - ) = abi.decode(payload, (uint256, bytes32, string, string, uint8, bytes, bytes)); + (, bytes32 tokenId, string memory name, string memory symbol, uint8 decimals, bytes memory distributorBytes) = abi.decode( + payload, + (uint256, bytes32, string, string, uint8, bytes) + ); address tokenAddress_; tokenAddress_ = _deployInterchainToken(tokenId, distributorBytes, name, symbol, decimals); - _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(operatorBytes, tokenAddress_)); + _deployTokenManager(tokenId, TokenManagerType.MINT_BURN, abi.encode(distributorBytes, tokenAddress_)); } /** @@ -722,7 +716,6 @@ contract InterchainTokenService is string memory symbol, uint8 decimals, bytes memory distributor, - bytes memory operator, string calldata destinationChain, uint256 gasValue ) internal { @@ -730,9 +723,9 @@ contract InterchainTokenService is validTokenManagerAddress(tokenId); // slither-disable-next-line reentrancy-events - emit InterchainTokenDeploymentStarted(tokenId, name, symbol, decimals, distributor, operator, destinationChain); + emit InterchainTokenDeploymentStarted(tokenId, name, symbol, decimals, distributor, destinationChain); - bytes memory payload = abi.encode(MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, distributor, operator); + bytes memory payload = abi.encode(MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, distributor); _callContract(destinationChain, payload, gasValue); } diff --git a/contracts/interfaces/IInterchainTokenFactory.sol b/contracts/interfaces/IInterchainTokenFactory.sol index 3b50c747..870745fa 100644 --- a/contracts/interfaces/IInterchainTokenFactory.sol +++ b/contracts/interfaces/IInterchainTokenFactory.sol @@ -23,15 +23,13 @@ interface IInterchainTokenFactory { string calldata symbol, uint8 decimals, uint256 mintAmount, - address distributor, - address operator + address distributor ) external payable; function deployRemoteInterchainToken( string calldata originalChainName, bytes32 salt, address additionalDistributor, - address optionalOperator, string memory destinationChain, uint256 gasValue ) external payable; diff --git a/contracts/interfaces/IInterchainTokenService.sol b/contracts/interfaces/IInterchainTokenService.sol index fc65fbc0..89eec342 100644 --- a/contracts/interfaces/IInterchainTokenService.sol +++ b/contracts/interfaces/IInterchainTokenService.sol @@ -71,7 +71,6 @@ interface IInterchainTokenService is string tokenSymbol, uint8 tokenDecimals, bytes distributor, - bytes operator, string destinationChain ); event TokenManagerDeployed(bytes32 indexed tokenId, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params); @@ -172,7 +171,6 @@ interface IInterchainTokenService is string memory symbol, uint8 decimals, bytes memory distributor, - bytes memory operator, uint256 gasValue ) external payable; diff --git a/contracts/interfaces/ITokenManager.sol b/contracts/interfaces/ITokenManager.sol index 2e138ca0..4bab9af0 100644 --- a/contracts/interfaces/ITokenManager.sol +++ b/contracts/interfaces/ITokenManager.sol @@ -99,6 +99,18 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen */ function takeToken(address sourceAddress, uint256 amount) external returns (uint256); + /** + * @notice This function adds a flow limiter for this TokenManager. Can only be called by the operator. + * @param flowLimiter the address of the new flow limiter. + */ + function addFlowLimiter(address flowLimiter) external; + + /** + * @notice This function removes a flow limiter for this TokenManager. Can only be called by the operator. + * @param flowLimiter the address of an existing flow limiter. + */ + function removeFlowLimiter(address flowLimiter) external; + /** * @notice This function sets the flow limit for this TokenManager. Can only be called by the operator. * @param flowLimit_ the maximum difference between the tokens flowing in and/or out at any given interval of time (6h) diff --git a/test/InterchainTokenFactory.js b/test/InterchainTokenFactory.js index 05d5c40d..99ac8ecf 100644 --- a/test/InterchainTokenFactory.js +++ b/test/InterchainTokenFactory.js @@ -73,8 +73,8 @@ describe('InterchainTokenFactory', () => { const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x', '0x'], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x'], ); await expect(tokenFactory.registerCanonicalInterchainToken(token.address)) @@ -87,7 +87,7 @@ describe('InterchainTokenFactory', () => { }), ) .to.emit(service, 'InterchainTokenDeploymentStarted') - .withArgs(tokenId, name, symbol, decimals, '0x', '0x', destinationChain) + .withArgs(tokenId, name, symbol, decimals, '0x', destinationChain) .and.to.emit(gasService, 'NativeGasPaidForContractCall') .withArgs(service.address, destinationChain, service.address, keccak256(payload), gasValue, wallet.address) .and.to.emit(gateway, 'ContractCall') @@ -176,17 +176,16 @@ describe('InterchainTokenFactory', () => { let tokenId; const mintAmount = 1234; const distributor = new Wallet(getRandomBytes32()).address; - const operator = new Wallet(getRandomBytes32()).address; it('Should register a token', async () => { const salt = keccak256('0x'); tokenId = await tokenFactory.interchainTokenId(wallet.address, salt); const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt); - const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]); + const params = defaultAbiCoder.encode(['bytes', 'address'], [tokenFactory.address, tokenAddress]); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); const token = await getContractAt('InterchainToken', tokenAddress, wallet); - await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, distributor, operator)) + await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, distributor)) .to.emit(service, 'InterchainTokenDeployed') .withArgs(tokenId, tokenAddress, tokenFactory.address, name, symbol, decimals) .and.to.emit(service, 'TokenManagerDeployed') @@ -194,11 +193,17 @@ describe('InterchainTokenFactory', () => { .and.to.emit(token, 'Transfer') .withArgs(AddressZero, tokenFactory.address, mintAmount) .and.to.emit(tokenManager, 'RolesAdded') - .withArgs(operator, (1 << OPERATOR_ROLE) | (1 << FLOW_LIMITER_ROLE)) + .withArgs(distributor, 1 << FLOW_LIMITER_ROLE) + .and.to.emit(tokenManager, 'RolesAdded') + .withArgs(distributor, 1 << OPERATOR_ROLE) .and.to.emit(token, 'RolesAdded') .withArgs(distributor, 1 << DISTRIBUTOR_ROLE) .and.to.emit(token, 'RolesRemoved') - .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE); + .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << OPERATOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << FLOW_LIMITER_ROLE); await expect(tokenFactory.interchainTransfer(tokenId, '', distributor, mintAmount, 0)) .to.emit(token, 'Transfer') @@ -215,11 +220,11 @@ describe('InterchainTokenFactory', () => { const salt = keccak256('0x12'); tokenId = await tokenFactory.interchainTokenId(wallet.address, salt); const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt); - let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); + let params = defaultAbiCoder.encode(['bytes', 'address'], [tokenFactory.address, tokenAddress]); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); const token = await getContractAt('InterchainToken', tokenAddress, wallet); - await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address, wallet.address)) + await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address)) .to.emit(service, 'InterchainTokenDeployed') .withArgs(tokenId, tokenAddress, tokenFactory.address, name, symbol, decimals) .and.to.emit(service, 'TokenManagerDeployed') @@ -228,30 +233,30 @@ describe('InterchainTokenFactory', () => { .withArgs(AddressZero, tokenFactory.address, mintAmount) .and.to.emit(token, 'RolesAdded') .withArgs(wallet.address, 1 << DISTRIBUTOR_ROLE) + .and.to.emit(tokenManager, 'RolesAdded') + .withArgs(wallet.address, 1 << OPERATOR_ROLE) + .and.to.emit(tokenManager, 'RolesAdded') + .withArgs(wallet.address, 1 << FLOW_LIMITER_ROLE) .and.to.emit(token, 'RolesRemoved') - .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE); + .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << OPERATOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << FLOW_LIMITER_ROLE); params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [ - MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, - tokenId, - name, - symbol, - decimals, - wallet.address.toLowerCase(), - wallet.address.toLowerCase(), - ], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, wallet.address.toLowerCase()], ); await expect( - tokenFactory.deployRemoteInterchainToken(chainName, salt, wallet.address, wallet.address, destinationChain, gasValue, { + tokenFactory.deployRemoteInterchainToken(chainName, salt, wallet.address, destinationChain, gasValue, { value: gasValue, }), ) .to.emit(service, 'InterchainTokenDeploymentStarted') - .withArgs(tokenId, name, symbol, decimals, wallet.address.toLowerCase(), wallet.address.toLowerCase(), destinationChain) + .withArgs(tokenId, name, symbol, decimals, wallet.address.toLowerCase(), destinationChain) .and.to.emit(gasService, 'NativeGasPaidForContractCall') .withArgs(service.address, destinationChain, service.address, keccak256(payload), gasValue, wallet.address) .and.to.emit(gateway, 'ContractCall') @@ -264,11 +269,11 @@ describe('InterchainTokenFactory', () => { const salt = keccak256('0x1245'); tokenId = await tokenFactory.interchainTokenId(wallet.address, salt); const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt); - let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); + let params = defaultAbiCoder.encode(['bytes', 'address'], [tokenFactory.address, tokenAddress]); const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); const token = await getContractAt('InterchainToken', tokenAddress, wallet); - await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address, wallet.address)) + await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address)) .to.emit(service, 'InterchainTokenDeployed') .withArgs(tokenId, tokenAddress, tokenFactory.address, name, symbol, decimals) .and.to.emit(service, 'TokenManagerDeployed') @@ -277,22 +282,30 @@ describe('InterchainTokenFactory', () => { .withArgs(AddressZero, tokenFactory.address, mintAmount) .and.to.emit(token, 'RolesAdded') .withArgs(wallet.address, 1 << DISTRIBUTOR_ROLE) + .and.to.emit(tokenManager, 'RolesAdded') + .withArgs(wallet.address, 1 << OPERATOR_ROLE) + .and.to.emit(tokenManager, 'RolesAdded') + .withArgs(wallet.address, 1 << FLOW_LIMITER_ROLE) .and.to.emit(token, 'RolesRemoved') - .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE); + .withArgs(tokenFactory.address, 1 << DISTRIBUTOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << OPERATOR_ROLE) + .and.to.emit(tokenManager, 'RolesRemoved') + .withArgs(tokenFactory.address, 1 << FLOW_LIMITER_ROLE); params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x', wallet.address], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x'], ); await expect( - tokenFactory.deployRemoteInterchainToken(chainName, salt, AddressZero, wallet.address, destinationChain, gasValue, { + tokenFactory.deployRemoteInterchainToken(chainName, salt, AddressZero, destinationChain, gasValue, { value: gasValue, }), ) .to.emit(service, 'InterchainTokenDeploymentStarted') - .withArgs(tokenId, name, symbol, decimals, '0x', wallet.address.toLowerCase(), destinationChain) + .withArgs(tokenId, name, symbol, decimals, '0x', destinationChain) .and.to.emit(gasService, 'NativeGasPaidForContractCall') .withArgs(service.address, destinationChain, service.address, keccak256(payload), gasValue, wallet.address) .and.to.emit(gateway, 'ContractCall') diff --git a/test/TokenService.js b/test/TokenService.js index 20d446bc..0cee287a 100644 --- a/test/TokenService.js +++ b/test/TokenService.js @@ -391,7 +391,7 @@ describe('Interchain Token Service', () => { const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); - await expect(service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, wallet.address, 0)) + await expect(service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, 0)) .to.emit(service, 'InterchainTokenDeployed') .withArgs(tokenId, tokenAddress, wallet.address, tokenName, tokenSymbol, tokenDecimals) .to.emit(service, 'TokenManagerDeployed') @@ -415,17 +415,7 @@ describe('Interchain Token Service', () => { await expectRevert( (gasOptions) => - service.deployInterchainToken( - salt, - '', - tokenName, - tokenSymbol, - tokenDecimals, - wallet.address, - wallet.address, - 0, - gasOptions, - ), + service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, 0, gasOptions), service, 'Pause', ); @@ -440,7 +430,7 @@ describe('Interchain Token Service', () => { const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]); const expectedTokenManagerAddress = await service.tokenManagerAddress(tokenId); - await expect(service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, wallet.address, 0)) + await expect(service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, 0)) .to.emit(service, 'TokenManagerDeployed') .withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params); const tokenManagerAddress = await service.validTokenManagerAddress(tokenId); @@ -453,17 +443,7 @@ describe('Interchain Token Service', () => { const revertData = keccak256(toUtf8Bytes('AlreadyDeployed()')).substring(0, 10); await expectRevert( (gasOptions) => - service.deployInterchainToken( - salt, - '', - tokenName, - tokenSymbol, - tokenDecimals, - wallet.address, - wallet.address, - 0, - gasOptions, - ), + service.deployInterchainToken(salt, '', tokenName, tokenSymbol, tokenDecimals, wallet.address, 0, gasOptions), service, 'InterchainTokenDeploymentFailed', [revertData], @@ -476,7 +456,6 @@ describe('Interchain Token Service', () => { const tokenSymbol = 'TN'; const tokenDecimals = 13; const distributor = '0x12345678'; - const operator = '0x674930ab'; const gasValue = 1234; const salt = getRandomBytes32(); let txPaused; @@ -499,26 +478,16 @@ describe('Interchain Token Service', () => { const tokenId = await service.interchainTokenId(wallet.address, salt); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, operator], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor], ); await expect( - service.deployInterchainToken( - salt, - destinationChain, - tokenName, - tokenSymbol, - tokenDecimals, - distributor, - operator, - gasValue, - { - value: gasValue, - }, - ), + service.deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, distributor, gasValue, { + value: gasValue, + }), ) .to.emit(service, 'InterchainTokenDeploymentStarted') - .withArgs(tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, operator, destinationChain) + .withArgs(tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, destinationChain) .and.to.emit(gasService, 'NativeGasPaidForContractCall') .withArgs(service.address, destinationChain, service.address, keccak256(payload), gasValue, wallet.address) .and.to.emit(gateway, 'ContractCall') @@ -531,20 +500,10 @@ describe('Interchain Token Service', () => { await expectRevert( (gasOptions) => - service.deployInterchainToken( - salt, - destinationChain, - tokenName, - tokenSymbol, - tokenDecimals, - distributor, - operator, - gasValue, - { - ...gasOptions, - value: gasValue, - }, - ), + service.deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, distributor, gasValue, { + ...gasOptions, + value: gasValue, + }), service, 'Pause', ); @@ -573,11 +532,10 @@ describe('Interchain Token Service', () => { it('Should revert on receiving a remote interchain token depoloyment if not approved by the gateway', async () => { const tokenId = getRandomBytes32(); const distributor = wallet.address; - const operator = wallet.address; const commandId = getRandomBytes32(); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, operator], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor], ); await expectRevert( @@ -596,8 +554,8 @@ describe('Interchain Token Service', () => { const tokenAddress = await service.interchainTokenAddress(tokenId); const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, operator], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor], ); const commandId = await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload); @@ -615,12 +573,11 @@ describe('Interchain Token Service', () => { const tokenId = getRandomBytes32(); const tokenManagerAddress = await service.tokenManagerAddress(tokenId); const distributor = '0x'; - const operator = wallet.address; const tokenAddress = await service.interchainTokenAddress(tokenId); - const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]); + const params = defaultAbiCoder.encode(['bytes', 'address'], [distributor, tokenAddress]); const payload = defaultAbiCoder.encode( - ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'], - [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor, operator], + ['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'], + [MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, distributor], ); const commandId = await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload); @@ -631,7 +588,7 @@ describe('Interchain Token Service', () => { .withArgs(tokenId, tokenManagerAddress, MINT_BURN, params); const tokenManager = await getContractAt('TokenManager', tokenManagerAddress, wallet); expect(await tokenManager.tokenAddress()).to.equal(tokenAddress); - expect(await tokenManager.hasRole(operator, OPERATOR_ROLE)).to.be.true; + expect(await tokenManager.hasRole(service.address, OPERATOR_ROLE)).to.be.true; }); it('Should be able to receive a remote interchain token depoloyment with a mint/burn token manager with empty distributor and operator', async () => {