@babylonlabs-io/ts-sdk 0.57.0 → 0.57.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 (33) hide show
  1. package/dist/{primeVpAuth-BlxUcdBf.cjs → batchPoll-BXIy3R7h.cjs} +2 -2
  2. package/dist/batchPoll-BXIy3R7h.cjs.map +1 -0
  3. package/dist/{primeVpAuth-DkJbvywo.js → batchPoll-DTYXoTEc.js} +161 -161
  4. package/dist/batchPoll-DTYXoTEc.js.map +1 -0
  5. package/dist/{buildAndBroadcastRefund-CDzzTZ2U.cjs → buildAndBroadcastRefund-4uAl7OIk.cjs} +2 -2
  6. package/dist/{buildAndBroadcastRefund-CDzzTZ2U.cjs.map → buildAndBroadcastRefund-4uAl7OIk.cjs.map} +1 -1
  7. package/dist/{buildAndBroadcastRefund-CCb1_z24.js → buildAndBroadcastRefund-Bo3AlqCk.js} +2 -2
  8. package/dist/{buildAndBroadcastRefund-CCb1_z24.js.map → buildAndBroadcastRefund-Bo3AlqCk.js.map} +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +101 -100
  11. package/dist/json-rpc-client-BiAmg_ho.cjs +2 -0
  12. package/dist/json-rpc-client-BiAmg_ho.cjs.map +1 -0
  13. package/dist/json-rpc-client-DuUARJvV.js +334 -0
  14. package/dist/json-rpc-client-DuUARJvV.js.map +1 -0
  15. package/dist/tbv/core/clients/index.cjs +1 -1
  16. package/dist/tbv/core/clients/index.js +28 -27
  17. package/dist/tbv/core/clients/vault-provider/index.d.ts +4 -4
  18. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  19. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +36 -14
  20. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  21. package/dist/tbv/core/index.cjs +1 -1
  22. package/dist/tbv/core/index.js +93 -92
  23. package/dist/tbv/core/services/index.cjs +1 -1
  24. package/dist/tbv/core/services/index.js +1 -1
  25. package/dist/tbv/index.cjs +1 -1
  26. package/dist/tbv/index.js +93 -92
  27. package/package.json +1 -1
  28. package/dist/json-rpc-client-Ehjthcd7.js +0 -324
  29. package/dist/json-rpc-client-Ehjthcd7.js.map +0 -1
  30. package/dist/json-rpc-client-fUoK-TzT.cjs +0 -2
  31. package/dist/json-rpc-client-fUoK-TzT.cjs.map +0 -1
  32. package/dist/primeVpAuth-BlxUcdBf.cjs.map +0 -1
  33. package/dist/primeVpAuth-DkJbvywo.js.map +0 -1
package/dist/tbv/index.js CHANGED
@@ -1,42 +1,42 @@
1
1
  import { b as s, c as t } from "../challengeAssert-BVQq50su.js";
2
2
  import { a as o } from "../constants-CDQE812z.js";
3
- import { computeMinClaimValue as n, computeMinPeginFee as p, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as d, expandWotsSeed as P, peginP2aAnchorOutput as c, supportedTxGraphVersions as T, validatePeginP2aAnchor as A } from "@babylonlabs-io/babylon-tbv-rust-wasm";
3
+ import { computeMinClaimValue as n, computeMinPeginFee as p, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as d, expandWotsSeed as P, peginP2aAnchorOutput as c, supportedTxGraphVersions as E, validatePeginP2aAnchor as T } from "@babylonlabs-io/babylon-tbv-rust-wasm";
4
4
  import { P as S, d as g, f as R, c as _, b as m, a as f, g as x, e as b } from "../verifyScriptPathSchnorrSignature-Xoo9DOHW.js";
5
- import { b as v, e as O, f as h } from "../peginInput-BKD_b3gq.js";
6
- import { a as I, b as y } from "../noPayout-CI4l1qu2.js";
7
- import { d as U, a as B, b as D, e as N, f as M, j as H, g as L, h as K, i as X, c as k, p as W, s as w, t as G, u as Y, v as Z } from "../bitcoin-B5aNKtsk.js";
8
- import { B as J, H as q, K as z, M as Q, T as $, c as aa } from "../validation-Dj3dqYtl.js";
5
+ import { b as O, e as V, f as v } from "../peginInput-BKD_b3gq.js";
6
+ import { a as y, b as I } from "../noPayout-CI4l1qu2.js";
7
+ import { d as U, a as B, b as D, e as N, f as M, j as H, g as L, h as K, i as k, c as X, p as W, s as w, t as G, u as j, v as J } from "../bitcoin-B5aNKtsk.js";
8
+ import { B as Z, H as q, K as z, M as Q, T as $, c as aa } from "../validation-Dj3dqYtl.js";
9
9
  import { c as sa } from "../signing-DaLvGwQe.js";
