Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use gmp sdk utils #132

Merged
merged 54 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e9c1939
Added a canonical token registrar.
Foivos Oct 2, 2023
10e4503
wrote some canonical token registrar tests
Foivos Oct 2, 2023
2866ecf
made the standardized token registrar
Foivos Oct 2, 2023
1127093
Wrote some basic tests
Foivos Oct 3, 2023
943de1f
Merge remote-tracking branch 'origin/main' into feat/custom-token-reg…
Foivos Oct 3, 2023
09b66bb
lint and fix a merge bug
Foivos Oct 3, 2023
f4ef75b
feat: bump to latest gmp-sdk and cgp
milapsheth Oct 9, 2023
4569336
Merge branch 'axe-2034' into feat/custom-token-registars
milapsheth Oct 9, 2023
14fecc4
rebase over dep bump
milapsheth Oct 9, 2023
8682513
Merge branch 'main' into feat/custom-token-registars
milapsheth Oct 12, 2023
1bd5f9b
clean lock file
milapsheth Oct 12, 2023
3391cd8
Merge branch 'main' into feat/custom-token-registars
milapsheth Oct 12, 2023
f82b23c
Merge branch 'main' into feat/custom-token-registars
milapsheth Oct 12, 2023
f0a7e29
slither checks
milapsheth Oct 12, 2023
04972f9
Merge branch 'main' into feat/custom-token-registars
milapsheth Oct 12, 2023
df97235
Added roles, tests pending
Foivos Oct 17, 2023
8ea68ca
fix: tests
Oct 19, 2023
afdb98d
Merge remote-tracking branch 'origin/main' into feat/roles
Oct 19, 2023
fc0d72b
Added some tests and fixed constants
Foivos Oct 19, 2023
4b0586d
made lint happy
Foivos Oct 19, 2023
8c28d6d
Chnaged roles constants to enum to make slither happy
Foivos Oct 19, 2023
3ef1db2
Fixed tests
Foivos Oct 20, 2023
1566fec
Merge branch 'main' into feat/custom-token-registars
milapsheth Oct 23, 2023
ed4be65
querrying chain name from the remoteAddressValidator for the registrars
Foivos Oct 25, 2023
4ec3612
Merge remote-tracking branch 'origin/feat/custom-token-registars' int…
Foivos Oct 25, 2023
844bfb6
Merge remote-tracking branch 'origin/feat/roles' into feat/custom-tok…
Foivos Oct 25, 2023
a8db922
stash to add more utils to roles.
Foivos Oct 25, 2023
6c4e38f
Added getter for distributor and opearator.
Foivos Oct 25, 2023
51a3ce4
made lint happy
Foivos Oct 25, 2023
68fcbdd
fixed a spelling error
Foivos Oct 25, 2023
7b69d55
Merge branch 'feat/roles' into feat/custom-token-registars
Foivos Oct 25, 2023
7815108
Fixed tests and interfaces
Foivos Oct 25, 2023
876c92f
installed newer sdk and deleted files
Foivos Oct 26, 2023
3f6be4b
supporing all the utils
Foivos Oct 26, 2023
de5bcda
Removed a lot of unused imports and made routers upgradable.
Foivos Oct 27, 2023
9bedfbe
Merge branch 'feat/custom-token-registars' into feat/use-gmp-sdk
Foivos Oct 27, 2023
43c68a1
fixed registrars to use interchain router
Foivos Oct 27, 2023
c62c8fd
Merge remote-tracking branch 'origin/main' into feat/use-gmp-sdk
Foivos Nov 1, 2023
38048d8
fixed tests
Foivos Nov 1, 2023
7230406
changed all getters to remove get
Foivos Nov 1, 2023
b1c50a7
prettier
Foivos Nov 1, 2023
77a383d
fixed build warnings
Foivos Nov 1, 2023
9e72fc9
update package_lock
Foivos Nov 1, 2023
0299200
make slither happy
Foivos Nov 1, 2023
716dc25
made slither even happier
Foivos Nov 1, 2023
aa79c5e
make slither super jolly
Foivos Nov 1, 2023
3f6fa79
minor change
Foivos Nov 1, 2023
854ce5d
addressed some comments
Foivos Nov 1, 2023
2c57eae
fix: tests
Nov 1, 2023
70c5387
fix: test file capitalization
Nov 1, 2023
6f31b97
feat(AddressTracker): updating with latest SDK
re1ro Nov 1, 2023
7b8e689
style(Solidity): prettier
re1ro Nov 1, 2023
594b4ef
fix(gitignore): root interfaces only
re1ro Nov 1, 2023
af3cea8
docs(Design): Address Tracker is not upgradable
re1ro Nov 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lib-cov

# Coverage directory used by tools like istanbul
coverage
coverage.json
*.lcov

# nyc test coverage
Expand Down Expand Up @@ -105,13 +106,12 @@ dist

# Editor files
.vscode/
.idea/

