Skip to content

Commit

Permalink
handle "testnet" env network name
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruch committed Jun 14, 2024
1 parent cd91e9c commit 6bf8330
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/rewards-calculator/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ export const config = {
},
network: {
gasLimit: BigInt(env("GAS_LIMIT", 10_000_000n)),
networkName: env<"sepolia" | "mainnet">("NETWORK_NAME", "sepolia"),
networkName: env<"sepolia" | "mainnet" | "testnet">(
"NETWORK_NAME",
"sepolia",
),
l2RpcUrl: env(
"L2_RPC_URL",
"https://arbitrum-sepolia.infura.io/v3/39b9cd000b9c4637b58d5a5214676196",
),
},
};

function isTestnet() {
return (
config.network.networkName === "testnet" ||
config.network.networkName === "sepolia"
);
}

export type ContractName = keyof typeof abis;

const deployments =
config.network.networkName === "sepolia"
? SepoliaDeployments
: ArbitrumDeployments;
const deployments = isTestnet() ? SepoliaDeployments : ArbitrumDeployments;

export const addresses = {
workerRegistration: deployments.WorkerRegistration,
Expand All @@ -69,10 +76,9 @@ export const addresses = {
networkController: deployments.NetworkController,
} as { [key in ContractName]: Address };

const l1Chain = config.network.networkName === "sepolia" ? sepolia : mainnet;
const l1Chain = isTestnet() ? sepolia : mainnet;

const l2Chain =
config.network.networkName === "sepolia" ? arbitrumSepolia : arbitrum;
const l2Chain = isTestnet() ? arbitrumSepolia : arbitrum;

export const abis = {
workerRegistration: workerRegistrationAbi,
Expand Down

2 comments on commit 6bf8330

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.