Skip to content

Commit

Permalink
Merge branch 'feat/test-coverage-one' into feat/test-coverage-two
Browse files Browse the repository at this point in the history
# Conflicts:
#	test/tokenServiceFullFlow.js
  • Loading branch information
re1ro committed Oct 3, 2023
2 parents 67f5f9b + a5fe901 commit 5a89f3d
Show file tree
Hide file tree
Showing 34 changed files with 1,302 additions and 1,191 deletions.
16 changes: 11 additions & 5 deletions contracts/interchain-token-service/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract InterchainTokenService is
bytes32 private constant CONTRACT_ID = keccak256('interchain-token-service');

/**
* @dev All of the varaibles passed here are stored as immutable variables.
* @dev All of the variables passed here are stored as immutable variables.
* @param tokenManagerDeployer_ the address of the TokenManagerDeployer.
* @param standardizedTokenDeployer_ the address of the StandardizedTokenDeployer.
* @param gateway_ the address of the AxelarGateway.
Expand Down Expand Up @@ -146,7 +146,7 @@ contract InterchainTokenService is
/**
* @notice Calculates the address of a TokenManager from a specific tokenId. The TokenManager does not need to exist already.
* @param tokenId the tokenId.
* @return tokenManagerAddress deployement address of the TokenManager.
* @return tokenManagerAddress deployment address of the TokenManager.
*/
// TODO: Maybe copy the code of the create3Deployer to save gas, but would introduce duplicate code problems.
function getTokenManagerAddress(bytes32 tokenId) public view returns (address tokenManagerAddress) {
Expand Down Expand Up @@ -353,12 +353,15 @@ contract InterchainTokenService is

/**
* @notice Used to deploy a standardized token alongside a TokenManager in another chain. If the `distributor` is empty
* bytes then a mint/burn TokenManager is used. Otherwise a lock/unlcok TokenManager is used.
* bytes then a mint/burn TokenManager is used. Otherwise a lock/unlock TokenManager is used.
* @param salt the salt to be used.
* @param name the name of the token to be deployed.
* @param symbol the symbol of the token to be deployed.
* @param decimals the decimals of the token to be deployed.
* @param distributor the address that will be able to mint and burn the deployed token.
* @param mintTo The address where the minted tokens will be sent upon deployment
* @param mintAmount The amount of tokens to be minted upon deployment
* @param operator The operator data for standardized tokens
* @param destinationChain the name of the destination chain to deploy to.
* @param gasValue the amount of native tokens to be used to pay for gas for the remote deployment. At least the amount
* specified needs to be passed to the call
Expand Down Expand Up @@ -461,11 +464,11 @@ contract InterchainTokenService is
/**
* @notice Transmit a sendTokenWithData for the given tokenId. Only callable by a token manager.
* @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 reimburment of gas.
* @param sourceAddress the address where the token is coming from, which will also be used for reimbursement of gas.
* @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 destiantion.
* @param metadata the data to be passed to the destination.
*/
function transmitSendToken(
bytes32 tokenId,
Expand Down Expand Up @@ -697,6 +700,9 @@ contract InterchainTokenService is
* @param symbol The symbol of the token
* @param decimals The number of decimals of the token
* @param distributor The distributor address for the token
* @param mintTo The address where the minted tokens will be sent upon deployment
* @param mintAmount The amount of tokens to be minted upon deployment
* @param operator The operator data for standardized tokens
* @param destinationChain The destination chain where the token will be deployed
* @param gasValue The amount of gas to be paid for the transaction
*/
Expand Down
8 changes: 4 additions & 4 deletions contracts/interchain-token/InterchainToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ERC20 } from '../token-implementations/ERC20.sol';
abstract contract InterchainToken is IInterchainToken, ERC20 {
/**
* @notice Getter for the tokenManager used for this token.
* @dev Needs to be overwitten.
* @dev Needs to be overwritten.
* @return tokenManager_ the TokenManager called to facilitate cross chain transfers.
*/
function tokenManager() public view virtual returns (ITokenManager tokenManager_);
Expand All @@ -25,7 +25,7 @@ abstract contract InterchainToken is IInterchainToken, ERC20 {
* A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well.
* @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 transfered.
* @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.
*/
function interchainTransfer(
Expand All @@ -49,7 +49,7 @@ abstract contract InterchainToken is IInterchainToken, ERC20 {
* @param sender the sender of the tokens. They need to have approved `msg.sender` before this is called.
* @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 transfered.
* @param amount the amount of token to be transferred.
* @param metadata either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer.
*/
function interchainTransferFrom(
Expand All @@ -76,7 +76,7 @@ abstract contract InterchainToken is IInterchainToken, ERC20 {
* @param from the sender of the tokens. They need to have approved `msg.sender` before this is called.
* @param destinationChain the string representation of the destination chain.
* @param destinationAddress the bytes representation of the address of the recipient.
* @param amount the amount of token to be transfered.
* @param amount the amount of token to be transferred.
* @param metadata either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer.
*/
function _beforeInterchainTransfer(
Expand Down
25 changes: 25 additions & 0 deletions contracts/interfaces/IERC20BurnableFrom.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20BurnableFrom {
/**
* @notice Function to burn tokens from a burn deposit address
* @notice It is needed to support legacy Axelar Gateway tokens
* @dev Can only be called after token is transferred to a deposit address.
* @param salt The address that will have its tokens burnt
*/
function burn(bytes32 salt) external;

/**
* @notice Function to burn tokens
* @notice Requires the caller to have allowance for `amount` on `from`
* @dev Can only be called by the distributor address.
* @param from The address that will have its tokens burnt
* @param amount The amount of tokens to burn
*/
function burnFrom(address from, uint256 amount) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20BurnableMintable {
interface IERC20MintableBurnable {
/**
* @notice Function to mint new tokens
* Can only be called by the distributor address.
* @dev Can only be called by the distributor address.
* @param to The address that will receive the minted tokens
* @param amount The amount of tokens to mint
*/
function mint(address to, uint256 amount) external;

/**
* @notice Function to burn tokens
* Can only be called by the distributor address.
* @dev Can only be called by the distributor address.
* @param from The address that will have its tokens burnt
* @param amount The amount of tokens to burn
*/
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IInterchainToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface IInterchainToken {
* A different implementation could have `metadata` that tells this function which function to use or that it is used for anything else as well.
* @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 transfered.
* @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.
*/
function interchainTransfer(
Expand All @@ -29,7 +29,7 @@ interface IInterchainToken {
* @param sender the sender of the tokens. They need to have approved `msg.sender` before this is called.
* @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 transfered.
* @param amount the amount of token to be transferred.
* @param metadata either empty, to just facilitate a cross-chain transfer, or the data to be passed to a cross-chain contract call and transfer.
*/
function interchainTransferFrom(
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IInterchainTokenExecutable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IInterchainTokenExecutable {
* @param sourceChain the name of the source chain
* @param sourceAddress the address that sent the contract call
* @param data the data to be proccessed
* @param tokenId the tokenId of the token manager managing the token. You can access it's address by querrying the service
* @param tokenId the tokenId of the token manager managing the token. You can access it's address by querying the service
* @param amount the amount of token that was sent
*/
function executeWithInterchainToken(
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IInterchainTokenExpressExecutable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IInterchainTokenExpressExecutable is IInterchainTokenExecutable {
* @param sourceChain the name of the source chain
* @param sourceAddress the address that sent the contract call
* @param data the data to be proccessed
* @param tokenId the tokenId of the token manager managing the token. You can access it's address by querrying the service
* @param tokenId the tokenId of the token manager managing the token. You can access it's address by querying the service
* @param amount the amount of token that was sent
*/
function expressExecuteWithInterchainToken(
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ interface IInterchainTokenService is ITokenManagerType, IExpressCallHandler, IAx
* @param symbol The symbol of the standardized tokens.
* @param decimals The number of decimals for the standardized tokens.
* @param distributor The distributor data for mint/burn operations.
* @param mintTo The address where the minted tokens will be sent upon deployment.
* @param mintAmount The amount of tokens to be minted upon deployment.
* @param operator The operator data for standardized tokens.
* @param destinationChain The name of the destination chain.
* @param gasValue The gas value for deployment.
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IRemoteAddressValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface IRemoteAddressValidator {
error LengthMismatch();
error ZeroStringLength();

event TrustedAddressAdded(string souceChain, string sourceAddress);
event TrustedAddressRemoved(string souceChain);
event TrustedAddressAdded(string sourceChain, string sourceAddress);
event TrustedAddressRemoved(string sourceChain);

/**
* @notice Returns the interchain token address
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IStandardizedToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.0;

import { IInterchainToken } from './IInterchainToken.sol';
import { IDistributable } from './IDistributable.sol';
import { IERC20BurnableMintable } from './IERC20BurnableMintable.sol';
import { IERC20MintableBurnable } from './IERC20MintableBurnable.sol';
import { ITokenManager } from './ITokenManager.sol';
import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';

Expand All @@ -13,7 +13,7 @@ import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interf
* @notice This contract implements a standardized token which extends InterchainToken functionality.
* This contract also inherits Distributable and Implementation logic.
*/
interface IStandardizedToken is IInterchainToken, IDistributable, IERC20BurnableMintable, IERC20 {
interface IStandardizedToken is IInterchainToken, IDistributable, IERC20MintableBurnable, IERC20 {
/**
* @notice Returns the contract id, which a proxy can check to ensure no false implementation was used.
*/
Expand Down
10 changes: 6 additions & 4 deletions contracts/interfaces/ITokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
function implementationType() external pure returns (uint256);

/**
* @notice Calls the service to initiate the a cross-chain transfer after taking the appropriate amount of tokens from the user.
* @notice Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user.
* @param destinationChain the name of the chain to send tokens to.
* @param destinationAddress the address of the user to send tokens to.
* @param amount the amount of tokens to take from msg.sender.
* @param metadata any additional data to be sent with the transfer.
*/
function interchainTransfer(
string calldata destinationChain,
Expand All @@ -49,7 +50,7 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
) external payable;

/**
* @notice Calls the service to initiate the a cross-chain transfer with data after taking the appropriate amount of tokens from the user.
* @notice Calls the service to initiate a cross-chain transfer with data after taking the appropriate amount of tokens from the user.
* @param destinationChain the name of the chain to send tokens to.
* @param destinationAddress the address of the user to send tokens to.
* @param amount the amount of tokens to take from msg.sender.
Expand All @@ -63,11 +64,12 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
) external payable;

/**
* @notice Calls the service to initiate the a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself.
* @notice Calls the service to initiate a cross-chain transfer after taking the appropriate amount of tokens from the user. This can only be called by the token itself.
* @param sender the address of the user paying for the cross chain transfer.
* @param destinationChain the name of the chain to send tokens to.
* @param destinationAddress the address of the user to send tokens to.
* @param amount the amount of tokens to take from msg.sender.
* @param metadata any additional data to be sent with the transfer.
*/
function transmitInterchainTransfer(
address sender,
Expand All @@ -81,7 +83,7 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
* @notice This function gives token to a specified address. Can only be called by the service.
* @param destinationAddress the address to give tokens to.
* @param amount the amount of token to give.
* @return the amount of token actually given, which will onle be differen than `amount` in cases where the token takes some on-transfer fee.
* @return the amount of token actually given, which will only be different than `amount` in cases where the token takes some on-transfer fee.
*/
function giveToken(address destinationAddress, uint256 amount) external returns (uint256);

Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/ITokenManagerType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ pragma solidity ^0.8.0;
*/
interface ITokenManagerType {
enum TokenManagerType {
LOCK_UNLOCK,
MINT_BURN,
MINT_BURN_FROM,
LOCK_UNLOCK,
LOCK_UNLOCK_FEE_ON_TRANSFER,
LIQUIDITY_POOL
}
Expand Down
7 changes: 4 additions & 3 deletions contracts/proxies/TokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { ITokenManagerProxy } from '../interfaces/ITokenManagerProxy.sol';

/**
* @title TokenManagerProxy
* @dev This contract is a proxy for token manager contracts. It implements ITokenManagerProxy.
* @notice This contract is a proxy for token manager contracts.
* @dev It implements ITokenManagerProxy.
*/
contract TokenManagerProxy is ITokenManagerProxy {
IInterchainTokenService public immutable interchainTokenService;
Expand Down Expand Up @@ -63,12 +64,12 @@ contract TokenManagerProxy is ITokenManagerProxy {
*/
// solhint-disable-next-line no-complex-fallback
fallback() external payable virtual {
address implementaion_ = implementation();
address implementation_ = implementation();

assembly {
calldatacopy(0, 0, calldatasize())

let result := delegatecall(gas(), implementaion_, 0, calldatasize(), 0, 0)
let result := delegatecall(gas(), implementation_, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())

switch result
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/FeeOnTransferTokenTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pragma solidity ^0.8.0;
import { InterchainToken } from '../interchain-token/InterchainToken.sol';
import { Distributable } from '../utils/Distributable.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';
import { IERC20BurnableMintable } from '../interfaces/IERC20BurnableMintable.sol';
import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol';

contract FeeOnTransferTokenTest is InterchainToken, Distributable, IERC20BurnableMintable {
contract FeeOnTransferTokenTest is InterchainToken, Distributable, IERC20MintableBurnable {
ITokenManager public tokenManager_;
bool internal tokenManagerRequiresApproval_ = true;

Expand Down
4 changes: 2 additions & 2 deletions contracts/test/InterchainTokenTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pragma solidity ^0.8.0;
import { InterchainToken } from '../interchain-token/InterchainToken.sol';
import { Distributable } from '../utils/Distributable.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';
import { IERC20BurnableMintable } from '../interfaces/IERC20BurnableMintable.sol';
import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol';

contract InterchainTokenTest is InterchainToken, Distributable, IERC20BurnableMintable {
contract InterchainTokenTest is InterchainToken, Distributable, IERC20MintableBurnable {
ITokenManager public tokenManager_;
bool internal tokenManagerRequiresApproval_ = true;
string public name;
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/InvalidStandardizedToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.0;

import { IERC20BurnableMintable } from '../interfaces/IERC20BurnableMintable.sol';
import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';

import { InterchainToken } from '../interchain-token/InterchainToken.sol';
Expand All @@ -11,7 +11,7 @@ import { AddressBytesUtils } from '../libraries/AddressBytesUtils.sol';
import { Implementation } from '../utils/Implementation.sol';
import { Distributable } from '../utils/Distributable.sol';

contract InvalidStandardizedToken is IERC20BurnableMintable, InterchainToken, ERC20Permit, Implementation, Distributable {
contract InvalidStandardizedToken is IERC20MintableBurnable, InterchainToken, ERC20Permit, Implementation, Distributable {
using AddressBytesUtils for bytes;

string public name;
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/utils/NakedProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ contract NakedProxy {

// solhint-disable-next-line no-complex-fallback
fallback() external payable virtual {
address implementaion_ = implementation;
address implementation_ = implementation;

assembly {
calldatacopy(0, 0, calldatasize())

let result := delegatecall(gas(), implementaion_, 0, calldatasize(), 0, 0)
let result := delegatecall(gas(), implementation_, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())

switch result
Expand Down
Loading

0 comments on commit 5a89f3d

Please sign in to comment.