10
10
  import { P as ra, b as oa, c as ia, d as na, e as pa } from "../PeginManager-CnX3uFb0.js";
11
- import { P as la, c as da, f as Pa, s as ca, v as Ta } from "../signPsbtsWithFallback-CzZFZf0I.js";
12
- import { A as Ea, P as Sa } from "../ProtocolParams.abi-CV938AYZ.js";
11
+ import { P as la, c as da, f as Pa, s as ca, v as Ea } from "../signPsbtsWithFallback-CzZFZf0I.js";
12
+ import { A as Aa, P as Sa } from "../ProtocolParams.abi-CV938AYZ.js";
13
13
  import { B as Ra } from "../BTCVaultRegistry.abi-CixOlp3B.js";
14
14
  import { B as ma } from "../BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
15
- import { C as xa, e as ba, g as Va, h as va, i as Oa } from "../errors-Blc-JWnI.js";
16
- import { V as Ca, b as Ia, a as ya, d as Fa } from "../deriveVaultRoot-B_gEOTD6.js";
15
+ import { C as xa, e as ba, g as Ca, h as Oa, i as Va } from "../errors-Blc-JWnI.js";
16
+ import { V as ha, b as ya, a as Ia, d as Fa } from "../deriveVaultRoot-B_gEOTD6.js";
17
17
  import { p as Ba } from "../parseFundingOutpoints-GSM-IaaK.js";
