From 48c2e3f3d41258554da6ff19952781b1fbc5aa5c Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Tue, 17 Oct 2023 15:02:57 -0400 Subject: [PATCH] remove redundant network setting --- connect/src/config.ts | 3 --- connect/src/types.ts | 1 - connect/src/wormhole.ts | 15 ++++++++------- core/tokenRegistry/src/foreignAssets.ts | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/connect/src/config.ts b/connect/src/config.ts index 0b0ae1714..cbea2bbda 100644 --- a/connect/src/config.ts +++ b/connect/src/config.ts @@ -71,19 +71,16 @@ export function networkPlatformConfigs( export const CONFIG = { Mainnet: { - network: "Mainnet", api: "https://api.wormholescan.io", circleAPI: circleAPI("Mainnet"), chains: chainConfigs("Mainnet"), }, Testnet: { - network: "Testnet", api: "https://api.testnet.wormholescan.io", circleAPI: circleAPI("Testnet"), chains: chainConfigs("Testnet"), }, Devnet: { - network: "Devnet", api: "https://localhost:7071", // Tilt Guardian REST api circleAPI: "", chains: chainConfigs("Devnet"), diff --git a/connect/src/types.ts b/connect/src/types.ts index c4e322aed..40a436223 100644 --- a/connect/src/types.ts +++ b/connect/src/types.ts @@ -8,7 +8,6 @@ import { } from "@wormhole-foundation/sdk-definitions"; export type WormholeConfig = { - network: Network; api: string; circleAPI: string; chains: ChainsConfig; diff --git a/connect/src/wormhole.ts b/connect/src/wormhole.ts index 176bff7de..4f13f73e5 100644 --- a/connect/src/wormhole.ts +++ b/connect/src/wormhole.ts @@ -49,7 +49,7 @@ import { getCircleAttestation } from "./circle-api"; export class Wormhole { protected _platforms: Map>; protected _chains: Map>; - + protected readonly _network: Network; readonly conf: WormholeConfig; constructor( @@ -57,6 +57,7 @@ export class Wormhole { platforms: Platform[], conf?: WormholeConfig, ) { + this._network = network; this.conf = conf ?? CONFIG[network]; this._chains = new Map(); @@ -69,7 +70,7 @@ export class Wormhole { } get network(): Network { - return this.conf.network; + return this._network; } /** @@ -344,11 +345,11 @@ export class Wormhole { t = isTokenId(sendingToken) ? sendingToken : { - chain: sendingChain, - address: ( - sendingToken as UniversalAddress | NativeAddress - ).toUniversalAddress(), - }; + chain: sendingChain, + address: ( + sendingToken as UniversalAddress | NativeAddress + ).toUniversalAddress(), + }; } const dstTokenBridge = await chain.getTokenBridge(); diff --git a/core/tokenRegistry/src/foreignAssets.ts b/core/tokenRegistry/src/foreignAssets.ts index 9c141334e..f9fd3f031 100644 --- a/core/tokenRegistry/src/foreignAssets.ts +++ b/core/tokenRegistry/src/foreignAssets.ts @@ -97,13 +97,13 @@ export const getForeignAssetsData = async ( if (configForeignAddress) { if (configForeignAddress.address !== foreignAddress) { throw new Error( - `❌ Invalid foreign address detected! Env: ${wh.conf.network}, Existing Address: ${configForeignAddress.address}, Chain: ${chain}, Expected: ${foreignAddress}, Received: ${configForeignAddress.address}`, + `❌ Invalid foreign address detected! Env: ${wh.network}, Existing Address: ${configForeignAddress.address}, Chain: ${chain}, Expected: ${foreignAddress}, Received: ${configForeignAddress.address}`, ); } else if ( configForeignAddress.decimals !== Number(foreignDecimals) ) { throw new Error( - `❌ Invalid foreign decimals detected! Env: ${wh.conf.network}, Existing Address: ${configForeignAddress.address}, Chain: ${chain}, Expected: ${foreignDecimals}, Received: ${configForeignAddress.decimals}`, + `❌ Invalid foreign decimals detected! Env: ${wh.network}, Existing Address: ${configForeignAddress.address}, Chain: ${chain}, Expected: ${foreignDecimals}, Received: ${configForeignAddress.decimals}`, ); } else { // console.log('✅ Config matches');