Skip to content

Commit

Permalink
Add mantle (#2197)
Browse files Browse the repository at this point in the history
* Added Mantle mainnet and testnet networks

* removed isSupportedChain sdkv2 test
  • Loading branch information
kev1n-peters authored Jun 18, 2024
1 parent 39bfab0 commit 12cb770
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 38 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ By default, it offers its full built-in list for both `mainnet` and `testnet`:
| scroll | scroll |
| blast | blast |
| xlayer | xlayer |

> Osmosis support is in beta, reach out to a Wormhole contributor for early access.
| mantle | mantle |

### Learn More

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"sideEffects": false,
"dependencies": {
"@certusone/wormhole-sdk": "^0.10.16",
"@certusone/wormhole-sdk": "^0.10.17",
"@cosmjs/cosmwasm-stargate": "^0.31.3",
"@cosmjs/proto-signing": "^0.31.3",
"@cosmjs/stargate": "^0.31.3",
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/config/MAINNET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const MAINNET_CHAINS = {
base: 30,
sei: 32,
scroll: 34,
mantle: 35,
blast: 36,
xlayer: 37,
wormchain: 3104,
Expand Down Expand Up @@ -288,6 +289,16 @@ const MAINNET: { [chain in MainnetChainName]: ChainConfig } = {
finalityThreshold: 0,
nativeTokenDecimals: 18,
},
mantle: {
key: 'mantle',
id: 35,
context: Context.ETH,
contracts: {
...CONTRACTS.MAINNET.mantle,
},
finalityThreshold: 0,
nativeTokenDecimals: 18,
},
blast: {
key: 'blast',
id: 36,
Expand Down Expand Up @@ -396,6 +407,7 @@ const MAINNET_CONFIG: WormholeConfig = {
scroll: 'https://rpc.ankr.com/scroll',
blast: 'https://rpc.ankr.com/blast',
xlayer: 'https://rpc.xlayer.tech',
mantle: 'https://rpc.mantle.xyz',
},
rest: {
sei: '',
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/config/TESTNET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const TESTNET_CHAINS = {
basegoerli: 30,
sei: 32,
scroll: 34,
mantle: 35,
blast: 36,
xlayer: 37,
wormchain: 3104,
Expand Down Expand Up @@ -274,6 +275,16 @@ const TESTNET: { [chain in TestnetChainName]: ChainConfig } = {
finalityThreshold: 0,
nativeTokenDecimals: 18,
},
mantle: {
key: 'mantle',
id: 35,
context: Context.ETH,
contracts: {
...CONTRACTS.TESTNET.mantle,
},
finalityThreshold: 0,
nativeTokenDecimals: 18,
},
blast: {
key: 'blast',
id: 36,
Expand Down Expand Up @@ -434,6 +445,7 @@ const TESTNET_CONFIG: WormholeConfig = {
scroll: 'https://rpc.ankr.com/scroll_sepolia_testnet',
blast: 'https://rpc.ankr.com/blast_testnet_sepolia',
xlayer: 'https://testrpc.xlayer.tech',
mantle: 'https://rpc.testnet.mantle.xyz',
},
rest: {
sei: 'https://rest.atlantic-2.seinetwork.io',
Expand Down
11 changes: 11 additions & 0 deletions wormhole-connect/src/config/mainnet/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,15 @@ export const MAINNET_CHAINS: ChainsConfig = {
automaticRelayer: false,
maxBlockSearch: 2000,
},
mantle: {
...chains.mantle!,
displayName: 'Mantle',
explorerUrl: 'https://explorer.mantle.xyz/',
explorerName: 'Mantle Explorer',
gasToken: 'MNT',
chainId: 5000,
icon: Icon.MANTLE,
automaticRelayer: false,
maxBlockSearch: 2000,
},
};
7 changes: 7 additions & 0 deletions wormhole-connect/src/config/mainnet/gasEstimates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,11 @@ export const MAINNET_GAS_ESTIMATES: GasEstimates = {
claim: 300000,
},
},
mantle: {
[Route.Bridge]: {
sendNative: 100000,
sendToken: 100000,
claim: 300000,
},
},
};
2 changes: 2 additions & 0 deletions wormhole-connect/src/config/mainnet/rpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
REACT_APP_SCROLL_RPC,
REACT_APP_BLAST_RPC,
REACT_APP_XLAYER_RPC,
REACT_APP_MANTLE_RPC,
} = import.meta.env;

export const MAINNET_RPC_MAPPING = {
Expand All @@ -52,6 +53,7 @@ export const MAINNET_RPC_MAPPING = {
...populateRpcField('scroll', REACT_APP_SCROLL_RPC),
...populateRpcField('blast', REACT_APP_BLAST_RPC),
...populateRpcField('xlayer', REACT_APP_XLAYER_RPC),
...populateRpcField('mantle', REACT_APP_MANTLE_RPC),
};

export const MAINNET_REST_MAPPING = {
Expand Down
27 changes: 27 additions & 0 deletions wormhole-connect/src/config/mainnet/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2802,4 +2802,31 @@ export const MAINNET_TOKENS: TokensConfig = {
default: 8,
},
},
MNT: {
key: 'MNT',
symbol: 'MNT',
nativeChain: 'mantle',
icon: Icon.MANTLE,
coinGeckoId: 'mantle',
decimals: {
Ethereum: 18,
default: 8,
},
wrappedAsset: 'WMNT',
},
WMNT: {
key: 'WMNT',
symbol: 'WMNT',
nativeChain: 'mantle',
icon: Icon.MANTLE,
tokenId: {
chain: 'mantle',
address: '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8',
},
coinGeckoId: 'mantle',
decimals: {
Ethereum: 18,
default: 8,
},
},
};
11 changes: 11 additions & 0 deletions wormhole-connect/src/config/testnet/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,15 @@ export const TESTNET_CHAINS: ChainsConfig = {
automaticRelayer: false,
maxBlockSearch: 2000,
},
mantle: {
...chains.mantle!,
displayName: 'Mantle',
explorerUrl: 'https://explorer.testnet.mantle.xyz/',
explorerName: 'Mantle Explorer',
gasToken: 'MNT',
chainId: 5001,
icon: Icon.MANTLE,
automaticRelayer: false,
maxBlockSearch: 2000,
},
};
7 changes: 7 additions & 0 deletions wormhole-connect/src/config/testnet/gasEstimates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,11 @@ export const TESTNET_GAS_ESTIMATES: GasEstimates = {
claim: 200000,
},
},
mantle: {
[Route.Bridge]: {
sendNative: 100000,
sendToken: 150000,
claim: 200000,
},
},
};
2 changes: 2 additions & 0 deletions wormhole-connect/src/config/testnet/rpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const {
REACT_APP_SCROLL_TESTNET_RPC,
REACT_APP_BLAST_TESTNET_RPC,
REACT_APP_XLAYER_TESTNET_RPC,
REACT_APP_MANTLE_TESTNET_RPC,
} = import.meta.env;

export const TESTNET_RPC_MAPPING = {
Expand Down Expand Up @@ -62,6 +63,7 @@ export const TESTNET_RPC_MAPPING = {
...populateRpcField('scroll', REACT_APP_SCROLL_TESTNET_RPC),
...populateRpcField('blast', REACT_APP_BLAST_TESTNET_RPC),
...populateRpcField('xlayer', REACT_APP_XLAYER_TESTNET_RPC),
...populateRpcField('mantle', REACT_APP_MANTLE_TESTNET_RPC),
};

export const TESTNET_REST_MAPPING = {
Expand Down
27 changes: 27 additions & 0 deletions wormhole-connect/src/config/testnet/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2347,4 +2347,31 @@ export const TESTNET_TOKENS: TokensConfig = {
default: 8,
},
},
MNT: {
key: 'MNT',
symbol: 'MNT',
nativeChain: 'mantle',
icon: Icon.MANTLE,
coinGeckoId: 'mantle',
decimals: {
Ethereum: 18,
default: 8,
},
wrappedAsset: 'WMNT',
},
WMNT: {
key: 'WMNT',
symbol: 'WMNT',
nativeChain: 'mantle',
icon: Icon.MANTLE,
tokenId: {
chain: 'mantle',
address: '0xa4c4cb2A072eE99f77212Fa18c2B7Ca26DA23905',
},
coinGeckoId: 'mantle',
decimals: {
Ethereum: 18,
default: 8,
},
},
};
1 change: 1 addition & 0 deletions wormhole-connect/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export enum Icon {
'SCROLL',
'BLAST',
'XLAYER',
'MANTLE',
}

export enum Route {
Expand Down
1 change: 1 addition & 0 deletions wormhole-connect/src/icons/TokenIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const iconMap: { [key in Icon]: React.JSX.Element } = {
[Icon.SCROLL]: SCROLL(),
[Icon.BLAST]: BLAST(),
[Icon.XLAYER]: <img src={chainToIcon('Xlayer')} />,
[Icon.MANTLE]: <img src={chainToIcon('Mantle')} />,
};

function isBuiltinIcon(icon?: Icon | string): icon is Icon {
Expand Down
2 changes: 1 addition & 1 deletion wormhole-connect/src/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const isIlliquidDestToken = (
['ETH', 'WETH'].includes(symbol) &&
nativeChain === 'ethereum' &&
// These are L2 chains that have a native bridge
(destChain === 'scroll' || destChain === 'blast')
(destChain === 'scroll' || destChain === 'blast' || destChain === 'mantle')
) {
return true;
}
Expand Down
30 changes: 0 additions & 30 deletions wormhole-connect/tests/ci/sdkv2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,36 +213,6 @@ describe('token', () => {
}
});

describe('compare isSupportedChain between v1 and v2 routes', () => {
const compareChains = (network: NetworkV1) => {
const chains = chainLists[network];

for (const chain of chains) {
for (let [RouteV1, RouteV2] of routeMappings) {
if (
(chain === 'evmos' || chain == 'osmosis' || chain === 'kujira') &&
(RouteV2.meta.name === 'ManualTokenBridge' ||
RouteV2.meta.name === 'AutomaticTokenBridge')
) {
// Temp hack. These are treated differently in SDKv2
continue;
}

test(`${RouteV1.name} (v1) vs. ${RouteV2.meta.name} (v2) - isSupportedChain(${chain})`, () => {
const v1Route = new RouteV1();
const v2Route = new SDKv2Route(network, RouteV2);
const isSupportedV1 = v1Route.isSupportedChain(chain);
const isSupportedV2 = v2Route.isSupportedChain(chain);
expect(isSupportedV1).toEqual(isSupportedV2);
});
}
}
};

compareChains('mainnet');
//compareChains('testnet');
});

describe('compare isSupportedSourceToken between v1 and v2 routes', () => {
const compareTokens = (network: NetworkV1) => {
const tokens = tokenLists[network];
Expand Down

0 comments on commit 12cb770

Please sign in to comment.