@babylonlabs-io/ts-sdk 0.27.1 → 0.28.1

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 (85) hide show
  1. package/dist/PeginManager-Da4uSHzl.cjs +2 -0
  2. package/dist/PeginManager-Da4uSHzl.cjs.map +1 -0
  3. package/dist/{context-ktqanzXE.js → PeginManager-DzMSIQ0I.js} +1100 -1058
  4. package/dist/PeginManager-DzMSIQ0I.js.map +1 -0
  5. package/dist/buildAndBroadcastRefund-DkEpTFkv.cjs +2 -0
  6. package/dist/buildAndBroadcastRefund-DkEpTFkv.cjs.map +1 -0
  7. package/dist/{buildAndBroadcastRefund-BzYJv-Fv.js → buildAndBroadcastRefund-xWS8frc6.js} +338 -348
  8. package/dist/buildAndBroadcastRefund-xWS8frc6.js.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +55 -55
  11. package/dist/sha2-6wN58S6R.js +280 -0
  12. package/dist/sha2-6wN58S6R.js.map +1 -0
  13. package/dist/sha2-CsTynrfJ.cjs +2 -0
  14. package/dist/sha2-CsTynrfJ.cjs.map +1 -0
  15. package/dist/shared/index.cjs.map +1 -1
  16. package/dist/shared/index.js.map +1 -1
  17. package/dist/shared/wallets/index.d.ts +2 -1
  18. package/dist/shared/wallets/index.d.ts.map +1 -1
  19. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +8 -0
  20. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
  21. package/dist/signing-BZigafm0.js.map +1 -1
  22. package/dist/signing-DHSXjhLM.cjs.map +1 -1
  23. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  24. package/dist/tbv/core/clients/index.cjs +1 -1
  25. package/dist/tbv/core/clients/index.js +2 -2
  26. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +80 -70
  27. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  28. package/dist/tbv/core/index.cjs +1 -1
  29. package/dist/tbv/core/index.js +52 -52
  30. package/dist/tbv/core/managers/PeginManager.d.ts +64 -27
  31. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  32. package/dist/tbv/core/managers/index.d.ts +1 -1
  33. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  34. package/dist/tbv/core/services/deposit/peginState.d.ts +1 -1
  35. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  36. package/dist/tbv/core/services/deposit/validation.d.ts +0 -4
  37. package/dist/tbv/core/services/deposit/validation.d.ts.map +1 -1
  38. package/dist/tbv/core/services/index.cjs +1 -1
  39. package/dist/tbv/core/services/index.js +1 -1
  40. package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts +13 -0
  41. package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts.map +1 -0
  42. package/dist/tbv/core/vault-secrets/context.d.ts +9 -0
  43. package/dist/tbv/core/vault-secrets/context.d.ts.map +1 -1
  44. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +56 -0
  45. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -0
  46. package/dist/tbv/core/vault-secrets/expand.d.ts +18 -3
  47. package/dist/tbv/core/vault-secrets/expand.d.ts.map +1 -1
  48. package/dist/tbv/core/vault-secrets/index.d.ts +6 -3
  49. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  50. package/dist/tbv/core/wots/blockDerivation.d.ts +20 -24
  51. package/dist/tbv/core/wots/blockDerivation.d.ts.map +1 -1
  52. package/dist/tbv/core/wots/errors.d.ts +3 -1
  53. package/dist/tbv/core/wots/errors.d.ts.map +1 -1
  54. package/dist/tbv/core/wots/index.d.ts +1 -2
  55. package/dist/tbv/core/wots/index.d.ts.map +1 -1
  56. package/dist/tbv/index.cjs +1 -1
  57. package/dist/tbv/index.js +52 -52
  58. package/dist/testing/MockBitcoinWallet.d.ts +10 -3
  59. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  60. package/dist/testing/index.cjs +1 -1
  61. package/dist/testing/index.cjs.map +1 -1
  62. package/dist/testing/index.js +67 -55
  63. package/dist/testing/index.js.map +1 -1
  64. package/dist/types-CnG3JsRs.js +680 -0
  65. package/dist/types-CnG3JsRs.js.map +1 -0
  66. package/dist/types-jmEyzzhY.cjs +2 -0
  67. package/dist/types-jmEyzzhY.cjs.map +1 -0
  68. package/dist/{vault-registry-reader-CpCOte7w.js → vault-registry-reader-BywZhqJL.js} +65 -64
  69. package/dist/{vault-registry-reader-CpCOte7w.js.map → vault-registry-reader-BywZhqJL.js.map} +1 -1
  70. package/dist/vault-registry-reader-DdruADqa.cjs +2 -0
  71. package/dist/{vault-registry-reader-BizmBSBV.cjs.map → vault-registry-reader-DdruADqa.cjs.map} +1 -1
  72. package/package.json +1 -1
  73. package/dist/buildAndBroadcastRefund-BEASMFsz.cjs +0 -2
  74. package/dist/buildAndBroadcastRefund-BEASMFsz.cjs.map +0 -1
  75. package/dist/buildAndBroadcastRefund-BzYJv-Fv.js.map +0 -1
  76. package/dist/context-B4fYDTxy.cjs +0 -2
  77. package/dist/context-B4fYDTxy.cjs.map +0 -1
  78. package/dist/context-ktqanzXE.js.map +0 -1
  79. package/dist/sha2-1XZuToHP.cjs +0 -2
  80. package/dist/sha2-1XZuToHP.cjs.map +0 -1
  81. package/dist/sha2-ZzfZqQSw.js +0 -1123
  82. package/dist/sha2-ZzfZqQSw.js.map +0 -1
  83. package/dist/tbv/core/wots/deriveWotsPkHash.d.ts +0 -9
  84. package/dist/tbv/core/wots/deriveWotsPkHash.d.ts.map +0 -1
  85. package/dist/vault-registry-reader-BizmBSBV.cjs +0 -2
