Skip to content

Commit

Permalink
updated rpcs so we dont have to override config
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Oct 18, 2023
1 parent 1b42fad commit 26e3148
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
21 changes: 21 additions & 0 deletions __tests__/tilt/helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
ChainAddress,
ChainConfig,
ChainContext,
ChainName,
PlatformName,
PlatformToChains,
Signer,
WormholeConfig,
nativeChainAddress,
rpcAddress,
} from "@wormhole-foundation/connect-sdk";
Expand Down Expand Up @@ -94,3 +96,22 @@ export async function getCosmosSigner(

return new CosmosSigner(chain.chain, signingClient, acct);
}



// const conf = overrideChainSetting(CONFIG[network], {
// "Ethereum": { "rpc": "http://localhost:8545" },
// "Bsc": { "rpc": "http://localhost:8546" },
// "Solana": { "rpc": "http://localhost:8899" }
// })

export type ConfigOverride = {
[key: string]: Partial<ChainConfig>
}
export function overrideChainSetting(conf: WormholeConfig, overrides: ConfigOverride): WormholeConfig {
for (const [cn, oride] of Object.entries(overrides)) {
// @ts-ignore
conf.chains[cn] = { ...conf.chains[cn], ...oride }
}
return conf
}
23 changes: 4 additions & 19 deletions __tests__/tilt/tokenbridge.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
import { TokenBridge, CONFIG, ChainConfig, Wormhole, WormholeConfig, isWormholeMessageId, nativeChainAddress, normalizeAmount, NativeAddress, Signer, ChainAddress } from "@wormhole-foundation/connect-sdk";
import { signSendWait } from "@wormhole-foundation/connect-sdk/src";
import { EvmPlatform } from "@wormhole-foundation/connect-sdk-evm";
import { SolanaAddress, SolanaPlatform } from "@wormhole-foundation/connect-sdk-solana";
import { EvmAddress, EvmPlatform } from "@wormhole-foundation/connect-sdk-evm";
import { getEvmSigner, getSolSigner, getStuff } from './helpers';
import { getStuff } from './helpers';

type ConfigOverride = {
[key: string]: Partial<ChainConfig>
}

function overrideChainSetting(conf: WormholeConfig, overrides: ConfigOverride): WormholeConfig {
for (const [cn, oride] of Object.entries(overrides)) {
// @ts-ignore
conf.chains[cn] = { ...conf.chains[cn], ...oride }
}
return conf
}
jest.setTimeout(10 * 60 * 1000)

const network = "Devnet"
const allPlatformCtrs = [SolanaPlatform, EvmPlatform];
const conf = overrideChainSetting(CONFIG[network], {
"Ethereum": { "rpc": "http://localhost:8545" },
"Bsc": { "rpc": "http://localhost:8546" },
"Solana": { "rpc": "http://localhost:8899" }
})
const conf = CONFIG[network]

jest.setTimeout(10 * 60 * 1000)
describe("Tilt Token Bridge Tests", () => {
const wh = new Wormhole(network, allPlatformCtrs, conf)

Expand Down
2 changes: 1 addition & 1 deletion core/base/src/constants/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const explorerConfig = [
]
>;

const explorerConfs = constMap(explorerConfig);
export const explorerConfs = constMap(explorerConfig);

export const explorerConfigs = (network: Network, chain: ChainName) =>
network === "Devnet"
Expand Down
12 changes: 10 additions & 2 deletions core/base/src/constants/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ const rpcConfig = [
["Terra2", ""],
],
],
[
"Devnet",
[
["Ethereum", "http://localhost:8545"],
["Bsc", "http://localhost:8546"],
["Solana", "http://localhost:8899"],
]
]
] as const satisfies RoArray<
readonly ["Mainnet" | "Testnet", RoArray<readonly [ChainName, string]>]
readonly [Network, RoArray<readonly [ChainName, string]>]
>;

const rpc = constMap(rpcConfig);
export const rpcAddress = (network: Network, chain: ChainName) =>
network === "Devnet" ? undefined : rpc.get(network, chain);
rpc.has(network, chain) ? rpc.get(network, chain) : "";

0 comments on commit 26e3148

Please sign in to comment.