@n1xyz/nord-ts 0.0.8 → 0.0.10

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.
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from "events";
2
- import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics, BlockQuery, BlockResponse, BlockSummaryResponse, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
2
+ import { Account, ActionQuery, ActionResponse, ActionsResponse, AggregateMetrics, Info, Market, MarketsStatsResponse, NordConfig, OrderbookQuery, OrderbookResponse, PeakTpsPeriodUnit, RollmanActionResponse, RollmanActionsResponse, Token, TradesQuery, TradesResponse, UserAccountIdsQuery, UserAccountIdsResponse } from "../../types";
3
3
  import { NordWebSocketClient } from "../../websocket/index";
4
4
  import { OrderbookSubscription, TradeSubscription } from "../models/Subscriber";
5
5
  /**
@@ -116,29 +116,6 @@ export declare class Nord {
116
116
  * @throws {NordError} If the request fails
117
117
  */
118
118
  marketsStats(): Promise<MarketsStatsResponse>;
119
- /**
120
- * Query a specific block
121
- *
122
- * @param query - Block query parameters
123
- * @returns Block response
124
- * @throws {NordError} If the request fails
125
- */
126
- queryBlock(query: BlockQuery): Promise<BlockResponse>;
127
- /**
128
- * Query the last N blocks
129
- *
130
- * @returns Block response for the last N blocks
131
- * @throws {NordError} If the request fails
132
- */
133
- queryLastNBlocks(): Promise<BlockResponse>;
134
- /**
135
- * Query recent blocks
136
- *
137
- * @param last_n - Number of recent blocks to query
138
- * @returns Block summary response
139
- * @throws {NordError} If the request fails
140
- */
141
- queryRecentBlocks(last_n: number): Promise<BlockSummaryResponse>;
142
119
  /**
143
120
  * Query a specific action
144
121
  *
@@ -150,11 +127,19 @@ export declare class Nord {
150
127
  /**
151
128
  * Query recent actions
152
129
  *
153
- * @param last_n - Number of recent actions to query
130
+ * @param from - Starting action index
131
+ * @param to - Ending action index
154
132
  * @returns Actions response
155
133
  * @throws {NordError} If the request fails
156
134
  */
157
- queryRecentActions(last_n: number): Promise<ActionsResponse>;
135
+ queryRecentActions(from: number, to: number): Promise<ActionsResponse>;
136
+ /**
137
+ * Get the last action ID
138
+ *
139
+ * @returns Last action ID
140
+ * @throws {NordError} If the request fails
141
+ */
142
+ getLastActionId(): Promise<number>;
158
143
  /**
159
144
  * Fetch aggregate metrics from the Nord API
160
145
  *
@@ -195,22 +180,6 @@ export declare class Nord {
195
180
  * @throws {NordError} If the request fails
196
181
  */
197
182
  getTotalTransactions(): Promise<number>;
198
- /**
199
- * Query a block from Rollman
200
- *
201
- * @param query - Block query parameters
202
- * @returns Rollman block response
203
- * @throws {NordError} If the request fails
204
- */
205
- blockQueryRollman(query: BlockQuery): Promise<RollmanBlockResponse>;
206
- /**
207
- * Query block summaries from Rollman
208
- *
209
- * @param last_n - Number of recent blocks to query
210
- * @returns Block summary response
211
- * @throws {NordError} If the request fails
212
- */
213
- blockSummaryQueryRollman(last_n: number): Promise<BlockSummaryResponse>;
214
183
  /**
215
184
  * Query an action from Rollman
216
185
  *
@@ -184,35 +184,6 @@ class Nord {
184
184
  async marketsStats() {
185
185
  return market.marketsStats(this.webServerUrl);
186
186
  }
187
- /**
188
- * Query a specific block
189
- *
190
- * @param query - Block query parameters
191
- * @returns Block response
192
- * @throws {NordError} If the request fails
193
- */
194
- async queryBlock(query) {
195
- return queries.queryBlock(this.webServerUrl, query);
196
- }
197
- /**
198
- * Query the last N blocks
199
- *
200
- * @returns Block response for the last N blocks
201
- * @throws {NordError} If the request fails
202
- */
203
- async queryLastNBlocks() {
204
- return queries.queryLastNBlocks(this.webServerUrl);
205
- }
206
- /**
207
- * Query recent blocks
208
- *
209
- * @param last_n - Number of recent blocks to query
210
- * @returns Block summary response
211
- * @throws {NordError} If the request fails
212
- */
213
- async queryRecentBlocks(last_n) {
214
- return queries.queryRecentBlocks(this.webServerUrl, last_n);
215
- }
216
187
  /**
217
188
  * Query a specific action
218
189
  *
@@ -226,12 +197,22 @@ class Nord {
226
197
  /**
227
198
  * Query recent actions
228
199
  *
229
- * @param last_n - Number of recent actions to query
200
+ * @param from - Starting action index
201
+ * @param to - Ending action index
230
202
  * @returns Actions response
231
203
  * @throws {NordError} If the request fails
232
204
  */
233
- async queryRecentActions(last_n) {
234
- return queries.queryRecentActions(this.webServerUrl, last_n);
205
+ async queryRecentActions(from, to) {
206
+ return queries.queryRecentActions(this.webServerUrl, from, to);
207
+ }
208
+ /**
209
+ * Get the last action ID
210
+ *
211
+ * @returns Last action ID
212
+ * @throws {NordError} If the request fails
213
+ */
214
+ async getLastActionId() {
215
+ return queries.getLastActionId(this.webServerUrl);
235
216
  }
236
217
  /**
237
218
  * Fetch aggregate metrics from the Nord API
@@ -283,26 +264,6 @@ class Nord {
283
264
  async getTotalTransactions() {
284
265
  return metrics.getTotalTransactions(this.webServerUrl);
285
266
  }
286
- /**
287
- * Query a block from Rollman
288
- *
289
- * @param query - Block query parameters
290
- * @returns Rollman block response
291
- * @throws {NordError} If the request fails
292
- */
293
- async blockQueryRollman(query) {
294
- return queries.blockQueryRollman(this.webServerUrl, query);
295
- }
296
- /**
297
- * Query block summaries from Rollman
298
- *
299
- * @param last_n - Number of recent blocks to query
300
- * @returns Block summary response
301
- * @throws {NordError} If the request fails
302
- */
303
- async blockSummaryQueryRollman(last_n) {
304
- return queries.blockSummaryQueryRollman(this.webServerUrl, last_n);
305
- }
306
267
  /**
307
268
  * Query an action from Rollman
308
269
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1xyz/nord-ts",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Typescript for Nord",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -110,13 +110,13 @@ export class SolanaBridgeClient {
110
110
  }
111
111
 
112
112
  /**
113
- * Find the asset whitelisted PDA for a token mint
113
+ * Find the asset config PDA for a token mint
114
114
  *
115
115
  * @param mint Token mint address
116
116
  * @returns [PDA, bump]
117
117
  */
118
- async findAssetWhitelistedPda(mint: PublicKey): Promise<[PublicKey, number]> {
119
- return this.findPda(PdaSeedType.AssetWhitelisted, mint);
118
+ async findAssetConfigPda(mint: PublicKey): Promise<[PublicKey, number]> {
119
+ return this.findPda(PdaSeedType.AssetConfig, mint);
120
120
  }
121
121
 
122
122
  /**
@@ -195,7 +195,7 @@ export class SolanaBridgeClient {
195
195
  */
196
196
  async depositSpl(params: DepositSplParams): Promise<string> {
197
197
  const [contractStorage] = await this.findContractStoragePda();
198
- const [assetWhitelisted] = await this.findAssetWhitelistedPda(params.mint);
198
+ const [assetWhitelisted] = await this.findAssetConfigPda(params.mint);
199
199
 
200
200
  // Get the last deposit index from contract storage
201
201
  const contractStorageAccount =
@@ -300,7 +300,7 @@ export class SolanaBridgeClient {
300
300
  */
301
301
  async whitelistAsset(mint: PublicKey, signer: Keypair): Promise<string> {
302
302
  const [contractStorage] = await this.findContractStoragePda();
303
- const [assetWhitelisted] = await this.findAssetWhitelistedPda(mint);
303
+ const [assetWhitelisted] = await this.findAssetConfigPda(mint);
304
304
 
305
305
  // Build the transaction
306
306
  const tx = await this.program.methods
@@ -118,7 +118,7 @@ export interface TransferParams {
118
118
  */
119
119
  export enum PdaSeedType {
120
120
  ContractStorage = "contract_storage",
121
- AssetWhitelisted = "asset_whitelisted",
121
+ AssetConfig = "asset_config",
122
122
  DepositStorage = "deposit_storage",
123
123
  BlockStorage = "block_storage",
124
124
  WithdrawalNullifier = "withdrawal_nullifier",
package/src/idl/bridge.ts CHANGED
@@ -43,14 +43,13 @@ export const BRIDGE_IDL: Idl = {
43
43
  },
44
44
  },
45
45
  {
46
- name: "asset_whitelisted",
46
+ name: "asset_config",
47
47
  pda: {
48
48
  seeds: [
49
49
  {
50
50
  kind: "const",
51
51
  value: [
52
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
53
- 115, 116, 101, 100,
52
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
54
53
  ],
55
54
  },
56
55
  {
@@ -82,6 +81,34 @@ export const BRIDGE_IDL: Idl = {
82
81
  {
83
82
  name: "to_account",
84
83
  writable: true,
84
+ pda: {
85
+ seeds: [
86
+ {
87
+ kind: "const",
88
+ value: [
89
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
90
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
91
+ 15, 16, 9, 188,
92
+ ],
93
+ },
94
+ {
95
+ kind: "account",
96
+ path: "token_program",
97
+ },
98
+ {
99
+ kind: "account",
100
+ path: "from_account.mint",
101
+ },
102
+ ],
103
+ program: {
104
+ kind: "const",
105
+ value: [
106
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
107
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
108
+ 219, 233, 248, 89,
109
+ ],
110
+ },
111
+ },
85
112
  },
86
113
  {
87
114
  name: "token_program",
@@ -98,6 +125,34 @@ export const BRIDGE_IDL: Idl = {
98
125
  },
99
126
  ],
100
127
  },
128
+ {
129
+ name: "emit_crumb",
130
+ discriminator: [96, 96, 18, 122, 83, 60, 102, 37],
131
+ accounts: [
132
+ {
133
+ name: "contract_storage",
134
+ docs: [
135
+ "Need a PDA to ensure that only this contract is allowed to",
136
+ "call this instruction; the contract storage account is",
137
+ "chosen since pretty much every other ix uses it, so this",
138
+ "avoids having to introduce a new account.",
139
+ ],
140
+ signer: true,
141
+ pda: {
142
+ seeds: [
143
+ {
144
+ kind: "const",
145
+ value: [
146
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
147
+ 97, 103, 101,
148
+ ],
149
+ },
150
+ ],
151
+ },
152
+ },
153
+ ],
154
+ args: [],
155
+ },
101
156
  {
102
157
  name: "finalize_block",
103
158
  discriminator: [63, 101, 92, 132, 135, 251, 98, 177],
@@ -161,6 +216,20 @@ export const BRIDGE_IDL: Idl = {
161
216
  writable: true,
162
217
  signer: true,
163
218
  },
219
+ {
220
+ name: "contract_storage",
221
+ pda: {
222
+ seeds: [
223
+ {
224
+ kind: "const",
225
+ value: [
226
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
227
+ 97, 103, 101,
228
+ ],
229
+ },
230
+ ],
231
+ },
232
+ },
164
233
  {
165
234
  name: "fact_state_storage",
166
235
  writable: true,
@@ -203,11 +272,6 @@ export const BRIDGE_IDL: Idl = {
203
272
  writable: true,
204
273
  signer: true,
205
274
  },
206
- {
207
- name: "program",
208
- signer: true,
209
- address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
210
- },
211
275
  {
212
276
  name: "contract_storage",
213
277
  writable: true,
@@ -233,6 +297,10 @@ export const BRIDGE_IDL: Idl = {
233
297
  name: "operator",
234
298
  type: "pubkey",
235
299
  },
300
+ {
301
+ name: "challenge_period_slots",
302
+ type: "u64",
303
+ },
236
304
  {
237
305
  name: "initial_app_state_commitment",
238
306
  type: {
@@ -307,6 +375,58 @@ export const BRIDGE_IDL: Idl = {
307
375
  },
308
376
  ],
309
377
  },
378
+ {
379
+ name: "set_min_deposit",
380
+ discriminator: [15, 182, 74, 248, 251, 148, 186, 171],
381
+ accounts: [
382
+ {
383
+ name: "operator",
384
+ signer: true,
385
+ },
386
+ {
387
+ name: "contract_storage",
388
+ pda: {
389
+ seeds: [
390
+ {
391
+ kind: "const",
392
+ value: [
393
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
394
+ 97, 103, 101,
395
+ ],
396
+ },
397
+ ],
398
+ },
399
+ },
400
+ {
401
+ name: "asset_config",
402
+ writable: true,
403
+ pda: {
404
+ seeds: [
405
+ {
406
+ kind: "const",
407
+ value: [
408
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
409
+ ],
410
+ },
411
+ {
412
+ kind: "arg",
413
+ path: "asset",
414
+ },
415
+ ],
416
+ },
417
+ },
418
+ ],
419
+ args: [
420
+ {
421
+ name: "asset",
422
+ type: "pubkey",
423
+ },
424
+ {
425
+ name: "min_deposit",
426
+ type: "u64",
427
+ },
428
+ ],
429
+ },
310
430
  {
311
431
  name: "whitelist_asset",
312
432
  discriminator: [113, 64, 172, 191, 33, 33, 57, 18],
@@ -331,15 +451,14 @@ export const BRIDGE_IDL: Idl = {
331
451
  },
332
452
  },
333
453
  {
334
- name: "asset_whitelisted",
454
+ name: "asset_config",
335
455
  writable: true,
336
456
  pda: {
337
457
  seeds: [
338
458
  {
339
459
  kind: "const",
340
460
  value: [
341
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
342
- 115, 116, 101, 100,
461
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
343
462
  ],
344
463
  },
345
464
  {
@@ -359,6 +478,10 @@ export const BRIDGE_IDL: Idl = {
359
478
  name: "asset",
360
479
  type: "pubkey",
361
480
  },
481
+ {
482
+ name: "min_deposit",
483
+ type: "u64",
484
+ },
362
485
  ],
363
486
  },
364
487
  {
@@ -413,6 +536,34 @@ export const BRIDGE_IDL: Idl = {
413
536
  {
414
537
  name: "from_account",
415
538
  writable: true,
539
+ pda: {
540
+ seeds: [
541
+ {
542
+ kind: "const",
543
+ value: [
544
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
545
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
546
+ 15, 16, 9, 188,
547
+ ],
548
+ },
549
+ {
550
+ kind: "account",
551
+ path: "token_program",
552
+ },
553
+ {
554
+ kind: "account",
555
+ path: "to_account.mint",
556
+ },
557
+ ],
558
+ program: {
559
+ kind: "const",
560
+ value: [
561
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
562
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
563
+ 219, 233, 248, 89,
564
+ ],
565
+ },
566
+ },
416
567
  },
417
568
  {
418
569
  name: "to_account",
@@ -429,6 +580,20 @@ export const BRIDGE_IDL: Idl = {
429
580
  ],
430
581
  },
431
582
  },
583
+ {
584
+ name: "contract_storage",
585
+ pda: {
586
+ seeds: [
587
+ {
588
+ kind: "const",
589
+ value: [
590
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
591
+ 97, 103, 101,
592
+ ],
593
+ },
594
+ ],
595
+ },
596
+ },
432
597
  {
433
598
  name: "token_program",
434
599
  },
@@ -451,8 +616,8 @@ export const BRIDGE_IDL: Idl = {
451
616
  ],
452
617
  accounts: [
453
618
  {
454
- name: "AssetWhitelisted",
455
- discriminator: [170, 42, 144, 120, 189, 54, 255, 166],
619
+ name: "AssetConfig",
620
+ discriminator: [57, 112, 247, 166, 247, 64, 140, 23],
456
621
  },
457
622
  {
458
623
  name: "Block",
@@ -477,10 +642,15 @@ export const BRIDGE_IDL: Idl = {
477
642
  ],
478
643
  types: [
479
644
  {
480
- name: "AssetWhitelisted",
645
+ name: "AssetConfig",
481
646
  type: {
482
647
  kind: "struct",
483
- fields: [],
648
+ fields: [
649
+ {
650
+ name: "min_deposit",
651
+ type: "u64",
652
+ },
653
+ ],
484
654
  },
485
655
  },
486
656
  {
@@ -500,6 +670,10 @@ export const BRIDGE_IDL: Idl = {
500
670
  name: "finalized",
501
671
  type: "bool",
502
672
  },
673
+ {
674
+ name: "slot_proposed",
675
+ type: "u64",
676
+ },
503
677
  ],
504
678
  },
505
679
  },
@@ -548,6 +722,10 @@ export const BRIDGE_IDL: Idl = {
548
722
  name: "operator",
549
723
  type: "pubkey",
550
724
  },
725
+ {
726
+ name: "challenge_period_slots",
727
+ type: "u64",
728
+ },
551
729
  {
552
730
  name: "last_block_id",
553
731
  type: "u64",
@@ -688,6 +866,22 @@ export const BRIDGE_IDL: Idl = {
688
866
  name: "block_id",
689
867
  type: "u64",
690
868
  },
869
+ {
870
+ name: "proof",
871
+ type: {
872
+ vec: {
873
+ array: ["u8", 32],
874
+ },
875
+ },
876
+ },
877
+ {
878
+ name: "leaf_index",
879
+ type: "u64",
880
+ },
881
+ {
882
+ name: "leaves_count",
883
+ type: "u64",
884
+ },
691
885
  ],
692
886
  },
693
887
  },