@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.
- package/README.md +30 -16
- package/dist/ClaimModal-CREZO27I.mjs +11 -0
- package/dist/ClaimModal-JRIA32U2.cjs +11 -0
- package/dist/{DepositModalReown-TEC3MEZ4.mjs → DepositModalReown-3H75G3XQ.mjs} +44 -22
- package/dist/{DepositModalReown-VG66OTIU.cjs → DepositModalReown-YNNHLAV2.cjs} +57 -35
- package/dist/{QRCode-WUC652SH.mjs → QRCode-5RGIZZHL.mjs} +1 -1
- package/dist/{QRCode-5DXFNKI2.cjs → QRCode-JKXG4RHN.cjs} +2 -2
- package/dist/WithdrawModal-NVRX44IZ.mjs +10 -0
- package/dist/WithdrawModal-YYSBPCJJ.cjs +10 -0
- package/dist/{chunk-OIN4CXCP.cjs → chunk-2G2EIN4A.cjs} +1510 -896
- package/dist/{chunk-O7BCVQ6L.cjs → chunk-4KCSH4T3.cjs} +157 -199
- package/dist/{chunk-TM7VGHAG.cjs → chunk-5NUIKYSF.cjs} +83 -209
- package/dist/{chunk-UQIJU6HV.cjs → chunk-7N77GIP4.cjs} +102 -88
- package/dist/{chunk-J46WDSRD.mjs → chunk-COCBCQQC.mjs} +121 -86
- package/dist/chunk-CVGNCUVU.cjs +154 -0
- package/dist/{chunk-SDSKIJC7.mjs → chunk-DSIZNRWA.mjs} +1540 -926
- package/dist/{chunk-75DVGSAX.cjs → chunk-DW2EQA2U.cjs} +6 -3
- package/dist/{chunk-FXXUIK4E.mjs → chunk-EOMT5LKX.mjs} +374 -151
- package/dist/chunk-FZ5FZFIG.mjs +31 -0
- package/dist/chunk-GACIGCSN.cjs +31 -0
- package/dist/{chunk-HL5NUKZW.cjs → chunk-HOGZKHHY.cjs} +3 -3
- package/dist/{chunk-FLVLYO64.mjs → chunk-LTMMETAB.mjs} +29 -15
- package/dist/{chunk-2TPSF77V.mjs → chunk-OLCD75JK.mjs} +20 -146
- package/dist/{chunk-PWLEBV5V.cjs → chunk-RAADLTSW.cjs} +240 -205
- package/dist/{chunk-4ZXQPFNU.mjs → chunk-RN5VKWI6.mjs} +4 -1
- package/dist/{chunk-3STTWRAN.mjs → chunk-VUATPOWJ.mjs} +147 -189
- package/dist/{chunk-JE4R5VA3.mjs → chunk-XYJFEN5D.mjs} +1 -1
- package/dist/chunk-YREVFB64.mjs +154 -0
- package/dist/{chunk-BRYNGLDM.cjs → chunk-ZMT4ATHR.cjs} +437 -214
- package/dist/claim.cjs +7 -6
- package/dist/claim.d.cts +11 -3
- package/dist/claim.d.ts +11 -3
- package/dist/claim.mjs +6 -5
- package/dist/{constants-FuzG3h4m.d.cts → constants-DBrWhJWE.d.cts} +12 -7
- package/dist/{constants-FuzG3h4m.d.ts → constants-DBrWhJWE.d.ts} +12 -7
- package/dist/constants.cjs +3 -9
- package/dist/constants.d.cts +2 -3
- package/dist/constants.d.ts +2 -3
- package/dist/constants.mjs +4 -10
- package/dist/deposit.cjs +8 -8
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +7 -7
- package/dist/embed.cjs +1268 -0
- package/dist/embed.d.cts +177 -0
- package/dist/embed.d.ts +177 -0
- package/dist/embed.mjs +1268 -0
- package/dist/index.cjs +11 -16
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +14 -19
- package/dist/modal-ui-state-OD1RmKkK.d.cts +30 -0
- package/dist/modal-ui-state-OD1RmKkK.d.ts +30 -0
- package/dist/polymarket.cjs +17 -7
- package/dist/polymarket.mjs +13 -3
- package/dist/styles.css +124 -98
- package/dist/{types-oFblf65g.d.ts → types-B89I8_8H.d.ts} +27 -1
- package/dist/{types-BO4iP6fG.d.cts → types-nnDR4tqA.d.cts} +27 -1
- package/dist/withdraw.cjs +6 -6
- package/dist/withdraw.d.cts +11 -3
- package/dist/withdraw.d.ts +11 -3
- package/dist/withdraw.mjs +5 -5
- package/package.json +33 -1
- package/dist/chunk-IAGFDSNC.mjs +0 -11
- package/dist/chunk-L32UI7LA.cjs +0 -11
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/core/version.ts
|
|
2
|
+
var MODAL_VERSION = "0.13.0";
|
|
3
|
+
var SERVICE_HEADERS = {
|
|
4
|
+
"Content-Type": "application/json",
|
|
5
|
+
"x-deposit-modal-version": MODAL_VERSION
|
|
6
|
+
};
|
|
7
|
+
var embedHostSuffix = "";
|
|
8
|
+
function setEmbedHost(host) {
|
|
9
|
+
if (!host) {
|
|
10
|
+
embedHostSuffix = "";
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const clean = (value, max) => (value ?? "").replace(/[^A-Za-z0-9._-]/g, "").slice(0, max);
|
|
14
|
+
const platform = clean(host.platform, 16) || "unknown";
|
|
15
|
+
const app = clean(host.app, 32);
|
|
16
|
+
const version = clean(host.version, 24);
|
|
17
|
+
const named = app ? version ? `${app}/${version}` : app : "";
|
|
18
|
+
embedHostSuffix = named ? ` (${platform}; ${named})` : ` (${platform})`;
|
|
19
|
+
}
|
|
20
|
+
function serviceHeaders() {
|
|
21
|
+
return {
|
|
22
|
+
...SERVICE_HEADERS,
|
|
23
|
+
"x-deposit-modal-version": `${MODAL_VERSION}${embedHostSuffix}`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
MODAL_VERSION,
|
|
29
|
+
setEmbedHost,
|
|
30
|
+
serviceHeaders
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/core/version.ts
|
|
2
|
+
var MODAL_VERSION = "0.13.0";
|
|
3
|
+
var SERVICE_HEADERS = {
|
|
4
|
+
"Content-Type": "application/json",
|
|
5
|
+
"x-deposit-modal-version": MODAL_VERSION
|
|
6
|
+
};
|
|
7
|
+
var embedHostSuffix = "";
|
|
8
|
+
function setEmbedHost(host) {
|
|
9
|
+
if (!host) {
|
|
10
|
+
embedHostSuffix = "";
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const clean = (value, max) => (_nullishCoalesce(value, () => ( ""))).replace(/[^A-Za-z0-9._-]/g, "").slice(0, max);
|
|
14
|
+
const platform = clean(host.platform, 16) || "unknown";
|
|
15
|
+
const app = clean(host.app, 32);
|
|
16
|
+
const version = clean(host.version, 24);
|
|
17
|
+
const named = app ? version ? `${app}/${version}` : app : "";
|
|
18
|
+
embedHostSuffix = named ? ` (${platform}; ${named})` : ` (${platform})`;
|
|
19
|
+
}
|
|
20
|
+
function serviceHeaders() {
|
|
21
|
+
return {
|
|
22
|
+
...SERVICE_HEADERS,
|
|
23
|
+
"x-deposit-modal-version": `${MODAL_VERSION}${embedHostSuffix}`
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.MODAL_VERSION = MODAL_VERSION; exports.setEmbedHost = setEmbedHost; exports.serviceHeaders = serviceHeaders;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkZMT4ATHRcjs = require('./chunk-ZMT4ATHR.cjs');
|
|
5
5
|
|
|
6
6
|
// src/components/ui/ListRow.tsx
|
|
7
7
|
var _jsxruntime = require('react/jsx-runtime');
|
|
@@ -19,7 +19,7 @@ function ListRow({
|
|
|
19
19
|
...props
|
|
20
20
|
}) {
|
|
21
21
|
const inner = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
22
|
-
leadingMedia ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-leading rs-list-row-leading--media", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
22
|
+
leadingMedia ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-leading rs-list-row-leading--media", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZMT4ATHRcjs.CdnIcon, { src: leadingMedia }) }) : leading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-leading", children: leading }) : null,
|
|
23
23
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-list-row-body", children: [
|
|
24
24
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-list-row-text", children: [
|
|
25
25
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-title", children: title }),
|
|
@@ -39,7 +39,7 @@ function ListRow({
|
|
|
39
39
|
}
|
|
40
40
|
) : meta && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-list-row-meta", children: meta })
|
|
41
41
|
] }),
|
|
42
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-chevron", children: _nullishCoalesce(trailing, () => ( (disabled ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
42
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-list-row-chevron", children: _nullishCoalesce(trailing, () => ( (disabled ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZMT4ATHRcjs.ChevronRightIcon, {})))) })
|
|
43
43
|
] });
|
|
44
44
|
if (action) {
|
|
45
45
|
const handleKey = (e) => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProcessingStep,
|
|
3
3
|
deriveAccountSalt,
|
|
4
|
+
isSubmissionUncertain,
|
|
4
5
|
useTokenPrices,
|
|
5
6
|
warnRemovedProps
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-COCBCQQC.mjs";
|
|
7
8
|
import {
|
|
8
9
|
BodyHeader,
|
|
9
10
|
Button,
|
|
@@ -29,15 +30,15 @@ import {
|
|
|
29
30
|
formatTokenAmount,
|
|
30
31
|
formatUserError,
|
|
31
32
|
getAssetId,
|
|
32
|
-
getPublicClient,
|
|
33
33
|
isNativeAsset,
|
|
34
34
|
isRecognizedToken,
|
|
35
35
|
useDestinationChains,
|
|
36
36
|
useLatestRef,
|
|
37
|
+
useReadClient,
|
|
37
38
|
useRpcUrls,
|
|
38
39
|
useStableRpcUrls,
|
|
39
40
|
useTargetTokens
|
|
40
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-EOMT5LKX.mjs";
|
|
41
42
|
import {
|
|
42
43
|
NATIVE_TOKEN_ADDRESS,
|
|
43
44
|
getChainIcon,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
getTokenDecimalsByAddress,
|
|
47
48
|
getTokenSymbol,
|
|
48
49
|
targetChainToCaip2
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-VUATPOWJ.mjs";
|
|
50
51
|
|
|
51
52
|
// src/WithdrawModal.tsx
|
|
52
53
|
import { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
|
|
@@ -660,6 +661,7 @@ function WithdrawReviewStep({
|
|
|
660
661
|
prices
|
|
661
662
|
}) ?? // No price for the target token — an honest dash beats a wrong number.
|
|
662
663
|
"\u2014";
|
|
664
|
+
const [submissionUncertain, setSubmissionUncertain] = useState2(false);
|
|
663
665
|
const handleConfirm = async () => {
|
|
664
666
|
setError(null);
|
|
665
667
|
setIsSubmitting(true);
|
|
@@ -667,14 +669,16 @@ function WithdrawReviewStep({
|
|
|
667
669
|
await onConfirm();
|
|
668
670
|
} catch (err) {
|
|
669
671
|
const raw = err instanceof Error ? err.message : "Withdraw failed";
|
|
670
|
-
const
|
|
672
|
+
const uncertain = isSubmissionUncertain(err);
|
|
673
|
+
const message = uncertain ? "Withdrawal status is uncertain. Check your activity before trying again." : formatUserError(raw);
|
|
674
|
+
if (uncertain) setSubmissionUncertain(true);
|
|
671
675
|
setError(message);
|
|
672
676
|
onError?.(message, "WITHDRAW_REVIEW_ERROR", raw);
|
|
673
677
|
} finally {
|
|
674
678
|
setIsSubmitting(false);
|
|
675
679
|
}
|
|
676
680
|
};
|
|
677
|
-
const disabled = isSubmitting || registrationPending || Boolean(registrationError);
|
|
681
|
+
const disabled = isSubmitting || submissionUncertain || registrationPending || Boolean(registrationError);
|
|
678
682
|
return /* @__PURE__ */ jsxs2("div", { className: "rs-screen", children: [
|
|
679
683
|
/* @__PURE__ */ jsxs2("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
680
684
|
/* @__PURE__ */ jsx2(
|
|
@@ -817,10 +821,7 @@ function WithdrawFlow({
|
|
|
817
821
|
const registration = useWithdrawStore((s) => s.registration);
|
|
818
822
|
const flowStep = useWithdrawStore((s) => s.step);
|
|
819
823
|
const reviewedRecipient = useWithdrawStore((s) => s.recipient);
|
|
820
|
-
const publicClient =
|
|
821
|
-
() => getPublicClient(sourceChain, rpcUrls),
|
|
822
|
-
[sourceChain, rpcUrls]
|
|
823
|
-
);
|
|
824
|
+
const publicClient = useReadClient(sourceChain, rpcUrls);
|
|
824
825
|
const recipientForRegistration = useMemo2(() => {
|
|
825
826
|
if (!recipientInput) return void 0;
|
|
826
827
|
return ADDR_REGEX.test(recipientInput) ? recipientInput : void 0;
|
|
@@ -932,7 +933,8 @@ function WithdrawFlow({
|
|
|
932
933
|
}, [storeApi]);
|
|
933
934
|
useEffect2(() => {
|
|
934
935
|
onStepChangeRef.current?.(
|
|
935
|
-
flowStep === "review" ? reviewBackHandler : void 0
|
|
936
|
+
flowStep === "review" ? reviewBackHandler : void 0,
|
|
937
|
+
flowStep
|
|
936
938
|
);
|
|
937
939
|
}, [flowStep, reviewBackHandler, onStepChangeRef]);
|
|
938
940
|
const lastStepOpenEventKeyRef = useRef2(null);
|
|
@@ -1284,6 +1286,9 @@ function WithdrawModal({
|
|
|
1284
1286
|
// Every prop 0.9.0 removed lands here, since none of them is named above.
|
|
1285
1287
|
// `uiConfig` is destructured, so its removed nested key isn't scanned — that
|
|
1286
1288
|
// one only ever applied to the deposit flow.
|
|
1289
|
+
// Before the rest element, or it lands in `removedProps` and gets warned
|
|
1290
|
+
// about as a prop 0.9.0 removed.
|
|
1291
|
+
onUiState,
|
|
1287
1292
|
...removedProps
|
|
1288
1293
|
}) {
|
|
1289
1294
|
warnRemovedProps("WithdrawModal", removedProps);
|
|
@@ -1293,6 +1298,8 @@ function WithdrawModal({
|
|
|
1293
1298
|
const [backHandler, setBackHandler] = useState4(
|
|
1294
1299
|
void 0
|
|
1295
1300
|
);
|
|
1301
|
+
const [screen, setScreen] = useState4("form");
|
|
1302
|
+
const onUiStateRef = useLatestRef(onUiState);
|
|
1296
1303
|
const targetChain = getChainId(targetChainProp ?? sourceChainProp);
|
|
1297
1304
|
const sourceChain = getChainId(sourceChainProp);
|
|
1298
1305
|
const rpcUrls = useStableRpcUrls(rpcUrlsProp);
|
|
@@ -1311,9 +1318,8 @@ function WithdrawModal({
|
|
|
1311
1318
|
}
|
|
1312
1319
|
}, [isOpen, onSendTransaction, onErrorRef]);
|
|
1313
1320
|
useEffect3(() => {
|
|
1314
|
-
if (isOpen
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1321
|
+
if (!isOpen || !modalRef.current) return;
|
|
1322
|
+
return applyTheme(modalRef.current, theme);
|
|
1317
1323
|
}, [isOpen, theme]);
|
|
1318
1324
|
useEffect3(() => {
|
|
1319
1325
|
if (isOpen) {
|
|
@@ -1325,9 +1331,17 @@ function WithdrawModal({
|
|
|
1325
1331
|
store.dispatch({ type: "modal/reset" });
|
|
1326
1332
|
}
|
|
1327
1333
|
}, [isOpen, store]);
|
|
1328
|
-
const handleStepChange = useCallback3((onBack) => {
|
|
1334
|
+
const handleStepChange = useCallback3((onBack, next) => {
|
|
1329
1335
|
setBackHandler(() => onBack);
|
|
1336
|
+
if (next) setScreen(next);
|
|
1330
1337
|
}, []);
|
|
1338
|
+
useEffect3(() => {
|
|
1339
|
+
onUiStateRef.current?.({
|
|
1340
|
+
screen,
|
|
1341
|
+
back: backHandler,
|
|
1342
|
+
submitting: false
|
|
1343
|
+
});
|
|
1344
|
+
}, [screen, backHandler, onUiStateRef]);
|
|
1331
1345
|
const showBackButton = uiConfig?.showBackButton ?? true;
|
|
1332
1346
|
const canGoBack = backHandler !== void 0;
|
|
1333
1347
|
return /* @__PURE__ */ jsx4(RpcUrlsProvider, { value: rpcUrls, children: /* @__PURE__ */ jsx4(ChainCatalogProvider, { service, rpcUrls, children: /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RecoveryError,
|
|
3
|
+
submitSignedRecovery
|
|
4
|
+
} from "./chunk-YREVFB64.mjs";
|
|
1
5
|
import {
|
|
2
6
|
ListRow
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XYJFEN5D.mjs";
|
|
4
8
|
import {
|
|
5
9
|
AlertTriangleIcon,
|
|
6
10
|
BodyHeader,
|
|
@@ -21,24 +25,19 @@ import {
|
|
|
21
25
|
applyTheme,
|
|
22
26
|
checkBackendUrl,
|
|
23
27
|
createDepositService,
|
|
24
|
-
debugError,
|
|
25
|
-
debugLog,
|
|
26
28
|
formatTokenAmount,
|
|
27
29
|
formatUserError,
|
|
28
30
|
useExplorerTxUrl,
|
|
29
31
|
useLatestRef,
|
|
30
32
|
useStableRpcUrls
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import {
|
|
33
|
-
SERVICE_HEADERS
|
|
34
|
-
} from "./chunk-IAGFDSNC.mjs";
|
|
33
|
+
} from "./chunk-EOMT5LKX.mjs";
|
|
35
34
|
import {
|
|
36
35
|
getChainIcon,
|
|
37
36
|
getChainName,
|
|
38
37
|
getTokenDecimalsByAddress,
|
|
39
38
|
getTokenSymbol,
|
|
40
39
|
tokenIconUrl
|
|
41
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-VUATPOWJ.mjs";
|
|
42
41
|
|
|
43
42
|
// src/ClaimModal.tsx
|
|
44
43
|
import {
|
|
@@ -76,142 +75,6 @@ var Input = forwardRef(
|
|
|
76
75
|
);
|
|
77
76
|
Input.displayName = "Input";
|
|
78
77
|
|
|
79
|
-
// src/core/recovery.ts
|
|
80
|
-
var RECOVER_DOMAIN = {
|
|
81
|
-
name: "Rhinestone Deposit Recovery",
|
|
82
|
-
version: "1"
|
|
83
|
-
};
|
|
84
|
-
var RECOVER_TYPES = {
|
|
85
|
-
RecoverDeposit: [
|
|
86
|
-
{ name: "depositId", type: "uint256" },
|
|
87
|
-
{ name: "destination", type: "address" }
|
|
88
|
-
]
|
|
89
|
-
};
|
|
90
|
-
var RecoveryError = class extends Error {
|
|
91
|
-
constructor(message, status, code, retryable = false) {
|
|
92
|
-
super(message);
|
|
93
|
-
this.name = "RecoveryError";
|
|
94
|
-
this.status = status;
|
|
95
|
-
this.code = code;
|
|
96
|
-
this.retryable = retryable;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
function formatRecoveryError(status, code, serverMessage) {
|
|
100
|
-
switch (code) {
|
|
101
|
-
case "DEPOSIT_NOT_RECOVERABLE":
|
|
102
|
-
return {
|
|
103
|
-
message: "This deposit can't be recovered \u2014 it may already have been claimed.",
|
|
104
|
-
retryable: false
|
|
105
|
-
};
|
|
106
|
-
case "RECOVERY_UNSUPPORTED":
|
|
107
|
-
return {
|
|
108
|
-
message: "This deposit can't be recovered automatically. Contact support to get your funds back.",
|
|
109
|
-
retryable: false
|
|
110
|
-
};
|
|
111
|
-
case "SIGNATURE_INVALID":
|
|
112
|
-
return {
|
|
113
|
-
message: "That signature wasn't accepted for this wallet. Contact support to recover this deposit.",
|
|
114
|
-
retryable: false
|
|
115
|
-
};
|
|
116
|
-
case "VERIFICATION_UNAVAILABLE":
|
|
117
|
-
return {
|
|
118
|
-
message: "Couldn't verify your signature just now. Try again shortly.",
|
|
119
|
-
retryable: true
|
|
120
|
-
};
|
|
121
|
-
case "REFUND_RECONCILIATION_REQUIRED":
|
|
122
|
-
return {
|
|
123
|
-
message: "Your recovery is being reviewed. Contact support with this deposit if it doesn't arrive.",
|
|
124
|
-
retryable: false
|
|
125
|
-
};
|
|
126
|
-
case "REFUND_FAILED":
|
|
127
|
-
return {
|
|
128
|
-
message: serverMessage ?? "The recovery couldn't be completed. Please try again or contact support.",
|
|
129
|
-
retryable: true
|
|
130
|
-
};
|
|
131
|
-
default:
|
|
132
|
-
if (status === 0) {
|
|
133
|
-
return {
|
|
134
|
-
message: "Couldn't reach the recovery service. Check your connection and try again.",
|
|
135
|
-
retryable: true
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
message: serverMessage ?? "The recovery couldn't be completed. Please try again or contact support.",
|
|
140
|
-
retryable: true
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async function submitSignedRecovery(params) {
|
|
145
|
-
const { backendUrl, depositId, signer, destination, signRecovery, debug } = params;
|
|
146
|
-
const scope = "service:recovery";
|
|
147
|
-
const typedData = {
|
|
148
|
-
domain: RECOVER_DOMAIN,
|
|
149
|
-
types: RECOVER_TYPES,
|
|
150
|
-
primaryType: "RecoverDeposit",
|
|
151
|
-
message: { depositId: BigInt(depositId), destination }
|
|
152
|
-
};
|
|
153
|
-
let signature;
|
|
154
|
-
try {
|
|
155
|
-
signature = await signRecovery({ typedData, signer, depositId, destination });
|
|
156
|
-
} catch (error) {
|
|
157
|
-
debugError(debug, scope, "signRecovery:failed", error);
|
|
158
|
-
throw new RecoveryError(
|
|
159
|
-
"Signature request was declined. Approve it in your wallet to recover this deposit.",
|
|
160
|
-
0,
|
|
161
|
-
void 0,
|
|
162
|
-
true
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
if (!signature) {
|
|
166
|
-
throw new RecoveryError(
|
|
167
|
-
"Signature request was declined. Approve it in your wallet to recover this deposit.",
|
|
168
|
-
0,
|
|
169
|
-
void 0,
|
|
170
|
-
true
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
const url = `${backendUrl.replace(/\/$/, "")}/deposits/recover`;
|
|
174
|
-
debugLog(debug, scope, "submitSignedRecovery:request", {
|
|
175
|
-
url,
|
|
176
|
-
depositId,
|
|
177
|
-
signer
|
|
178
|
-
});
|
|
179
|
-
let response;
|
|
180
|
-
try {
|
|
181
|
-
response = await fetch(url, {
|
|
182
|
-
method: "POST",
|
|
183
|
-
// The shared const, so recovery carries `x-deposit-modal-version` like
|
|
184
|
-
// every other backend call. Without it this path would be invisible in the
|
|
185
|
-
// per-client version telemetry the processor records.
|
|
186
|
-
headers: SERVICE_HEADERS,
|
|
187
|
-
// `depositId` as a string: it is a uint256 upstream and JSON numbers lose
|
|
188
|
-
// precision well before that range.
|
|
189
|
-
body: JSON.stringify({ depositId, destination, signature })
|
|
190
|
-
});
|
|
191
|
-
} catch (error) {
|
|
192
|
-
debugError(debug, scope, "submitSignedRecovery:network", error);
|
|
193
|
-
const { message, retryable } = formatRecoveryError(0);
|
|
194
|
-
throw new RecoveryError(message, 0, void 0, retryable);
|
|
195
|
-
}
|
|
196
|
-
if (!response.ok) {
|
|
197
|
-
const body = await response.json().catch(() => ({}));
|
|
198
|
-
debugError(debug, scope, "submitSignedRecovery:failed", body, {
|
|
199
|
-
status: response.status
|
|
200
|
-
});
|
|
201
|
-
const { message, retryable } = formatRecoveryError(
|
|
202
|
-
response.status,
|
|
203
|
-
body.code,
|
|
204
|
-
body.error
|
|
205
|
-
);
|
|
206
|
-
throw new RecoveryError(message, response.status, body.code, retryable);
|
|
207
|
-
}
|
|
208
|
-
const result = await response.json();
|
|
209
|
-
debugLog(debug, scope, "submitSignedRecovery:success", {
|
|
210
|
-
transactionHash: result.transactionHash
|
|
211
|
-
});
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
78
|
// src/ClaimModal.tsx
|
|
216
79
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
217
80
|
function evmChainIdFromCaip2(chain) {
|
|
@@ -323,7 +186,8 @@ function ClaimModal({
|
|
|
323
186
|
onLifecycle,
|
|
324
187
|
onEvent,
|
|
325
188
|
onError,
|
|
326
|
-
debug
|
|
189
|
+
debug,
|
|
190
|
+
onUiState
|
|
327
191
|
}) {
|
|
328
192
|
checkBackendUrl("ClaimModal", backendUrl);
|
|
329
193
|
const modalRef = useRef(null);
|
|
@@ -341,7 +205,8 @@ function ClaimModal({
|
|
|
341
205
|
const isOpenRef = useRef(isOpen);
|
|
342
206
|
isOpenRef.current = isOpen;
|
|
343
207
|
useEffect(() => {
|
|
344
|
-
if (isOpen
|
|
208
|
+
if (!isOpen || !modalRef.current) return;
|
|
209
|
+
return applyTheme(modalRef.current, theme);
|
|
345
210
|
}, [isOpen, theme]);
|
|
346
211
|
useEffect(() => {
|
|
347
212
|
if (isOpen) {
|
|
@@ -362,6 +227,14 @@ function ClaimModal({
|
|
|
362
227
|
}
|
|
363
228
|
}, [state.step, onClose]);
|
|
364
229
|
const canGoBack = state.step === "select" || state.step === "review" || state.step === "failed";
|
|
230
|
+
const onUiStateRef = useLatestRef(onUiState);
|
|
231
|
+
useEffect(() => {
|
|
232
|
+
onUiStateRef.current?.({
|
|
233
|
+
screen: state.step,
|
|
234
|
+
back: canGoBack ? () => dispatch({ type: "back" }) : void 0,
|
|
235
|
+
submitting: state.step === "processing"
|
|
236
|
+
});
|
|
237
|
+
}, [state.step, canGoBack, onUiStateRef]);
|
|
365
238
|
const showBackButton = uiConfig?.showBackButton ?? true;
|
|
366
239
|
return /* @__PURE__ */ jsx2(RpcUrlsProvider, { value: rpcUrls, children: /* @__PURE__ */ jsx2(ChainCatalogProvider, { service, rpcUrls, children: /* @__PURE__ */ jsx2(
|
|
367
240
|
Modal,
|
|
@@ -516,6 +389,7 @@ function ClaimBody({
|
|
|
516
389
|
try {
|
|
517
390
|
const result = await submitSignedRecovery({
|
|
518
391
|
backendUrl,
|
|
392
|
+
chainId: sourceChainId,
|
|
519
393
|
depositId: deposit.id,
|
|
520
394
|
signer,
|
|
521
395
|
destination,
|