Skip to content

Commit

Permalink
starting to do tilt testing
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Oct 17, 2023
1 parent 62cfe43 commit 6e9399c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
42 changes: 42 additions & 0 deletions examples/src/testing.ts
Original file line number Diff line number Diff line change
@@ -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<PlatformName>): Promise<string> {
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))
})();
6 changes: 6 additions & 0 deletions platforms/evm/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const networkChainEvmCIdEntries = [
['Sepolia', 11155111n], //actually just another ethereum testnet...
],
],
[
"Devnet",
[
["Bsc", 1397n]
]
]
] as const satisfies RoArray<
readonly [Network, RoArray<readonly [PlatformToChains<'Evm'>, bigint]>]
>;
Expand Down
1 change: 1 addition & 0 deletions platforms/solana/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<readonly [ChainName, string]>]
>;
Expand Down

0 comments on commit 6e9399c

Please sign in to comment.