Skip to content

Commit

Permalink
Merge branch 'main' into feat/service-upgrade-test
Browse files Browse the repository at this point in the history
  • Loading branch information
deanamiel authored Nov 3, 2023
2 parents dc19ba9 + db537f0 commit 7d52ceb
Show file tree
Hide file tree
Showing 14 changed files with 3,545 additions and 3,216 deletions.
337 changes: 177 additions & 160 deletions contracts/interchain-token-service/InterchainTokenService.sol

Large diffs are not rendered by default.

102 changes: 49 additions & 53 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,67 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
error LengthMismatch();
error InvalidTokenManagerImplementationType(address implementation);
error NotRemoteService();
error TokenManagerDoesNotExist(bytes32 tokenId_);
error TokenManagerDoesNotExist(bytes32 tokenId);
error NotTokenManager(address caller, address tokenManager);
error ExecuteWithInterchainTokenFailed(address contractAddress);
error InvalidCanonicalTokenId(bytes32 expectedCanonicalTokenId);
error ExpressExecuteWithInterchainTokenFailed(address contractAddress);
error GatewayToken();
error TokenManagerDeploymentFailed(bytes error);
error InterchainTokenDeploymentFailed(bytes error);
error SelectorUnknown(uint256 selector);
error InvalidMessageType(uint256 messageType);
error InvalidMetadataVersion(uint32 version);
error ExecuteWithTokenNotSupported();
error UntrustedChain(string chainName);
error InvalidExpressSelector(uint256 selector);
error InvalidExpressMessageType(uint256 messageType);

event TokenSent(bytes32 indexed tokenId_, string destinationChain, bytes destinationAddress, uint256 indexed amount);
event TokenSentWithData(
bytes32 indexed tokenId_,
event InterchainTransfer(bytes32 indexed tokenId, string destinationChain, bytes destinationAddress, uint256 indexed amount);
event InterchainTransferWithData(
bytes32 indexed tokenId,
string destinationChain,
bytes destinationAddress,
uint256 indexed amount,
address indexed sourceAddress,
bytes data
);
event TokenReceived(
bytes32 indexed tokenId_,
event InterchainTransferReceived(
bytes32 indexed tokenId,
string sourceChain,
bytes sourceAddress,
address indexed destinationAddress,
uint256 indexed amount
);
event TokenReceivedWithData(
bytes32 indexed tokenId_,
event InterchainTransferReceivedWithData(
bytes32 indexed tokenId,
string sourceChain,
bytes sourceAddress,
address indexed destinationAddress,
uint256 indexed amount
);
event RemoteTokenManagerDeploymentInitialized(
bytes32 indexed tokenId_,
event TokenManagerDeploymentStarted(
bytes32 indexed tokenId,
string destinationChain,
uint256 indexed gasValue,
TokenManagerType indexed tokenManagerType,
bytes params
);
event RemoteInterchainTokenDeploymentInitialized(
bytes32 indexed tokenId_,
event InterchainTokenDeploymentStarted(
bytes32 indexed tokenId,
string tokenName,
string tokenSymbol,
uint8 tokenDecimals,
bytes distributor,
bytes operator,
string destinationChain,
uint256 indexed gasValue
string destinationChain
);
event TokenManagerDeployed(bytes32 indexed tokenId_, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params);
event TokenManagerDeployed(bytes32 indexed tokenId, address tokenManager, TokenManagerType indexed tokenManagerType, bytes params);
event InterchainTokenDeployed(
bytes32 indexed tokenId_,
bytes32 indexed tokenId,
address tokenAddress,
address indexed distributor,
string name,
string symbol,
uint8 decimals
);
event CustomTokenIdClaimed(bytes32 indexed tokenId_, address indexed deployer, bytes32 indexed salt);
event PausedSet(bool indexed paused, address indexed msgSender);
event InterchainTokenIdClaimed(bytes32 indexed tokenId, address indexed deployer, bytes32 indexed salt);

/**
* @notice Returns the address of the interchain router contract.
Expand All @@ -100,40 +96,40 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
function interchainTokenDeployer() external view returns (address interchainTokenDeployerAddress);

/**
* @notice Returns the address of the token manager associated with the given tokenId_.
* @param tokenId_ The tokenId_ of the token manager.
* @notice Returns the address of the token manager associated with the given tokenId.
* @param tokenId The tokenId of the token manager.
* @return tokenManagerAddress_ The address of the token manager.
*/
function tokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_);
function tokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_);

/**
* @notice Returns the address of the valid token manager associated with the given tokenId_.
* @param tokenId_ The tokenId_ of the token manager.
* @notice Returns the address of the valid token manager associated with the given tokenId.
* @param tokenId The tokenId of the token manager.
* @return tokenManagerAddress_ The address of the valid token manager.
*/
function validTokenManagerAddress(bytes32 tokenId_) external view returns (address tokenManagerAddress_);
function validTokenManagerAddress(bytes32 tokenId) external view returns (address tokenManagerAddress_);

/**
* @notice Returns the address of the token associated with the given tokenId_.
* @param tokenId_ The tokenId_ of the token manager.
* @notice Returns the address of the token associated with the given tokenId.
* @param tokenId The tokenId of the token manager.
* @return tokenAddress_ The address of the token.
*/
function tokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_);
function tokenAddress(bytes32 tokenId) external view returns (address tokenAddress_);

/**
* @notice Returns the address of the standardized token associated with the given tokenId_.
* @param tokenId_ The tokenId_ of the standardized token.
* @notice Returns the address of the standardized token associated with the given tokenId.
* @param tokenId The tokenId of the standardized token.
* @return tokenAddress_ The address of the standardized token.
*/
function interchainTokenAddress(bytes32 tokenId_) external view returns (address tokenAddress_);
function interchainTokenAddress(bytes32 tokenId) external view returns (address tokenAddress_);

/**
* @notice Returns the custom tokenId_ associated with the given operator and salt.
* @notice Returns the custom tokenId associated with the given operator and salt.
* @param operator_ The operator address.
* @param salt The salt used for token id calculation.
* @return tokenId_ The custom tokenId_ associated with the operator and salt.
* @return tokenId The custom tokenId associated with the operator and salt.
*/
function tokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId_);
function interchainTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId);

