-
Notifications
You must be signed in to change notification settings - Fork 4
/
truffle.js
64 lines (60 loc) · 1.45 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
const homedir = require('homedir')
const path = require('path')
const provider = require('eth-provider')
const HDWalletProvider = require('truffle-hdwallet-provider')
const HDWalletProviderPrivkey = require('truffle-hdwallet-provider-privkey')
const settingsForNetwork = (network) => {
try {
let settingsPath = process.env.KEY_FILE || path.join(homedir(), `.aragon/${network}.json`)
return require(settingsPath)
} catch (e) {
return null;
}
}
const providerForNetwork = (network) => (
() => {
let settings = settingsForNetwork(network);
if (settings) {
return new HDWalletProviderPrivkey(settings.keys, settings.rpc)
} else {
let preset;
if (network === 'mainnet') {
preset = 'infura';
} else {
let [first, ...rest] = network;
preset = `infura${first.toUpperCase()}${rest.join('')}`;
}
return provider(['frame', 'local', preset]);
}
}
)
module.exports = {
networks: {
development: {
host: 'localhost',
port: 7545,
network_id: '*'
},
mainnet: {
network_id: 1,
provider: providerForNetwork('mainnet')
},
rinkeby: {
network_id: 4,
provider: providerForNetwork('rinkeby')
},
kovan: {
network_id: 42,
provider: providerForNetwork('kovan')
},
goerli: {
network_id: 5,
provider: providerForNetwork('goerli')
}
},
compilers: {
solc: {
version: "0.4.24"
}
}
}