mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-06 21:03:57 -05:00
feat: Environment variables modified to be generic
This commit is contained in:
10
.env.example
10
.env.example
@@ -1,9 +1,11 @@
|
||||
MNEMONIC=
|
||||
ETHERSCAN_KEY=
|
||||
INFURA_KEY=
|
||||
ETHERSCAN_NETWORK=
|
||||
POLYGON_RPC_URL=
|
||||
MUMBAI_RPC_URL=
|
||||
KOVAN_RPC_URL=
|
||||
ROPSTEN_RPC_URL=
|
||||
MAINNET_RPC_URL=
|
||||
BLOCK_EXPLORER_KEY=
|
||||
TENDERLY_PROJECT=
|
||||
TENDERLY_USERNAME=
|
||||
ALCHEMY_KEY=
|
||||
TENDERLY_FORK_ID=
|
||||
TENDERLY_HEAD_ID=
|
||||
|
||||
@@ -45,13 +45,12 @@ The Lens Protocol is a decentralized, non-custodial social graph. Lens implement
|
||||
>
|
||||
> (feel free to experiment and submit PR's)
|
||||
|
||||
The environment is built using Docker Compose, note that your `.env` file must have an `ALCHEMY_KEY` or an `INFURA_KEY` variable, and an optional `MNEMONIC` and `ETHERSCAN_KEY`, defined like so:
|
||||
The environment is built using Docker Compose, note that your `.env` file must have the RPC URL of the network you want to use, and an optional `MNEMONIC` and `BLOCK_EXPLORER_KEY`, defined like so, assuming you choose to use Mumbai network:
|
||||
|
||||
```
|
||||
MNEMONIC="MNEMONIC YOU WANT TO DERIVE WALLETS FROM HERE"
|
||||
ALCHEMY_KEY="YOUR ALCHEMY KEY HERE"
|
||||
INFURA_KEY="OR YOUR INFURA KEY HERE"
|
||||
ETHERSCAN_KEY="YOUR ETHERSCAN API KEY HERE"
|
||||
MUMBAI_RPC_URL="YOUR RPC URL HERE"
|
||||
BLOCK_EXPLORER_KEY="YOUR BLOCK EXPLORER API KEY HERE"
|
||||
```
|
||||
|
||||
With the environment file set up, you can move on to using Docker:
|
||||
|
||||
@@ -14,11 +14,9 @@ services:
|
||||
- $HOME/.tenderly/config.yaml:/root/.tenderly/config.yaml:ro
|
||||
#environment:
|
||||
#- MNEMONIC=
|
||||
#- ETHERSCAN_KEY=
|
||||
#- INFURA_KEY=
|
||||
#- ETHERSCAN_NETWORK=
|
||||
#- RPC_URL=
|
||||
#- BLOCK_EXPLORER_KEY=
|
||||
#- TENDERLY_PROJECT=
|
||||
#- TENDERLY_USERNAME=
|
||||
#- ALCHEMY_KEY=
|
||||
#- TENDERLY_FORK_ID=
|
||||
#- TENDERLY_HEAD_ID=
|
||||
|
||||
@@ -28,7 +28,7 @@ const MNEMONIC_PATH = "m/44'/60'/0'/0";
|
||||
const MNEMONIC = process.env.MNEMONIC || '';
|
||||
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
|
||||
const TRACK_GAS = process.env.TRACK_GAS === 'true';
|
||||
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
|
||||
const BLOCK_EXPLORER_KEY = process.env.BLOCK_EXPLORER_KEY || '';
|
||||
|
||||
const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
|
||||
url: NETWORKS_RPC_URL[networkName],
|
||||
@@ -95,7 +95,7 @@ const config: HardhatUserConfig = {
|
||||
runOnCompile: false,
|
||||
},
|
||||
etherscan: {
|
||||
apiKey: ETHERSCAN_KEY,
|
||||
apiKey: BLOCK_EXPLORER_KEY,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -8,30 +8,18 @@ import {
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config({});
|
||||
|
||||
const INFURA_KEY = process.env.INFURA_KEY || '';
|
||||
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
|
||||
const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID || '';
|
||||
|
||||
const GWEI = 1000 * 1000 * 1000;
|
||||
|
||||
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
|
||||
[eEthereumNetwork.kovan]: ALCHEMY_KEY
|
||||
? `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_KEY}`
|
||||
: `https://kovan.infura.io/v3/${INFURA_KEY}`,
|
||||
[eEthereumNetwork.ropsten]: ALCHEMY_KEY
|
||||
? `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_KEY}`
|
||||
: `https://ropsten.infura.io/v3/${INFURA_KEY}`,
|
||||
[eEthereumNetwork.main]: ALCHEMY_KEY
|
||||
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
|
||||
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
|
||||
[eEthereumNetwork.kovan]: process.env.KOVAN_RPC_URL,
|
||||
[eEthereumNetwork.ropsten]: process.env.ROPSTEN_RPC_URL,
|
||||
[eEthereumNetwork.main]: process.env.MAINNET_RPC_URL,
|
||||
[eEthereumNetwork.hardhat]: 'http://localhost:8545',
|
||||
[eEthereumNetwork.harhatevm]: 'http://localhost:8545',
|
||||
[eEthereumNetwork.tenderlyMain]: `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`,
|
||||
[ePolygonNetwork.mumbai]: ALCHEMY_KEY
|
||||
? `https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_KEY}`
|
||||
: `https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`,
|
||||
[ePolygonNetwork.matic]: ALCHEMY_KEY
|
||||
? `https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`
|
||||
: `https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
|
||||
[ePolygonNetwork.mumbai]: process.env.MUMBAI_RPC_URL,
|
||||
[ePolygonNetwork.matic]: process.env.POLYGON_RPC_URL,
|
||||
[eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/',
|
||||
};
|
||||
};
|
||||
|
||||
@@ -173,7 +173,7 @@ export async function resetFork(): Promise<void> {
|
||||
params: [
|
||||
{
|
||||
forking: {
|
||||
jsonRpcUrl: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`,
|
||||
jsonRpcUrl: process.env.MAINNET_RPC_URL,
|
||||
blockNumber: 12012081,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user