/**
* @notice Deploys a custom token manager contract on a remote chain.
Expand All @@ -149,7 +145,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
TokenManagerType tokenManagerType,
bytes calldata params,
uint256 gasValue
) external payable returns (bytes32 tokenId_);
) external payable returns (bytes32 tokenId);

/**
* @notice Deploys and registers a standardized token on a remote chain.
Expand Down Expand Up @@ -180,15 +176,15 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_);

function interchainTransfer(
bytes32 tokenId_,
bytes32 tokenId,
string calldata destinationChain,
bytes calldata destinationAddress,
uint256 amount,
bytes calldata metadata
) external payable;

function sendTokenWithData(
bytes32 tokenId_,
function callContractWithInterchainToken(
bytes32 tokenId,
string calldata destinationChain,
bytes calldata destinationAddress,
uint256 amount,
Expand All @@ -197,15 +193,15 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec

/**
* @notice Initiates an interchain token transfer. Only callable by TokenManagers
* @param tokenId_ The tokenId_ of the token to be transmitted.
* @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 transmitSendToken(
bytes32 tokenId_,
function transmitInterchainTransfer(
bytes32 tokenId,
address sourceAddress,
string calldata destinationChain,
bytes memory destinationAddress,
Expand All @@ -222,28 +218,28 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec

/**
* @notice Returns the flow limit for a specific token.
* @param tokenId_ The tokenId_ of the token.
* @param tokenId The tokenId of the token.
* @return flowLimit_ The flow limit for the token.
*/
function flowLimit(bytes32 tokenId_) external view returns (uint256 flowLimit_);
function flowLimit(bytes32 tokenId) external view returns (uint256 flowLimit_);

/**
* @notice Returns the total amount of outgoing flow for a specific token.
* @param tokenId_ The tokenId_ of the token.
* @param tokenId The tokenId of the token.
* @return flowOutAmount_ The total amount of outgoing flow for the token.
*/
function flowOutAmount(bytes32 tokenId_) external view returns (uint256 flowOutAmount_);
function flowOutAmount(bytes32 tokenId) external view returns (uint256 flowOutAmount_);

