-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: addressed ackee's report #312
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -395,6 +395,26 @@ contract InterchainTokenService is | |||||
return _contractCallValue(payload); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @notice Executes operations based on the payload and selector. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
unrelated to the issue but noticed an improvement |
||||||
* @param commandId The unique message id. | ||||||
* @param sourceChain The chain where the transaction originates from. | ||||||
* @param sourceAddress The address of the remote ITS where the transaction originates from. | ||||||
* @param payload The encoded data payload for the transaction. | ||||||
*/ | ||||||
function execute( | ||||||
bytes32 commandId, | ||||||
string calldata sourceChain, | ||||||
string calldata sourceAddress, | ||||||
bytes calldata payload | ||||||
) external onlyRemoteService(sourceChain, sourceAddress) whenNotPaused { | ||||||
bytes32 payloadHash = keccak256(payload); | ||||||
|
||||||
if (!gateway.validateContractCall(commandId, sourceChain, sourceAddress, payloadHash)) revert NotApprovedByGateway(); | ||||||
|
||||||
_execute(commandId, sourceChain, sourceAddress, payload, payloadHash); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @notice Express executes operations based on the payload and selector. | ||||||
* @dev This function is `payable` because non-payable functions cannot be called in a multicall that calls other `payable` functions. | ||||||
|
@@ -646,26 +666,6 @@ contract InterchainTokenService is | |||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* @notice Executes operations based on the payload and selector. | ||||||
* @param commandId The unique message id. | ||||||
* @param sourceChain The chain where the transaction originates from. | ||||||
* @param sourceAddress The address of the remote ITS where the transaction originates from. | ||||||
* @param payload The encoded data payload for the transaction. | ||||||
*/ | ||||||
function execute( | ||||||
bytes32 commandId, | ||||||
string calldata sourceChain, | ||||||
string calldata sourceAddress, | ||||||
bytes calldata payload | ||||||
) external onlyRemoteService(sourceChain, sourceAddress) whenNotPaused { | ||||||
bytes32 payloadHash = keccak256(payload); | ||||||
|
||||||
if (!gateway.validateContractCall(commandId, sourceChain, sourceAddress, payloadHash)) revert NotApprovedByGateway(); | ||||||
|
||||||
_execute(commandId, sourceChain, sourceAddress, payload, payloadHash); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @notice Processes the payload data for a send token call. | ||||||
* @param commandId The unique message id. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
import { ITokenHandler } from './interfaces/ITokenHandler.sol'; | ||
import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol'; | ||
import { SafeTokenTransfer, SafeTokenTransferFrom, SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol'; | ||
import { ReentrancyGuard } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/ReentrancyGuard.sol'; | ||
import { Create3AddressFixed } from './utils/Create3AddressFixed.sol'; | ||
|
||
|
@@ -16,12 +16,11 @@ | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix above lint |
||
/** | ||
* @title TokenHandler | ||
* @notice This interface is responsible for handling tokens before initiating an interchain token transfer, or after receiving one. | ||
* @notice This contract is responsible for handling tokens before initiating an interchain token transfer, or after receiving one. | ||
*/ | ||
contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Create3AddressFixed { | ||
using SafeTokenTransferFrom for IERC20; | ||
using SafeTokenCall for IERC20; | ||
using SafeTokenTransfer for IERC20; | ||
|
||
/** | ||
* @notice This function gives token to a specified address from the token manager. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,9 @@ | |
|
||
pragma solidity ^0.8.0; | ||
|
||
import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol'; | ||
|
||
import { IInterchainToken } from '../interfaces/IInterchainToken.sol'; | ||
|
||
import { InterchainTokenStandard } from './InterchainTokenStandard.sol'; | ||
import { ERC20 } from './ERC20.sol'; | ||
import { ERC20Permit } from './ERC20Permit.sol'; | ||
import { Minter } from '../utils/Minter.sol'; | ||
|
||
|
@@ -16,9 +13,7 @@ import { Minter } from '../utils/Minter.sol'; | |
* @notice This contract implements an interchain token which extends InterchainToken functionality. | ||
* @dev This contract also inherits Minter and Implementation logic. | ||
*/ | ||
contract InterchainToken is InterchainTokenStandard, ERC20, ERC20Permit, Minter, IInterchainToken { | ||
using AddressBytes for bytes; | ||
|
||
contract InterchainToken is InterchainTokenStandard, ERC20Permit, Minter, IInterchainToken { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't want to change token bytecode unless necessary |
||
string public name; | ||
string public symbol; | ||
uint8 public decimals; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,7 @@ describe('InterchainToken', () => { | |
const contractBytecodeHash = keccak256(contractBytecode); | ||
|
||
const expected = { | ||
london: '0xa01cf28b0b6ce6dc3b466e995585d69486400d671fce0ea8d06beba583e6f3bb', | ||
london: '0x482146829055f052063003e9cf0ffaf798a12fb58088c2667566a135b9568355', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid changing contracts with fixed bytecode unless necessary. We want to avoid multiple versions of tokens to be active at the same time since we can't upgrade previous ones |
||
}[getEVMVersion()]; | ||
|
||
expect(contractBytecodeHash).to.be.equal(expected); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,18 +235,13 @@ describe('InterchainTokenFactory', () => { | |
it('Should register a token if the mint amount is zero and minter is the zero address', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update test name |
||
const salt = keccak256('0x123456'); | ||
tokenId = await tokenFactory.interchainTokenId(wallet.address, salt); | ||
const tokenAddress = await service.interchainTokenAddress(tokenId); | ||
const minterBytes = new Uint8Array(); | ||
const params = defaultAbiCoder.encode(['bytes', 'address'], [minterBytes, tokenAddress]); | ||
const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet); | ||
|
||
await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, 0, AddressZero)) | ||
.to.emit(service, 'InterchainTokenDeployed') | ||
.withArgs(tokenId, tokenAddress, AddressZero, name, symbol, decimals) | ||
.and.to.emit(service, 'TokenManagerDeployed') | ||
.withArgs(tokenId, tokenManager.address, NATIVE_INTERCHAIN_TOKEN, params); | ||
|
||
await checkRoles(tokenManager, AddressZero); | ||
await expectRevert( | ||
(gasOptions) => tokenFactory.deployInterchainToken(salt, name, symbol, decimals, 0, AddressZero, { gasOptions }), | ||
tokenFactory, | ||
'EmptyInterchainToken', | ||
[], | ||
); | ||
}); | ||
|
||
it('Should register a token if the mint amount is greater than zero and the minter is the zero address', async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ describe('Token Manager', () => { | |
const proxyBytecodeHash = keccak256(proxyBytecode); | ||
|
||
const expected = { | ||
london: '0x8080880884e00735cc1a34bdf5c1ea6c023db60a01cfa1e951ca41ecf5fd8836', | ||
london: '0x3b336208cc75ca67bdd39bdeed72871ce795e6e9cd28e20f811599ea51973ebf', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same proxy code shouldn't be changed |
||
}[getEVMVersion()]; | ||
|
||
expect(proxyBytecodeHash).to.be.equal(expected); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also mention this behaviour in the docstring