This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 697
/
args.js
237 lines (235 loc) · 8.36 KB
/
args.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
module.exports = exports = function(yargs, version, isDocker) {
return yargs
.strict()
.option('p', {
group: 'Network:',
alias: 'port',
type: 'number',
default: 8545,
describe: 'Port number to listen on'
})
.option('h', {
group: 'Network:',
alias: ['host', 'hostname'],
type: 'string',
default: isDocker ? '0.0.0.0' : '127.0.0.1',
describe: 'Hostname to listen on'
})
.option('keepAliveTimeout', {
group: 'Network:',
type: 'number',
default: 5000,
describe: 'The number of milliseconds of inactivity a server needs to wait for additional incoming data, after it has finished writing the last response, before a socket will be destroyed.'
})
.option('a', {
group: 'Accounts:',
alias: 'accounts',
describe: 'Number of accounts to generate at startup',
type: 'number',
default: 10
})
.option('e', {
group: 'Accounts:',
alias: 'defaultBalanceEther',
describe: 'Amount of ether to assign each test account',
type: 'number',
default: 100.0
})
.option('account', {
group: 'Accounts:',
describe: "Account data in the form '<private_key>,<initial_balance>', can be specified multiple times. Note that private keys are 64 characters long and must be entered as an 0x-prefixed hex string. Balance can either be input as an integer, or as a 0x-prefixed hex string with either form specifying the initial balance in wei.",
type: 'array',
string: true,
demandOption: false
})
.option('account_keys_path', {
group: 'Accounts:',
alias: 'acctKeys',
type: 'string',
describe: 'saves generated accounts and private keys as JSON object in specified file',
normalize: true,
demandOption: false,
default: null
})
.option('n', {
group: 'Accounts:',
alias: 'secure',
describe: 'Lock available accounts by default (good for third party transaction signing)',
type: 'boolean',
default: false
})
.option('u', {
group: 'Accounts:',
alias: 'unlock',
type: 'array',
string: true,
describe: 'Comma-separated list of accounts or indices to unlock',
demandOption: false
})
.option('k', {
group: 'Chain:',
alias: 'hardfork',
type: 'string',
describe: "Allows users to specify which hardfork should be used. Supported hardforks are `byzantium`, `constantinople`, `petersburg`, `istanbul` and `muirGlacier` (default).",
default: "muirGlacier"
})
.option('f', {
group: 'Chain:',
alias: 'fork',
type: 'string',
describe: "Fork from another currently running Ethereum client at a given block. Input should be the HTTP location and port of the other client, e.g. 'http://localhost:8545' or optionally provide a block number 'http://localhost:8545@1599200'",
default: false
})
.option('forkCacheSize', {
group: 'Chain:',
type: 'number',
describe: "The maximum size, in bytes, of the in-memory cache for queries on a chain fork. Defaults to `1_073_741_824` bytes (1 gigabyte). You can set this to `0` to disable caching (not recommended), or to `-1` for unlimited (will be limited by your node process).",
default: 1073741824
})
.option('db', {
group: 'Chain:',
describe: 'Directory of chain database; creates one if it doesn\'t exist',
type: 'string',
normalize: true,
default: null
})
.option('s', {
group: 'Chain:',
alias: 'seed',
type: 'string',
describe: 'Arbitrary data to generate the HD wallet mnemonic to be used',
defaultDescription: "Random value, unless -d is specified",
conflicts: 'd',
demandOption: false
})
.option('hdPath', {
group: 'Accounts:',
alias: 'hd_path',
describe: `The hierarchical deterministic path to use when generating accounts. Default: "m/44'/60'/0'/0/"`,
type: 'string',
demandOption: false
})
.option('d', {
group: 'Chain:',
alias: 'deterministic',
describe: 'Generate deterministic addresses based on a pre-defined mnemonic.',
conflicts: 's',
type: 'boolean',
default: undefined,
demandOption: false
})
.option('m', {
group: 'Chain:',
alias: 'mnemonic',
type: 'string',
describe: 'bip39 mnemonic phrase for generating a PRNG seed, which is in turn used for hierarchical deterministic (HD) account generation',
demandOption: false
})
.option('noVMErrorsOnRPCResponse', {
group: 'Chain:',
describe: 'Do not transmit transaction failures as RPC errors. Enable this flag for error reporting behaviour which is compatible with other clients such as geth and Parity.',
type: 'boolean',
default: false
})
.option('b', {
group: 'Chain:',
alias: 'blockTime',
type: 'number',
describe: 'Block time in seconds for automatic mining. Will instantly mine a new block for every transaction if option omitted. Avoid using unless your test cases require a specific mining interval.',
demandOption: false
})
.option('i', {
group: 'Chain:',
alias: 'networkId',
type: 'number',
describe: "The Network ID ganache-cli will use to identify itself.",
defaultDescription: "System time at process start or Network ID of forked blockchain if configured.",
demandOption: false
})
.option('chainId', {
group: 'Chain:',
type: 'number',
describe: "The Chain ID ganache-cli will use for `eth_chainId` RPC and the `CHAINID` opcode.",
defaultDescription: "For legacy reasons, the default is currently `1337` for `eth_chainId` RPC and `1` for the `CHAINID` opcode. This will be fixed in the next major version of ganache-cli and ganache-core!",
demandOption: false
})
.option('g', {
group: 'Chain:',
alias: 'gasPrice',
describe: 'The price of gas in wei',
type: 'number',
default: 20000000000
})
.option('l', {
group: 'Chain:',
alias: 'gasLimit',
describe: 'The block gas limit in wei',
type: 'number',
default: 0x6691b7
})
.option('callGasLimit', {
group: 'Chain:',
describe: 'Sets the transaction gas limit for `eth_call` and `eth_estimateGas` calls. Must be specified as a hex string. Defaults to "0x1fffffffffffff" (Number.MAX_SAFE_INTEGER)',
type: 'number',
default: 0x1fffffffffffff
})
.option('allowUnlimitedContractSize', {
group: 'Chain:',
describe: 'Allows unlimited contract sizes while debugging. By enabling this flag, the check within the EVM for contract size limit of 24KB (see EIP-170) is bypassed. Enabling this flag *will* cause ganache-cli to behave differently than production environments.',
type: 'boolean',
default: false
})
.option('t', {
group: 'Chain:',
alias: 'time',
describe: 'Date (ISO 8601) that the first block should start. Use this feature, along with the evm_increaseTime method to test time-dependent code.',
type: 'string',
coerce: (arg) => {
let timestamp = Date.parse(arg);
if (isNaN(timestamp)) {
throw new Error('Invalid \'time\' format');
}
return new Date(timestamp);
}
})
.option('debug', {
group: 'Other:',
describe: 'Output VM opcodes for debugging',
type: 'boolean',
default: false
})
.option('v', {
group: 'Other:',
alias: 'verbose',
describe: 'Log all requests and responses to stdout',
type: 'boolean',
default: false
})
.option('mem', {
group: 'Other:',
describe: 'Only show memory output, not tx history',
type: 'boolean',
default: false
})
.option('q', {
group: 'Other:',
alias: 'quiet',
describe: 'Run ganache quietly (no logs)',
type: 'boolean',
default: false
})
.showHelpOnFail(false, 'Specify -? or --help for available options')
.help('help')
.alias('help', '?')
.wrap(Math.min(120, yargs.terminalWidth()))
.version(version)
.check((argv) => {
if (argv.p < 1 || argv.p > 65535) {
throw new Error(`Invalid port number '${argv.p}'`);
}
if (argv.h.trim() == '') {
throw new Error('Cannot leave hostname blank; please provide a hostname');
}
return true;
})
}