@witnet/sdk 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env_witnet +6 -6
- package/LICENSE +21 -21
- package/README.md +103 -103
- package/dist/bin/helpers.d.ts +88 -0
- package/dist/bin/helpers.d.ts.map +1 -0
- package/dist/bin/helpers.js +866 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/lib/crypto/account.d.ts +18 -0
- package/dist/lib/crypto/account.d.ts.map +1 -0
- package/dist/lib/crypto/account.js +152 -0
- package/dist/lib/crypto/coinbase.d.ts +9 -0
- package/dist/lib/crypto/coinbase.d.ts.map +1 -0
- package/dist/lib/crypto/coinbase.js +39 -0
- package/dist/lib/crypto/index.d.ts +7 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +28 -0
- package/dist/lib/crypto/interfaces.d.ts +80 -0
- package/dist/lib/crypto/interfaces.d.ts.map +1 -0
- package/dist/lib/crypto/interfaces.js +3 -0
- package/dist/lib/crypto/payloads/DataRequestPayload.d.ts +47 -0
- package/dist/lib/crypto/payloads/DataRequestPayload.d.ts.map +1 -0
- package/dist/lib/crypto/payloads/DataRequestPayload.js +384 -0
- package/dist/lib/crypto/payloads/StakePayload.d.ts +27 -0
- package/dist/lib/crypto/payloads/StakePayload.d.ts.map +1 -0
- package/dist/lib/crypto/payloads/StakePayload.js +184 -0
- package/dist/lib/crypto/payloads/UnstakePayload.d.ts +35 -0
- package/dist/lib/crypto/payloads/UnstakePayload.d.ts.map +1 -0
- package/dist/lib/crypto/payloads/UnstakePayload.js +244 -0
- package/dist/lib/crypto/payloads/ValueTransferPayload.d.ts +24 -0
- package/dist/lib/crypto/payloads/ValueTransferPayload.d.ts.map +1 -0
- package/dist/lib/crypto/payloads/ValueTransferPayload.js +182 -0
- package/dist/lib/crypto/payloads.d.ts +54 -0
- package/dist/lib/crypto/payloads.d.ts.map +1 -0
- package/dist/lib/crypto/payloads.js +224 -0
- package/dist/lib/crypto/signer.d.ts +26 -0
- package/dist/lib/crypto/signer.d.ts.map +1 -0
- package/dist/lib/crypto/signer.js +299 -0
- package/dist/lib/crypto/transmitters/DataRequests.d.ts +14 -0
- package/dist/lib/crypto/transmitters/DataRequests.d.ts.map +1 -0
- package/dist/lib/crypto/transmitters/DataRequests.js +62 -0
- package/dist/lib/crypto/transmitters/StakeDeposits.d.ts +11 -0
- package/dist/lib/crypto/transmitters/StakeDeposits.d.ts.map +1 -0
- package/dist/lib/crypto/transmitters/StakeDeposits.js +48 -0
- package/dist/lib/crypto/transmitters/StakeWithdrawals.d.ts +17 -0
- package/dist/lib/crypto/transmitters/StakeWithdrawals.d.ts.map +1 -0
- package/dist/lib/crypto/transmitters/StakeWithdrawals.js +115 -0
- package/dist/lib/crypto/transmitters/ValueTransfers.d.ts +10 -0
- package/dist/lib/crypto/transmitters/ValueTransfers.d.ts.map +1 -0
- package/dist/lib/crypto/transmitters/ValueTransfers.js +47 -0
- package/dist/lib/crypto/transmitters.d.ts +46 -0
- package/dist/lib/crypto/transmitters.d.ts.map +1 -0
- package/dist/lib/crypto/transmitters.js +506 -0
- package/dist/lib/crypto/types.d.ts +127 -0
- package/dist/lib/crypto/types.d.ts.map +1 -0
- package/dist/lib/crypto/types.js +261 -0
- package/dist/lib/crypto/utils.d.ts +10 -0
- package/dist/lib/crypto/utils.d.ts.map +1 -0
- package/dist/lib/crypto/utils.js +97 -0
- package/dist/lib/crypto/wallet.d.ts +26 -0
- package/dist/lib/crypto/wallet.d.ts.map +1 -0
- package/dist/lib/crypto/wallet.js +327 -0
- package/dist/lib/helpers.d.ts +90 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +1031 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +21 -0
- package/dist/lib/radon/artifacts.d.ts +55 -0
- package/dist/lib/radon/artifacts.d.ts.map +1 -0
- package/dist/lib/radon/artifacts.js +347 -0
- package/dist/lib/radon/ccdr/eth.d.ts +100 -0
- package/dist/lib/radon/ccdr/eth.d.ts.map +1 -0
- package/dist/lib/radon/ccdr/eth.js +237 -0
- package/dist/lib/radon/ccdr/index.d.ts +34 -0
- package/dist/lib/radon/ccdr/index.d.ts.map +1 -0
- package/dist/lib/radon/ccdr/index.js +63 -0
- package/dist/lib/radon/ccdr/wit.d.ts +29 -0
- package/dist/lib/radon/ccdr/wit.d.ts.map +1 -0
- package/dist/lib/radon/ccdr/wit.js +60 -0
- package/dist/lib/radon/filters.d.ts +14 -0
- package/dist/lib/radon/filters.d.ts.map +1 -0
- package/dist/lib/radon/filters.js +47 -0
- package/dist/lib/radon/index.d.ts +36 -0
- package/dist/lib/radon/index.d.ts.map +1 -0
- package/dist/lib/radon/index.js +154 -0
- package/dist/lib/radon/reducers.d.ts +29 -0
- package/dist/lib/radon/reducers.d.ts.map +1 -0
- package/dist/lib/radon/reducers.js +101 -0
- package/dist/lib/radon/retrievals.d.ts +120 -0
- package/dist/lib/radon/retrievals.d.ts.map +1 -0
- package/dist/lib/radon/retrievals.js +358 -0
- package/dist/lib/radon/sources.d.ts +102 -0
- package/dist/lib/radon/sources.d.ts.map +1 -0
- package/dist/lib/radon/sources.js +294 -0
- package/dist/lib/radon/types.d.ts +521 -0
- package/dist/lib/radon/types.d.ts.map +1 -0
- package/dist/lib/radon/types.js +1066 -0
- package/dist/lib/radon/utils.d.ts +55 -0
- package/dist/lib/radon/utils.d.ts.map +1 -0
- package/dist/lib/radon/utils.js +181 -0
- package/dist/lib/rpc/farm.d.ts +66 -0
- package/dist/lib/rpc/farm.d.ts.map +1 -0
- package/dist/lib/rpc/farm.js +808 -0
- package/dist/lib/rpc/index.d.ts +3 -0
- package/dist/lib/rpc/index.d.ts.map +1 -0
- package/dist/lib/rpc/index.js +19 -0
- package/dist/lib/rpc/node.d.ts +38 -0
- package/dist/lib/rpc/node.d.ts.map +1 -0
- package/dist/lib/rpc/node.js +335 -0
- package/dist/lib/rpc/nodes.d.ts +40 -0
- package/dist/lib/rpc/nodes.d.ts.map +1 -0
- package/dist/lib/rpc/nodes.js +531 -0
- package/dist/lib/rpc/provider.d.ts +72 -0
- package/dist/lib/rpc/provider.d.ts.map +1 -0
- package/dist/lib/rpc/provider.js +402 -0
- package/dist/lib/rpc/reporter.d.ts +18 -0
- package/dist/lib/rpc/reporter.d.ts.map +1 -0
- package/dist/lib/rpc/reporter.js +99 -0
- package/dist/lib/rpc/types.d.ts +396 -0
- package/dist/lib/rpc/types.d.ts.map +1 -0
- package/dist/lib/rpc/types.js +81 -0
- package/dist/lib/rpc/wallet.d.ts +72 -0
- package/dist/lib/rpc/wallet.d.ts.map +1 -0
- package/dist/lib/rpc/wallet.js +41 -0
- package/dist/lib/types.d.ts +19 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +7 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +51 -0
- package/dist/package.json +1 -1
- package/dist/src/bin/helpers.js +2 -2
- package/dist/src/index.js +1 -1
- package/dist/src/lib/crypto/account.js +1 -1
- package/dist/src/lib/crypto/coinbase.js +1 -1
- package/dist/src/lib/crypto/index.js +1 -1
- package/dist/src/lib/crypto/interfaces.js +1 -1
- package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts +2 -2
- package/dist/src/lib/crypto/payloads/DataRequestPayload.d.ts.map +1 -1
- package/dist/src/lib/crypto/payloads/DataRequestPayload.js +8 -8
- package/dist/src/lib/crypto/payloads/StakePayload.js +1 -1
- package/dist/src/lib/crypto/payloads/UnstakePayload.js +1 -1
- package/dist/src/lib/crypto/payloads/ValueTransferPayload.js +1 -1
- package/dist/src/lib/crypto/payloads.js +1 -1
- package/dist/src/lib/crypto/signer.js +1 -1
- package/dist/src/lib/crypto/transmitters/DataRequests.d.ts +0 -1
- package/dist/src/lib/crypto/transmitters/DataRequests.d.ts.map +1 -1
- package/dist/src/lib/crypto/transmitters/DataRequests.js +1 -2
- package/dist/src/lib/crypto/transmitters/StakeDeposits.js +1 -1
- package/dist/src/lib/crypto/transmitters/StakeWithdrawals.js +1 -1
- package/dist/src/lib/crypto/transmitters/ValueTransfers.js +1 -1
- package/dist/src/lib/crypto/transmitters.js +1 -1
- package/dist/src/lib/crypto/types.js +1 -1
- package/dist/src/lib/crypto/utils.js +1 -1
- package/dist/src/lib/crypto/wallet.js +1 -1
- package/dist/src/lib/index.js +1 -1
- package/dist/src/lib/radon/ccdr/eth.js +1 -1
- package/dist/src/lib/radon/ccdr/index.js +1 -1
- package/dist/src/lib/radon/ccdr/wit.d.ts +11 -0
- package/dist/src/lib/radon/ccdr/wit.d.ts.map +1 -1
- package/dist/src/lib/radon/ccdr/wit.js +17 -2
- package/dist/src/lib/radon/filters.js +1 -1
- package/dist/src/lib/radon/index.d.ts +1 -1
- package/dist/src/lib/radon/index.d.ts.map +1 -1
- package/dist/src/lib/radon/index.js +9 -3
- package/dist/src/lib/radon/reducers.js +1 -1
- package/dist/src/lib/radon/types.js +1 -1
- package/dist/src/lib/radon/utils.js +1 -1
- package/dist/src/lib/rpc/index.js +1 -1
- package/dist/src/lib/rpc/nodes.js +1 -1
- package/dist/src/lib/rpc/provider.d.ts +5 -3
- package/dist/src/lib/rpc/provider.d.ts.map +1 -1
- package/dist/src/lib/rpc/provider.js +14 -3
- package/dist/src/lib/rpc/reporter.d.ts +2 -3
- package/dist/src/lib/rpc/reporter.d.ts.map +1 -1
- package/dist/src/lib/rpc/reporter.js +1 -4
- package/dist/src/lib/rpc/types.d.ts +49 -24
- package/dist/src/lib/rpc/types.d.ts.map +1 -1
- package/dist/src/lib/rpc/types.js +3 -1
- package/dist/src/lib/types.d.ts +1 -1
- package/dist/src/lib/types.d.ts.map +1 -1
- package/dist/src/lib/types.js +1 -1
- package/dist/src/lib/utils.js +1 -1
- package/dist/witnet/assets/index.js +1 -1
- package/dist/witnet/assets/modals/index.js +1 -1
- package/dist/witnet/assets/modals/web3/eth.js +1 -1
- package/dist/witnet/assets/modals/web3/ipfs.js +1 -1
- package/dist/witnet/assets/modals/web3/wit.js +4 -7
- package/dist/witnet/assets/requests.js +1 -1
- package/package.json +1 -1
- package/src/bin/cli/history.js +31 -31
- package/src/bin/cli/inspect.js +405 -359
- package/src/bin/cli/network.js +594 -592
- package/src/bin/cli/nodes.js +364 -364
- package/src/bin/cli/radon.js +815 -815
- package/src/bin/cli/wallet.js +1117 -1094
- package/src/bin/helpers.js +840 -840
- package/src/bin/postinstall.js +9 -9
- package/src/bin/toolkit.js +295 -295
- package/witnet/assets/_index.js +8 -8
- package/witnet/assets/_requests.js +25 -25
- package/witnet/assets/_sources.js +36 -36
- package/witnet/assets/_templates.js +36 -36
- package/witnet/assets/index.js +4 -4
- package/witnet/assets/modals/index.js +9 -9
- package/witnet/assets/modals/web3/eth.js +29 -29
- package/witnet/assets/modals/web3/ipfs.js +19 -19
- package/witnet/assets/modals/web3/wit.js +21 -23
- package/witnet/assets/requests.js +95 -95
package/src/bin/cli/inspect.js
CHANGED
|
@@ -1,359 +1,405 @@
|
|
|
1
|
-
const moment = require("moment")
|
|
2
|
-
|
|
3
|
-
const helpers = require("../helpers")
|
|
4
|
-
const { utils, Witnet } = require("../../../dist/src")
|
|
5
|
-
|
|
6
|
-
const { cyan, gray, green, lyellow, magenta, mgreen, mmagenta, myellow, yellow } = helpers.colors
|
|
7
|
-
|
|
8
|
-
/// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
9
|
-
/// CLI SUBMODULE CONSTANTS ===========================================================================================
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
envars: {
|
|
13
|
-
WITNET_SDK_PROVIDER_URL: "=> Wit/Oracle RPC provider(s) to connect to, if no otherwise specified.",
|
|
14
|
-
},
|
|
15
|
-
flags: {
|
|
16
|
-
provider: {
|
|
17
|
-
hint: "Public Wit/Oracle JSON-RPC provider, other than default.",
|
|
18
|
-
param: ":http-url",
|
|
19
|
-
},
|
|
20
|
-
verbose: {
|
|
21
|
-
hint: "Outputs validators' nonce and last validation epochs.",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
router: {
|
|
25
|
-
balance: {
|
|
26
|
-
hint: "Show available Wits on given address.",
|
|
27
|
-
params: "WIT_ADDRESS",
|
|
28
|
-
},
|
|
29
|
-
block: {
|
|
30
|
-
hint: "Get block data given its block hash.",
|
|
31
|
-
params: "BLOCK_HASH",
|
|
32
|
-
},
|
|
33
|
-
dataRequest: {
|
|
34
|
-
hint: "
|
|
35
|
-
params: "DR_TX_HASH",
|
|
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
|
-
const
|
|
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
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const
|
|
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
|
-
return [
|
|
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
|
-
|
|
1
|
+
const moment = require("moment")
|
|
2
|
+
|
|
3
|
+
const helpers = require("../helpers")
|
|
4
|
+
const { utils, Witnet } = require("../../../dist/src")
|
|
5
|
+
|
|
6
|
+
const { cyan, gray, green, lyellow, magenta, mgreen, mmagenta, myellow, yellow } = helpers.colors
|
|
7
|
+
|
|
8
|
+
/// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
9
|
+
/// CLI SUBMODULE CONSTANTS ===========================================================================================
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
envars: {
|
|
13
|
+
WITNET_SDK_PROVIDER_URL: "=> Wit/Oracle RPC provider(s) to connect to, if no otherwise specified.",
|
|
14
|
+
},
|
|
15
|
+
flags: {
|
|
16
|
+
provider: {
|
|
17
|
+
hint: "Public Wit/Oracle JSON-RPC provider, other than default.",
|
|
18
|
+
param: ":http-url",
|
|
19
|
+
},
|
|
20
|
+
verbose: {
|
|
21
|
+
hint: "Outputs validators' nonce and last validation epochs.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
router: {
|
|
25
|
+
balance: {
|
|
26
|
+
hint: "Show available Wits on given address.",
|
|
27
|
+
params: "WIT_ADDRESS",
|
|
28
|
+
},
|
|
29
|
+
block: {
|
|
30
|
+
hint: "Get block data given its block hash.",
|
|
31
|
+
params: "BLOCK_HASH",
|
|
32
|
+
},
|
|
33
|
+
dataRequest: {
|
|
34
|
+
hint: "Get query parameters and result to some data request transaction.",
|
|
35
|
+
params: "DR_TX_HASH",
|
|
36
|
+
options: {
|
|
37
|
+
force: {
|
|
38
|
+
hint: "Get data even if the WIT/RPC provider is not synced."
|
|
39
|
+
},
|
|
40
|
+
mode: {
|
|
41
|
+
hint: "Possible report formats (default: `ethereal`).",
|
|
42
|
+
param: "`ethereal` | `full``",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
"dataRequests*": {
|
|
47
|
+
hint: "Search for in-flight or recently solved data request transactions.",
|
|
48
|
+
params: "BYTECODE | RAD_HASH | DDR_HASH",
|
|
49
|
+
options: {
|
|
50
|
+
limit: { hint: "Limit output records (default: 100).", param: "LIMIT" },
|
|
51
|
+
since: {
|
|
52
|
+
hint: "Number of past epochs to search for (default: 256; max: 2048).",
|
|
53
|
+
param: "EPOCH|MINUS_EPOCHS",
|
|
54
|
+
},
|
|
55
|
+
"min-unitary-reward": {
|
|
56
|
+
hint: "Filters out those providing less unitary reward than specified.",
|
|
57
|
+
param: "NANOWITS",
|
|
58
|
+
},
|
|
59
|
+
"min-witnesses": {
|
|
60
|
+
hint: "Filters out those solved with less than specified witnesses.",
|
|
61
|
+
param: "NUM_WITNESSES",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
superblock: {
|
|
66
|
+
hint: "Show superblock metadata for given epoch.",
|
|
67
|
+
params: "EPOCH",
|
|
68
|
+
},
|
|
69
|
+
transaction: {
|
|
70
|
+
hint: "Report transaction details given its transaction hash.",
|
|
71
|
+
params: "TX_HASH",
|
|
72
|
+
},
|
|
73
|
+
validators: {
|
|
74
|
+
hint: "List validators treasuring delegated stake from the specified address.",
|
|
75
|
+
params: "WIT_ADDRESS",
|
|
76
|
+
},
|
|
77
|
+
valueTransfer: {
|
|
78
|
+
hint: "Report value transfer details given its transaction hash.",
|
|
79
|
+
params: "VT_TX_HASH",
|
|
80
|
+
options: {
|
|
81
|
+
force: {
|
|
82
|
+
hint: "Get data even if the WIT/RPC provider is not synced."
|
|
83
|
+
},
|
|
84
|
+
mode: {
|
|
85
|
+
hint: "Possible report formats (default: `full`).",
|
|
86
|
+
param: "`ethereal` | `full` | `simple`",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
withdrawers: {
|
|
91
|
+
hint: "List withdrawers currently delegating stake to the specified address.",
|
|
92
|
+
params: "WIT_ADDRESS",
|
|
93
|
+
},
|
|
94
|
+
utxos: {
|
|
95
|
+
hint: "List UTXOs available to the specified address.",
|
|
96
|
+
params: "WIT_ADDRESS",
|
|
97
|
+
options: {
|
|
98
|
+
"small-first": {
|
|
99
|
+
hint: "Outputs smallest UTXOs first (default: false).",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
subcommands: {
|
|
105
|
+
balance, block, dataRequest, superblock, transaction, validators, withdrawers, utxos, valueTransfer,
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
110
|
+
/// CLI SUBMODULE COMMANDS ============================================================================================
|
|
111
|
+
|
|
112
|
+
async function balance (options = {}, args = []) {
|
|
113
|
+
if (args.length === 0) {
|
|
114
|
+
throw Error("No WIT_ADDRESS was specified")
|
|
115
|
+
}
|
|
116
|
+
const pkh = args[0]
|
|
117
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
118
|
+
const balance = await provider.getBalance(pkh)
|
|
119
|
+
const records = []
|
|
120
|
+
records.push([
|
|
121
|
+
Witnet.Coins.fromNanowits(balance.locked).wits,
|
|
122
|
+
Witnet.Coins.fromNanowits(balance.staked).wits,
|
|
123
|
+
Witnet.Coins.fromNanowits(balance.unlocked).wits,
|
|
124
|
+
Witnet.Coins.fromNanowits(balance.locked + balance.staked + balance.unlocked).wits,
|
|
125
|
+
])
|
|
126
|
+
helpers.traceTable(records, {
|
|
127
|
+
headlines: ["Locked ($WIT)", "Staked ($WIT)", "Available ($WIT)", "BALANCE ($WIT)"],
|
|
128
|
+
humanizers: [helpers.commas, helpers.commas, helpers.commas, helpers.commas],
|
|
129
|
+
colors: [gray, yellow, myellow, lyellow],
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function block (options = {}, args = []) {
|
|
134
|
+
if (args.length === 0) {
|
|
135
|
+
throw Error("No BLOCK_HASH was specified")
|
|
136
|
+
}
|
|
137
|
+
const blockHash = args[0].startsWith("0x") ? args[0].slice(2) : args[0]
|
|
138
|
+
if (!helpers.isHexString(blockHash)) {
|
|
139
|
+
throw Error("Invalid BLOCK_HASH was provided")
|
|
140
|
+
}
|
|
141
|
+
const provider = await Witnet.JsonRpcProvider.fromEnv(options?.provider)
|
|
142
|
+
const block = await provider.getBlock(blockHash)
|
|
143
|
+
console.info(gray(JSON.stringify(block, (key, value) => {
|
|
144
|
+
switch (key) {
|
|
145
|
+
case "bytes":
|
|
146
|
+
case "der":
|
|
147
|
+
case "proof":
|
|
148
|
+
return Array.isArray(value) ? helpers.toHexString(value, true) : value
|
|
149
|
+
|
|
150
|
+
case "public_key":
|
|
151
|
+
return Array.isArray(value)
|
|
152
|
+
? helpers.toHexString(value, true)
|
|
153
|
+
: (typeof value === 'object' ? Witnet.PublicKey.fromProtobuf(value).hash().toBech32(provider.network) : value)
|
|
154
|
+
|
|
155
|
+
default:
|
|
156
|
+
return value
|
|
157
|
+
}
|
|
158
|
+
}, 2)))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function dataRequest (options = {}, args = []) {
|
|
162
|
+
if (args.length === 0) {
|
|
163
|
+
throw Error("No DR_TX_HASH was specified")
|
|
164
|
+
}
|
|
165
|
+
const drTxHash = args[0].startsWith("0x") ? args[0].slice(2) : args[0]
|
|
166
|
+
if (!helpers.isHexString(drTxHash)) {
|
|
167
|
+
throw Error("Invalid DR_TX_HASH was provided")
|
|
168
|
+
}
|
|
169
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
170
|
+
|
|
171
|
+
const drTxJsonReplacer = (key, value) => {
|
|
172
|
+
switch (key) {
|
|
173
|
+
case "proof":
|
|
174
|
+
case "public_key":
|
|
175
|
+
case "signature":
|
|
176
|
+
case "signatures":
|
|
177
|
+
return undefined
|
|
178
|
+
|
|
179
|
+
case "reveal":
|
|
180
|
+
case "tally":
|
|
181
|
+
if (Array.isArray(value)) {
|
|
182
|
+
const result = utils.cbor.decode(Uint8Array.from(value))
|
|
183
|
+
return Buffer.isBuffer(result) ? utils.toHexString(value) : result
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
default:
|
|
187
|
+
return value
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const mode = options?.mode || `ethereal`
|
|
192
|
+
if (!["ethereal", "full"].includes(mode)) {
|
|
193
|
+
throw Error(`Invalid mode value: "${options.mode}"`)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const report = await provider.getDataRequest(drTxHash, mode, options?.force)
|
|
197
|
+
console.info(JSON.stringify(report, drTxJsonReplacer, 4))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function superblock (options = {}, args = []) {
|
|
201
|
+
if (args.length === 0) {
|
|
202
|
+
throw Error("No EPOCH was specified")
|
|
203
|
+
}
|
|
204
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
205
|
+
const superblock = await provider.getSuperblock(args[0])
|
|
206
|
+
console.info(superblock)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function transaction (options = {}, args = []) {
|
|
210
|
+
if (args.length === 0) {
|
|
211
|
+
throw Error("No TX_HASH was specified")
|
|
212
|
+
}
|
|
213
|
+
const txHash = args[0].startsWith("0x") ? args[0].slice(2) : args[0]
|
|
214
|
+
if (!helpers.isHexString(txHash)) {
|
|
215
|
+
throw Error("Invalid TX_HASH was provided")
|
|
216
|
+
}
|
|
217
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
218
|
+
const transaction = await provider.getTransaction(txHash)
|
|
219
|
+
console.info(
|
|
220
|
+
`${yellow(JSON.stringify(transaction, utils.txJsonReplacer, 2))}`
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function utxos (options = {}, args = []) {
|
|
225
|
+
if (args.length < 1) {
|
|
226
|
+
throw Error("No WIT_ADDRESS was specified")
|
|
227
|
+
}
|
|
228
|
+
const now = Math.floor(Date.now() / 1000)
|
|
229
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
230
|
+
let utxos = await provider.getUtxos(args[0], options["small-first"] || false)
|
|
231
|
+
let totalBalance = 0n
|
|
232
|
+
if (!options?.verbose) {
|
|
233
|
+
utxos = utxos
|
|
234
|
+
.filter(utxo => utxo.timelock <= now)
|
|
235
|
+
.map(utxo => {
|
|
236
|
+
totalBalance += utxo.value
|
|
237
|
+
return [
|
|
238
|
+
utxo.output_pointer,
|
|
239
|
+
utxo.value,
|
|
240
|
+
]
|
|
241
|
+
})
|
|
242
|
+
helpers.traceTable(utxos, {
|
|
243
|
+
headlines: [":UTXOs", "Value ($pedros)"],
|
|
244
|
+
humanizers: [, helpers.commas],
|
|
245
|
+
colors: [, myellow],
|
|
246
|
+
})
|
|
247
|
+
} else {
|
|
248
|
+
utxos = utxos
|
|
249
|
+
.map(utxo => {
|
|
250
|
+
totalBalance += utxo.value
|
|
251
|
+
return [
|
|
252
|
+
utxo.output_pointer,
|
|
253
|
+
utxo.timelock > now ? gray(moment.unix(utxo.timelock).fromNow()) : "",
|
|
254
|
+
utxo.timelock > now ? gray(helpers.commas(utxo.value)) : myellow(helpers.commas(utxo.value)),
|
|
255
|
+
]
|
|
256
|
+
})
|
|
257
|
+
helpers.traceTable(utxos, {
|
|
258
|
+
headlines: [":UTXOs", "Timelock", "Value ($pedros)"],
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
console.info(`^ Showing ${utxos.length} UTXOs: ${lyellow(helpers.whole_wits(totalBalance, 2))}.`)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function validators (options = {}, args = []) {
|
|
265
|
+
if (args.length === 0) {
|
|
266
|
+
throw Error("No WIT_ADDRESS was specified")
|
|
267
|
+
}
|
|
268
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
269
|
+
const query = {
|
|
270
|
+
filter: { withdrawer: args[0] },
|
|
271
|
+
}
|
|
272
|
+
const records = await provider.stakes(query)
|
|
273
|
+
let nanowits = 0
|
|
274
|
+
if (records.length > 0) {
|
|
275
|
+
helpers.traceTable(
|
|
276
|
+
records.map((record, index) => {
|
|
277
|
+
nanowits += record.value.coins
|
|
278
|
+
return [
|
|
279
|
+
1 + index,
|
|
280
|
+
record.key.validator,
|
|
281
|
+
...(
|
|
282
|
+
options?.verbose
|
|
283
|
+
? [record.value.nonce, record.value.epochs.witnessing, record.value.epochs.mining]
|
|
284
|
+
: []
|
|
285
|
+
),
|
|
286
|
+
Witnet.Coins.fromNanowits(record.value.coins).wits,
|
|
287
|
+
]
|
|
288
|
+
}), {
|
|
289
|
+
headlines: [
|
|
290
|
+
"RANK",
|
|
291
|
+
"VALIDATORS",
|
|
292
|
+
...(
|
|
293
|
+
options?.verbose
|
|
294
|
+
? ["Nonce", "LW_Epoch", "LM_Epoch"]
|
|
295
|
+
: []
|
|
296
|
+
),
|
|
297
|
+
"STAKED ($WIT)",
|
|
298
|
+
],
|
|
299
|
+
humanizers: [
|
|
300
|
+
,, ...(
|
|
301
|
+
options?.verbose
|
|
302
|
+
? [helpers.commas, helpers.commas, helpers.commas]
|
|
303
|
+
: []
|
|
304
|
+
),
|
|
305
|
+
helpers.commas,
|
|
306
|
+
],
|
|
307
|
+
colors: [, green, ...(
|
|
308
|
+
options?.verbose
|
|
309
|
+
? [, magenta, cyan, myellow]
|
|
310
|
+
: [myellow]
|
|
311
|
+
)],
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
console.info(
|
|
315
|
+
`^ ${records.length} validators for withdrawer ${
|
|
316
|
+
mgreen(args[0])
|
|
317
|
+
}: ${
|
|
318
|
+
lyellow(helpers.whole_wits(nanowits, 2))
|
|
319
|
+
}`
|
|
320
|
+
)
|
|
321
|
+
} else {
|
|
322
|
+
console.info(`> No validators found for withdrawer ${mmagenta(args[0])}.`)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
async function valueTransfer (options = {}, args = []) {
|
|
327
|
+
if (args.length === 0) {
|
|
328
|
+
throw Error("No VT_TX_HASH was specified")
|
|
329
|
+
}
|
|
330
|
+
const txHash = args[0].startsWith("0x") ? args[0].slice(2) : args[0]
|
|
331
|
+
if (!helpers.isHexString(txHash)) {
|
|
332
|
+
throw Error("Invalid VT_TX_HASH was provided")
|
|
333
|
+
}
|
|
334
|
+
const mode = options?.mode || `full`
|
|
335
|
+
if (!["ethereal", "full", "simple"].includes(mode)) {
|
|
336
|
+
throw Error(`Invalid mode value: "${options.mode}"`)
|
|
337
|
+
}
|
|
338
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
339
|
+
const transaction = await provider.getValueTransfer(txHash, mode, options?.force)
|
|
340
|
+
console.info(
|
|
341
|
+
`${yellow(JSON.stringify(transaction, utils.txJsonReplacer, 2))}`
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async function withdrawers (options = {}, args = []) {
|
|
346
|
+
if (args.length === 0) {
|
|
347
|
+
throw Error("No WIT_ADDRESS was specified")
|
|
348
|
+
}
|
|
349
|
+
const provider = new Witnet.JsonRpcProvider(options?.provider)
|
|
350
|
+
const query = {
|
|
351
|
+
filter: { validator: args[0] },
|
|
352
|
+
}
|
|
353
|
+
const records = await provider.stakes(query)
|
|
354
|
+
let nanowits = 0
|
|
355
|
+
if (records.length > 0) {
|
|
356
|
+
helpers.traceTable(
|
|
357
|
+
records.map((record, index) => {
|
|
358
|
+
nanowits += record.value.coins
|
|
359
|
+
return [
|
|
360
|
+
1 + index,
|
|
361
|
+
record.key.withdrawer,
|
|
362
|
+
...(
|
|
363
|
+
options?.verbose
|
|
364
|
+
? [record.value.nonce, record.value.epochs.witnessing, record.value.epochs.mining]
|
|
365
|
+
: []
|
|
366
|
+
),
|
|
367
|
+
Witnet.Coins.fromNanowits(record.value.coins).wits,
|
|
368
|
+
]
|
|
369
|
+
}), {
|
|
370
|
+
headlines: [
|
|
371
|
+
"RANK",
|
|
372
|
+
"WITHDRAWERS",
|
|
373
|
+
...(
|
|
374
|
+
options?.verbose
|
|
375
|
+
? ["Nonce", "LW_Epoch", "LM_Epoch"]
|
|
376
|
+
: []
|
|
377
|
+
),
|
|
378
|
+
"STAKED ($WIT)",
|
|
379
|
+
],
|
|
380
|
+
humanizers: [
|
|
381
|
+
,, ...(
|
|
382
|
+
options?.verbose
|
|
383
|
+
? [helpers.commas, helpers.commas, helpers.commas]
|
|
384
|
+
: []
|
|
385
|
+
),
|
|
386
|
+
helpers.commas,
|
|
387
|
+
],
|
|
388
|
+
colors: [, green, ...(
|
|
389
|
+
options?.verbose
|
|
390
|
+
? [, magenta, cyan, myellow]
|
|
391
|
+
: [myellow]
|
|
392
|
+
)],
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
console.info(
|
|
396
|
+
`^ ${records.length} withdrawers for validator ${
|
|
397
|
+
mgreen(args[0])
|
|
398
|
+
}: ${
|
|
399
|
+
lyellow(helpers.whole_wits(nanowits, 2))
|
|
400
|
+
}`
|
|
401
|
+
)
|
|
402
|
+
} else {
|
|
403
|
+
console.info(`> No withdrawers found for validator ${mmagenta(args[0])}.`)
|
|
404
|
+
}
|
|
405
|
+
}
|