diff --git a/scripts/package.json b/scripts/package.json index 96898605..3c7d65c8 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -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" }, diff --git a/scripts/src/chains/HyperEVM.json b/scripts/src/chains/HyperEVM.json index 757c0fac..c13c4193 100644 --- a/scripts/src/chains/HyperEVM.json +++ b/scripts/src/chains/HyperEVM.json @@ -17,11 +17,6 @@ "testnet": true, "devnet": false }, - "ntt": { - "mainnet": true, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/Mezo.json b/scripts/src/chains/Mezo.json index 86790e97..4f1a3713 100644 --- a/scripts/src/chains/Mezo.json +++ b/scripts/src/chains/Mezo.json @@ -23,11 +23,6 @@ "testnet": true, "devnet": false }, - "ntt": { - "mainnet": false, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/Worldchain.json b/scripts/src/chains/Worldchain.json index a4759a08..ff1f0b6b 100644 --- a/scripts/src/chains/Worldchain.json +++ b/scripts/src/chains/Worldchain.json @@ -28,7 +28,7 @@ }, "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/chains/blast.json b/scripts/src/chains/blast.json index 4538be56..be88411c 100644 --- a/scripts/src/chains/blast.json +++ b/scripts/src/chains/blast.json @@ -33,7 +33,7 @@ }, "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/chains/gnosis.json b/scripts/src/chains/gnosis.json index b2e5b860..0ce2ced5 100644 --- a/scripts/src/chains/gnosis.json +++ b/scripts/src/chains/gnosis.json @@ -23,11 +23,6 @@ } ], "products": { - "ntt": { - "mainnet": true, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/holesky.json b/scripts/src/chains/holesky.json index 5284ae13..5790dff7 100644 --- a/scripts/src/chains/holesky.json +++ b/scripts/src/chains/holesky.json @@ -26,11 +26,6 @@ "testnet": true, "devnet": false }, - "ntt": { - "mainnet": false, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/kaia.json b/scripts/src/chains/kaia.json index 845d2a3b..6a692829 100644 --- a/scripts/src/chains/kaia.json +++ b/scripts/src/chains/kaia.json @@ -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 } } } diff --git a/scripts/src/chains/klaytn.json b/scripts/src/chains/klaytn.json index 2f4226f0..5bae4802 100644 --- a/scripts/src/chains/klaytn.json +++ b/scripts/src/chains/klaytn.json @@ -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 } } } \ No newline at end of file diff --git a/scripts/src/chains/linea.json b/scripts/src/chains/linea.json index ccf440eb..963859a1 100644 --- a/scripts/src/chains/linea.json +++ b/scripts/src/chains/linea.json @@ -30,11 +30,6 @@ "testnet": true, "devnet": false }, - "ntt": { - "mainnet": false, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/mantle.json b/scripts/src/chains/mantle.json index 8ed15ea6..dfbbd7c6 100644 --- a/scripts/src/chains/mantle.json +++ b/scripts/src/chains/mantle.json @@ -34,7 +34,7 @@ }, "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/chains/neon.json b/scripts/src/chains/neon.json index 86e30e22..507a4ee9 100644 --- a/scripts/src/chains/neon.json +++ b/scripts/src/chains/neon.json @@ -28,11 +28,6 @@ "testnet": true, "devnet": false }, - "ntt": { - "mainnet": false, - "testnet": true, - "devnet": false - }, "multigov": { "mainnet": true, "testnet": true, diff --git a/scripts/src/chains/scroll.json b/scripts/src/chains/scroll.json index 4fe3e31e..1d64b6d5 100644 --- a/scripts/src/chains/scroll.json +++ b/scripts/src/chains/scroll.json @@ -37,7 +37,7 @@ }, "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/chains/snaxchain.json b/scripts/src/chains/snaxchain.json index 9498f069..a4c36d8f 100644 --- a/scripts/src/chains/snaxchain.json +++ b/scripts/src/chains/snaxchain.json @@ -19,7 +19,7 @@ "products": { "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/chains/xlayer.json b/scripts/src/chains/xlayer.json index 3cc02fc3..6d0b2708 100644 --- a/scripts/src/chains/xlayer.json +++ b/scripts/src/chains/xlayer.json @@ -34,7 +34,7 @@ }, "ntt": { "mainnet": true, - "testnet": true, + "testnet": false, "devnet": false }, "tokenBridge": { diff --git a/scripts/src/config.ts b/scripts/src/config.ts index 8f938c33..6c0e01c6 100644 --- a/scripts/src/config.ts +++ b/scripts/src/config.ts @@ -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 = @@ -110,6 +111,10 @@ const chainTypeMapping: Record = { Btc: 'BTC', }; +const chainNameOverrides: Record = { + Klaytn: 'Kaia', +}; + function getChainType(platformName: Platform): ChainType { return chainTypeMapping[platformName] ?? ''; } @@ -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'); @@ -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, diff --git a/scripts/src/fetchRelayerNTTChains.ts b/scripts/src/fetchRelayerNTTChains.ts new file mode 100644 index 00000000..96018e11 --- /dev/null +++ b/scripts/src/fetchRelayerNTTChains.ts @@ -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 = { + 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 = { + 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(); diff --git a/scripts/src/generated/ntt-support.json b/scripts/src/generated/ntt-support.json new file mode 100644 index 00000000..12237904 --- /dev/null +++ b/scripts/src/generated/ntt-support.json @@ -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" + ] +} \ No newline at end of file