@babylonlabs-io/ts-sdk 0.36.0 → 0.36.2

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 (57) hide show
  1. package/dist/PeginManager-BPXVXu8t.cjs +2 -0
  2. package/dist/{PeginManager-cPQuJTB9.cjs.map → PeginManager-BPXVXu8t.cjs.map} +1 -1
  3. package/dist/{PeginManager-DF1oinIQ.js → PeginManager-CB-dVkT2.js} +387 -369
  4. package/dist/{PeginManager-DF1oinIQ.js.map → PeginManager-CB-dVkT2.js.map} +1 -1
  5. package/dist/buildAndBroadcastRefund-C2VqXiOx.js +893 -0
  6. package/dist/buildAndBroadcastRefund-C2VqXiOx.js.map +1 -0
  7. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs +2 -0
  8. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +74 -70
  11. package/dist/tbv/core/clients/eth/types.d.ts +1 -0
  12. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  13. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +1 -0
  14. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  15. package/dist/tbv/core/clients/index.cjs +1 -1
  16. package/dist/tbv/core/clients/index.js +1 -1
  17. package/dist/tbv/core/index.cjs +1 -1
  18. package/dist/tbv/core/index.js +67 -63
  19. package/dist/tbv/core/managers/PeginManager.d.ts +22 -4
  20. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  21. package/dist/tbv/core/managers/index.cjs +1 -1
  22. package/dist/tbv/core/managers/index.js +1 -1
  23. package/dist/tbv/core/services/deposit/__tests__/validateOnChainParticipantKeys.test.d.ts +2 -0
  24. package/dist/tbv/core/services/deposit/__tests__/validateOnChainParticipantKeys.test.d.ts.map +1 -0
  25. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredVaultVersions.test.d.ts +2 -0
  26. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredVaultVersions.test.d.ts.map +1 -0
  27. package/dist/tbv/core/services/deposit/index.d.ts +8 -12
  28. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  29. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  30. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +21 -0
  31. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -0
  32. package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts +15 -0
  33. package/dist/tbv/core/services/deposit/verifyRegisteredVaultVersions.d.ts.map +1 -0
  34. package/dist/tbv/core/services/index.cjs +1 -1
  35. package/dist/tbv/core/services/index.js +23 -19
  36. package/dist/tbv/core/vault-secrets/index.d.ts +1 -0
  37. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  38. package/dist/tbv/index.cjs +1 -1
  39. package/dist/tbv/index.js +67 -63
  40. package/dist/tbv/integrations/aave/constants.d.ts +15 -2
  41. package/dist/tbv/integrations/aave/constants.d.ts.map +1 -1
  42. package/dist/tbv/integrations/aave/index.cjs +1 -1
  43. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  44. package/dist/tbv/integrations/aave/index.d.ts +1 -1
  45. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  46. package/dist/tbv/integrations/aave/index.js +94 -93
  47. package/dist/tbv/integrations/aave/index.js.map +1 -1
  48. package/dist/{vault-registry-reader-Cufa-ZkW.cjs → vault-registry-reader-CLnhAUN4.cjs} +2 -2
  49. package/dist/{vault-registry-reader-Cufa-ZkW.cjs.map → vault-registry-reader-CLnhAUN4.cjs.map} +1 -1
  50. package/dist/{vault-registry-reader-Bz8uu0dh.js → vault-registry-reader-CrLodprY.js} +220 -190
  51. package/dist/{vault-registry-reader-Bz8uu0dh.js.map → vault-registry-reader-CrLodprY.js.map} +1 -1
  52. package/package.json +1 -1
  53. package/dist/PeginManager-cPQuJTB9.cjs +0 -2
  54. package/dist/buildAndBroadcastRefund-BQ0CaL6Q.cjs +0 -2
  55. package/dist/buildAndBroadcastRefund-BQ0CaL6Q.cjs.map +0 -1
  56. package/dist/buildAndBroadcastRefund-DzX11N9S.js +0 -785
  57. package/dist/buildAndBroadcastRefund-DzX11N9S.js.map +0 -1
@@ -5,10 +5,10 @@ import { D as be, J as re, e as _e } from "./types-TiIjyo2b.js";
5
5
  import { X as R, C as L, s as C, S as ye, h as Pe } from "./bitcoin-B0S8SHCX.js";
6
6
  import { H as T } from "./validation-CxqROCno.js";
7
7
  import * as j from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { payments as we, Transaction as K } from "bitcoinjs-lib";
8
+ import { payments as we, Transaction as U } from "bitcoinjs-lib";
9
9
  import { Buffer as A } from "buffer";
10
10
  import { s as z } from "./sha2-BYVxyZzX.js";
11
- import { B as V } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
11
+ import { B as w } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
12
12
  import { P as _, A as F } from "./ProtocolParams.abi-DXu8L0Fn.js";
13
13
  const W = new Set(Object.values(be)), ve = 200;
14
14
  function l(t) {
@@ -16,7 +16,7 @@ function l(t) {
16
16
  return ((e = JSON.stringify(t)) == null ? void 0 : e.slice(0, ve)) ?? "undefined";
17
17
  }
18
18
  const xe = "The vault provider returned an unexpected response. Please try again or contact support.";
19
- class s extends Error {
19
+ class o extends Error {
20
20
  constructor(n) {
21
21
  super(xe);
22
22
  p(this, "detail");
@@ -24,96 +24,96 @@ class s extends Error {
24
24
  }
25
25
  }
26
26
  const $ = 64;
27
- function w(t) {
27
+ function v(t) {
28
28
  return typeof t == "string" && t.length > 0 && T.test(t);
29
29
  }
30
30
  function ie(t) {
31
31
  return typeof t == "string" && t.length > 0;
32
32
  }
33
33
  function se(t, e) {
34
- if (!w(t))
35
- throw new s(
34
+ if (!v(t))
35
+ throw new o(
36
36
  `VP response validation failed: "${e}" must be a non-empty hex string, got ${l(t)}`
37
37
  );
38
38
  }
39
39
  function m(t, e) {
40
40
  if (!ie(t))
41
- throw new s(
41
+ throw new o(
42
42
  `VP response validation failed: "${e}" must be a non-empty string, got ${l(t)}`
43
43
  );
44
44
  }
45
45
  function oe(t, e) {
46
- if (!w(t) || t.length !== R && t.length !== L)
47
- throw new s(
46
+ if (!v(t) || t.length !== R && t.length !== L)
47
+ throw new o(
48
48
  `VP response validation failed: "${e}" must be a ${R} or ${L}-char hex string (BTC pubkey), got ${l(t)}`
49
49
  );
50
50
  }
51
- function Ae(t) {
51
+ function Ve(t) {
52
52
  const e = t.presigning;
53
53
  if (e == null) return;
54
54
  if (typeof e != "object" || Array.isArray(e))
55
- throw new s(
55
+ throw new o(
56
56
  'VP response validation failed: "progress.presigning" must be an object if present'
57
57
  );
58
58
  const n = e;
59
59
  if (n.depositor_graph_created !== void 0 && typeof n.depositor_graph_created != "boolean")
60
- throw new s(
60
+ throw new o(
61
61
  `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${l(n.depositor_graph_created)}`
62
62
  );
63
63
  if (n.vk_challenger_presigning_completed !== void 0 && typeof n.vk_challenger_presigning_completed != "number")
64
- throw new s(
64
+ throw new o(
65
65
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${l(n.vk_challenger_presigning_completed)}`
66
66
  );
67
67
  if (n.vk_challenger_presigning_total !== void 0 && typeof n.vk_challenger_presigning_total != "number")
68
- throw new s(
68
+ throw new o(
69
69
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${l(n.vk_challenger_presigning_total)}`
70
70
  );
71
71
  }
72
72
  function ae(t) {
73
73
  if (t === null || typeof t != "object")
74
- throw new s(
74
+ throw new o(
75
75
  "VP response validation failed: getPeginStatus response is not an object"
76
76
  );
77
77
  const e = t;
78
- if (!w(e.pegin_txid) || e.pegin_txid.length !== $)
79
- throw new s(
78
+ if (!v(e.pegin_txid) || e.pegin_txid.length !== $)
79
+ throw new o(
80
80
  `VP response validation failed: "pegin_txid" must be a ${$}-char hex string (txid), got ${l(e.pegin_txid)}`
81
81
  );
82
82
  if (typeof e.status != "string")
83
- throw new s(
83
+ throw new o(
84
84
  'VP response validation failed: "status" must be a string'
85
85
  );
86
86
  if (!W.has(e.status))
87
- throw new s(
87
+ throw new o(
88
88
  `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...W].join(", ")}`
89
89
  );
90
90
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
91
- throw new s(
91
+ throw new o(
92
92
  'VP response validation failed: "progress" must be an object'
93
93
  );
94
- if (Ae(e.progress), typeof e.health_info != "string")
95
- throw new s(
94
+ if (Ve(e.progress), typeof e.health_info != "string")
95
+ throw new o(
96
96
  'VP response validation failed: "health_info" must be a string'
97
97
  );
98
98
  if (e.last_error !== void 0 && typeof e.last_error != "string")
99
- throw new s(
99
+ throw new o(
100
100
  `VP response validation failed: "last_error" must be a string if present, got ${l(e.last_error)}`
101
101
  );
102
102
  }
103
- function Ve(t) {
103
+ function Ae(t) {
104
104
  if (t === null || typeof t != "object")
105
- throw new s(
105
+ throw new o(
106
106
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
107
107
  );
108
108
  const e = t;
109
109
  if (!Array.isArray(e.txs))
110
- throw new s(
110
+ throw new o(
111
111
  'VP response validation failed: "txs" must be an array'
112
112
  );
113
113
  for (let n = 0; n < e.txs.length; n++)
114
114
  $e(e.txs[n], `txs[${n}]`);
115
115
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
116
- throw new s(
116
+ throw new o(
117
117
  'VP response validation failed: "depositor_graph" must be an object'
118
118
  );
119
119
  Re(
@@ -122,14 +122,14 @@ function Ve(t) {
122
122
  }
123
123
  function y(t, e) {
124
124
  if (t === null || typeof t != "object")
125
- throw new s(
125
+ throw new o(
126
126
  `VP response validation failed: "${e}" must be an object`
127
127
  );
128
128
  se(t.tx_hex, `${e}.tx_hex`);
129
129
  }
130
130
  function $e(t, e) {
131
131
  if (t === null || typeof t != "object")
132
- throw new s(
132
+ throw new o(
133
133
  `VP response validation failed: "${e}" must be an object`
134
134
  );
135
135
  const n = t;
@@ -137,15 +137,15 @@ function $e(t, e) {
137
137
  }
138
138
  function Te(t, e) {
139
139
  if (t === null || typeof t != "object")
140
- throw new s(
140
+ throw new o(
141
141
  `VP response validation failed: "${e}" must be an object`
142
142
  );
143
143
  const n = t;
144
144
  m(n.wots_pks_json, `${e}.wots_pks_json`), m(n.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
145
145
  }
146
- function ke(t, e) {
146
+ function Se(t, e) {
147
147
  if (t === null || typeof t != "object")
148
- throw new s(
148
+ throw new o(
149
149
  `VP response validation failed: "${e}" must be an object`
150
150
  );
151
151
  const n = t;
@@ -156,7 +156,7 @@ function ke(t, e) {
156
156
  n.challenge_assert_y_tx,
157
157
  `${e}.challenge_assert_y_tx`
158
158
  ), y(n.nopayout_tx, `${e}.nopayout_tx`), m(n.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(n.challenge_assert_connectors))
159
- throw new s(
159
+ throw new o(
160
160
  `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
161
161
  );
162
162
  for (let r = 0; r < n.challenge_assert_connectors.length; r++)
@@ -165,7 +165,7 @@ function ke(t, e) {
165
165
  `${e}.challenge_assert_connectors[${r}]`
166
166
  );
167
167
  if (!Array.isArray(n.output_label_hashes))
168
- throw new s(
168
+ throw new o(
169
169
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
170
170
  );
171
171
  for (let r = 0; r < n.output_label_hashes.length; r++)
@@ -174,61 +174,61 @@ function ke(t, e) {
174
174
  `${e}.output_label_hashes[${r}]`
175
175
  );
176
176
  }
177
- function Se(t) {
177
+ function ke(t) {
178
178
  if (t === null || typeof t != "object")
179
- throw new s(
179
+ throw new o(
180
180
  "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
181
181
  );
182
182
  const e = t;
183
183
  if (!ie(e.tx_graph_json))
184
- throw new s(
184
+ throw new o(
185
185
  `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${l(e.tx_graph_json)}`
186
186
  );
187
- if (!w(e.verifying_key_hex))
188
- throw new s(
187
+ if (!v(e.verifying_key_hex))
188
+ throw new o(
189
189
  `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`
190
190
  );
191
191
  if (e.babe_sessions === null || typeof e.babe_sessions != "object")
192
- throw new s(
192
+ throw new o(
193
193
  'VP response validation failed: "babe_sessions" must be an object'
194
194
  );
195
195
  for (const [n, r] of Object.entries(
196
196
  e.babe_sessions
197
197
  )) {
198
198
  if (r === null || typeof r != "object")
199
- throw new s(
199
+ throw new o(
200
200
  `VP response validation failed: "babe_sessions.${n}" must be an object`
201
201
  );
202
- const i = r;
203
- if (!w(i.decryptor_artifacts_hex))
204
- throw new s(
205
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(i.decryptor_artifacts_hex)}`
202
+ const s = r;
203
+ if (!v(s.decryptor_artifacts_hex))
204
+ throw new o(
205
+ `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(s.decryptor_artifacts_hex)}`
206
206
  );
207
207
  }
208
208
  }
209
209
  function Ce(t) {
210
210
  if (t === null || typeof t != "object")
211
- throw new s(
211
+ throw new o(
212
212
  "VP response validation failed: pegout status payload is not an object"
213
213
  );
214
214
  const e = t;
215
- if (!w(e.pegin_txid) || e.pegin_txid.length !== $)
216
- throw new s(
215
+ if (!v(e.pegin_txid) || e.pegin_txid.length !== $)
216
+ throw new o(
217
217
  `VP response validation failed: "pegin_txid" must be a ${$}-char hex string (txid), got ${l(e.pegin_txid)}`
218
218
  );
219
219
  if (typeof e.found != "boolean")
220
- throw new s(
220
+ throw new o(
221
221
  `VP response validation failed: "found" must be a boolean, got ${l(e.found)}`
222
222
  );
223
223
  if (e.claimer !== null) {
224
224
  if (typeof e.claimer != "object")
225
- throw new s(
225
+ throw new o(
226
226
  `VP response validation failed: "claimer" must be an object or null, got ${l(e.claimer)}`
227
227
  );
228
228
  Ie(e.claimer);
229
229
  }
230
230
  if (!Array.isArray(e.challengers))
231
- throw new s(
231
+ throw new o(
232
232
  `VP response validation failed: "challengers" must be an array, got ${l(e.challengers)}`
233
233
  );
234
234
  for (let n = 0; n < e.challengers.length; n++)
@@ -236,25 +236,25 @@ function Ce(t) {
236
236
  }
237
237
  function Ie(t) {
238
238
  if (m(t.status, "claimer.status"), typeof t.failed != "boolean")
239
- throw new s(
239
+ throw new o(
240
240
  `VP response validation failed: "claimer.failed" must be a boolean, got ${l(t.failed)}`
241
241
  );
242
242
  if (m(t.claim_txid, "claimer.claim_txid"), m(t.claimer_pubkey, "claimer.claimer_pubkey"), m(t.assert_txid, "claimer.assert_txid"), t.challenger_pubkey !== null && typeof t.challenger_pubkey != "string")
243
- throw new s(
243
+ throw new o(
244
244
  `VP response validation failed: "claimer.challenger_pubkey" must be a string or null, got ${l(t.challenger_pubkey)}`
245
245
  );
246
246
  if (typeof t.created_at != "number")
247
- throw new s(
247
+ throw new o(
248
248
  `VP response validation failed: "claimer.created_at" must be a number, got ${l(t.created_at)}`
249
249
  );
250
250
  if (typeof t.updated_at != "number")
251
- throw new s(
251
+ throw new o(
252
252
  `VP response validation failed: "claimer.updated_at" must be a number, got ${l(t.updated_at)}`
253
253
  );
254
254
  }
255
255
  function Ee(t, e) {
256
256
  if (t === null || typeof t != "object")
257
- throw new s(
257
+ throw new o(
258
258
  `VP response validation failed: "challengers[${e}]" must be an object, got ${l(t)}`
259
259
  );
260
260
  const n = t;
@@ -265,17 +265,17 @@ function Ee(t, e) {
265
265
  n.challenge_assert_y_txid,
266
266
  `challengers[${e}].challenge_assert_y_txid`
267
267
  ), I(n.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof n.created_at != "number")
268
- throw new s(
268
+ throw new o(
269
269
  `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${l(n.created_at)}`
270
270
  );
271
271
  if (typeof n.updated_at != "number")
272
- throw new s(
272
+ throw new o(
273
273
  `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${l(n.updated_at)}`
274
274
  );
275
275
  }
276
276
  function I(t, e) {
277
277
  if (t !== null && typeof t != "string")
278
- throw new s(
278
+ throw new o(
279
279
  `VP response validation failed: "${e}" must be a string or null, got ${l(t)}`
280
280
  );
281
281
  }
@@ -291,62 +291,62 @@ function Ne(t) {
291
291
  }
292
292
  function ce(t, e, n) {
293
293
  if (t === null || typeof t != "object")
294
- throw new s(
294
+ throw new o(
295
295
  `VP response validation failed: ${e} response is not an object`
296
296
  );
297
297
  const r = t;
298
298
  if (!Array.isArray(r.results))
299
- throw new s(
299
+ throw new o(
300
300
  `VP response validation failed: "${e}.results" must be an array, got ${l(r.results)}`
301
301
  );
302
- for (let i = 0; i < r.results.length; i++) {
303
- const o = r.results[i];
304
- if (o === null || typeof o != "object")
305
- throw new s(
306
- `VP response validation failed: "${e}.results[${i}]" must be an object, got ${l(o)}`
302
+ for (let s = 0; s < r.results.length; s++) {
303
+ const i = r.results[s];
304
+ if (i === null || typeof i != "object")
305
+ throw new o(
306
+ `VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(i)}`
307
307
  );
308
- const a = o;
309
- if (!w(a.pegin_txid) || a.pegin_txid.length !== $)
310
- throw new s(
311
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${$}-char hex string, got ${l(a.pegin_txid)}`
308
+ const a = i;
309
+ if (!v(a.pegin_txid) || a.pegin_txid.length !== $)
310
+ throw new o(
311
+ `VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${$}-char hex string, got ${l(a.pegin_txid)}`
312
312
  );
313
313
  if (a.error !== null && typeof a.error != "string")
314
- throw new s(
315
- `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${l(a.error)}`
314
+ throw new o(
315
+ `VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(a.error)}`
316
316
  );
317
317
  if (a.result === null && a.error === null)
318
- throw new s(
319
- `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
318
+ throw new o(
319
+ `VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`
320
320
  );
321
321
  if (a.result !== null && a.error !== null)
322
- throw new s(
323
- `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
322
+ throw new o(
323
+ `VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`
324
324
  );
325
- n(a, i);
325
+ n(a, s);
326
326
  }
327
327
  }
328
328
  function Re(t) {
329
329
  if (y(t.claim_tx, "depositor_graph.claim_tx"), y(t.assert_tx, "depositor_graph.assert_tx"), y(t.payout_tx, "depositor_graph.payout_tx"), m(t.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(t.challenger_presign_data))
330
- throw new s(
330
+ throw new o(
331
331
  'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
332
332
  );
333
333
  for (let e = 0; e < t.challenger_presign_data.length; e++)
334
- ke(
334
+ Se(
335
335
  t.challenger_presign_data[e],
336
336
  `depositor_graph.challenger_presign_data[${e}]`
337
337
  );
338
338
  if (typeof t.offchain_params_version != "number")
339
- throw new s(
339
+ throw new o(
340
340
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
341
341
  );
342
342
  }
343
- const Oe = 6e4;
344
- class He {
343
+ const He = 6e4;
344
+ class Oe {
345
345
  constructor(e, n) {
346
346
  p(this, "client");
347
347
  const r = {
348
348
  baseUrl: e,
349
- timeout: (n == null ? void 0 : n.timeout) ?? Oe,
349
+ timeout: (n == null ? void 0 : n.timeout) ?? He,
350
350
  retries: n == null ? void 0 : n.retries,
351
351
  retryDelay: n == null ? void 0 : n.retryDelay,
352
352
  retryableFor: n == null ? void 0 : n.retryableFor,
@@ -362,7 +362,7 @@ class He {
362
362
  */
363
363
  async requestDepositorPresignTransactions(e, n) {
364
364
  const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, n);
365
- return Ve(r), r;
365
+ return Ae(r), r;
366
366
  }
367
367
  /**
368
368
  * Submit the depositor's pre-signatures for the payout transactions
@@ -393,7 +393,7 @@ class He {
393
393
  */
394
394
  async requestDepositorClaimerArtifacts(e, n) {
395
395
  const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, n);
396
- return Se(r), r;
396
+ return ke(r), r;
397
397
  }
398
398
  /** Get the current pegin status from the vault provider daemon. */
399
399
  async getPeginStatus(e, n) {
@@ -426,31 +426,31 @@ function De(t, e) {
426
426
  const n = /* @__PURE__ */ new Set();
427
427
  for (const u of t)
428
428
  n.add(u.toLowerCase());
429
- const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), o = [], a = [];
429
+ const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), i = [], a = [];
430
430
  for (const u of e) {
431
431
  const h = u.pegin_txid.toLowerCase();
432
432
  if (!n.has(h)) {
433
433
  a.push(h);
434
434
  continue;
435
435
  }
436
- if (i.has(h)) {
437
- o.push(h);
436
+ if (s.has(h)) {
437
+ i.push(h);
438
438
  continue;
439
439
  }
440
- i.add(h), r.set(h, { result: u.result, error: u.error });
440
+ s.add(h), r.set(h, { result: u.result, error: u.error });
441
441
  }
442
442
  const c = [];
443
443
  for (const u of n)
444
- i.has(u) || c.push(u);
445
- return { byTxid: r, missing: c, unexpected: a, duplicate: o };
444
+ s.has(u) || c.push(u);
445
+ return { byTxid: r, missing: c, unexpected: a, duplicate: i };
446
446
  }
447
447
  async function lt(t) {
448
448
  const {
449
449
  items: e,
450
450
  getTxid: n,
451
451
  batchCall: r,
452
- onItem: i,
453
- onMissing: o,
452
+ onItem: s,
453
+ onMissing: i,
454
454
  onDuplicate: a,
455
455
  onDuplicateBatch: c,
456
456
  onWholeBatchError: u,
@@ -462,34 +462,34 @@ async function lt(t) {
462
462
  `batchPollByProvider: batchSize must be a positive integer, got ${f}`
463
463
  );
464
464
  for (let P = 0; P < e.length; P += f) {
465
- const v = e.slice(P, P + f), k = /* @__PURE__ */ new Map(), U = [];
466
- for (const d of v) {
465
+ const x = e.slice(P, P + f), S = /* @__PURE__ */ new Map(), K = [];
466
+ for (const d of x) {
467
467
  const b = n(d).toLowerCase();
468
- k.set(b, d), U.push(b);
468
+ S.set(b, d), K.push(b);
469
469
  }
470
- let x;
470
+ let V;
471
471
  try {
472
- const d = await r(U);
473
- x = De(U, d.results);
472
+ const d = await r(K);
473
+ V = De(K, d.results);
474
474
  } catch (d) {
475
- u(v, d);
475
+ u(x, d);
476
476
  continue;
477
477
  }
478
- h && x.unexpected.length > 0 && h(x.unexpected);
479
- const S = new Set(x.duplicate);
480
- for (const d of S) {
481
- const b = k.get(d);
478
+ h && V.unexpected.length > 0 && h(V.unexpected);
479
+ const k = new Set(V.duplicate);
480
+ for (const d of k) {
481
+ const b = S.get(d);
482
482
  b && a(b);
483
483
  }
484
- c && S.size > 0 && c(S.size);
485
- for (const d of x.missing) {
486
- const b = k.get(d);
487
- b && o(b);
484
+ c && k.size > 0 && c(k.size);
485
+ for (const d of V.missing) {
486
+ const b = S.get(d);
487
+ b && i(b);
488
488
  }
489
- for (const [d, b] of x.byTxid) {
490
- if (S.has(d)) continue;
491
- const q = k.get(d);
492
- q && i(q, {
489
+ for (const [d, b] of V.byTxid) {
490
+ if (k.has(d)) continue;
491
+ const q = S.get(d);
492
+ q && s(q, {
493
493
  pegin_txid: d,
494
494
  result: b.result,
495
495
  error: b.error
@@ -497,24 +497,24 @@ async function lt(t) {
497
497
  }
498
498
  }
499
499
  }
500
- const je = "BIP0322-signed-message", Ue = "TapTweak", le = 32, Ke = 64;
500
+ const je = "BIP0322-signed-message", Ke = "TapTweak", le = 32, Ue = 64;
501
501
  function ue(t, e) {
502
- const n = new TextEncoder().encode(t), r = z(n), i = new Uint8Array(r.length * 2 + e.length);
503
- return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), z(i);
502
+ const n = new TextEncoder().encode(t), r = z(n), s = new Uint8Array(r.length * 2 + e.length);
503
+ return s.set(r, 0), s.set(r, r.length), s.set(e, r.length * 2), z(s);
504
504
  }
505
505
  function Fe(t) {
506
506
  if (t.length !== le) return null;
507
- const e = ue(Ue, t), n = j.xOnlyPointAddTweak(t, e);
507
+ const e = ue(Ke, t), n = j.xOnlyPointAddTweak(t, e);
508
508
  return n ? n.xOnlyPubkey : null;
509
509
  }
510
510
  function Me(t, e, n) {
511
- if (e.length !== le || n.length !== Ke) return !1;
511
+ if (e.length !== le || n.length !== Ue) return !1;
512
512
  try {
513
- const r = ue(je, t), i = we.p2tr({
513
+ const r = ue(je, t), s = we.p2tr({
514
514
  internalPubkey: A.from(e)
515
515
  });
516
- if (!i.output) return !1;
517
- const o = i.output, a = 0, c = new K();
516
+ if (!s.output) return !1;
517
+ const i = s.output, a = 0, c = new U();
518
518
  c.version = 0, c.locktime = 0;
519
519
  const u = A.concat([
520
520
  A.from([0, 32]),
@@ -528,58 +528,58 @@ function Me(t, e, n) {
528
528
  0,
529
529
  // sequence = 0
530
530
  u
531
- ), c.addOutput(o, a);
532
- const h = new K();
531
+ ), c.addOutput(i, a);
532
+ const h = new U();
533
533
  h.version = 0, h.locktime = 0;
534
534
  const f = c.getHash();
535
535
  h.addInput(f, 0, 0), h.addOutput(A.from([106]), a);
536
536
  const P = h.hashForWitnessV1(
537
537
  0,
538
- [o],
538
+ [i],
539
539
  [a],
540
- K.SIGHASH_DEFAULT
541
- ), v = Fe(e);
542
- return v ? j.verifySchnorr(P, v, n) : !1;
540
+ U.SIGHASH_DEFAULT
541
+ ), x = Fe(e);
542
+ return x ? j.verifySchnorr(P, x, n) : !1;
543
543
  } catch {
544
544
  return !1;
545
545
  }
546
546
  }
547
- function O(t, e) {
547
+ function H(t, e) {
548
548
  const n = (t & 7) << 5, r = typeof e == "bigint" ? e : BigInt(e);
549
549
  if (r < 0n) throw new Error("cborHead: negative argument");
550
550
  if (r < 24n) return new Uint8Array([n | Number(r)]);
551
551
  if (r < 0x100n) return new Uint8Array([n | 24, Number(r)]);
552
552
  if (r < 0x10000n) {
553
- const o = Number(r);
554
- return new Uint8Array([n | 25, o >>> 8 & 255, o & 255]);
553
+ const i = Number(r);
554
+ return new Uint8Array([n | 25, i >>> 8 & 255, i & 255]);
555
555
  }
556
556
  if (r < 0x100000000n) {
557
- const o = Number(r);
557
+ const i = Number(r);
558
558
  return new Uint8Array([
559
559
  n | 26,
560
- o >>> 24 & 255,
561
- o >>> 16 & 255,
562
- o >>> 8 & 255,
563
- o & 255
560
+ i >>> 24 & 255,
561
+ i >>> 16 & 255,
562
+ i >>> 8 & 255,
563
+ i & 255
564
564
  ]);
565
565
  }
566
- const i = new Uint8Array(9);
567
- i[0] = n | 27;
568
- for (let o = 7; o >= 0; o--)
569
- i[1 + o] = Number(r >> BigInt((7 - o) * 8)) & 255;
570
- return i;
566
+ const s = new Uint8Array(9);
567
+ s[0] = n | 27;
568
+ for (let i = 7; i >= 0; i--)
569
+ s[1 + i] = Number(r >> BigInt((7 - i) * 8)) & 255;
570
+ return s;
571
571
  }
572
572
  function he(...t) {
573
- const e = t.reduce((i, o) => i + o.length, 0), n = new Uint8Array(e);
573
+ const e = t.reduce((s, i) => s + i.length, 0), n = new Uint8Array(e);
574
574
  let r = 0;
575
- for (const i of t)
576
- n.set(i, r), r += i.length;
575
+ for (const s of t)
576
+ n.set(s, r), r += s.length;
577
577
  return n;
578
578
  }
579
579
  function Q(t) {
580
- const n = [O(4, t.length)];
580
+ const n = [H(4, t.length)];
581
581
  for (const r of t)
582
- n.push(O(0, r));
582
+ n.push(H(0, r));
583
583
  return he(...n);
584
584
  }
585
585
  function Le(t, e, n) {
@@ -587,8 +587,8 @@ function Le(t, e, n) {
587
587
  throw new Error(
588
588
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${n}`
589
589
  );
590
- const r = O(4, 3), i = Q(t), o = Q(e), a = O(0, n);
591
- return he(r, i, o, a);
590
+ const r = H(4, 3), s = Q(t), i = Q(e), a = H(0, n);
591
+ return he(r, s, i, a);
592
592
  }
593
593
  const Ge = new TextEncoder().encode(
594
594
  "btc-auth.server-identity.v1"
@@ -605,10 +605,10 @@ function E(t) {
605
605
  return e;
606
606
  }
607
607
  function qe(t) {
608
- const { proof: e, pinnedServerPubkey: n, now: r } = t, i = t.maxLifetimeSecs ?? Xe, o = C(n).toLowerCase();
609
- if (o.length !== R || !T.test(o))
608
+ const { proof: e, pinnedServerPubkey: n, now: r } = t, s = t.maxLifetimeSecs ?? Xe, i = C(n).toLowerCase();
609
+ if (i.length !== R || !T.test(i))
610
610
  throw new g(
611
- `pinnedServerPubkey must be 32-byte hex; got ${o.length} chars`,
611
+ `pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
612
612
  "invalid_pubkey_encoding"
613
613
  );
614
614
  const a = C(e.server_pubkey).toLowerCase();
@@ -617,9 +617,9 @@ function qe(t) {
617
617
  `server_pubkey must be 32-byte hex; got ${a.length} chars`,
618
618
  "invalid_pubkey_encoding"
619
619
  );
620
- if (a !== o)
620
+ if (a !== i)
621
621
  throw new g(
622
- `server_pubkey does not match pinned value: expected ${o}, got ${a}`,
622
+ `server_pubkey does not match pinned value: expected ${i}, got ${a}`,
623
623
  "pinned_pubkey_mismatch"
624
624
  );
625
625
  if (!Number.isSafeInteger(e.expires_at))
@@ -637,14 +637,14 @@ function qe(t) {
637
637
  `server identity proof expired at ${e.expires_at}, now ${r}`,
638
638
  "expired"
639
639
  );
640
- if (!Number.isSafeInteger(i) || i <= 0)
640
+ if (!Number.isSafeInteger(s) || s <= 0)
641
641
  throw new g(
642
- `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
642
+ `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,
643
643
  "invalid_max_lifetime"
644
644
  );
645
- if (e.expires_at - r > i)
645
+ if (e.expires_at - r > s)
646
646
  throw new g(
647
- `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${i}s`,
647
+ `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${s}s`,
648
648
  "expires_too_far"
649
649
  );
650
650
  const c = C(e.ephemeral_pubkey).toLowerCase();
@@ -766,16 +766,16 @@ class Je {
766
766
  throw new Error(
767
767
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
768
768
  );
769
- const i = this.now();
770
- if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > J)
769
+ const s = this.now();
770
+ if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= s || r.expires_at > J)
771
771
  throw new Error(
772
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${J}])`
772
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${s}, ${J}])`
773
773
  );
774
- const o = {
774
+ const i = {
775
775
  token: r.token,
776
776
  expiresAt: r.expires_at
777
777
  };
778
- return this.cached = o, o;
778
+ return this.cached = i, i;
779
779
  } finally {
780
780
  this.inFlight = null;
781
781
  }
@@ -858,7 +858,7 @@ function ut(t) {
858
858
  authAnchorHex: t.authAnchorHex,
859
859
  pinnedServerPubkey: t.pinnedServerPubkey
860
860
  });
861
- return new He(t.baseUrl, {
861
+ return new Oe(t.baseUrl, {
862
862
  ...t.options,
863
863
  tokenProvider: n
864
864
  });
@@ -876,12 +876,12 @@ async function dt(t, e) {
876
876
  contracts: [
877
877
  {
878
878
  address: e,
879
- abi: V,
879
+ abi: w,
880
880
  functionName: "protocolParams"
881
881
  },
882
882
  {
883
883
  address: e,
884
- abi: V,
884
+ abi: w,
885
885
  functionName: "applicationRegistry"
886
886
  }
887
887
  ],
@@ -892,9 +892,9 @@ async function dt(t, e) {
892
892
  applicationRegistry: r
893
893
  };
894
894
  }
895
- const M = 65535, Y = 1e4, H = 4294967295, Z = 255;
895
+ const M = 65535, Y = 1e4, O = 4294967295, Z = 255;
896
896
  function X(t) {
897
- if (!Number.isInteger(t) || t < 0 || t > H)
897
+ if (!Number.isInteger(t) || t < 0 || t > O)
898
898
  throw new Error(
899
899
  `Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`
900
900
  );
@@ -913,8 +913,8 @@ function N(t) {
913
913
  `minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`
914
914
  ), (!Number.isInteger(t.proverProgramVersion) || t.proverProgramVersion < 0 || t.proverProgramVersion > M) && e.push(
915
915
  `proverProgramVersion must be a uint16, got ${t.proverProgramVersion}`
916
- ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > H) && e.push(
917
- `minPrepeginDepth must be a uint32 in [1, ${H}], got ${t.minPrepeginDepth}`
916
+ ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > O) && e.push(
917
+ `minPrepeginDepth must be a uint32 in [1, ${O}], got ${t.minPrepeginDepth}`
918
918
  ), t.babeTotalInstances <= 0 && e.push(
919
919
  `babeTotalInstances must be positive, got ${t.babeTotalInstances}`
920
920
  ), t.babeInstancesToFinalize <= 0 && e.push(
@@ -944,7 +944,7 @@ function ge(t) {
944
944
  throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
945
945
  }
946
946
  function Ze(t) {
947
- if (ge(t), N(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > H)
947
+ if (ge(t), N(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > O)
948
948
  throw new Error(
949
949
  `Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
950
950
  );
@@ -1051,7 +1051,7 @@ class pt {
1051
1051
  }
1052
1052
  ],
1053
1053
  allowFailure: !1
1054
- }), n = te(e[0]), r = B(e[1]), i = Number(e[2]), o = {
1054
+ }), n = te(e[0]), r = B(e[1]), s = Number(e[2]), i = {
1055
1055
  minimumPegInAmount: n.minimumPegInAmount,
1056
1056
  maxPegInAmount: n.maxPegInAmount,
1057
1057
  pegInAckTimeout: n.pegInAckTimeout,
@@ -1061,9 +1061,9 @@ class pt {
1061
1061
  timelockRefund: r.tRefund,
1062
1062
  minVpCommissionBps: r.minVpCommissionBps,
1063
1063
  offchainParams: r,
1064
- offchainParamsVersion: i
1064
+ offchainParamsVersion: s
1065
1065
  };
1066
- return Ze(o), o;
1066
+ return Ze(i), i;
1067
1067
  }
1068
1068
  /**
1069
1069
  * Fetch every historical offchain params version in a single multicall.
@@ -1079,17 +1079,17 @@ class pt {
1079
1079
  const n = await this.getLatestOffchainParamsVersion();
1080
1080
  if (n === 0)
1081
1081
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
1082
- const r = Array.from({ length: n }, (c, u) => u + 1), i = r.map((c) => ({
1082
+ const r = Array.from({ length: n }, (c, u) => u + 1), s = r.map((c) => ({
1083
1083
  address: this.contractAddress,
1084
1084
  abi: _,
1085
1085
  functionName: "getOffchainParamsByVersion",
1086
1086
  args: [c]
1087
- })), o = await this.publicClient.multicall({
1088
- contracts: i,
1087
+ })), i = await this.publicClient.multicall({
1088
+ contracts: s,
1089
1089
  allowFailure: !1
1090
1090
  }), a = /* @__PURE__ */ new Map();
1091
1091
  for (let c = 0; c < r.length; c++) {
1092
- const u = B(o[c]);
1092
+ const u = B(i[c]);
1093
1093
  try {
1094
1094
  N(u), a.set(r[c], u);
1095
1095
  } catch (h) {
@@ -1181,7 +1181,7 @@ class mt {
1181
1181
  async getVaultProviderBtcPubKey(e) {
1182
1182
  const r = (await this.publicClient.readContract({
1183
1183
  address: this.contractAddress,
1184
- abi: V,
1184
+ abi: w,
1185
1185
  functionName: "getVaultProviderBTCKey",
1186
1186
  args: [e]
1187
1187
  })).toLowerCase();
@@ -1189,17 +1189,17 @@ class mt {
1189
1189
  throw new Error(
1190
1190
  `getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
1191
1191
  );
1192
- const i = r.slice(2);
1193
- if (!j.isXOnlyPoint(Pe(i)))
1192
+ const s = r.slice(2);
1193
+ if (!j.isXOnlyPoint(Pe(s)))
1194
1194
  throw new Error(
1195
1195
  `getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
1196
1196
  );
1197
- return i;
1197
+ return s;
1198
1198
  }
1199
1199
  async getVaultBasicInfo(e) {
1200
1200
  const n = await this.publicClient.readContract({
1201
1201
  address: this.contractAddress,
1202
- abi: V,
1202
+ abi: w,
1203
1203
  functionName: "getBtcVaultBasicInfo",
1204
1204
  args: [e]
1205
1205
  });
@@ -1216,7 +1216,7 @@ class mt {
1216
1216
  async getVaultProtocolInfo(e) {
1217
1217
  const n = await this.publicClient.readContract({
1218
1218
  address: this.contractAddress,
1219
- abi: V,
1219
+ abi: w,
1220
1220
  functionName: "getBtcVaultProtocolInfo",
1221
1221
  args: [e]
1222
1222
  }), r = Number(n.offchainParamsVersion);
@@ -1234,6 +1234,36 @@ class mt {
1234
1234
  vaultProviderCommissionBps: n.vaultProviderCommissionBps
1235
1235
  };
1236
1236
  }
1237
+ async getProtocolInfoBatch(e) {
1238
+ return e.length === 0 ? [] : (await this.publicClient.multicall({
1239
+ contracts: e.map((r) => ({
1240
+ address: this.contractAddress,
1241
+ abi: w,
1242
+ functionName: "getBtcVaultProtocolInfo",
1243
+ args: [r]
1244
+ })),
1245
+ allowFailure: !1
1246
+ })).map((r, s) => {
1247
+ const i = r;
1248
+ if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
1249
+ throw new Error(
1250
+ `Vault ${e[s]} not found on-chain or has no pegin transaction`
1251
+ );
1252
+ return {
1253
+ depositorSignedPeginTx: i.depositorSignedPeginTx,
1254
+ universalChallengersVersion: i.universalChallengersVersion,
1255
+ appVaultKeepersVersion: i.appVaultKeepersVersion,
1256
+ offchainParamsVersion: i.offchainParamsVersion,
1257
+ verifiedAt: i.verifiedAt,
1258
+ depositorWotsPkHash: i.depositorWotsPkHash,
1259
+ hashlock: i.hashlock,
1260
+ htlcVout: i.htlcVout,
1261
+ depositorPopSignature: i.depositorPopSignature,
1262
+ prePeginTxHash: i.prePeginTxHash,
1263
+ vaultProviderCommissionBps: i.vaultProviderCommissionBps
1264
+ };
1265
+ });
1266
+ }
1237
1267
  async getVaultData(e) {
1238
1268
  const [n, r] = await Promise.all([
1239
1269
  this.getVaultBasicInfo(e),
@@ -1254,26 +1284,26 @@ class mt {
1254
1284
  return e.length === 0 ? [] : (await this.publicClient.multicall({
1255
1285
  contracts: e.map((r) => ({
1256
1286
  address: this.contractAddress,
1257
- abi: V,
1287
+ abi: w,
1258
1288
  functionName: "getBtcVaultProtocolInfo",
1259
1289
  args: [r]
1260
1290
  })),
1261
1291
  allowFailure: !1
1262
1292
  })).map((r) => {
1263
- const i = r;
1264
- if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
1293
+ const s = r;
1294
+ if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
1265
1295
  throw new Error(
1266
1296
  "Vault not found on-chain or has no pegin transaction while reading offchain params version"
1267
1297
  );
1268
- const o = Number(i.offchainParamsVersion);
1269
- return X(o), o;
1298
+ const i = Number(s.offchainParamsVersion);
1299
+ return X(i), i;
1270
1300
  });
1271
1301
  }
1272
1302
  }
1273
1303
  export {
1274
1304
  g as S,
1275
- He as V,
1276
- s as a,
1305
+ Oe as V,
1306
+ o as a,
1277
1307
  lt as b,
1278
1308
  qe as c,
1279
1309
  Ye as d,
@@ -1288,6 +1318,6 @@ export {
1288
1318
  mt as m,
1289
1319
  ht as p,
1290
1320
  dt as r,
1291
- Se as v
1321
+ ke as v
1292
1322
  };
1293
- //# sourceMappingURL=vault-registry-reader-Bz8uu0dh.js.map
1323
+ //# sourceMappingURL=vault-registry-reader-CrLodprY.js.map