@@ -0,0 +1,680 @@
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 G = [
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
+ {
220
+ name: "vBasic",
221
+ type: "tuple",
222
+ internalType: "struct BTCVaultTypes.BTCVaultBasicInfo",
223
+ components: [
224
+ { name: "depositor", type: "address", internalType: "address" },
225
+ {
226
+ name: "depositorBtcPubKey",
227
+ type: "bytes32",
228
+ internalType: "bytes32"
229
+ },
230
+ { name: "amount", type: "uint256", internalType: "uint256" },
231
+ {
232
+ name: "vaultProvider",
233
+ type: "address",
234
+ internalType: "address"
235
+ },
236
+ {
237
+ name: "status",
238
+ type: "uint8",
239
+ internalType: "enum IBTCVaultRegistry.BTCVaultStatus"
240
+ },
241
+ {
242
+ name: "applicationEntryPoint",
243
+ type: "address",
244
+ internalType: "address"
245
+ },
246
+ { name: "createdAt", type: "uint256", internalType: "uint256" }
247
+ ]
248
+ }
249
+ ],
250
+ stateMutability: "view"
251
+ },
252
+ {
253
+ type: "error",
254
+ name: "InvalidPeginFee",
255
+ inputs: [
256
+ {
257
+ name: "provided",
258
+ type: "uint256",
259
+ internalType: "uint256"
260
+ },
261
+ {
262
+ name: "required",
263
+ type: "uint256",
264
+ internalType: "uint256"
265
+ }
266
+ ]
267
+ },
268
+ {
269
+ type: "error",
270
+ name: "InvalidSecret",
271
+ inputs: []
272
+ },
273
+ {
274
+ type: "error",
275
+ name: "ActivationDeadlineExpired",
276
+ inputs: []
277
+ },
278
+ {
279
+ type: "error",
280
+ name: "InvalidHashlock",
281
+ inputs: []
282
+ },
283
+ {
284
+ type: "error",
285
+ name: "DuplicateHashlock",
286
+ inputs: []
287
+ },
288
+ {
289
+ type: "error",
290
+ name: "CapExceeded",
291
+ inputs: []
292
+ },
293
+ {
294
+ type: "error",
295
+ name: "InvalidOutputIndex",
296
+ inputs: []
297
+ },
298
+ {
299
+ type: "error",
300
+ name: "PeginSignaturesIncomplete",
301
+ inputs: []
302
+ },
303
+ {
304
+ type: "function",
305
+ name: "getBtcVaultProtocolInfo",
306
+ inputs: [
307
+ {
308
+ name: "vaultId",
309
+ type: "bytes32",
310
+ internalType: "bytes32"
311
+ }
312
+ ],
313
+ outputs: [
314
+ {
315
+ name: "vProtocol",
316
+ type: "tuple",
317
+ internalType: "struct BTCVaultRegistryTypes.BTCVaultProtocolInfo",
318
+ components: [
319
+ {
320
+ name: "depositorSignedPeginTx",
321
+ type: "bytes",
322
+ internalType: "bytes"
323
+ },
324
+ {
325
+ name: "universalChallengersVersion",
326
+ type: "uint16",
327
+ internalType: "uint16"
328
+ },
329
+ {
330
+ name: "appVaultKeepersVersion",
331
+ type: "uint16",
332
+ internalType: "uint16"
333
+ },
334
+ {
335
+ name: "offchainParamsVersion",
336
+ type: "uint16",
337
+ internalType: "uint16"
338
+ },
339
+ {
340
+ name: "verifiedAt",
341
+ type: "uint256",
342
+ internalType: "uint256"
343
+ },
344
+ {
345
+ name: "depositorWotsPkHash",
346
+ type: "bytes32",
347
+ internalType: "bytes32"
348
+ },
349
+ {
350
+ name: "hashlock",
351
+ type: "bytes32",
352
+ internalType: "bytes32"
353
+ },
354
+ {
355
+ name: "htlcVout",
356
+ type: "uint8",
357
+ internalType: "uint8"
358
+ },
359
+ {
360
+ name: "depositorPopSignature",
361
+ type: "bytes",
362
+ internalType: "bytes"
363
+ },
364
+ {
365
+ name: "prePeginTxHash",
366
+ type: "bytes32",
367
+ internalType: "bytes32"
368
+ },
369
+ {
370
+ name: "vaultProviderCommissionBps",
371
+ type: "uint16",
372
+ internalType: "uint16"
373
+ }
374
+ ]
375
+ }
376
+ ],
377
+ stateMutability: "view"
378
+ },
379
+ {
380
+ type: "function",
381
+ name: "protocolParams",
382
+ inputs: [],
383
+ outputs: [
384
+ {
385
+ name: "",
386
+ type: "address",
387
+ internalType: "contract IProtocolParams"
388
+ }
389
+ ],
390
+ stateMutability: "view"
391
+ },
392
+ {
393
+ type: "function",
394
+ name: "applicationRegistry",
395
+ inputs: [],
396
+ outputs: [
397
+ {
398
+ name: "",
399
+ type: "address",
400
+ internalType: "contract IApplicationRegistry"
401
+ }
402
+ ],
403
+ stateMutability: "view"
404
+ }
405
+ ];
406
+ class d extends Error {
407
+ constructor(t, n, r = "local", i) {
408
+ super(n), this.code = t, this.source = r, this.data = i, this.name = "JsonRpcError";
409
+ }
410
+ }
411
+ const T = {
412
+ TIMEOUT: -32e3,
413
+ NETWORK: -32001,
414
+ /** VP proxy: request timed out at proxy level */
415
+ PROXY_TIMEOUT: -32002,
416
+ /** VP proxy: VP unreachable / DNS failure / response too large */
417
+ PROXY_UNAVAILABLE: -32003,
418
+ /** SDK client: response missing "result" field (malformed JSON-RPC) */
419
+ INVALID_RESPONSE: -32700
420
+ }, A = "2.0", _ = 3, S = 1e3, N = /* @__PURE__ */ new Set([
421
+ 408,
422
+ // Request Timeout
423
+ 429,
424
+ // Too Many Requests
425
+ 500,
426
+ // Internal Server Error
427
+ 502,
428
+ // Bad Gateway
429
+ 503,
430
+ // Service Unavailable
431
+ 504
432
+ // Gateway Timeout
433
+ ]), g = /* @__PURE__ */ new Set([
434
+ "vaultProvider_getPeginStatus",
435
+ "vaultProvider_getPegoutStatus",
436
+ "vaultProvider_requestDepositorPresignTransactions"
437
+ ]);
438
+ function v(e) {
439
+ return g.has(e);
440
+ }
441
+ const O = "auth_expired";
442
+ function f(e) {
443
+ if (!(e instanceof d) || e.source !== "wire") return !1;
444
+ const t = e.data;
445
+ return t === null || typeof t != "object" ? !1 : t.kind === O;
446
+ }
447
+ class k {
448
+ constructor(t) {
449
+ p(this, "baseUrl");
450
+ p(this, "timeout");
451
+ p(this, "headers");
452
+ p(this, "requestId", 0);
453
+ p(this, "retries");
454
+ p(this, "retryDelay");
455
+ p(this, "retryableFor");
456
+ p(this, "tokenProvider");
457
+ this.baseUrl = t.baseUrl.replace(/\/$/, ""), this.timeout = t.timeout, this.headers = {
458
+ "Content-Type": "application/json",
459
+ ...t.headers
460
+ }, this.retries = t.retries ?? _, this.retryDelay = t.retryDelay ?? S, this.retryableFor = t.retryableFor ?? v, this.tokenProvider = t.tokenProvider;
461
+ }
462
+ async buildHeaders(t) {
463
+ const n = { ...this.headers };
464
+ if (this.tokenProvider) {
465
+ const r = await this.tokenProvider.getToken(t);
466
+ r && (n.Authorization = `Bearer ${r}`);
467
+ }
468
+ return n;
469
+ }
470
+ /**
471
+ * Make a JSON-RPC request with optional retry for safe methods.
472
+ *
473
+ * If the request fails with a wire-origin `auth_expired` error and a
474
+ * `tokenProvider` is configured, the client invalidates its cached
475
+ * token and retries the request once with a freshly-acquired bearer.
476
+ *
477
+ * @param method - The RPC method name
478
+ * @param params - The method parameters
479
+ * @param signal - Optional AbortSignal for caller-controlled cancellation
480
+ * @returns The result from the RPC method
481
+ * @throws JsonRpcError if the RPC call fails
482
+ */
483
+ async call(t, n, r) {
484
+ try {
485
+ return await this.callOnce(t, n, r);
486
+ } catch (i) {
487
+ if (this.tokenProvider && f(i))
488
+ return this.tokenProvider.invalidate(), await this.callOnce(t, n, r);
489
+ throw i;
490
+ }
491
+ }
492
+ async callOnce(t, n, r) {
493
+ const i = await this.fetchWithRetry(t, n, r);
494
+ let s;
495
+ try {
496
+ s = await i.json();
497
+ } catch {
498
+ throw new d(
499
+ T.INVALID_RESPONSE,
500
+ "Invalid JSON-RPC response: body is not valid JSON",
501
+ "local"
502
+ );
503
+ }
504
+ if (s === null || typeof s != "object" || Array.isArray(s))
505
+ throw new d(
506
+ T.INVALID_RESPONSE,
507
+ `Invalid JSON-RPC response: expected an object, got ${typeof s}`,
508
+ "local"
509
+ );
510
+ const o = s;
511
+ if ("error" in o && o.error != null) {
512
+ const c = o.error;
513
+ throw new d(
514
+ c.code ?? T.INVALID_RESPONSE,
515
+ c.message ?? "Unknown RPC error",
516
+ "wire",
517
+ c.data
518
+ );
519
+ }
520
+ if (!("result" in o))
521
+ throw new d(
522
+ T.INVALID_RESPONSE,
523
+ 'Invalid JSON-RPC response: missing "result" field',
524
+ "local"
525
+ );
526
+ return o.result;
527
+ }
528
+ /**
529
+ * Make a JSON-RPC request returning the raw Response (unparsed body).
530
+ *
531
+ * Bearer tokens are injected identically to `call`. **Reactive refresh
532
+ * is NOT performed here** — the response body may be unbounded (e.g.
533
+ * claimer-artifact downloads), so the client refuses to parse it to
534
+ * detect auth errors. Callers relying on token-expired retries for
535
+ * large downloads must read the body themselves and re-invoke
536
+ * `callRaw` after `tokenProvider.invalidate()`.
537
+ */
538
+ async callRaw(t, n, r) {
539
+ return this.fetchWithRetry(t, n, r);
540
+ }
541
+ async fetchWithRetry(t, n, r) {
542
+ const i = ++this.requestId, s = this.retryableFor(t) ? this.retries : 0, c = JSON.stringify({
543
+ jsonrpc: A,
544
+ method: t,
545
+ params: [n],
546
+ id: i
547
+ });
548
+ let b = null;
549
+ for (let u = 0; u <= s; u++) {
550
+ const P = new AbortController(), m = setTimeout(
551
+ () => P.abort(),
552
+ this.timeout
553
+ ), l = r ? w(r, P.signal) : null, E = l ? l.signal : P.signal;
554
+ try {
555
+ const a = await this.buildHeaders(t), y = await fetch(this.baseUrl, {
556
+ method: "POST",
557
+ headers: a,
558
+ body: c,
559
+ signal: E
560
+ });
561
+ if (clearTimeout(m), l == null || l.cleanup(), !y.ok) {
562
+ if (u < s && N.has(y.status)) {
563
+ const I = this.retryDelay * Math.pow(2, u);
564
+ await this.sleep(I, r);
565
+ continue;
566
+ }
567
+ throw new Error(
568
+ `HTTP error: ${y.status} ${y.statusText}`
569
+ );
570
+ }
571
+ return y;
572
+ } catch (a) {
573
+ if (clearTimeout(m), l == null || l.cleanup(), b = a instanceof Error ? a : new Error(String(a)), r != null && r.aborted)
574
+ throw new Error("Request aborted");
575
+ if (a instanceof Error && a.name === "AbortError") {
576
+ if (u < s) {
577
+ const y = this.retryDelay * Math.pow(2, u);
578
+ await this.sleep(y, r);
579
+ continue;
580
+ }
581
+ throw new d(
582
+ T.TIMEOUT,
583
+ `Request timeout after ${this.timeout}ms (${s + 1} attempts)`,
584
+ "local"
585
+ );
586
+ }
587
+ if (a instanceof TypeError) {
588
+ if (u < s) {
589
+ const y = this.retryDelay * Math.pow(2, u);
590
+ await this.sleep(y, r);
591
+ continue;
592
+ }
593
+ throw new d(
594
+ T.NETWORK,
595
+ `Network error: ${a.message} (${s + 1} attempts)`,
596
+ "local"
597
+ );
598
+ }
599
+ throw a;
600
+ }
601
+ }
602
+ throw b || new Error("Unknown error after retries");
603
+ }
604
+ sleep(t, n) {
605
+ return new Promise((r, i) => {
606
+ if (n != null && n.aborted) {
607
+ i(new Error("Request aborted"));
608
+ return;
609
+ }
610
+ const s = setTimeout(() => {
611
+ n == null || n.removeEventListener("abort", o), r();
612
+ }, t), o = () => {
613
+ clearTimeout(s), i(new Error("Request aborted"));
614
+ };
615
+ n == null || n.addEventListener("abort", o, { once: !0 });
616
+ });
617
+ }
618
+ getBaseUrl() {
619
+ return this.baseUrl;
620
+ }
621
+ }
622
+ function w(e, t) {
623
+ if (e.aborted) return { signal: e, cleanup: () => {
624
+ } };
625
+ if (t.aborted) return { signal: t, cleanup: () => {
626
+ } };
627
+ const n = new AbortController(), r = () => {
628
+ t.removeEventListener("abort", i), n.abort();
629
+ }, i = () => {
630
+ e.removeEventListener("abort", r), n.abort();
631
+ };
632
+ e.addEventListener("abort", r, { once: !0 }), t.addEventListener("abort", i, { once: !0 });
633
+ const s = () => {
634
+ e.removeEventListener("abort", r), t.removeEventListener("abort", i);
635
+ };
636
+ return { signal: n.signal, cleanup: s };
637
+ }
638
+ 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 || {});
639
+ const M = [
640
+ "PendingIngestion",
641
+ "PendingBabeSetup",
642
+ "PendingChallengerPresigning",
643
+ "PendingPeginSigsAvailability",
644
+ "PendingPrePegInConfirmations"
645
+ /* PENDING_PRE_PEGIN_CONFIRMATIONS */
646
+ ], B = [
647
+ "PendingACKs",
648
+ "PendingActivation",
649
+ "Activated"
650
+ /* ACTIVATED */
651
+ ], V = /* @__PURE__ */ new Set([
652
+ "PendingBabeSetup",
653
+ "PendingChallengerPresigning",
654
+ "PendingPeginSigsAvailability",
655
+ "PendingPrePegInConfirmations",
656
+ ...B
657
+ ]), x = /* @__PURE__ */ new Set([
658
+ "Expired",
659
+ "ClaimPosted",
660
+ "PeggedOut"
661
+ /* PEGGED_OUT */
662
+ ]), H = /* @__PURE__ */ new Set([
663
+ ...V,
664
+ "PendingDepositorSignatures"
665
+ /* PENDING_DEPOSITOR_SIGNATURES */
666
+ ]);
667
+ var L = /* @__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))(L || {});
668
+ export {
669
+ G as B,
670
+ D,
671
+ k as J,
672
+ M as P,
673
+ L as R,
674
+ V,
675
+ d as a,
676
+ T as b,
677
+ x as c,
678
+ H as d
679
+ };
680
+ //# sourceMappingURL=types-CnG3JsRs.js.map