Skip to content

Commit

Permalink
src/__tests__/env.ts: DEFAULT_PUBLIC_RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Jun 15, 2024
1 parent c6c6a01 commit f4d5a0a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/__tests__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ const env = {
PROVIDER_RPC_URL: process.env.PROVIDER_RPC_URL,
};

const DEFAULT_PUBLIC_RPC = "https://ethereum-rpc.publicnode.com";

const provider = CompatibleProvider(function() {
let rpc_url = env.PROVIDER_RPC_URL;
if (env.PROVIDER === "viem") {
let rpc_url = env.PROVIDER_RPC_URL;
if (env.INFURA_API_KEY) {
rpc_url = "https://mainnet.infura.io/v3/" + env.INFURA_API_KEY;
}
return createPublicClient({
transport: http(rpc_url),
transport: http(rpc_url ?? DEFAULT_PUBLIC_RPC),
});
}
// env.provider == "ethers"
if (env.PROVIDER_RPC_URL) return new ethers.JsonRpcProvider(rpc_url);
if (env.PROVIDER_RPC_URL) return new ethers.JsonRpcProvider(env.PROVIDER_RPC_URL);
if (env.INFURA_API_KEY) return new ethers.InfuraProvider("homestead", env.INFURA_API_KEY);
return ethers.getDefaultProvider("homestead");
return new ethers.JsonRpcProvider(DEFAULT_PUBLIC_RPC);
}());

type ItConcurrent = typeof test.skip;
Expand Down

0 comments on commit f4d5a0a

Please sign in to comment.