Skip to content

Commit

Permalink
feat: add ecosystem picker variable
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Aug 29, 2024
1 parent 042cea1 commit 52fa1e6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ contracts/out
contracts/cache

# Turborepo
.turbo
.turbo

.tmp
35 changes: 32 additions & 3 deletions apps/api/src/common/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import dotenv from "dotenv";
import { Address } from "viem";
import { mainnet, zksync } from "viem/chains";
import {
localhost,
mainnet,
sepolia,
zksync,
zksyncLocalNode,
zksyncSepoliaTestnet,
} from "viem/chains";

import { MetadataConfig } from "@zkchainhub/metadata";
import { PricingConfig } from "@zkchainhub/pricing";
Expand Down Expand Up @@ -59,19 +66,41 @@ const createPricingConfig = (env: typeof envData): PricingConfig<typeof env.PRIC
}
};

const getChain = (environment: "mainnet" | "testnet" | "local") => {
switch (environment) {
case "mainnet":
return mainnet;
case "testnet":
return sepolia;
case "local":
return localhost;
}
};

const getL2Chain = (environment: "mainnet" | "testnet" | "local") => {
switch (environment) {
case "mainnet":
return zksync;
case "testnet":
return zksyncSepoliaTestnet;
case "local":
return zksyncLocalNode;
}
};

export const config = {
port: envData.PORT,
environment: envData.ENVIRONMENT,

l1: {
rpcUrls: envData.L1_RPC_URLS,
chain: mainnet,
chain: getChain(envData.ENVIRONMENT),
},
l2:
envData.L2_RPC_URLS.length > 0
? {
rpcUrls: envData.L2_RPC_URLS,
chain: zksync,
chain: getL2Chain(envData.ENVIRONMENT),
}
: undefined,
bridgeHubAddress: envData.BRIDGE_HUB_ADDRESS as Address,
Expand Down

0 comments on commit 52fa1e6

Please sign in to comment.