Skip to content

Martinh/ntt supported chains #268

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

Merged
merged 10 commits into from
Jun 17, 2025
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
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"update": "npx npm-check-updates -u && npm install --silent",
"generate": "npx tsx src/index.ts",
"generate": "npx tsx src/fetchRelayerNTTChains.ts && npx tsx src/index.ts",
"check:consts": "npx tsx src/check.ts",
"check:links": "find ../docs -name \\*.md -print0 | xargs -0 -n1 npx markdown-link-check"
},
Expand Down
5 changes: 0 additions & 5 deletions scripts/src/chains/HyperEVM.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": true,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
5 changes: 0 additions & 5 deletions scripts/src/chains/Mezo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": false,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/Worldchain.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/blast.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
5 changes: 0 additions & 5 deletions scripts/src/chains/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
}
],
"products": {
"ntt": {
"mainnet": true,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
5 changes: 0 additions & 5 deletions scripts/src/chains/holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": false,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
1 change: 0 additions & 1 deletion scripts/src/chains/kaia.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"products": {
"connect": { "mainnet": true, "testnet": true, "devnet": false },
"ntt": { "mainnet": true, "testnet": true, "devnet": false },
"tokenBridge": { "mainnet": true, "testnet": true, "devnet": false }
}
}
10 changes: 5 additions & 5 deletions scripts/src/chains/klaytn.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": true,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
"devnet": true
},
"ntt": {
"mainnet": true,
"testnet": false,
"devnet": false
}
}
}
5 changes: 0 additions & 5 deletions scripts/src/chains/linea.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": false,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/mantle.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
5 changes: 0 additions & 5 deletions scripts/src/chains/neon.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
"testnet": true,
"devnet": false
},
"ntt": {
"mainnet": false,
"testnet": true,
"devnet": false
},
"multigov": {
"mainnet": true,
"testnet": true,
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/scroll.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/snaxchain.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"products": {
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/chains/xlayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"ntt": {
"mainnet": true,
"testnet": true,
"testnet": false,
"devnet": false
},
"tokenBridge": {
Expand Down
32 changes: 24 additions & 8 deletions scripts/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Chain,
} from '@wormhole-foundation/sdk';
import fs from 'fs';
import nttSupport from './generated/ntt-support.json';

// Many chains have the same underlying runtime
export type ChainType =
Expand Down Expand Up @@ -110,6 +111,10 @@ const chainTypeMapping: Record<Platform, ChainType> = {
Btc: 'BTC',
};

const chainNameOverrides: Record<string, string> = {
Klaytn: 'Kaia',
};

function getChainType(platformName: Platform): ChainType {
return chainTypeMapping[platformName] ?? '';
}
Expand Down Expand Up @@ -151,18 +156,21 @@ function getChainDetails(chainName: string): ExtraDetails {
}

// NTT
const platform = chainToPlatform(chainName as Chain);
const chainType = getChainType(platform);

// Only allow EVM and Solana (not other SVMs like Pythnet)
const isSupportedForNTT =
chainType === 'EVM' || (chainType === 'SVM' && chainName === 'Solana');
if (contracts.coreBridge && isSupportedForNTT) {
if (!products.ntt) products.ntt = { mainnet: false, testnet: false, devnet: false };
products.ntt[net.toLowerCase() as keyof ProductSupport] = true;
const effectiveChainName = chainNameOverrides[chainName] || chainName;
const isNTTSupported = (nttSupport[net] || []).includes(effectiveChainName) || (chainName === 'Solana' && net === 'Devnet');

// Ensure `products.ntt` is initialized even if unsupported
if (!products.ntt) {
products.ntt = { mainnet: false, testnet: false, devnet: false };
}

products.ntt[net.toLowerCase() as keyof ProductSupport] = isNTTSupported;

// Multigov
const platform = chainToPlatform(chainName as Chain);
const chainType = getChainType(platform);

const isMultigovEligible =
chainType === 'EVM' || (chainType === 'SVM' && chainName === 'Solana');

Expand All @@ -174,6 +182,14 @@ function getChainDetails(chainName: string): ExtraDetails {
}
}

// Remove any product with no support in any environment
for (const productKey of Object.keys(products) as (keyof Products)[]) {
const product = products[productKey];
if (!product?.mainnet && !product?.testnet && !product?.devnet) {
delete products[productKey];
}
}

// Only write if something was added
const updatedDetails = {
...existingDetails,
Expand Down
54 changes: 54 additions & 0 deletions scripts/src/fetchRelayerNTTChains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// This script fetches the relayer NTT chains from the Wormhole SDK repository
// and generates a JSON file with the supported chains for each network.

import axios from 'axios';
import fs from 'fs';

// The below mapping is used to override the chain names in the output.
const chainNameOverrides: Record<string, string> = {
Klaytn: "Kaia",
};

// The URL to the relayer file in the Wormhole SDK repository.
const RELAYER_FILE_URL = 'https://raw.githubusercontent.com/wormhole-foundation/wormhole-sdk-ts/main/core/base/src/constants/contracts/relayer.ts';

async function extractRelayerNTTChains() {
const res = await axios.get(RELAYER_FILE_URL);
const text = res.data;

const relayerChains: Record<string, string[]> = {
Mainnet: [],
Testnet: [],
Devnet: [],
};

const networkBlockRegex = /\[\s*"(\w+)"\s*,\s*\[((?:.|\n)*?)\]\s*\]/gm;
let match;
while ((match = networkBlockRegex.exec(text)) !== null) {
const network = match[1];
const body = match[2];

const chainRegex = /\[\s*"([\w\d]+)"\s*,\s*"0x[a-fA-F0-9]{40}"\s*\]/g;
let chainMatch;
while ((chainMatch = chainRegex.exec(body)) !== null) {
const originalName = chainMatch[1];
const normalizedName = chainNameOverrides[originalName] || originalName;

relayerChains[network].push(normalizedName);
}
}

relayerChains.Mainnet.push('Solana');
relayerChains.Testnet.push('Solana');

for (const net of Object.keys(relayerChains)) {
relayerChains[net] = [...new Set(relayerChains[net])];
}

fs.mkdirSync('./src/generated', { recursive: true });
fs.writeFileSync('./src/generated/ntt-support.json', JSON.stringify(relayerChains, null, 2));

console.log('Wrote NTT relayer support to scripts/generated/ntt-support.json');
}

extractRelayerNTTChains();
53 changes: 53 additions & 0 deletions scripts/src/generated/ntt-support.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"Mainnet": [
"Ethereum",
"Bsc",
"Polygon",
"Avalanche",
"Fantom",
"Kaia",
"Celo",
"Moonbeam",
"Base",
"Arbitrum",
"Optimism",
"Blast",
"Scroll",
"Mantle",
"Xlayer",
"Berachain",
"Seievm",
"Ink",
"Worldchain",
"Snaxchain",
"Unichain",
"Solana"
],
"Testnet": [
"Ethereum",
"Bsc",
"Polygon",
"Avalanche",
"Fantom",
"Celo",
"Seievm",
"Moonbeam",
"Arbitrum",
"Optimism",
"Base",
"Sepolia",
"ArbitrumSepolia",
"BaseSepolia",
"OptimismSepolia",
"Berachain",
"Unichain",
"Ink",
"Monad",
"PolygonSepolia",
"Solana"
],
"Devnet": [
"Ethereum",
"Bsc"
]
}