-
Notifications
You must be signed in to change notification settings - Fork 375
/
Copy pathtruffle-config-parent.js
223 lines (199 loc) · 6.39 KB
/
truffle-config-parent.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/* 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')
var Web3 = require('web3')
var net = require('net')
const argv = require('minimist')(process.argv.slice(2), {
string: ['truffle_override', 'network'],
boolean: ['reset'],
})
const ALFAJORES_NETWORKID = 44787
const BAKLAVA_NETWORKID = 62320
const BAKLAVASTAGING_NETWORKID = 31420
const CANNOLI_NETWORKID = 17323
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 BAKLAVA_FROM = '0x0Cc59Ed03B3e763c02d54D695FFE353055f1502D'
const BAKLAVASTAGING_FROM = '0x4588ABb84e1BBEFc2BcF4b2296F785fB7AD9F285'
const STAGING_FROM = '0x4e3d385ecdee402da395a3b18575b05cc5e8ff21'
const CANNOLI_FROM = '0x8C174E896A85E487aa895865657b78Ea64879dC7' // validator zero
const gasLimit = 13000000
const hostAddress = process.env.CELO_NODE_ADDRESS || '127.0.0.1'
const hostPort = parseInt(process.env.CELO_NODE_PORT || '8545')
const defaultConfig = {
host: hostAddress,
port: hostPort,
network_id: 1101,
from: OG_FROM,
gas: gasLimit,
gasPrice: 100000000000,
// maxFeePerGas: 975000000,
}
const freeGasConfig = { ...defaultConfig, ...{ gasPrice: 0 } }
// ipcProvider returns a function to create an IPC provider when called.
// Use by adding `provider: ipcProvider(...)` to any of the configs below.
function ipcProvider(path) {
return () => new Web3.providers.IpcProvider(path, net)
}
// Here to avoid recreating it each time
let coverageProvider = null
const fornoUrls = {
alfajores: 'https://alfajores-forno.celo-testnet.org',
baklava: 'https://baklava-forno.celo-testnet.org',
rc1: 'https://forno.celo.org',
mainnet: 'https://forno.celo.org',
staging: 'https://staging-forno.celo-networks-dev.org',
}
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: hostAddress,
port: hostPort,
from: RC0_FROM,
network_id: 200312,
gasPrice: 100000000000,
},
rc1: {
host: '127.0.0.1',
port: 8545,
from: '0xE23a4c6615669526Ab58E9c37088bee4eD2b2dEE',
network_id: 42220,
gas: gasLimit,
gasPrice: 10000000000,
},
coverage: {
host: 'localhost',
network_id: '*',
gasPrice: 0,
gas: gasLimit,
from: DEVELOPMENT_FROM,
provider: function () {
if (coverageProvider == null) {
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) {
// eslint-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,
network_id: 1101,
},
argentinastaging: freeGasConfig,
argentinaproduction: freeGasConfig,
alfajoresstaging: {
...defaultConfig,
from: ALFAJORESSTAGING_FROM,
},
alfajores: {
...defaultConfig,
network_id: ALFAJORES_NETWORKID,
from: ALFAJORES_FROM,
},
cannoli: {
...defaultConfig,
network_id: CANNOLI_NETWORKID,
from: CANNOLI_FROM,
},
pilot: {
...defaultConfig,
from: PILOT_FROM,
},
pilotstaging: {
...defaultConfig,
from: PILOTSTAGING_FROM,
},
baklava: {
...defaultConfig,
from: BAKLAVA_FROM,
network_id: BAKLAVA_NETWORKID,
},
baklavastaging: {
...defaultConfig,
from: BAKLAVASTAGING_FROM,
network_id: BAKLAVASTAGING_NETWORKID,
},
staging: {
...defaultConfig,
from: STAGING_FROM,
},
}
// Equivalent
networks.mainnet = networks.rc1
// 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 }
}
}
if (process.argv.includes('--forno')) {
if (!fornoUrls[argv.network]) {
console.log(`Forno URL for network ${argv.network} not known!`)
process.exit(1)
}
networks[argv.network].host = undefined
networks[argv.network].port = undefined
networks[argv.network].provider = function () {
return new Web3.providers.HttpProvider(fornoUrls[argv.network])
}
}
module.exports = { networks: networks }