Skip to content

Commit

Permalink
refactor: removed NetworkNameMapping and added base and sepolia support
Browse files Browse the repository at this point in the history
  • Loading branch information
heueristik committed Oct 18, 2023
1 parent 46495a9 commit 65d6825
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
35 changes: 32 additions & 3 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {NetworkNameMapping} from './utils/helpers';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-etherscan';
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import {config as dotenvConfig} from 'dotenv';
import {ethers} from 'ethers';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import {extendEnvironment, HardhatUserConfig} from 'hardhat/config';
Expand All @@ -21,11 +21,13 @@ if (!process.env.INFURA_API_KEY) {
throw new Error('INFURA_API_KEY in .env not set');
}

const apiUrls: NetworkNameMapping = {
const apiUrls: {[index: string]: string} = {
mainnet: 'https://mainnet.infura.io/v3/',
goerli: 'https://goerli.infura.io/v3/',
sepolia: 'https://sepolia.infura.io/v3/',
polygon: 'https://polygon-mainnet.infura.io/v3/',
polygonMumbai: 'https://polygon-mumbai.infura.io/v3/',
base: 'https://mainnet.base.org',
baseGoerli: 'https://goerli.base.org',
};

Expand All @@ -46,6 +48,10 @@ export const networks: {[index: string]: NetworkUserConfig} = {
chainId: 5,
url: `${apiUrls.goerli}${process.env.INFURA_API_KEY}`,
},
sepolia: {
chainId: 11155111,
url: `${apiUrls.sepolia}${process.env.INFURA_API_KEY}`,
},
polygon: {
chainId: 137,
url: `${apiUrls.polygon}${process.env.INFURA_API_KEY}`,
Expand All @@ -54,10 +60,15 @@ export const networks: {[index: string]: NetworkUserConfig} = {
chainId: 80001,
url: `${apiUrls.polygonMumbai}${process.env.INFURA_API_KEY}`,
},
base: {
chainId: 8453,
url: `${apiUrls.base}`,
gasPrice: ethers.utils.parseUnits('0.001', 'gwei').toNumber(),
},
baseGoerli: {
chainId: 84531,
url: `${apiUrls.baseGoerli}`,
gasPrice: 20000000000,
gasPrice: ethers.utils.parseUnits('0.0000001', 'gwei').toNumber(),
},
};

Expand Down Expand Up @@ -88,11 +99,29 @@ const config: HardhatUserConfig = {
apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY || '',
goerli: process.env.ETHERSCAN_API_KEY || '',
sepolia: process.env.ETHERSCAN_API_KEY || '',
polygon: process.env.POLYGONSCAN_API_KEY || '',
polygonMumbai: process.env.POLYGONSCAN_API_KEY || '',
base: process.env.BASESCAN_API_KEY || '',
baseGoerli: process.env.BASESCAN_API_KEY || '',
},
customChains: [
{
network: 'sepolia',
chainId: 11155111,
urls: {
apiURL: 'https://api-sepolia.etherscan.io/api',
browserURL: 'https://sepolia.etherscan.io',
},
},
{
network: 'base',
chainId: 8453,
urls: {
apiURL: 'https://api.basescan.org/api',
browserURL: 'https://basescan.org',
},
},
{
network: 'baseGoerli',
chainId: 84531,
Expand Down
10 changes: 0 additions & 10 deletions contracts/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import {
} from 'ethers/lib/utils';
import {ethers} from 'hardhat';

export type NetworkNameMapping = {[index: string]: string};

export const networkNameMapping: NetworkNameMapping = {
mainnet: 'mainnet',
goerli: 'goerli',
polygon: 'polygon',
polygonMumbai: 'mumbai',
baseGoerli: 'baseGoerli',
};

export function toBytes(string: string) {
return ethers.utils.formatBytes32String(string);
}
Expand Down

0 comments on commit 65d6825

Please sign in to comment.