build/
cache/
artifacts/
/interfaces/

info/local.json
keys.json
.vscode
coverage.json
coverage
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Most projects that look to go cross-chain nowadays have more complex needs that
- Mint/Burn: This `TokenManager` will burn/mint tokens from/to the user to initiate/fulfill cross-chain transfers. Tokens used with this kind of `TokenManager` need to be properly permissioned to allow for this behavior.
- Liquidity Pool: This `TokenManager` functions exactly like a Lock/Unlock one, except the balance is kept at a separate, pre-specified account. This allows for deployers to have more control over the bridged funds.

## Linker Router
## Interchain Address Tracker

We plan to finalize the design of the `InterchainTokenService` but we want to be able to support new chains as they get added to the Axelar Network. For this purpose, the service will ask a separate contract, the [`RemoteAddressValidator`](./contracts/remoteAddressValidator/RemoteAddressValidator.sol) to obtain the destination address for outgoing messages, and for validation of incoming messages. This contract might eventually stop being upgradable but it will probably be able to support new addresses for new chains indefinitely.
We plan to finalize the design of the `InterchainTokenService` but we want to be able to support new chains as they get added to the Axelar Network. For this purpose, the service will ask a separate contract, the [`InterchainAddressTracker`](https://github.com/axelarnetwork/axelar-gmp-sdk-solidity/blob/main/contracts/utils/InterchainAddressTracker.sol) to obtain the destination address for outgoing messages, and for validation of incoming messages.

## Interchain Token

Expand Down
33 changes: 33 additions & 0 deletions contracts/address-tracker/AddressTracker.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { Ownable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Ownable.sol';
import { InterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/InterchainAddressTracker.sol';

import { IAddressTracker } from '../interfaces/IAddressTracker.sol';

contract AddressTracker is IAddressTracker, Ownable, InterchainAddressTracker {
constructor(
address owner_,
string memory chainName_,
string[] memory trustedChainNames,
string[] memory trustedAddresses
) Ownable(owner_) InterchainAddressTracker(chainName_) {
uint256 length = trustedChainNames.length;

if (length != trustedAddresses.length) revert LengthMismatch();

for (uint256 i; i < length; ++i) {
_setTrustedAddress(trustedChainNames[i], trustedAddresses[i]);
}
}

function setTrustedAddress(string memory chain, string memory address_) external onlyOwner {
_setTrustedAddress(chain, address_);
}

function removeTrustedAddress(string memory chain) external onlyOwner {
_removeTrustedAddress(chain);
}
}
180 changes: 91 additions & 89 deletions contracts/interchain-token-service/InterchainTokenService.sol

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions contracts/interfaces/IAddressTracker.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { IOwnable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IOwnable.sol';
import { IInterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IInterchainAddressTracker.sol';

interface IAddressTracker is IOwnable, IInterchainAddressTracker {
/**
* @dev Sets the trusted address for the specified chain
* @param chain Chain name to be trusted
* @param address_ Trusted address to be added for the chain
*/
function setTrustedAddress(string memory chain, string memory address_) external;

/**
* @dev Remove the trusted address of the chain.
* @param chain Chain name that should be made untrusted
*/
function removeTrustedAddress(string calldata chain) external;
}
4 changes: 2 additions & 2 deletions contracts/interfaces/ICanonicalTokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ interface ICanonicalTokenRegistrar {

function chainNameHash() external view returns (bytes32);

function getCanonicalTokenSalt(address tokenAddress) external view returns (bytes32 salt);
function canonicalTokenSalt(address tokenAddress) external view returns (bytes32 salt);

function getCanonicalTokenId(address tokenAddress) external view returns (bytes32 tokenId);
function canonicalTokenId(address tokenAddress) external view returns (bytes32 tokenId);

function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId);

Expand Down
14 changes: 7 additions & 7 deletions contracts/interfaces/IFlowLimit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ pragma solidity ^0.8.0;
interface IFlowLimit {
error FlowLimitExceeded(uint256 limit, uint256 flowAmount);

event FlowLimitSet(bytes32 indexed tokenId, address operator, uint256 flowLimit);
event FlowLimitSet(bytes32 indexed tokenId, address operator, uint256 flowLimit_);

/**
* @notice Returns the current flow limit
* @return flowLimit The current flow limit value
* @return flowLimit_ The current flow limit value
*/
function getFlowLimit() external view returns (uint256 flowLimit);
function flowLimit() external view returns (uint256 flowLimit_);

/**
* @notice Returns the current flow out amount
* @return flowOutAmount The current flow out amount
* @return flowOutAmount_ The current flow out amount
*/
function getFlowOutAmount() external view returns (uint256 flowOutAmount);
function flowOutAmount() external view returns (uint256 flowOutAmount_);

/**
* @notice Returns the current flow in amount
* @return flowInAmount The current flow in amount
* @return flowInAmount_ The current flow in amount
*/
function getFlowInAmount() external view returns (uint256 flowInAmount);
function flowInAmount() external view returns (uint256 flowInAmount_);
}
58 changes: 30 additions & 28 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pragma solidity ^0.8.0;

import { IAxelarValuedExpressExecutable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarValuedExpressExecutable.sol';
import { IContractIdentifier } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IContractIdentifier.sol';
import { IMulticall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IMulticall.sol';
import { IInterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IInterchainAddressTracker.sol';
import { IPausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IPausable.sol';

import { ITokenManagerType } from './ITokenManagerType.sol';
import { IPausable } from './IPausable.sol';
import { IMulticall } from './IMulticall.sol';
import { IRemoteAddressValidator } from './IRemoteAddressValidator.sol';

interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExecutable, IPausable, IMulticall, IContractIdentifier {
error ZeroAddress();
Expand All @@ -26,6 +26,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
error SelectorUnknown(uint256 selector);
error InvalidMetadataVersion(uint32 version);
error ExecuteWithTokenNotSupported();
error UntrustedChain(string chainName);
error InvalidExpressSelector(uint256 selector);

event TokenSent(bytes32 indexed tokenId, string destinationChain, bytes destinationAddress, uint256 indexed amount);
Expand Down Expand Up @@ -82,12 +83,13 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
address mintTo
);
event CustomTokenIdClaimed(bytes32 indexed tokenId, address indexed deployer, bytes32 indexed salt);
event PausedSet(bool indexed paused, address indexed msgSender);

/**
* @notice Returns the address of the token manager deployer contract.
* @return remoteAddressValidator_ The remoteAddressValidator.
* @notice Returns the address of the interchain router contract.
* @return interchainAddressTracker_ The interchainAddressTracker.
*/
function remoteAddressValidator() external view returns (IRemoteAddressValidator remoteAddressValidator_);
function interchainAddressTracker() external view returns (IInterchainAddressTracker interchainAddressTracker_);

/**
* @notice Returns the address of the token manager deployer contract.
Expand All @@ -104,52 +106,52 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
/**
* @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.
* @return tokenManagerAddress_ The address of the token manager.
*/
function getTokenManagerAddress(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.
* @return tokenManagerAddress The address of the valid token manager.
* @return tokenManagerAddress_ The address of the valid token manager.
*/
function getValidTokenManagerAddress(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.
* @return tokenAddress The address of the token.
* @return tokenAddress_ The address of the token.
*/
function getTokenAddress(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.
* @return tokenAddress The address of the standardized token.
* @return tokenAddress_ The address of the standardized token.
*/
function getStandardizedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress);
function standardizedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress_);

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

/**
* @notice Returns the custom tokenId associated with the given operator and salt.
* @param operator The operator address.
* @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.
*/
function getCustomTokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId);
function customTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId);

/**
* @notice Registers a canonical token and returns its associated tokenId.
* @param tokenAddress The address of the canonical token.
* @param tokenAddress_ The address of the canonical token.
* @return tokenId The tokenId associated with the registered canonical token.
*/
function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId);
function registerCanonicalToken(address tokenAddress_) external payable returns (bytes32 tokenId);

/**
* @notice Deploys a standardized canonical token on a remote chain.
Expand Down Expand Up @@ -235,9 +237,9 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
/**
* @notice Returns the implementation address for a given token manager type.
* @param tokenManagerType The type of token manager.
* @return tokenManagerAddress The address of the token manager implementation.
* @return tokenManagerAddress_ The address of the token manager implementation.
*/
function getImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress);
function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_);

function interchainTransfer(
bytes32 tokenId,
Expand Down Expand Up @@ -283,23 +285,23 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
/**
* @notice Returns the flow limit for a specific token.
* @param tokenId The tokenId of the token.
* @return flowLimit The flow limit for the token.
* @return flowLimit_ The flow limit for the token.
*/
function getFlowLimit(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.
* @return flowOutAmount The total amount of outgoing flow for the token.
* @return flowOutAmount_ The total amount of outgoing flow for the token.
*/
function getFlowOutAmount(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.
* @return flowInAmount The total amount of incoming flow for the token.
* @return flowInAmount_ The total amount of incoming flow for the token.
*/
function getFlowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount);
function flowInAmount(bytes32 tokenId) external view returns (uint256 flowInAmount_);

/**
* @notice Sets the paused state of the contract.
Expand Down
19 changes: 0 additions & 19 deletions contracts/interfaces/IMulticall.sol

This file was deleted.

18 changes: 0 additions & 18 deletions contracts/interfaces/INoReEntrancy.sol

This file was deleted.

20 changes: 0 additions & 20 deletions contracts/interfaces/IPausable.sol

This file was deleted.

52 changes: 0 additions & 52 deletions contracts/interfaces/IRemoteAddressValidator.sol

This file was deleted.

Loading
Loading