Skip to content

Commit

Permalink
refactor: remove ITS interface dep in BaseInterchainToken
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Dec 6, 2023
1 parent a1abfc2 commit 9688abf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
10 changes: 5 additions & 5 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ contract InterchainTokenService is
* @param destinationChain The destination chain to send the tokens to.
* @param destinationAddress The address on the destination chain to send the tokens to.
* @param amount The amount of tokens to be transferred.
* @param metadata Additional data to be passed along with the transfer. If provided with a bytes4(0) version prefix, it will execute the destination contract.
* @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).
*/
function interchainTransfer(
bytes32 tokenId,
Expand Down Expand Up @@ -491,13 +491,13 @@ contract InterchainTokenService is

/**
* @notice Transmit an interchain transfer for the given tokenId.
* @dev Only callable by a token registered under tokenId.
* @param tokenId The tokenId of the TokenManager (which must be the msg.sender).
* @param sourceAddress The address where the token is coming from, which will also be used for reimbursement of gas.
* @dev Only callable by a token registered under a tokenId.
* @param tokenId The tokenId of the token (which must be the msg.sender).
* @param sourceAddress The address where the token is coming from.
* @param destinationChain The name of the chain to send tokens to.
* @param destinationAddress The destinationAddress for the interchainTransfer.
* @param amount The amount of token to give.
* @param metadata The data to be passed to the destination.
* @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).
*/
function transmitInterchainTransfer(
bytes32 tokenId,
Expand Down
24 changes: 17 additions & 7 deletions contracts/interchain-token/BaseInterchainToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity ^0.8.0;

import { IInterchainTokenStandard } from '../interfaces/IInterchainTokenStandard.sol';
import { IInterchainTokenService } from '../interfaces/IInterchainTokenService.sol';
import { ITransmitInterchainToken } from '../interfaces/ITransmitInterchainToken.sol';

/**
* @title An example implementation of the IInterchainTokenStandard.
Expand Down Expand Up @@ -44,9 +44,14 @@ abstract contract BaseInterchainToken is IInterchainTokenStandard {

_beforeInterchainTransfer(msg.sender, destinationChain, recipient, amount, metadata);

IInterchainTokenService service = IInterchainTokenService(interchainTokenService());

service.transmitInterchainTransfer{ value: msg.value }(interchainTokenId(), sender, destinationChain, recipient, amount, metadata);
ITransmitInterchainToken(interchainTokenService()).transmitInterchainTransfer{ value: msg.value }(
interchainTokenId(),
sender,
destinationChain,
recipient,
amount,
metadata
);
}

/**
Expand All @@ -70,9 +75,14 @@ abstract contract BaseInterchainToken is IInterchainTokenStandard {

_beforeInterchainTransfer(sender, destinationChain, recipient, amount, metadata);

IInterchainTokenService service = IInterchainTokenService(interchainTokenService());

service.transmitInterchainTransfer{ value: msg.value }(interchainTokenId(), sender, destinationChain, recipient, amount, metadata);
ITransmitInterchainToken(interchainTokenService()).transmitInterchainTransfer{ value: msg.value }(
interchainTokenId(),
sender,
destinationChain,
recipient,
amount,
metadata
);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions contracts/interchain-token/InterchainToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/
import { IInterchainToken } from '../interfaces/IInterchainToken.sol';

import { BaseInterchainToken } from './BaseInterchainToken.sol';
import { ERC20 } from './ERC20.sol';
import { ERC20Permit } from './ERC20Permit.sol';
import { Minter } from '../utils/Minter.sol';

Expand All @@ -16,7 +15,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 BaseInterchainToken, ERC20, ERC20Permit, Minter, IInterchainToken {
contract InterchainToken is BaseInterchainToken, ERC20Permit, Minter, IInterchainToken {
using AddressBytes for bytes;

string public name;
Expand Down
23 changes: 3 additions & 20 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IContractIdentifier } from '@axelar-network/axelar-gmp-sdk-solidity/con
import { IMulticall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IMulticall.sol';
import { IPausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IPausable.sol';

import { ITransmitInterchainToken } from './ITransmitInterchainToken.sol';
import { ITokenManagerType } from './ITokenManagerType.sol';
import { ITokenManagerImplementation } from './ITokenManagerImplementation.sol';
import { IAddressTracker } from './IAddressTracker.sol';
Expand All @@ -16,6 +17,7 @@ import { IAddressTracker } from './IAddressTracker.sol';
* @notice Interface for the Interchain Token Service
*/
interface IInterchainTokenService is
ITransmitInterchainToken,
ITokenManagerType,
ITokenManagerImplementation,
IAxelarValuedExpressExecutable,
Expand Down Expand Up @@ -193,7 +195,7 @@ interface IInterchainTokenService is
* @param destinationChain The destination chain to send the tokens to.
* @param destinationAddress The address on the destination chain to send the tokens to.
* @param amount The amount of tokens to be transferred.
* @param metadata Additional metadata to be passed along with the transfer.
* @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).
*/
function interchainTransfer(
bytes32 tokenId,
Expand All @@ -219,25 +221,6 @@ interface IInterchainTokenService is
bytes calldata data
) external payable;

/**
* @notice Initiates an interchain token transfer.
* @dev Only callable by TokenManagers.
* @param tokenId The tokenId of the token to be transmitted.
* @param sourceAddress The source address of the token.
* @param destinationChain The name of the destination chain.
* @param destinationAddress The destination address on the destination chain.
* @param amount The amount of tokens to transmit.
* @param metadata The metadata associated with the transmission.
*/
function transmitInterchainTransfer(
bytes32 tokenId,
address sourceAddress,
string calldata destinationChain,
bytes memory destinationAddress,
uint256 amount,
bytes calldata metadata
) external payable;

/**
* @notice Sets the flow limits for multiple tokens.
* @param tokenIds An array of tokenIds.
Expand Down
5 changes: 2 additions & 3 deletions contracts/interfaces/IInterchainTokenStandard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ interface IInterchainTokenStandard {
* @param destinationChain The destination chain identifier.
* @param recipient The bytes representation of the address of the recipient.
* @param amount The amount of token to be transferred.
* @param metadata Either empty, to just facilitate an interchain transfer, or the data can be passed for an interchain contract
* call with transfer as per semantics defined by the token service.
* @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).
*/
function interchainTransfer(
string calldata destinationChain,
Expand All @@ -32,7 +31,7 @@ interface IInterchainTokenStandard {
* @param destinationChain The string representation of the destination chain.
* @param recipient The bytes representation of the address of the recipient.
* @param amount The amount of token to be transferred.
* @param metadata Either empty, to just facilitate an interchain transfer, or the data to be passed to an interchain contract call and transfer.
* @param metadata Optional metadata for the call for additional effects (such as calling a destination contract.)
*/
function interchainTransferFrom(
address sender,
Expand Down

0 comments on commit 9688abf

Please sign in to comment.