Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Oct 27, 2024
1 parent 626da8a commit a0efe34
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 81 deletions.
22 changes: 2 additions & 20 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,7 @@ contract InterchainTokenService is

(IGatewayCaller.MetadataVersion metadataVersion, bytes memory data) = _decodeMetadata(metadata);

_transmitInterchainTransfer(
tokenId,
msg.sender,
destinationChain,
destinationAddress,
amount,
metadataVersion,
data,
gasValue
);
_transmitInterchainTransfer(tokenId, msg.sender, destinationChain, destinationAddress, amount, metadataVersion, data, gasValue);
}

/**
Expand Down Expand Up @@ -547,16 +538,7 @@ contract InterchainTokenService is

(IGatewayCaller.MetadataVersion metadataVersion, bytes memory data) = _decodeMetadata(metadata);

_transmitInterchainTransfer(
tokenId,
sourceAddress,
destinationChain,
destinationAddress,
amount,
metadataVersion,
data,
msg.value
);
_transmitInterchainTransfer(tokenId, sourceAddress, destinationChain, destinationAddress, amount, metadataVersion, data, msg.value);
}

/*************\
Expand Down
8 changes: 1 addition & 7 deletions contracts/TokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ITokenManager } from './interfaces/ITokenManager.sol';
import { ITokenManagerProxy } from './interfaces/ITokenManagerProxy.sol';
import { IERC20MintableBurnable } from './interfaces/IERC20MintableBurnable.sol';
import { IERC20BurnableFrom } from './interfaces/IERC20BurnableFrom.sol';
import { IERC20Named } from './interfaces/IERC20Named.sol';

/**
* @title TokenHandler
Expand Down Expand Up @@ -75,12 +74,7 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea
* @return uint256 The amount of token actually taken, which could be different for certain token type.
*/
// slither-disable-next-line locked-ether
function takeToken(
bytes32 tokenId,
bool tokenOnly,
address from,
uint256 amount
) external payable returns (uint256) {
function takeToken(bytes32 tokenId, bool tokenOnly, address from, uint256 amount) external payable returns (uint256) {
address tokenManager = _create3Address(tokenId);
(uint256 tokenManagerType, address tokenAddress) = ITokenManagerProxy(tokenManager).getImplementationTypeAndTokenAddress();

Expand Down
7 changes: 1 addition & 6 deletions contracts/interfaces/ITokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ interface ITokenHandler {
* @return uint256 The amount of token actually taken, which could be different for certain token type.
*/
// slither-disable-next-line locked-ether
function takeToken(
bytes32 tokenId,
bool tokenOnly,
address from,
uint256 amount
) external payable returns (uint256);
function takeToken(bytes32 tokenId, bool tokenOnly, address from, uint256 amount) external payable returns (uint256);

/**
* @notice This function transfers token from and to a specified address.
Expand Down
41 changes: 0 additions & 41 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { ethers } = require('hardhat');
const { deployContract } = require('./deploy');
const { AddressZero } = ethers.constants;
const { defaultAbiCoder, keccak256 } = ethers.utils;

function getRandomBytes32() {
Expand All @@ -26,46 +24,7 @@ async function approveContractCall(
return commandId;
}

async function approveContractCallWithMint(
gateway,
sourceChain,
sourceAddress,
contractAddress,
payload,
symbol,
amount,
sourceTxHash = getRandomBytes32(),
sourceEventIndex = 0,
commandId = getRandomBytes32(),
) {
const params = defaultAbiCoder.encode(
['string', 'string', 'address', 'bytes32', 'string', 'uint256', 'bytes32', 'uint256'],
[sourceChain, sourceAddress, contractAddress, keccak256(payload), symbol, amount, sourceTxHash, sourceEventIndex],
);
await gateway.approveContractCallWithMint(params, commandId).then((tx) => tx.wait);

return commandId;
}

async function deployGatewayToken(gateway, tokenName, tokenSymbol, tokenDecimals, walletForExternal) {
let tokenAddress = AddressZero;

if (walletForExternal) {
const token = await deployContract(walletForExternal, 'GatewayToken', [tokenName, tokenSymbol, tokenDecimals]);
tokenAddress = token.address;
}

const params = defaultAbiCoder.encode(
['string', 'string', 'uint8', 'uint256', 'address', 'uint256'],
[tokenName, tokenSymbol, tokenDecimals, 0, tokenAddress, 0],
);
const commandId = getRandomBytes32();
await gateway.deployToken(params, commandId).then((tx) => tx.wait);
}

module.exports = {
getRandomBytes32,
approveContractCall,
approveContractCallWithMint,
deployGatewayToken,
};
3 changes: 1 addition & 2 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ const {
getContractAt,
Wallet,
constants: { AddressZero },
utils: { defaultAbiCoder, keccak256, toUtf8Bytes, id },
utils: { defaultAbiCoder, keccak256, toUtf8Bytes },
} = ethers;
const { deployAll, deployContract } = require('../scripts/deploy');
const { getRandomBytes32, expectRevert } = require('./utils');
const {
MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN,
NATIVE_INTERCHAIN_TOKEN,
LOCK_UNLOCK,
GATEWAY,
MINTER_ROLE,
OPERATOR_ROLE,
FLOW_LIMITER_ROLE,
Expand Down
5 changes: 2 additions & 3 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
} = ethers;
const Create3Deployer = require('@axelar-network/axelar-gmp-sdk-solidity/artifacts/contracts/deploy/Create3Deployer.sol/Create3Deployer.json');
const { getCreate3Address } = require('@axelar-network/axelar-gmp-sdk-solidity');
const { approveContractCall, approveContractCallWithMint } = require('../scripts/utils');
const { approveContractCall } = require('../scripts/utils');
const { getRandomBytes32, getRandomInt, expectRevert, gasReporter, getEVMVersion } = require('./utils');
const { deployAll, deployContract, deployInterchainTokenService } = require('../scripts/deploy');
const {
Expand Down Expand Up @@ -2973,8 +2973,7 @@ describe('Interchain Token Service', () => {
describe('Call contract with token value', () => {
it('Should revert on contract call value', async () => {
await expectRevert(
(gasOptions) =>
service.contractCallWithTokenValue(sourceChain, 'sourceAddress', '0x', 'TEST', 1, gasOptions),
(gasOptions) => service.contractCallWithTokenValue(sourceChain, 'sourceAddress', '0x', 'TEST', 1, gasOptions),
service,
'NotSupported',
);
Expand Down
2 changes: 0 additions & 2 deletions test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const MINT_BURN_FROM = 1;
const LOCK_UNLOCK = 2;
const LOCK_UNLOCK_FEE_ON_TRANSFER = 3;
const MINT_BURN = 4;
const GATEWAY = 5;

const MINTER_ROLE = 0;
const OPERATOR_ROLE = 1;
Expand All @@ -35,7 +34,6 @@ module.exports = {
LOCK_UNLOCK,
LOCK_UNLOCK_FEE_ON_TRANSFER,
MINT_BURN,
GATEWAY,
MINTER_ROLE,
OPERATOR_ROLE,
FLOW_LIMITER_ROLE,
Expand Down

0 comments on commit a0efe34

Please sign in to comment.