forked from celo-org/celo-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
truffle-config.js
190 lines (171 loc) · 5.15 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* tslint:disable: object-literal-sort-keys */
require('ts-node/register')
const ProviderEngine = require('web3-provider-engine')
const WebsocketSubprovider = require('web3-provider-engine/subproviders/websocket.js')
const { TruffleArtifactAdapter } = require('@0x/sol-trace')
const { CoverageSubprovider } = require('@0x/sol-coverage')
const argv = require('minimist')(process.argv.slice(2), { string: ['truffle_override', 'network'] })
const SOLC_VERSION = '0.5.8'
const ALFAJORES_NETWORKID = 44785
const BAKLAVA_NETWORKID = 200110
const BAKLAVASTAGING_NETWORKID = 31416
const OG_FROM = '0xfeE1a22F43BeeCB912B5a4912ba87527682ef0fC'
const DEVELOPMENT_FROM = '0x5409ed021d9299bf6814279a6a1411a7e866a631'
const INTEGRATION_FROM = '0x47e172F6CfB6c7D01C1574fa3E2Be7CC73269D95'
const INTEGRATION_TESTING_FROM = '0x47e172F6CfB6c7D01C1574fa3E2Be7CC73269D95'
const ALFAJORESSTAGING_FROM = '0xf4314cb9046bece6aa54bb9533155434d0c76909'
const ALFAJORES_FROM = '0x456f41406B32c45D59E539e4BBA3D7898c3584dA'
const PILOT_FROM = '0x387bCb16Bfcd37AccEcF5c9eB2938E30d3aB8BF2'
const PILOTSTAGING_FROM = '0x545DEBe3030B570731EDab192640804AC8Cf65CA'
const RC0_FROM = '0x469be98FE71AFf8F6e7f64F9b732e28A03596B5C'
const gasLimit = 20000000
const defaultConfig = {
host: '127.0.0.1',
port: 8545,
network_id: 1101,
from: OG_FROM,
gas: gasLimit,
gasPrice: 100000000000,
}
const freeGasConfig = { ...defaultConfig, ...{ gasPrice: 0 } }
// Here to avoid recreating it each time
let coverageProvider = null
const networks = {
development: {
...defaultConfig,
from: DEVELOPMENT_FROM,
gasPrice: 0,
gas: gasLimit,
defaultBalance: 200000000,
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
},
rc0: {
host: '127.0.0.1',
port: 8545,
from: RC0_FROM,
network_id: 200312,
gasPrice: 100000000000,
},
coverage: {
host: 'localhost',
network_id: '*',
gasPrice: 0,
gas: gasLimit,
from: DEVELOPMENT_FROM,
provider: function() {
if (coverageProvider == null) {
console.log('building provider!')
coverageProvider = new ProviderEngine()
const projectRoot = ''
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, SOLC_VERSION)
global.coverageSubprovider = new CoverageSubprovider(artifactAdapter, DEVELOPMENT_FROM, {
isVerbose: true,
ignoreFilesGlobs: [
// Proxies
'**/*Proxy.sol',
// Test contracts
'**/test/*.sol',
// Interfaces
'**/interfaces/*.sol',
],
})
coverageProvider.addProvider(global.coverageSubprovider)
coverageProvider.addProvider(
new WebsocketSubprovider({
rpcUrl: `http://localhost:${defaultConfig.port}`,
debug: false,
})
)
coverageProvider.start((err) => {
if (err !== undefined) {
// tslint:disable-next-line: no-console
console.error(err)
process.exit(1)
}
})
/**
* HACK: Truffle providers should have `send` function, while `ProviderEngine` creates providers with `sendAsync`,
* but it can be easily fixed by assigning `sendAsync` to `send`.
*/
coverageProvider.send = coverageProvider.sendAsync.bind(coverageProvider)
}
return coverageProvider
},
},
testnet_prod: defaultConfig,
// New testnets
integration: {
...defaultConfig,
from: INTEGRATION_FROM,
},
testing: {
...defaultConfig,
from: INTEGRATION_TESTING_FROM,
},
// testnet for integration tests
integrationtesting: {
...defaultConfig,
from: INTEGRATION_TESTING_FROM,
},
argentinastaging: freeGasConfig,
argentinaproduction: freeGasConfig,
alfajoresstaging: {
...defaultConfig,
from: ALFAJORESSTAGING_FROM,
},
alfajores: {
...defaultConfig,
network_id: ALFAJORES_NETWORKID,
from: ALFAJORES_FROM,
},
pilot: {
...defaultConfig,
from: PILOT_FROM,
},
pilotstaging: {
...defaultConfig,
from: PILOTSTAGING_FROM,
},
baklava: {
...defaultConfig,
network_id: BAKLAVA_NETWORKID,
},
baklavastaging: {
...defaultConfig,
network_id: BAKLAVASTAGING_NETWORKID,
},
}
// If an override was provided, apply it.
// If the network is missing from networks, start with the default config.
if (argv.truffle_override || !(argv.network in networks)) {
const configOverride = argv.truffle_override ? JSON.parse(argv.truffle_override) : {}
if (argv.network in networks) {
networks[argv.network] = { ...networks[argv.network], ...configOverride }
} else {
networks[argv.network] = { ...defaultConfig, ...configOverride }
}
}
module.exports = {
plugins: ['truffle-security', 'truffle-plugin-blockscout-verify'],
compilers: {
solc: {
version: SOLC_VERSION,
},
},
networks,
}
if (process.argv.includes('--gas')) {
module.exports = {
compilers: {
solc: {
version: '0.5.8',
},
},
plugins: ['truffle-security', 'truffle-plugin-blockscout-verify'],
networks,
reporter: 'eth-gas-reporter',
reporterOptions: {
currency: 'USD',
},
}
}