Skip to content

Commit

Permalink
Merge branch 'main' into alexbharley/hypfiatcollateral-warp-route
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBHarley committed Jun 14, 2024
2 parents 62828ba + 51bfff6 commit 7cb2d10
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 168 deletions.
8 changes: 8 additions & 0 deletions .changeset/selfish-days-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@hyperlane-xyz/sdk': minor
'@hyperlane-xyz/core': minor
'@hyperlane-xyz/cli': minor
---

Mint/burn limit checking for xERC20 bridging
Corrects CLI output for HypXERC20 and HypXERC20Lockbox deployments
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"eslint": "^9.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.2.0",
"husky": "^8.0.0",
Expand Down
23 changes: 19 additions & 4 deletions rust/hyperlane-core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ pub enum KnownHyperlaneDomain {
Injective = 6909546,
InEvm = 2525,

Ancient8 = 888888888,

Blast = 81457,

Mode = 34443,

Redstone = 690,

Viction = 88,

Zetachain = 7000,

PlumeTestnet = 161221135,

// -- Local test chains --
Expand Down Expand Up @@ -216,7 +228,8 @@ impl KnownHyperlaneDomain {
many_to_one!(match self {
Mainnet: [
Ethereum, Avalanche, Arbitrum, Polygon, Optimism, BinanceSmartChain, Celo,
Moonbeam, Gnosis, MantaPacific, Neutron, Injective, InEvm
Moonbeam, Gnosis, MantaPacific, Neutron, Injective, InEvm, Ancient8, Blast,
Mode, Redstone, Viction, Zetachain
],
Testnet: [
Alfajores, MoonbaseAlpha, Sepolia, ScrollSepolia, Chiado, PlumeTestnet, Fuji, BinanceSmartChainTestnet, Holesky
Expand All @@ -232,8 +245,9 @@ impl KnownHyperlaneDomain {
HyperlaneDomainProtocol::Ethereum: [
Ethereum, Sepolia, Holesky, Polygon, Avalanche, Fuji, Arbitrum,
Optimism, BinanceSmartChain, BinanceSmartChainTestnet, Celo, Gnosis,
Alfajores, Moonbeam, InEvm, MoonbaseAlpha, ScrollSepolia,
Chiado, MantaPacific, PlumeTestnet, Test1, Test2, Test3
Alfajores, Moonbeam, InEvm, Ancient8, Blast, Mode, Redstone, Viction,
Zetachain, MoonbaseAlpha, ScrollSepolia, Chiado, MantaPacific, PlumeTestnet,
Test1, Test2, Test3
],
HyperlaneDomainProtocol::Fuel: [FuelTest1],
HyperlaneDomainProtocol::Sealevel: [SealevelTest1, SealevelTest2],
Expand All @@ -249,7 +263,8 @@ impl KnownHyperlaneDomain {
HyperlaneDomainTechnicalStack::Other: [
Ethereum, Sepolia, Holesky, Polygon, Avalanche, Fuji, Optimism,
BinanceSmartChain, BinanceSmartChainTestnet, Celo, Gnosis, Alfajores, Moonbeam, MoonbaseAlpha,
ScrollSepolia, Chiado, MantaPacific, Neutron, Injective, InEvm,
ScrollSepolia, Chiado, MantaPacific, Neutron, Injective, InEvm, Ancient8, Blast, Mode, Redstone,
Viction, Zetachain,
Test1, Test2, Test3, FuelTest1, SealevelTest1, SealevelTest2, CosmosTest99990, CosmosTest99991
],
})
Expand Down
12 changes: 12 additions & 0 deletions solidity/contracts/test/ERC20Test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ contract XERC20Test is ERC20Test, IXERC20 {
function owner() external pure returns (address) {
return address(0x0);
}

function burningCurrentLimitOf(
address _bridge
) external view returns (uint256) {
return type(uint256).max;
}

function mintingCurrentLimitOf(
address _bridge
) external view returns (uint256) {
return type(uint256).max;
}
}

contract XERC20LockboxTest is IXERC20Lockbox {
Expand Down
18 changes: 18 additions & 0 deletions solidity/contracts/token/interfaces/IXERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,22 @@ interface IXERC20 is IERC20 {
) external;

function owner() external returns (address);

/**
* @notice Returns the current limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function burningCurrentLimitOf(
address _bridge
) external view returns (uint256 _limit);

/**
* @notice Returns the current limit of a bridge
* @param _bridge the bridge we are viewing the limits of
* @return _limit The limit the bridge has
*/
function mintingCurrentLimitOf(
address _bridge
) external view returns (uint256 _limit);
}
3 changes: 3 additions & 0 deletions solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/node": "^18.14.5",
"chai": "^4.3.6",
"ethereum-waffle": "^4.0.10",
"ethers": "^5.7.2",
Expand All @@ -26,6 +28,7 @@
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^4.5.4",
"solhint-plugin-prettier": "^0.0.5",
"solidity-bytes-utils": "^0.8.0",
"solidity-coverage": "^0.8.3",
"ts-generator": "^0.1.1",
"ts-node": "^10.8.0",
Expand Down
2 changes: 2 additions & 0 deletions typescript/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"zod": "^3.21.2"
},
"devDependencies": {
"@ethersproject/abi": "*",
"@ethersproject/providers": "*",
"@types/mocha": "^10.0.1",
"@types/node": "^18.14.5",
"@types/yargs": "^17.0.24",
Expand Down
37 changes: 32 additions & 5 deletions typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { confirm } from '@inquirer/prompts';

import {
HypXERC20Lockbox__factory,
HypXERC20__factory,
} from '@hyperlane-xyz/core';
import {
HypERC20Deployer,
HypERC721Deployer,
Expand Down Expand Up @@ -161,13 +165,36 @@ async function getWarpCoreConfig(
throw new Error('Missing decimals on token metadata');
}

const collateralAddressOrDenom =
const collateralAddressOrDenom = await (async () => {
if (config.type === TokenType.XERC20Lockbox) {
const provider = context.multiProvider.tryGetProvider(chainName);
if (!provider) {
throw new Error(`Unable to pull provider for ${chainName}`);
}

const xERC20 = await HypXERC20Lockbox__factory.connect(
config.token,
provider,
).xERC20();
const wrappedToken = await HypXERC20__factory.connect(
xERC20,
provider,
).wrappedToken();
return wrappedToken;
}

// todo: merge this with CollateralExtensions when CLI 2.0 is out
// https://github.com/hyperlane-xyz/hyperlane-monorepo/pull/3838/files#diff-a1429ad1c3e9d3fe43d28f08333e95f6c79176b6d36873e42e455e5e806826aaR16
config.type === TokenType.collateral ||
config.type == TokenType.collateralFiat
? config.token
: undefined;
if (
config.type === TokenType.collateral ||
config.type === TokenType.XERC20 ||
config.type === TokenType.collateralFiat
) {
return config.token;
}

return undefined;
})();
warpCoreConfig.tokens.push({
chainName,
standard: TOKEN_TYPE_TO_STANDARD[config.type],
Expand Down
1 change: 1 addition & 0 deletions typescript/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
Expand Down
16 changes: 16 additions & 0 deletions typescript/sdk/src/token/Token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ const STANDARD_TO_TOKEN: Record<TokenStandard, TokenArgs | null> = {
symbol: 'USDC',
name: 'USDC',
},
[TokenStandard.EvmHypXERC20]: {
chainName: TestChainName.test2,
standard: TokenStandard.EvmHypXERC20,
addressOrDenom: '0x8358D8291e3bEDb04804975eEa0fe9fe0fAfB147',
decimals: 6,
symbol: 'USDC',
name: 'USDC',
},
[TokenStandard.EvmHypXERC20Lockbox]: {
chainName: TestChainName.test2,
standard: TokenStandard.EvmHypXERC20Lockbox,
addressOrDenom: '0x8358D8291e3bEDb04804975eEa0fe9fe0fAfB147',
decimals: 6,
symbol: 'USDC',
name: 'USDC',
},

// Sealevel
[TokenStandard.SealevelSpl]: {
Expand Down
10 changes: 10 additions & 0 deletions typescript/sdk/src/token/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
EvmHypCollateralAdapter,
EvmHypNativeAdapter,
EvmHypSyntheticAdapter,
EvmHypXERC20Adapter,
EvmHypXERC20LockboxAdapter,
EvmNativeTokenAdapter,
EvmTokenAdapter,
} from './adapters/EvmTokenAdapter.js';
Expand Down Expand Up @@ -213,6 +215,14 @@ export class Token implements IToken {
return new EvmHypSyntheticAdapter(chainName, multiProvider, {
token: addressOrDenom,
});
} else if (standard === TokenStandard.EvmHypXERC20) {
return new EvmHypXERC20Adapter(chainName, multiProvider, {
token: addressOrDenom,
});
} else if (standard === TokenStandard.EvmHypXERC20Lockbox) {
return new EvmHypXERC20LockboxAdapter(chainName, multiProvider, {
token: addressOrDenom,
});
} else if (standard === TokenStandard.SealevelHypNative) {
return new SealevelHypNativeAdapter(
chainName,
Expand Down
12 changes: 10 additions & 2 deletions typescript/sdk/src/token/TokenStandard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export enum TokenStandard {
EvmHypNative = 'EvmHypNative',
EvmHypCollateral = 'EvmHypCollateral',
EvmHypSynthetic = 'EvmHypSynthetic',
EvmHypXERC20 = 'EvmHypXERC20',
EvmHypXERC20Lockbox = 'EvmHypXERC20Lockbox',

// Sealevel (Solana)
SealevelSpl = 'SealevelSpl',
Expand Down Expand Up @@ -48,6 +50,8 @@ export const TOKEN_STANDARD_TO_PROTOCOL: Record<TokenStandard, ProtocolType> = {
EvmHypNative: ProtocolType.Ethereum,
EvmHypCollateral: ProtocolType.Ethereum,
EvmHypSynthetic: ProtocolType.Ethereum,
EvmHypXERC20: ProtocolType.Ethereum,
EvmHypXERC20Lockbox: ProtocolType.Ethereum,

// Sealevel (Solana)
SealevelSpl: ProtocolType.Sealevel,
Expand Down Expand Up @@ -90,6 +94,8 @@ export const TOKEN_NFT_STANDARDS = [
export const TOKEN_COLLATERALIZED_STANDARDS = [
TokenStandard.EvmHypCollateral,
TokenStandard.EvmHypNative,
TokenStandard.EvmHypXERC20,
TokenStandard.EvmHypXERC20Lockbox,
TokenStandard.SealevelHypCollateral,
TokenStandard.SealevelHypNative,
TokenStandard.CwHypCollateral,
Expand All @@ -100,6 +106,8 @@ export const TOKEN_HYP_STANDARDS = [
TokenStandard.EvmHypNative,
TokenStandard.EvmHypCollateral,
TokenStandard.EvmHypSynthetic,
TokenStandard.EvmHypXERC20,
TokenStandard.EvmHypXERC20Lockbox,
TokenStandard.SealevelHypNative,
TokenStandard.SealevelHypCollateral,
TokenStandard.SealevelHypSynthetic,
Expand Down Expand Up @@ -128,8 +136,8 @@ export const TOKEN_TYPE_TO_STANDARD: Record<TokenType, TokenStandard> = {
[TokenType.native]: TokenStandard.EvmHypNative,
[TokenType.collateral]: TokenStandard.EvmHypCollateral,
[TokenType.collateralFiat]: TokenStandard.EvmHypCollateral,
[TokenType.XERC20]: TokenStandard.EvmHypCollateral,
[TokenType.XERC20Lockbox]: TokenStandard.EvmHypCollateral,
[TokenType.XERC20]: TokenStandard.EvmHypXERC20,
[TokenType.XERC20Lockbox]: TokenStandard.EvmHypXERC20Lockbox,
[TokenType.collateralVault]: TokenStandard.EvmHypCollateral,
[TokenType.collateralUri]: TokenStandard.EvmHypCollateral,
[TokenType.fastCollateral]: TokenStandard.EvmHypCollateral,
Expand Down
Loading

0 comments on commit 7cb2d10

Please sign in to comment.