Skip to content

Commit

Permalink
lint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Mar 28, 2024
1 parent ce9f001 commit cde0be6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 44 deletions.
11 changes: 1 addition & 10 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ import { Pausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/util
import { InterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/InterchainAddressTracker.sol';

import { IInterchainTokenService } from './interfaces/IInterchainTokenService.sol';
import { ITokenManagerProxy } from './interfaces/ITokenManagerProxy.sol';
import { ITokenHandler } from './interfaces/ITokenHandler.sol';
import { ITokenManagerDeployer } from './interfaces/ITokenManagerDeployer.sol';
import { IInterchainTokenDeployer } from './interfaces/IInterchainTokenDeployer.sol';
import { IInterchainTokenExecutable } from './interfaces/IInterchainTokenExecutable.sol';
import { IInterchainTokenExpressExecutable } from './interfaces/IInterchainTokenExpressExecutable.sol';
import { ITokenManager } from './interfaces/ITokenManager.sol';
import { IERC20Named } from './interfaces/IERC20Named.sol';

import { Operator } from './utils/Operator.sol';

Expand Down Expand Up @@ -402,13 +400,7 @@ contract InterchainTokenService is
IERC20 token;
{
(bool success, bytes memory returnData) = tokenHandler.delegatecall(
abi.encodeWithSelector(
ITokenHandler.transferTokenFrom.selector,
tokenId,
msg.sender,
destinationAddress,
amount
)
abi.encodeWithSelector(ITokenHandler.transferTokenFrom.selector, tokenId, msg.sender, destinationAddress, amount)
);
if (!success) revert TokenHandlerFailed(returnData);
(amount, token) = abi.decode(returnData, (uint256, IERC20));
Expand Down Expand Up @@ -1073,7 +1065,6 @@ contract InterchainTokenService is
* @dev Takes token from a sender via the token service. `tokenOnly` indicates if the caller should be restricted to the token only.
*/
function _takeToken(bytes32 tokenId, address from, uint256 amount, bool tokenOnly) internal returns (uint256, string memory symbol) {

(bool success, bytes memory data) = tokenHandler.delegatecall(
abi.encodeWithSelector(ITokenHandler.takeToken.selector, tokenId, tokenOnly, from, amount)
);
Expand Down
15 changes: 2 additions & 13 deletions contracts/TokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { IERC20MintableBurnable } from './interfaces/IERC20MintableBurnable.sol'
import { IERC20BurnableFrom } from './interfaces/IERC20BurnableFrom.sol';
import { IERC20Named } from './interfaces/IERC20Named.sol';


/**
* @title TokenHandler
* @notice This interface is responsible for handling tokens before initiating an interchain token transfer, or after receiving one.
Expand Down Expand Up @@ -43,11 +42,7 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea
* @return address the address of the token.
*/
// slither-disable-next-line locked-ether
function giveToken(
bytes32 tokenId,
address to,
uint256 amount
) external payable returns (uint256, address) {
function giveToken(bytes32 tokenId, address to, uint256 amount) external payable returns (uint256, address) {
address tokenManager = _create3Address(tokenId);

(uint256 tokenManagerType, address tokenAddress) = ITokenManagerProxy(tokenManager).getImplementationTypeAndTokenAddress();
Expand Down Expand Up @@ -99,7 +94,6 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea
address from,
uint256 amount
) external payable returns (uint256, string memory symbol) {

address tokenManager = _create3Address(tokenId);
(uint256 tokenManagerType, address tokenAddress) = ITokenManagerProxy(tokenManager).getImplementationTypeAndTokenAddress();

Expand Down Expand Up @@ -154,12 +148,7 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea
* @return address The address of the token corresponding to the input tokenId.
*/
// slither-disable-next-line locked-ether
function transferTokenFrom(
bytes32 tokenId,
address from,
address to,
uint256 amount
) external payable returns (uint256, address) {
function transferTokenFrom(bytes32 tokenId, address from, address to, uint256 amount) external payable returns (uint256, address) {
address tokenManager = _create3Address(tokenId);
(uint256 tokenManagerType, address tokenAddress) = ITokenManagerProxy(tokenManager).getImplementationTypeAndTokenAddress();
if (
Expand Down
14 changes: 3 additions & 11 deletions contracts/interfaces/ITokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ interface ITokenHandler {
* @return uint256 The amount of token actually given, which could be different for certain token type.
* @return address the address of the token.
*/
function giveToken(
bytes32 tokenId,
address to,
uint256 amount
) external payable returns (uint256, address);
function giveToken(bytes32 tokenId, address to, uint256 amount) external payable returns (uint256, address);

/**
* @notice This function takes token from a specified address to the token manager.
Expand Down Expand Up @@ -58,12 +54,8 @@ interface ITokenHandler {
* @return address The address of the token corresponding to the input tokenId.
*/
// slither-disable-next-line locked-ether
function transferTokenFrom(
bytes32 tokenId,
address from,
address to,
uint256 amount
) external payable returns (uint256, address);
function transferTokenFrom(bytes32 tokenId, address from, address to, uint256 amount) external payable returns (uint256, address);

/**
* @notice This function prepares a token manager after it is deployed
* @param tokenManagerType The token manager type.
Expand Down
20 changes: 10 additions & 10 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ describe('Interchain Token Service', () => {
it(`Should revert on transmit send token when not called by interchain token`, async () => {
const errorSignatureHash = id('NotToken(address,address)');
const selector = errorSignatureHash.substring(0, 10);
const errorData = defaultAbiCoder.encode(['address', 'address'], [wallet.address, token.address])
const errorData = defaultAbiCoder.encode(['address', 'address'], [wallet.address, token.address]);

await expectRevert(
(gasOptions) =>
Expand Down Expand Up @@ -2588,10 +2588,10 @@ describe('Interchain Token Service', () => {

it('Should be able to send token only if it does not trigger the mint limit', async () => {
await service.interchainTransfer(tokenId, destinationChain, destinationAddress, sendAmount, '0x', 0).then((tx) => tx.wait);

const errorSignatureHash = id('FlowLimitExceeded(uint256,uint256,address)');
const selector = errorSignatureHash.substring(0, 10);
const errorData = defaultAbiCoder.encode(['uint256', 'uint256', 'address'], [flowLimit, 2 * sendAmount, tokenManager.address])
const errorData = defaultAbiCoder.encode(['uint256', 'uint256', 'address'], [flowLimit, 2 * sendAmount, tokenManager.address]);

await expectRevert(
(gasOptions) => service.interchainTransfer(tokenId, destinationChain, destinationAddress, sendAmount, '0x', 0, gasOptions),
Expand Down Expand Up @@ -2631,14 +2631,14 @@ describe('Interchain Token Service', () => {

const errorSignatureHash = id('FlowLimitExceeded(uint256,uint256,address)');
const selector = errorSignatureHash.substring(0, 10);
const errorData = defaultAbiCoder.encode(['uint256', 'uint256', 'address'], [
(5 * sendAmount) / 2,
3 * sendAmount,
tokenManager.address,
])

const errorData = defaultAbiCoder.encode(
['uint256', 'uint256', 'address'],
[(5 * sendAmount) / 2, 3 * sendAmount, tokenManager.address],
);

await expectRevert((gasOptions) => receiveToken(2 * sendAmount, gasOptions), service, 'GiveTokenFailed', [selector + errorData.substring(2)]);
await expectRevert((gasOptions) => receiveToken(2 * sendAmount, gasOptions), service, 'GiveTokenFailed', [
selector + errorData.substring(2),
]);
});

it('Should be able to set flow limits for each token manager', async () => {
Expand Down

0 comments on commit cde0be6

Please sign in to comment.