diff --git a/examples/package.json b/examples/package.json index 9c658c9a0a..1ca13b5b2d 100644 --- a/examples/package.json +++ b/examples/package.json @@ -34,6 +34,7 @@ }, "sideEffects": false, "scripts": { + "testing":"tsx src/testing.ts", "tb": "tsx src/tokenBridge.ts", "cctp": "tsx src/cctp.ts", "demo": "tsx src/index.ts", diff --git a/examples/src/testing.ts b/examples/src/testing.ts new file mode 100644 index 0000000000..297318281d --- /dev/null +++ b/examples/src/testing.ts @@ -0,0 +1,42 @@ +import { CONFIG, ChainConfig, ChainContext, ChainName, PlatformName, Wormhole, WormholeConfig, normalizeAmount } from "@wormhole-foundation/connect-sdk"; +import { EvmPlatform } from "@wormhole-foundation/connect-sdk-evm"; +import { SolanaPlatform } from "@wormhole-foundation/connect-sdk-solana"; + + +function overrideChainSetting(conf: WormholeConfig, chain: ChainName, setting: keyof ChainConfig, value: any): WormholeConfig { + // @ts-ignore + conf.chains[chain] = { ...conf.chains[chain], [setting]: value } + return conf +} + +async function getNative(chain: ChainContext): Promise { + try { + const tb = await chain.getTokenBridge() + const addy = await tb.getWrappedNative() + return addy.toString() + } catch (e) { + console.error("Could not get native for: ", chain.chain) + console.error(e) + } + return "" +} + +(async function () { + const network = "Devnet" + + let cnf: WormholeConfig = CONFIG[network] + cnf = overrideChainSetting(cnf, "Ethereum", "rpc", "http://localhost:8545") + cnf = overrideChainSetting(cnf, "Bsc", "rpc", "http://localhost:8546") + cnf = overrideChainSetting(cnf, "Solana", "rpc", "http://localhost:8899") + + const wh = new Wormhole(network, [EvmPlatform, SolanaPlatform], cnf); + + + const eth = wh.getChain("Ethereum"); + const bsc = wh.getChain("Bsc") + const sol = wh.getChain("Solana") + + console.log(await getNative(eth)) + console.log(await getNative(bsc)) + console.log(await getNative(sol)) +})(); \ No newline at end of file diff --git a/platforms/evm/src/constants.ts b/platforms/evm/src/constants.ts index 2b13968b57..2be5b8846a 100644 --- a/platforms/evm/src/constants.ts +++ b/platforms/evm/src/constants.ts @@ -55,6 +55,12 @@ const networkChainEvmCIdEntries = [ ['Sepolia', 11155111n], //actually just another ethereum testnet... ], ], + [ + "Devnet", + [ + ["Bsc", 1397n] + ] + ] ] as const satisfies RoArray< readonly [Network, RoArray, bigint]>] >; diff --git a/platforms/solana/src/constants.ts b/platforms/solana/src/constants.ts index a03455bb7e..605ffbe679 100644 --- a/platforms/solana/src/constants.ts +++ b/platforms/solana/src/constants.ts @@ -8,6 +8,7 @@ import { const networkChainSolanaGenesisHashes = [ ['Mainnet', [['Solana', '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d']]], ['Testnet', [['Solana', 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG']]], // Note: this is referred to as `devnet` in sol + ['Devnet', [['Solana', 'DJFsKjBLis7jFd5QpqjV4YbmGMFGfN93e8qhhzD3tsjr']]] // Note: this is only for local testing with Tilt ] as const satisfies RoArray< readonly [Network, RoArray] >;