-
Notifications
You must be signed in to change notification settings - Fork 239
/
truffle-config.js
137 lines (129 loc) · 4.15 KB
/
truffle-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const fs = require("fs");
const os = require("os");
const path = require("path");
require("dotenv").config();
function getConfigPath() {
const configPath = process.env["NETWORK_CONFIG_PATH"];
if (configPath) {
return configPath;
} else {
return path.join(os.homedir(), ".ethereum");
}
}
function createNetwork(name) {
try {
var json = require(path.join(getConfigPath(), name + ".json"));
if (json) {
var gasPrice = json.gasPrice != null ? json.gasPrice : 2000000000;
const res = {
provider: () => {
const { estimate } = require("@rarible/estimate-middleware");
if (json.path != null) {
const {
createProvider: createTrezorProvider,
} = require("@rarible/trezor-provider");
const provider = createTrezorProvider({
url: json.url,
path: json.path,
chainId: json.network_id,
});
provider.send = provider.sendAsync;
return provider;
} else {
return createProvider(json.address, json.key, json.url);
}
},
from: json.address,
gas: 15000000,
gasPrice: gasPrice,
network_id: json.network_id,
skipDryRun: true,
networkCheckTimeout: 500000,
};
if (json.verify) {
res.verify = {
apiUrl: json.verify.apiUrl,
apiKey: json.verify.apiKey,
explorerUrl: json.verify.explorerUrl,
};
}
return res;
}
return {};
} catch (e) {
return null;
}
}
function createProvider(address, key, url) {
console.log("creating provider for address: " + address);
var HDWalletProvider = require("@truffle/hdwallet-provider");
return new HDWalletProvider(key, url);
}
function getScanApiKey(name) {
let apiKey = "UNKNOWN";
const envApiKeyName = `${name.toUpperCase()}_API_KEY`;
if (process.env[envApiKeyName]) {
console.log(`loading ${name} key from env ${envApiKeyName}`);
apiKey = process.env[envApiKeyName];
console.log(`loaded ${name} key from env ${envApiKeyName}`);
} else {
const filePath = path.join(getConfigPath(), name + ".json");
if (fs.existsSync(filePath)) {
console.log(`Loading ${name} key from ${filePath}`);
apiKey = require(filePath).apiKey;
console.log(`loaded ${name} api key`);
} else {
console.log(`unable to load ${name} key from config`);
}
}
return apiKey;
}
module.exports = {
api_keys: {
etherscan: getScanApiKey("etherscan"),
polygonscan: getScanApiKey("polygonscan"),
polygon_mumbai: getScanApiKey("polygonscan"),
optimistic_etherscan: getScanApiKey("optimisticscan"),
},
plugins: ["truffle-plugin-verify"],
networks: {
e2e: createNetwork("e2e"),
ops: createNetwork("ops"),
ropsten: createNetwork("ropsten"),
mainnet: createNetwork("mainnet"),
rinkeby: createNetwork("rinkeby"),
rinkeby2: createNetwork("rinkeby2"),
polygon_mumbai: createNetwork("polygon_mumbai"),
polygon_mainnet: createNetwork("polygon_mainnet"),
polygon_dev: createNetwork("polygon_dev"),
dev: createNetwork("dev"),
goerli: createNetwork("goerli"),
staging: createNetwork("staging"),
polygon_staging: createNetwork("polygon_staging"),
optimism_mainnet: createNetwork("optimism_mainnet"),
optimism_goerli: createNetwork("optimism_goerli"),
mantle_testnet: createNetwork("mantle_testnet"),
mantle_mainnet: createNetwork("mantle_mainnet"),
arbitrum_goerli: createNetwork("arbitrum_goerli"),
arbitrum_sepolia: createNetwork("arbitrum_sepolia"),
arbitrum_mainnet: createNetwork("arbitrum_mainnet"),
zkatana_testnet: createNetwork("zkatana_testnet"),
zkatana_mainnet: createNetwork("zkatana_mainnet"),
chiliz_testnet: createNetwork("chiliz_testnet"),
chiliz_mainnet: createNetwork("chiliz_mainnet"),
lightlink_pegasus: createNetwork("lightlink_pegasus"),
lightlink_phoenix: createNetwork("lightlink_phoenix"),
},
compilers: {
solc: {
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
},
},
},
};