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

Feature: Native Token Transfers (NTT) integration #1674

Merged
merged 17 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ See the "Arbitrary Token" example in [the config docs](https://docs.wormhole.com

Please note you have to [register a token](https://portalbridge.com/advanced-tools/#/register) with the token bridge before you can use it in Connect.

### Configuring Custom NTT (Native Token Transfer) Groups
To configure custom NTT groups, include an `nttGroups` key in your configuration.

```ts
const config: WormholeConnectConfig = {
nttGroups: {
// Your custom NTT groups go here
}
}
```

For a practical example of how to structure your custom NTT groups, refer to the [nttGroups.ts](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/config/testnet/nttGroups.ts) file.

Please note that the `tokenKey` specified in your custom NTT group must correspond to an existing entry in the tokensConfig, whether it's a built-in or a custom token.

### Custom Theme

You can also customize Connect's color scheme by providing a `WormholeConnectTheme` as the `theme` prop.
Expand Down
14 changes: 14 additions & 0 deletions builder/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ export const ROUTE_INFOS: RouteInfo[] = [
title: "wstETH Bridge",
description: "Permissionlessly transfer wstETH cross-chain with Wormhole.",
},
{
key: "nttManual",
title: "Native Token Transfer",
description:
"Permissionlessly transfer native tokens cross-chain with Wormhole.",
link: "https://github.com/wormhole-foundation/example-native-token-transfers/blob/main/README.md",
},
{
key: "nttRelay",
title: "Native Token Transfer Automatic Redeems",
description:
"Automatic redeems for Native Token Transfers powered by xLabs.",
link: "https://github.com/wormhole-foundation/example-native-token-transfers/blob/main/README.md",
},
];
export const ROUTES = ROUTE_INFOS.map((r) => r.key);

Expand Down
131 changes: 96 additions & 35 deletions package-lock.json

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

13 changes: 6 additions & 7 deletions sdk/src/config/TESTNET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ const TESTNET: { [chain in TestnetChainName]: ChainConfig } = {
contracts: {
...CONTRACTS.TESTNET.ethereum,
relayer: '0x9563a59c15842a6f322b10f69d1dd88b41f2e97b',
cctpContracts: {
kev1n-peters marked this conversation as resolved.
Show resolved Hide resolved
cctpTokenMessenger: '0xd0c3da58f55358142b8d3e06c1c30c5c6114efe8',
cctpMessageTransmitter: '0x26413e8157cd32011e726065a5462e97dd4d03d9',
wormholeCircleRelayer: '0x17da1ff5386d044c63f00747b5b8ad1e3806448d',
wormholeCCTP: '0x0a69146716b3a21622287efa1607424c663069a4',
},
},
finalityThreshold: 64,
nativeTokenDecimals: 18,
Expand Down Expand Up @@ -323,9 +317,14 @@ const TESTNET: { [chain in TestnetChainName]: ChainConfig } = {
context: Context.ETH,
contracts: {
...CONTRACTS.TESTNET.sepolia,
cctpContracts: {
cctpTokenMessenger: '0x9f3b8679c73c2fef8b59b4f3444d4e156fb70aa5',
cctpMessageTransmitter: '0x7865fafc2db2093669d92c0f33aeef291086befd',
},
},
finalityThreshold: 0,
nativeTokenDecimals: 18,
cctpDomain: 0,
},
arbitrum_sepolia: {
key: 'arbitrum_sepolia',
Expand Down Expand Up @@ -397,7 +396,7 @@ const TESTNET_CONFIG: WormholeConfig = {
klaytn: 'https://rpc.ankr.com/klaytn_testnet',
sepolia: 'https://rpc.ankr.com/eth_sepolia',
arbitrum_sepolia: 'https://sepolia-rollup.arbitrum.io/rpc',
base_sepolia: 'https://sepolia.base.org',
base_sepolia: 'https://base-sepolia-rpc.publicnode.com',
optimism_sepolia: 'https://sepolia.optimism.io',
},
rest: {
Expand Down
6 changes: 4 additions & 2 deletions wormhole-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"dependencies": {
"@certusone/wormhole-sdk": "^0.10.10",
"@coral-xyz/anchor": "^0.29.0",
"@cosmjs/cosmwasm-stargate": "^0.31.3",
"@cosmjs/stargate": "^0.31.3",
"@cosmjs/tendermint-rpc": "^0.31.3",
Expand All @@ -30,7 +31,7 @@
"@reduxjs/toolkit": "^1.9.1",
"@solana/wallet-adapter-wallets": "^0.19.25",
"@solana/web3.js": "^1.73.0",
"@wormhole-foundation/sdk-definitions": "^0.5.0",
"@wormhole-foundation/sdk-definitions": "^0.5.2-beta.0",
kev1n-peters marked this conversation as resolved.
Show resolved Hide resolved
"@xlabs-libs/wallet-aggregator-aptos": "^0.0.1-alpha.14",
"@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.18",
"@xlabs-libs/wallet-aggregator-cosmos": "^0.0.1-alpha.14",
Expand Down Expand Up @@ -62,7 +63,8 @@
"prettier": "prettier --write ./src",
"analyze": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=6144 vite-bundle-visualizer",
"test": "jest ./tests/*.test.ts --detectOpenHandles",
"checksdn": "npx tsx scripts/ofac/checkSdnListForUpdates.ts"
"checksdn": "npx tsx scripts/ofac/checkSdnListForUpdates.ts",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
Expand Down
4 changes: 4 additions & 0 deletions wormhole-connect/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { setRoute } from './store/router';
import { clearWallets } from './store/wallet';
import { clearPorticoBridge } from 'store/porticoBridge';
import { useExternalSearch } from 'hooks/useExternalSearch';
import { clearNtt } from 'store/ntt';
import internalConfig from 'config';

const useStyles = makeStyles()((theme: any) => ({
appContent: {
Expand Down Expand Up @@ -71,6 +73,8 @@ function AppRouter({ config }: Props) {
if (prevRoute === redeemRoute && route !== redeemRoute) {
dispatch(clearRedeem());
dispatch(clearWallets());
dispatch(clearNtt());
kev1n-peters marked this conversation as resolved.
Show resolved Hide resolved
internalConfig.wh.registerProviders(); // reset providers that may have been set during transfer
}
// reset transfer state on leave
if (prevRoute === bridgeRoute && route !== bridgeRoute) {
Expand Down
2 changes: 2 additions & 0 deletions wormhole-connect/src/config/devnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DEVNET_RPC_MAPPING,
} from './rpcs';
import { DEVNET_TOKENS } from './tokens';
import { DEVNET_NTT_GROUPS } from './nttGroups';

export * from './chains';
export * from './gasEstimates';
Expand All @@ -20,6 +21,7 @@ const DEVNET: NetworkData = {
rpcs: DEVNET_RPC_MAPPING,
rest: DEVNET_REST_MAPPING,
graphql: DEVNET_GRAPHQL_MAPPING,
nttGroups: DEVNET_NTT_GROUPS,
};

export default DEVNET;
3 changes: 3 additions & 0 deletions wormhole-connect/src/config/devnet/nttGroups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { NttGroups } from 'config/types';

export const DEVNET_NTT_GROUPS: NttGroups = {};
13 changes: 12 additions & 1 deletion wormhole-connect/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import TESTNET from './testnet';
import DEVNET from './devnet';
import type { WormholeConnectConfig } from './types';
import { Network, InternalConfig, Route, TokensConfig } from './types';
import { mergeCustomTokensConfig, validateDefaults } from './utils';
import {
mergeCustomTokensConfig,
mergeNttGroups,
validateDefaults,
} from './utils';

export function buildConfig(
customConfig?: WormholeConnectConfig,
Expand Down Expand Up @@ -132,6 +136,13 @@ export function buildConfig(
// Route options
ethBridgeMaxAmount: customConfig?.ethBridgeMaxAmount ?? 5,
wstETHBridgeMaxAmount: customConfig?.wstETHBridgeMaxAmount ?? 5,

// NTT config
nttGroups: mergeNttGroups(
tokens,
networkData.nttGroups,
customConfig?.nttGroups,
),
};
}

Expand Down
14 changes: 14 additions & 0 deletions wormhole-connect/src/config/mainnet/gasEstimates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export const MAINNET_GAS_ESTIMATES: GasEstimates = {
sendToken: 300000,
claim: 450000,
},
[Route.NttManual]: {
sendToken: 10000000,
claim: 10000000,
},
[Route.NttRelay]: {
sendToken: 10000000,
},
},
polygon: {
[Route.Bridge]: {
Expand Down Expand Up @@ -107,6 +114,13 @@ export const MAINNET_GAS_ESTIMATES: GasEstimates = {
sendNative: 250000,
sendToken: 300000,
},
[Route.NttManual]: {
sendToken: 10000000,
claim: 10000000,
},
[Route.NttRelay]: {
sendToken: 10000000,
},
},
celo: {
[Route.Bridge]: {
Expand Down
2 changes: 2 additions & 0 deletions wormhole-connect/src/config/mainnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MAINNET_RPC_MAPPING,
} from './rpcs';
import { MAINNET_TOKENS } from './tokens';
import { MAINNET_NTT_GROUPS } from './nttGroups';

export * from './chains';
export * from './gasEstimates';
Expand All @@ -20,6 +21,7 @@ const MAINNET: NetworkData = {
rpcs: MAINNET_RPC_MAPPING,
rest: MAINNET_REST_MAPPING,
graphql: MAINNET_GRAPHQL_MAPPING,
nttGroups: MAINNET_NTT_GROUPS,
};

export default MAINNET;
Loading
Loading