@n1xyz/nord-ts 0.0.16 → 0.0.18-8121ed05.0

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 (192) hide show
  1. package/dist/bridge/client.js +45 -6
  2. package/dist/gen/nord.d.ts +48 -4
  3. package/dist/gen/nord.js +634 -34
  4. package/dist/idl/bridge.d.ts +569 -0
  5. package/dist/idl/bridge.js +8 -0
  6. package/dist/idl/bridge.json +75 -62
  7. package/dist/idl/index.d.ts +71 -49
  8. package/dist/index.d.ts +1 -3
  9. package/dist/index.js +6 -13
  10. package/dist/nord/api/actions.d.ts +7 -2
  11. package/dist/nord/api/actions.js +7 -1
  12. package/dist/nord/api/core.d.ts +1 -1
  13. package/dist/nord/api/core.js +3 -3
  14. package/dist/nord/api/market.js +1 -3
  15. package/dist/nord/api/queries.js +2 -2
  16. package/dist/nord/client/Nord.d.ts +9 -14
  17. package/dist/nord/client/Nord.js +27 -38
  18. package/dist/nord/client/NordUser.d.ts +7 -23
  19. package/dist/nord/client/NordUser.js +67 -143
  20. package/dist/nord/utils/NordError.js +5 -2
  21. package/dist/types.d.ts +34 -50
  22. package/dist/utils.d.ts +2 -9
  23. package/dist/utils.js +13 -18
  24. package/package.json +17 -18
  25. package/protoc-generate.sh +0 -0
  26. package/src/idl/bridge.json +75 -62
  27. package/src/index.ts +9 -12
  28. package/src/nord/api/actions.ts +14 -3
  29. package/src/nord/api/core.ts +4 -2
  30. package/src/nord/api/market.ts +1 -4
  31. package/src/nord/api/queries.ts +2 -2
  32. package/src/nord/client/Nord.ts +45 -50
  33. package/src/nord/client/NordUser.ts +90 -171
  34. package/src/nord/utils/NordError.ts +6 -2
  35. package/src/types.ts +34 -49
  36. package/src/utils.ts +16 -19
  37. package/codebase.md +0 -18886
  38. package/docs/.nojekyll +0 -1
  39. package/docs/assets/hierarchy.js +0 -1
  40. package/docs/assets/highlight.css +0 -92
  41. package/docs/assets/icons.js +0 -18
  42. package/docs/assets/icons.svg +0 -1
  43. package/docs/assets/main.js +0 -60
  44. package/docs/assets/navigation.js +0 -1
  45. package/docs/assets/search.js +0 -1
  46. package/docs/assets/style.css +0 -1611
  47. package/docs/classes/Nord.html +0 -189
  48. package/docs/classes/NordError.html +0 -24
  49. package/docs/classes/NordUser.html +0 -115
  50. package/docs/classes/NordWebSocketClient.html +0 -330
  51. package/docs/classes/SolanaBridgeClient.html +0 -91
  52. package/docs/classes/Subscriber.html +0 -10
  53. package/docs/enums/FillMode.html +0 -5
  54. package/docs/enums/KeyType.html +0 -4
  55. package/docs/enums/MetricPeriod.html +0 -9
  56. package/docs/enums/PdaSeedType.html +0 -11
  57. package/docs/enums/PeakTpsPeriodUnit.html +0 -15
  58. package/docs/enums/Side.html +0 -3
  59. package/docs/enums/WebSocketMessageType.html +0 -7
  60. package/docs/functions/actionQueryRollman.html +0 -6
  61. package/docs/functions/actionsQueryRollman.html +0 -6
  62. package/docs/functions/aggregateMetrics-1.html +0 -7
  63. package/docs/functions/assert.html +0 -1
  64. package/docs/functions/bigIntToProtoU128.html +0 -4
  65. package/docs/functions/bridgeToBN.html +0 -5
  66. package/docs/functions/bufferToHex.html +0 -4
  67. package/docs/functions/cancelOrder.html +0 -1
  68. package/docs/functions/checkPubKeyLength.html +0 -1
  69. package/docs/functions/checkedFetch.html +0 -6
  70. package/docs/functions/createSession.html +0 -1
  71. package/docs/functions/decodeLengthDelimited.html +0 -11
  72. package/docs/functions/encodeLengthDelimited.html +0 -6
  73. package/docs/functions/fillModeToProtoFillMode.html +0 -5
  74. package/docs/functions/findMarket.html +0 -1
  75. package/docs/functions/findPda.html +0 -6
  76. package/docs/functions/findToken.html +0 -1
  77. package/docs/functions/fromBN.html +0 -5
  78. package/docs/functions/getAccount.html +0 -6
  79. package/docs/functions/getActionNonce.html +0 -5
  80. package/docs/functions/getCurrentTps.html +0 -6
  81. package/docs/functions/getInfo.html +0 -5
  82. package/docs/functions/getLastActionId.html +0 -5
  83. package/docs/functions/getMedianLatency.html +0 -6
  84. package/docs/functions/getOrderbook.html +0 -6
  85. package/docs/functions/getPeakTps.html +0 -6
  86. package/docs/functions/getTimestamp.html +0 -5
  87. package/docs/functions/getTotalTransactions.html +0 -5
  88. package/docs/functions/getTrades.html +0 -6
  89. package/docs/functions/getUserAccountIds.html +0 -6
  90. package/docs/functions/hexToBuffer.html +0 -4
  91. package/docs/functions/initWebSocketClient.html +0 -12
  92. package/docs/functions/keypairFromPrivateKey.html +0 -4
  93. package/docs/functions/makeSigningFunction.html +0 -4
  94. package/docs/functions/makeWalletSignFn.html +0 -6
  95. package/docs/functions/marketsStats.html +0 -5
  96. package/docs/functions/optExpect.html +0 -5
  97. package/docs/functions/optMap.html +0 -5
  98. package/docs/functions/optUnwrap.html +0 -2
  99. package/docs/functions/panic.html +0 -1
  100. package/docs/functions/placeOrder.html +0 -1
  101. package/docs/functions/queryAction.html +0 -6
  102. package/docs/functions/queryPrometheus.html +0 -6
  103. package/docs/functions/queryRecentActions.html +0 -7
  104. package/docs/functions/revokeSession.html +0 -1
  105. package/docs/functions/shortenPublicKey.html +0 -5
  106. package/docs/functions/signAction.html +0 -6
  107. package/docs/functions/toBN.html +0 -5
  108. package/docs/functions/toScaledU128.html +0 -8
  109. package/docs/functions/toScaledU64.html +0 -8
  110. package/docs/functions/transfer.html +0 -1
  111. package/docs/functions/withdraw.html +0 -1
  112. package/docs/hierarchy.html +0 -1
  113. package/docs/index.html +0 -40
  114. package/docs/interfaces/Account.html +0 -8
  115. package/docs/interfaces/ActionInfo.html +0 -8
  116. package/docs/interfaces/ActionNonceResponse.html +0 -3
  117. package/docs/interfaces/ActionQuery.html +0 -4
  118. package/docs/interfaces/ActionResponse.html +0 -8
  119. package/docs/interfaces/ActionsExtendedInfo.html +0 -10
  120. package/docs/interfaces/ActionsQuery.html +0 -5
  121. package/docs/interfaces/ActionsResponse.html +0 -6
  122. package/docs/interfaces/AggregateMetrics.html +0 -12
  123. package/docs/interfaces/BlockFacts.html +0 -10
  124. package/docs/interfaces/BlockQuery.html +0 -6
  125. package/docs/interfaces/BlockResponse.html +0 -6
  126. package/docs/interfaces/BlockSummary.html +0 -8
  127. package/docs/interfaces/BlockSummaryResponse.html +0 -6
  128. package/docs/interfaces/DeltaEvent.html +0 -6
  129. package/docs/interfaces/DepositSplParams.html +0 -8
  130. package/docs/interfaces/Info.html +0 -3
  131. package/docs/interfaces/Market.html +0 -8
  132. package/docs/interfaces/MarketStats.html +0 -7
  133. package/docs/interfaces/MarketsStatsResponse.html +0 -2
  134. package/docs/interfaces/NordConfig.html +0 -24
  135. package/docs/interfaces/NordWebSocketClientEvents.html +0 -4
  136. package/docs/interfaces/NordWebSocketEvents.html +0 -8
  137. package/docs/interfaces/Order.html +0 -6
  138. package/docs/interfaces/OrderInfo.html +0 -6
  139. package/docs/interfaces/OrderbookEntry.html +0 -4
  140. package/docs/interfaces/OrderbookQuery.html +0 -6
  141. package/docs/interfaces/OrderbookResponse.html +0 -6
  142. package/docs/interfaces/OrderbookSubscription.html +0 -159
  143. package/docs/interfaces/PerpMarketStats.html +0 -5
  144. package/docs/interfaces/RollmanActionExtendedInfo.html +0 -4
  145. package/docs/interfaces/RollmanActionInfo.html +0 -4
  146. package/docs/interfaces/RollmanActionResponse.html +0 -4
  147. package/docs/interfaces/RollmanActionsResponse.html +0 -2
  148. package/docs/interfaces/RollmanBlockResponse.html +0 -3
  149. package/docs/interfaces/SPLTokenInfo.html +0 -10
  150. package/docs/interfaces/SolanaBridgeConfig.html +0 -12
  151. package/docs/interfaces/StateFacts.html +0 -10
  152. package/docs/interfaces/SubscriberConfig.html +0 -3
  153. package/docs/interfaces/TimestampResponse.html +0 -3
  154. package/docs/interfaces/Token.html +0 -5
  155. package/docs/interfaces/TokenInfo.html +0 -6
  156. package/docs/interfaces/Trade.html +0 -5
  157. package/docs/interfaces/TradeSubscription.html +0 -159
  158. package/docs/interfaces/Trades.html +0 -5
  159. package/docs/interfaces/TradesQuery.html +0 -6
  160. package/docs/interfaces/TradesResponse.html +0 -7
  161. package/docs/interfaces/TransferParams.html +0 -8
  162. package/docs/interfaces/UserAccountIdsQuery.html +0 -3
  163. package/docs/interfaces/UserAccountIdsResponse.html +0 -3
  164. package/docs/interfaces/WebSocketAccountUpdate.html +0 -6
  165. package/docs/interfaces/WebSocketDeltaUpdate.html +0 -9
  166. package/docs/interfaces/WebSocketSubscription.html +0 -4
  167. package/docs/interfaces/WebSocketTradeUpdate.html +0 -6
  168. package/docs/interfaces/WithdrawalClaim.html +0 -14
  169. package/docs/interfaces/WithdrawalParams.html +0 -8
  170. package/docs/modules.html +0 -1
  171. package/docs/types/BigIntValue.html +0 -2
  172. package/docs/types/SubscriptionPattern.html +0 -4
  173. package/docs/types/SubscriptionType.html +0 -2
  174. package/docs/types/WebSocketMessage.html +0 -1
  175. package/docs/variables/DEBUG_KEYS.html +0 -1
  176. package/docs/variables/DEFAULT_FUNDING_AMOUNTS.html +0 -1
  177. package/docs/variables/DEV_TOKEN_INFOS.html +0 -1
  178. package/docs/variables/DEV_URL.html +0 -1
  179. package/docs/variables/MAX_BUFFER_LEN.html +0 -1
  180. package/docs/variables/SESSION_TTL.html +0 -1
  181. package/docs/variables/WEBSERVER_DEV_URL.html +0 -1
  182. package/docs/variables/ZERO_DECIMAL.html +0 -1
  183. package/docs/variables/_private.html +0 -2
  184. package/idl-generate.sh +0 -4
  185. package/src/bridge/client.ts +0 -498
  186. package/src/bridge/const.ts +0 -53
  187. package/src/bridge/index.ts +0 -6
  188. package/src/bridge/types.ts +0 -129
  189. package/src/bridge/utils.ts +0 -140
  190. package/src/gen/common.ts +0 -297
  191. package/src/gen/nord.ts +0 -6716
  192. package/src/idl/index.ts +0 -2
