-
Notifications
You must be signed in to change notification settings - Fork 10
/
truffle.js
executable file
·75 lines (65 loc) · 2.46 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
/**
* Truffle configuration
*/
const cnf = require('./config/networks.json');
const HDWalletProvider = require('truffle-hdwallet-provider');
require('babel-register');
require('babel-polyfill');
const network = process.env.NETWORK;
let secrets = '';
if (network === 'rinkebyInfura') {
secrets = require('./config/.secrets.json');
}
const path = require('path');
const basePath = process.cwd();
const buildDir = path.join(basePath, 'build');
const buildDirContracts = path.join(basePath, 'build/contracts');
const srcDir = path.join(basePath, 'contracts');
const testDir = path.join(basePath, 'test/contracts');
const migrationsDir = path.join(basePath, 'migrations/contracts');
module.exports = {
mocha: {
useColors: true
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
},
networks: {
develop: {
host: cnf.networks.develop.host,
port: cnf.networks.develop.port,
network_id: cnf.networks.develop.chainId, // eslint-disable-line
gas: cnf.networks.develop.gas,
gasPrice: cnf.networks.develop.gasPrice
},
coverage: {
host: cnf.networks.coverage.host,
network_id: cnf.networks.coverage.chainId, // eslint-disable-line
port: cnf.networks.coverage.port,
gas: cnf.networks.coverage.gas,
gasPrice: cnf.networks.coverage.gasPrice
},
rinkebyInfura: getRinkebyConfig()
},
build_directory: buildDir, // eslint-disable-line
contracts_build_directory: buildDirContracts, // eslint-disable-line
migrations_directory: migrationsDir, // eslint-disable-line
contracts_directory: srcDir, // eslint-disable-line
test_directory: testDir // eslint-disable-line
};
function getRinkebyConfig() {
let rinkebyProvider = '';
if (network === 'rinkebyInfura') {
rinkebyProvider = new HDWalletProvider(secrets.rinkeby.mnemonic, secrets.rinkeby.host);
return {
network_id: cnf.networks.rinkeby.chainId, // eslint-disable-line
provider: rinkebyProvider,
from: rinkebyProvider.getAddress(),
gas: cnf.networks.rinkeby.gas,
gasPrice: cnf.networks.rinkeby.gasPrice
};
}
}