Skip to content

Commit

Permalink
remove redundant network setting
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Oct 17, 2023
1 parent a4b2625 commit 48c2e3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
3 changes: 0 additions & 3 deletions connect/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion connect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@wormhole-foundation/sdk-definitions";

export type WormholeConfig = {
network: Network;
api: string;
circleAPI: string;
chains: ChainsConfig;
Expand Down
15 changes: 8 additions & 7 deletions connect/src/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ import { getCircleAttestation } from "./circle-api";
export class Wormhole {
protected _platforms: Map<PlatformName, Platform<PlatformName>>;
protected _chains: Map<ChainName, ChainContext<PlatformName>>;

protected readonly _network: Network;
readonly conf: WormholeConfig;

constructor(
network: Network,
platforms: Platform<PlatformName>[],
conf?: WormholeConfig,
) {
this._network = network;
this.conf = conf ?? CONFIG[network];

this._chains = new Map();
Expand All @@ -69,7 +70,7 @@ export class Wormhole {
}

get network(): Network {
return this.conf.network;
return this._network;
}

/**
Expand Down Expand Up @@ -344,11 +345,11 @@ export class Wormhole {
t = isTokenId(sendingToken)
? sendingToken
: {
chain: sendingChain,
address: (
sendingToken as UniversalAddress | NativeAddress<PlatformName>
).toUniversalAddress(),
};
chain: sendingChain,
address: (
sendingToken as UniversalAddress | NativeAddress<PlatformName>
).toUniversalAddress(),
};
}

const dstTokenBridge = await chain.getTokenBridge();
Expand Down
4 changes: 2 additions & 2 deletions core/tokenRegistry/src/foreignAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 48c2e3f

Please sign in to comment.