@rhinestone/deposit-modal 0.12.2 → 0.13.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 (65) hide show
  1. package/README.md +30 -16
  2. package/dist/ClaimModal-CREZO27I.mjs +11 -0
  3. package/dist/ClaimModal-JRIA32U2.cjs +11 -0
  4. package/dist/{DepositModalReown-TEC3MEZ4.mjs → DepositModalReown-3H75G3XQ.mjs} +44 -22
  5. package/dist/{DepositModalReown-VG66OTIU.cjs → DepositModalReown-YNNHLAV2.cjs} +57 -35
  6. package/dist/{QRCode-WUC652SH.mjs → QRCode-5RGIZZHL.mjs} +1 -1
  7. package/dist/{QRCode-5DXFNKI2.cjs → QRCode-JKXG4RHN.cjs} +2 -2
  8. package/dist/WithdrawModal-NVRX44IZ.mjs +10 -0
  9. package/dist/WithdrawModal-YYSBPCJJ.cjs +10 -0
  10. package/dist/{chunk-OIN4CXCP.cjs → chunk-2G2EIN4A.cjs} +1510 -896
  11. package/dist/{chunk-O7BCVQ6L.cjs → chunk-4KCSH4T3.cjs} +157 -199
  12. package/dist/{chunk-TM7VGHAG.cjs → chunk-5NUIKYSF.cjs} +83 -209
  13. package/dist/{chunk-UQIJU6HV.cjs → chunk-7N77GIP4.cjs} +102 -88
  14. package/dist/{chunk-J46WDSRD.mjs → chunk-COCBCQQC.mjs} +121 -86
  15. package/dist/chunk-CVGNCUVU.cjs +154 -0
  16. package/dist/{chunk-SDSKIJC7.mjs → chunk-DSIZNRWA.mjs} +1540 -926
  17. package/dist/{chunk-75DVGSAX.cjs → chunk-DW2EQA2U.cjs} +6 -3
  18. package/dist/{chunk-FXXUIK4E.mjs → chunk-EOMT5LKX.mjs} +374 -151
  19. package/dist/chunk-FZ5FZFIG.mjs +31 -0
  20. package/dist/chunk-GACIGCSN.cjs +31 -0
  21. package/dist/{chunk-HL5NUKZW.cjs → chunk-HOGZKHHY.cjs} +3 -3
  22. package/dist/{chunk-FLVLYO64.mjs → chunk-LTMMETAB.mjs} +29 -15
  23. package/dist/{chunk-2TPSF77V.mjs → chunk-OLCD75JK.mjs} +20 -146
  24. package/dist/{chunk-PWLEBV5V.cjs → chunk-RAADLTSW.cjs} +240 -205
  25. package/dist/{chunk-4ZXQPFNU.mjs → chunk-RN5VKWI6.mjs} +4 -1
  26. package/dist/{chunk-3STTWRAN.mjs → chunk-VUATPOWJ.mjs} +147 -189
  27. package/dist/{chunk-JE4R5VA3.mjs → chunk-XYJFEN5D.mjs} +1 -1
  28. package/dist/chunk-YREVFB64.mjs +154 -0
  29. package/dist/{chunk-BRYNGLDM.cjs → chunk-ZMT4ATHR.cjs} +437 -214
  30. package/dist/claim.cjs +7 -6
  31. package/dist/claim.d.cts +11 -3
  32. package/dist/claim.d.ts +11 -3
  33. package/dist/claim.mjs +6 -5
  34. package/dist/{constants-FuzG3h4m.d.cts → constants-DBrWhJWE.d.cts} +12 -7
  35. package/dist/{constants-FuzG3h4m.d.ts → constants-DBrWhJWE.d.ts} +12 -7
  36. package/dist/constants.cjs +3 -9
  37. package/dist/constants.d.cts +2 -3
  38. package/dist/constants.d.ts +2 -3
  39. package/dist/constants.mjs +4 -10
  40. package/dist/deposit.cjs +8 -8
  41. package/dist/deposit.d.cts +2 -2
  42. package/dist/deposit.d.ts +2 -2
  43. package/dist/deposit.mjs +7 -7
  44. package/dist/embed.cjs +1268 -0
  45. package/dist/embed.d.cts +177 -0
  46. package/dist/embed.d.ts +177 -0
  47. package/dist/embed.mjs +1268 -0
  48. package/dist/index.cjs +11 -16
  49. package/dist/index.d.cts +3 -3
  50. package/dist/index.d.ts +3 -3
  51. package/dist/index.mjs +14 -19
  52. package/dist/modal-ui-state-OD1RmKkK.d.cts +30 -0
  53. package/dist/modal-ui-state-OD1RmKkK.d.ts +30 -0
  54. package/dist/polymarket.cjs +17 -7
  55. package/dist/polymarket.mjs +13 -3
  56. package/dist/styles.css +124 -98
  57. package/dist/{types-oFblf65g.d.ts → types-B89I8_8H.d.ts} +27 -1
  58. package/dist/{types-BO4iP6fG.d.cts → types-nnDR4tqA.d.cts} +27 -1
  59. package/dist/withdraw.cjs +6 -6
  60. package/dist/withdraw.d.cts +11 -3
  61. package/dist/withdraw.d.ts +11 -3
  62. package/dist/withdraw.mjs +5 -5
  63. package/package.json +33 -1
  64. package/dist/chunk-IAGFDSNC.mjs +0 -11
  65. package/dist/chunk-L32UI7LA.cjs +0 -11
