forked from compound-finance/compound-money-market
-
Notifications
You must be signed in to change notification settings - Fork 0
/
truffle.js
90 lines (81 loc) · 2.14 KB
/
truffle.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
"use strict";
const WalletProvider = require("truffle-wallet-provider");
const Wallet = require('ethereumjs-wallet');
const fs = require('fs');
const path = require('path');
const networks = ["rinkeby", "kovan", "ropsten", "mainnet"];
const infuraNetworks = networks.reduce((networks, network) => {
const envVarName = `${network.toUpperCase()}_PRIVATE_KEY`
let privateKeyHex = process.env[envVarName];
const networksHome = process.env['ETHEREUM_NETWORKS_HOME'];
if (networksHome && !privateKeyHex) {
try {
// Try to read from file
const networkPathResolved = path.join(fs.realpathSync(networksHome), network);
privateKeyHex = fs.readFileSync(networkPathResolved, 'UTF8').trim();
} catch (e) {
// File does not exist or is inaccessible
}
}
if (privateKeyHex) {
const privateKey = Buffer.from(privateKeyHex, "hex")
const wallet = Wallet.fromPrivateKey(privateKey);
const provider = new WalletProvider(wallet, `https://${network}.infura.io/`);
return {
...networks,
[network]: {
host: "localhost",
port: 8545,
network_id: "*",
gas: 6600000,
gasPrice: 15000000000, // 15 gwei
provider,
}
};
} else {
return networks;
}
}, {});
let mochaOptions = {};
if (process.env.SOLIDITY_COVERAGE) {
mochaOptions = {
enableTimeouts: false,
grep: /@gas/,
invert: true
};
}
module.exports = {
networks: {
...infuraNetworks,
development: {
host: "localhost",
port: 8545,
network_id: "*",
// TODO: Use `test` instead and change back to 4600000
gas: 6600000,
gasPrice: 20000,
},
// See example coverage settings at https://github.com/sc-forks/solidity-coverage
coverage: {
host: "localhost",
network_id: "*",
gas: 0xfffffffffff,
gasPrice: 0x01,
port: 8555
},
test: {
host: "localhost",
port: 8545,
network_id: "*",
gas: 6721975,
gasPrice: 1
}
},
solc: {
optimizer: {
enabled: true
}
},
mocha: mochaOptions,
contracts_build_directory: process.env.CONTRACTS_BUILD_DIRECTORY || undefined
};