@n1xyz/nord-ts 0.0.4 → 0.0.5

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 (306) hide show
  1. package/dist/bridge/client.d.ts +4 -4
  2. package/dist/bridge/client.js +4 -4
  3. package/dist/bridge/const.d.ts +2 -2
  4. package/dist/bridge/const.js +22 -22
  5. package/dist/bridge/index.d.ts +4 -4
  6. package/dist/bridge/types.d.ts +3 -3
  7. package/dist/bridge/utils.d.ts +4 -4
  8. package/dist/bridge/utils.js +10 -10
  9. package/dist/const.d.ts +1 -1
  10. package/dist/const.js +17 -17
  11. package/dist/gen/nord.d.ts +1 -4
  12. package/dist/idl/bridge.d.ts +1 -1
  13. package/dist/idl/bridge.js +185 -185
  14. package/dist/index.d.ts +8 -8
  15. package/dist/nord/api/actions.d.ts +3 -3
  16. package/dist/nord/api/actions.js +21 -21
  17. package/dist/nord/api/core.d.ts +3 -3
  18. package/dist/nord/api/core.js +12 -12
  19. package/dist/nord/api/market.d.ts +1 -1
  20. package/dist/nord/api/market.js +12 -12
  21. package/dist/nord/api/metrics.d.ts +1 -1
  22. package/dist/nord/api/metrics.js +6 -6
  23. package/dist/nord/api/queries.d.ts +1 -1
  24. package/dist/nord/api/queries.js +9 -9
  25. package/dist/nord/client/Nord.d.ts +4 -4
  26. package/dist/nord/client/Nord.js +18 -18
  27. package/dist/nord/client/NordUser.d.ts +7 -7
  28. package/dist/nord/client/NordUser.js +45 -49
  29. package/dist/nord/index.d.ts +9 -9
  30. package/dist/nord/models/Subscriber.d.ts +6 -6
  31. package/dist/nord/models/Subscriber.js +1 -5
  32. package/dist/nord/utils/NordError.js +2 -2
  33. package/dist/types.d.ts +1 -1
  34. package/dist/types.js +1 -1
  35. package/dist/utils.d.ts +6 -6
  36. package/dist/utils.js +8 -8
  37. package/dist/websocket/NordWebSocketClient.d.ts +2 -2
  38. package/dist/websocket/NordWebSocketClient.js +38 -38
  39. package/dist/websocket/events.d.ts +1 -1
  40. package/dist/websocket/index.d.ts +2 -2
  41. package/docs/assets/hierarchy.js +1 -0
  42. package/docs/assets/highlight.css +16 -16
  43. package/docs/assets/icons.js +17 -14
  44. package/docs/assets/icons.svg +1 -1
  45. package/docs/assets/main.js +5 -4
  46. package/docs/assets/navigation.js +1 -1
  47. package/docs/assets/search.js +1 -1
  48. package/docs/assets/style.css +1423 -1227
  49. package/docs/classes/Nord.html +190 -31
  50. package/docs/classes/NordError.html +24 -0
  51. package/docs/classes/NordUser.html +120 -35
  52. package/docs/classes/NordWebSocketClient.html +335 -0
  53. package/docs/classes/SolanaBridgeClient.html +86 -0
  54. package/docs/classes/Subscriber.html +10 -0
  55. package/docs/enums/FillMode.html +5 -5
  56. package/docs/enums/KeyType.html +4 -4
  57. package/docs/enums/MetricPeriod.html +9 -0
  58. package/docs/enums/PdaSeedType.html +9 -0
  59. package/docs/enums/PeakTpsPeriodUnit.html +7 -7
  60. package/docs/enums/Side.html +3 -3
  61. package/docs/enums/WebSocketMessageType.html +7 -0
  62. package/docs/functions/actionQueryRollman.html +6 -0
  63. package/docs/functions/actionsQueryRollman.html +6 -0
  64. package/docs/functions/aggregateMetrics-1.html +7 -0
  65. package/docs/functions/assert.html +1 -1
  66. package/docs/functions/bigIntToProtoU128.html +3 -3
  67. package/docs/functions/blockQueryRollman.html +6 -0
  68. package/docs/functions/blockSummaryQueryRollman.html +6 -0
  69. package/docs/functions/bridgeToBN.html +5 -0
  70. package/docs/functions/bufferToHex.html +4 -0
  71. package/docs/functions/cancelOrder.html +1 -0
  72. package/docs/functions/checkPubKeyLength.html +1 -1
  73. package/docs/functions/checkedFetch.html +4 -4
  74. package/docs/functions/createSession.html +1 -0
  75. package/docs/functions/decodeLengthDelimited.html +7 -6
  76. package/docs/functions/encodeLengthDelimited.html +4 -4
  77. package/docs/functions/fillModeToProtoFillMode.html +4 -4
  78. package/docs/functions/findMarket.html +1 -1
  79. package/docs/functions/findPda.html +6 -0
  80. package/docs/functions/findToken.html +1 -1
  81. package/docs/functions/fromBN.html +5 -0
  82. package/docs/functions/getAccount.html +6 -0
  83. package/docs/functions/getActionNonce.html +5 -0
  84. package/docs/functions/getCurrentTps.html +6 -0
  85. package/docs/functions/getInfo.html +5 -0
  86. package/docs/functions/getMedianLatency.html +6 -0
  87. package/docs/functions/getOrderbook.html +6 -0
  88. package/docs/functions/getPeakTps.html +6 -0
  89. package/docs/functions/getTimestamp.html +5 -0
  90. package/docs/functions/getTotalTransactions.html +5 -0
  91. package/docs/functions/getTrades.html +6 -0
  92. package/docs/functions/getUserAccountIds.html +6 -0
  93. package/docs/functions/hexToBuffer.html +4 -0
  94. package/docs/functions/initWebSocketClient.html +12 -0
  95. package/docs/functions/keypairFromPrivateKey.html +4 -0
  96. package/docs/functions/makeSigningFunction.html +4 -0
  97. package/docs/functions/makeWalletSignFn.html +5 -5
  98. package/docs/functions/marketsStats.html +5 -0
  99. package/docs/functions/optExpect.html +4 -4
  100. package/docs/functions/optMap.html +5 -5
  101. package/docs/functions/optUnwrap.html +2 -2
  102. package/docs/functions/panic.html +1 -1
  103. package/docs/functions/placeOrder.html +1 -0
  104. package/docs/functions/queryAction.html +6 -0
  105. package/docs/functions/queryBlock.html +6 -0
  106. package/docs/functions/queryLastNBlocks.html +5 -0
  107. package/docs/functions/queryPrometheus.html +6 -0
  108. package/docs/functions/queryRecentActions.html +6 -0
  109. package/docs/functions/queryRecentBlocks.html +6 -0
  110. package/docs/functions/revokeSession.html +1 -0
  111. package/docs/functions/shortenPublicKey.html +5 -0
  112. package/docs/functions/signAction.html +2 -2
  113. package/docs/functions/toBN.html +5 -0
  114. package/docs/functions/toScaledU128.html +5 -5
  115. package/docs/functions/toScaledU64.html +5 -5
  116. package/docs/functions/transfer.html +1 -0
  117. package/docs/functions/withdraw.html +1 -0
  118. package/docs/hierarchy.html +1 -0
  119. package/docs/index.html +39 -20
  120. package/docs/interfaces/Account.html +8 -8
  121. package/docs/interfaces/ActionInfo.html +8 -8
  122. package/docs/interfaces/ActionNonceResponse.html +3 -0
  123. package/docs/interfaces/ActionQuery.html +4 -4
  124. package/docs/interfaces/ActionResponse.html +8 -8
  125. package/docs/interfaces/ActionsExtendedInfo.html +10 -10
  126. package/docs/interfaces/ActionsQuery.html +5 -5
  127. package/docs/interfaces/ActionsResponse.html +6 -6
  128. package/docs/interfaces/AggregateMetrics.html +12 -12
  129. package/docs/interfaces/BlockFacts.html +10 -0
  130. package/docs/interfaces/BlockQuery.html +6 -6
  131. package/docs/interfaces/BlockResponse.html +6 -6
  132. package/docs/interfaces/BlockSummary.html +8 -8
  133. package/docs/interfaces/BlockSummaryResponse.html +6 -6
  134. package/docs/interfaces/DeltaEvent.html +6 -6
  135. package/docs/interfaces/DepositSplParams.html +10 -0
  136. package/docs/interfaces/Info.html +3 -3
  137. package/docs/interfaces/Market.html +8 -6
  138. package/docs/interfaces/MarketStats.html +7 -7
  139. package/docs/interfaces/MarketsStatsResponse.html +2 -2
  140. package/docs/interfaces/NordConfig.html +14 -5
  141. package/docs/interfaces/NordWebSocketClientEvents.html +4 -0
  142. package/docs/interfaces/NordWebSocketEvents.html +8 -0
  143. package/docs/interfaces/Order.html +6 -6
  144. package/docs/interfaces/OrderInfo.html +6 -6
  145. package/docs/interfaces/OrderbookEntry.html +4 -0
  146. package/docs/interfaces/OrderbookQuery.html +6 -0
  147. package/docs/interfaces/OrderbookResponse.html +6 -0
  148. package/docs/interfaces/OrderbookSubscription.html +159 -0
  149. package/docs/interfaces/PerpMarketStats.html +5 -5
  150. package/docs/interfaces/RollmanActionExtendedInfo.html +4 -4
  151. package/docs/interfaces/RollmanActionInfo.html +4 -4
  152. package/docs/interfaces/RollmanActionResponse.html +4 -4
  153. package/docs/interfaces/RollmanActionsResponse.html +2 -2
  154. package/docs/interfaces/RollmanBlockResponse.html +3 -3
  155. package/docs/interfaces/SPLTokenInfo.html +10 -0
  156. package/docs/interfaces/SolanaBridgeConfig.html +10 -0
  157. package/docs/interfaces/StateFacts.html +10 -0
  158. package/docs/interfaces/SubscriberConfig.html +3 -3
  159. package/docs/interfaces/TimestampResponse.html +3 -0
  160. package/docs/interfaces/Token.html +5 -5
  161. package/docs/interfaces/TokenInfo.html +5 -0
  162. package/docs/interfaces/Trade.html +5 -5
  163. package/docs/interfaces/TradeSubscription.html +159 -0
  164. package/docs/interfaces/Trades.html +5 -5
  165. package/docs/interfaces/TradesQuery.html +6 -0
  166. package/docs/interfaces/TradesResponse.html +7 -0
  167. package/docs/interfaces/TransferParams.html +8 -0
  168. package/docs/interfaces/UserAccountIdsQuery.html +3 -0
  169. package/docs/interfaces/UserAccountIdsResponse.html +3 -0
  170. package/docs/interfaces/WebSocketDeltaUpdate.html +9 -0
  171. package/docs/interfaces/WebSocketSubscription.html +4 -0
  172. package/docs/interfaces/WebSocketTradeUpdate.html +6 -0
  173. package/docs/interfaces/WebSocketUserUpdate.html +6 -0
  174. package/docs/interfaces/WithdrawalClaim.html +14 -0
  175. package/docs/interfaces/WithdrawalParams.html +8 -0
  176. package/docs/modules.html +1 -70
  177. package/docs/types/BigIntValue.html +2 -2
  178. package/docs/types/WebSocketMessage.html +1 -0
  179. package/docs/variables/DEBUG_KEYS.html +1 -1
  180. package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +1 -1
  181. package/docs/variables/DEV_TOKEN_INFOS.html +1 -1
  182. package/docs/variables/DEV_URL.html +1 -1
  183. package/docs/variables/MAX_BUFFER_LEN.html +1 -1
  184. package/docs/variables/SESSION_TTL.html +1 -1
  185. package/docs/variables/WEBSERVER_DEV_URL.html +1 -1
  186. package/docs/variables/ZERO_DECIMAL.html +1 -1
  187. package/docs/variables/_private.html +2 -0
  188. package/eslint.config.mjs +66 -0
  189. package/package.json +12 -13
  190. package/src/bridge/client.ts +10 -10
  191. package/src/bridge/const.ts +24 -24
  192. package/src/bridge/index.ts +4 -4
  193. package/src/bridge/types.ts +10 -10
  194. package/src/bridge/utils.ts +14 -14
  195. package/src/const.ts +18 -18
  196. package/src/gen/nord.ts +1 -4
  197. package/src/idl/bridge.ts +186 -186
  198. package/src/index.ts +8 -8
  199. package/src/nord/api/actions.ts +25 -25
  200. package/src/nord/api/core.ts +16 -16
  201. package/src/nord/api/market.ts +15 -15
  202. package/src/nord/api/metrics.ts +16 -16
  203. package/src/nord/api/queries.ts +12 -12
  204. package/src/nord/client/Nord.ts +27 -27
  205. package/src/nord/client/NordUser.ts +59 -63
  206. package/src/nord/index.ts +9 -9
  207. package/src/nord/models/Subscriber.ts +11 -12
  208. package/src/nord/utils/NordError.ts +2 -2
  209. package/src/types.ts +12 -12
  210. package/src/utils.ts +20 -20
  211. package/src/websocket/NordWebSocketClient.ts +42 -42
  212. package/src/websocket/events.ts +1 -1
  213. package/src/websocket/index.ts +2 -2
  214. package/tests/utils.spec.ts +24 -24
  215. package/tsconfig.eslint.json +12 -0
  216. package/.eslintignore +0 -1
  217. package/.eslintrc.js +0 -31
  218. package/dist/abis/ERC20_ABI.d.ts +0 -39
  219. package/dist/abis/ERC20_ABI.js +0 -313
  220. package/dist/abis/NORD_GETTERS_FACET_ABI.d.ts +0 -34
  221. package/dist/abis/NORD_GETTERS_FACET_ABI.js +0 -195
  222. package/dist/abis/NORD_RAMP_FACET_ABI.d.ts +0 -35
  223. package/dist/abis/NORD_RAMP_FACET_ABI.js +0 -144
  224. package/dist/abis/index.d.ts +0 -3
  225. package/dist/abis/index.js +0 -9
  226. package/dist/bridge/NordUser.d.ts +0 -78
  227. package/dist/bridge/NordUser.js +0 -196
  228. package/dist/client.d.ts +0 -70
  229. package/dist/client.js +0 -129
  230. package/dist/constants/endpoints.d.ts +0 -65
  231. package/dist/constants/endpoints.js +0 -68
  232. package/dist/models/account.d.ts +0 -58
  233. package/dist/models/account.js +0 -6
  234. package/dist/models/index.d.ts +0 -8
  235. package/dist/models/index.js +0 -28
  236. package/dist/models/market.d.ts +0 -137
  237. package/dist/models/market.js +0 -6
  238. package/dist/models/order.d.ts +0 -211
  239. package/dist/models/order.js +0 -6
  240. package/dist/models/token.d.ts +0 -50
  241. package/dist/models/token.js +0 -6
  242. package/dist/nord/Nord.d.ts +0 -249
  243. package/dist/nord/Nord.js +0 -388
  244. package/dist/nord/NordError.d.ts +0 -23
  245. package/dist/nord/NordError.js +0 -48
  246. package/dist/nord/NordImpl.d.ts +0 -11
  247. package/dist/nord/NordImpl.js +0 -26
  248. package/dist/nord/NordUser.d.ts +0 -243
  249. package/dist/nord/NordUser.js +0 -481
  250. package/dist/nord/Subscriber.d.ts +0 -37
  251. package/dist/nord/Subscriber.js +0 -29
  252. package/dist/nord/actions.d.ts +0 -101
  253. package/dist/nord/actions.js +0 -254
  254. package/dist/nord/api/index.d.ts +0 -1
  255. package/dist/nord/api/index.js +0 -17
  256. package/dist/nord/api/orderFunctions.d.ts +0 -168
  257. package/dist/nord/api/orderFunctions.js +0 -133
  258. package/dist/nord/core.d.ts +0 -48
  259. package/dist/nord/core.js +0 -97
  260. package/dist/nord/market.d.ts +0 -36
  261. package/dist/nord/market.js +0 -90
  262. package/dist/nord/metrics.d.ts +0 -67
  263. package/dist/nord/metrics.js +0 -124
  264. package/dist/nord/queries.d.ts +0 -81
  265. package/dist/nord/queries.js +0 -181
  266. package/dist/nord/types.d.ts +0 -88
  267. package/dist/nord/types.js +0 -2
  268. package/dist/nord/websocket.d.ts +0 -49
  269. package/dist/nord/websocket.js +0 -107
  270. package/dist/operations/account.d.ts +0 -58
  271. package/dist/operations/account.js +0 -112
  272. package/dist/operations/market.d.ts +0 -65
  273. package/dist/operations/market.js +0 -131
  274. package/dist/operations/orders.d.ts +0 -57
  275. package/dist/operations/orders.js +0 -129
  276. package/dist/solana/NordUser.d.ts +0 -78
  277. package/dist/solana/NordUser.js +0 -196
  278. package/dist/solana/client.d.ts +0 -139
  279. package/dist/solana/client.js +0 -360
  280. package/dist/solana/const.d.ts +0 -23
  281. package/dist/solana/const.js +0 -47
  282. package/dist/solana/index.d.ts +0 -5
  283. package/dist/solana/index.js +0 -23
  284. package/dist/solana/types.d.ts +0 -118
  285. package/dist/solana/types.js +0 -16
  286. package/dist/solana/utils.d.ts +0 -64
  287. package/dist/solana/utils.js +0 -131
  288. package/dist/types/api.d.ts +0 -152
  289. package/dist/types/api.js +0 -6
  290. package/dist/types/config.d.ts +0 -34
  291. package/dist/types/config.js +0 -6
  292. package/dist/utils/errors.d.ts +0 -96
  293. package/dist/utils/errors.js +0 -132
  294. package/dist/utils/http.d.ts +0 -35
  295. package/dist/utils/http.js +0 -105
  296. package/dist/websocket/client.d.ts +0 -93
  297. package/dist/websocket/client.js +0 -222
  298. package/dist/websocket.d.ts +0 -55
  299. package/dist/websocket.js +0 -211
  300. package/docs/interfaces/ERC20TokenInfo.html +0 -5
  301. package/docs/variables/DEV_CONTRACT_ADDRESS.html +0 -1
  302. package/docs/variables/ERC20_ABI.html +0 -1
  303. package/docs/variables/EVM_DEV_URL.html +0 -1
  304. package/docs/variables/FAUCET_PRIVATE_ADDRESS.html +0 -1
  305. package/docs/variables/NORD_GETTERS_FACET_ABI.html +0 -1
  306. package/docs/variables/NORD_RAMP_FACET_ABI.html +0 -1