@@ -24,16 +24,17 @@ import {
24
24
  tokenAmountToNumber,
25
25
  useExplorerTxUrl,
26
26
  useLatestRef
27
- } from "./chunk-FXXUIK4E.mjs";
27
+ } from "./chunk-EOMT5LKX.mjs";
28
28
  import {
29
29
  NATIVE_TOKEN_ADDRESS,
30
+ SOLANA_MAINNET_CAIP2,
30
31
  cdnIconUrl,
31
32
  getChainIcon,
32
33
  getChainName,
33
34
  targetChainToCaip2,
34
35
  targetChainToChainId,
35
36
  toEvmCaip2
36
- } from "./chunk-3STTWRAN.mjs";
37
+ } from "./chunk-VUATPOWJ.mjs";
37
38
 
38
39
  // src/core/removed-props.ts
39
40
  var MANAGED_ACCOUNT_REMOVALS = {
@@ -62,7 +63,7 @@ var REMOVED_PROPS = {
62
63
  }
63
64
  };
64
65
  var REMOVED_UI_CONFIG_KEYS = {
65
- checkLiquidity: "removed \u2014 the liquidity cap is shown on the QR / transfer screen, which checks it directly.",
66
+ checkLiquidity: "removed \u2014 the modal no longer surfaces a liquidity cap. Route capacity is enforced when the deposit is processed.",
66
67
  showHistoryButton: "removed \u2014 deposit history is always offered, from the modal's home screen. There is no way to hide it."
67
68
  };
68
69
  var warned = /* @__PURE__ */ new Set();
@@ -96,73 +97,23 @@ function warnRemovedProps(component, props) {
96
97
  }
97
98
  }
98
99
 
99
- // src/core/useTokenPrices.ts
100
- import { useEffect, useState } from "react";
101
- function isErc20(token) {
102
- return typeof token.chainId === "number" && !!token.address && token.address.toLowerCase() !== NATIVE_TOKEN_ADDRESS.toLowerCase();
103
- }
104
- function caip2For(token) {
105
- return `${toEvmCaip2(token.chainId)}:${token.address.toLowerCase()}`;
100
+ // src/core/submission-uncertainty.ts
101
+ var MARKER = "__rhinestoneSubmissionUncertain";
102
+ function markSubmissionUncertain(error) {
103
+ Object.defineProperty(error, MARKER, {
104
+ value: true,
105
+ enumerable: false
106
+ });
107
+ return error;
106
108
  }
107
- async function fetchTokenPriceUsd(service, token) {
108
- if (isErc20(token)) {
109
- const caip2 = caip2For(token);
110
- const prices2 = await service.fetchPricesByAddress([caip2]);
111
- const price2 = prices2[caip2];
112
- return typeof price2 === "number" && price2 > 0 ? price2 : null;
109
+ function isSubmissionUncertain(error) {
110
+ let current = error;
111
+ for (let depth = 0; depth < 10; depth += 1) {
112
+ if (typeof current !== "object" || current === null) return false;
113
+ if (current[MARKER] === true) return true;
114
+ current = current.cause;
113
115
  }
114
- const symbol = token.symbol.toUpperCase();
115
- const prices = await service.fetchPrices([symbol]);
116
- const price = prices[symbol];
117
- return typeof price === "number" && price > 0 ? price : null;
118
- }
119
- function useTokenPrices(service, tokens) {
120
- const [prices, setPrices] = useState({});
121
- const defined = tokens.filter((t) => Boolean(t?.symbol));
122
- const entries = [
123
- ...new Map(
124
- defined.map((token) => {
125
- const erc20 = isErc20(token);
126
- const caip2 = erc20 ? caip2For(token) : null;
127
- const symbol = token.symbol.toUpperCase();
128
- return [caip2 ?? `sym:${symbol}`, { symbol, caip2 }];
129
- })
130
- ).values()
131
- ].sort(
132
- (a, b) => (a.caip2 ?? a.symbol).localeCompare(b.caip2 ?? b.symbol)
133
- );
134
- const key = JSON.stringify(entries);
135
- useEffect(() => {
136
- if (key === "[]") return;
137
- let cancelled = false;
138
- const parsed = JSON.parse(key);
139
- const symbols = [
140
- ...new Set(parsed.filter((e) => !e.caip2).map((e) => e.symbol))
141
- ];
142
- const caip2Ids = [
143
- ...new Set(
144
- parsed.filter((e) => e.caip2).map((e) => e.caip2)
145
- )
146
- ];
147
- Promise.all([
148
- symbols.length > 0 ? service.fetchPrices(symbols) : Promise.resolve({}),
149
- caip2Ids.length > 0 ? service.fetchPricesByAddress(caip2Ids) : Promise.resolve({})
150
- ]).then(([bySymbol, byAddress]) => {
151
- if (cancelled) return;
152
- const merged = { ...bySymbol };
153
- for (const entry of parsed) {
154
- if (!entry.caip2) continue;
155
- const price = byAddress[entry.caip2];
156
- if (typeof price === "number") merged[entry.symbol] = price;
157
- }
158
- setPrices(merged);
159
- }).catch(() => {
160
- });
161
- return () => {
162
- cancelled = true;
163
- };
164
- }, [service, key]);
165
- return prices;
116
+ return false;
166
117
  }
167
118
 
168
119
  // src/components/steps/ProcessingStep.tsx
@@ -170,16 +121,16 @@ import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2
170
121
 
171
122
  // src/components/ui/Tooltip.tsx
172
123
  import {
173
- useState as useState2,
124
+ useState,
174
125
  useRef,
175
- useEffect as useEffect2,
126
+ useEffect,
176
127
  useCallback
177
128
  } from "react";
178
129
  import { createPortal } from "react-dom";
179
130
  import { jsx, jsxs } from "react/jsx-runtime";
180
131
  function Tooltip({ content, children, className }) {
181
- const [open, setOpen] = useState2(false);
182
- const [position, setPosition] = useState2(null);
132
+ const [open, setOpen] = useState(false);
133
+ const [position, setPosition] = useState(null);
183
134
  const triggerRef = useRef(null);
184
135
  const bubbleRef = useRef(null);
185
136
  const updatePosition = useCallback(() => {
@@ -191,7 +142,7 @@ function Tooltip({ content, children, className }) {
191
142
  left: rect.left + rect.width / 2
192
143
  });
193
144
  }, []);
194
- useEffect2(() => {
145
+ useEffect(() => {
195
146
  if (!open) return;
196
147
  updatePosition();
197
148
  function handleOutside(event) {
@@ -266,10 +217,10 @@ function Tooltip({ content, children, className }) {
266
217
  Tooltip.displayName = "Tooltip";
267
218
 
268
219
  // src/components/ui/FeesAccordion.tsx
269
- import { useState as useState3 } from "react";
220
+ import { useState as useState2 } from "react";
270
221
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
271
222
  function FeesAccordion({ total, rows, tooltip }) {
272
- const [open, setOpen] = useState3(false);
223
+ const [open, setOpen] = useState2(false);
273
224
  const expandable = rows.length > 0;
274
225
  return /* @__PURE__ */ jsxs2("div", { className: "rs-fees-accordion", children: [
275
226
  /* @__PURE__ */ jsxs2("div", { className: "rs-fees-accordion-summary", children: [
@@ -555,6 +506,70 @@ function failureMessageForEvent(event) {
555
506
  return formatBridgeFailedMessage(event).message;
556
507
  }
557
508
 
509
+ // src/core/useTokenPrices.ts
510
+ import { useEffect as useEffect2, useState as useState3 } from "react";
511
+ var PRICE_SERVICE_NATIVE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
512
+ var WRAPPED_SOL_MINT = "So11111111111111111111111111111111111111112";
513
+ var SOL_SYSTEM_PROGRAM = "11111111111111111111111111111111";
514
+ function isSolanaNativeAddress(address) {
515
+ if (!address) return true;
516
+ const lower = address.toLowerCase();
517
+ return lower === "native" || lower === SOL_SYSTEM_PROGRAM;
518
+ }
519
+ function isNativeAddress(address) {
520
+ if (!address) return true;
521
+ return address.toLowerCase() === NATIVE_TOKEN_ADDRESS.toLowerCase();
522
+ }
523
+ function caip2For(token) {
524
+ if (token.chainId === "solana") {
525
+ const mint = isSolanaNativeAddress(token.address) ? WRAPPED_SOL_MINT : token.address;
526
+ return mint ? `${SOLANA_MAINNET_CAIP2}:${mint}` : void 0;
527
+ }
528
+ if (typeof token.chainId !== "number") return void 0;
529
+ const address = isNativeAddress(token.address) ? PRICE_SERVICE_NATIVE : token.address;
530
+ return `${toEvmCaip2(token.chainId)}:${address.toLowerCase()}`;
531
+ }
532
+ async function fetchTokenPriceUsd(service, token) {
533
+ const caip2 = caip2For(token);
534
+ if (!caip2) return null;
535
+ const prices = await service.fetchPricesByAddress([caip2]);
536
+ const price = prices[caip2];
537
+ return typeof price === "number" && price > 0 ? price : null;
538
+ }
539
+ function useTokenPrices(service, tokens) {
540
+ const [prices, setPrices] = useState3({});
541
+ const defined = tokens.filter((t) => Boolean(t?.symbol));
542
+ const entries = [
543
+ ...new Map(
544
+ defined.flatMap((token) => {
545
+ const caip2 = caip2For(token);
546
+ return caip2 ? [{ symbol: token.symbol.toUpperCase(), caip2 }] : [];
547
+ }).map((entry) => [entry.caip2, entry])
548
+ ).values()
549
+ ].sort((a, b) => a.caip2.localeCompare(b.caip2));
550
+ const key = JSON.stringify(entries);
551
+ useEffect2(() => {
552
+ if (key === "[]") return;
553
+ let cancelled = false;
554
+ const parsed = JSON.parse(key);
555
+ const caip2Ids = [...new Set(parsed.map((e) => e.caip2))];
556
+ service.fetchPricesByAddress(caip2Ids).then((byAddress) => {
557
+ if (cancelled) return;
558
+ const merged = {};
559
+ for (const entry of parsed) {
560
+ const price = byAddress[entry.caip2];
561
+ if (typeof price === "number") merged[entry.symbol] = price;
562
+ }
563
+ setPrices(merged);
564
+ }).catch(() => {
565
+ });
566
+ return () => {
567
+ cancelled = true;
568
+ };
569
+ }, [service, key]);
570
+ return prices;
571
+ }
572
+
558
573
  // src/components/steps/ProcessingStep.tsx
559
574
  import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
560
575
  function SuccessBadge() {
@@ -837,6 +852,9 @@ function getInitialProcessingState(event, txHash) {
837
852
  }
838
853
  return null;
839
854
  }
855
+ function getSettledSourceTxHash(event, fallbackTxHash) {
856
+ return event?.data?.source?.transactionHash ?? fallbackTxHash;
857
+ }
840
858
  function ProcessingStep({
841
859
  smartAccount,
842
860
  solanaDepositAddress,
@@ -850,6 +868,7 @@ function ProcessingStep({
850
868
  amountUsd,
851
869
  service,
852
870
  directTransfer,
871
+ sourceTxHashPending,
853
872
  initialEvent,
854
873
  flowLabel = "deposit",
855
874
  debug,
@@ -959,20 +978,26 @@ function ProcessingStep({
959
978
  if (!outcome) return;
960
979
  if (outcome.type === "complete") {
961
980
  const context = processingContextRef.current;
981
+ const sourceTxHash2 = getSettledSourceTxHash(event, txHash);
962
982
  debugLog(debug, "processing", "initial-event:complete", {
963
983
  txHash,
984
+ sourceTxHash: sourceTxHash2,
964
985
  destinationTxHash: outcome.destinationTxHash,
965
986
  event: event.type
966
987
  });
967
- onDepositCompleteRef.current?.(txHash, outcome.destinationTxHash, {
968
- amount: context.amount,
969
- sourceChain: context.sourceChain,
970
- sourceToken: context.sourceToken,
971
- sourceDecimals: context.sourceDecimals,
972
- amountUsd: context.amountUsd,
973
- targetChain: context.targetChain,
974
- targetToken: context.targetToken
975
- });
988
+ onDepositCompleteRef.current?.(
989
+ sourceTxHash2,
990
+ outcome.destinationTxHash,
991
+ {
992
+ amount: context.amount,
993
+ sourceChain: context.sourceChain,
994
+ sourceToken: context.sourceToken,
995
+ sourceDecimals: context.sourceDecimals,
996
+ amountUsd: context.amountUsd,
997
+ targetChain: context.targetChain,
998
+ targetToken: context.targetToken
999
+ }
1000
+ );
976
1001
  return;
977
1002
  }
978
1003
  debugLog(debug, "processing", "initial-event:failed", {
@@ -1101,14 +1126,19 @@ function ProcessingStep({
1101
1126
  if (!isMounted) return;
1102
1127
  if (eventForCurrentTx?.type === "bridge-complete") {
1103
1128
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1129
+ const sourceTxHash2 = getSettledSourceTxHash(
1130
+ eventForCurrentTx,
1131
+ txHash
1132
+ );
1104
1133
  const destinationTxHash2 = eventForCurrentTx.data?.destination?.transactionHash;
1105
1134
  debugLog(debug, "processing", "state:complete", {
1106
1135
  txHash,
1136
+ sourceTxHash: sourceTxHash2,
1107
1137
  destinationTxHash: destinationTxHash2,
1108
1138
  event: eventForCurrentTx.type
1109
1139
  });
1110
1140
  const context = processingContextRef.current;
1111
- onDepositCompleteRef.current?.(txHash, destinationTxHash2, {
1141
+ onDepositCompleteRef.current?.(sourceTxHash2, destinationTxHash2, {
1112
1142
  amount: context.amount,
1113
1143
  sourceChain: context.sourceChain,
1114
1144
  sourceToken: context.sourceToken,
@@ -1219,12 +1249,15 @@ function ProcessingStep({
1219
1249
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
1220
1250
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
1221
1251
  const destinationTxHash = lastEvent?.data?.destination?.transactionHash || null;
1252
+ const sourceTxHash = getSettledSourceTxHash(lastEvent, txHash);
1222
1253
  const sourceDetails = getEventSourceDetails(lastEvent);
1223
1254
  const displaySourceChain = sourceDetails.chainId ?? sourceChain;
1224
1255
  const displaySourceToken = sourceDetails.token ?? sourceToken;
1225
1256
  const displayAmount = sourceDetails.amount ?? amount;
1226
1257
  const targetChainId = targetChainToChainId(targetChain);
1227
- const sourceExplorerUrl = explorerTxUrl(displaySourceChain, txHash);
1258
+ const settledSourceTxHash = lastEvent?.data?.source?.transactionHash;
1259
+ const sourceExplorerHash = settledSourceTxHash ?? (sourceTxHashPending ? null : sourceTxHash);
1260
+ const sourceExplorerUrl = sourceExplorerHash ? explorerTxUrl(displaySourceChain, sourceExplorerHash) : null;
1228
1261
  const destExplorerUrl = destinationTxHash ? explorerTxUrl(targetChainId, destinationTxHash) : null;
1229
1262
  const sourceDisplay = (() => {
1230
1263
  const resolved = resolveTokenDisplay(displaySourceToken, displaySourceChain, {
@@ -1748,6 +1781,8 @@ export {
1748
1781
  getExchangeLogoSrc,
1749
1782
  getExchangeLogo,
1750
1783
  Tooltip,
1784
+ markSubmissionUncertain,
1785
+ isSubmissionUncertain,
1751
1786
  getEventTxHash,
1752
1787
  getEventSourceDetails,
1753
1788
  isDepositEvent,
@@ -0,0 +1,154 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkZMT4ATHRcjs = require('./chunk-ZMT4ATHR.cjs');
5
+
6
+
7
+ var _chunkGACIGCSNcjs = require('./chunk-GACIGCSN.cjs');
8
+
9
+ // src/core/recovery.ts
10
+ var RECOVER_DOMAIN = {
11
+ name: "Rhinestone Deposit Recovery",
12
+ version: "1"
13
+ };
14
+ var RECOVER_TYPES = {
15
+ RecoverDeposit: [
16
+ { name: "depositId", type: "uint256" },
17
+ { name: "destination", type: "address" }
18
+ ]
19
+ };
20
+ var RecoveryError = class extends Error {
21
+ constructor(message, status, code, retryable = false) {
22
+ super(message);
23
+ this.name = "RecoveryError";
24
+ this.status = status;
25
+ this.code = code;
26
+ this.retryable = retryable;
27
+ }
28
+ };
29
+ function formatRecoveryError(status, code, serverMessage) {
30
+ switch (code) {
31
+ case "DEPOSIT_NOT_RECOVERABLE":
32
+ return {
33
+ message: "This deposit can't be recovered \u2014 it may already have been claimed.",
34
+ retryable: false
35
+ };
36
+ case "RECOVERY_UNSUPPORTED":
37
+ return {
38
+ message: "This deposit can't be recovered automatically. Contact support to get your funds back.",
39
+ retryable: false
40
+ };
41
+ case "SIGNATURE_INVALID":
42
+ return {
43
+ message: "That signature wasn't accepted for this wallet. Contact support to recover this deposit.",
44
+ retryable: false
45
+ };
46
+ case "VERIFICATION_UNAVAILABLE":
47
+ return {
48
+ message: "Couldn't verify your signature just now. Try again shortly.",
49
+ retryable: true
50
+ };
51
+ case "REFUND_RECONCILIATION_REQUIRED":
52
+ return {
53
+ message: "Your recovery is being reviewed. Contact support with this deposit if it doesn't arrive.",
54
+ retryable: false
55
+ };
56
+ case "REFUND_FAILED":
57
+ return {
58
+ message: _nullishCoalesce(serverMessage, () => ( "The recovery couldn't be completed. Please try again or contact support.")),
59
+ retryable: true
60
+ };
61
+ default:
62
+ if (status === 0) {
63
+ return {
64
+ message: "Couldn't reach the recovery service. Check your connection and try again.",
65
+ retryable: true
66
+ };
67
+ }
68
+ return {
69
+ message: _nullishCoalesce(serverMessage, () => ( "The recovery couldn't be completed. Please try again or contact support.")),
70
+ retryable: true
71
+ };
72
+ }
73
+ }
74
+ async function submitSignedRecovery(params) {
75
+ const { backendUrl, chainId, depositId, signer, destination, signRecovery, debug } = params;
76
+ const scope = "service:recovery";
77
+ const typedData = {
78
+ domain: RECOVER_DOMAIN,
79
+ types: RECOVER_TYPES,
80
+ primaryType: "RecoverDeposit",
81
+ message: { depositId: BigInt(depositId), destination }
82
+ };
83
+ let signature;
84
+ try {
85
+ signature = await signRecovery({
86
+ typedData,
87
+ chainId,
88
+ signer,
89
+ depositId,
90
+ destination
91
+ });
92
+ } catch (error) {
93
+ _chunkZMT4ATHRcjs.debugError.call(void 0, debug, scope, "signRecovery:failed", error);
94
+ throw new RecoveryError(
95
+ "Signature request was declined. Approve it in your wallet to recover this deposit.",
96
+ 0,
97
+ void 0,
98
+ true
99
+ );
100
+ }
101
+ if (!signature) {
102
+ throw new RecoveryError(
103
+ "Signature request was declined. Approve it in your wallet to recover this deposit.",
104
+ 0,
105
+ void 0,
106
+ true
107
+ );
108
+ }
109
+ const url = `${backendUrl.replace(/\/$/, "")}/deposits/recover`;
110
+ _chunkZMT4ATHRcjs.debugLog.call(void 0, debug, scope, "submitSignedRecovery:request", {
111
+ url,
112
+ depositId,
113
+ signer
114
+ });
115
+ let response;
116
+ try {
117
+ response = await fetch(url, {
118
+ method: "POST",
119
+ // The shared const, so recovery carries `x-deposit-modal-version` like
120
+ // every other backend call. Without it this path would be invisible in the
121
+ // per-client version telemetry the processor records.
122
+ headers: _chunkGACIGCSNcjs.serviceHeaders.call(void 0, ),
123
+ // `depositId` as a string: it is a uint256 upstream and JSON numbers lose
124
+ // precision well before that range.
125
+ body: JSON.stringify({ depositId, destination, signature })
126
+ });
127
+ } catch (error) {
128
+ _chunkZMT4ATHRcjs.debugError.call(void 0, debug, scope, "submitSignedRecovery:network", error);
129
+ const { message, retryable } = formatRecoveryError(0);
130
+ throw new RecoveryError(message, 0, void 0, retryable);
131
+ }
132
+ if (!response.ok) {
133
+ const body = await response.json().catch(() => ({}));
134
+ _chunkZMT4ATHRcjs.debugError.call(void 0, debug, scope, "submitSignedRecovery:failed", body, {
135
+ status: response.status
136
+ });
137
+ const { message, retryable } = formatRecoveryError(
138
+ response.status,
139
+ body.code,
140
+ body.error
141
+ );
142
+ throw new RecoveryError(message, response.status, body.code, retryable);
143
+ }
144
+ const result = await response.json();
145
+ _chunkZMT4ATHRcjs.debugLog.call(void 0, debug, scope, "submitSignedRecovery:success", {
146
+ transactionHash: result.transactionHash
147
+ });
148
+ return result;
149
+ }
150
+
151
+
152
+
153
+
154
+ exports.RecoveryError = RecoveryError; exports.submitSignedRecovery = submitSignedRecovery;