@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/src/index.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  // Export types
2
- export * from './types';
3
- export * from './utils';
4
- export * from './const';
2
+ export * from "./types";
3
+ export * from "./utils";
4
+ export * from "./const";
5
5
 
6
6
  // Export Nord modules
7
- export * from './nord';
7
+ export * from "./nord";
8
8
 
9
9
  // Export WebSocket modules
10
- export * from './websocket/index';
10
+ export * from "./websocket/index";
11
11
 
12
12
  // Export bridge modules
13
- export * from './bridge/client';
14
- export * from './bridge/types';
13
+ export * from "./bridge/client";
14
+ export * from "./bridge/types";
15
15
  export {
16
16
  bridgeToBN,
17
17
  fromBN,
@@ -21,4 +21,4 @@ export {
21
21
  bufferToHex,
22
22
  hexToBuffer,
23
23
  shortenPublicKey,
24
- } from './bridge/utils';
24
+ } from "./bridge/utils";
@@ -1,6 +1,6 @@
1
- import Decimal from 'decimal.js';
2
- import * as proto from '../../gen/nord';
3
- import { FillMode, fillModeToProtoFillMode, KeyType, Side } from '../../types';
1
+ import Decimal from "decimal.js";
2
+ import * as proto from "../../gen/nord";
3
+ import { FillMode, fillModeToProtoFillMode, KeyType, Side } from "../../types";
4
4
  import {
5
5
  assert,
6
6
  bigIntToProtoU128,
@@ -13,7 +13,7 @@ import {
13
13
  SESSION_TTL,
14
14
  toScaledU128,
15
15
  toScaledU64,
16
- } from '../../utils';
16
+ } from "../../utils";
17
17
 
