-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters