@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
@@ -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.blockQueryRollman = blockQueryRollman;
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 last_n - Number of recent actions to query
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, last_n) {
40
+ async function queryRecentActions(webServerUrl, from, to) {
100
41
  try {
101
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?last_n=${last_n}`);
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 (last ${last_n})`, {
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
- * Query a block from Rollman
52
+ * Get the last action ID
112
53
  *
113
54
  * @param webServerUrl - Base URL for the Nord web server
114
- * @param query - Block query parameters
115
- * @returns Rollman block response
55
+ * @returns Last action ID
116
56
  * @throws {NordError} If the request fails
117
57
  */
118
- async function blockQueryRollman(webServerUrl, query) {
58
+ async function getLastActionId(webServerUrl) {
119
59
  try {
120
- const params = new URLSearchParams();
121
- if (query.block_number !== undefined) {
122
- params.append("block_height", query.block_number.toString());
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 query Rollman block", { cause: error });
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, BlockQuery, BlockResponse, BlockSummaryResponse, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
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 last_n - Number of recent actions to query
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(last_n: number): Promise<ActionsResponse>;
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
  *
@@ -184,35 +184,6 @@ class Nord {
184
184
  async marketsStats() {
185
185
  return market.marketsStats(this.webServerUrl);
186
186
  }
187
- /**
188
- * Query a specific block
189
- *
190
- * @param query - Block query parameters
191
- * @returns Block response
192
- * @throws {NordError} If the request fails
193
- */
194
- async queryBlock(query) {
195
- return queries.queryBlock(this.webServerUrl, query);
196
- }
197
- /**
198
- * Query the last N blocks
199
- *
200
- * @returns Block response for the last N blocks
201
- * @throws {NordError} If the request fails
202
- */
203
- async queryLastNBlocks() {
204
- return queries.queryLastNBlocks(this.webServerUrl);
205
- }
206
- /**
207
- * Query recent blocks
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
- async queryRecentBlocks(last_n) {
214
- return queries.queryRecentBlocks(this.webServerUrl, last_n);
215
- }
216
187
  /**
217
188
  * Query a specific action
218
189
  *
@@ -226,12 +197,22 @@ class Nord {
226
197
  /**
227
198
  * Query recent actions
228
199
  *
229
- * @param last_n - Number of recent actions to query
200
+ * @param from - Starting action index
201
+ * @param to - Ending action index
230
202
  * @returns Actions response
231
203
  * @throws {NordError} If the request fails
232
204
  */
233
- async queryRecentActions(last_n) {
234
- return queries.queryRecentActions(this.webServerUrl, last_n);
205
+ async queryRecentActions(from, to) {
206
+ return queries.queryRecentActions(this.webServerUrl, from, to);
207
+ }
208
+ /**
209
+ * Get the last action ID
210
+ *
211
+ * @returns Last action ID
212
+ * @throws {NordError} If the request fails
213
+ */
214
+ async getLastActionId() {
215
+ return queries.getLastActionId(this.webServerUrl);
235
216
  }
236
217
  /**
237
218
  * Fetch aggregate metrics from the Nord API
@@ -283,26 +264,6 @@ class Nord {
283
264
  async getTotalTransactions() {
284
265
  return metrics.getTotalTransactions(this.webServerUrl);
285
266
  }
286
- /**
287
- * Query a block from Rollman
288
- *
289
- * @param query - Block query parameters
290
- * @returns Rollman block response
291
- * @throws {NordError} If the request fails
292
- */
293
- async blockQueryRollman(query) {
294
- return queries.blockQueryRollman(this.webServerUrl, query);
295
- }
296
- /**
297
- * Query block summaries from Rollman
298
- *
299
- * @param last_n - Number of recent blocks to query
300
- * @returns Block summary response
301
- * @throws {NordError} If the request fails
302
- */
303
- async blockSummaryQueryRollman(last_n) {
304
- return queries.blockSummaryQueryRollman(this.webServerUrl, last_n);
305
- }
306
267
  /**
307
268
  * Query an action from Rollman
308
269
  *