package/dist/types.d.ts CHANGED
@@ -35,22 +35,11 @@ export interface NordConfig {
35
35
  bridgeVk: string;
36
36
  /** Solana cluster URL */
37
37
  solanaUrl: string;
38
- /** Whether to initialize WebSockets on creation, defaults to true */
39
- initWebSockets?: boolean;
40
- /**
41
- * Initial subscriptions for the trades WebSocket
42
- * Supports both formats:
43
- * - Legacy format: ["BTCUSDC", "ETHUSDC"]
44
- * - New format: ["trades@BTCUSDC", "trades@ETHUSDC"]
45
- */
46
- tradesSubscriptions?: SubscriptionPattern[];
47
38
  /**
48
- * Initial subscriptions for the deltas WebSocket
49
- * Supports both formats:
50
- * - Legacy format: ["BTCUSDC", "ETHUSDC"]
51
- * - New format: ["deltas@BTCUSDC", "deltas@ETHUSDC"]
39
+ * Whether to initialize WebSockets on creation, defaults to true
40
+ * @deprecated this is a funky api we're gonna be removing it
52
41
  */
53
- deltasSubscriptions?: SubscriptionPattern[];
42
+ initWebSockets?: boolean;
54
43
  }
55
44
  /**
56
45
  * Configuration options for the Nord client
@@ -132,7 +121,7 @@ export interface OrderInfo {
132
121
  size: number;
133
122
  account_id: number;
134
123
  }
135
- interface HashMap<T> {
124
+ export interface HashMap<T> {
136
125
  [key: number]: T;
137
126
  }
138
127
  export interface Account {
@@ -146,17 +135,16 @@ export interface Account {
146
135
  }
147
136
  /**
148
137
  * Query the transactions in the specified L2 block.
149
- * @field {number} block_number specifies the block number to query.
150
- * If not specified, transactions from latest block
151
- * are returned.
138
+ * block_number specifies the block number to query.
139
+ * If not specified, transactions from latest block are returned.
152
140
  */
153
141
  export interface BlockQuery {
154
142
  block_number?: number;
155
143
  }
156
144
  /**
157
145
  * Response for BlockQuery.
158
- * @field {number} block_number specifies the block number being returned.
159
- * @field {BlockActions} actions are the list of transactions from the block.
146
+ * block_number specifies the block number being returned.
147
+ * actions are the list of transactions from the block.
160
148
  */
161
149
  export interface BlockResponse {
162
150
  block_number: number;
@@ -164,26 +152,25 @@ export interface BlockResponse {
164
152
  }
165
153
  /**
166
154
  * Response for BlockSummaryQuery.
167
- * @field {BlockSummary} block_summary is the summary of upto the last N blocks.
168
- * The server can return fewer than last_n block summary if
169
- * fewer blocks are available or if it exceeds a max cap.
155
+ * block_summary is the summary of upto the last N blocks.
156
+ * The server can return fewer than last_n block summary if
157
+ * fewer blocks are available or if it exceeds a max cap.
170
158
  */
171
159
  export interface BlockSummaryResponse {
172
160
  block_summary: BlockSummary[];
173
161
  }
174
162
  /**
175
163
  * Query the action for the specified action id.
176
- * @field {number} action_id specifies the action to query.
164
+ * action_id specifies the action to query.
177
165
  */
178
166
  export interface ActionQuery {
179
167
  action_id: number;
180
168
  }
181
169
  /**
182
170
  * Response for ActionQuery.
183
- * @field {number} block_number the block the action is part of.
184
- * If the action is not yet included in any block,
185
- * null is returned.
186
- * @field {Action} the transaction.
171
+ * block_number the block the action is part of.
172
+ * If the action is not yet included in any block, null is returned.
173
+ * action the transaction.
187
174
  */
188
175
  export interface ActionResponse {
189
176
  block_number?: number;
@@ -191,26 +178,25 @@ export interface ActionResponse {
191
178
  }
192
179
  /**
193
180
  * Query the recent actions
194
- * @field {number} last_n requests last N actions.
195
- * @field {number} action_id specifies the action to query.
181
+ * last_n requests last N actions.
196
182
  */
197
183
  export interface ActionsQuery {
198
184
  last_n: number;
199
185
  }
200
186
  /**
201
187
  * Response for ActionsQuery.
202
- * @field {ActionsExtendedInfo} actions returns upto the last N actions.
203
- * The server can return fewer than last_n actions if
204
- * fewer actions are available or if it exceeds a max cap.
188
+ * actions returns upto the last N actions.
189
+ * The server can return fewer than last_n actions if
190
+ * fewer actions are available or if it exceeds a max cap.
205
191
  */
206
192
  export interface ActionsResponse {
207
193
  actions: ActionsExtendedInfo[];
208
194
  }
209
195
  /**
210
196
  * Block summary.
211
- * @field {number} block_number Block number.
212
- * @field {Action} from First action_id in the block.
213
- * @field {Action} to Last action_id in the block.
197
+ * block_number Block number.
198
+ * from_action_id First action_id in the block.
199
+ * to_action_id Last action_id in the block.
214
200
  */
215
201
  export interface BlockSummary {
216
202
  block_number: number;
@@ -219,9 +205,9 @@ export interface BlockSummary {
219
205
  }
220
206
  /**
221
207
  * Info about the block transaction.
222
- * @field {number} action_id is the action identifier.
223
- * @field {Action} action in protobuf format.
224
- * @field {number} exec_timestamp is the execution timestamp.
208
+ * action_id is the action identifier.
209
+ * action in protobuf format.
210
+ * exec_timestamp is the execution timestamp.
225
211
  */
226
212
  export interface ActionInfo {
227
213
  action_id: number;
@@ -230,11 +216,10 @@ export interface ActionInfo {
230
216
  }
231
217
  /**
232
218
  * Extended info about the block transaction.
233
- * @field {number} block_number the block the action is part of.
234
- * If the action is not yet included in any block,
235
- * null is returned.
236
- * @field {number} action_id of the action.
237
- * @field {Action} action the transaction.
219
+ * block_number the block the action is part of.
220
+ * If the action is not yet included in any block, null is returned.
221
+ * action_id of the action.
222
+ * action the transaction.
238
223
  */
239
224
  export interface ActionsExtendedInfo {
240
225
  block_number?: number;
@@ -243,11 +228,11 @@ export interface ActionsExtendedInfo {
243
228
  }
244
229
  /**
245
230
  * Aggregate metrics
246
- * @field {number} blocks_total: Total number of L2 blocks.
247
- * @field {number} tx_total: Total number of transactions.
248
- * @field {number} tx_tps: Transaction throughput.
249
- * @field {number} tx_tps_peak: Peak transaction throughput.
250
- * @field {number} request_latency_average: Average request latency.
231
+ * blocks_total: Total number of L2 blocks.
232
+ * tx_total: Total number of transactions.
233
+ * tx_tps: Transaction throughput.
234
+ * tx_tps_peak: Peak transaction throughput.
235
+ * request_latency_average: Average request latency.
251
236
  */
252
237
  export interface AggregateMetrics {
253
238
  blocks_total: number;
@@ -420,4 +405,3 @@ export interface WebSocketAccountUpdate {
420
405
  timestamp: number;
421
406
  }
422
407
  export type WebSocketMessage = WebSocketSubscription | WebSocketTradeUpdate | WebSocketDeltaUpdate | WebSocketAccountUpdate;
423
- export {};
package/dist/utils.d.ts CHANGED
@@ -3,7 +3,7 @@ import { KeyType, type Market, type Token } from "./types";
3
3
  import * as proto from "./gen/nord";
4
4
  import { ethers } from "ethers";
5
5
  import { RequestInfo, RequestInit, Response } from "node-fetch";
6
- import { BN } from "@coral-xyz/anchor";
6
+ import { Keypair } from "@solana/web3.js";
7
7
  export declare const SESSION_TTL: bigint;
8
8
  export declare const ZERO_DECIMAL: Decimal;
9
9
  export declare const MAX_BUFFER_LEN = 10000;
@@ -113,11 +113,4 @@ export declare function decodeLengthDelimited<T, M extends proto.MessageFns<T>>(
113
113
  export declare function checkPubKeyLength(keyType: KeyType, len: number): void;
114
114
  export declare function findMarket(markets: Market[], marketId: number): Market;
115
115
  export declare function findToken(tokens: Token[], tokenId: number): Token;
116
- /**
117
- * Convert a number to a BN with the specified number of decimals
118
- *
119
- * @param amount Amount as a number
120
- * @param decimals Number of decimal places
121
- * @returns Amount as a BN
122
- */
123
- export declare function toBN(amount: number, decimals: number): BN;
116
+ export declare function keypairFromPrivateKey(privateKey: string | Uint8Array): Keypair;
package/dist/utils.js CHANGED
@@ -18,7 +18,7 @@ exports.decodeLengthDelimited = decodeLengthDelimited;
18
18
  exports.checkPubKeyLength = checkPubKeyLength;
19
19
  exports.findMarket = findMarket;
20
20
  exports.findToken = findToken;
21
- exports.toBN = toBN;
21
+ exports.keypairFromPrivateKey = keypairFromPrivateKey;
22
22
  const decimal_js_1 = require("decimal.js");
23
23
  const ed25519_1 = require("@noble/curves/ed25519");
24
24
  const bls12_381_1 = require("@noble/curves/bls12-381");
@@ -28,7 +28,8 @@ const types_1 = require("./types");
28
28
  const wire_1 = require("@bufbuild/protobuf/wire");
29
29
  const ethers_1 = require("ethers");
30
30
  const node_fetch_1 = __importDefault(require("node-fetch"));
31
- const anchor_1 = require("@coral-xyz/anchor");
31
+ const web3_js_1 = require("@solana/web3.js");
32
+ const bs58_1 = __importDefault(require("bs58"));
32
33
  exports.SESSION_TTL = 60n * 60n * 24n * 30n;
33
34
  exports.ZERO_DECIMAL = new decimal_js_1.Decimal(0);
34
35
  exports.MAX_BUFFER_LEN = 10000;
@@ -257,20 +258,14 @@ function findToken(tokens, tokenId) {
257
258
  }
258
259
  return tokens[tokenId];
259
260
  }
260
- /**
261
- * Convert a number to a BN with the specified number of decimals
262
- *
263
- * @param amount Amount as a number
264
- * @param decimals Number of decimal places
265
- * @returns Amount as a BN
266
- */
267
- function toBN(amount, decimals) {
268
- const amountString = amount.toFixed(decimals);
269
- const [whole, fraction] = amountString.split(".");
270
- // Convert to smallest units (no decimals)
271
- const wholeBN = new anchor_1.BN(whole).mul(new anchor_1.BN(10).pow(new anchor_1.BN(decimals)));
272
- const fractionBN = fraction
273
- ? new anchor_1.BN(fraction.padEnd(decimals, "0").slice(0, decimals))
274
- : new anchor_1.BN(0);
275
- return wholeBN.add(fractionBN);
261
+ function keypairFromPrivateKey(privateKey) {
262
+ if (typeof privateKey === "string") {
263
+ if (!privateKey.startsWith("0x")) {
264
+ return web3_js_1.Keypair.fromSecretKey(bs58_1.default.decode(privateKey));
265
+ }
266
+ const hex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
267
+ const bytes = new Uint8Array(hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
268
+ return web3_js_1.Keypair.fromSecretKey(bytes);
269
+ }
270
+ return web3_js_1.Keypair.fromSecretKey(privateKey);
276
271
  }
package/package.json CHANGED
@@ -1,21 +1,9 @@
1
1
  {
2
2
  "name": "@n1xyz/nord-ts",
3
- "version": "0.0.16",
3
+ "version": "0.0.18-8121ed05.0",
4
4
  "description": "Typescript for Nord",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "scripts": {
8
- "dev": "nodemon --exec npx tsc",
9
- "build:proto": "./protoc-generate.sh",
10
- "build:idl": "./idl-generate.sh",
11
- "build": "pnpm run build:proto && pnpm run build:idl && pnpm exec tsc && pnpm run docs",
12
- "test": "pnpm exec jest",
13
- "docs": "pnpm exec typedoc --out ./docs ./src",
14
- "compile": "tsc",
15
- "clean": "rm -rf ./src/gen ./dist ./docs",
16
- "fmt": "prettier --write src tests",
17
- "ci": "eslint && prettier --check src tests"
18
- },
19
7
  "repository": {
20
8
  "type": "git",
21
9
  "url": "git+https://github.com/n1xyz/nord.git"
@@ -28,7 +16,7 @@
28
16
  "@jest/types": "^29.6.3",
29
17
  "@types/google-protobuf": "^3.15.10",
30
18
  "@types/jest": "^29.5.12",
31
- "@types/node": "^20.12.3",
19
+ "@types/node": "^22.15.29",
32
20
  "@types/node-fetch": "^2.6.9",
33
21
  "@types/ws": "^8.5.10",
34
22
  "@typescript-eslint/eslint-plugin": "^8.26.1",
@@ -45,17 +33,28 @@
45
33
  },
46
34
  "dependencies": {
47
35
  "@bufbuild/protobuf": "^2.0.0",
48
- "@coral-xyz/anchor": "^0.30.1",
49
36
  "@noble/curves": "^1.3.0",
50
37
  "@noble/ed25519": "^2.2.3",
51
38
  "@noble/hashes": "^1.3.2",
52
39
  "@solana/spl-token": "^0.4.13",
53
- "@solana/web3.js": "1.92.1",
40
+ "@solana/web3.js": "^1.98.2",
54
41
  "bs58": "^6.0.0",
55
42
  "decimal.js": "^10.4.3",
56
43
  "ethers": "^6.11.1",
57
44
  "node-fetch": "2.6.13",
58
45
  "tweetnacl": "^1.0.3",
59
- "ws": "^8.16.0"
46
+ "ws": "^8.16.0",
47
+ "@n1xyz/proton": "0.0.1-8121ed05.0"
48
+ },
49
+ "scripts": {
50
+ "dev": "nodemon --exec npx tsc",
51
+ "build:proto": "./protoc-generate.sh",
52
+ "build": "pnpm run build:proto && pnpm exec tsc && pnpm run docs",
53
+ "test": "pnpm exec jest",
54
+ "docs": "pnpm exec typedoc --out ./docs ./src",
55
+ "compile": "tsc",
56
+ "clean": "rm -rf ./src/gen ./dist ./docs",
57
+ "fmt": "prettier --write src tests",
58
+ "ci": "eslint && prettier --check src tests"
60
59
  }
61
- }
60
+ }
File without changes
@@ -317,11 +317,6 @@
317
317
  177
318
318
  ],
319
319
  "accounts": [
320
- {
321
- "name": "payer",
322
- "writable": true,
323
- "signer": true
324
- },
325
320
  {
326
321
  "name": "bridge",
327
322
  "writable": true
@@ -633,7 +628,39 @@
633
628
  }
634
629
  },
635
630
  {
636
- "name": "da_fact_state"
631
+ "name": "da_fact_state",
632
+ "pda": {
633
+ "seeds": [
634
+ {
635
+ "kind": "const",
636
+ "value": [
637
+ 100,
638
+ 97,
639
+ 95,
640
+ 102,
641
+ 97,
642
+ 99,
643
+ 116,
644
+ 95,
645
+ 115,
646
+ 116,
647
+ 111,
648
+ 114,
649
+ 97,
650
+ 103,
651
+ 101
652
+ ]
653
+ },
654
+ {
655
+ "kind": "account",
656
+ "path": "bridge"
657
+ },
658
+ {
659
+ "kind": "arg",
660
+ "path": "facts.da_commitment"
661
+ }
662
+ ]
663
+ }
637
664
  },
638
665
  {
639
666
  "name": "crumb_authority",
@@ -737,12 +764,15 @@
737
764
  "path": "bridge"
738
765
  },
739
766
  {
740
- "kind": "arg",
741
- "path": "asset"
767
+ "kind": "account",
768
+ "path": "mint"
742
769
  }
743
770
  ]
744
771
  }
745
772
  },
773
+ {
774
+ "name": "mint"
775
+ },
746
776
  {
747
777
  "name": "crumb_authority",
748
778
  "pda": {
@@ -779,10 +809,6 @@
779
809
  }
780
810
  ],
781
811
  "args": [
782
- {
783
- "name": "asset",
784
- "type": "pubkey"
785
- },
786
812
  {
787
813
  "name": "min_deposit",
788
814
  "type": "u64"
@@ -842,12 +868,15 @@
842
868
  "path": "bridge"
843
869
  },
844
870
  {
845
- "kind": "arg",
846
- "path": "asset"
871
+ "kind": "account",
872
+ "path": "mint"
847
873
  }
848
874
  ]
849
875
  }
850
876
  },
877
+ {
878
+ "name": "mint"
879
+ },
851
880
  {
852
881
  "name": "crumb_authority",
853
882
  "pda": {
@@ -888,10 +917,6 @@
888
917
  }
889
918
  ],
890
919
  "args": [
891
- {
892
- "name": "asset",
893
- "type": "pubkey"
894
- },
895
920
  {
896
921
  "name": "min_deposit",
897
922
  "type": "u64"
@@ -1192,19 +1217,6 @@
1192
1217
  227
1193
1218
  ]
1194
1219
  },
1195
- {
1196
- "name": "EffectNullifier",
1197
- "discriminator": [
1198
- 138,
1199
- 66,
1200
- 66,
1201
- 124,
1202
- 33,
1203
- 209,
1204
- 105,
1205
- 159
1206
- ]
1207
- },
1208
1220
  {
1209
1221
  "name": "FactStateStorage",
1210
1222
  "discriminator": [
@@ -1280,19 +1292,17 @@
1280
1292
  {
1281
1293
  "name": "da_commitment",
1282
1294
  "type": {
1283
- "array": [
1284
- "u8",
1285
- 32
1286
- ]
1295
+ "defined": {
1296
+ "name": "Commitment"
1297
+ }
1287
1298
  }
1288
1299
  },
1289
1300
  {
1290
1301
  "name": "effects_root",
1291
1302
  "type": {
1292
- "array": [
1293
- "u8",
1294
- 32
1295
- ]
1303
+ "defined": {
1304
+ "name": "Commitment"
1305
+ }
1296
1306
  }
1297
1307
  }
1298
1308
  ]
@@ -1334,6 +1344,20 @@
1334
1344
  ]
1335
1345
  }
1336
1346
  },
1347
+ {
1348
+ "name": "Commitment",
1349
+ "type": {
1350
+ "kind": "struct",
1351
+ "fields": [
1352
+ {
1353
+ "array": [
1354
+ "u8",
1355
+ 32
1356
+ ]
1357
+ }
1358
+ ]
1359
+ }
1360
+ },
1337
1361
  {
1338
1362
  "name": "Deposit",
1339
1363
  "type": {
@@ -1350,22 +1374,14 @@
1350
1374
  {
1351
1375
  "name": "prev_deposit_root",
1352
1376
  "type": {
1353
- "array": [
1354
- "u8",
1355
- 32
1356
- ]
1377
+ "defined": {
1378
+ "name": "Commitment"
1379
+ }
1357
1380
  }
1358
1381
  }
1359
1382
  ]
1360
1383
  }
1361
1384
  },
1362
- {
1363
- "name": "EffectNullifier",
1364
- "type": {
1365
- "kind": "struct",
1366
- "fields": []
1367
- }
1368
- },
1369
1385
  {
1370
1386
  "name": "FactState",
1371
1387
  "type": {
@@ -1404,19 +1420,17 @@
1404
1420
  {
1405
1421
  "name": "app_state_commitment",
1406
1422
  "type": {
1407
- "array": [
1408
- "u8",
1409
- 32
1410
- ]
1423
+ "defined": {
1424
+ "name": "Commitment"
1425
+ }
1411
1426
  }
1412
1427
  },
1413
1428
  {
1414
1429
  "name": "deposit_root",
1415
1430
  "type": {
1416
- "array": [
1417
- "u8",
1418
- 32
1419
- ]
1431
+ "defined": {
1432
+ "name": "Commitment"
1433
+ }
1420
1434
  }
1421
1435
  },
1422
1436
  {
@@ -1471,10 +1485,9 @@
1471
1485
  "name": "proof",
1472
1486
  "type": {
1473
1487
  "vec": {
1474
- "array": [
1475
- "u8",
1476
- 32
1477
- ]
1488
+ "defined": {
1489
+ "name": "Commitment"
1490
+ }
1478
1491
  }
1479
1492
  }
1480
1493
  },
package/src/index.ts CHANGED
@@ -9,16 +9,13 @@ export * from "./nord";
9
9
  // Export WebSocket modules
10
10
  export * from "./websocket/index";
11
11
 
12
- // Export bridge modules
13
- export * from "./bridge/client";
14
- export * from "./bridge/types";
12
+ // Re-export proton bridge functionality for backward compatibility
15
13
  export {
16
- bridgeToBN,
17
- fromBN,
18
- keypairFromPrivateKey,
19
- makeSigningFunction,
20
- findPda,
21
- bufferToHex,
22
- hexToBuffer,
23
- shortenPublicKey,
24
- } from "./bridge/utils";
14
+ ProtonClient,
15
+ buildDepositTx,
16
+ createTokenAccountIfNeeded,
17
+ type DepositSplParams,
18
+ type WithdrawalParams,
19
+ type WithdrawalClaim,
20
+ type SPLTokenInfo,
21
+ } from "@n1xyz/proton";
@@ -198,7 +198,7 @@ async function withdrawImpl(
198
198
  tokenId: number;
199
199
  amount: Decimal.Value;
200
200
  },
201
- ): Promise<void> {
201
+ ): Promise<{ actionId: bigint } & proto.Receipt_WithdrawResult> {
202
202
  const amount = toScaledU64(params.amount, params.sizeDecimals);
203
203
 
204
204
  if (amount <= 0) {
@@ -218,7 +218,18 @@ async function withdrawImpl(
218
218
  },
219
219
  };
220
220
 
221
- await sendAction(sendFn, (m) => sessionSign(signFn, m), action, "withdraw");
221
+ const resp = await sendAction(
222
+ sendFn,
223
+ (m) => sessionSign(signFn, m),
224
+ action,
225
+ "withdraw",
226
+ );
227
+
228
+ if (resp.kind?.$case === "withdrawResult") {
229
+ return { actionId: resp.actionId, ...resp.kind.value };
230
+ } else {
231
+ throw new Error(`Unexpected receipt kind ${resp.kind?.$case}`);
232
+ }
222
233
  }
