@n1xyz/nord-ts 0.0.8 → 0.0.9
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/dist/idl/bridge.js +237 -10
- package/dist/nord/api/queries.d.ts +7 -42
- package/dist/nord/api/queries.js +15 -93
- package/dist/nord/client/Nord.d.ts +11 -42
- package/dist/nord/client/Nord.js +13 -52
- package/package.json +1 -1
- package/src/idl/bridge.ts +238 -11
- package/src/nord/api/queries.ts +16 -113
- package/src/nord/client/Nord.ts +15 -64
- package/test.ts +50 -23
package/dist/idl/bridge.js
CHANGED
|
@@ -44,14 +44,13 @@ exports.BRIDGE_IDL = {
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
|
-
name: "
|
|
47
|
+
name: "asset_config",
|
|
48
48
|
pda: {
|
|
49
49
|
seeds: [
|
|
50
50
|
{
|
|
51
51
|
kind: "const",
|
|
52
52
|
value: [
|
|
53
|
-
97, 115, 115, 101, 116, 95,
|
|
54
|
-
115, 116, 101, 100,
|
|
53
|
+
97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
|
|
55
54
|
],
|
|
56
55
|
},
|
|
57
56
|
{
|
|
@@ -83,6 +82,38 @@ exports.BRIDGE_IDL = {
|
|
|
83
82
|
{
|
|
84
83
|
name: "to_account",
|
|
85
84
|
writable: true,
|
|
85
|
+
pda: {
|
|
86
|
+
seeds: [
|
|
87
|
+
{
|
|
88
|
+
kind: "const",
|
|
89
|
+
value: [
|
|
90
|
+
79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
|
|
91
|
+
128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
|
|
92
|
+
15, 16, 9, 188,
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
kind: "account",
|
|
97
|
+
path: "token_program",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
kind: "account",
|
|
101
|
+
path: "from_account.mint",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
program: {
|
|
105
|
+
kind: "const",
|
|
106
|
+
value: [
|
|
107
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
108
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
109
|
+
219, 233, 248, 89,
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "program",
|
|
116
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
86
117
|
},
|
|
87
118
|
{
|
|
88
119
|
name: "token_program",
|
|
@@ -99,6 +130,34 @@ exports.BRIDGE_IDL = {
|
|
|
99
130
|
},
|
|
100
131
|
],
|
|
101
132
|
},
|
|
133
|
+
{
|
|
134
|
+
name: "emit_crumb",
|
|
135
|
+
discriminator: [96, 96, 18, 122, 83, 60, 102, 37],
|
|
136
|
+
accounts: [
|
|
137
|
+
{
|
|
138
|
+
name: "contract_storage",
|
|
139
|
+
docs: [
|
|
140
|
+
"Need a PDA to ensure that only this contract is allowed to",
|
|
141
|
+
"call this instruction; the contract storage account is",
|
|
142
|
+
"chosen since pretty much every other ix uses it, so this",
|
|
143
|
+
"avoids having to introduce a new account.",
|
|
144
|
+
],
|
|
145
|
+
signer: true,
|
|
146
|
+
pda: {
|
|
147
|
+
seeds: [
|
|
148
|
+
{
|
|
149
|
+
kind: "const",
|
|
150
|
+
value: [
|
|
151
|
+
99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
|
|
152
|
+
97, 103, 101,
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
args: [],
|
|
160
|
+
},
|
|
102
161
|
{
|
|
103
162
|
name: "finalize_block",
|
|
104
163
|
discriminator: [63, 101, 92, 132, 135, 251, 98, 177],
|
|
@@ -141,6 +200,10 @@ exports.BRIDGE_IDL = {
|
|
|
141
200
|
],
|
|
142
201
|
},
|
|
143
202
|
},
|
|
203
|
+
{
|
|
204
|
+
name: "program",
|
|
205
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
206
|
+
},
|
|
144
207
|
{
|
|
145
208
|
name: "system_program",
|
|
146
209
|
address: "11111111111111111111111111111111",
|
|
@@ -162,6 +225,20 @@ exports.BRIDGE_IDL = {
|
|
|
162
225
|
writable: true,
|
|
163
226
|
signer: true,
|
|
164
227
|
},
|
|
228
|
+
{
|
|
229
|
+
name: "contract_storage",
|
|
230
|
+
pda: {
|
|
231
|
+
seeds: [
|
|
232
|
+
{
|
|
233
|
+
kind: "const",
|
|
234
|
+
value: [
|
|
235
|
+
99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
|
|
236
|
+
97, 103, 101,
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
},
|
|
165
242
|
{
|
|
166
243
|
name: "fact_state_storage",
|
|
167
244
|
writable: true,
|
|
@@ -181,6 +258,10 @@ exports.BRIDGE_IDL = {
|
|
|
181
258
|
],
|
|
182
259
|
},
|
|
183
260
|
},
|
|
261
|
+
{
|
|
262
|
+
name: "program",
|
|
263
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
264
|
+
},
|
|
184
265
|
{
|
|
185
266
|
name: "system_program",
|
|
186
267
|
address: "11111111111111111111111111111111",
|
|
@@ -234,6 +315,10 @@ exports.BRIDGE_IDL = {
|
|
|
234
315
|
name: "operator",
|
|
235
316
|
type: "pubkey",
|
|
236
317
|
},
|
|
318
|
+
{
|
|
319
|
+
name: "challenge_period_slots",
|
|
320
|
+
type: "u64",
|
|
321
|
+
},
|
|
237
322
|
{
|
|
238
323
|
name: "initial_app_state_commitment",
|
|
239
324
|
type: {
|
|
@@ -292,6 +377,10 @@ exports.BRIDGE_IDL = {
|
|
|
292
377
|
],
|
|
293
378
|
},
|
|
294
379
|
},
|
|
380
|
+
{
|
|
381
|
+
name: "program",
|
|
382
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
383
|
+
},
|
|
295
384
|
{
|
|
296
385
|
name: "system_program",
|
|
297
386
|
address: "11111111111111111111111111111111",
|
|
@@ -308,6 +397,62 @@ exports.BRIDGE_IDL = {
|
|
|
308
397
|
},
|
|
309
398
|
],
|
|
310
399
|
},
|
|
400
|
+
{
|
|
401
|
+
name: "set_min_deposit",
|
|
402
|
+
discriminator: [15, 182, 74, 248, 251, 148, 186, 171],
|
|
403
|
+
accounts: [
|
|
404
|
+
{
|
|
405
|
+
name: "operator",
|
|
406
|
+
signer: true,
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: "contract_storage",
|
|
410
|
+
pda: {
|
|
411
|
+
seeds: [
|
|
412
|
+
{
|
|
413
|
+
kind: "const",
|
|
414
|
+
value: [
|
|
415
|
+
99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
|
|
416
|
+
97, 103, 101,
|
|
417
|
+
],
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: "asset_config",
|
|
424
|
+
writable: true,
|
|
425
|
+
pda: {
|
|
426
|
+
seeds: [
|
|
427
|
+
{
|
|
428
|
+
kind: "const",
|
|
429
|
+
value: [
|
|
430
|
+
97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
kind: "arg",
|
|
435
|
+
path: "asset",
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
name: "program",
|
|
442
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
args: [
|
|
446
|
+
{
|
|
447
|
+
name: "asset",
|
|
448
|
+
type: "pubkey",
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: "min_deposit",
|
|
452
|
+
type: "u64",
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
},
|
|
311
456
|
{
|
|
312
457
|
name: "whitelist_asset",
|
|
313
458
|
discriminator: [113, 64, 172, 191, 33, 33, 57, 18],
|
|
@@ -332,15 +477,14 @@ exports.BRIDGE_IDL = {
|
|
|
332
477
|
},
|
|
333
478
|
},
|
|
334
479
|
{
|
|
335
|
-
name: "
|
|
480
|
+
name: "asset_config",
|
|
336
481
|
writable: true,
|
|
337
482
|
pda: {
|
|
338
483
|
seeds: [
|
|
339
484
|
{
|
|
340
485
|
kind: "const",
|
|
341
486
|
value: [
|
|
342
|
-
97, 115, 115, 101, 116, 95,
|
|
343
|
-
115, 116, 101, 100,
|
|
487
|
+
97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
|
|
344
488
|
],
|
|
345
489
|
},
|
|
346
490
|
{
|
|
@@ -350,6 +494,10 @@ exports.BRIDGE_IDL = {
|
|
|
350
494
|
],
|
|
351
495
|
},
|
|
352
496
|
},
|
|
497
|
+
{
|
|
498
|
+
name: "program",
|
|
499
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
500
|
+
},
|
|
353
501
|
{
|
|
354
502
|
name: "system_program",
|
|
355
503
|
address: "11111111111111111111111111111111",
|
|
@@ -360,6 +508,10 @@ exports.BRIDGE_IDL = {
|
|
|
360
508
|
name: "asset",
|
|
361
509
|
type: "pubkey",
|
|
362
510
|
},
|
|
511
|
+
{
|
|
512
|
+
name: "min_deposit",
|
|
513
|
+
type: "u64",
|
|
514
|
+
},
|
|
363
515
|
],
|
|
364
516
|
},
|
|
365
517
|
{
|
|
@@ -414,6 +566,34 @@ exports.BRIDGE_IDL = {
|
|
|
414
566
|
{
|
|
415
567
|
name: "from_account",
|
|
416
568
|
writable: true,
|
|
569
|
+
pda: {
|
|
570
|
+
seeds: [
|
|
571
|
+
{
|
|
572
|
+
kind: "const",
|
|
573
|
+
value: [
|
|
574
|
+
79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
|
|
575
|
+
128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
|
|
576
|
+
15, 16, 9, 188,
|
|
577
|
+
],
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
kind: "account",
|
|
581
|
+
path: "token_program",
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
kind: "account",
|
|
585
|
+
path: "to_account.mint",
|
|
586
|
+
},
|
|
587
|
+
],
|
|
588
|
+
program: {
|
|
589
|
+
kind: "const",
|
|
590
|
+
value: [
|
|
591
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
592
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
593
|
+
219, 233, 248, 89,
|
|
594
|
+
],
|
|
595
|
+
},
|
|
596
|
+
},
|
|
417
597
|
},
|
|
418
598
|
{
|
|
419
599
|
name: "to_account",
|
|
@@ -430,6 +610,24 @@ exports.BRIDGE_IDL = {
|
|
|
430
610
|
],
|
|
431
611
|
},
|
|
432
612
|
},
|
|
613
|
+
{
|
|
614
|
+
name: "contract_storage",
|
|
615
|
+
pda: {
|
|
616
|
+
seeds: [
|
|
617
|
+
{
|
|
618
|
+
kind: "const",
|
|
619
|
+
value: [
|
|
620
|
+
99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
|
|
621
|
+
97, 103, 101,
|
|
622
|
+
],
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "program",
|
|
629
|
+
address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
|
|
630
|
+
},
|
|
433
631
|
{
|
|
434
632
|
name: "token_program",
|
|
435
633
|
},
|
|
@@ -452,8 +650,8 @@ exports.BRIDGE_IDL = {
|
|
|
452
650
|
],
|
|
453
651
|
accounts: [
|
|
454
652
|
{
|
|
455
|
-
name: "
|
|
456
|
-
discriminator: [
|
|
653
|
+
name: "AssetConfig",
|
|
654
|
+
discriminator: [57, 112, 247, 166, 247, 64, 140, 23],
|
|
457
655
|
},
|
|
458
656
|
{
|
|
459
657
|
name: "Block",
|
|
@@ -478,10 +676,15 @@ exports.BRIDGE_IDL = {
|
|
|
478
676
|
],
|
|
479
677
|
types: [
|
|
480
678
|
{
|
|
481
|
-
name: "
|
|
679
|
+
name: "AssetConfig",
|
|
482
680
|
type: {
|
|
483
681
|
kind: "struct",
|
|
484
|
-
fields: [
|
|
682
|
+
fields: [
|
|
683
|
+
{
|
|
684
|
+
name: "min_deposit",
|
|
685
|
+
type: "u64",
|
|
686
|
+
},
|
|
687
|
+
],
|
|
485
688
|
},
|
|
486
689
|
},
|
|
487
690
|
{
|
|
@@ -501,6 +704,10 @@ exports.BRIDGE_IDL = {
|
|
|
501
704
|
name: "finalized",
|
|
502
705
|
type: "bool",
|
|
503
706
|
},
|
|
707
|
+
{
|
|
708
|
+
name: "slot_proposed",
|
|
709
|
+
type: "u64",
|
|
710
|
+
},
|
|
504
711
|
],
|
|
505
712
|
},
|
|
506
713
|
},
|
|
@@ -549,6 +756,10 @@ exports.BRIDGE_IDL = {
|
|
|
549
756
|
name: "operator",
|
|
550
757
|
type: "pubkey",
|
|
551
758
|
},
|
|
759
|
+
{
|
|
760
|
+
name: "challenge_period_slots",
|
|
761
|
+
type: "u64",
|
|
762
|
+
},
|
|
552
763
|
{
|
|
553
764
|
name: "last_block_id",
|
|
554
765
|
type: "u64",
|
|
@@ -689,6 +900,22 @@ exports.BRIDGE_IDL = {
|
|
|
689
900
|
name: "block_id",
|
|
690
901
|
type: "u64",
|
|
691
902
|
},
|
|
903
|
+
{
|
|
904
|
+
name: "proof",
|
|
905
|
+
type: {
|
|
906
|
+
vec: {
|
|
907
|
+
array: ["u8", 32],
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
name: "leaf_index",
|
|
913
|
+
type: "u64",
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
name: "leaves_count",
|
|
917
|
+
type: "u64",
|
|
918
|
+
},
|
|
692
919
|
],
|
|
693
920
|
},
|
|
694
921
|
},
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
import { ActionQuery, ActionResponse, ActionsResponse,
|
|
2
|
-
/**
|
|
3
|
-
* Query a specific block
|
|
4
|
-
*
|
|
5
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
6
|
-
* @param query - Block query parameters
|
|
7
|
-
* @returns Block response
|
|
8
|
-
* @throws {NordError} If the request fails
|
|
9
|
-
*/
|
|
10
|
-
export declare function queryBlock(webServerUrl: string, query: BlockQuery): Promise<BlockResponse>;
|
|
11
|
-
/**
|
|
12
|
-
* Query the last N blocks
|
|
13
|
-
*
|
|
14
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
15
|
-
* @returns Block response for the last N blocks
|
|
16
|
-
* @throws {NordError} If the request fails
|
|
17
|
-
*/
|
|
18
|
-
export declare function queryLastNBlocks(webServerUrl: string): Promise<BlockResponse>;
|
|
19
|
-
/**
|
|
20
|
-
* Query recent blocks
|
|
21
|
-
*
|
|
22
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
23
|
-
* @param last_n - Number of recent blocks to query
|
|
24
|
-
* @returns Block summary response
|
|
25
|
-
* @throws {NordError} If the request fails
|
|
26
|
-
*/
|
|
27
|
-
export declare function queryRecentBlocks(webServerUrl: string, last_n: number): Promise<BlockSummaryResponse>;
|
|
1
|
+
import { ActionQuery, ActionResponse, ActionsResponse, RollmanActionResponse, RollmanActionsResponse } from "../../types";
|
|
28
2
|
/**
|
|
29
3
|
* Query a specific action
|
|
30
4
|
*
|
|
@@ -38,29 +12,20 @@ export declare function queryAction(webServerUrl: string, query: ActionQuery): P
|
|
|
38
12
|
* Query recent actions
|
|
39
13
|
*
|
|
40
14
|
* @param webServerUrl - Base URL for the Nord web server
|
|
41
|
-
* @param
|
|
15
|
+
* @param from - Starting action index
|
|
16
|
+
* @param to - Ending action index
|
|
42
17
|
* @returns Actions response
|
|
43
18
|
* @throws {NordError} If the request fails
|
|
44
19
|
*/
|
|
45
|
-
export declare function queryRecentActions(webServerUrl: string,
|
|
46
|
-
/**
|
|
47
|
-
* Query a block from Rollman
|
|
48
|
-
*
|
|
49
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
50
|
-
* @param query - Block query parameters
|
|
51
|
-
* @returns Rollman block response
|
|
52
|
-
* @throws {NordError} If the request fails
|
|
53
|
-
*/
|
|
54
|
-
export declare function blockQueryRollman(webServerUrl: string, query: BlockQuery): Promise<RollmanBlockResponse>;
|
|
20
|
+
export declare function queryRecentActions(webServerUrl: string, from: number, to: number): Promise<ActionsResponse>;
|
|
55
21
|
/**
|
|
56
|
-
*
|
|
22
|
+
* Get the last action ID
|
|
57
23
|
*
|
|
58
24
|
* @param webServerUrl - Base URL for the Nord web server
|
|
59
|
-
* @
|
|
60
|
-
* @returns Block summary response
|
|
25
|
+
* @returns Last action ID
|
|
61
26
|
* @throws {NordError} If the request fails
|
|
62
27
|
*/
|
|
63
|
-
export declare function
|
|
28
|
+
export declare function getLastActionId(webServerUrl: string): Promise<number>;
|
|
64
29
|
/**
|
|
65
30
|
* Query an action from Rollman
|
|
66
31
|
*
|
package/dist/nord/api/queries.js
CHANGED
|
@@ -1,72 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queryBlock = queryBlock;
|
|
4
|
-
exports.queryLastNBlocks = queryLastNBlocks;
|
|
5
|
-
exports.queryRecentBlocks = queryRecentBlocks;
|
|
6
3
|
exports.queryAction = queryAction;
|
|
7
4
|
exports.queryRecentActions = queryRecentActions;
|
|
8
|
-
exports.
|
|
9
|
-
exports.blockSummaryQueryRollman = blockSummaryQueryRollman;
|
|
5
|
+
exports.getLastActionId = getLastActionId;
|
|
10
6
|
exports.actionQueryRollman = actionQueryRollman;
|
|
11
7
|
exports.actionsQueryRollman = actionsQueryRollman;
|
|
12
8
|
const utils_1 = require("../../utils");
|
|
13
9
|
const NordError_1 = require("../utils/NordError");
|
|
14
|
-
/**
|
|
15
|
-
* Query a specific block
|
|
16
|
-
*
|
|
17
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
18
|
-
* @param query - Block query parameters
|
|
19
|
-
* @returns Block response
|
|
20
|
-
* @throws {NordError} If the request fails
|
|
21
|
-
*/
|
|
22
|
-
async function queryBlock(webServerUrl, query) {
|
|
23
|
-
try {
|
|
24
|
-
const params = new URLSearchParams();
|
|
25
|
-
if (query.block_number !== undefined) {
|
|
26
|
-
params.append("block_height", query.block_number.toString());
|
|
27
|
-
}
|
|
28
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/block?${params.toString()}`);
|
|
29
|
-
return await response.json();
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new NordError_1.NordError("Failed to query block", { cause: error });
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Query the last N blocks
|
|
37
|
-
*
|
|
38
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
39
|
-
* @returns Block response for the last N blocks
|
|
40
|
-
* @throws {NordError} If the request fails
|
|
41
|
-
*/
|
|
42
|
-
async function queryLastNBlocks(webServerUrl) {
|
|
43
|
-
try {
|
|
44
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/blocks`);
|
|
45
|
-
return await response.json();
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
throw new NordError_1.NordError("Failed to query last N blocks", { cause: error });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Query recent blocks
|
|
53
|
-
*
|
|
54
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
55
|
-
* @param last_n - Number of recent blocks to query
|
|
56
|
-
* @returns Block summary response
|
|
57
|
-
* @throws {NordError} If the request fails
|
|
58
|
-
*/
|
|
59
|
-
async function queryRecentBlocks(webServerUrl, last_n) {
|
|
60
|
-
try {
|
|
61
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/blocks_summary?last_n=${last_n}`);
|
|
62
|
-
return await response.json();
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
throw new NordError_1.NordError(`Failed to query recent blocks (last ${last_n})`, {
|
|
66
|
-
cause: error,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
10
|
/**
|
|
71
11
|
* Query a specific action
|
|
72
12
|
*
|
|
@@ -92,57 +32,39 @@ async function queryAction(webServerUrl, query) {
|
|
|
92
32
|
* Query recent actions
|
|
93
33
|
*
|
|
94
34
|
* @param webServerUrl - Base URL for the Nord web server
|
|
95
|
-
* @param
|
|
35
|
+
* @param from - Starting action index
|
|
36
|
+
* @param to - Ending action index
|
|
96
37
|
* @returns Actions response
|
|
97
38
|
* @throws {NordError} If the request fails
|
|
98
39
|
*/
|
|
99
|
-
async function queryRecentActions(webServerUrl,
|
|
40
|
+
async function queryRecentActions(webServerUrl, from, to) {
|
|
100
41
|
try {
|
|
101
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?
|
|
42
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?from=${from}&to=${to}`);
|
|
102
43
|
return await response.json();
|
|
103
44
|
}
|
|
104
45
|
catch (error) {
|
|
105
|
-
throw new NordError_1.NordError(`Failed to query recent actions (
|
|
46
|
+
throw new NordError_1.NordError(`Failed to query recent actions (from ${from} to ${to})`, {
|
|
106
47
|
cause: error,
|
|
107
48
|
});
|
|
108
49
|
}
|
|
109
50
|
}
|
|
110
51
|
/**
|
|
111
|
-
*
|
|
52
|
+
* Get the last action ID
|
|
112
53
|
*
|
|
113
54
|
* @param webServerUrl - Base URL for the Nord web server
|
|
114
|
-
* @
|
|
115
|
-
* @returns Rollman block response
|
|
55
|
+
* @returns Last action ID
|
|
116
56
|
* @throws {NordError} If the request fails
|
|
117
57
|
*/
|
|
118
|
-
async function
|
|
58
|
+
async function getLastActionId(webServerUrl) {
|
|
119
59
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/block?${params.toString()}`);
|
|
125
|
-
return await response.json();
|
|
60
|
+
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/last_actionid`);
|
|
61
|
+
const data = await response.json();
|
|
62
|
+
return data.last_actionid;
|
|
126
63
|
}
|
|
127
64
|
catch (error) {
|
|
128
|
-
throw new NordError_1.NordError("Failed to
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Query block summaries from Rollman
|
|
133
|
-
*
|
|
134
|
-
* @param webServerUrl - Base URL for the Nord web server
|
|
135
|
-
* @param last_n - Number of recent blocks to query
|
|
136
|
-
* @returns Block summary response
|
|
137
|
-
* @throws {NordError} If the request fails
|
|
138
|
-
*/
|
|
139
|
-
async function blockSummaryQueryRollman(webServerUrl, last_n) {
|
|
140
|
-
try {
|
|
141
|
-
const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/blocks_summary?last_n=${last_n}`);
|
|
142
|
-
return await response.json();
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
throw new NordError_1.NordError(`Failed to query Rollman block summaries (last ${last_n})`, { cause: error });
|
|
65
|
+
throw new NordError_1.NordError("Failed to get last action ID", {
|
|
66
|
+
cause: error,
|
|
67
|
+
});
|
|
146
68
|
}
|
|
147
69
|
}
|
|
148
70
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics,
|
|
2
|
+
import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
|
|
3
3
|
import { NordWebSocketClient } from "../../websocket/index";
|
|
4
4
|
import { OrderbookSubscription, TradeSubscription } from "../models/Subscriber";
|
|
5
5
|
/**
|
|
@@ -116,29 +116,6 @@ export declare class Nord {
|
|
|
116
116
|
* @throws {NordError} If the request fails
|
|
117
117
|
*/
|
|
118
118
|
marketsStats(): Promise<MarketsStatsResponse>;
|
|
119
|
-
/**
|
|
120
|
-
* Query a specific block
|
|
121
|
-
*
|
|
122
|
-
* @param query - Block query parameters
|
|
123
|
-
* @returns Block response
|
|
124
|
-
* @throws {NordError} If the request fails
|
|
125
|
-
*/
|
|
126
|
-
queryBlock(query: BlockQuery): Promise<BlockResponse>;
|
|
127
|
-
/**
|
|
128
|
-
* Query the last N blocks
|
|
129
|
-
*
|
|
130
|
-
* @returns Block response for the last N blocks
|
|
131
|
-
* @throws {NordError} If the request fails
|
|
132
|
-
*/
|
|
133
|
-
queryLastNBlocks(): Promise<BlockResponse>;
|
|
134
|
-
/**
|
|
135
|
-
* Query recent blocks
|
|
136
|
-
*
|
|
137
|
-
* @param last_n - Number of recent blocks to query
|
|
138
|
-
* @returns Block summary response
|
|
139
|
-
* @throws {NordError} If the request fails
|
|
140
|
-
*/
|
|
141
|
-
queryRecentBlocks(last_n: number): Promise<BlockSummaryResponse>;
|
|
142
119
|
/**
|
|
143
120
|
* Query a specific action
|
|
144
121
|
*
|
|
@@ -150,11 +127,19 @@ export declare class Nord {
|
|
|
150
127
|
/**
|
|
151
128
|
* Query recent actions
|
|
152
129
|
*
|
|
153
|
-
* @param
|
|
130
|
+
* @param from - Starting action index
|
|
131
|
+
* @param to - Ending action index
|
|
154
132
|
* @returns Actions response
|
|
155
133
|
* @throws {NordError} If the request fails
|
|
156
134
|
*/
|
|
157
|
-
queryRecentActions(
|
|
135
|
+
queryRecentActions(from: number, to: number): Promise<ActionsResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Get the last action ID
|
|
138
|
+
*
|
|
139
|
+
* @returns Last action ID
|
|
140
|
+
* @throws {NordError} If the request fails
|
|
141
|
+
*/
|
|
142
|
+
getLastActionId(): Promise<number>;
|
|
158
143
|
/**
|
|
159
144
|
* Fetch aggregate metrics from the Nord API
|
|
160
145
|
*
|
|
@@ -195,22 +180,6 @@ export declare class Nord {
|
|
|
195
180
|
* @throws {NordError} If the request fails
|
|
196
181
|
*/
|
|
197
182
|
getTotalTransactions(): Promise<number>;
|
|
198
|
-
/**
|
|
199
|
-
* Query a block from Rollman
|
|
200
|
-
*
|
|
201
|
-
* @param query - Block query parameters
|
|
202
|
-
* @returns Rollman block response
|
|
203
|
-
* @throws {NordError} If the request fails
|
|
204
|
-
*/
|
|
205
|
-
blockQueryRollman(query: BlockQuery): Promise<RollmanBlockResponse>;
|
|
206
|
-
/**
|
|
207
|
-
* Query block summaries from Rollman
|
|
208
|
-
*
|
|
209
|
-
* @param last_n - Number of recent blocks to query
|
|
210
|
-
* @returns Block summary response
|
|
211
|
-
* @throws {NordError} If the request fails
|
|
212
|
-
*/
|
|
213
|
-
blockSummaryQueryRollman(last_n: number): Promise<BlockSummaryResponse>;
|
|
214
183
|
/**
|
|
215
184
|
* Query an action from Rollman
|
|
216
185
|
*
|