/**
* @notice Returns the total amount of incoming flow for a specific token.
* @param tokenId_ The tokenId_ of the token.
* @param tokenId The tokenId of the token.
* @return flowInAmount_ The total amount of incoming flow for the token.
*/
function flowInAmount(bytes32 tokenId_) external view returns (uint256 flowInAmount_);
function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_);

/**
* @notice Sets the paused state of the contract.
* @param paused The boolean value indicating whether the contract is paused or not.
* @notice Allows the owner to pause/unpause the token service.
* @param paused whether to pause or unpause.
*/
function setPaused(bool paused) external;
function setPauseStatus(bool paused) external;
}
11 changes: 0 additions & 11 deletions contracts/interfaces/IStandardizedTokenProxy.sol

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/interfaces/ITokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
/**
* @notice A function that returns the token id.
*/
function tokenId() external view returns (bytes32);
function interchainTokenId() external view returns (bytes32);

/**
* @notice A function that should return the address of the token.
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ITokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ interface ITokenManagerProxy {
/**
* @notice Returns token ID of the token manager.
*/
function tokenId() external view returns (bytes32);
function interchainTokenId() external view returns (bytes32);
}
10 changes: 3 additions & 7 deletions contracts/interfaces/ITokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ interface ITokenRegistrar {
uint256 gasValue
) external payable;

function interchainTransferFrom(
bytes32 tokenId,
string calldata destinationChain,
bytes calldata destinationAddress,
uint256 amount,
uint256 gasValue
) external payable;
function tokenTransferFrom(bytes32 tokenId, uint256 amount) external payable;

function tokenApprove(bytes32 tokenId, uint256 amount) external payable;
}
5 changes: 2 additions & 3 deletions contracts/proxies/StandardizedTokenProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ pragma solidity ^0.8.0;
import { FixedProxy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/FixedProxy.sol';

import { IStandardizedToken } from '../interfaces/IStandardizedToken.sol';
import { IStandardizedTokenProxy } from '../interfaces/IStandardizedTokenProxy.sol';
import { IImplementation } from '../interfaces/IImplementation.sol';

/**
* @title StandardizedTokenProxy
* @dev Proxy contract for StandardizedToken contracts. Inherits from FixedProxy and implements IStandardizedTokenProxy.
* @dev Proxy contract for StandardizedToken contracts. Inherits from FixedProxy.
*/
contract StandardizedTokenProxy is FixedProxy, IStandardizedTokenProxy {
contract StandardizedTokenProxy is FixedProxy {
bytes32 private constant CONTRACT_ID = keccak256('standardized-token');

/**
Expand Down
8 changes: 4 additions & 4 deletions contracts/proxies/TokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import { ITokenManagerProxy } from '../interfaces/ITokenManagerProxy.sol';
contract TokenManagerProxy is ITokenManagerProxy {
IInterchainTokenService public immutable interchainTokenService;
uint256 public immutable implementationType;
bytes32 public immutable tokenId;
bytes32 public immutable interchainTokenId;

/**
* @dev Constructs the TokenManagerProxy contract.
* @param interchainTokenServiceAddress_ The address of the interchain token service
* @param implementationType_ The token manager type
* @param tokenId_ The identifier for the token
* @param tokenId The identifier for the token
* @param params The initialization parameters for the token manager contract
*/
constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId_, bytes memory params) {
constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId, bytes memory params) {
interchainTokenService = IInterchainTokenService(interchainTokenServiceAddress_);
implementationType = implementationType_;
tokenId = tokenId_;
interchainTokenId = tokenId;
address impl = _tokenManagerImplementation(IInterchainTokenService(interchainTokenServiceAddress_), implementationType_);

(bool success, bytes memory returnData) = impl.delegatecall(abi.encodeWithSelector(TokenManagerProxy.setup.selector, params));
Expand Down
Loading

0 comments on commit 7d52ceb

Please sign in to comment.