forked from trufflesuite/ganache-cli-archive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
args.js
203 lines (201 loc) · 6.7 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
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('acctKeys', {
group: 'Accounts:',
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('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('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('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('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('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;
})
}