forked from rarible/protocol-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
truffle-config.js
101 lines (93 loc) · 2.88 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
const fs = require("fs");
const os = require('os');
const path = require('path');
require('dotenv').config();
function createNetwork(name) {
try {
var json = require(path.join(os.homedir(), ".ethereum", name + ".json"));
var gasPrice = json.gasPrice != null ? json.gasPrice : 2000000000;
return {
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: 8000000,
gasPrice: gasPrice + "000000000",
network_id: json.network_id,
skipDryRun: true,
networkCheckTimeout: 500000
};
} 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(os.homedir(), ".ethereum", 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'),
},
plugins: [
'truffle-plugin-verify',
'truffle-contract-size'
],
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")
},
compilers: {
solc: {
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 200
},
evmVersion: "istanbul"
}
}
}
}