-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_nem2-cli
383 lines (365 loc) · 13.4 KB
/
_nem2-cli
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#compdef nem2-cli
__nem2-cli_commands() {
local -a _c
_c=(
'account:Fetch account information'
'blockchain:Fetch blockchain information'
'mosaic:Fetch mosaic information'
'namespace:Fetch namespace information'
'transaction:Send transactions'
'monitor:Monitor blocks, transactions and errors'
'profile:Profile management'
)
_describe -t commands Commands _c
}
__account_commands() {
local -a _c
_c=(
'aggregatebonded:Fetch aggregate bonded transactions from account'
'generate:Generate new accounts'
'incoming:Fetch incoming transactions from account'
'info:Fetch account info'
'outgoing:Fetch outgoing transactions from account'
'transactions:Fetch transactions from account'
'unconfirmed:Fetch unconfirmed transactions from account'
)
_describe -t commands Commands _c
}
__blockchain_commands() {
local -a _c
_c=(
'height:Blockchain height'
'score:Blockchain score'
)
_describe -t commands Commands _c
}
__mosaic_commands() {
local -a _c
_c=(
'info:Fetch Mosaic info'
)
_describe -t commands Commands _c
}
__namespace_commands() {
local -a _c
_c=(
'info:Fetch Mosaic info'
)
_describe -t commands Commands _c
}
__transaction_commands() {
local -a _c
_c=(
'cosign:Cosign an announce aggregate bonded transaction'
'info:Fetch Transaction info'
'mosaic:Mosaic creation transaction'
'namespace:Register namespace transaction'
'pullfunds:Create a pull transaction requesting xem to an account'
'transfer:Send transfer transaction'
)
_describe -t commands Commands _c
}
__monitor_commands() {
local -a _c
_c=(
'aggregatebonded:Monitor aggregate bonded transactions added'
'block:Monitor new blocks'
'confirmed:Monitor confirmed transactions added'
'cosignature:Monitor cosignatures added'
'status:Monitor transaction status error'
'unconfirmed:Monitor unconfirmed transactions added'
)
_describe -t commands Commands _c
}
__profile_commands() {
local -a _c
_c=(
'create:Create an account'
'list:List accounts'
)
_describe -t commands Commands _c
}
_nem2-cli() {
local context curcontext=$curcontext state line
declare -A opt_args
local -a default_opts
local -a opts
local ret=1
default_opts=(
'--help[show help]'
'--profile[(optional) Select between your profiles, by providing a profile name]'
)
_arguments -C \
'1: :__nem2-cli_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(account)
_arguments -C \
'1: :__account_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(aggregatebonded)
_arguments -C \
'(-p --publickey)'{-p,--publickey}'[Account public key]' \
'(-n --numtransactions)'{-n,--numtransactions}'[(optional) Number of transactions]' \
'(-i --id)'{-i,--id}'[(optional) Identifier of the transaction after which we want the transactions to be returned]' \
$default_opts \
&& ret=0
;;
(generate)
_arguments -C \
'(-s --save)'{-s,--save}'[(Optional) Save profile]' \
'(-u --url)'{-u,--url}'[(Optional) When saving profile, provide a NEM2 Node URL. Example: http://localhost:3000]' \
'(-n --network)'{-n,--network}'[Network Type: MAIN_NET, TEST_NET, MIJIN, MIJIN_TEST]' \
$default_opts \
&& ret=0
;;
(incoming)
_arguments -C \
'(-p --publickey)'{-p,--publickey}'[Account public key]' \
'(-n --numtransactions)'{-n,--numtransactions}'[(optional) Number of transactions]' \
'(-i --id)'{-i,--id}'[(optional) Identifier of the transaction after which we want the transactions to be returned]' \
$default_opts \
&& ret=0
;;
(info)
_arguments -C \
'(-a --address)'{-a,--address}'[Account address]' \
$default_opts \
&& ret=0
;;
(outgoing)
_arguments -C \
'(-p --publickey)'{-p,--publickey}'[Account public key]' \
'(-n --numtransactions)'{-n,--numtransactions}'[(optional) Number of transactions]' \
'(-i --id)'{-i,--id}'[(optional) Identifier of the transaction after which we want the transactions to be returned]' \
$default_opts \
&& ret=0
;;
(transactions)
_arguments -C \
'(-p --publickey)'{-p,--publickey}'[Account public key]' \
'(-n --numtransactions)'{-n,--numtransactions}'[(optional) Number of transactions]' \
'(-i --id)'{-i,--id}'[(optional) Identifier of the transaction after which we want the transactions to be returned]' \
$default_opts \
&& ret=0
;;
(unconfirmed)
_arguments -C \
'(-p --publickey)'{-p,--publickey}'[Account public key]' \
'(-n --numtransactions)'{-n,--numtransactions}'[(optional) Number of transactions]' \
'(-i --id)'{-i,--id}'[(optional) Identifier of the transaction after which we want the transactions to be returned]' \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(blockchain)
_arguments -C \
'1: :__blockchain_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(height)
_arguments -C \
$default_opts \
&& ret=0
;;
(score)
_arguments -C \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(mosaic)
_arguments -C \
'1: :__mosaic_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(info)
_arguments -C \
'(-n --name)'{-n,--name}'[Mosaic Id in string format]' \
'(-u --uint)'{-u,--uint}'[Mosaic id in uint64 format. \[number, number\]]' \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(namespace)
_arguments -C \
'1: :__namespace_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(info)
_arguments -C \
'(-n --name)'{-n,--name}'[Namespace Id in string format]' \
'(-u --uint)'{-u,--uint}'[Namespace id in uint64 format. [number, number]]' \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(transaction)
_arguments -C \
'1: :__transaction_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(cosign)
_arguments -C \
'(-h --hash)'{-h,--hash}'[Aggregate bonded transaction hash to be signed]' \
$default_opts \
&& ret=0
;;
(info)
_arguments -C \
'(-h --hash)'{-h,--hash}'[Transaction hash]' \
$default_opts \
&& ret=0
;;
(mosaic)
_arguments -C \
'(-m --mosaicname)'{-m,--mosaicname}'[Mosaic name]' \
'(-n --namespacename)'{-n,--namespacename}'[Parent namespace name]' \
'(-a --amount)'{-a,--amount}'[Amount of tokens]' \
'(-t --transferable)'{-t,--transferable}'[Mosaic transferable]' \
'(-s --supplymutable)'{-s,--supplymutable}'[Mosaic supply mutable]' \
'(-l --levymutable)'{-l,--levymutable}'[Mosaic levy mutable]' \
'(-d --divisibility)'{-d,--divisibility}'[Mosaic divisibility, from 0 to 6]' \
'(-u --duration)'{-u,--duration}'[Mosaic duration in amount of blocks]' \
$default_opts \
&& ret=0
;;
(namespace)
_arguments -C \
'(-n --name)'{-n,--name}'[Namespace name]' \
'(-r --rootnamespace)'{-r,--rootnamespace}'[Root namespace]' \
'(-s --subnamespace)'{-s,--subnamespace}'[Sub namespace]' \
'(-d --duration)'{-d,--duration}'[Duration (use it with --rootnamespace)]' \
'(-p --parentname)'{-p,--parentname}'[Parent namespace name (use it with --subnamespace)]' \
$default_opts \
&& ret=0
;;
(pullfunds)
_arguments -C \
'(-r --recipient)'{-r,--recipient}'[Funds holder address]' \
'(-m --message)'{-m,--message}'[Message to the funds holder]' \
'(-x --mosaic)'{-x,--mosaic}'[Mosaic you want to get in the format namespaceName:mosaicName::absoluteAmount]' \
$default_opts \
&& ret=0
;;
(transfer)
_arguments -C \
'(-r --recipient)'{-r,--recipient}'[Recipient]' \
'(-m --message)'{-m,--message}'[Transaction message]' \
'(-c --mosaic)'{-c,--mosaic}'[Mosaic you want to get in the format namespaceName:mosaicName::absoluteAmount, add multiple mosaics splitting them with a comma]' \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(monitor)
_arguments -C \
'1: :__monitor_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(aggregatebonded)
_arguments -C \
'(-a --address)'{-a,--address}'[Address]' \
$default_opts \
&& ret=0
;;
(block)
_arguments -C \
$default_opts \
&& ret=0
;;
(confirmed)
_arguments -C \
'(-a --address)'{-a,--address}'[Address]' \
$default_opts \
&& ret=0
;;
(cosignature)
_arguments -C \
'(-a --address)'{-a,--address}'[Address]' \
$default_opts \
&& ret=0
;;
(status)
_arguments -C \
'(-a --address)'{-a,--address}'[Address]' \
$default_opts \
&& ret=0
;;
(unconfirmed)
_arguments -C \
'(-a --address)'{-a,--address}'[Address]' \
$default_opts \
&& ret=0
;;
esac
;;
esac
;;
(profile)
_arguments -C \
'1: :__profile_commands' \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(create)
_arguments -C \
'(-p --privatekey)'{-p,--privatekey}'[Private key]' \
'(-n --network)'{-n,--network}'[Network Type: MAIN_NET, TEST_NET, MIJIN, MIJIN_TEST]' \
'(-u --url)'{-u,--url}'[NEM2 Node URL. Example: http://localhost:3000]' \
$default_opts \
&& ret=0
;;
(list)
_arguments -C \
'(-a --address)'{-a,--address}'[Account address]' \
&& ret=0
;;
esac
;;
esac
;;
esac
;;
esac
return ret
}
_nem2-cli "$@"