[ethereum] Update truffle config (#552)
* [ethereum] Update truffle config hdwallet package was updated in the PR bringing lerna to this repo. In the new package the constructor arguments have changed. This PR updates that and adds a helper function to make the config more clear. * Update truffle-config.js
This commit is contained in:
parent
f4d18167cd
commit
58505a21c8
|
@ -1,6 +1,19 @@
|
|||
require("dotenv").config({ path: ".env" });
|
||||
const HDWalletProvider = require("@truffle/hdwallet-provider");
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} url
|
||||
* @returns {HDWalletProvider} An instance of HDWalletProvider
|
||||
*/
|
||||
function payerProvider(url) {
|
||||
return () =>
|
||||
new HDWalletProvider({
|
||||
mnemonic: process.env.MNEMONIC,
|
||||
providerOrUrl: url,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
migrations_directory: process.env.MIGRATIONS_DIR,
|
||||
networks: {
|
||||
|
@ -10,9 +23,7 @@ module.exports = {
|
|||
network_id: "*",
|
||||
},
|
||||
ethereum: {
|
||||
provider: () =>
|
||||
new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
provider: payerProvider(
|
||||
`https://mainnet.infura.io/v3/` + process.env.INFURA_KEY
|
||||
),
|
||||
network_id: 1,
|
||||
|
@ -23,9 +34,7 @@ module.exports = {
|
|||
skipDryRun: false,
|
||||
},
|
||||
ropsten: {
|
||||
provider: () =>
|
||||
new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
provider: payerProvider(
|
||||
`https://ropsten.infura.io/v3/` + process.env.INFURA_KEY
|
||||
),
|
||||
network_id: 3,
|
||||
|
@ -35,9 +44,7 @@ module.exports = {
|
|||
skipDryRun: true,
|
||||
},
|
||||
rinkeby: {
|
||||
provider: () =>
|
||||
new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
provider: payerProvider(
|
||||
`https://rinkeby.infura.io/v3/` + process.env.INFURA_KEY
|
||||
),
|
||||
network_id: 4,
|
||||
|
@ -47,34 +54,22 @@ module.exports = {
|
|||
skipDryRun: true,
|
||||
},
|
||||
goerli: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://goerli.infura.io/v3/" + process.env.INFURA_KEY
|
||||
);
|
||||
},
|
||||
provider: payerProvider(
|
||||
`https://goerli.infura.io/v3/` + process.env.INFURA_KEY
|
||||
),
|
||||
network_id: "5",
|
||||
gas: 8465030,
|
||||
gasPrice: 15000000000,
|
||||
skipDryRun: true,
|
||||
},
|
||||
bnb: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/bsc"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc.ankr.com/bsc`),
|
||||
network_id: "56",
|
||||
gas: 70000000,
|
||||
gasPrice: 5500000000,
|
||||
},
|
||||
bnb_testnet: {
|
||||
provider: () =>
|
||||
new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/bsc_testnet_chapel"
|
||||
),
|
||||
provider: payerProvider(`https://rpc.ankr.com/bsc_testnet_chapel`),
|
||||
network_id: "97",
|
||||
confirmations: 10,
|
||||
networkCheckTimeout: 1000000,
|
||||
|
@ -82,62 +77,35 @@ module.exports = {
|
|||
skipDryRun: true,
|
||||
},
|
||||
polygon: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://polygon-rpc.com"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://polygon-rpc.com`),
|
||||
network_id: "137",
|
||||
gas: 20000000,
|
||||
gasPrice: 300000000000,
|
||||
},
|
||||
mumbai: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://polygon-testnet-rpc.allthatnode.com:8545"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(
|
||||
`https://polygon-testnet-rpc.allthatnode.com:8545`
|
||||
),
|
||||
network_id: "80001",
|
||||
},
|
||||
avalanche: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://api.avax.network/ext/bc/C/rpc"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://api.avax.network/ext/bc/C/rpc`),
|
||||
network_id: "43114",
|
||||
gas: 8000000,
|
||||
gasPrice: 30000000000,
|
||||
},
|
||||
fuji: {
|
||||
provider: () =>
|
||||
new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://api.avax-test.network/ext/bc/C/rpc"
|
||||
),
|
||||
provider: payerProvider(`https://api.avax-test.network/ext/bc/C/rpc`),
|
||||
network_id: "43113",
|
||||
},
|
||||
oasis: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://emerald.oasis.dev/"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://emerald.oasis.dev/`),
|
||||
network_id: 42262,
|
||||
gas: 4465030,
|
||||
gasPrice: 30000000000,
|
||||
},
|
||||
aurora: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://mainnet.aurora.dev"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://mainnet.aurora.dev`),
|
||||
network_id: 0x4e454152,
|
||||
gas: 10000000,
|
||||
from: "0xC42e9476b0a458097087336e2395Dbf45B0BdC12", // creator public key
|
||||
|
@ -145,12 +113,7 @@ module.exports = {
|
|||
timeoutBlocks: 1000,
|
||||
},
|
||||
aurora_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://testnet.aurora.dev"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://testnet.aurora.dev`),
|
||||
network_id: 0x4e454153,
|
||||
gas: 10000000,
|
||||
from: "0xC42e9476b0a458097087336e2395Dbf45B0BdC12", // public key
|
||||
|
@ -158,134 +121,64 @@ module.exports = {
|
|||
timeoutBlocks: 1000,
|
||||
},
|
||||
arbitrum: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://arb1.arbitrum.io/rpc"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://arb1.arbitrum.io/rpc`),
|
||||
network_id: 42161,
|
||||
},
|
||||
arbitrum_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://goerli-rollup.arbitrum.io/rpc"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://goerli-rollup.arbitrum.io/rpc`),
|
||||
network_id: 421613,
|
||||
},
|
||||
optimism: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/optimism"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc.ankr.com/optimism`),
|
||||
network_id: 10,
|
||||
},
|
||||
optimism_goerli: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/optimism_testnet"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc.ankr.com/optimism_testnet`),
|
||||
network_id: 420,
|
||||
},
|
||||
fantom: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/fantom"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc.ankr.com/fantom`),
|
||||
network_id: 250,
|
||||
gas: 8000000,
|
||||
gasPrice: 50000000000,
|
||||
timeoutBlocks: 15000,
|
||||
},
|
||||
fantom_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/fantom_testnet"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc.ankr.com/fantom_testnet`),
|
||||
network_id: 0xfa2,
|
||||
gas: 8000000,
|
||||
gasPrice: 300000000000,
|
||||
},
|
||||
celo: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://forno.celo.org"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://forno.celo.org`),
|
||||
network_id: 42220,
|
||||
},
|
||||
celo_alfajores_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://alfajores-forno.celo-testnet.org"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://alfajores-forno.celo-testnet.org`),
|
||||
network_id: 44787,
|
||||
},
|
||||
kcc: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc-mainnet.kcc.network"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc-mainnet.kcc.network`),
|
||||
network_id: 321,
|
||||
},
|
||||
kcc_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc-testnet.kcc.network"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://rpc-testnet.kcc.network`),
|
||||
network_id: 322,
|
||||
},
|
||||
zksync: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://zksync2-mainnet.zksync.io"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://zksync2-mainnet.zksync.io`),
|
||||
network_id: 324,
|
||||
},
|
||||
zksync_goerli: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://zksync2-testnet.zksync.dev"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://zksync2-testnet.zksync.dev`),
|
||||
network_id: 280,
|
||||
},
|
||||
cronos: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://cronosrpc-1.xstaking.sg"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://cronosrpc-1.xstaking.sg`),
|
||||
network_id: 25,
|
||||
},
|
||||
cronos_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://evm-t3.cronos.org"
|
||||
);
|
||||
},
|
||||
provider: payerProvider(`https://evm-t3.cronos.org`),
|
||||
network_id: 338,
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue