@n1xyz/nord-ts 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.9",
4
4
  "description": "Typescript for Nord",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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,38 @@ 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
+ },
112
+ },
113
+ {
114
+ name: "program",
115
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
85
116
  },
86
117
  {
87
118
  name: "token_program",
@@ -98,6 +129,34 @@ export const BRIDGE_IDL: Idl = {
98
129
  },
99
130
  ],
100
131
  },
132
+ {
133
+ name: "emit_crumb",
134
+ discriminator: [96, 96, 18, 122, 83, 60, 102, 37],
135
+ accounts: [
136
+ {
137
+ name: "contract_storage",
138
+ docs: [
139
+ "Need a PDA to ensure that only this contract is allowed to",
140
+ "call this instruction; the contract storage account is",
141
+ "chosen since pretty much every other ix uses it, so this",
142
+ "avoids having to introduce a new account.",
143
+ ],
144
+ signer: true,
145
+ pda: {
146
+ seeds: [
147
+ {
148
+ kind: "const",
149
+ value: [
150
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
151
+ 97, 103, 101,
152
+ ],
153
+ },
154
+ ],
155
+ },
156
+ },
157
+ ],
158
+ args: [],
159
+ },
101
160
  {
102
161
  name: "finalize_block",
103
162
  discriminator: [63, 101, 92, 132, 135, 251, 98, 177],
@@ -140,6 +199,10 @@ export const BRIDGE_IDL: Idl = {
140
199
  ],
141
200
  },
142
201
  },
202
+ {
203
+ name: "program",
204
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
205
+ },
143
206
  {
144
207
  name: "system_program",
145
208
  address: "11111111111111111111111111111111",
@@ -161,6 +224,20 @@ export const BRIDGE_IDL: Idl = {
161
224
  writable: true,
162
225
  signer: true,
163
226
  },
227
+ {
228
+ name: "contract_storage",
229
+ pda: {
230
+ seeds: [
231
+ {
232
+ kind: "const",
233
+ value: [
234
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
235
+ 97, 103, 101,
236
+ ],
237
+ },
238
+ ],
239
+ },
240
+ },
164
241
  {
165
242
  name: "fact_state_storage",
166
243
  writable: true,
@@ -180,6 +257,10 @@ export const BRIDGE_IDL: Idl = {
180
257
  ],
181
258
  },
182
259
  },
260
+ {
261
+ name: "program",
262
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
263
+ },
183
264
  {
184
265
  name: "system_program",
185
266
  address: "11111111111111111111111111111111",
@@ -233,6 +314,10 @@ export const BRIDGE_IDL: Idl = {
233
314
  name: "operator",
234
315
  type: "pubkey",
235
316
  },
317
+ {
318
+ name: "challenge_period_slots",
319
+ type: "u64",
320
+ },
236
321
  {
237
322
  name: "initial_app_state_commitment",
238
323
  type: {
@@ -291,6 +376,10 @@ export const BRIDGE_IDL: Idl = {
291
376
  ],
292
377
  },
293
378
  },
379
+ {
380
+ name: "program",
381
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
382
+ },
294
383
  {
295
384
  name: "system_program",
296
385
  address: "11111111111111111111111111111111",
@@ -307,6 +396,62 @@ export const BRIDGE_IDL: Idl = {
307
396
  },
308
397
  ],
309
398
  },
399
+ {
400
+ name: "set_min_deposit",
401
+ discriminator: [15, 182, 74, 248, 251, 148, 186, 171],
402
+ accounts: [
403
+ {
404
+ name: "operator",
405
+ signer: true,
406
+ },
407
+ {
408
+ name: "contract_storage",
409
+ pda: {
410
+ seeds: [
411
+ {
412
+ kind: "const",
413
+ value: [
414
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
415
+ 97, 103, 101,
416
+ ],
417
+ },
418
+ ],
419
+ },
420
+ },
421
+ {
422
+ name: "asset_config",
423
+ writable: true,
424
+ pda: {
425
+ seeds: [
426
+ {
427
+ kind: "const",
428
+ value: [
429
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
430
+ ],
431
+ },
432
+ {
433
+ kind: "arg",
434
+ path: "asset",
435
+ },
436
+ ],
437
+ },
438
+ },
439
+ {
440
+ name: "program",
441
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
442
+ },
443
+ ],
444
+ args: [
445
+ {
446
+ name: "asset",
447
+ type: "pubkey",
448
+ },
449
+ {
450
+ name: "min_deposit",
451
+ type: "u64",
452
+ },
453
+ ],
454
+ },
310
455
  {
311
456
  name: "whitelist_asset",
312
457
  discriminator: [113, 64, 172, 191, 33, 33, 57, 18],
@@ -331,15 +476,14 @@ export const BRIDGE_IDL: Idl = {
331
476
  },
332
477
  },
