@n1xyz/nord-ts 0.0.7 → 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.
Files changed (151) hide show
  1. package/dist/gen/common.js +1 -1
  2. package/dist/gen/nord.js +1 -1
  3. package/dist/idl/bridge.js +237 -10
  4. package/dist/nord/api/metrics.js +101 -7
  5. package/dist/nord/api/queries.d.ts +7 -42
  6. package/dist/nord/api/queries.js +15 -93
  7. package/dist/nord/client/Nord.d.ts +11 -42
  8. package/dist/nord/client/Nord.js +13 -52
  9. package/docs/classes/Nord.html +41 -41
  10. package/docs/classes/NordError.html +8 -8
  11. package/docs/classes/NordUser.html +37 -37
  12. package/docs/classes/NordWebSocketClient.html +34 -34
  13. package/docs/classes/SolanaBridgeClient.html +22 -22
  14. package/docs/classes/Subscriber.html +3 -3
  15. package/docs/enums/FillMode.html +2 -2
  16. package/docs/enums/KeyType.html +2 -2
  17. package/docs/enums/MetricPeriod.html +2 -2
  18. package/docs/enums/PdaSeedType.html +2 -2
  19. package/docs/enums/PeakTpsPeriodUnit.html +2 -2
  20. package/docs/enums/Side.html +2 -2
  21. package/docs/enums/WebSocketMessageType.html +2 -2
  22. package/docs/functions/actionQueryRollman.html +1 -1
  23. package/docs/functions/actionsQueryRollman.html +1 -1
  24. package/docs/functions/aggregateMetrics-1.html +1 -1
  25. package/docs/functions/assert.html +1 -1
  26. package/docs/functions/bigIntToProtoU128.html +1 -1
  27. package/docs/functions/blockQueryRollman.html +1 -1
  28. package/docs/functions/blockSummaryQueryRollman.html +1 -1
  29. package/docs/functions/bridgeToBN.html +1 -1
  30. package/docs/functions/bufferToHex.html +1 -1
  31. package/docs/functions/cancelOrder.html +1 -1
  32. package/docs/functions/checkPubKeyLength.html +1 -1
  33. package/docs/functions/checkedFetch.html +1 -1
  34. package/docs/functions/createSession.html +1 -1
  35. package/docs/functions/decodeLengthDelimited.html +1 -1
  36. package/docs/functions/encodeLengthDelimited.html +1 -1
  37. package/docs/functions/fillModeToProtoFillMode.html +1 -1
  38. package/docs/functions/findMarket.html +1 -1
  39. package/docs/functions/findPda.html +1 -1
  40. package/docs/functions/findToken.html +1 -1
  41. package/docs/functions/fromBN.html +1 -1
  42. package/docs/functions/getAccount.html +1 -1
  43. package/docs/functions/getActionNonce.html +1 -1
  44. package/docs/functions/getCurrentTps.html +1 -1
  45. package/docs/functions/getInfo.html +1 -1
  46. package/docs/functions/getMedianLatency.html +1 -1
  47. package/docs/functions/getOrderbook.html +1 -1
  48. package/docs/functions/getPeakTps.html +1 -1
  49. package/docs/functions/getTimestamp.html +1 -1
  50. package/docs/functions/getTotalTransactions.html +1 -1
  51. package/docs/functions/getTrades.html +1 -1
  52. package/docs/functions/getUserAccountIds.html +1 -1
  53. package/docs/functions/hexToBuffer.html +1 -1
  54. package/docs/functions/initWebSocketClient.html +1 -1
  55. package/docs/functions/keypairFromPrivateKey.html +1 -1
  56. package/docs/functions/makeSigningFunction.html +1 -1
  57. package/docs/functions/makeWalletSignFn.html +1 -1
  58. package/docs/functions/marketsStats.html +1 -1
  59. package/docs/functions/optExpect.html +1 -1
  60. package/docs/functions/optMap.html +1 -1
  61. package/docs/functions/optUnwrap.html +1 -1
  62. package/docs/functions/panic.html +1 -1
  63. package/docs/functions/placeOrder.html +1 -1
  64. package/docs/functions/queryAction.html +1 -1
  65. package/docs/functions/queryBlock.html +1 -1
  66. package/docs/functions/queryLastNBlocks.html +1 -1
  67. package/docs/functions/queryPrometheus.html +1 -1
  68. package/docs/functions/queryRecentActions.html +1 -1
  69. package/docs/functions/queryRecentBlocks.html +1 -1
  70. package/docs/functions/revokeSession.html +1 -1
  71. package/docs/functions/shortenPublicKey.html +1 -1
  72. package/docs/functions/signAction.html +1 -1
  73. package/docs/functions/toBN.html +1 -1
  74. package/docs/functions/toScaledU128.html +1 -1
  75. package/docs/functions/toScaledU64.html +1 -1
  76. package/docs/functions/transfer.html +1 -1
  77. package/docs/functions/withdraw.html +1 -1
  78. package/docs/interfaces/Account.html +2 -2
  79. package/docs/interfaces/ActionInfo.html +2 -2
  80. package/docs/interfaces/ActionNonceResponse.html +2 -2
  81. package/docs/interfaces/ActionQuery.html +2 -2
  82. package/docs/interfaces/ActionResponse.html +2 -2
  83. package/docs/interfaces/ActionsExtendedInfo.html +2 -2
  84. package/docs/interfaces/ActionsQuery.html +2 -2
  85. package/docs/interfaces/ActionsResponse.html +2 -2
  86. package/docs/interfaces/AggregateMetrics.html +2 -2
  87. package/docs/interfaces/BlockFacts.html +5 -5
  88. package/docs/interfaces/BlockQuery.html +2 -2
  89. package/docs/interfaces/BlockResponse.html +2 -2
  90. package/docs/interfaces/BlockSummary.html +2 -2
  91. package/docs/interfaces/BlockSummaryResponse.html +2 -2
  92. package/docs/interfaces/DeltaEvent.html +2 -2
  93. package/docs/interfaces/DepositSplParams.html +5 -5
  94. package/docs/interfaces/Info.html +2 -2
  95. package/docs/interfaces/Market.html +2 -2
  96. package/docs/interfaces/MarketStats.html +2 -2
  97. package/docs/interfaces/MarketsStatsResponse.html +2 -2
  98. package/docs/interfaces/NordConfig.html +7 -7
  99. package/docs/interfaces/NordWebSocketClientEvents.html +2 -2
  100. package/docs/interfaces/NordWebSocketEvents.html +2 -2
  101. package/docs/interfaces/Order.html +2 -2
  102. package/docs/interfaces/OrderInfo.html +2 -2
  103. package/docs/interfaces/OrderbookEntry.html +2 -2
  104. package/docs/interfaces/OrderbookQuery.html +2 -2
  105. package/docs/interfaces/OrderbookResponse.html +2 -2
  106. package/docs/interfaces/OrderbookSubscription.html +18 -18
  107. package/docs/interfaces/PerpMarketStats.html +2 -2
  108. package/docs/interfaces/RollmanActionExtendedInfo.html +2 -2
  109. package/docs/interfaces/RollmanActionInfo.html +2 -2
  110. package/docs/interfaces/RollmanActionResponse.html +2 -2
  111. package/docs/interfaces/RollmanActionsResponse.html +2 -2
  112. package/docs/interfaces/RollmanBlockResponse.html +2 -2
  113. package/docs/interfaces/SPLTokenInfo.html +5 -5
  114. package/docs/interfaces/SolanaBridgeConfig.html +5 -5
  115. package/docs/interfaces/StateFacts.html +5 -5
  116. package/docs/interfaces/SubscriberConfig.html +2 -2
  117. package/docs/interfaces/TimestampResponse.html +2 -2
  118. package/docs/interfaces/Token.html +2 -2
  119. package/docs/interfaces/TokenInfo.html +2 -2
  120. package/docs/interfaces/Trade.html +2 -2
  121. package/docs/interfaces/TradeSubscription.html +18 -18
  122. package/docs/interfaces/Trades.html +2 -2
  123. package/docs/interfaces/TradesQuery.html +2 -2
  124. package/docs/interfaces/TradesResponse.html +2 -2
  125. package/docs/interfaces/TransferParams.html +4 -4
  126. package/docs/interfaces/UserAccountIdsQuery.html +2 -2
  127. package/docs/interfaces/UserAccountIdsResponse.html +2 -2
  128. package/docs/interfaces/WebSocketDeltaUpdate.html +2 -2
  129. package/docs/interfaces/WebSocketSubscription.html +2 -2
  130. package/docs/interfaces/WebSocketTradeUpdate.html +2 -2
  131. package/docs/interfaces/WebSocketUserUpdate.html +2 -2
  132. package/docs/interfaces/WithdrawalClaim.html +7 -7
  133. package/docs/interfaces/WithdrawalParams.html +4 -4
  134. package/docs/types/BigIntValue.html +1 -1
  135. package/docs/types/WebSocketMessage.html +1 -1
  136. package/docs/variables/DEBUG_KEYS.html +1 -1
  137. package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
  138. package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
  139. package/docs/variables/DEV_URL.html +1 -1
  140. package/docs/variables/MAX_BUFFER_LEN.html +1 -1
  141. package/docs/variables/SESSION_TTL.html +1 -1
  142. package/docs/variables/WEBSERVER_DEV_URL.html +1 -1
  143. package/docs/variables/ZERO_DECIMAL.html +1 -1
  144. package/docs/variables/_private.html +1 -1
  145. package/package.json +1 -1
  146. package/src/gen/common.ts +1 -1
  147. package/src/gen/nord.ts +1 -1
  148. package/src/idl/bridge.ts +238 -11
  149. package/src/nord/api/queries.ts +16 -113
  150. package/src/nord/client/Nord.ts +15 -64
  151. package/test.ts +107 -0
