diff --git a/packages/apps/.env.development b/packages/apps/.env.development index 2bbb9b664..8852dc19d 100644 --- a/packages/apps/.env.development +++ b/packages/apps/.env.development @@ -1 +1,2 @@ NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo-stg.helixbridge.app/graphql +NEXT_PUBLIC_NODE_ENV=development diff --git a/packages/apps/.env.production b/packages/apps/.env.production index 532e78a50..4b2fa6b77 100644 --- a/packages/apps/.env.production +++ b/packages/apps/.env.production @@ -1 +1,2 @@ NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo.helixbridge.app/graphql +NEXT_PUBLIC_NODE_ENV=production diff --git a/packages/apps/.env.test b/packages/apps/.env.test index 89188c271..62e70bd7f 100644 --- a/packages/apps/.env.test +++ b/packages/apps/.env.test @@ -1 +1,2 @@ NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo-test.helixbridge.app/graphql +NEXT_PUBLIC_NODE_ENV=test diff --git a/packages/apps/src/bridges/lnbridge-default.ts b/packages/apps/src/bridges/lnbridge-default.ts index 90148e962..a809111c3 100644 --- a/packages/apps/src/bridges/lnbridge-default.ts +++ b/packages/apps/src/bridges/lnbridge-default.ts @@ -4,6 +4,7 @@ import { Network } from "@/types/chain"; import { TokenSymbol } from "@/types/token"; import { getChainConfig } from "@/utils/chain"; import { PublicClient, WalletClient } from "wagmi"; +import { isProduction } from "@/utils/env"; export class LnBridgeDefault extends LnBridgeBase { constructor(args: { @@ -27,7 +28,7 @@ export class LnBridgeDefault extends LnBridgeBase { sourceAddress: "0x79e6f452f1e491a7aF0382FA0a6EF9368691960D", targetAddress: "0x79e6f452f1e491a7aF0382FA0a6EF9368691960D", }; - } else if (process.env.NODE_ENV !== "production") { + } else if (!isProduction()) { this.contract = { sourceAddress: "0x54cc9716905ba8ebdD01E6364125cA338Cd0054E", targetAddress: "0x54cc9716905ba8ebdD01E6364125cA338Cd0054E", diff --git a/packages/apps/src/utils/chain.ts b/packages/apps/src/utils/chain.ts index 6e896d564..bf8d26393 100644 --- a/packages/apps/src/utils/chain.ts +++ b/packages/apps/src/utils/chain.ts @@ -13,6 +13,7 @@ import { pangoroChain } from "@/config/chains/pangoro"; import { zksyncChain } from "@/config/chains/zksync"; import { zksyncGoerliChain } from "@/config/chains/zksync-goerli"; import { ChainConfig, Network } from "@/types/chain"; +import { isProduction } from "./env"; export function getChainConfig(network?: Network | null): ChainConfig | undefined { switch (network) { @@ -67,7 +68,7 @@ export function getChainsConfig() { zksyncGoerliChain, ]; - if (process.env.NODE_ENV === "production") { + if (isProduction()) { return all.filter((c) => !c.hidden && !c.testnet); } else { return all.filter((c) => !c.hidden && !!c.testnet); diff --git a/packages/apps/src/utils/env.ts b/packages/apps/src/utils/env.ts new file mode 100644 index 000000000..ddf26f79d --- /dev/null +++ b/packages/apps/src/utils/env.ts @@ -0,0 +1,11 @@ +export function isProduction() { + return process.env.NEXT_PUBLIC_NODE_ENV === "production"; +} + +export function isDevelopment() { + return process.env.NEXT_PUBLIC_NODE_ENV === "development"; +} + +export function isTest() { + return process.env.NEXT_PUBLIC_NODE_ENV === "test"; +}