333
478
  {
334
- name: "asset_whitelisted",
479
+ name: "asset_config",
335
480
  writable: true,
336
481
  pda: {
337
482
  seeds: [
338
483
  {
339
484
  kind: "const",
340
485
  value: [
341
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
342
- 115, 116, 101, 100,
486
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
343
487
  ],
344
488
  },
345
489
  {
@@ -349,6 +493,10 @@ export const BRIDGE_IDL: Idl = {
349
493
  ],
350
494
  },
351
495
  },
496
+ {
497
+ name: "program",
498
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
499
+ },
352
500
  {
353
501
  name: "system_program",
354
502
  address: "11111111111111111111111111111111",
@@ -359,6 +507,10 @@ export const BRIDGE_IDL: Idl = {
359
507
  name: "asset",
360
508
  type: "pubkey",
361
509
  },
510
+ {
511
+ name: "min_deposit",
512
+ type: "u64",
513
+ },
362
514
  ],
363
515
  },
364
516
  {
@@ -413,6 +565,34 @@ export const BRIDGE_IDL: Idl = {
413
565
  {
414
566
  name: "from_account",
415
567
  writable: true,
568
+ pda: {
569
+ seeds: [
570
+ {
571
+ kind: "const",
572
+ value: [
573
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
574
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
575
+ 15, 16, 9, 188,
576
+ ],
577
+ },
578
+ {
579
+ kind: "account",
580
+ path: "token_program",
581
+ },
582
+ {
583
+ kind: "account",
584
+ path: "to_account.mint",
585
+ },
586
+ ],
587
+ program: {
588
+ kind: "const",
589
+ value: [
590
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
591
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
592
+ 219, 233, 248, 89,
593
+ ],
594
+ },
595
+ },
416
596
  },
417
597
  {
418
598
  name: "to_account",
@@ -429,6 +609,24 @@ export const BRIDGE_IDL: Idl = {
429
609
  ],
430
610
  },
431
611
  },
612
+ {
613
+ name: "contract_storage",
614
+ pda: {
615
+ seeds: [
616
+ {
617
+ kind: "const",
618
+ value: [
619
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
620
+ 97, 103, 101,
621
+ ],
622
+ },
623
+ ],
624
+ },
625
+ },
626
+ {
627
+ name: "program",
628
+ address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
629
+ },
432
630
  {
433
631
  name: "token_program",
434
632
  },
@@ -451,8 +649,8 @@ export const BRIDGE_IDL: Idl = {
451
649
  ],
452
650
  accounts: [
453
651
  {
454
- name: "AssetWhitelisted",
455
- discriminator: [170, 42, 144, 120, 189, 54, 255, 166],
652
+ name: "AssetConfig",
653
+ discriminator: [57, 112, 247, 166, 247, 64, 140, 23],
456
654
  },
457
655
  {
458
656
  name: "Block",
@@ -477,10 +675,15 @@ export const BRIDGE_IDL: Idl = {
477
675
  ],
478
676
  types: [
479
677
  {
480
- name: "AssetWhitelisted",
678
+ name: "AssetConfig",
481
679
  type: {
482
680
  kind: "struct",
483
- fields: [],
681
+ fields: [
682
+ {
683
+ name: "min_deposit",
684
+ type: "u64",
685
+ },
686
+ ],
484
687
  },
485
688
  },
486
689
  {
@@ -500,6 +703,10 @@ export const BRIDGE_IDL: Idl = {
500
703
  name: "finalized",
501
704
  type: "bool",
502
705
  },
706
+ {
707
+ name: "slot_proposed",
708
+ type: "u64",
709
+ },
503
710
  ],
504
711
  },
505
712
  },
@@ -548,6 +755,10 @@ export const BRIDGE_IDL: Idl = {
548
755
  name: "operator",
549
756
  type: "pubkey",
550
757
  },
758
+ {
759
+ name: "challenge_period_slots",
760
+ type: "u64",
761
+ },
551
762
  {
552
763
  name: "last_block_id",
553
764
  type: "u64",
@@ -688,6 +899,22 @@ export const BRIDGE_IDL: Idl = {
688
899
  name: "block_id",
689
900
  type: "u64",
690
901
  },
902
+ {
903
+ name: "proof",
904
+ type: {
905
+ vec: {
906
+ array: ["u8", 32],
907
+ },
908
+ },
909
+ },
910
+ {
911
+ name: "leaf_index",
912
+ type: "u64",
913
+ },
914
+ {
915
+ name: "leaves_count",
916
+ type: "u64",
917
+ },
691
918
  ],
692
919
  },
693
920
  },
@@ -699,4 +926,4 @@ export const BRIDGE_IDL: Idl = {
699
926
  },
700
927
  },
701
928
  ],
702
- };
929
+ };
@@ -12,74 +12,6 @@ import {
12
12
  import { checkedFetch } from "../../utils";
13
13
  import { NordError } from "../utils/NordError";
14
14
 
15
- /**
16
- * Query a specific block
17
- *
18
- * @param webServerUrl - Base URL for the Nord web server
19
- * @param query - Block query parameters
20
- * @returns Block response
21
- * @throws {NordError} If the request fails
22
- */
23
- export async function queryBlock(
24
- webServerUrl: string,
25
- query: BlockQuery,
26
- ): Promise<BlockResponse> {
27
- try {
28
- const params = new URLSearchParams();
29
- if (query.block_number !== undefined) {
30
- params.append("block_height", query.block_number.toString());
31
- }
32
-
33
- const response = await checkedFetch(
34
- `${webServerUrl}/block?${params.toString()}`,
35
- );
36
- return await response.json();
37
- } catch (error) {
38
- throw new NordError("Failed to query block", { cause: error });
39
- }
40
- }
41
-
42
- /**
43
- * Query the last N blocks
44
- *
45
- * @param webServerUrl - Base URL for the Nord web server
46
- * @returns Block response for the last N blocks
47
- * @throws {NordError} If the request fails
48
- */
49
- export async function queryLastNBlocks(
50
- webServerUrl: string,
51
- ): Promise<BlockResponse> {
52
- try {
53
- const response = await checkedFetch(`${webServerUrl}/blocks`);
54
- return await response.json();
55
- } catch (error) {
56
- throw new NordError("Failed to query last N blocks", { cause: error });
57
- }
58
- }
59
-
60
- /**
61
- * Query recent blocks
62
- *
63
- * @param webServerUrl - Base URL for the Nord web server
64
- * @param last_n - Number of recent blocks to query
65
- * @returns Block summary response
66
- * @throws {NordError} If the request fails
67
- */
68
- export async function queryRecentBlocks(
69
- webServerUrl: string,
70
- last_n: number,
71
- ): Promise<BlockSummaryResponse> {
72
- try {
73
- const response = await checkedFetch(
74
- `${webServerUrl}/blocks_summary?last_n=${last_n}`,
75
- );
76
- return await response.json();
77
- } catch (error) {
78
- throw new NordError(`Failed to query recent blocks (last ${last_n})`, {
79
- cause: error,
80
- });
81
- }
82
- }
83
15
 
84
16
  /**
85
17
  * Query a specific action
@@ -112,75 +44,46 @@ export async function queryAction(
112
44
  * Query recent actions
113
45
  *
114
46
  * @param webServerUrl - Base URL for the Nord web server
115
- * @param last_n - Number of recent actions to query
47
+ * @param from - Starting action index
48
+ * @param to - Ending action index
116
49
  * @returns Actions response
117
50
  * @throws {NordError} If the request fails
118
51
  */
119
52
  export async function queryRecentActions(
120
53
  webServerUrl: string,
121
- last_n: number,
54
+ from: number,
55
+ to: number,
122
56
  ): Promise<ActionsResponse> {
123
57
  try {
124
58
  const response = await checkedFetch(
125
- `${webServerUrl}/actions?last_n=${last_n}`,
59
+ `${webServerUrl}/actions?from=${from}&to=${to}`,
126
60
  );
127
61
  return await response.json();
128
62
  } catch (error) {
129
- throw new NordError(`Failed to query recent actions (last ${last_n})`, {
63
+ throw new NordError(`Failed to query recent actions (from ${from} to ${to})`, {
130
64
  cause: error,
131
65
  });
132
66
  }
133
67
  }
134
68
 
135
69
  /**
136
- * Query a block from Rollman
70
+ * Get the last action ID
137
71
  *
138
72
  * @param webServerUrl - Base URL for the Nord web server
139
- * @param query - Block query parameters
140
- * @returns Rollman block response
73
+ * @returns Last action ID
141
74
  * @throws {NordError} If the request fails
142
75
  */
143
- export async function blockQueryRollman(
76
+ export async function getLastActionId(
144
77
  webServerUrl: string,
145
- query: BlockQuery,
146
- ): Promise<RollmanBlockResponse> {
78
+ ): Promise<number> {
147
79
  try {
148
- const params = new URLSearchParams();
149
- if (query.block_number !== undefined) {
150
- params.append("block_height", query.block_number.toString());
151
- }
152
-
153
- const response = await checkedFetch(
154
- `${webServerUrl}/rollman/block?${params.toString()}`,
155
- );
156
- return await response.json();
80
+ const response = await checkedFetch(`${webServerUrl}/last_actionid`);
81
+ const data = await response.json();
82
+ return data.last_actionid;
157
83
  } catch (error) {
158
- throw new NordError("Failed to query Rollman block", { cause: error });
159
- }
160
- }
161
-
162
- /**
163
- * Query block summaries from Rollman
164
- *
165
- * @param webServerUrl - Base URL for the Nord web server
166
- * @param last_n - Number of recent blocks to query
167
- * @returns Block summary response
168
- * @throws {NordError} If the request fails
169
- */
170
- export async function blockSummaryQueryRollman(
171
- webServerUrl: string,
172
- last_n: number,
173
- ): Promise<BlockSummaryResponse> {
174
- try {
175
- const response = await checkedFetch(
176
- `${webServerUrl}/rollman/blocks_summary?last_n=${last_n}`,
177
- );
178
- return await response.json();
179
- } catch (error) {
180
- throw new NordError(
181
- `Failed to query Rollman block summaries (last ${last_n})`,
182
- { cause: error },
183
- );
84
+ throw new NordError("Failed to get last action ID", {
85
+ cause: error,
86
+ });
184
87
  }
185
88
  }
186
89