@babylonlabs-io/ts-sdk 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/{buildAndBroadcastRefund-BzYJv-Fv.js → buildAndBroadcastRefund-Cc4-L7gX.js} +32 -31
  2. package/dist/buildAndBroadcastRefund-Cc4-L7gX.js.map +1 -0
  3. package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs +2 -0
  4. package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs.map +1 -0
  5. package/dist/deriveVaultRoot-B4gnRbW_.cjs +2 -0
  6. package/dist/deriveVaultRoot-B4gnRbW_.cjs.map +1 -0
  7. package/dist/{context-CClNOyD3.js → deriveVaultRoot-DAMZDqg-.js} +495 -541
  8. package/dist/deriveVaultRoot-DAMZDqg-.js.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +55 -55
  11. package/dist/psbtInputFields-CB8hqjQ5.cjs +2 -0
  12. package/dist/psbtInputFields-CB8hqjQ5.cjs.map +1 -0
  13. package/dist/{psbtInputFields-C3dqKWjQ.js → psbtInputFields-DeTFSJOq.js} +70 -64
  14. package/dist/psbtInputFields-DeTFSJOq.js.map +1 -0
  15. package/dist/sha2-CPdTLk1u.js +280 -0
  16. package/dist/sha2-CPdTLk1u.js.map +1 -0
  17. package/dist/sha2-CsTynrfJ.cjs +2 -0
  18. package/dist/sha2-CsTynrfJ.cjs.map +1 -0
  19. package/dist/shared/index.cjs.map +1 -1
  20. package/dist/shared/index.js.map +1 -1
  21. package/dist/shared/wallets/index.d.ts +2 -1
  22. package/dist/shared/wallets/index.d.ts.map +1 -1
  23. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +8 -0
  24. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
  25. package/dist/signing-BZigafm0.js.map +1 -1
  26. package/dist/signing-DHSXjhLM.cjs.map +1 -1
  27. package/dist/tbv/core/clients/index.cjs +1 -1
  28. package/dist/tbv/core/clients/index.js +2 -2
  29. package/dist/tbv/core/index.cjs +1 -1
  30. package/dist/tbv/core/index.js +52 -52
  31. package/dist/tbv/core/services/deposit/peginState.d.ts +1 -1
  32. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  33. package/dist/tbv/core/services/index.cjs +1 -1
  34. package/dist/tbv/core/services/index.js +1 -1
  35. package/dist/tbv/core/utils/index.cjs +1 -1
  36. package/dist/tbv/core/utils/index.js +1 -1
  37. package/dist/tbv/core/utils/utxo/reservation.d.ts +5 -0
  38. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  39. package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts +13 -0
  40. package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts.map +1 -0
  41. package/dist/tbv/core/vault-secrets/context.d.ts +9 -0
  42. package/dist/tbv/core/vault-secrets/context.d.ts.map +1 -1
  43. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +56 -0
  44. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -0
  45. package/dist/tbv/core/vault-secrets/expand.d.ts +18 -3
  46. package/dist/tbv/core/vault-secrets/expand.d.ts.map +1 -1
  47. package/dist/tbv/core/vault-secrets/index.d.ts +6 -3
  48. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  49. package/dist/tbv/core/wots/blockDerivation.d.ts +20 -24
  50. package/dist/tbv/core/wots/blockDerivation.d.ts.map +1 -1
  51. package/dist/tbv/core/wots/errors.d.ts +3 -1
  52. package/dist/tbv/core/wots/errors.d.ts.map +1 -1
  53. package/dist/tbv/core/wots/index.d.ts +1 -2
  54. package/dist/tbv/core/wots/index.d.ts.map +1 -1
  55. package/dist/tbv/index.cjs +1 -1
  56. package/dist/tbv/index.js +52 -52
  57. package/dist/testing/MockBitcoinWallet.d.ts +9 -3
  58. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  59. package/dist/testing/index.cjs +1 -1
  60. package/dist/testing/index.cjs.map +1 -1
  61. package/dist/testing/index.js +65 -54
  62. package/dist/testing/index.js.map +1 -1
  63. package/dist/types-CQ86O7NX.js +650 -0
  64. package/dist/types-CQ86O7NX.js.map +1 -0
  65. package/dist/types-CcwaEPE1.cjs +2 -0
  66. package/dist/types-CcwaEPE1.cjs.map +1 -0
  67. package/dist/{vault-registry-reader-CpCOte7w.js → vault-registry-reader-CshEgmS0.js} +31 -30
  68. package/dist/{vault-registry-reader-CpCOte7w.js.map → vault-registry-reader-CshEgmS0.js.map} +1 -1
  69. package/dist/vault-registry-reader-_2BjSjoN.cjs +2 -0
  70. package/dist/{vault-registry-reader-BizmBSBV.cjs.map → vault-registry-reader-_2BjSjoN.cjs.map} +1 -1
  71. package/package.json +3 -3
  72. package/dist/buildAndBroadcastRefund-BEASMFsz.cjs +0 -2
  73. package/dist/buildAndBroadcastRefund-BEASMFsz.cjs.map +0 -1
  74. package/dist/buildAndBroadcastRefund-BzYJv-Fv.js.map +0 -1
  75. package/dist/context-BSdcD4J_.cjs +0 -2
  76. package/dist/context-BSdcD4J_.cjs.map +0 -1
  77. package/dist/context-CClNOyD3.js.map +0 -1
  78. package/dist/psbtInputFields-C3dqKWjQ.js.map +0 -1
  79. package/dist/psbtInputFields-DhGm77bP.cjs +0 -2
  80. package/dist/psbtInputFields-DhGm77bP.cjs.map +0 -1
  81. package/dist/sha2-1XZuToHP.cjs +0 -2
  82. package/dist/sha2-1XZuToHP.cjs.map +0 -1
  83. package/dist/sha2-ZzfZqQSw.js +0 -1123
  84. package/dist/sha2-ZzfZqQSw.js.map +0 -1
  85. package/dist/tbv/core/wots/deriveWotsPkHash.d.ts +0 -9
  86. package/dist/tbv/core/wots/deriveWotsPkHash.d.ts.map +0 -1
  87. package/dist/vault-registry-reader-BizmBSBV.cjs +0 -2
@@ -0,0 +1,650 @@
1
+ var R = Object.defineProperty;
2
+ var h = (e, t, n) => t in e ? R(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var p = (e, t, n) => h(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const k = [
5
+ {
6
+ type: "function",
7
+ name: "submitPeginRequest",
8
+ inputs: [
9
+ {
10
+ name: "depositor",
11
+ type: "address",
12
+ internalType: "address"
13
+ },
14
+ {
15
+ name: "depositorBtcPubKey",
16
+ type: "bytes32",
17
+ internalType: "bytes32"
18
+ },
19
+ {
20
+ name: "btcPopSignature",
21
+ type: "bytes",
22
+ internalType: "bytes"
23
+ },
24
+ {
25
+ name: "unsignedPrePeginTx",
26
+ type: "bytes",
27
+ internalType: "bytes"
28
+ },
29
+ {
30
+ name: "depositorSignedPeginTx",
31
+ type: "bytes",
32
+ internalType: "bytes"
33
+ },
34
+ {
35
+ name: "vaultProvider",
36
+ type: "address",
37
+ internalType: "address"
38
+ },
39
+ {
40
+ name: "hashlock",
41
+ type: "bytes32",
42
+ internalType: "bytes32"
43
+ },
44
+ {
45
+ name: "htlcVout",
46
+ type: "uint8",
47
+ internalType: "uint8"
48
+ },
49
+ {
50
+ name: "depositorPayoutBtcAddress",
51
+ type: "bytes",
52
+ internalType: "bytes"
53
+ },
54
+ {
55
+ name: "depositorWotsPkHash",
56
+ type: "bytes32",
57
+ internalType: "bytes32"
58
+ }
59
+ ],
60
+ outputs: [
61
+ {
62
+ name: "",
63
+ type: "bytes32",
64
+ internalType: "bytes32"
65
+ }
66
+ ],
67
+ stateMutability: "payable"
68
+ },
69
+ {
70
+ type: "function",
71
+ name: "submitPeginRequest",
72
+ inputs: [
73
+ {
74
+ name: "depositor",
75
+ type: "address",
76
+ internalType: "address"
77
+ },
78
+ {
79
+ name: "depositorBtcPubKey",
80
+ type: "bytes32",
81
+ internalType: "bytes32"
82
+ },
83
+ {
84
+ name: "btcPopSignature",
85
+ type: "bytes",
86
+ internalType: "bytes"
87
+ },
88
+ {
89
+ name: "unsignedPrePeginTx",
90
+ type: "bytes",
91
+ internalType: "bytes"
92
+ },
93
+ {
94
+ name: "depositorSignedPeginTx",
95
+ type: "bytes",
96
+ internalType: "bytes"
97
+ },
98
+ {
99
+ name: "vaultProvider",
100
+ type: "address",
101
+ internalType: "address"
102
+ },
103
+ {
104
+ name: "hashlock",
105
+ type: "bytes32",
106
+ internalType: "bytes32"
107
+ },
108
+ {
109
+ name: "htlcVout",
110
+ type: "uint8",
111
+ internalType: "uint8"
112
+ },
113
+ {
114
+ name: "referralCode",
115
+ type: "uint32",
116
+ internalType: "uint32"
117
+ },
118
+ {
119
+ name: "depositorPayoutBtcAddress",
120
+ type: "bytes",
121
+ internalType: "bytes"
122
+ },
123
+ {
124
+ name: "depositorWotsPkHash",
125
+ type: "bytes32",
126
+ internalType: "bytes32"
127
+ }
128
+ ],
129
+ outputs: [
130
+ {
131
+ name: "",
132
+ type: "bytes32",
133
+ internalType: "bytes32"
134
+ }
135
+ ],
136
+ stateMutability: "payable"
137
+ },
138
+ {
139
+ type: "function",
140
+ name: "submitPeginRequestBatch",
141
+ inputs: [
142
+ { name: "depositor", type: "address", internalType: "address" },
143
+ { name: "vaultProvider", type: "address", internalType: "address" },
144
+ {
145
+ name: "requests",
146
+ type: "tuple[]",
147
+ internalType: "struct IBTCVaultRegistry.BatchPeginRequest[]",
148
+ components: [
149
+ { name: "depositorBtcPubKey", type: "bytes32", internalType: "bytes32" },
150
+ { name: "btcPopSignature", type: "bytes", internalType: "bytes" },
151
+ { name: "unsignedPrePeginTx", type: "bytes", internalType: "bytes" },
152
+ { name: "depositorSignedPeginTx", type: "bytes", internalType: "bytes" },
153
+ { name: "hashlock", type: "bytes32", internalType: "bytes32" },
154
+ { name: "htlcVout", type: "uint8", internalType: "uint8" },
155
+ { name: "referralCode", type: "uint32", internalType: "uint32" },
156
+ { name: "depositorPayoutBtcAddress", type: "bytes", internalType: "bytes" },
157
+ { name: "depositorWotsPkHash", type: "bytes32", internalType: "bytes32" }
158
+ ]
159
+ }
160
+ ],
161
+ outputs: [
162
+ { name: "vaultIds", type: "bytes32[]", internalType: "bytes32[]" }
163
+ ],
164
+ stateMutability: "payable"
165
+ },
166
+ {
167
+ type: "function",
168
+ name: "activateVaultWithSecret",
169
+ inputs: [
170
+ {
171
+ name: "vaultId",
172
+ type: "bytes32",
173
+ internalType: "bytes32"
174
+ },
175
+ {
176
+ name: "s",
177
+ type: "bytes32",
178
+ internalType: "bytes32"
179
+ },
180
+ {
181
+ name: "activationMetadata",
182
+ type: "bytes",
183
+ internalType: "bytes"
184
+ }
185
+ ],
186
+ outputs: [],
187
+ stateMutability: "nonpayable"
188
+ },
189
+ {
190
+ type: "function",
191
+ name: "getPegInFee",
192
+ inputs: [
193
+ {
194
+ name: "vaultProvider",
195
+ type: "address",
196
+ internalType: "address"
197
+ }
198
+ ],
199
+ outputs: [
200
+ {
201
+ name: "totalFee",
202
+ type: "uint256",
203
+ internalType: "uint256"
204
+ }
205
+ ],
206
+ stateMutability: "view"
207
+ },
208
+ {
209
+ type: "function",
210
+ name: "getBtcVaultBasicInfo",
211
+ inputs: [
212
+ {
213
+ name: "vaultId",
214
+ type: "bytes32",
215
+ internalType: "bytes32"
216
+ }
217
+ ],
218
+ outputs: [
219
+ { name: "depositor", type: "address", internalType: "address" },
220
+ { name: "depositorBtcPubKey", type: "bytes32", internalType: "bytes32" },
221
+ { name: "amount", type: "uint256", internalType: "uint256" },
222
+ { name: "vaultProvider", type: "address", internalType: "address" },
223
+ { name: "status", type: "uint8", internalType: "enum IBTCVaultRegistry.BTCVaultStatus" },
224
+ { name: "applicationEntryPoint", type: "address", internalType: "address" },
225
+ { name: "createdAt", type: "uint256", internalType: "uint256" }
226
+ ],
227
+ stateMutability: "view"
228
+ },
229
+ {
230
+ type: "error",
231
+ name: "InvalidPeginFee",
232
+ inputs: [
233
+ {
234
+ name: "provided",
235
+ type: "uint256",
236
+ internalType: "uint256"
237
+ },
238
+ {
239
+ name: "required",
240
+ type: "uint256",
241
+ internalType: "uint256"
242
+ }
243
+ ]
244
+ },
245
+ {
246
+ type: "error",
247
+ name: "InvalidSecret",
248
+ inputs: []
249
+ },
250
+ {
251
+ type: "error",
252
+ name: "ActivationDeadlineExpired",
253
+ inputs: []
254
+ },
255
+ {
256
+ type: "error",
257
+ name: "InvalidHashlock",
258
+ inputs: []
259
+ },
260
+ {
261
+ type: "error",
262
+ name: "DuplicateHashlock",
263
+ inputs: []
264
+ },
265
+ {
266
+ type: "error",
267
+ name: "CapExceeded",
268
+ inputs: []
269
+ },
270
+ {
271
+ type: "error",
272
+ name: "InvalidOutputIndex",
273
+ inputs: []
274
+ },
275
+ {
276
+ type: "error",
277
+ name: "PeginSignaturesIncomplete",
278
+ inputs: []
279
+ },
280
+ {
281
+ type: "function",
282
+ name: "getBtcVaultProtocolInfo",
283
+ inputs: [
284
+ {
285
+ name: "vaultId",
286
+ type: "bytes32",
287
+ internalType: "bytes32"
288
+ }
289
+ ],
290
+ outputs: [
291
+ {
292
+ name: "depositorSignedPeginTx",
293
+ type: "bytes",
294
+ internalType: "bytes"
295
+ },
296
+ {
297
+ name: "universalChallengersVersion",
298
+ type: "uint16",
299
+ internalType: "uint16"
300
+ },
301
+ {
302
+ name: "appVaultKeepersVersion",
303
+ type: "uint16",
304
+ internalType: "uint16"
305
+ },
306
+ {
307
+ name: "offchainParamsVersion",
308
+ type: "uint16",
309
+ internalType: "uint16"
310
+ },
311
+ {
312
+ name: "verifiedAt",
313
+ type: "uint256",
314
+ internalType: "uint256"
315
+ },
316
+ {
317
+ name: "depositorWotsPkHash",
318
+ type: "bytes32",
319
+ internalType: "bytes32"
320
+ },
321
+ {
322
+ name: "hashlock",
323
+ type: "bytes32",
324
+ internalType: "bytes32"
325
+ },
326
+ {
327
+ name: "htlcVout",
328
+ type: "uint8",
329
+ internalType: "uint8"
330
+ },
331
+ {
332
+ name: "depositorPopSignature",
333
+ type: "bytes",
334
+ internalType: "bytes"
335
+ },
336
+ {
337
+ name: "prePeginTxHash",
338
+ type: "bytes32",
339
+ internalType: "bytes32"
340
+ },
341
+ {
342
+ name: "vaultProviderCommissionBps",
343
+ type: "uint16",
344
+ internalType: "uint16"
345
+ }
346
+ ],
347
+ stateMutability: "view"
348
+ },
349
+ {
350
+ type: "function",
351
+ name: "protocolParams",
352
+ inputs: [],
353
+ outputs: [
354
+ {
355
+ name: "",
356
+ type: "address",
357
+ internalType: "contract IProtocolParams"
358
+ }
359
+ ],
360
+ stateMutability: "view"
361
+ },
362
+ {
363
+ type: "function",
364
+ name: "applicationRegistry",
365
+ inputs: [],
366
+ outputs: [
367
+ {
368
+ name: "",
369
+ type: "address",
370
+ internalType: "contract IApplicationRegistry"
371
+ }
372
+ ],
373
+ stateMutability: "view"
374
+ }
375
+ ];
376
+ class d extends Error {
377
+ constructor(t, n, r = "local", i) {
378
+ super(n), this.code = t, this.source = r, this.data = i, this.name = "JsonRpcError";
379
+ }
380
+ }
381
+ const T = {
382
+ TIMEOUT: -32e3,
383
+ NETWORK: -32001,
384
+ /** VP proxy: request timed out at proxy level */
385
+ PROXY_TIMEOUT: -32002,
386
+ /** VP proxy: VP unreachable / DNS failure / response too large */
387
+ PROXY_UNAVAILABLE: -32003,
388
+ /** SDK client: response missing "result" field (malformed JSON-RPC) */
389
+ INVALID_RESPONSE: -32700
390
+ }, A = "2.0", _ = 3, S = 1e3, N = /* @__PURE__ */ new Set([
391
+ 408,
392
+ // Request Timeout
393
+ 429,
394
+ // Too Many Requests
395
+ 500,
396
+ // Internal Server Error
397
+ 502,
398
+ // Bad Gateway
399
+ 503,
400
+ // Service Unavailable
401
+ 504
402
+ // Gateway Timeout
403
+ ]), g = /* @__PURE__ */ new Set([
404
+ "vaultProvider_getPeginStatus",
405
+ "vaultProvider_getPegoutStatus",
406
+ "vaultProvider_requestDepositorPresignTransactions"
407
+ ]);
408
+ function v(e) {
409
+ return g.has(e);
410
+ }
411
+ const O = "auth_expired";
412
+ function f(e) {
413
+ if (!(e instanceof d) || e.source !== "wire") return !1;
414
+ const t = e.data;
415
+ return t === null || typeof t != "object" ? !1 : t.kind === O;
416
+ }
417
+ class C {
418
+ constructor(t) {
419
+ p(this, "baseUrl");
420
+ p(this, "timeout");
421
+ p(this, "headers");
422
+ p(this, "requestId", 0);
423
+ p(this, "retries");
424
+ p(this, "retryDelay");
425
+ p(this, "retryableFor");
426
+ p(this, "tokenProvider");
427
+ this.baseUrl = t.baseUrl.replace(/\/$/, ""), this.timeout = t.timeout, this.headers = {
428
+ "Content-Type": "application/json",
429
+ ...t.headers
430
+ }, this.retries = t.retries ?? _, this.retryDelay = t.retryDelay ?? S, this.retryableFor = t.retryableFor ?? v, this.tokenProvider = t.tokenProvider;
431
+ }
432
+ async buildHeaders(t) {
433
+ const n = { ...this.headers };
434
+ if (this.tokenProvider) {
435
+ const r = await this.tokenProvider.getToken(t);
436
+ r && (n.Authorization = `Bearer ${r}`);
437
+ }
438
+ return n;
439
+ }
440
+ /**
441
+ * Make a JSON-RPC request with optional retry for safe methods.
442
+ *
443
+ * If the request fails with a wire-origin `auth_expired` error and a
444
+ * `tokenProvider` is configured, the client invalidates its cached
445
+ * token and retries the request once with a freshly-acquired bearer.
446
+ *
447
+ * @param method - The RPC method name
448
+ * @param params - The method parameters
449
+ * @param signal - Optional AbortSignal for caller-controlled cancellation
450
+ * @returns The result from the RPC method
451
+ * @throws JsonRpcError if the RPC call fails
452
+ */
453
+ async call(t, n, r) {
454
+ try {
455
+ return await this.callOnce(t, n, r);
456
+ } catch (i) {
457
+ if (this.tokenProvider && f(i))
458
+ return this.tokenProvider.invalidate(), await this.callOnce(t, n, r);
459
+ throw i;
460
+ }
461
+ }
462
+ async callOnce(t, n, r) {
463
+ const i = await this.fetchWithRetry(t, n, r);
464
+ let s;
465
+ try {
466
+ s = await i.json();
467
+ } catch {
468
+ throw new d(
469
+ T.INVALID_RESPONSE,
470
+ "Invalid JSON-RPC response: body is not valid JSON",
471
+ "local"
472
+ );
473
+ }
474
+ if (s === null || typeof s != "object" || Array.isArray(s))
475
+ throw new d(
476
+ T.INVALID_RESPONSE,
477
+ `Invalid JSON-RPC response: expected an object, got ${typeof s}`,
478
+ "local"
479
+ );
480
+ const o = s;
481
+ if ("error" in o && o.error != null) {
482
+ const P = o.error;
483
+ throw new d(
484
+ P.code ?? T.INVALID_RESPONSE,
485
+ P.message ?? "Unknown RPC error",
486
+ "wire",
487
+ P.data
488
+ );
489
+ }
490
+ if (!("result" in o))
491
+ throw new d(
492
+ T.INVALID_RESPONSE,
493
+ 'Invalid JSON-RPC response: missing "result" field',
494
+ "local"
495
+ );
496
+ return o.result;
497
+ }
498
+ /**
499
+ * Make a JSON-RPC request returning the raw Response (unparsed body).
500
+ *
501
+ * Bearer tokens are injected identically to `call`. **Reactive refresh
502
+ * is NOT performed here** — the response body may be unbounded (e.g.
503
+ * claimer-artifact downloads), so the client refuses to parse it to
504
+ * detect auth errors. Callers relying on token-expired retries for
505
+ * large downloads must read the body themselves and re-invoke
506
+ * `callRaw` after `tokenProvider.invalidate()`.
507
+ */
508
+ async callRaw(t, n, r) {
509
+ return this.fetchWithRetry(t, n, r);
510
+ }
511
+ async fetchWithRetry(t, n, r) {
512
+ const i = ++this.requestId, s = this.retryableFor(t) ? this.retries : 0, P = JSON.stringify({
513
+ jsonrpc: A,
514
+ method: t,
515
+ params: [n],
516
+ id: i
517
+ });
518
+ let b = null;
519
+ for (let u = 0; u <= s; u++) {
520
+ const c = new AbortController(), m = setTimeout(
521
+ () => c.abort(),
522
+ this.timeout
523
+ ), l = r ? w(r, c.signal) : null, E = l ? l.signal : c.signal;
524
+ try {
525
+ const a = await this.buildHeaders(t), y = await fetch(this.baseUrl, {
526
+ method: "POST",
527
+ headers: a,
528
+ body: P,
529
+ signal: E
530
+ });
531
+ if (clearTimeout(m), l == null || l.cleanup(), !y.ok) {
532
+ if (u < s && N.has(y.status)) {
533
+ const I = this.retryDelay * Math.pow(2, u);
534
+ await this.sleep(I, r);
535
+ continue;
536
+ }
537
+ throw new Error(
538
+ `HTTP error: ${y.status} ${y.statusText}`
539
+ );
540
+ }
541
+ return y;
542
+ } catch (a) {
543
+ if (clearTimeout(m), l == null || l.cleanup(), b = a instanceof Error ? a : new Error(String(a)), r != null && r.aborted)
544
+ throw new Error("Request aborted");
545
+ if (a instanceof Error && a.name === "AbortError") {
546
+ if (u < s) {
547
+ const y = this.retryDelay * Math.pow(2, u);
548
+ await this.sleep(y, r);
549
+ continue;
550
+ }
551
+ throw new d(
552
+ T.TIMEOUT,
553
+ `Request timeout after ${this.timeout}ms (${s + 1} attempts)`,
554
+ "local"
555
+ );
556
+ }
557
+ if (a instanceof TypeError) {
558
+ if (u < s) {
559
+ const y = this.retryDelay * Math.pow(2, u);
560
+ await this.sleep(y, r);
561
+ continue;
562
+ }
563
+ throw new d(
564
+ T.NETWORK,
565
+ `Network error: ${a.message} (${s + 1} attempts)`,
566
+ "local"
567
+ );
568
+ }
569
+ throw a;
570
+ }
571
+ }
572
+ throw b || new Error("Unknown error after retries");
573
+ }
574
+ sleep(t, n) {
575
+ return new Promise((r, i) => {
576
+ if (n != null && n.aborted) {
577
+ i(new Error("Request aborted"));
578
+ return;
579
+ }
580
+ const s = setTimeout(() => {
581
+ n == null || n.removeEventListener("abort", o), r();
582
+ }, t), o = () => {
583
+ clearTimeout(s), i(new Error("Request aborted"));
584
+ };
585
+ n == null || n.addEventListener("abort", o, { once: !0 });
586
+ });
587
+ }
588
+ getBaseUrl() {
589
+ return this.baseUrl;
590
+ }
591
+ }
592
+ function w(e, t) {
593
+ if (e.aborted) return { signal: e, cleanup: () => {
594
+ } };
595
+ if (t.aborted) return { signal: t, cleanup: () => {
596
+ } };
597
+ const n = new AbortController(), r = () => {
598
+ t.removeEventListener("abort", i), n.abort();
599
+ }, i = () => {
600
+ e.removeEventListener("abort", r), n.abort();
601
+ };
602
+ e.addEventListener("abort", r, { once: !0 }), t.addEventListener("abort", i, { once: !0 });
603
+ const s = () => {
604
+ e.removeEventListener("abort", r), t.removeEventListener("abort", i);
605
+ };
606
+ return { signal: n.signal, cleanup: s };
607
+ }
608
+ var D = /* @__PURE__ */ ((e) => (e.PENDING_INGESTION = "PendingIngestion", e.PENDING_DEPOSITOR_WOTS_PK = "PendingDepositorWotsPK", e.PENDING_BABE_SETUP = "PendingBabeSetup", e.PENDING_CHALLENGER_PRESIGNING = "PendingChallengerPresigning", e.PENDING_PEGIN_SIGS_AVAILABILITY = "PendingPeginSigsAvailability", e.PENDING_PRE_PEGIN_CONFIRMATIONS = "PendingPrePegInConfirmations", e.PENDING_DEPOSITOR_SIGNATURES = "PendingDepositorSignatures", e.PENDING_ACKS = "PendingACKs", e.PENDING_ACTIVATION = "PendingActivation", e.ACTIVATED = "Activated", e.EXPIRED = "Expired", e.CLAIM_POSTED = "ClaimPosted", e.PEGGED_OUT = "PeggedOut", e))(D || {});
609
+ const M = [
610
+ "PendingIngestion",
611
+ "PendingBabeSetup",
612
+ "PendingChallengerPresigning",
613
+ "PendingPeginSigsAvailability",
614
+ "PendingPrePegInConfirmations"
615
+ /* PENDING_PRE_PEGIN_CONFIRMATIONS */
616
+ ], L = [
617
+ "PendingACKs",
618
+ "PendingActivation",
619
+ "Activated"
620
+ /* ACTIVATED */
621
+ ], B = /* @__PURE__ */ new Set([
622
+ "PendingBabeSetup",
623
+ "PendingChallengerPresigning",
624
+ "PendingPeginSigsAvailability",
625
+ "PendingPrePegInConfirmations",
626
+ ...L
627
+ ]), x = /* @__PURE__ */ new Set([
628
+ "Expired",
629
+ "ClaimPosted",
630
+ "PeggedOut"
631
+ /* PEGGED_OUT */
632
+ ]), H = /* @__PURE__ */ new Set([
633
+ ...B,
634
+ "PendingDepositorSignatures"
635
+ /* PENDING_DEPOSITOR_SIGNATURES */
636
+ ]);
637
+ var V = /* @__PURE__ */ ((e) => (e[e.DATABASE_ERROR = -32005] = "DATABASE_ERROR", e[e.PRESIGN_ERROR = -32006] = "PRESIGN_ERROR", e[e.JSON_SERIALIZATION_ERROR = -32007] = "JSON_SERIALIZATION_ERROR", e[e.TX_GRAPH_ERROR = -32008] = "TX_GRAPH_ERROR", e[e.INVALID_GRAPH = -32009] = "INVALID_GRAPH", e[e.VALIDATION_ERROR = -32010] = "VALIDATION_ERROR", e[e.NOT_FOUND = -32011] = "NOT_FOUND", e[e.INTERNAL_ERROR = -32603] = "INTERNAL_ERROR", e))(V || {});
638
+ export {
639
+ k as B,
640
+ D,
641
+ C as J,
642
+ M as P,
643
+ V as R,
644
+ B as V,
645
+ d as a,
646
+ T as b,
647
+ x as c,
648
+ H as d
649
+ };
650
+ //# sourceMappingURL=types-CQ86O7NX.js.map