From 78169eaa99c9de010e4bf69ce944df2968f3719c Mon Sep 17 00:00:00 2001 From: Martin Hofmann Date: Tue, 17 Jun 2025 11:20:54 -0400 Subject: [PATCH 1/2] Martinh/ntt supported chains (#268) * logic to fetch ntt supported chains * import new logic * update script to fetch ntt supported chains * update ntt supported chains * ntt supported chains file * updae script for ntt * update script to map klaytn to kaia * update chain name * prettier check * prettier --- scripts/package.json | 2 +- scripts/src/chains/HyperEVM.json | 5 --- scripts/src/chains/Mezo.json | 5 --- scripts/src/chains/Worldchain.json | 2 +- scripts/src/chains/blast.json | 2 +- scripts/src/chains/gnosis.json | 5 --- scripts/src/chains/holesky.json | 5 --- scripts/src/chains/kaia.json | 1 - scripts/src/chains/klaytn.json | 10 ++--- scripts/src/chains/linea.json | 5 --- scripts/src/chains/mantle.json | 2 +- scripts/src/chains/neon.json | 5 --- scripts/src/chains/scroll.json | 2 +- scripts/src/chains/snaxchain.json | 2 +- scripts/src/chains/xlayer.json | 2 +- scripts/src/config.ts | 32 +++++++++++---- scripts/src/fetchRelayerNTTChains.ts | 54 ++++++++++++++++++++++++++ scripts/src/generated/ntt-support.json | 53 +++++++++++++++++++++++++ 18 files changed, 143 insertions(+), 51 deletions(-) create mode 100644 scripts/src/fetchRelayerNTTChains.ts create mode 100644 scripts/src/generated/ntt-support.json diff --git a/scripts/package.json b/scripts/package.json index 968986059..3c7d65c80 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 757c0fac4..c13c41933 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 86790e97b..4f1a37138 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 a4759a082..ff1f0b6b8 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 4538be564..be88411ca 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 b2e5b860f..0ce2ced57 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 5284ae13e..5790dff78 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 845d2a3bf..6a692829e 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 2f4226f05..5bae48029 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 ccf440eb2..963859a19 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 8ed15ea6d..dfbbd7c67 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 86e30e222..507a4ee9b 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 4fe3e31eb..1d64b6d5b 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 9498f0696..a4c36d8f3 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 3cc02fc39..6d0b27085 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 8f938c336..6c0e01c6d 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 000000000..96018e110 --- /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 000000000..12237904d --- /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 From 7253d8ad5981732d164adfeda979515376fc8bb7 Mon Sep 17 00:00:00 2001 From: Ilaria <43253244+ilariae@users.noreply.github.com> Date: Tue, 17 Jun 2025 17:40:43 +0200 Subject: [PATCH 2/2] Update submodule to dc83eab (#271) Co-authored-by: Ilaria Enache --- wormhole-docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wormhole-docs b/wormhole-docs index c7cc22832..dc83eabe8 160000 --- a/wormhole-docs +++ b/wormhole-docs @@ -1 +1 @@ -Subproject commit c7cc22832edc95714a339bcfc6f85378590528e4 +Subproject commit dc83eabe87a59c1dd5cabca7bfa408307aa65cfa