223
234
 
224
235
  export async function withdraw(
@@ -232,7 +243,7 @@ export async function withdraw(
232
243
  tokenId: number;
233
244
  amount: number;
234
245
  },
235
- ): Promise<void> {
246
+ ): Promise<{ actionId: bigint } & proto.Receipt_WithdrawResult> {
236
247
  return withdrawImpl(
237
248
  makeSendHttp(serverUrl),
238
249
  signFn,
@@ -26,9 +26,11 @@ export async function getTimestamp(webServerUrl: string): Promise<bigint> {
26
26
  * @returns Next action nonce
27
27
  * @throws {NordError} If the request fails
28
28
  */
29
- export async function getActionNonce(webServerUrl: string): Promise<number> {
29
+ export async function getLastEventNonce(webServerUrl: string): Promise<number> {
30
30
  try {
31
- const response = await checkedFetch(`${webServerUrl}/action_nonce`);
31
+ const response = await checkedFetch(
32
+ `${webServerUrl}/event/last-acked-nonce`,
33
+ );
32
34
  const data = await response.json();
33
35
  return data.nonce;
34
36
  } catch (error) {
@@ -78,11 +78,8 @@ export async function getUserAccountIds(
78
78
  query: UserAccountIdsQuery,
79
79
  ): Promise<UserAccountIdsResponse> {
80
80
  try {
81
- const params = new URLSearchParams();
82
- params.append("pubkey", query.pubkey);
83
-
84
81
  const response = await checkedFetch(
85
- `${webServerUrl}/user?${params.toString()}`,
82
+ `${webServerUrl}/user/${query.pubkey.toString()}`,
86
83
  );
87
84
  return await response.json();
88
85
  } catch (error) {
@@ -73,9 +73,9 @@ export async function queryRecentActions(
73
73
  */
74
74
  export async function getLastActionId(webServerUrl: string): Promise<number> {
75
75
  try {
76
- const response = await checkedFetch(`${webServerUrl}/last_actionid`);
76
+ const response = await checkedFetch(`${webServerUrl}/actions/last-id`);
77
77
  const data = await response.json();
78
- return data.last_actionid;
78
+ return data;
79
79
  } catch (error) {
80
80
  throw new NordError("Failed to get last action ID", {
81
81
  cause: error,