Skip to content

Commit

Permalink
fix env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Apr 24, 2024
1 parent 33d753b commit 9ca8782
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MIGRATION_WEBHOOK_URL=
GASLESS_WEBHOOK_URL=
GASLESS_DISABLED=false
DASHBOARD_PASSWORD=
TENDERLY_RPC_KEY=
NEXT_PUBLIC_TENDERLY_RPC_KEY=

# this is used to determine which database to fetch data from
NEXT_PUBLIC_VERCEL_ENV=development
2 changes: 1 addition & 1 deletion lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ export const config: SystemConfig = {
DASHBOARD_PASSWORD: process.env.DASHBOARD_PASSWORD || '',
GASLESS_BACKDOOR_SECRET: process.env.GASLESS_BACKDOOR_SECRET || '',
GASLESS_DISABLED: process.env.GASLESS_DISABLED || '',
TENDERLY_RPC_KEY: process.env.TENDERLY_RPC_KEY || ''
TENDERLY_RPC_KEY: process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY || ''
};
30 changes: 17 additions & 13 deletions modules/web3/helpers/getDefaultProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ ethers.utils.Logger.setLogLevel(ethers.utils.Logger.levels.ERROR);
export const getDefaultProvider = (
network: SupportedNetworks | string | undefined
): providers.FallbackProvider => {
const infuraProvider = new ethers.providers.InfuraProvider(network, config.INFURA_KEY);
const alchemyProvider = new ethers.providers.AlchemyProvider(network, config.ALCHEMY_KEY);
const pocketProvider = new ethers.providers.PocketProvider(network, config.POCKET_KEY);
const etherscanProvider = new ethers.providers.EtherscanProvider(network, config.ETHERSCAN_KEY);

const provider = new ethers.providers.FallbackProvider([
{ provider: infuraProvider, priority: 2 },
{ provider: alchemyProvider, priority: 1 },
{ provider: pocketProvider, priority: 3 },
{ provider: etherscanProvider, priority: 3 }
], 1); //Quorum of 1

return provider;
if (network === SupportedNetworks.TENDERLY) {
return new ethers.providers.FallbackProvider([new ethers.providers.JsonRpcProvider(`https://virtual.mainnet.rpc.tenderly.co/${config.TENDERLY_RPC_KEY}`)], 1);
} else {
const infuraProvider = new ethers.providers.InfuraProvider(network, config.INFURA_KEY);
const alchemyProvider = new ethers.providers.AlchemyProvider(network, config.ALCHEMY_KEY);
const pocketProvider = new ethers.providers.PocketProvider(network, config.POCKET_KEY);
const etherscanProvider = new ethers.providers.EtherscanProvider(network, config.ETHERSCAN_KEY);

const provider = new ethers.providers.FallbackProvider([
{ provider: infuraProvider, priority: 2 },
{ provider: alchemyProvider, priority: 1 },
{ provider: pocketProvider, priority: 3 },
{ provider: etherscanProvider, priority: 3 }
], 1); //Quorum of 1

return provider;
}
};

0 comments on commit 9ca8782

Please sign in to comment.