This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
truffle.js
110 lines (97 loc) · 2.22 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const homedir = require('homedir')
const path = require('path')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const DEFAULT_MNEMONIC = 'stumble story behind hurt patient ball whisper art swift tongue ice alien'
const defaultRPC = (network) =>
`https://${network}.infura.io`
const configFilePath = (filename) =>
path.join(homedir(), `.aragon/${filename}`)
const mnemonic = () => {
try {
return require(configFilePath('mnemonic.json')).mnemonic
} catch (e) {
return DEFAULT_MNEMONIC
}
}
const settingsForNetwork = (network) => {
try {
return require(configFilePath(`${network}_key.json`))
} catch (e) {
return { }
}
}
// Lazily loaded provider
const providerForNetwork = (network) => (
() => {
let { rpc, keys } = settingsForNetwork(network)
rpc = rpc || defaultRPC(network)
if (!keys || keys.length == 0) {
return new HDWalletProvider(mnemonic(), rpc)
}
return new HDWalletProviderPrivkey(keys, rpc)
}
)
const mochaGasSettings = {
reporter: 'eth-gas-reporter',
reporterOptions : {
currency: 'USD',
gasPrice: 3
}
}
const mocha = process.env.GAS_REPORTER ? mochaGasSettings : {}
module.exports = {
networks: {
rpc: {
network_id: 15,
host: 'localhost',
port: 8545,
gas: 8.9e6,
gasPrice: 20000000001
},
devnet: {
network_id: 16,
host: 'localhost',
port: 8555,
gas: 8.9e6,
gasPrice: 15000000001
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet'),
gas: 7.9e6,
gasPrice: 8000000001
},
ropsten: {
network_id: 3,
provider: providerForNetwork('ropsten'),
gas: 4.712e6
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby'),
gas: 7.9e6,
gasPrice: 15000000001
},
kovan: {
network_id: 42,
provider: providerForNetwork('kovan'),
gas: 6.9e6
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555,
gas: 0xffffffffff,
gasPrice: 0x01
},
},
build: {},
mocha,
solc: {
optimizer: {
enabled: true,
runs: 1
}
},
}