@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.
@@ -38,12 +38,12 @@ export declare class SolanaBridgeClient {
38
38
  */
39
39
  findContractStoragePda(): Promise<[PublicKey, number]>;
40
40
  /**
41
- * Find the asset whitelisted PDA for a token mint
41
+ * Find the asset config PDA for a token mint
42
42
  *
43
43
  * @param mint Token mint address
44
44
  * @returns [PDA, bump]
45
45
  */
46
- findAssetWhitelistedPda(mint: PublicKey): Promise<[PublicKey, number]>;
46
+ findAssetConfigPda(mint: PublicKey): Promise<[PublicKey, number]>;
47
47
  /**
48
48
  * Find the deposit storage PDA for a deposit index
49
49
  *
@@ -105,13 +105,13 @@ class SolanaBridgeClient {
105
105
  return this.findPda(types_1.PdaSeedType.ContractStorage);
106
106
  }
107
107
  /**
108
- * Find the asset whitelisted PDA for a token mint
108
+ * Find the asset config PDA for a token mint
109
109
  *
110
110
  * @param mint Token mint address
111
111
  * @returns [PDA, bump]
112
112
  */
113
- async findAssetWhitelistedPda(mint) {
114
- return this.findPda(types_1.PdaSeedType.AssetWhitelisted, mint);
113
+ async findAssetConfigPda(mint) {
114
+ return this.findPda(types_1.PdaSeedType.AssetConfig, mint);
115
115
  }
116
116
  /**
117
117
  * Find the deposit storage PDA for a deposit index
@@ -172,7 +172,7 @@ class SolanaBridgeClient {
172
172
  */
173
173
  async depositSpl(params) {
174
174
  const [contractStorage] = await this.findContractStoragePda();
175
- const [assetWhitelisted] = await this.findAssetWhitelistedPda(params.mint);
175
+ const [assetWhitelisted] = await this.findAssetConfigPda(params.mint);
176
176
  // Get the last deposit index from contract storage
177
177
  const contractStorageAccount = await this.program.account.contractStorage.fetch(contractStorage);
178
178
  const lastDepositIndex = contractStorageAccount.lastDepositIndex.toNumber();
@@ -256,7 +256,7 @@ class SolanaBridgeClient {
256
256
  */
257
257
  async whitelistAsset(mint, signer) {
258
258
  const [contractStorage] = await this.findContractStoragePda();
259
- const [assetWhitelisted] = await this.findAssetWhitelistedPda(mint);
259
+ const [assetWhitelisted] = await this.findAssetConfigPda(mint);
260
260
  // Build the transaction
261
261
  const tx = await this.program.methods
262
262
  .whitelistAsset(mint)
@@ -109,7 +109,7 @@ export interface TransferParams {
109
109
  */
110
110
  export declare enum PdaSeedType {
111
111
  ContractStorage = "contract_storage",
112
- AssetWhitelisted = "asset_whitelisted",
112
+ AssetConfig = "asset_config",
113
113
  DepositStorage = "deposit_storage",
114
114
  BlockStorage = "block_storage",
115
115
  WithdrawalNullifier = "withdrawal_nullifier",
@@ -7,7 +7,7 @@ exports.PdaSeedType = void 0;
7
7
  var PdaSeedType;
8
8
  (function (PdaSeedType) {
9
9
  PdaSeedType["ContractStorage"] = "contract_storage";
10
- PdaSeedType["AssetWhitelisted"] = "asset_whitelisted";
10
+ PdaSeedType["AssetConfig"] = "asset_config";
11
11
  PdaSeedType["DepositStorage"] = "deposit_storage";
12
12
  PdaSeedType["BlockStorage"] = "block_storage";
13
13
  PdaSeedType["WithdrawalNullifier"] = "withdrawal_nullifier";
@@ -44,14 +44,13 @@ exports.BRIDGE_IDL = {
44
44
  },
45
45
  },
46
46
  {
47
- name: "asset_whitelisted",
47
+ name: "asset_config",
48
48
  pda: {
49
49
  seeds: [
50
50
  {
51
51
  kind: "const",
52
52
  value: [
53
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
54
- 115, 116, 101, 100,
53
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
55
54
  ],
56
55
  },
57
56
  {
@@ -83,6 +82,34 @@ exports.BRIDGE_IDL = {
83
82
  {
84
83
  name: "to_account",
85
84
  writable: true,
85
+ pda: {
86
+ seeds: [
87
+ {
88
+ kind: "const",
89
+ value: [
90
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
91
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
92
+ 15, 16, 9, 188,
93
+ ],
94
+ },
95
+ {
96
+ kind: "account",
97
+ path: "token_program",
98
+ },
99
+ {
100
+ kind: "account",
101
+ path: "from_account.mint",
102
+ },
103
+ ],
104
+ program: {
105
+ kind: "const",
106
+ value: [
107
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
108
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
109
+ 219, 233, 248, 89,
110
+ ],
111
+ },
112
+ },
86
113
  },
87
114
  {
88
115
  name: "token_program",
@@ -99,6 +126,34 @@ exports.BRIDGE_IDL = {
99
126
  },
100
127
  ],
101
128
  },
129
+ {
130
+ name: "emit_crumb",
131
+ discriminator: [96, 96, 18, 122, 83, 60, 102, 37],
132
+ accounts: [
133
+ {
134
+ name: "contract_storage",
135
+ docs: [
136
+ "Need a PDA to ensure that only this contract is allowed to",
137
+ "call this instruction; the contract storage account is",
138
+ "chosen since pretty much every other ix uses it, so this",
139
+ "avoids having to introduce a new account.",
140
+ ],
141
+ signer: true,
142
+ pda: {
143
+ seeds: [
144
+ {
145
+ kind: "const",
146
+ value: [
147
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
148
+ 97, 103, 101,
149
+ ],
150
+ },
151
+ ],
152
+ },
153
+ },
154
+ ],
155
+ args: [],
156
+ },
102
157
  {
103
158
  name: "finalize_block",
104
159
  discriminator: [63, 101, 92, 132, 135, 251, 98, 177],
@@ -162,6 +217,20 @@ exports.BRIDGE_IDL = {
162
217
  writable: true,
163
218
  signer: true,
164
219
  },
220
+ {
221
+ name: "contract_storage",
222
+ pda: {
223
+ seeds: [
224
+ {
225
+ kind: "const",
226
+ value: [
227
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
228
+ 97, 103, 101,
229
+ ],
230
+ },
231
+ ],
232
+ },
233
+ },
165
234
  {
166
235
  name: "fact_state_storage",
167
236
  writable: true,
@@ -204,11 +273,6 @@ exports.BRIDGE_IDL = {
204
273
  writable: true,
205
274
  signer: true,
206
275
  },
207
- {
208
- name: "program",
209
- signer: true,
210
- address: "CVDFLCAjXhVWiPXH9nTCTpCgVzmDVoiPzNJYuccr1dqB",
211
- },
212
276
  {
213
277
  name: "contract_storage",
214
278
  writable: true,
@@ -234,6 +298,10 @@ exports.BRIDGE_IDL = {
234
298
  name: "operator",
235
299
  type: "pubkey",
236
300
  },
301
+ {
302
+ name: "challenge_period_slots",
303
+ type: "u64",
304
+ },
237
305
  {
238
306
  name: "initial_app_state_commitment",
239
307
  type: {
@@ -308,6 +376,58 @@ exports.BRIDGE_IDL = {
308
376
  },
309
377
  ],
310
378
  },
379
+ {
380
+ name: "set_min_deposit",
381
+ discriminator: [15, 182, 74, 248, 251, 148, 186, 171],
382
+ accounts: [
383
+ {
384
+ name: "operator",
385
+ signer: true,
386
+ },
387
+ {
388
+ name: "contract_storage",
389
+ pda: {
390
+ seeds: [
391
+ {
392
+ kind: "const",
393
+ value: [
394
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
395
+ 97, 103, 101,
396
+ ],
397
+ },
398
+ ],
399
+ },
400
+ },
401
+ {
402
+ name: "asset_config",
403
+ writable: true,
404
+ pda: {
405
+ seeds: [
406
+ {
407
+ kind: "const",
408
+ value: [
409
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
410
+ ],
411
+ },
412
+ {
413
+ kind: "arg",
414
+ path: "asset",
415
+ },
416
+ ],
417
+ },
418
+ },
419
+ ],
420
+ args: [
421
+ {
422
+ name: "asset",
423
+ type: "pubkey",
424
+ },
425
+ {
426
+ name: "min_deposit",
427
+ type: "u64",
428
+ },
429
+ ],
430
+ },
311
431
  {
312
432
  name: "whitelist_asset",
313
433
  discriminator: [113, 64, 172, 191, 33, 33, 57, 18],
@@ -332,15 +452,14 @@ exports.BRIDGE_IDL = {
332
452
  },
333
453
  },
334
454
  {
335
- name: "asset_whitelisted",
455
+ name: "asset_config",
336
456
  writable: true,
337
457
  pda: {
338
458
  seeds: [
339
459
  {
340
460
  kind: "const",
341
461
  value: [
342
- 97, 115, 115, 101, 116, 95, 119, 104, 105, 116, 101, 108, 105,
343
- 115, 116, 101, 100,
462
+ 97, 115, 115, 101, 116, 95, 99, 111, 110, 102, 105, 103,
344
463
  ],
345
464
  },
346
465
  {
@@ -360,6 +479,10 @@ exports.BRIDGE_IDL = {
360
479
  name: "asset",
361
480
  type: "pubkey",
362
481
  },
482
+ {
483
+ name: "min_deposit",
484
+ type: "u64",
485
+ },
363
486
  ],
364
487
  },
365
488
  {
@@ -414,6 +537,34 @@ exports.BRIDGE_IDL = {
414
537
  {
415
538
  name: "from_account",
416
539
  writable: true,
540
+ pda: {
541
+ seeds: [
542
+ {
543
+ kind: "const",
544
+ value: [
545
+ 79, 224, 127, 226, 92, 181, 26, 89, 30, 167, 10, 86, 86, 68,
546
+ 128, 20, 156, 34, 76, 69, 18, 76, 98, 233, 62, 41, 163, 58,
547
+ 15, 16, 9, 188,
548
+ ],
549
+ },
550
+ {
551
+ kind: "account",
552
+ path: "token_program",
553
+ },
554
+ {
555
+ kind: "account",
556
+ path: "to_account.mint",
557
+ },
558
+ ],
559
+ program: {
560
+ kind: "const",
561
+ value: [
562
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
563
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
564
+ 219, 233, 248, 89,
565
+ ],
566
+ },
567
+ },
417
568
  },
418
569
  {
419
570
  name: "to_account",
@@ -430,6 +581,20 @@ exports.BRIDGE_IDL = {
430
581
  ],
431
582
  },
432
583
  },
584
+ {
585
+ name: "contract_storage",
586
+ pda: {
587
+ seeds: [
588
+ {
589
+ kind: "const",
590
+ value: [
591
+ 99, 111, 110, 116, 114, 97, 99, 116, 95, 115, 116, 111, 114,
592
+ 97, 103, 101,
593
+ ],
594
+ },
595
+ ],
596
+ },
597
+ },
433
598
  {
434
599
  name: "token_program",
435
600
  },
@@ -452,8 +617,8 @@ exports.BRIDGE_IDL = {
452
617
  ],
453
618
  accounts: [
454
619
  {
455
- name: "AssetWhitelisted",
456
- discriminator: [170, 42, 144, 120, 189, 54, 255, 166],
620
+ name: "AssetConfig",
621
+ discriminator: [57, 112, 247, 166, 247, 64, 140, 23],
457
622
  },
458
623
  {
459
624
  name: "Block",
@@ -478,10 +643,15 @@ exports.BRIDGE_IDL = {
478
643
  ],
479
644
  types: [
480
645
  {
481
- name: "AssetWhitelisted",
646
+ name: "AssetConfig",
482
647
  type: {
483
648
  kind: "struct",
484
- fields: [],
649
+ fields: [
650
+ {
651
+ name: "min_deposit",
652
+ type: "u64",
653
+ },
654
+ ],
485
655
  },
486
656
  },
487
657
  {
@@ -501,6 +671,10 @@ exports.BRIDGE_IDL = {
501
671
  name: "finalized",
502
672
  type: "bool",
503
673
  },
674
+ {
675
+ name: "slot_proposed",
676
+ type: "u64",
677
+ },
504
678
  ],
505
679
  },
506
680
  },
@@ -549,6 +723,10 @@ exports.BRIDGE_IDL = {
549
723
  name: "operator",
550
724
  type: "pubkey",
551
725
  },
726
+ {
727
+ name: "challenge_period_slots",
728
+ type: "u64",
729
+ },
552
730
  {
553
731
  name: "last_block_id",
554
732
  type: "u64",
@@ -689,6 +867,22 @@ exports.BRIDGE_IDL = {
689
867
  name: "block_id",
690
868
  type: "u64",
691
869
  },
870
+ {
871
+ name: "proof",
872
+ type: {
873
+ vec: {
874
+ array: ["u8", 32],
875
+ },
876
+ },
877
+ },
878
+ {
879
+ name: "leaf_index",
880
+ type: "u64",
881
+ },
882
+ {
883
+ name: "leaves_count",
884
+ type: "u64",
885
+ },
692
886
  ],
693
887
  },
694
888
  },
@@ -1,30 +1,4 @@
1
- import { ActionQuery, ActionResponse, ActionsResponse, BlockQuery, BlockResponse, BlockSummaryResponse, RollmanActionResponse, RollmanActionsResponse, RollmanBlockResponse } from "../../types";
2
- /**
3
- * Query a specific block
4
- *
5
- * @param webServerUrl - Base URL for the Nord web server
6
- * @param query - Block query parameters
7
- * @returns Block response
8
- * @throws {NordError} If the request fails
9
- */
10
- export declare function queryBlock(webServerUrl: string, query: BlockQuery): Promise<BlockResponse>;
11
- /**
12
- * Query the last N blocks
13
- *
14
- * @param webServerUrl - Base URL for the Nord web server
15
- * @returns Block response for the last N blocks
16
- * @throws {NordError} If the request fails
17
- */
18
- export declare function queryLastNBlocks(webServerUrl: string): Promise<BlockResponse>;
19
- /**
20
- * Query recent blocks
21
- *
22
- * @param webServerUrl - Base URL for the Nord web server
23
- * @param last_n - Number of recent blocks to query
24
- * @returns Block summary response
25
- * @throws {NordError} If the request fails
26
- */
27
- export declare function queryRecentBlocks(webServerUrl: string, last_n: number): Promise<BlockSummaryResponse>;
1
+ import { ActionQuery, ActionResponse, ActionsResponse, RollmanActionResponse, RollmanActionsResponse } from "../../types";
28
2
  /**
29
3
  * Query a specific action
30
4
  *
@@ -38,29 +12,20 @@ export declare function queryAction(webServerUrl: string, query: ActionQuery): P
38
12
  * Query recent actions
39
13
  *
40
14
  * @param webServerUrl - Base URL for the Nord web server
41
- * @param last_n - Number of recent actions to query
15
+ * @param from - Starting action index
16
+ * @param to - Ending action index
42
17
  * @returns Actions response
43
18
  * @throws {NordError} If the request fails
44
19
  */
45
- export declare function queryRecentActions(webServerUrl: string, last_n: number): Promise<ActionsResponse>;
46
- /**
47
- * Query a block from Rollman
48
- *
49
- * @param webServerUrl - Base URL for the Nord web server
50
- * @param query - Block query parameters
51
- * @returns Rollman block response
52
- * @throws {NordError} If the request fails
53
- */
54
- export declare function blockQueryRollman(webServerUrl: string, query: BlockQuery): Promise<RollmanBlockResponse>;
20
+ export declare function queryRecentActions(webServerUrl: string, from: number, to: number): Promise<ActionsResponse>;
55
21
  /**
56
- * Query block summaries from Rollman
22
+ * Get the last action ID
57
23
  *
58
24
  * @param webServerUrl - Base URL for the Nord web server
59
- * @param last_n - Number of recent blocks to query
60
- * @returns Block summary response
25
+ * @returns Last action ID
61
26
  * @throws {NordError} If the request fails
62
27
  */
63
- export declare function blockSummaryQueryRollman(webServerUrl: string, last_n: number): Promise<BlockSummaryResponse>;
28
+ export declare function getLastActionId(webServerUrl: string): Promise<number>;
64
29
  /**
65
30
  * Query an action from Rollman
66
31
  *
@@ -1,72 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryBlock = queryBlock;
4
- exports.queryLastNBlocks = queryLastNBlocks;
5
- exports.queryRecentBlocks = queryRecentBlocks;
6
3
  exports.queryAction = queryAction;
7
4
  exports.queryRecentActions = queryRecentActions;
8
- exports.blockQueryRollman = blockQueryRollman;
9
- exports.blockSummaryQueryRollman = blockSummaryQueryRollman;
5
+ exports.getLastActionId = getLastActionId;
10
6
  exports.actionQueryRollman = actionQueryRollman;
11
7
  exports.actionsQueryRollman = actionsQueryRollman;
12
8
  const utils_1 = require("../../utils");
13
9
  const NordError_1 = require("../utils/NordError");
14
- /**
15
- * Query a specific block
16
- *
17
- * @param webServerUrl - Base URL for the Nord web server
18
- * @param query - Block query parameters
19
- * @returns Block response
20
- * @throws {NordError} If the request fails
21
- */
22
- async function queryBlock(webServerUrl, query) {
23
- try {
24
- const params = new URLSearchParams();
25
- if (query.block_number !== undefined) {
26
- params.append("block_height", query.block_number.toString());
27
- }
28
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/block?${params.toString()}`);
29
- return await response.json();
30
- }
31
- catch (error) {
32
- throw new NordError_1.NordError("Failed to query block", { cause: error });
33
- }
34
- }
35
- /**
36
- * Query the last N blocks
37
- *
38
- * @param webServerUrl - Base URL for the Nord web server
39
- * @returns Block response for the last N blocks
40
- * @throws {NordError} If the request fails
41
- */
42
- async function queryLastNBlocks(webServerUrl) {
43
- try {
44
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/blocks`);
45
- return await response.json();
46
- }
47
- catch (error) {
48
- throw new NordError_1.NordError("Failed to query last N blocks", { cause: error });
49
- }
50
- }
51
- /**
52
- * Query recent blocks
53
- *
54
- * @param webServerUrl - Base URL for the Nord web server
55
- * @param last_n - Number of recent blocks to query
56
- * @returns Block summary response
57
- * @throws {NordError} If the request fails
58
- */
59
- async function queryRecentBlocks(webServerUrl, last_n) {
60
- try {
61
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/blocks_summary?last_n=${last_n}`);
62
- return await response.json();
63
- }
64
- catch (error) {
65
- throw new NordError_1.NordError(`Failed to query recent blocks (last ${last_n})`, {
66
- cause: error,
67
- });
68
- }
69
- }
70
10
  /**
71
11
  * Query a specific action
72
12
  *
@@ -92,57 +32,39 @@ async function queryAction(webServerUrl, query) {
92
32
  * Query recent actions
93
33
  *
94
34
  * @param webServerUrl - Base URL for the Nord web server
95
- * @param last_n - Number of recent actions to query
35
+ * @param from - Starting action index
36
+ * @param to - Ending action index
96
37
  * @returns Actions response
97
38
  * @throws {NordError} If the request fails
98
39
  */
99
- async function queryRecentActions(webServerUrl, last_n) {
40
+ async function queryRecentActions(webServerUrl, from, to) {
100
41
  try {
101
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?last_n=${last_n}`);
42
+ const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/actions?from=${from}&to=${to}`);
102
43
  return await response.json();
103
44
  }
104
45
  catch (error) {
105
- throw new NordError_1.NordError(`Failed to query recent actions (last ${last_n})`, {
46
+ throw new NordError_1.NordError(`Failed to query recent actions (from ${from} to ${to})`, {
106
47
  cause: error,
107
48
  });
108
49
  }
109
50
  }
110
51
  /**
111
- * Query a block from Rollman
52
+ * Get the last action ID
112
53
  *
113
54
  * @param webServerUrl - Base URL for the Nord web server
114
- * @param query - Block query parameters
115
- * @returns Rollman block response
55
+ * @returns Last action ID
116
56
  * @throws {NordError} If the request fails
117
57
  */
118
- async function blockQueryRollman(webServerUrl, query) {
58
+ async function getLastActionId(webServerUrl) {
119
59
  try {
120
- const params = new URLSearchParams();
121
- if (query.block_number !== undefined) {
122
- params.append("block_height", query.block_number.toString());
123
- }
124
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/block?${params.toString()}`);
125
- return await response.json();
60
+ const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/last_actionid`);
61
+ const data = await response.json();
62
+ return data.last_actionid;
126
63
  }
127
64
  catch (error) {
128
- throw new NordError_1.NordError("Failed to query Rollman block", { cause: error });
129
- }
130
- }
131
- /**
132
- * Query block summaries from Rollman
133
- *
134
- * @param webServerUrl - Base URL for the Nord web server
135
- * @param last_n - Number of recent blocks to query
136
- * @returns Block summary response
137
- * @throws {NordError} If the request fails
138
- */
139
- async function blockSummaryQueryRollman(webServerUrl, last_n) {
140
- try {
141
- const response = await (0, utils_1.checkedFetch)(`${webServerUrl}/rollman/blocks_summary?last_n=${last_n}`);
142
- return await response.json();
143
- }
144
- catch (error) {
145
- throw new NordError_1.NordError(`Failed to query Rollman block summaries (last ${last_n})`, { cause: error });
65
+ throw new NordError_1.NordError("Failed to get last action ID", {
66
+ cause: error,
67
+ });
146
68
  }
147
69
  }
148
70
  /**