18
- import { B as Na, a as Ma, f as Ha, c as La, b as Ka, d as Xa, g as ka, i as Wa, h as wa, s as Ga, e as Ya, w as Za } from "../waitForTransactionReceiptSmartAware-lobLm0q0.js";
19
- import { B as Ja, D as qa, L as za, M as Qa, c as $a, P as ae, b as ee, a as se, S as te, T as re, W as oe, f as ie, d as ne, p as pe, r as ue } from "../fundPeginTransaction-B2wyjqp0.js";
20
- import { U as de, a as Pe, e as ce, f as Te, v as Ae } from "../reservation-cHDRn4DA.js";
21
- import { M as Se, V as ge, g as Re, a as _e, b as me, c as fe, d as xe, e as be, f as Ve, h as ve, i as Oe, p as he, v as Ce, j as Ie, k as ye } from "../mempoolApi-C0olk43O.js";
22
- import { O as Ue, S as Be, V as De, g as Ne, h as Me, i as He, j as Le, a as Ke, d as Xe, b as ke, f as We, p as we, r as Ge, v as Ye, c as Ze, e as je } from "../primeVpAuth-DkJbvywo.js";
23
- import { A as qe, D as ze, b as Qe, J as $e, a as as, d as es, P as ss, R as ts, e as rs, c as os, V as is } from "../json-rpc-client-Ehjthcd7.js";
24
- import { a as ps } from "../onChainBtcPubkey-aPY5ib3Q.js";
25
- import { i as ls } from "../errors-B-H0seUG.js";
26
- import { B as Ps, C as cs, P as Ts, x as As, y as Es, z as Ss, A as gs, R as Rs, a as _s, t as ms, u as fs, i as xs, j as bs, q as Vs, p as vs, l as Os, n as hs, o as Cs, r as Is, s as ys, b as Fs, c as Us, d as Bs, v as Ds, e as Ns, f as Ms, g as Hs, h as Ls, k as Ks, m as Xs, w as ks } from "../buildAndBroadcastRefund-CCb1_z24.js";
27
- import { C as ws, P as Gs, c as Ys, g as Zs, i as js } from "../peginState-BB81JI6I.js";
18
+ import { B as Na, a as Ma, f as Ha, c as La, b as Ka, d as ka, g as Xa, i as Wa, h as wa, s as Ga, e as ja, w as Ja } from "../waitForTransactionReceiptSmartAware-lobLm0q0.js";
19
+ import { B as Za, D as qa, L as za, M as Qa, c as $a, P as ae, b as ee, a as se, S as te, T as re, W as oe, f as ie, d as ne, p as pe, r as ue } from "../fundPeginTransaction-B2wyjqp0.js";
20
+ import { U as de, a as Pe, e as ce, f as Ee, v as Te } from "../reservation-cHDRn4DA.js";
21
+ import { M as Se, V as ge, g as Re, a as _e, b as me, c as fe, d as xe, e as be, f as Ce, h as Oe, i as Ve, p as ve, v as he, j as ye, k as Ie } from "../mempoolApi-C0olk43O.js";
22
+ import { O as Ue, S as Be, V as De, g as Ne, h as Me, i as He, j as Le, a as Ke, d as ke, b as Xe, f as We, p as we, r as Ge, v as je, c as Je, e as Ye } from "../batchPoll-DTYXoTEc.js";
23
+ import { A as qe, D as ze, J as Qe, a as $e, b as as, d as es, P as ss, R as ts, e as rs, c as os, V as is, i as ns } from "../json-rpc-client-DuUARJvV.js";
24
+ import { a as us } from "../onChainBtcPubkey-aPY5ib3Q.js";
25
+ import { i as ds } from "../errors-B-H0seUG.js";
26
+ import { B as cs, C as Es, P as Ts, x as As, y as Ss, z as gs, A as Rs, R as _s, a as ms, t as fs, u as xs, i as bs, j as Cs, q as Os, p as Vs, l as vs, n as hs, o as ys, r as Is, s as Fs, b as Us, c as Bs, d as Ds, v as Ns, e as Ms, f as Hs, g as Ls, h as Ks, k as ks, m as Xs, w as Ws } from "../buildAndBroadcastRefund-Bo3AlqCk.js";
27
+ import { C as Gs, P as js, c as Js, g as Ys, i as Zs } from "../peginState-BB81JI6I.js";
28
28
  export {
29
- qe as AUTH_EXPIRED_DATA_KIND,
30
- Ea as ApplicationRegistryABI,
31
- Ps as BIP68NotMatureError,
32
- J as BITCOIN_ADDRESS_RE,
29
+ qe as AUTH_REJECTED_RPC_CODE,
30
+ Aa as ApplicationRegistryABI,
31
+ cs as BIP68NotMatureError,
32
+ Z as BITCOIN_ADDRESS_RE,
33
33
  Ra as BTCVaultRegistryABI,
34
34
  ma as BTCVaultRegistryKeyEpochsABI,
35
- Ja as BTC_DUST_SAT,
35
+ Za as BTC_DUST_SAT,
36
36
  Na as BitcoinScriptType,
37
37
  xa as CONTRACT_ERRORS,
38
- cs as ClaimerPegoutStatusValue,
39
- ws as ContractStatus,
38
+ Es as ClaimerPegoutStatusValue,
39
+ Gs as ContractStatus,
40
40
  qa as DUST_THRESHOLD,
41
41
  ze as DaemonStatus,
42
42
  q as HEX_RE,
@@ -57,22 +57,22 @@ export {
57
57
  ss as PRE_DEPOSITOR_SIGNATURES_STATES,
58
58
  Ts as ParticipantKeyDriftError,
59
59
  la as PayoutManager,
60
- Gs as PeginAction,
60
+ js as PeginAction,
61
61
  ra as PeginManager,
62
62
  Sa as ProtocolParamsABI,
63
63
  S as PsbtSubstitutionError,
64
64
  As as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
65
- Es as REFUND_MAX_FEE_FRACTION_NUMERATOR,
66
- Ss as REFUND_MAX_FEE_RATE_SATS_VB,
67
- gs as REFUND_VSIZE,
68
- Rs as RegisteredVaultVersionMismatchError,
65
+ Ss as REFUND_MAX_FEE_FRACTION_NUMERATOR,
66
+ gs as REFUND_MAX_FEE_RATE_SATS_VB,
67
+ Rs as REFUND_VSIZE,
68
+ _s as RegisteredVaultVersionMismatchError,
69
69
  ts as RpcErrorCode,
70
70
  te as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
71
71
  Be as ServerIdentityError,
72
72
  $ as TXID_RE,
73
73
  re as TX_BUFFER_SIZE_OVERHEAD,
74
74
  de as UtxoNotAvailableError,
75
- Ca as VAULT_APP_NAME,
75
+ ha as VAULT_APP_NAME,
76
76
  rs as VP_BATCH_MAX_SIZE,
77
77
  os as VP_TERMINAL_FAILURE_STATUSES,
78
78
  is as VP_TRANSIENT_STATUSES,
@@ -83,29 +83,29 @@ export {
83
83
  Le as ViemVaultKeeperReader,
84
84
  ge as ViemVaultRegistryReader,
85
85
  Ke as VpResponseValidationError,
86
- Xe as VpTokenRegistry,
86
+ ke as VpTokenRegistry,
87
87
  oe as WALLET_RELAY_FEE_RATE_THRESHOLD,
88
- _s as activateVault,
88
+ ms as activateVault,
89
89
  Ma as applyChangeOutputPolicy,
90
- ps as assertOnChainBtcPubkey,
90
+ us as assertOnChainBtcPubkey,
91
91
  g as assertPsbtUnsignedTxMatches,
92
92
  R as assertScriptPathSchnorrSignature,
93
93
  Pe as assertUtxosAvailable,
94
94
  o as assertValidVaultCoreVersion,
95
- ke as batchPollByProvider,
96
- ms as buildAndBroadcastRefund,
95
+ Xe as batchPollByProvider,
96
+ fs as buildAndBroadcastRefund,
97
97
  s as buildChallengeAssertPsbt,
98
98
  oa as buildDepositTerms,
99
- Ia as buildFundingOutpointsCommitment,
100
- I as buildNoPayoutPsbt,
99
+ ya as buildFundingOutpointsCommitment,
100
+ y as buildNoPayoutPsbt,
101
101
  _ as buildPayoutPsbt,
102
- v as buildPeginInputPsbt,
102
+ O as buildPeginInputPsbt,
103
103
  m as buildPeginTxFromFundedPrePegin,
104
104
  f as buildPrePeginPsbt,
105
- y as buildRefundPsbt,
106
- ya as buildVaultContext,
105
+ I as buildRefundPsbt,
106
+ Ia as buildVaultContext,
107
107
  Ha as calculateBtcTxHash,
108
- Ys as canPerformAction,
108
+ Js as canPerformAction,
109
109
  aa as combineAbortSignals,
110
110
  La as computeChangeOutputFeeSats,
111
111
  da as computeHashlock,
@@ -113,7 +113,7 @@ export {
113
113
  n as computeMinClaimValue,
114
114
  p as computeMinPeginFee,
115
115
  t as computeNumLocalChallengers,
116
- Xa as computePeginBaseFeeSats,
116
+ ka as computePeginBaseFeeSats,
117
117
  ia as computeWotsBlockPublicKeysHash,
118
118
  We as createAuthenticatedVpClient,
119
119
  x as createPayoutScript,
@@ -125,7 +125,7 @@ export {
125
125
  Fa as deriveVaultRoot,
126
126
  na as deriveWotsBlocksFromSeed,
127
127
  N as ensureHexPrefix,
128
- fs as estimateRefundFeeSats,
128
+ xs as estimateRefundFeeSats,
129
129
  pa as estimateSubmitPeginRequestBatchGas,
130
130
  l as expandAuthAnchor,
131
131
  d as expandHashlockSecret,
@@ -133,81 +133,82 @@ export {
133
133
  ba as extractErrorData,
134
134
  ce as extractInputsFromTransaction,
135
135
  b as extractPayoutSignature,
136
- O as extractPeginInputSignature,
137
- h as finalizePeginInputPsbt,
138
- Te as findOverlappingPendingVaults,
136
+ V as extractPeginInputSignature,
137
+ v as finalizePeginInputPsbt,
138
+ Ee as findOverlappingPendingVaults,
139
139
  M as formatSatoshisToBtc,
140
140
  Pa as forwardDepositApproval,
141
141
  ie as fundPeginTransaction,
142
142
  Re as getAddressTxs,
143
143
  _e as getAddressUtxos,
144
- Va as getContractErrorMessage,
145
- ka as getDustThreshold,
144
+ Ca as getContractErrorMessage,
145
+ Xa as getDustThreshold,
146
146
  me as getMempoolApiUrl,
147
147
  H as getNetwork,
148
148
  fe as getNetworkFees,
149
149
  xe as getOutspend,
150
- Zs as getPeginProtocolState,
150
+ Ys as getPeginProtocolState,
151
151
  Wa as getPsbtInputFields,
152
152
  wa as getScriptType,
153
153
  L as getSortedXOnlyPubkeys,
154
154
  be as getTipHeight,
155
- Ve as getTxHex,
156
- ve as getTxInfo,
157
- Oe as getUtxoInfo,
158
- va as handleContractError,
155
+ Ce as getTxHex,
156
+ Oe as getTxInfo,
157
+ Ve as getUtxoInfo,
158
+ Oa as handleContractError,
159
159
  K as hexToUint8Array,
160
- js as isActivationDeadlinePassedOnChain,
161
- X as isAddressFromPublicKey,
162
- xs as isDepositAmountValid,
163
- Oa as isKnownContractError,
164
- bs as isParticipantKeyDriftError,
165
- Vs as isPegoutTerminalStatus,
166
- vs as isRecognizedPegoutStatus,
167
- Os as isRegisteredVaultVersionMismatchError,
168
- k as isValidHex,
169
- ls as isWotsMismatchError,
160
+ Zs as isActivationDeadlinePassedOnChain,
161
+ k as isAddressFromPublicKey,
162
+ ns as isAuthRejectedError,
163
+ bs as isDepositAmountValid,
164
+ Va as isKnownContractError,
165
+ Cs as isParticipantKeyDriftError,
166
+ Os as isPegoutTerminalStatus,
167
+ Vs as isRecognizedPegoutStatus,
168
+ vs as isRegisteredVaultVersionMismatchError,
169
+ X as isValidHex,
170
+ ds as isWotsMismatchError,
170
171
  Ba as parseFundingOutpointsFromTx,
171
172
  ne as parseUnfundedWasmTransaction,
172
173
  pe as peginOutputCount,
173
174
  c as peginP2aAnchorOutput,
174
175
  we as primeVpTokenRegistry,
175
176
  W as processPublicKeyToXOnly,
176
- he as pushTx,
177
+ ve as pushTx,
177
178
  ue as rateBasedTxBufferFee,
178
179
  hs as resolveCurrentParticipantKeys,
179
- Cs as resolveParticipantKeysAtEpochs,
180
+ ys as resolveParticipantKeysAtEpochs,
180
181
  Ge as resolveProtocolAddresses,
181
182
  Is as runDepositorPresignFlow,
182
183
  Ga as selectUtxosForPegin,
183
- Ya as shouldAddChangeOutput,
184
- ys as signDepositorGraph,
184
+ ja as shouldAddChangeOutput,
185
+ Fs as signDepositorGraph,
185
186
  w as stripHexPrefix,
186
- Fs as submitWotsPublicKey,
187
- T as supportedTxGraphVersions,
187
+ Us as submitWotsPublicKey,
188
+ E as supportedTxGraphVersions,
188
189
  ca as supportsDepositApproval,
189
190
  G as toXOnly,
190
- Y as uint8ArrayToHex,
191
- Us as validateDepositAmount,
192
- Bs as validateMultiVaultDepositInputs,
193
- Ce as validateOffchainParams,
194
- Ds as validateOnChainParticipantKeys,
195
- Ie as validatePegInConfiguration,
196
- A as validatePeginP2aAnchor,
197
- Ns as validateProviderSelection,
198
- Ms as validateRemainingCapacity,
199
- Ye as validateRequestDepositorClaimerArtifactsResponse,
200
- Ta as validateSecretAgainstHashlock,
201
- ye as validateTBVProtocolParams,
202
- Ae as validateUtxosAvailable,
203
- Hs as validateVaultAmounts,
204
- Ls as validateVaultProviderPubkey,
205
- Z as validateWalletPubkey,
206
- Ks as verifyRegisteredParticipantKeys,
191
+ j as uint8ArrayToHex,
192
+ Bs as validateDepositAmount,
193
+ Ds as validateMultiVaultDepositInputs,
194
+ he as validateOffchainParams,
195
+ Ns as validateOnChainParticipantKeys,
196
+ ye as validatePegInConfiguration,
197
+ T as validatePeginP2aAnchor,
198
+ Ms as validateProviderSelection,
199
+ Hs as validateRemainingCapacity,
200
+ je as validateRequestDepositorClaimerArtifactsResponse,
201
+ Ea as validateSecretAgainstHashlock,
202
+ Ie as validateTBVProtocolParams,
203
+ Te as validateUtxosAvailable,
204
+ Ls as validateVaultAmounts,
205
+ Ks as validateVaultProviderPubkey,
206
+ J as validateWalletPubkey,
207
+ ks as verifyRegisteredParticipantKeys,
207
208
  Xs as verifyRegisteredVaultVersions,
208
- Ze as verifyServerIdentity,
209
- je as vpTokenRegistry,
210
- ks as waitForPeginStatus,
211
- Za as waitForTransactionReceiptSmartAware
209
+ Je as verifyServerIdentity,
210
+ Ye as vpTokenRegistry,
211
+ Ws as waitForPeginStatus,
212
+ Ja as waitForTransactionReceiptSmartAware
212
213
  };
213
214
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonlabs-io/ts-sdk",
3
- "version": "0.57.0",
3
+ "version": "0.57.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,324 +0,0 @@
1
- var S = Object.defineProperty;
2
- var p = (t, e, r) => e in t ? S(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var E = (t, e, r) => p(t, typeof e != "symbol" ? e + "" : e, r);
4
- var w = /* @__PURE__ */ ((t) => (t.PENDING_INGESTION = "PendingIngestion", t.PENDING_DEPOSITOR_WOTS_PK = "PendingDepositorWotsPK", t.PENDING_BABE_SETUP = "PendingBabeSetup", t.PENDING_CHALLENGER_PRESIGNING = "PendingChallengerPresigning", t.PENDING_PEGIN_SIGS_AVAILABILITY = "PendingPeginSigsAvailability", t.PENDING_PRE_PEGIN_CONFIRMATIONS = "PendingPrePegInConfirmations", t.PENDING_DEPOSITOR_SIGNATURES = "PendingDepositorSignatures", t.PENDING_ACKS = "PendingACKs", t.PENDING_ACTIVATION = "PendingActivation", t.ACTIVATED_PENDING_BROADCAST = "ActivatedPendingBroadcast", t.ACTIVATED = "Activated", t.EXPIRED = "Expired", t.INGESTION_REJECTED = "IngestionRejected", t.INVALID_SIG_IN_CONTRACT = "InvalidSigInContract", t.AML_REJECTED = "AmlRejected", t.EXPIRED_CLEANED_UP = "ExpiredCleanedUp", t.EXPIRED_IN_CLAIM = "ExpiredInClaim", t))(w || {});
5
- const F = [
6
- "PendingIngestion",
7
- "PendingBabeSetup",
8
- "PendingChallengerPresigning",
9
- "PendingPeginSigsAvailability",
10
- "PendingPrePegInConfirmations"
11
- /* PENDING_PRE_PEGIN_CONFIRMATIONS */
12
- ], O = [
13
- "PendingACKs",
14
- "PendingActivation",
15
- "ActivatedPendingBroadcast",
16
- "Activated"
17
- /* ACTIVATED */
18
- ], y = /* @__PURE__ */ new Set([
19
- "PendingBabeSetup",
20
- "PendingChallengerPresigning",
21
- "PendingPeginSigsAvailability",
22
- "PendingPrePegInConfirmations",
23
- ...O
24
- ]), J = /* @__PURE__ */ new Set([
25
- "IngestionRejected",
26
- "InvalidSigInContract",
27
- "AmlRejected",
28
- "ExpiredCleanedUp",
29
- "ExpiredInClaim"
30
- /* EXPIRED_IN_CLAIM */
31
- ]), q = /* @__PURE__ */ new Set([
32
- ...y,
33
- "PendingDepositorSignatures"
34
- /* PENDING_DEPOSITOR_SIGNATURES */
35
- ]), Y = 50;
36
- var b = /* @__PURE__ */ ((t) => (t[t.PEGIN_NOT_FOUND = 4001] = "PEGIN_NOT_FOUND", t))(b || {});
37
- class P extends Error {
38
- constructor(e, r, n = "local", s) {
39
- super(r), this.code = e, this.source = n, this.data = s, this.name = "JsonRpcError";
40
- }
41
- }
42
- const T = {
43
- TIMEOUT: -32e3,
44
- NETWORK: -32001,
45
- /** VP proxy: request timed out at proxy level */
46
- PROXY_TIMEOUT: -32002,
47
- /** VP proxy: VP unreachable / DNS failure / response too large */
48
- PROXY_UNAVAILABLE: -32003,
49
- /** SDK client: response missing "result" field (malformed JSON-RPC) */
50
- INVALID_RESPONSE: -32700,
51
- /** SDK client: response body exceeded the configured byte limit */
52
- RESPONSE_TOO_LARGE: -32701
53
- }, f = "2.0", v = 3, g = 1e3, C = 2 * 1024 * 1024, D = /* @__PURE__ */ new Set([
54
- "vaultProvider_requestDepositorClaimerArtifacts"
55
- ]), L = /* @__PURE__ */ new Set([
56
- 408,
57
- // Request Timeout
58
- 429,
59
- // Too Many Requests
60
- 500,
61
- // Internal Server Error
62
- 502,
63
- // Bad Gateway
64
- 503,
65
- // Service Unavailable
66
- 504
67
- // Gateway Timeout
68
- ]), U = /* @__PURE__ */ new Set([
69
- "vaultProvider_getPeginStatus",
70
- "vaultProvider_batchGetPeginStatus",
71
- "vaultProvider_batchGetPegoutStatus",
72
- "vaultProvider_requestDepositorPresignTransactions"
73
- ]);
74
- function m(t) {
75
- return U.has(t);
76
- }
77
- const G = "auth_expired";
78
- function x(t) {
79
- if (!(t instanceof P) || t.source !== "wire") return !1;
80
- const e = t.data;
81
- return e === null || typeof e != "object" ? !1 : e.kind === G;
82
- }
83
- class $ {
84
- constructor(e) {
85
- E(this, "baseUrl");
86
- E(this, "timeout");
87
- E(this, "headers");
88
- E(this, "requestId", 0);
89
- E(this, "retries");
90
- E(this, "retryDelay");
91
- E(this, "maxResponseBytes");
92
- E(this, "retryableFor");
93
- E(this, "tokenProvider");
94
- if (this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.timeout = e.timeout, this.headers = {
95
- "Content-Type": "application/json",
96
- ...e.headers
97
- }, this.retries = e.retries ?? v, this.retryDelay = e.retryDelay ?? g, this.maxResponseBytes = e.maxResponseBytes ?? C, !Number.isFinite(this.maxResponseBytes) || this.maxResponseBytes <= 0)
98
- throw new Error("maxResponseBytes must be a positive finite number");
99
- this.retryableFor = e.retryableFor ?? m, this.tokenProvider = e.tokenProvider;
100
- }
101
- async buildHeaders(e) {
102
- const r = { ...this.headers };
103
- if (this.tokenProvider) {
104
- const n = await this.tokenProvider.getToken(e);
105
- n && (r.Authorization = `Bearer ${n}`);
106
- }
107
- return r;
108
- }
109
- /**
110
- * Make a JSON-RPC request with optional retry for safe methods.
111
- *
112
- * If the request fails with a wire-origin `auth_expired` error and a
113
- * `tokenProvider` is configured, the client invalidates its cached
114
- * token and retries the request once with a freshly-acquired bearer.
115
- *
116
- * @param method - The RPC method name
117
- * @param params - The method parameters
118
- * @param signal - Optional AbortSignal for caller-controlled cancellation
119
- * @returns The result from the RPC method
120
- * @throws JsonRpcError if the RPC call fails
121
- */
122
- async call(e, r, n) {
123
- try {
124
- return await this.callOnce(e, r, n);
125
- } catch (s) {
126
- if (this.tokenProvider && x(s))
127
- return this.tokenProvider.invalidate(), await this.callOnce(e, r, n);
128
- throw s;
129
- }
130
- }
131
- async callOnce(e, r, n) {
132
- const s = await this.fetchWithRetry(e, r, n);
133
- let o;
134
- try {
135
- const i = D.has(e) ? await s.text() : await k(s, this.maxResponseBytes);
136
- o = JSON.parse(i);
137
- } catch (i) {
138
- throw i instanceof P ? i : new P(
139
- T.INVALID_RESPONSE,
140
- "Invalid JSON-RPC response: body is not valid JSON",
141
- "local"
142
- );
143
- }
144
- if (o === null || typeof o != "object" || Array.isArray(o))
145
- throw new P(
146
- T.INVALID_RESPONSE,
147
- `Invalid JSON-RPC response: expected an object, got ${typeof o}`,
148
- "local"
149
- );
150
- const a = o;
151
- if ("error" in a && a.error != null) {
152
- const i = a.error;
153
- throw new P(
154
- i.code ?? T.INVALID_RESPONSE,
155
- i.message ?? "Unknown RPC error",
156
- "wire",
157
- i.data
158
- );
159
- }
160
- if (!("result" in a))
161
- throw new P(
162
- T.INVALID_RESPONSE,
163
- 'Invalid JSON-RPC response: missing "result" field',
164
- "local"
165
- );
166
- return a.result;
167
- }
168
- /**
169
- * Make a JSON-RPC request returning the raw Response (unparsed body).
170
- *
171
- * Bearer tokens are injected identically to `call`. **Reactive refresh
172
- * is NOT performed here** — the response body may be unbounded (e.g.
173
- * claimer-artifact downloads), so the client refuses to parse it to
174
- * detect auth errors. Callers relying on token-expired retries for
175
- * large downloads must read the body themselves and re-invoke
176
- * `callRaw` after `tokenProvider.invalidate()`.
177
- */
178
- async callRaw(e, r, n) {
179
- return this.fetchWithRetry(e, r, n);
180
- }
181
- async fetchWithRetry(e, r, n) {
182
- const s = ++this.requestId, o = this.retryableFor(e) ? this.retries : 0, i = JSON.stringify({
183
- jsonrpc: f,
184
- method: e,
185
- params: [r],
186
- id: s
187
- });
188
- let _ = null;
189
- for (let l = 0; l <= o; l++) {
190
- const h = new AbortController(), I = setTimeout(
191
- () => h.abort(),
192
- this.timeout
193
- ), u = n ? B(n, h.signal) : null, A = u ? u.signal : h.signal;
194
- try {
195
- const c = await this.buildHeaders(e), d = await fetch(this.baseUrl, {
196
- method: "POST",
197
- headers: c,
198
- body: i,
199
- signal: A
200
- });
201
- if (clearTimeout(I), u == null || u.cleanup(), !d.ok) {
202
- if (l < o && L.has(d.status)) {
203
- const N = this.retryDelay * Math.pow(2, l);
204
- await this.sleep(N, n);
205
- continue;
206
- }
207
- throw new Error(
208
- `HTTP error: ${d.status} ${d.statusText}`
209
- );
210
- }
211
- return d;
212
- } catch (c) {
213
- if (clearTimeout(I), u == null || u.cleanup(), _ = c instanceof Error ? c : new Error(String(c)), n != null && n.aborted)
214
- throw new Error("Request aborted");
215
- if (c instanceof Error && c.name === "AbortError") {
216
- if (l < o) {
217
- const d = this.retryDelay * Math.pow(2, l);
218
- await this.sleep(d, n);
219
- continue;
220
- }
221
- throw new P(
222
- T.TIMEOUT,
223
- `Request timeout after ${this.timeout}ms (${o + 1} attempts)`,
224
- "local"
225
- );
226
- }
227
- if (c instanceof TypeError) {
228
- if (l < o) {
229
- const d = this.retryDelay * Math.pow(2, l);
230
- await this.sleep(d, n);
231
- continue;
232
- }
233
- throw new P(
234
- T.NETWORK,
235
- `Network error: ${c.message} (${o + 1} attempts)`,
236
- "local"
237
- );
238
- }
239
- throw c;
240
- }
241
- }
242
- throw _ || new Error("Unknown error after retries");
243
- }
244
- sleep(e, r) {
245
- return new Promise((n, s) => {
246
- if (r != null && r.aborted) {
247
- s(new Error("Request aborted"));
248
- return;
249
- }
250
- const o = setTimeout(() => {
251
- r == null || r.removeEventListener("abort", a), n();
252
- }, e), a = () => {
253
- clearTimeout(o), s(new Error("Request aborted"));
254
- };
255
- r == null || r.addEventListener("abort", a, { once: !0 });
256
- });
257
- }
258
- getBaseUrl() {
259
- return this.baseUrl;
260
- }
261
- }
262
- function B(t, e) {
263
- if (t.aborted) return { signal: t, cleanup: () => {
264
- } };
265
- if (e.aborted) return { signal: e, cleanup: () => {
266
- } };
267
- const r = new AbortController(), n = () => {
268
- e.removeEventListener("abort", s), r.abort();
269
- }, s = () => {
270
- t.removeEventListener("abort", n), r.abort();
271
- };
272
- t.addEventListener("abort", n, { once: !0 }), e.addEventListener("abort", s, { once: !0 });
273
- const o = () => {
274
- t.removeEventListener("abort", n), e.removeEventListener("abort", s);
275
- };
276
- return { signal: r.signal, cleanup: o };
277
- }
278
- async function k(t, e) {
279
- const r = t.headers.get("content-length");
280
- if (r !== null) {
281
- const i = Number(r);
282
- if (Number.isFinite(i) && i > e)
283
- throw R(e);
284
- }
285
- if (!t.body)
286
- return "";
287
- const n = t.body.getReader(), s = new TextDecoder();
288
- let o = 0, a = "";
289
- try {
290
- for (; ; ) {
291
- const { done: i, value: _ } = await n.read();
292
- if (i) break;
293
- if (_) {
294
- if (o += _.byteLength, o > e)
295
- throw await n.cancel(), R(e);
296
- a += s.decode(_, { stream: !0 });
297
- }
298
- }
299
- } finally {
300
- n.releaseLock();
301
- }
302
- return a + s.decode();
303
- }
304
- function R(t) {
305
- return new P(
306
- T.RESPONSE_TOO_LARGE,
307
- `JSON-RPC response exceeds maximum size of ${t} bytes`,
308
- "local"
309
- );
310
- }
311
- export {
312
- G as A,
313
- w as D,
314
- $ as J,
315
- F as P,
316
- b as R,
317
- y as V,
318
- P as a,
319
- T as b,
320
- J as c,
321
- q as d,
322
- Y as e
323
- };
324
- //# sourceMappingURL=json-rpc-client-Ehjthcd7.js.map