Skip to content

Commit

Permalink
Merge pull request #92 from shazow/fix-tests
Browse files Browse the repository at this point in the history
src/__tests__/env.ts: viem-infura scenario
  • Loading branch information
shazow authored Jun 15, 2024
2 parents 562eae2 + f4d5a0a commit 4fd9d9a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/__tests__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +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 ?? "https://mainnet.infura.io/v3/" + env.INFURA_API_KEY;
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 4fd9d9a

Please sign in to comment.