Skip to content

Commit

Permalink
fix env check
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Oct 8, 2023
1 parent 2c4abf2 commit 9c27978
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/apps/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo-stg.helixbridge.app/graphql
NEXT_PUBLIC_NODE_ENV=development
1 change: 1 addition & 0 deletions packages/apps/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo.helixbridge.app/graphql
NEXT_PUBLIC_NODE_ENV=production
1 change: 1 addition & 0 deletions packages/apps/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_GRAPHQL_ENDPOINT=https://apollo-test.helixbridge.app/graphql
NEXT_PUBLIC_NODE_ENV=test
3 changes: 2 additions & 1 deletion packages/apps/src/bridges/lnbridge-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/apps/src/utils/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions packages/apps/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 9c27978

Please sign in to comment.