package/src/idl/bridge.ts CHANGED
@@ -43,14 +43,13 @@ export const BRIDGE_IDL: Idl = {
43
43
  },
44
44
  },
45
45
  {
46
- name: "asset_whitelisted",
46
+ name: "asset_config",
47
47
  pda: {
48
48
  seeds: [
49
49
  {
50
50
  kind: "const",
51
51
  value: [
52
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
53
- 115, 116, 101, 100,
52
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
54
53
  ],
55
54
  },
56
55
  {
@@ -82,6 +81,38 @@ export const BRIDGE_IDL: Idl = {
82
81
  {
83
82
  name: "to_account",
84
83
  writable: true,
84
+ pda: {
85
+ seeds: [
86
+ {
87
+ kind: "const",
88
+ value: [
89
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
90
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
91
+ 15, 16, 9, 188,
92
+ ],
93
+ },
94
+ {
95
+ kind: "account",
96
+ path: "token_program",
97
+ },
98
+ {
99
+ kind: "account",
100
+ path: "from_account.mint",
101
+ },
102
+ ],
103
+ program: {
104
+ kind: "const",
105
+ value: [
106
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
107
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
108
+ 219, 233, 248, 89,
109
+ ],
110
+ },
111
+ },
112
+ },
113
+ {
114
+ name: "program",
115
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
85
116
  },
86
117
  {
87
118
  name: "token_program",
@@ -98,6 +129,34 @@ export const BRIDGE_IDL: Idl = {
98
129
  },
99
130
  ],
100
131
  },
132
+ {
133
+ name: "emit_crumb",
134
+ discriminator: [96, 96, 18, 122, 83, 60, 102, 37],
135
+ accounts: [
136
+ {
137
+ name: "contract_storage",
138
+ docs: [
139
+ "Need a PDA to ensure that only this contract is allowed to",
140
+ "call this instruction; the contract storage account is",
141
+ "chosen since pretty much every other ix uses it, so this",
142
+ "avoids having to introduce a new account.",
143
+ ],
144
+ signer: true,
145
+ pda: {
146
+ seeds: [
147
+ {
148
+ kind: "const",
149
+ value: [
150
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
151
+ 97, 103, 101,
152
+ ],
153
+ },
154
+ ],
155
+ },
156
+ },
157
+ ],
158
+ args: [],
159
+ },
101
160
  {
102
161
  name: "finalize_block",
103
162
  discriminator: [63, 101, 92, 132, 135, 251, 98, 177],
@@ -140,6 +199,10 @@ export const BRIDGE_IDL: Idl = {
140
199
  ],
141
200
  },
142
201
  },
202
+ {
203
+ name: "program",
204
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
205
+ },
143
206
  {
144
207
  name: "system_program",
145
208
  address: "11111111111111111111111111111111",
@@ -161,6 +224,20 @@ export const BRIDGE_IDL: Idl = {
161
224
  writable: true,
162
225
  signer: true,
163
226
  },
227
+ {
228
+ name: "contract_storage",
229
+ pda: {
230
+ seeds: [
231
+ {
232
+ kind: "const",
233
+ value: [
234
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
235
+ 97, 103, 101,
236
+ ],
237
+ },
238
+ ],
239
+ },
240
+ },
164
241
  {
165
242
  name: "fact_state_storage",
166
243
  writable: true,
@@ -180,6 +257,10 @@ export const BRIDGE_IDL: Idl = {
180
257
  ],
181
258
  },
182
259
  },
260
+ {
261
+ name: "program",
262
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
263
+ },
183
264
  {
184
265
  name: "system_program",
185
266
  address: "11111111111111111111111111111111",
@@ -233,6 +314,10 @@ export const BRIDGE_IDL: Idl = {
233
314
  name: "operator",
234
315
  type: "pubkey",
235
316
  },
317
+ {
318
+ name: "challenge_period_slots",
319
+ type: "u64",
320
+ },
236
321
  {
237
322
  name: "initial_app_state_commitment",
238
323
  type: {
@@ -291,6 +376,10 @@ export const BRIDGE_IDL: Idl = {
291
376
  ],
292
377
  },
293
378
  },
379
+ {
380
+ name: "program",
381
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
382
+ },
294
383
  {
295
384
  name: "system_program",
296
385
  address: "11111111111111111111111111111111",
@@ -307,6 +396,62 @@ export const BRIDGE_IDL: Idl = {
307
396
  },
308
397
  ],
309
398
  },
399
+ {
400
+ name: "set_min_deposit",
401
+ discriminator: [15, 182, 74, 248, 251, 148, 186, 171],
402
+ accounts: [
403
+ {
404
+ name: "operator",
405
+ signer: true,
406
+ },
407
+ {
408
+ name: "contract_storage",
409
+ pda: {
410
+ seeds: [
411
+ {
412
+ kind: "const",
413
+ value: [
414
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
415
+ 97, 103, 101,
416
+ ],
417
+ },
418
+ ],
419
+ },
420
+ },
421
+ {
422
+ name: "asset_config",
423
+ writable: true,
424
+ pda: {
425
+ seeds: [
426
+ {
427
+ kind: "const",
428
+ value: [
429
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
430
+ ],
431
+ },
432
+ {
433
+ kind: "arg",
434
+ path: "asset",
435
+ },
436
+ ],
437
+ },
438
+ },
439
+ {
440
+ name: "program",
441
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
442
+ },
443
+ ],
444
+ args: [
445
+ {
446
+ name: "asset",
447
+ type: "pubkey",
448
+ },
449
+ {
450
+ name: "min_deposit",
451
+ type: "u64",
452
+ },
453
+ ],
454
+ },
310
455
  {
311
456
  name: "whitelist_asset",
312
457
  discriminator: [113, 64, 172, 191, 33, 33, 57, 18],
@@ -331,15 +476,14 @@ export const BRIDGE_IDL: Idl = {
331
476
  },
332
477
  },
333
478
  {
334
- name: "asset_whitelisted",
479
+ name: "asset_config",
335
480
  writable: true,
336
481
  pda: {
337
482
  seeds: [
338
483
  {
339
484
  kind: "const",
340
485
  value: [
341
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
342
- 115, 116, 101, 100,
486
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
343
487
  ],
344
488
  },
345
489
  {
@@ -349,6 +493,10 @@ export const BRIDGE_IDL: Idl = {
349
493
  ],
350
494
  },
351
495
  },
496
+ {
497
+ name: "program",
498
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
499
+ },
352
500
  {
353
501
  name: "system_program",
354
502
  address: "11111111111111111111111111111111",
@@ -359,6 +507,10 @@ export const BRIDGE_IDL: Idl = {
359
507
  name: "asset",
360
508
  type: "pubkey",
361
509
  },
510
+ {
511
+ name: "min_deposit",
512
+ type: "u64",
513
+ },
362
514
  ],
363
515
  },
364
516
  {
@@ -413,6 +565,34 @@ export const BRIDGE_IDL: Idl = {
413
565
  {
414
566
  name: "from_account",
415
567
  writable: true,
568
+ pda: {
569
+ seeds: [
570
+ {
571
+ kind: "const",
572
+ value: [
573
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
574
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
575
+ 15, 16, 9, 188,
576
+ ],
577
+ },
578
+ {
579
+ kind: "account",
580
+ path: "token_program",
581
+ },
582
+ {
583
+ kind: "account",
584
+ path: "to_account.mint",
585
+ },
586
+ ],
587
+ program: {
588
+ kind: "const",
589
+ value: [
590
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
591
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
592
+ 219, 233, 248, 89,
593
+ ],
594
+ },
595
+ },
416
596
  },
417
597
  {
418
598
  name: "to_account",
@@ -429,6 +609,24 @@ export const BRIDGE_IDL: Idl = {
429
609
  ],
430
610
  },
431
611
  },
612
+ {
613
+ name: "contract_storage",
614
+ pda: {
615
+ seeds: [
616
+ {
617
+ kind: "const",
618
+ value: [
619
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
620
+ 97, 103, 101,
621
+ ],
622
+ },
623
+ ],
624
+ },
625
+ },
626
+ {
627
+ name: "program",
628
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
629
+ },
432
630
  {
433
631
  name: "token_program",
434
632
  },
@@ -451,8 +649,8 @@ export const BRIDGE_IDL: Idl = {
451
649
  ],
452
650
  accounts: [
453
651
  {
454
- name: "AssetWhitelisted",
455
- discriminator: [170, 42, 144, 120, 189, 54, 255, 166],
652
+ name: "AssetConfig",
653
+ discriminator: [57, 112, 247, 166, 247, 64, 140, 23],
456
654
  },
457
655
  {
458
656
  name: "Block",
@@ -477,10 +675,15 @@ export const BRIDGE_IDL: Idl = {
477
675
  ],
478
676
  types: [
479
677
  {
480
- name: "AssetWhitelisted",
678
+ name: "AssetConfig",
481
679
  type: {
482
680
  kind: "struct",
483
- fields: [],
681
+ fields: [
682
+ {
683
+ name: "min_deposit",
684
+ type: "u64",
685
+ },
686
+ ],
484
687
  },
485
688
  },
486
689
  {
@@ -500,6 +703,10 @@ export const BRIDGE_IDL: Idl = {
500
703
  name: "finalized",
501
704
  type: "bool",
502
705
  },
706
+ {
707
+ name: "slot_proposed",
708
+ type: "u64",
709
+ },
503
710
  ],
504
711
  },
505
712
  },
@@ -548,6 +755,10 @@ export const BRIDGE_IDL: Idl = {
548
755
  name: "operator",
549
756
  type: "pubkey",
550
757
  },
758
+ {
759
+ name: "challenge_period_slots",
760
+ type: "u64",
761
+ },
551
762
  {
552
763
  name: "last_block_id",
553
764
  type: "u64",
@@ -688,6 +899,22 @@ export const BRIDGE_IDL: Idl = {
688
899
  name: "block_id",
689
900
  type: "u64",
690
901
  },
902
+ {
903
+ name: "proof",
904
+ type: {
905
+ vec: {
906
+ array: ["u8", 32],
907
+ },
908
+ },
909
+ },
910
+ {
911
+ name: "leaf_index",
912
+ type: "u64",
913
+ },
914
+ {
915
+ name: "leaves_count",
916
+ type: "u64",
917
+ },
691
918
  ],
692
919
  },
693
920
  },
@@ -699,4 +926,4 @@ export const BRIDGE_IDL: Idl = {
699
926
  },
700
927
  },
701
928
  ],
702
- };
929
+ };
@@ -12,74 +12,6 @@ import {
12
12
  import { checkedFetch } from "../../utils";
13
13
  import { NordError } from "../utils/NordError";
14
14
 
15
- /**
16
- * Query a specific block
17
- *
18
- * @param webServerUrl - Base URL for the Nord web server
19
- * @param query - Block query parameters
20
- * @returns Block response
21
- * @throws {NordError} If the request fails
22
- */
23
- export async function queryBlock(
24
- webServerUrl: string,
25
- query: BlockQuery,
26
- ): Promise<BlockResponse> {
27
- try {
28
- const params = new URLSearchParams();
29
- if (query.block_number !== undefined) {
30
- params.append("block_height", query.block_number.toString());
31
- }
32
-
33
- const response = await checkedFetch(
34
- `${webServerUrl}/block?${params.toString()}`,
35
- );
36
- return await response.json();
37
- } catch (error) {
38
- throw new NordError("Failed to query block", { cause: error });
39
- }
40
- }
41
-
42
- /**
43
- * Query the last N blocks
44
- *
45
- * @param webServerUrl - Base URL for the Nord web server
46
- * @returns Block response for the last N blocks
47
- * @throws {NordError} If the request fails
48
- */
49
- export async function queryLastNBlocks(
50
- webServerUrl: string,
51
- ): Promise<BlockResponse> {
52
- try {
53
- const response = await checkedFetch(`${webServerUrl}/blocks`);
54
- return await response.json();
55
- } catch (error) {
56
- throw new NordError("Failed to query last N blocks", { cause: error });
57
- }
58
- }
59
-
60
- /**
61
- * Query recent blocks
62
- *
63
- * @param webServerUrl - Base URL for the Nord web server
64
- * @param last_n - Number of recent blocks to query
65
- * @returns Block summary response
66
- * @throws {NordError} If the request fails
67
- */
68
- export async function queryRecentBlocks(
69
- webServerUrl: string,
70
- last_n: number,
71
- ): Promise<BlockSummaryResponse> {
72
- try {
73
- const response = await checkedFetch(
74
- `${webServerUrl}/blocks_summary?last_n=${last_n}`,
75
- );
76
- return await response.json();
77
- } catch (error) {
78
- throw new NordError(`Failed to query recent blocks (last ${last_n})`, {
79
- cause: error,
80
- });
81
- }
82
- }
83
15
 
84
16
  /**
85
17
  * Query a specific action
@@ -112,75 +44,46 @@ export async function queryAction(
112
44
  * Query recent actions
113
45
  *
114
46
  * @param webServerUrl - Base URL for the Nord web server
115
- * @param last_n - Number of recent actions to query
47
+ * @param from - Starting action index
48
+ * @param to - Ending action index
116
49
  * @returns Actions response
117
50
  * @throws {NordError} If the request fails
118
51
  */
119
52
  export async function queryRecentActions(
120
53
  webServerUrl: string,
121
- last_n: number,
54
+ from: number,
55
+ to: number,
122
56
  ): Promise<ActionsResponse> {
123
57
  try {
124
58
  const response = await checkedFetch(
125
- `${webServerUrl}/actions?last_n=${last_n}`,
59
+ `${webServerUrl}/actions?from=${from}&to=${to}`,
126
60
  );
127
61
  return await response.json();
128
62
  } catch (error) {
129
- throw new NordError(`Failed to query recent actions (last ${last_n})`, {
63
+ throw new NordError(`Failed to query recent actions (from ${from} to ${to})`, {
130
64
  cause: error,
131
65
  });
132
66
  }
133
67
  }
134
68
 
135
69
  /**
136
- * Query a block from Rollman
70
+ * Get the last action ID
137
71
  *
138
72
  * @param webServerUrl - Base URL for the Nord web server
139
- * @param query - Block query parameters
140
- * @returns Rollman block response
73
+ * @returns Last action ID
141
74
  * @throws {NordError} If the request fails
142
75
  */
143
- export async function blockQueryRollman(
76
+ export async function getLastActionId(
144
77
  webServerUrl: string,
145
- query: BlockQuery,
146
- ): Promise<RollmanBlockResponse> {
78
+ ): Promise<number> {
147
79
  try {
148
- const params = new URLSearchParams();
149
- if (query.block_number !== undefined) {
150
- params.append("block_height", query.block_number.toString());
151
- }
152
-
153
- const response = await checkedFetch(
154
- `${webServerUrl}/rollman/block?${params.toString()}`,
155
- );
156
- return await response.json();
80
+ const response = await checkedFetch(`${webServerUrl}/last_actionid`);
81
+ const data = await response.json();
82
+ return data.last_actionid;
157
83
  } catch (error) {
158
- throw new NordError("Failed to query Rollman block", { cause: error });
159
- }
160
- }
161
-
162
- /**
163
- * Query block summaries from Rollman
164
- *
165
- * @param webServerUrl - Base URL for the Nord web server
166
- * @param last_n - Number of recent blocks to query
167
- * @returns Block summary response
168
- * @throws {NordError} If the request fails
169
- */
170
- export async function blockSummaryQueryRollman(
171
- webServerUrl: string,
172
- last_n: number,
173
- ): Promise<BlockSummaryResponse> {
174
- try {
175
- const response = await checkedFetch(
176
- `${webServerUrl}/rollman/blocks_summary?last_n=${last_n}`,
177
- );
178
- return await response.json();
179
- } catch (error) {
180
- throw new NordError(
181
- `Failed to query Rollman block summaries (last ${last_n})`,
182
- { cause: error },
183
- );
84
+ throw new NordError("Failed to get last action ID", {
85
+ cause: error,
86
+ });
184
87
  }
185
88
  }
186
89
 
@@ -5,9 +5,6 @@ import {
5
5
  ActionResponse,
6
6
  ActionsResponse,
7
7
  AggregateMetrics,
8
- BlockQuery,
9
- BlockResponse,
10
- BlockSummaryResponse,
11
8
  Info,
12
9
  Market,
13
10
  MarketsStatsResponse,
@@ -17,12 +14,11 @@ import {
17
14
  PeakTpsPeriodUnit,
18
15
  RollmanActionResponse,
19
16
  RollmanActionsResponse,
20
- RollmanBlockResponse,
21
17
  Token,
22
18
  TradesQuery,
23
19
  TradesResponse,
24
20
  UserAccountIdsQuery,
25
- UserAccountIdsResponse,
21
+ UserAccountIdsResponse
26
22
  } from "../../types";
27
23
  import { NordWebSocketClient } from "../../websocket/index";
28
24
  import * as core from "../api/core";
@@ -240,38 +236,6 @@ export class Nord {
240
236
  return market.marketsStats(this.webServerUrl);
241
237
  }
242
238
 
243
- /**
244
- * Query a specific block
245
- *
246
- * @param query - Block query parameters
247
- * @returns Block response
248
- * @throws {NordError} If the request fails
249
- */
250
- async queryBlock(query: BlockQuery): Promise<BlockResponse> {
251
- return queries.queryBlock(this.webServerUrl, query);
252
- }
253
-
254
- /**
255
- * Query the last N blocks
256
- *
257
- * @returns Block response for the last N blocks
258
- * @throws {NordError} If the request fails
259
- */
260
- async queryLastNBlocks(): Promise<BlockResponse> {
261
- return queries.queryLastNBlocks(this.webServerUrl);
262
- }
263
-
264
- /**
265
- * Query recent blocks
266
- *
267
- * @param last_n - Number of recent blocks to query
268
- * @returns Block summary response
269
- * @throws {NordError} If the request fails
270
- */
271
- async queryRecentBlocks(last_n: number): Promise<BlockSummaryResponse> {
272
- return queries.queryRecentBlocks(this.webServerUrl, last_n);
273
- }
274
-
275
239
  /**
276
240
  * Query a specific action
277
241
  *
@@ -286,14 +250,25 @@ export class Nord {
286
250
  /**
287
251
  * Query recent actions
288
252
  *
289
- * @param last_n - Number of recent actions to query
253
+ * @param from - Starting action index
254
+ * @param to - Ending action index
290
255
  * @returns Actions response
291
256
  * @throws {NordError} If the request fails
292
257
  */
293
- async queryRecentActions(last_n: number): Promise<ActionsResponse> {
294
- return queries.queryRecentActions(this.webServerUrl, last_n);
258
+ async queryRecentActions(from: number, to: number): Promise<ActionsResponse> {
259
+ return queries.queryRecentActions(this.webServerUrl, from, to);
295
260
  }
296
261
 
262
+ /**
263
+ * Get the last action ID
264
+ *
265
+ * @returns Last action ID
266
+ * @throws {NordError} If the request fails
267
+ */
268
+ async getLastActionId(): Promise<number> {
269
+ return queries.getLastActionId(this.webServerUrl);
270
+ }
271
+
297
272
  /**
298
273
  * Fetch aggregate metrics from the Nord API
299
274
  *
@@ -356,30 +331,6 @@ export class Nord {
356
331
  return metrics.getTotalTransactions(this.webServerUrl);
357
332
  }
358
333
 
359
- /**
360
- * Query a block from Rollman
361
- *
362
- * @param query - Block query parameters
363
- * @returns Rollman block response
364
- * @throws {NordError} If the request fails
365
- */
366
- async blockQueryRollman(query: BlockQuery): Promise<RollmanBlockResponse> {
367
- return queries.blockQueryRollman(this.webServerUrl, query);
368
- }
369
-
370
- /**
371
- * Query block summaries from Rollman
372
- *
373
- * @param last_n - Number of recent blocks to query
374
- * @returns Block summary response
375
- * @throws {NordError} If the request fails
376
- */
377
- async blockSummaryQueryRollman(
378
- last_n: number,
379
- ): Promise<BlockSummaryResponse> {
380
- return queries.blockSummaryQueryRollman(this.webServerUrl, last_n);
381
- }
382
-
383
334
  /**
384
335
  * Query an action from Rollman
385
336
  *