package/dist/nord/core.js DELETED
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTimestamp = getTimestamp;
4
- exports.getActionNonce = getActionNonce;
5
- exports.getInfo = getInfo;
6
- exports.getAccount = getAccount;
7
- exports.initWebSocketClient = initWebSocketClient;
8
- const utils_1 = require("../utils");
9
- const NordError_1 = require("./utils/NordError");
10
- const index_1 = require("../websocket/index");
11
- /**
12
- * Get the current timestamp from the Nord server
13
- *
14
- * @param webServerUrl - Base URL for the Nord web server
15
- * @returns Current timestamp as a bigint
16
- * @throws {NordError} If the request fails
17
- */
18
- async function getTimestamp(webServerUrl) {
19
- try {
20
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/timestamp`);
21
- const data = await response.json();
22
- return BigInt(data.timestamp);
23
- }
24
- catch (error) {
25
- throw new NordError_1.NordError("Failed to get timestamp", { cause: error });
26
- }
27
- }
28
- /**
29
- * Get the next action nonce from the Nord server
30
- *
31
- * @param webServerUrl - Base URL for the Nord web server
32
- * @returns Next action nonce
33
- * @throws {NordError} If the request fails
34
- */
35
- async function getActionNonce(webServerUrl) {
36
- try {
37
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/action_nonce`);
38
- const data = await response.json();
39
- return data.nonce;
40
- }
41
- catch (error) {
42
- throw new NordError_1.NordError("Failed to get action nonce", { cause: error });
43
- }
44
- }
45
- /**
46
- * Get information about the Nord server
47
- *
48
- * @param webServerUrl - Base URL for the Nord web server
49
- * @returns Information about markets and tokens
50
- * @throws {NordError} If the request fails
51
- */
52
- async function getInfo(webServerUrl) {
53
- try {
54
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/info`);
55
- return await response.json();
56
- }
57
- catch (error) {
58
- throw new NordError_1.NordError("Failed to get info", { cause: error });
59
- }
60
- }
61
- /**
62
- * Get account information
63
- *
64
- * @param webServerUrl - Base URL for the Nord web server
65
- * @param accountId - Account ID to get information for
66
- * @returns Account information
67
- * @throws {NordError} If the request fails
68
- */
69
- async function getAccount(webServerUrl, accountId) {
70
- try {
71
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/account?account_id=${accountId}`);
72
- return await response.json();
73
- }
74
- catch (error) {
75
- throw new NordError_1.NordError(`Failed to get account ${accountId}`, { cause: error });
76
- }
77
- }
78
- /**
79
- * Initialize a WebSocket client for Nord
80
- *
81
- * Connects to one of the specific Nord WebSocket endpoints:
82
- * - /ws/trades - For trade updates (default)
83
- * - /ws/deltas - For orderbook delta updates
84
- * - /ws/user - For user-specific updates
85
- *
86
- * @param webServerUrl - Base URL for the Nord web server
87
- * @param endpoint - Specific WebSocket endpoint to connect to (trades, deltas, or user)
88
- * @returns WebSocket client
89
- */
90
- function initWebSocketClient(webServerUrl, endpoint) {
91
- // If no specific endpoint is provided, we'll connect to trades by default
92
- const specificEndpoint = endpoint || 'trades';
93
- const wsUrl = webServerUrl.replace(/^http/, "ws") + `/ws/${specificEndpoint}`;
94
- const ws = new index_1.NordWebSocketClient(wsUrl);
95
- ws.connect();
96
- return ws;
97
- }
@@ -1,36 +0,0 @@
1
- import { MarketsStatsResponse, OrderbookQuery, OrderbookResponse, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../types";
2
- /**
3
- * Get market statistics
4
- *
5
- * @param webServerUrl - Base URL for the Nord web server
6
- * @returns Market statistics response
7
- * @throws {NordError} If the request fails
8
- */
9
- export declare function marketsStats(webServerUrl: string): Promise<MarketsStatsResponse>;
10
- /**
11
- * Get trades for a market
12
- *
13
- * @param webServerUrl - Base URL for the Nord web server
14
- * @param query - Trades query parameters
15
- * @returns Trades response
16
- * @throws {NordError} If the request fails
17
- */
18
- export declare function getTrades(webServerUrl: string, query: TradesQuery): Promise<TradesResponse>;
19
- /**
20
- * Get user account IDs
21
- *
22
- * @param webServerUrl - Base URL for the Nord web server
23
- * @param query - User account IDs query parameters
24
- * @returns User account IDs response
25
- * @throws {NordError} If the request fails
26
- */
27
- export declare function getUserAccountIds(webServerUrl: string, query: UserAccountIdsQuery): Promise<UserAccountIdsResponse>;
28
- /**
29
- * Get orderbook for a market
30
- *
31
- * @param webServerUrl - Base URL for the Nord web server
32
- * @param query - Orderbook query parameters
33
- * @returns Orderbook response
34
- * @throws {NordError} If the request fails
35
- */
36
- export declare function getOrderbook(webServerUrl: string, query: OrderbookQuery): Promise<OrderbookResponse>;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketsStats = marketsStats;
4
- exports.getTrades = getTrades;
5
- exports.getUserAccountIds = getUserAccountIds;
6
- exports.getOrderbook = getOrderbook;
7
- const utils_1 = require("../utils");
8
- const NordError_1 = require("./NordError");
9
- /**
10
- * Get market statistics
11
- *
12
- * @param webServerUrl - Base URL for the Nord web server
13
- * @returns Market statistics response
14
- * @throws {NordError} If the request fails
15
- */
16
- async function marketsStats(webServerUrl) {
17
- try {
18
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/markets_stats`);
19
- return await response.json();
20
- }
21
- catch (error) {
22
- throw new NordError_1.NordError("Failed to fetch markets stats", { cause: error });
23
- }
24
- }
25
- /**
26
- * Get trades for a market
27
- *
28
- * @param webServerUrl - Base URL for the Nord web server
29
- * @param query - Trades query parameters
30
- * @returns Trades response
31
- * @throws {NordError} If the request fails
32
- */
33
- async function getTrades(webServerUrl, query) {
34
- try {
35
- const params = new URLSearchParams();
36
- params.append("accountId", query.accountId.toString());
37
- if (query.since) {
38
- params.append("since", query.since);
39
- }
40
- if (query.until) {
41
- params.append("until", query.until);
42
- }
43
- if (query.pageId) {
44
- params.append("pageId", query.pageId);
45
- }
46
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/trades?${params.toString()}`);
47
- return await response.json();
48
- }
49
- catch (error) {
50
- throw new NordError_1.NordError("Failed to get trades", { cause: error });
51
- }
52
- }
53
- /**
54
- * Get user account IDs
55
- *
56
- * @param webServerUrl - Base URL for the Nord web server
57
- * @param query - User account IDs query parameters
58
- * @returns User account IDs response
59
- * @throws {NordError} If the request fails
60
- */
61
- async function getUserAccountIds(webServerUrl, query) {
62
- try {
63
- const params = new URLSearchParams();
64
- params.append("pubkey", query.pubkey);
65
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/user_account_ids?${params.toString()}`);
66
- return await response.json();
67
- }
68
- catch (error) {
69
- throw new NordError_1.NordError("Failed to get user account IDs", { cause: error });
70
- }
71
- }
72
- /**
73
- * Get orderbook for a market
74
- *
75
- * @param webServerUrl - Base URL for the Nord web server
76
- * @param query - Orderbook query parameters
77
- * @returns Orderbook response
78
- * @throws {NordError} If the request fails
79
- */
80
- async function getOrderbook(webServerUrl, query) {
81
- try {
82
- const params = new URLSearchParams();
83
- params.append("symbol", query.symbol);
84
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/orderbook?${params.toString()}`);
85
- return await response.json();
86
- }
87
- catch (error) {
88
- throw new NordError_1.NordError("Failed to get orderbook", { cause: error });
89
- }
90
- }
@@ -1,67 +0,0 @@
1
- import { AggregateMetrics, PeakTpsPeriodUnit } from "../types";
2
- /**
3
- * Time periods for metrics queries
4
- */
5
- export declare enum MetricPeriod {
6
- ONE_MINUTE = "1m",
7
- FIVE_MINUTES = "5m",
8
- FIFTEEN_MINUTES = "15m",
9
- ONE_HOUR = "1h",
10
- FOUR_HOURS = "4h",
11
- ONE_DAY = "24h",
12
- ONE_WEEK = "7d"
13
- }
14
- /**
15
- * Fetch aggregate metrics from the Nord API
16
- *
17
- * @param webServerUrl - Base URL for the Nord web server
18
- * @param txPeakTpsPeriod - Period for peak TPS calculation
19
- * @param txPeakTpsPeriodUnit - Unit for peak TPS period
20
- * @returns Aggregate metrics
21
- * @throws {NordError} If the request fails
22
- */
23
- export declare function aggregateMetrics(webServerUrl: string, txPeakTpsPeriod?: number, txPeakTpsPeriodUnit?: PeakTpsPeriodUnit): Promise<AggregateMetrics>;
24
- /**
25
- * Get current transactions per second
26
- *
27
- * @param webServerUrl - Base URL for the Nord web server
28
- * @param period - Time period for the query
29
- * @returns Current TPS value
30
- * @throws {NordError} If the request fails
31
- */
32
- export declare function getCurrentTps(webServerUrl: string, period?: string): Promise<number>;
33
- /**
34
- * Get peak transactions per second
35
- *
36
- * @param webServerUrl - Base URL for the Nord web server
37
- * @param period - Time period for the query
38
- * @returns Peak TPS value
39
- * @throws {NordError} If the request fails
40
- */
41
- export declare function getPeakTps(webServerUrl: string, period?: string): Promise<number>;
42
- /**
43
- * Get median transaction latency
44
- *
45
- * @param webServerUrl - Base URL for the Nord web server
46
- * @param period - Time period for the query
47
- * @returns Median latency in milliseconds
48
- * @throws {NordError} If the request fails
49
- */
50
- export declare function getMedianLatency(webServerUrl: string, period?: string): Promise<number>;
51
- /**
52
- * Get total transaction count
53
- *
54
- * @param webServerUrl - Base URL for the Nord web server
55
- * @returns Total transaction count
56
- * @throws {NordError} If the request fails
57
- */
58
- export declare function getTotalTransactions(webServerUrl: string): Promise<number>;
59
- /**
60
- * Query Prometheus metrics
61
- *
62
- * @param webServerUrl - Base URL for the Nord web server
63
- * @param params - Prometheus query parameters
64
- * @returns Query result as a number
65
- * @throws {NordError} If the request fails
66
- */
67
- export declare function queryPrometheus(webServerUrl: string, params: string): Promise<number>;
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetricPeriod = void 0;
4
- exports.aggregateMetrics = aggregateMetrics;
5
- exports.getCurrentTps = getCurrentTps;
6
- exports.getPeakTps = getPeakTps;
7
- exports.getMedianLatency = getMedianLatency;
8
- exports.getTotalTransactions = getTotalTransactions;
9
- exports.queryPrometheus = queryPrometheus;
10
- const types_1 = require("../types");
11
- const utils_1 = require("../utils");
12
- const NordError_1 = require("./NordError");
13
- /**
14
- * Time periods for metrics queries
15
- */
16
- var MetricPeriod;
17
- (function (MetricPeriod) {
18
- MetricPeriod["ONE_MINUTE"] = "1m";
19
- MetricPeriod["FIVE_MINUTES"] = "5m";
20
- MetricPeriod["FIFTEEN_MINUTES"] = "15m";
21
- MetricPeriod["ONE_HOUR"] = "1h";
22
- MetricPeriod["FOUR_HOURS"] = "4h";
23
- MetricPeriod["ONE_DAY"] = "24h";
24
- MetricPeriod["ONE_WEEK"] = "7d";
25
- })(MetricPeriod || (exports.MetricPeriod = MetricPeriod = {}));
26
- /**
27
- * Fetch aggregate metrics from the Nord API
28
- *
29
- * @param webServerUrl - Base URL for the Nord web server
30
- * @param txPeakTpsPeriod - Period for peak TPS calculation
31
- * @param txPeakTpsPeriodUnit - Unit for peak TPS period
32
- * @returns Aggregate metrics
33
- * @throws {NordError} If the request fails
34
- */
35
- async function aggregateMetrics(webServerUrl, txPeakTpsPeriod = 1, txPeakTpsPeriodUnit = types_1.PeakTpsPeriodUnit.Day) {
36
- try {
37
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/metrics?tx_peak_tps_period=${txPeakTpsPeriod}&tx_peak_tps_period_unit=${txPeakTpsPeriodUnit}`);
38
- return await response.json();
39
- }
40
- catch (error) {
41
- throw new NordError_1.NordError("Failed to fetch aggregate metrics", { cause: error });
42
- }
43
- }
44
- /**
45
- * Get current transactions per second
46
- *
47
- * @param webServerUrl - Base URL for the Nord web server
48
- * @param period - Time period for the query
49
- * @returns Current TPS value
50
- * @throws {NordError} If the request fails
51
- */
52
- async function getCurrentTps(webServerUrl, period = "1m") {
53
- try {
54
- return await queryPrometheus(webServerUrl, `sum(rate(nord_tx_count[${period}]))`);
55
- }
56
- catch (error) {
57
- throw new NordError_1.NordError(`Failed to get current TPS for period ${period}`, { cause: error });
58
- }
59
- }
60
- /**
61
- * Get peak transactions per second
62
- *
63
- * @param webServerUrl - Base URL for the Nord web server
64
- * @param period - Time period for the query
65
- * @returns Peak TPS value
66
- * @throws {NordError} If the request fails
67
- */
68
- async function getPeakTps(webServerUrl, period = "24h") {
69
- try {
70
- return await queryPrometheus(webServerUrl, `max_over_time(sum(rate(nord_tx_count[1m]))[${period}:])`);
71
- }
72
- catch (error) {
73
- throw new NordError_1.NordError(`Failed to get peak TPS for period ${period}`, { cause: error });
74
- }
75
- }
76
- /**
77
- * Get median transaction latency
78
- *
79
- * @param webServerUrl - Base URL for the Nord web server
80
- * @param period - Time period for the query
81
- * @returns Median latency in milliseconds
82
- * @throws {NordError} If the request fails
83
- */
84
- async function getMedianLatency(webServerUrl, period = "1m") {
85
- try {
86
- return await queryPrometheus(webServerUrl, `quantile_over_time(0.5, nord_tx_latency_ms[${period}])`);
87
- }
88
- catch (error) {
89
- throw new NordError_1.NordError(`Failed to get median latency for period ${period}`, { cause: error });
90
- }
91
- }
92
- /**
93
- * Get total transaction count
94
- *
95
- * @param webServerUrl - Base URL for the Nord web server
96
- * @returns Total transaction count
97
- * @throws {NordError} If the request fails
98
- */
99
- async function getTotalTransactions(webServerUrl) {
100
- try {
101
- return await queryPrometheus(webServerUrl, "sum(nord_tx_count)");
102
- }
103
- catch (error) {
104
- throw new NordError_1.NordError("Failed to get total transactions", { cause: error });
105
- }
106
- }
107
- /**
108
- * Query Prometheus metrics
109
- *
110
- * @param webServerUrl - Base URL for the Nord web server
111
- * @param params - Prometheus query parameters
112
- * @returns Query result as a number
113
- * @throws {NordError} If the request fails
114
- */
115
- async function queryPrometheus(webServerUrl, params) {
116
- try {
117
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/prometheus?query=${encodeURIComponent(params)}`);
118
- const data = await response.json();
119
- return data.data.result[0]?.value[1] || 0;
120
- }
121
- catch (error) {
122
- throw new NordError_1.NordError(`Failed to query Prometheus: ${params}`, { cause: error });
123
- }
124
- }
@@ -1,81 +0,0 @@
1
- import { ActionQuery, ActionResponse, ActionsResponse, BlockQuery, BlockResponse, BlockSummaryResponse, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse } from "../types";
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>;
28
- /**
29
- * Query a specific action
30
- *
31
- * @param webServerUrl - Base URL for the Nord web server
32
- * @param query - Action query parameters
33
- * @returns Action response
34
- * @throws {NordError} If the request fails
35
- */
36
- export declare function queryAction(webServerUrl: string, query: ActionQuery): Promise<ActionResponse>;
37
- /**
38
- * Query recent actions
39
- *
40
- * @param webServerUrl - Base URL for the Nord web server
41
- * @param last_n - Number of recent actions to query
42
- * @returns Actions response
43
- * @throws {NordError} If the request fails
44
- */
45
- export declare function queryRecentActions(webServerUrl: string, last_n: number): Promise<ActionsResponse>;
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>;
55
- /**
56
- * Query block summaries from Rollman
57
- *
58
- * @param webServerUrl - Base URL for the Nord web server
59
- * @param last_n - Number of recent blocks to query
60
- * @returns Block summary response
61
- * @throws {NordError} If the request fails
62
- */
63
- export declare function blockSummaryQueryRollman(webServerUrl: string, last_n: number): Promise<BlockSummaryResponse>;
64
- /**
65
- * Query an action from Rollman
66
- *
67
- * @param webServerUrl - Base URL for the Nord web server
68
- * @param query - Action query parameters
69
- * @returns Rollman action response
70
- * @throws {NordError} If the request fails
71
- */
72
- export declare function actionQueryRollman(webServerUrl: string, query: ActionQuery): Promise<RollmanActionResponse>;
73
- /**
74
- * Query actions from Rollman
75
- *
76
- * @param webServerUrl - Base URL for the Nord web server
77
- * @param last_n - Number of recent actions to query
78
- * @returns Rollman actions response
79
- * @throws {NordError} If the request fails
80
- */
81
- export declare function actionsQueryRollman(webServerUrl: string, last_n: number): Promise<RollmanActionsResponse>;
@@ -1,181 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryBlock = queryBlock;
4
- exports.queryLastNBlocks = queryLastNBlocks;
5
- exports.queryRecentBlocks = queryRecentBlocks;
6
- exports.queryAction = queryAction;
7
- exports.queryRecentActions = queryRecentActions;
8
- exports.blockQueryRollman = blockQueryRollman;
9
- exports.blockSummaryQueryRollman = blockSummaryQueryRollman;
10
- exports.actionQueryRollman = actionQueryRollman;
11
- exports.actionsQueryRollman = actionsQueryRollman;
12
- const utils_1 = require("../utils");
13
- const NordError_1 = require("./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})`, { cause: error });
66
- }
67
- }
68
- /**
69
- * Query a specific action
70
- *
71
- * @param webServerUrl - Base URL for the Nord web server
72
- * @param query - Action query parameters
73
- * @returns Action response
74
- * @throws {NordError} If the request fails
75
- */
76
- async function queryAction(webServerUrl, query) {
77
- try {
78
- const params = new URLSearchParams();
79
- if (query.action_id !== undefined) {
80
- params.append("action_id", query.action_id.toString());
81
- }
82
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/action?${params.toString()}`);
83
- return await response.json();
84
- }
85
- catch (error) {
86
- throw new NordError_1.NordError("Failed to query action", { cause: error });
87
- }
88
- }
89
- /**
90
- * Query recent actions
91
- *
92
- * @param webServerUrl - Base URL for the Nord web server
93
- * @param last_n - Number of recent actions to query
94
- * @returns Actions response
95
- * @throws {NordError} If the request fails
96
- */
97
- async function queryRecentActions(webServerUrl, last_n) {
98
- try {
99
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?last_n=${last_n}`);
100
- return await response.json();
101
- }
102
- catch (error) {
103
- throw new NordError_1.NordError(`Failed to query recent actions (last ${last_n})`, { cause: error });
104
- }
105
- }
106
- /**
107
- * Query a block from Rollman
108
- *
109
- * @param webServerUrl - Base URL for the Nord web server
110
- * @param query - Block query parameters
111
- * @returns Rollman block response
112
- * @throws {NordError} If the request fails
113
- */
114
- async function blockQueryRollman(webServerUrl, query) {
115
- try {
116
- const params = new URLSearchParams();
117
- if (query.block_number !== undefined) {
118
- params.append("block_height", query.block_number.toString());
119
- }
120
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/block?${params.toString()}`);
121
- return await response.json();
122
- }
123
- catch (error) {
124
- throw new NordError_1.NordError("Failed to query Rollman block", { cause: error });
125
- }
126
- }
127
- /**
128
- * Query block summaries from Rollman
129
- *
130
- * @param webServerUrl - Base URL for the Nord web server
131
- * @param last_n - Number of recent blocks to query
132
- * @returns Block summary response
133
- * @throws {NordError} If the request fails
134
- */
135
- async function blockSummaryQueryRollman(webServerUrl, last_n) {
136
- try {
137
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/blocks_summary?last_n=${last_n}`);
138
- return await response.json();
139
- }
140
- catch (error) {
141
- throw new NordError_1.NordError(`Failed to query Rollman block summaries (last ${last_n})`, { cause: error });
142
- }
143
- }
144
- /**
145
- * Query an action from Rollman
146
- *
147
- * @param webServerUrl - Base URL for the Nord web server
148
- * @param query - Action query parameters
149
- * @returns Rollman action response
150
- * @throws {NordError} If the request fails
151
- */
152
- async function actionQueryRollman(webServerUrl, query) {
153
- try {
154
- const params = new URLSearchParams();
155
- if (query.action_id !== undefined) {
156
- params.append("action_id", query.action_id.toString());
157
- }
158
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/action?${params.toString()}`);
159
- return await response.json();
160
- }
161
- catch (error) {
162
- throw new NordError_1.NordError("Failed to query Rollman action", { cause: error });
163
- }
164
- }
165
- /**
166
- * Query actions from Rollman
167
- *
168
- * @param webServerUrl - Base URL for the Nord web server
169
- * @param last_n - Number of recent actions to query
170
- * @returns Rollman actions response
171
- * @throws {NordError} If the request fails
172
- */
173
- async function actionsQueryRollman(webServerUrl, last_n) {
174
- try {
175
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/actions?last_n=${last_n}`);
176
- return await response.json();
177
- }
178
- catch (error) {
179
- throw new NordError_1.NordError(`Failed to query Rollman actions (last ${last_n})`, { cause: error });
180
- }
181
- }