18
18
  async function sessionSign(
19
19
  signFn: (message: Uint8Array) => Promise<Uint8Array>,
@@ -36,9 +36,9 @@ function makeSendHttp(
36
36
  ): (encoded: Uint8Array) => Promise<Uint8Array> {
37
37
  return async (body) => {
38
38
  const response = await checkedFetch(`${serverUrl}/action`, {
39
- method: 'POST',
39
+ method: "POST",
40
40
  headers: {
41
- 'Content-Type': 'application/json',
41
+ "Content-Type": "application/json",
42
42
  },
43
43
  body,
44
44
  });
@@ -57,7 +57,7 @@ async function sendAction(
57
57
  const rawResp = await sendFn(body);
58
58
  const resp: proto.Receipt = decodeLengthDelimited(rawResp, proto.Receipt);
59
59
 
60
- if (resp.kind?.$case === 'err') {
60
+ if (resp.kind?.$case === "err") {
61
61
  throw new Error(
62
62
  `Could not ${actionErrorDesc}, reason: ${proto.errorToJSON(resp.kind.value)}`,
63
63
  );
@@ -87,7 +87,7 @@ async function createSessionImpl(
87
87
  expiry = params.expiryTimestamp;
88
88
  assert(
89
89
  expiry > currentTimestamp,
90
- 'Cannot set expiry timestamp in the past',
90
+ "Cannot set expiry timestamp in the past",
91
91
  );
92
92
  } else {
93
93
  expiry = currentTimestamp + SESSION_TTL;
@@ -97,7 +97,7 @@ async function createSessionImpl(
97
97
  currentTimestamp,
98
98
  nonce,
99
99
  kind: {
100
- $case: 'createSession',
100
+ $case: "createSession",
101
101
  value: {
102
102
  userPubkey: params.userPubkey,
103
103
  blstPubkey: params.sessionPubkey,
@@ -110,10 +110,10 @@ async function createSessionImpl(
110
110
  sendFn,
111
111
  (m) => walletSign(walletSignFn, m),
112
112
  action,
113
- 'create a new session',
113
+ "create a new session",
114
114
  );
115
115
 
116
- if (resp.kind?.$case === 'createSessionResult') {
116
+ if (resp.kind?.$case === "createSessionResult") {
117
117
  return resp.kind.value.sessionId;
118
118
  } else {
119
119
  throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
@@ -154,7 +154,7 @@ async function revokeSessionImpl(
154
154
  currentTimestamp,
155
155
  nonce,
156
156
  kind: {
157
- $case: 'revokeSession',
157
+ $case: "revokeSession",
158
158
  value: {
159
159
  sessionId: BigInt(params.sessionId),
160
160
  },
@@ -165,7 +165,7 @@ async function revokeSessionImpl(
165
165
  sendFn,
166
166
  (m) => walletSign(walletSignFn, m),
167
167
  action,
168
- 'create a new session',
168
+ "create a new session",
169
169
  );
170
170
  }
171
171
 
@@ -202,14 +202,14 @@ async function withdrawImpl(
202
202
  const amount = toScaledU64(params.amount, params.sizeDecimals);
203
203
 
204
204
  if (amount <= 0) {
205
- throw new Error('Withdraw amount must be positive');
205
+ throw new Error("Withdraw amount must be positive");
206
206
  }
207
207
 
208
208
  const action: proto.Action = {
209
209
  currentTimestamp,
210
210
  nonce,
211
211
  kind: {
212
- $case: 'withdraw',
212
+ $case: "withdraw",
213
213
  value: {
214
214
  sessionId: BigInt(params.sessionId),
215
215
  tokenId: params.tokenId,
@@ -218,7 +218,7 @@ async function withdrawImpl(
218
218
  },
219
219
  };
220
220
 
221
- await sendAction(sendFn, (m) => sessionSign(signFn, m), action, 'withdraw');
221
+ await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "withdraw");
222
222
  }
223
223
 
224
224
  export async function withdraw(
@@ -276,7 +276,7 @@ async function placeOrderImpl(
276
276
  currentTimestamp,
277
277
  nonce,
278
278
  kind: {
279
- $case: 'placeOrder',
279
+ $case: "placeOrder",
280
280
  value: {
281
281
  sessionId: BigInt(params.sessionId),
282
282
  senderAccountId: params.senderId,
@@ -297,10 +297,10 @@ async function placeOrderImpl(
297
297
  sendFn,
298
298
  (m) => sessionSign(signFn, m),
299
299
  action,
300
- 'place the order',
300
+ "place the order",
301
301
  );
302
302
 
303
- if (resp.kind?.$case === 'placeOrderResult') {
303
+ if (resp.kind?.$case === "placeOrderResult") {
304
304
  return resp.kind.value.posted?.orderId;
305
305
  } else {
306
306
  throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
@@ -353,7 +353,7 @@ async function cancelOrderImpl(
353
353
  currentTimestamp,
354
354
  nonce: nonce,
355
355
  kind: {
356
- $case: 'cancelOrderById',
356
+ $case: "cancelOrderById",
357
357
  value: {
358
358
  orderId: BigInt(params.orderId),
359
359
  sessionId: BigInt(params.sessionId),
@@ -367,10 +367,10 @@ async function cancelOrderImpl(
367
367
  sendFn,
368
368
  (m) => sessionSign(signFn, m),
369
369
  action,
370
- 'cancel the order',
370
+ "cancel the order",
371
371
  );
372
372
 
373
- if (resp.kind?.$case === 'cancelOrderResult') {
373
+ if (resp.kind?.$case === "cancelOrderResult") {
374
374
  return resp.kind.value.orderId;
375
375
  } else {
376
376
  throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
@@ -416,7 +416,7 @@ async function transferImpl(
416
416
  currentTimestamp,
417
417
  nonce: nonce,
418
418
  kind: {
419
- $case: 'transfer',
419
+ $case: "transfer",
420
420
  value: {
421
421
  sessionId: BigInt(params.sessionId),
422
422
  fromAccountId: params.fromAccountId,
@@ -431,10 +431,10 @@ async function transferImpl(
431
431
  sendFn,
432
432
  (m) => sessionSign(signFn, m),
433
433
  action,
434
- 'transfer asset to other account',
434
+ "transfer asset to other account",
435
435
  );
436
436
 
437
- if (resp.kind?.$case === 'transferred') {
437
+ if (resp.kind?.$case === "transferred") {
438
438
  if (resp.kind.value.accountCreated) {
439
439
  return resp.kind.value.toUserAccount;
440
440
  } else {
@@ -1,7 +1,7 @@
1
- import { Account, Info, NordConfig, TokenInfo } from '../../types';
2
- import { checkedFetch } from '../../utils';
3
- import { NordError } from '../utils/NordError';
4
- import { NordWebSocketClient } from '../../websocket/index';
1
+ import { Account, Info } from "../../types";
2
+ import { checkedFetch } from "../../utils";
3
+ import { NordWebSocketClient } from "../../websocket/index";
4
+ import { NordError } from "../utils/NordError";
5
5
 
6
6
  /**
7
7
  * Get the current timestamp from the Nord server
@@ -15,7 +15,7 @@ export async function getTimestamp(webServerUrl: string): Promise<bigint> {
15
15
  const response = await checkedFetch(`${webServerUrl}/timestamp`);
16
16
  return BigInt(await response.json());
17
17
  } catch (error) {
18
- throw new NordError('Failed to get timestamp', { cause: error });
18
+ throw new NordError("Failed to get timestamp", { cause: error });
19
19
  }
20
20
  }
21
21
 
@@ -32,7 +32,7 @@ export async function getActionNonce(webServerUrl: string): Promise<number> {
32
32
  const data = await response.json();
33
33
  return data.nonce;
34
34
  } catch (error) {
35
- throw new NordError('Failed to get action nonce', { cause: error });
35
+ throw new NordError("Failed to get action nonce", { cause: error });
36
36
  }
37
37
  }
38
38
 
@@ -48,7 +48,7 @@ export async function getInfo(webServerUrl: string): Promise<Info> {
48
48
  const response = await checkedFetch(`${webServerUrl}/info`);
49
49
  return await response.json();
50
50
  } catch (error) {
51
- throw new NordError('Failed to get info', { cause: error });
51
+ throw new NordError("Failed to get info", { cause: error });
52
52
  }
53
53
  }
54
54
 
@@ -89,28 +89,28 @@ export async function getAccount(
89
89
  */
90
90
  export function initWebSocketClient(
91
91
  webServerUrl: string,
92
- endpoint?: 'trades' | 'deltas' | 'user',
92
+ endpoint?: "trades" | "deltas" | "user",
93
93
  initialSubscriptions?: string[],
94
94
  ): NordWebSocketClient {
95
95
  try {
96
96
  // Convert HTTP URL to WebSocket URL with specific endpoint
97
97
  // If no specific endpoint is provided, we'll connect to trades by default
98
- const specificEndpoint = endpoint || 'trades';
98
+ const specificEndpoint = endpoint || "trades";
99
99
  const wsUrl =
100
- webServerUrl.replace(/^http/, 'ws') + `/ws/${specificEndpoint}`;
100
+ webServerUrl.replace(/^http/, "ws") + `/ws/${specificEndpoint}`;
101
101
  console.log(`Initializing WebSocket client with URL: ${wsUrl}`);
102
102
 
103
103
  // Create and connect the WebSocket client
104
104
  const ws = new NordWebSocketClient(wsUrl);
105
105
 
106
106
  // Add error handler
107
- ws.on('error', (error) => {
108
- console.error('Nord WebSocket error:', error);
107
+ ws.on("error", (error) => {
108
+ console.error("Nord WebSocket error:", error);
109
109
  });
110
110
 
111
111
  // Add connected handler for debugging
112
- ws.on('connected', () => {
113
- console.log('Nord WebSocket connected successfully');
112
+ ws.on("connected", () => {
113
+ console.log("Nord WebSocket connected successfully");
114
114
 
115
115
  // Subscribe to initial subscriptions if provided
116
116
  if (initialSubscriptions && initialSubscriptions.length > 0) {
@@ -122,8 +122,8 @@ export function initWebSocketClient(
122
122
  ws.connect();
123
123
  return ws;
124
124
  } catch (error) {
125
- console.error('Failed to initialize WebSocket client:', error);
126
- throw new NordError('Failed to initialize WebSocket client', {
125
+ console.error("Failed to initialize WebSocket client:", error);
126
+ throw new NordError("Failed to initialize WebSocket client", {
127
127
  cause: error,
128
128
  });
129
129
  }
@@ -6,9 +6,9 @@ import {
6
6
  TradesResponse,
7
7
  UserAccountIdsQuery,
8
8
  UserAccountIdsResponse,
9
- } from '../../types';
10
- import { checkedFetch } from '../../utils';
11
- import { NordError } from '../utils/NordError';
9
+ } from "../../types";
10
+ import { checkedFetch } from "../../utils";
11
+ import { NordError } from "../utils/NordError";
12
12
 
13
13
  /**
14
14
  * Get market statistics
@@ -24,7 +24,7 @@ export async function marketsStats(
24
24
  const response = await checkedFetch(`${webServerUrl}/stats`);
25
25
  return await response.json();
26
26
  } catch (error) {
27
- throw new NordError('Failed to fetch markets stats', { cause: error });
27
+ throw new NordError("Failed to fetch markets stats", { cause: error });
28
28
  }
29
29
  }
30
30
 
@@ -42,18 +42,18 @@ export async function getTrades(
42
42
  ): Promise<TradesResponse> {
43
43
  try {
44
44
  const params = new URLSearchParams();
45
- params.append('accountId', query.accountId.toString());
45
+ params.append("accountId", query.accountId.toString());
46
46
 
47
47
  if (query.since) {
48
- params.append('since', query.since);
48
+ params.append("since", query.since);
49
49
  }
50
50
 
51
51
  if (query.until) {
52
- params.append('until', query.until);
52
+ params.append("until", query.until);
53
53
  }
54
54
 
55
55
  if (query.pageId) {
56
- params.append('pageId', query.pageId);
56
+ params.append("pageId", query.pageId);
57
57
  }
58
58
 
59
59
  const response = await checkedFetch(
@@ -61,7 +61,7 @@ export async function getTrades(
61
61
  );
62
62
  return await response.json();
63
63
  } catch (error) {
64
- throw new NordError('Failed to get trades', { cause: error });
64
+ throw new NordError("Failed to get trades", { cause: error });
65
65
  }
66
66
  }
67
67
 
@@ -79,14 +79,14 @@ export async function getUserAccountIds(
79
79
  ): Promise<UserAccountIdsResponse> {
80
80
  try {
81
81
  const params = new URLSearchParams();
82
- params.append('pubkey', query.pubkey);
82
+ params.append("pubkey", query.pubkey);
83
83
 
84
84
  const response = await checkedFetch(
85
85
  `${webServerUrl}/user?${params.toString()}`,
86
86
  );
87
87
  return await response.json();
88
88
  } catch (error) {
89
- throw new NordError('Failed to get user account IDs', { cause: error });
89
+ throw new NordError("Failed to get user account IDs", { cause: error });
90
90
  }
91
91
  }
92
92
 
@@ -106,12 +106,12 @@ export async function getOrderbook(
106
106
  const params = new URLSearchParams();
107
107
 
108
108
  if (query.symbol) {
109
- params.append('symbol', query.symbol);
109
+ params.append("symbol", query.symbol);
110
110
  } else if (query.market_id !== undefined) {
111
- params.append('market_id', query.market_id.toString());
111
+ params.append("market_id", query.market_id.toString());
112
112
  } else {
113
113
  throw new NordError(
114
- 'Either symbol or market_id must be provided for orderbook query',
114
+ "Either symbol or market_id must be provided for orderbook query",
115
115
  );
116
116
  }
117
117
 
@@ -120,6 +120,6 @@ export async function getOrderbook(
120
120
  );
121
121
  return await response.json();
122
122
  } catch (error) {
123
- throw new NordError('Failed to get orderbook', { cause: error });
123
+ throw new NordError("Failed to get orderbook", { cause: error });
124
124
  }
125
125
  }
@@ -1,18 +1,18 @@
1
- import { AggregateMetrics, PeakTpsPeriodUnit } from '../../types';
2
- import { checkedFetch } from '../../utils';
3
- import { NordError } from '../utils/NordError';
1
+ import { AggregateMetrics, PeakTpsPeriodUnit } from "../../types";
2
+ import { checkedFetch } from "../../utils";
3
+ import { NordError } from "../utils/NordError";
4
4
 
5
5
  /**
6
6
  * Time periods for metrics queries
7
7
  */
8
8
  export enum MetricPeriod {
9
- ONE_MINUTE = '1m',
10
- FIVE_MINUTES = '5m',
11
- FIFTEEN_MINUTES = '15m',
12
- ONE_HOUR = '1h',
13
- FOUR_HOURS = '4h',
14
- ONE_DAY = '24h',
15
- ONE_WEEK = '7d',
9
+ ONE_MINUTE = "1m",
10
+ FIVE_MINUTES = "5m",
11
+ FIFTEEN_MINUTES = "15m",
12
+ ONE_HOUR = "1h",
13
+ FOUR_HOURS = "4h",
14
+ ONE_DAY = "24h",
15
+ ONE_WEEK = "7d",
16
16
  }
17
17
 
18
18
  /**
@@ -35,7 +35,7 @@ export async function aggregateMetrics(
35
35
  );
36
36
  return await response.json();
37
37
  } catch (error) {
38
- throw new NordError('Failed to fetch aggregate metrics', { cause: error });
38
+ throw new NordError("Failed to fetch aggregate metrics", { cause: error });
39
39
  }
40
40
  }
41
41
 
@@ -49,7 +49,7 @@ export async function aggregateMetrics(
49
49
  */
50
50
  export async function getCurrentTps(
51
51
  webServerUrl: string,
52
- period: string = '1m',
52
+ period: string = "1m",
53
53
  ): Promise<number> {
54
54
  try {
55
55
  return await queryPrometheus(
@@ -73,7 +73,7 @@ export async function getCurrentTps(
73
73
  */
74
74
  export async function getPeakTps(
75
75
  webServerUrl: string,
76
- period: string = '24h',
76
+ period: string = "24h",
77
77
  ): Promise<number> {
78
78
  try {
79
79
  return await queryPrometheus(
@@ -97,7 +97,7 @@ export async function getPeakTps(
97
97
  */
98
98
  export async function getMedianLatency(
99
99
  webServerUrl: string,
100
- period: string = '1m',
100
+ period: string = "1m",
101
101
  ): Promise<number> {
102
102
  try {
103
103
  return await queryPrometheus(
@@ -122,9 +122,9 @@ export async function getTotalTransactions(
122
122
  webServerUrl: string,
123
123
  ): Promise<number> {
124
124
  try {
125
- return await queryPrometheus(webServerUrl, 'sum(nord_tx_count)');
125
+ return await queryPrometheus(webServerUrl, "sum(nord_tx_count)");
126
126
  } catch (error) {
127
- throw new NordError('Failed to get total transactions', { cause: error });
127
+ throw new NordError("Failed to get total transactions", { cause: error });
128
128
  }
129
129
  }
130
130
 
@@ -8,9 +8,9 @@ import {
8
8
  RollmanActionResponse,
9
9
  RollmanActionsResponse,
10
10
  RollmanBlockResponse,
11
- } from '../../types';
12
- import { checkedFetch } from '../../utils';
13
- import { NordError } from '../utils/NordError';
11
+ } from "../../types";
12
+ import { checkedFetch } from "../../utils";
13
+ import { NordError } from "../utils/NordError";
14
14
 
15
15
  /**
16
16
  * Query a specific block
@@ -27,7 +27,7 @@ export async function queryBlock(
27
27
  try {
28
28
  const params = new URLSearchParams();
29
29
  if (query.block_number !== undefined) {
30
- params.append('block_height', query.block_number.toString());
30
+ params.append("block_height", query.block_number.toString());
31
31
  }
32
32
 
33
33
  const response = await checkedFetch(
@@ -35,7 +35,7 @@ export async function queryBlock(
35
35
  );
36
36
  return await response.json();
37
37
  } catch (error) {
38
- throw new NordError('Failed to query block', { cause: error });
38
+ throw new NordError("Failed to query block", { cause: error });
39
39
  }
40
40
  }
41
41
 
@@ -53,7 +53,7 @@ export async function queryLastNBlocks(
53
53
  const response = await checkedFetch(`${webServerUrl}/blocks`);
54
54
  return await response.json();
55
55
  } catch (error) {
56
- throw new NordError('Failed to query last N blocks', { cause: error });
56
+ throw new NordError("Failed to query last N blocks", { cause: error });
57
57
  }
58
58
  }
59
59
 
@@ -96,7 +96,7 @@ export async function queryAction(
96
96
  try {
97
97
  const params = new URLSearchParams();
98
98
  if (query.action_id !== undefined) {
99
- params.append('action_id', query.action_id.toString());
99
+ params.append("action_id", query.action_id.toString());
100
100
  }
101
101
 
102
102
  const response = await checkedFetch(
@@ -104,7 +104,7 @@ export async function queryAction(
104
104
  );
105
105
  return await response.json();
106
106
  } catch (error) {
107
- throw new NordError('Failed to query action', { cause: error });
107
+ throw new NordError("Failed to query action", { cause: error });
108
108
  }
109
109
  }
110
110
 
@@ -147,7 +147,7 @@ export async function blockQueryRollman(
147
147
  try {
148
148
  const params = new URLSearchParams();
149
149
  if (query.block_number !== undefined) {
150
- params.append('block_height', query.block_number.toString());
150
+ params.append("block_height", query.block_number.toString());
151
151
  }
152
152
 
153
153
  const response = await checkedFetch(
@@ -155,7 +155,7 @@ export async function blockQueryRollman(
155
155
  );
156
156
  return await response.json();
157
157
  } catch (error) {
158
- throw new NordError('Failed to query Rollman block', { cause: error });
158
+ throw new NordError("Failed to query Rollman block", { cause: error });
159
159
  }
160
160
  }
161
161
 
@@ -199,7 +199,7 @@ export async function actionQueryRollman(
199
199
  try {
200
200
  const params = new URLSearchParams();
201
201
  if (query.action_id !== undefined) {
202
- params.append('action_id', query.action_id.toString());
202
+ params.append("action_id", query.action_id.toString());
203
203
  }
204
204
 
205
205
  const response = await checkedFetch(
@@ -207,7 +207,7 @@ export async function actionQueryRollman(
207
207
  );
208
208
  return await response.json();
209
209
  } catch (error) {
210
- throw new NordError('Failed to query Rollman action', { cause: error });
210
+ throw new NordError("Failed to query Rollman action", { cause: error });
211
211
  }
212
212
  }
213
213