@rhinestone/deposit-modal 0.3.0-alpha.1 → 0.3.0-alpha.3
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/dist/{DepositModalReown-EESTTLN4.mjs → DepositModalReown-6QBOLFNL.mjs} +2 -2
- package/dist/{DepositModalReown-VV3H2WWC.cjs → DepositModalReown-DVRWDPYV.cjs} +3 -3
- package/dist/{WithdrawModalReown-IP4MOGER.cjs → WithdrawModalReown-KGFCNAJP.cjs} +3 -3
- package/dist/{WithdrawModalReown-SQQQV6KQ.mjs → WithdrawModalReown-UO7XCJ7K.mjs} +2 -2
- package/dist/{chunk-D5YCALVX.mjs → chunk-GE3TMZEL.mjs} +17 -291
- package/dist/{chunk-C6JK3IO6.cjs → chunk-IATY2C5R.cjs} +1759 -824
- package/dist/{chunk-SLLI7SB6.mjs → chunk-QLTTDVFU.mjs} +1967 -1032
- package/dist/{chunk-FY76DWPD.mjs → chunk-TFXIQ7YH.mjs} +551 -196
- package/dist/{chunk-K7MNFNR7.cjs → chunk-UEYFJM5Y.cjs} +69 -343
- package/dist/{chunk-DCAANLEP.cjs → chunk-V6NJIPSS.cjs} +514 -159
- package/dist/deposit.cjs +3 -3
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/styles.css +13 -1
- package/dist/{types-DRou84ZM.d.cts → types-xSHZSlrT.d.cts} +16 -1
- package/dist/{types-DRou84ZM.d.ts → types-xSHZSlrT.d.ts} +16 -1
- package/dist/withdraw.cjs +3 -3
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +2 -2
- package/package.json +1 -1
|
@@ -12,13 +12,16 @@ import {
|
|
|
12
12
|
ConnectStep,
|
|
13
13
|
CopyIcon,
|
|
14
14
|
ExternalLinkIcon,
|
|
15
|
+
HandCoinsIcon,
|
|
15
16
|
HistoryIcon,
|
|
16
17
|
InfoIcon,
|
|
18
|
+
ListRow,
|
|
17
19
|
Modal,
|
|
18
20
|
PercentIcon,
|
|
19
21
|
PlusCircleIcon,
|
|
20
22
|
PoweredBy,
|
|
21
23
|
ProcessingStep,
|
|
24
|
+
SAFE_ABI,
|
|
22
25
|
Spinner,
|
|
23
26
|
Tooltip,
|
|
24
27
|
WalletIcon,
|
|
@@ -45,7 +48,7 @@ import {
|
|
|
45
48
|
tokenFormatter,
|
|
46
49
|
txRefsMatch,
|
|
47
50
|
useLatestRef
|
|
48
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-TFXIQ7YH.mjs";
|
|
49
52
|
import {
|
|
50
53
|
DEFAULT_BACKEND_URL,
|
|
51
54
|
DEFAULT_SIGNER_ADDRESS,
|
|
@@ -69,210 +72,22 @@ import {
|
|
|
69
72
|
// src/DepositModal.tsx
|
|
70
73
|
import {
|
|
71
74
|
useMemo as useMemo7,
|
|
72
|
-
useEffect as
|
|
73
|
-
useRef as
|
|
74
|
-
useState as
|
|
75
|
-
useCallback as
|
|
75
|
+
useEffect as useEffect9,
|
|
76
|
+
useRef as useRef6,
|
|
77
|
+
useState as useState11,
|
|
78
|
+
useCallback as useCallback5,
|
|
76
79
|
lazy as lazy2,
|
|
77
80
|
Suspense as Suspense2
|
|
78
81
|
} from "react";
|
|
79
82
|
|
|
80
83
|
// src/DepositFlow.tsx
|
|
81
|
-
import { useState as
|
|
82
|
-
import { formatUnits as
|
|
83
|
-
|
|
84
|
-
// src/components/steps/SetupStep.tsx
|
|
85
|
-
import { useState, useEffect, useRef, useCallback } from "react";
|
|
86
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
87
|
-
async function resolveSessionOwner(eoaAddress) {
|
|
88
|
-
const localOwner = loadSessionOwnerFromStorage(eoaAddress);
|
|
89
|
-
if (localOwner) {
|
|
90
|
-
return {
|
|
91
|
-
account: accountFromPrivateKey(localOwner.privateKey),
|
|
92
|
-
address: localOwner.address
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const created = createSessionOwnerKey();
|
|
96
|
-
saveSessionOwnerToStorage(eoaAddress, created.privateKey, created.address);
|
|
97
|
-
return {
|
|
98
|
-
account: created.account,
|
|
99
|
-
address: created.address
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function SetupStep({
|
|
103
|
-
walletClient,
|
|
104
|
-
address,
|
|
105
|
-
targetChain,
|
|
106
|
-
targetToken,
|
|
107
|
-
signerAddress,
|
|
108
|
-
sessionChainIds,
|
|
109
|
-
recipient,
|
|
110
|
-
postBridgeActions,
|
|
111
|
-
outputTokenRules,
|
|
112
|
-
rejectUnmapped,
|
|
113
|
-
forceRegister,
|
|
114
|
-
enableSolana = true,
|
|
115
|
-
service,
|
|
116
|
-
onSetupComplete,
|
|
117
|
-
onError,
|
|
118
|
-
onConnected
|
|
119
|
-
}) {
|
|
120
|
-
const [state, setState] = useState({ type: "idle" });
|
|
121
|
-
const setupInitiatedRef = useRef(false);
|
|
122
|
-
const runSetup = useCallback(async () => {
|
|
123
|
-
if (!address) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (walletClient && !walletClient.account) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
setState({ type: "creating-account" });
|
|
131
|
-
const sessionOwner = await resolveSessionOwner(address);
|
|
132
|
-
const setup = await service.setupAccount({
|
|
133
|
-
ownerAddress: address,
|
|
134
|
-
sessionOwnerAddress: sessionOwner.address,
|
|
135
|
-
targetChain: toEvmCaip2(targetChain),
|
|
136
|
-
targetToken,
|
|
137
|
-
recipient,
|
|
138
|
-
postBridgeActions,
|
|
139
|
-
outputTokenRules,
|
|
140
|
-
rejectUnmapped,
|
|
141
|
-
signerAddress,
|
|
142
|
-
sessionChainIds,
|
|
143
|
-
forceRegister
|
|
144
|
-
});
|
|
145
|
-
const smartAccount = setup.smartAccount;
|
|
146
|
-
if (!setup.needsRegistration) {
|
|
147
|
-
setState({ type: "ready", smartAccount });
|
|
148
|
-
onConnected?.(address, smartAccount);
|
|
149
|
-
onSetupComplete(
|
|
150
|
-
smartAccount,
|
|
151
|
-
enableSolana ? setup.solanaDepositAddress : void 0
|
|
152
|
-
);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
setState({ type: "signing-session" });
|
|
156
|
-
if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
|
|
157
|
-
throw new Error("Missing registration payload from setup-account");
|
|
158
|
-
}
|
|
159
|
-
if (!sessionOwner.account.signTypedData) {
|
|
160
|
-
throw new Error("Session owner account does not support signTypedData");
|
|
161
|
-
}
|
|
162
|
-
const typedData = setup.sessionDetailsUnsigned.data;
|
|
163
|
-
const signature = await sessionOwner.account.signTypedData({
|
|
164
|
-
domain: typedData.domain,
|
|
165
|
-
types: typedData.types,
|
|
166
|
-
primaryType: typedData.primaryType,
|
|
167
|
-
message: typedData.message
|
|
168
|
-
});
|
|
169
|
-
const sessionDetails = buildSessionDetails(setup.sessionDetailsUnsigned, signature);
|
|
170
|
-
setState({ type: "registering" });
|
|
171
|
-
const registerResult = await service.registerAccount({
|
|
172
|
-
address: smartAccount,
|
|
173
|
-
accountParams: {
|
|
174
|
-
factory: setup.accountParams.factory,
|
|
175
|
-
factoryData: setup.accountParams.factoryData,
|
|
176
|
-
sessionDetails
|
|
177
|
-
},
|
|
178
|
-
eoaAddress: address,
|
|
179
|
-
sessionOwner: sessionOwner.address,
|
|
180
|
-
target: {
|
|
181
|
-
chain: toEvmCaip2(targetChain),
|
|
182
|
-
token: targetToken,
|
|
183
|
-
...recipient && { recipient },
|
|
184
|
-
...postBridgeActions?.length && { postBridgeActions },
|
|
185
|
-
...outputTokenRules?.length && { outputTokenRules },
|
|
186
|
-
...rejectUnmapped != null && { rejectUnmapped }
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
setState({ type: "ready", smartAccount });
|
|
190
|
-
onConnected?.(address, smartAccount);
|
|
191
|
-
onSetupComplete(
|
|
192
|
-
smartAccount,
|
|
193
|
-
enableSolana ? registerResult.solanaDepositAddress : void 0
|
|
194
|
-
);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
const message = error instanceof Error ? error.message : "Setup failed";
|
|
197
|
-
setState({ type: "error", message });
|
|
198
|
-
onError?.(message, "SETUP_ERROR");
|
|
199
|
-
}
|
|
200
|
-
}, [
|
|
201
|
-
address,
|
|
202
|
-
walletClient,
|
|
203
|
-
targetChain,
|
|
204
|
-
targetToken,
|
|
205
|
-
signerAddress,
|
|
206
|
-
sessionChainIds,
|
|
207
|
-
recipient,
|
|
208
|
-
postBridgeActions,
|
|
209
|
-
outputTokenRules,
|
|
210
|
-
rejectUnmapped,
|
|
211
|
-
forceRegister,
|
|
212
|
-
enableSolana,
|
|
213
|
-
service,
|
|
214
|
-
onSetupComplete,
|
|
215
|
-
onError,
|
|
216
|
-
onConnected
|
|
217
|
-
]);
|
|
218
|
-
useEffect(() => {
|
|
219
|
-
const hasWallet = walletClient ? Boolean(walletClient.account) : true;
|
|
220
|
-
if (address && hasWallet && !setupInitiatedRef.current && state.type === "idle") {
|
|
221
|
-
setupInitiatedRef.current = true;
|
|
222
|
-
runSetup();
|
|
223
|
-
}
|
|
224
|
-
}, [address, walletClient, state.type, runSetup]);
|
|
225
|
-
const handleRetry = () => {
|
|
226
|
-
setupInitiatedRef.current = false;
|
|
227
|
-
setState({ type: "idle" });
|
|
228
|
-
};
|
|
229
|
-
const renderStateMessage = () => {
|
|
230
|
-
switch (state.type) {
|
|
231
|
-
case "idle":
|
|
232
|
-
return "Preparing...";
|
|
233
|
-
case "creating-account":
|
|
234
|
-
return "Preparing your deposit account...";
|
|
235
|
-
case "signing-session":
|
|
236
|
-
return "Authorizing your deposit session...";
|
|
237
|
-
case "registering":
|
|
238
|
-
return "Finalizing setup...";
|
|
239
|
-
case "ready":
|
|
240
|
-
return "Account ready!";
|
|
241
|
-
case "error":
|
|
242
|
-
return state.message;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const isLoading = state.type === "idle" || state.type === "creating-account" || state.type === "signing-session" || state.type === "registering";
|
|
246
|
-
const isError = state.type === "error";
|
|
247
|
-
return /* @__PURE__ */ jsxs("div", { className: "rs-step", children: [
|
|
248
|
-
/* @__PURE__ */ jsxs("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
249
|
-
isLoading && /* @__PURE__ */ jsx(
|
|
250
|
-
BodyHeader,
|
|
251
|
-
{
|
|
252
|
-
icon: /* @__PURE__ */ jsx(Spinner, { className: "rs-spinner--sm" }),
|
|
253
|
-
title: renderStateMessage(),
|
|
254
|
-
subtitle: "This may take a moment"
|
|
255
|
-
}
|
|
256
|
-
),
|
|
257
|
-
isError && /* @__PURE__ */ jsx(
|
|
258
|
-
BodyHeader,
|
|
259
|
-
{
|
|
260
|
-
variant: "error",
|
|
261
|
-
icon: /* @__PURE__ */ jsx(AlertTriangleIcon, {}),
|
|
262
|
-
title: "Setup failed",
|
|
263
|
-
subtitle: state.message
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
] }),
|
|
267
|
-
isError && /* @__PURE__ */ jsx("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx(Button, { onClick: handleRetry, variant: "default", fullWidth: true, children: "Try Again" }) }),
|
|
268
|
-
/* @__PURE__ */ jsx(PoweredBy, {})
|
|
269
|
-
] });
|
|
270
|
-
}
|
|
84
|
+
import { useState as useState9, useCallback as useCallback3, useMemo as useMemo6, useEffect as useEffect8, useRef as useRef5 } from "react";
|
|
85
|
+
import { formatUnits as formatUnits7 } from "viem";
|
|
271
86
|
|
|
272
87
|
// src/components/steps/AssetSelectStep.tsx
|
|
273
|
-
import { useEffect
|
|
88
|
+
import { useEffect, useMemo, useState } from "react";
|
|
274
89
|
import { formatUnits } from "viem";
|
|
275
|
-
import { jsx
|
|
90
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
276
91
|
function AssetSelectStep({
|
|
277
92
|
address,
|
|
278
93
|
publicClient,
|
|
@@ -285,10 +100,10 @@ function AssetSelectStep({
|
|
|
285
100
|
onAssetsLoaded,
|
|
286
101
|
onDisconnect
|
|
287
102
|
}) {
|
|
288
|
-
const [assets, setAssets] =
|
|
289
|
-
const [selectedAssetId, setSelectedAssetId] =
|
|
290
|
-
const [loading, setLoading] =
|
|
291
|
-
const [error, setError] =
|
|
103
|
+
const [assets, setAssets] = useState([]);
|
|
104
|
+
const [selectedAssetId, setSelectedAssetId] = useState(null);
|
|
105
|
+
const [loading, setLoading] = useState(true);
|
|
106
|
+
const [error, setError] = useState(null);
|
|
292
107
|
const defaultAssetId = useMemo(() => {
|
|
293
108
|
if (!defaultSourceChain || !defaultSourceToken) return null;
|
|
294
109
|
return getAssetId({
|
|
@@ -296,7 +111,7 @@ function AssetSelectStep({
|
|
|
296
111
|
token: defaultSourceToken
|
|
297
112
|
});
|
|
298
113
|
}, [defaultSourceChain, defaultSourceToken]);
|
|
299
|
-
|
|
114
|
+
useEffect(() => {
|
|
300
115
|
let active = true;
|
|
301
116
|
async function loadPortfolio() {
|
|
302
117
|
if (!address) {
|
|
@@ -338,13 +153,13 @@ function AssetSelectStep({
|
|
|
338
153
|
active = false;
|
|
339
154
|
};
|
|
340
155
|
}, [address, publicClient, service]);
|
|
341
|
-
|
|
156
|
+
useEffect(() => {
|
|
342
157
|
if (!defaultAssetId || selectedAssetId) return;
|
|
343
158
|
if (assets.some((asset) => asset.id === defaultAssetId)) {
|
|
344
159
|
setSelectedAssetId(defaultAssetId);
|
|
345
160
|
}
|
|
346
161
|
}, [assets, defaultAssetId, selectedAssetId]);
|
|
347
|
-
|
|
162
|
+
useEffect(() => {
|
|
348
163
|
const total = assets.reduce(
|
|
349
164
|
(sum, asset) => sum + (asset.balanceUsd ?? 0),
|
|
350
165
|
0
|
|
@@ -394,30 +209,30 @@ function AssetSelectStep({
|
|
|
394
209
|
return asset.balance;
|
|
395
210
|
}
|
|
396
211
|
};
|
|
397
|
-
return /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ jsxs("div", { className: "rs-screen", children: [
|
|
213
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-screen-body", children: [
|
|
214
|
+
/* @__PURE__ */ jsx(
|
|
400
215
|
BodyHeader,
|
|
401
216
|
{
|
|
402
|
-
icon: /* @__PURE__ */
|
|
217
|
+
icon: /* @__PURE__ */ jsx(WalletIcon, {}),
|
|
403
218
|
title: "Your assets",
|
|
404
219
|
subtitle: "Select source assets to transfer"
|
|
405
220
|
}
|
|
406
221
|
),
|
|
407
|
-
loading && /* @__PURE__ */
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */
|
|
222
|
+
loading && /* @__PURE__ */ jsxs("div", { className: "rs-loading-state", style: { padding: "40px 12px" }, children: [
|
|
223
|
+
/* @__PURE__ */ jsx(Spinner, { className: "rs-text-tertiary" }),
|
|
224
|
+
/* @__PURE__ */ jsx("span", { className: "rs-text-sm rs-text-tertiary", children: "Loading balances" })
|
|
410
225
|
] }),
|
|
411
|
-
error && /* @__PURE__ */
|
|
412
|
-
!loading && !error && rows.length === 0 && /* @__PURE__ */
|
|
413
|
-
/* @__PURE__ */
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
/* @__PURE__ */
|
|
226
|
+
error && /* @__PURE__ */ jsx("div", { className: "rs-alert rs-alert--error", children: /* @__PURE__ */ jsx("span", { className: "rs-alert-text", children: error }) }),
|
|
227
|
+
!loading && !error && rows.length === 0 && /* @__PURE__ */ jsxs("div", { className: "rs-empty-state", children: [
|
|
228
|
+
/* @__PURE__ */ jsx(WalletIcon, { className: "rs-empty-icon" }),
|
|
229
|
+
/* @__PURE__ */ jsx("div", { className: "rs-empty-text", children: "No funds in connected wallet" }),
|
|
230
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-empty-address", children: [
|
|
416
231
|
address.slice(0, 6),
|
|
417
232
|
"...",
|
|
418
233
|
address.slice(-4)
|
|
419
234
|
] }),
|
|
420
|
-
onDisconnect && /* @__PURE__ */
|
|
235
|
+
onDisconnect && /* @__PURE__ */ jsx(
|
|
421
236
|
"button",
|
|
422
237
|
{
|
|
423
238
|
type: "button",
|
|
@@ -427,13 +242,13 @@ function AssetSelectStep({
|
|
|
427
242
|
}
|
|
428
243
|
)
|
|
429
244
|
] }),
|
|
430
|
-
!loading && !error && rows.length > 0 && /* @__PURE__ */
|
|
245
|
+
!loading && !error && rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "rs-asset-list", children: rows.map((asset) => {
|
|
431
246
|
const isSelected = selectedAssetId === asset.id;
|
|
432
247
|
const tokenAmount = formatBalance(asset);
|
|
433
248
|
const badge = getChainBadge(asset.chainId);
|
|
434
249
|
const tokenIcon = getTokenIcon(asset.symbol);
|
|
435
250
|
const chainIcon = getChainIcon(asset.chainId);
|
|
436
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ jsxs(
|
|
437
252
|
"button",
|
|
438
253
|
{
|
|
439
254
|
type: "button",
|
|
@@ -441,16 +256,16 @@ function AssetSelectStep({
|
|
|
441
256
|
className: `rs-asset-row ${isSelected ? "rs-asset-row--selected" : ""}`,
|
|
442
257
|
"aria-pressed": isSelected,
|
|
443
258
|
children: [
|
|
444
|
-
/* @__PURE__ */
|
|
445
|
-
/* @__PURE__ */
|
|
446
|
-
tokenIcon ? /* @__PURE__ */
|
|
447
|
-
chainIcon ? /* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-asset-info", children: [
|
|
260
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-asset-icon-wrapper", children: [
|
|
261
|
+
tokenIcon ? /* @__PURE__ */ jsx("span", { className: "rs-asset-icon", children: /* @__PURE__ */ jsx("img", { src: tokenIcon, alt: asset.symbol }) }) : /* @__PURE__ */ jsx("span", { className: "rs-asset-icon", children: asset.symbol.slice(0, 4) }),
|
|
262
|
+
chainIcon ? /* @__PURE__ */ jsx("span", { className: "rs-asset-chain-badge", children: /* @__PURE__ */ jsx(
|
|
448
263
|
"img",
|
|
449
264
|
{
|
|
450
265
|
src: chainIcon,
|
|
451
266
|
alt: getChainName(asset.chainId)
|
|
452
267
|
}
|
|
453
|
-
) }) : /* @__PURE__ */
|
|
268
|
+
) }) : /* @__PURE__ */ jsx(
|
|
454
269
|
"span",
|
|
455
270
|
{
|
|
456
271
|
className: "rs-asset-chain-badge",
|
|
@@ -462,28 +277,28 @@ function AssetSelectStep({
|
|
|
462
277
|
}
|
|
463
278
|
)
|
|
464
279
|
] }),
|
|
465
|
-
/* @__PURE__ */
|
|
466
|
-
/* @__PURE__ */
|
|
467
|
-
/* @__PURE__ */
|
|
468
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-asset-text", children: [
|
|
281
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-asset-name-row", children: [
|
|
282
|
+
/* @__PURE__ */ jsx("span", { className: "rs-asset-name", children: asset.symbol }),
|
|
283
|
+
/* @__PURE__ */ jsxs("span", { className: "rs-asset-chain", children: [
|
|
469
284
|
"on ",
|
|
470
285
|
getChainName(asset.chainId)
|
|
471
286
|
] })
|
|
472
287
|
] }),
|
|
473
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ jsxs("div", { className: "rs-asset-balance-small", children: [
|
|
474
289
|
tokenAmount,
|
|
475
290
|
" ",
|
|
476
291
|
asset.symbol
|
|
477
292
|
] })
|
|
478
293
|
] })
|
|
479
294
|
] }),
|
|
480
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ jsx("div", { className: "rs-asset-balance", children: asset.balanceUsd !== void 0 && asset.balanceUsd > 0 ? currencyFormatter.format(asset.balanceUsd) : tokenAmount !== "--" ? `${tokenAmount} ${asset.symbol}` : "--" })
|
|
481
296
|
]
|
|
482
297
|
},
|
|
483
298
|
asset.id
|
|
484
299
|
);
|
|
485
300
|
}) }),
|
|
486
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ jsx(
|
|
487
302
|
Button,
|
|
488
303
|
{
|
|
489
304
|
onClick: () => selectedAsset && onContinue(selectedAsset),
|
|
@@ -493,7 +308,7 @@ function AssetSelectStep({
|
|
|
493
308
|
}
|
|
494
309
|
)
|
|
495
310
|
] }),
|
|
496
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ jsx(PoweredBy, {})
|
|
497
312
|
] });
|
|
498
313
|
}
|
|
499
314
|
async function fetchNativeAssets(address, publicClient, existing) {
|
|
@@ -536,9 +351,9 @@ function mergeAssets(existing, incoming) {
|
|
|
536
351
|
}
|
|
537
352
|
|
|
538
353
|
// src/components/steps/AmountStep.tsx
|
|
539
|
-
import { useEffect as
|
|
354
|
+
import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
540
355
|
import { erc20Abi, formatUnits as formatUnits2, parseUnits } from "viem";
|
|
541
|
-
import { Fragment, jsx as
|
|
356
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
542
357
|
var PRESETS = [
|
|
543
358
|
{ value: 25, label: "25%" },
|
|
544
359
|
{ value: 50, label: "50%" },
|
|
@@ -559,6 +374,7 @@ function AmountStep({
|
|
|
559
374
|
address,
|
|
560
375
|
balanceAddress,
|
|
561
376
|
asset,
|
|
377
|
+
liquiditySource,
|
|
562
378
|
defaultAmount,
|
|
563
379
|
switchChain,
|
|
564
380
|
targetChain,
|
|
@@ -571,11 +387,11 @@ function AmountStep({
|
|
|
571
387
|
onCtaClick,
|
|
572
388
|
service
|
|
573
389
|
}) {
|
|
574
|
-
const [amount, setAmount] =
|
|
575
|
-
const [balance, setBalance] =
|
|
576
|
-
const [error, setError] =
|
|
577
|
-
const [isCheckingLiquidity, setIsCheckingLiquidity] =
|
|
578
|
-
const hasAttemptedSwitch =
|
|
390
|
+
const [amount, setAmount] = useState2("");
|
|
391
|
+
const [balance, setBalance] = useState2(null);
|
|
392
|
+
const [error, setError] = useState2(null);
|
|
393
|
+
const [isCheckingLiquidity, setIsCheckingLiquidity] = useState2(false);
|
|
394
|
+
const hasAttemptedSwitch = useRef(false);
|
|
579
395
|
const chainMismatch = Boolean(
|
|
580
396
|
walletClient?.chain?.id && walletClient.chain.id !== asset.chainId
|
|
581
397
|
);
|
|
@@ -598,7 +414,7 @@ function AmountStep({
|
|
|
598
414
|
}
|
|
599
415
|
}, [tokenPriceUsdOverride, asset.balanceUsd, asset.balance, asset.decimals]);
|
|
600
416
|
const hasPricing = tokenPriceUsd !== null;
|
|
601
|
-
|
|
417
|
+
useEffect2(() => {
|
|
602
418
|
let active = true;
|
|
603
419
|
async function fetchBalance() {
|
|
604
420
|
const balanceTarget = balanceAddress ?? address;
|
|
@@ -620,7 +436,7 @@ function AmountStep({
|
|
|
620
436
|
active = false;
|
|
621
437
|
};
|
|
622
438
|
}, [address, balanceAddress, publicClient, asset]);
|
|
623
|
-
|
|
439
|
+
useEffect2(() => {
|
|
624
440
|
if (chainMismatch && switchChain && !hasAttemptedSwitch.current) {
|
|
625
441
|
hasAttemptedSwitch.current = true;
|
|
626
442
|
switchChain(asset.chainId).catch((err) => {
|
|
@@ -629,10 +445,10 @@ function AmountStep({
|
|
|
629
445
|
});
|
|
630
446
|
}
|
|
631
447
|
}, [chainMismatch, switchChain, asset.chainId]);
|
|
632
|
-
|
|
448
|
+
useEffect2(() => {
|
|
633
449
|
hasAttemptedSwitch.current = false;
|
|
634
450
|
}, [asset.chainId]);
|
|
635
|
-
|
|
451
|
+
useEffect2(() => {
|
|
636
452
|
if (defaultAmount && !amount) {
|
|
637
453
|
const parsed = Number(defaultAmount);
|
|
638
454
|
if (Number.isFinite(parsed) && parsed > 0) {
|
|
@@ -650,7 +466,7 @@ function AmountStep({
|
|
|
650
466
|
return null;
|
|
651
467
|
}
|
|
652
468
|
}, [balance, tokenPriceUsd, asset.decimals]);
|
|
653
|
-
|
|
469
|
+
useEffect2(() => {
|
|
654
470
|
onBalanceUsdChange?.(balanceUsd ?? 0);
|
|
655
471
|
}, [balanceUsd, onBalanceUsdChange]);
|
|
656
472
|
const formattedBalance = useMemo2(() => {
|
|
@@ -740,8 +556,8 @@ function AmountStep({
|
|
|
740
556
|
let liquidityWarning;
|
|
741
557
|
try {
|
|
742
558
|
const liquidity = await service.checkLiquidity({
|
|
743
|
-
sourceChainId: asset.chainId,
|
|
744
|
-
sourceToken: asset.token,
|
|
559
|
+
sourceChainId: liquiditySource?.chainId ?? asset.chainId,
|
|
560
|
+
sourceToken: liquiditySource?.token ?? asset.token,
|
|
745
561
|
destinationChainId: targetChain,
|
|
746
562
|
destinationToken: targetToken,
|
|
747
563
|
amount: amountInUnits.toString()
|
|
@@ -776,14 +592,14 @@ function AmountStep({
|
|
|
776
592
|
const targetChainName = getChainName(targetChain);
|
|
777
593
|
const sourceTokenIcon = getTokenIcon(asset.symbol);
|
|
778
594
|
const targetTokenIcon = getTokenIcon(targetSymbol);
|
|
779
|
-
return /* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
783
|
-
/* @__PURE__ */
|
|
784
|
-
/* @__PURE__ */
|
|
785
|
-
/* @__PURE__ */
|
|
786
|
-
/* @__PURE__ */
|
|
595
|
+
return /* @__PURE__ */ jsxs2("div", { className: "rs-screen", children: [
|
|
596
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
597
|
+
/* @__PURE__ */ jsx2(BodyHeader, { icon: /* @__PURE__ */ jsx2(WalletIcon, {}), title: "Wallet deposit" }),
|
|
598
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-section", children: [
|
|
599
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-display", children: [
|
|
600
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-input-row", children: [
|
|
601
|
+
/* @__PURE__ */ jsx2("span", { "aria-hidden": "true", children: "$" }),
|
|
602
|
+
/* @__PURE__ */ jsx2(
|
|
787
603
|
"input",
|
|
788
604
|
{
|
|
789
605
|
type: "text",
|
|
@@ -796,25 +612,25 @@ function AmountStep({
|
|
|
796
612
|
}
|
|
797
613
|
)
|
|
798
614
|
] }),
|
|
799
|
-
/* @__PURE__ */
|
|
800
|
-
/* @__PURE__ */
|
|
615
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-meta", children: [
|
|
616
|
+
/* @__PURE__ */ jsxs2("span", { className: "rs-amount-meta-balance", children: [
|
|
801
617
|
formattedBalance,
|
|
802
618
|
" ",
|
|
803
619
|
asset.symbol,
|
|
804
620
|
" available",
|
|
805
|
-
balanceUsd !== null && /* @__PURE__ */
|
|
621
|
+
balanceUsd !== null && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
806
622
|
" (~",
|
|
807
623
|
currencyFormatter.format(balanceUsd),
|
|
808
624
|
")"
|
|
809
625
|
] })
|
|
810
626
|
] }),
|
|
811
|
-
minDepositUsd !== null && /* @__PURE__ */
|
|
627
|
+
minDepositUsd !== null && /* @__PURE__ */ jsxs2("span", { className: "rs-amount-meta-minimum", children: [
|
|
812
628
|
"Min. deposit ",
|
|
813
629
|
currencyFormatter.format(minDepositUsd)
|
|
814
630
|
] })
|
|
815
631
|
] })
|
|
816
632
|
] }),
|
|
817
|
-
/* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ jsx2("div", { className: "rs-amount-presets", children: PRESETS.map((preset) => /* @__PURE__ */ jsx2(
|
|
818
634
|
"button",
|
|
819
635
|
{
|
|
820
636
|
type: "button",
|
|
@@ -826,39 +642,39 @@ function AmountStep({
|
|
|
826
642
|
preset.value
|
|
827
643
|
)) })
|
|
828
644
|
] }),
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
832
|
-
/* @__PURE__ */
|
|
833
|
-
/* @__PURE__ */
|
|
645
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-details", children: [
|
|
646
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
|
|
647
|
+
/* @__PURE__ */ jsx2("span", { children: "You send" }),
|
|
648
|
+
/* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
|
|
649
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
834
650
|
sourceChainName,
|
|
835
651
|
" ",
|
|
836
652
|
asset.symbol
|
|
837
653
|
] }),
|
|
838
|
-
sourceTokenIcon && /* @__PURE__ */
|
|
654
|
+
sourceTokenIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: sourceTokenIcon, alt: "" }) })
|
|
839
655
|
] })
|
|
840
656
|
] }),
|
|
841
|
-
/* @__PURE__ */
|
|
842
|
-
/* @__PURE__ */
|
|
843
|
-
/* @__PURE__ */
|
|
844
|
-
/* @__PURE__ */
|
|
657
|
+
/* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
|
|
658
|
+
/* @__PURE__ */ jsx2("span", { children: "Receive" }),
|
|
659
|
+
/* @__PURE__ */ jsxs2("span", { className: "rs-amount-detail-value", children: [
|
|
660
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
845
661
|
targetChainName,
|
|
846
662
|
" ",
|
|
847
663
|
targetSymbol
|
|
848
664
|
] }),
|
|
849
|
-
targetTokenIcon && /* @__PURE__ */
|
|
665
|
+
targetTokenIcon && /* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx2("img", { src: targetTokenIcon, alt: "" }) })
|
|
850
666
|
] })
|
|
851
667
|
] }),
|
|
852
|
-
balanceAfterUsd !== null && /* @__PURE__ */
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
668
|
+
balanceAfterUsd !== null && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-detail-row", children: [
|
|
669
|
+
/* @__PURE__ */ jsx2("span", { children: "Balance after deposit" }),
|
|
670
|
+
/* @__PURE__ */ jsx2("span", { className: "rs-amount-detail-value", children: currencyFormatter.format(balanceAfterUsd) })
|
|
855
671
|
] })
|
|
856
672
|
] }),
|
|
857
|
-
error && /* @__PURE__ */
|
|
858
|
-
/* @__PURE__ */
|
|
859
|
-
/* @__PURE__ */
|
|
673
|
+
error && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-error", role: "alert", children: [
|
|
674
|
+
/* @__PURE__ */ jsx2(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
675
|
+
/* @__PURE__ */ jsx2("span", { children: error })
|
|
860
676
|
] }),
|
|
861
|
-
/* @__PURE__ */
|
|
677
|
+
/* @__PURE__ */ jsx2(
|
|
862
678
|
Button,
|
|
863
679
|
{
|
|
864
680
|
onClick: handleContinue,
|
|
@@ -868,14 +684,21 @@ function AmountStep({
|
|
|
868
684
|
}
|
|
869
685
|
)
|
|
870
686
|
] }),
|
|
871
|
-
/* @__PURE__ */
|
|
687
|
+
/* @__PURE__ */ jsx2(PoweredBy, {})
|
|
872
688
|
] });
|
|
873
689
|
}
|
|
874
690
|
|
|
875
691
|
// src/components/steps/ConfirmStep.tsx
|
|
876
|
-
import { useEffect as
|
|
692
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
877
693
|
import { erc20Abi as erc20Abi2, parseUnits as parseUnits2 } from "viem";
|
|
878
|
-
|
|
694
|
+
|
|
695
|
+
// src/core/dapp-imports/types.ts
|
|
696
|
+
function isDappImportAsset(asset) {
|
|
697
|
+
return typeof asset.source === "string" && typeof asset.sourceLabel === "string" && "providerMetadata" in asset;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/components/steps/ConfirmStep.tsx
|
|
701
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
879
702
|
function ConfirmStep({
|
|
880
703
|
walletClient,
|
|
881
704
|
address,
|
|
@@ -896,11 +719,12 @@ function ConfirmStep({
|
|
|
896
719
|
quotedFeeSymbol,
|
|
897
720
|
onConfirm,
|
|
898
721
|
onError,
|
|
899
|
-
onDepositSubmitted
|
|
722
|
+
onDepositSubmitted,
|
|
723
|
+
executeTransfer
|
|
900
724
|
}) {
|
|
901
|
-
const [isSubmitting, setIsSubmitting] =
|
|
902
|
-
const [error, setError] =
|
|
903
|
-
const hasAttemptedSwitch =
|
|
725
|
+
const [isSubmitting, setIsSubmitting] = useState3(false);
|
|
726
|
+
const [error, setError] = useState3(null);
|
|
727
|
+
const hasAttemptedSwitch = useRef2(false);
|
|
904
728
|
const chainMismatch = Boolean(
|
|
905
729
|
walletClient?.chain?.id && walletClient.chain.id !== asset.chainId
|
|
906
730
|
);
|
|
@@ -925,10 +749,9 @@ function ConfirmStep({
|
|
|
925
749
|
return formattedSendAmount;
|
|
926
750
|
})();
|
|
927
751
|
const receiveAmount = sameRoute ? formattedReceiveAmount : `~${formattedReceiveAmount}`;
|
|
928
|
-
const feeSymbol = quotedFeeSymbol ?? asset.symbol;
|
|
929
752
|
const feeSponsored = uiConfig?.feeSponsored ?? false;
|
|
930
753
|
const feeTooltip = uiConfig?.feeTooltip ?? (feeSponsored ? "Network fees are sponsored for this deposit." : "Network fees apply.");
|
|
931
|
-
|
|
754
|
+
useEffect3(() => {
|
|
932
755
|
if (chainMismatch && switchChain && !hasAttemptedSwitch.current) {
|
|
933
756
|
hasAttemptedSwitch.current = true;
|
|
934
757
|
switchChain(asset.chainId).catch((err) => {
|
|
@@ -937,7 +760,7 @@ function ConfirmStep({
|
|
|
937
760
|
});
|
|
938
761
|
}
|
|
939
762
|
}, [chainMismatch, switchChain, asset.chainId]);
|
|
940
|
-
|
|
763
|
+
useEffect3(() => {
|
|
941
764
|
hasAttemptedSwitch.current = false;
|
|
942
765
|
}, [asset.chainId]);
|
|
943
766
|
const handleConfirm = async () => {
|
|
@@ -974,21 +797,31 @@ function ConfirmStep({
|
|
|
974
797
|
throw new Error("Wallet not properly connected");
|
|
975
798
|
}
|
|
976
799
|
const transferTo = sameRoute ? recipient : smartAccount;
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
800
|
+
let hash;
|
|
801
|
+
let resolvedSourceToken = asset.token;
|
|
802
|
+
if (executeTransfer) {
|
|
803
|
+
const result = await executeTransfer(amountUnits);
|
|
804
|
+
hash = result.txHash;
|
|
805
|
+
resolvedSourceToken = result.sourceToken;
|
|
806
|
+
} else if (isNativeAsset(asset)) {
|
|
807
|
+
hash = await walletClient.sendTransaction({
|
|
808
|
+
account,
|
|
809
|
+
chain,
|
|
810
|
+
to: transferTo,
|
|
811
|
+
value: amountUnits
|
|
812
|
+
});
|
|
813
|
+
} else {
|
|
814
|
+
hash = await walletClient.writeContract({
|
|
815
|
+
account,
|
|
816
|
+
chain,
|
|
817
|
+
address: asset.token,
|
|
818
|
+
abi: erc20Abi2,
|
|
819
|
+
functionName: "transfer",
|
|
820
|
+
args: [transferTo, amountUnits]
|
|
821
|
+
});
|
|
822
|
+
}
|
|
990
823
|
onDepositSubmitted?.(hash, asset.chainId, amountUnits.toString());
|
|
991
|
-
onConfirm(hash, asset.chainId, amountUnits.toString(),
|
|
824
|
+
onConfirm(hash, asset.chainId, amountUnits.toString(), resolvedSourceToken);
|
|
992
825
|
} catch (err) {
|
|
993
826
|
const raw = err instanceof Error ? err.message : "Transfer failed";
|
|
994
827
|
const message = formatUserError(raw);
|
|
@@ -998,77 +831,83 @@ function ConfirmStep({
|
|
|
998
831
|
setIsSubmitting(false);
|
|
999
832
|
}
|
|
1000
833
|
};
|
|
1001
|
-
return /* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1007
|
-
/* @__PURE__ */
|
|
1008
|
-
/* @__PURE__ */
|
|
1009
|
-
sourceChainIcon && /* @__PURE__ */
|
|
834
|
+
return /* @__PURE__ */ jsxs3("div", { className: "rs-screen", children: [
|
|
835
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
836
|
+
/* @__PURE__ */ jsx3(BodyHeader, { icon: /* @__PURE__ */ jsx3(WalletIcon, {}), title: "Review deposit" }),
|
|
837
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-details", children: [
|
|
838
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
839
|
+
/* @__PURE__ */ jsx3("span", { children: "Source chain" }),
|
|
840
|
+
/* @__PURE__ */ jsxs3("span", { className: "rs-amount-detail-value", children: [
|
|
841
|
+
/* @__PURE__ */ jsx3("span", { children: sourceChainName }),
|
|
842
|
+
sourceChainIcon && /* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx3("img", { src: sourceChainIcon, alt: "" }) })
|
|
1010
843
|
] })
|
|
1011
844
|
] }),
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1015
|
-
/* @__PURE__ */
|
|
1016
|
-
targetChainIcon && /* @__PURE__ */
|
|
845
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
846
|
+
/* @__PURE__ */ jsx3("span", { children: "Destination chain" }),
|
|
847
|
+
/* @__PURE__ */ jsxs3("span", { className: "rs-amount-detail-value", children: [
|
|
848
|
+
/* @__PURE__ */ jsx3("span", { children: targetChainName }),
|
|
849
|
+
targetChainIcon && /* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx3("img", { src: targetChainIcon, alt: "" }) })
|
|
1017
850
|
] })
|
|
1018
851
|
] }),
|
|
1019
|
-
/* @__PURE__ */
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
853
|
+
/* @__PURE__ */ jsx3("span", { children: "Estimated time" }),
|
|
854
|
+
/* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-value", children: estimatedTime })
|
|
1022
855
|
] }),
|
|
1023
|
-
/* @__PURE__ */
|
|
1024
|
-
/* @__PURE__ */
|
|
1025
|
-
/* @__PURE__ */
|
|
1026
|
-
/* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
857
|
+
/* @__PURE__ */ jsx3("span", { children: "You send" }),
|
|
858
|
+
/* @__PURE__ */ jsxs3("span", { className: "rs-amount-detail-value", children: [
|
|
859
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1027
860
|
formattedSendAmount,
|
|
1028
861
|
" ",
|
|
1029
862
|
asset.symbol
|
|
1030
863
|
] }),
|
|
1031
|
-
sourceTokenIcon && /* @__PURE__ */
|
|
864
|
+
sourceTokenIcon && /* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx3("img", { src: sourceTokenIcon, alt: "" }) })
|
|
1032
865
|
] })
|
|
1033
866
|
] }),
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
/* @__PURE__ */
|
|
867
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
868
|
+
/* @__PURE__ */ jsx3("span", { children: "Receive" }),
|
|
869
|
+
/* @__PURE__ */ jsxs3("span", { className: "rs-amount-detail-value", children: [
|
|
870
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
1038
871
|
receiveAmount,
|
|
1039
872
|
" ",
|
|
1040
873
|
targetSymbol
|
|
1041
874
|
] }),
|
|
1042
|
-
targetTokenIcon && /* @__PURE__ */
|
|
875
|
+
targetTokenIcon && /* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx3("img", { src: targetTokenIcon, alt: "" }) })
|
|
1043
876
|
] })
|
|
1044
877
|
] }),
|
|
1045
|
-
/* @__PURE__ */
|
|
1046
|
-
/* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-detail-row", children: [
|
|
879
|
+
/* @__PURE__ */ jsx3("span", { children: "Fees" }),
|
|
880
|
+
/* @__PURE__ */ jsxs3("span", { className: "rs-amount-detail-value", children: [
|
|
881
|
+
/* @__PURE__ */ jsx3(
|
|
1049
882
|
"span",
|
|
1050
883
|
{
|
|
1051
884
|
style: feeSponsored ? { textDecoration: "line-through" } : void 0,
|
|
1052
|
-
children:
|
|
1053
|
-
quotedFeeAmount,
|
|
1054
|
-
" ",
|
|
1055
|
-
feeSymbol
|
|
1056
|
-
]
|
|
885
|
+
children: "$0.05"
|
|
1057
886
|
}
|
|
1058
887
|
),
|
|
1059
|
-
/* @__PURE__ */
|
|
888
|
+
/* @__PURE__ */ jsx3(Tooltip, { content: feeTooltip, children: /* @__PURE__ */ jsx3("span", { className: "rs-amount-detail-info", "aria-label": "Fee info", children: /* @__PURE__ */ jsx3(InfoIcon, {}) }) })
|
|
1060
889
|
] })
|
|
1061
890
|
] })
|
|
1062
891
|
] }),
|
|
1063
|
-
liquidityWarning && (liquidityWarning.kind === "unavailable" || liquidityWarning.kind === "check-failed") &&
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
/* @__PURE__ */
|
|
892
|
+
liquidityWarning && (liquidityWarning.kind === "unavailable" || liquidityWarning.kind === "check-failed") && (isDappImportAsset(asset) ? (
|
|
893
|
+
// Dapp-import sources route through an unwrap before the
|
|
894
|
+
// orchestrator sees funds; the upstream route check often
|
|
895
|
+
// returns "unavailable" for the source token even though the
|
|
896
|
+
// post-unwrap route works. Surface as a soft warning rather
|
|
897
|
+
// than a red blocker until the orchestrator handles it.
|
|
898
|
+
/* @__PURE__ */ jsxs3("div", { className: "rs-amount-error rs-amount-error--warning", role: "status", children: [
|
|
899
|
+
/* @__PURE__ */ jsx3(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
900
|
+
/* @__PURE__ */ jsx3("span", { children: "Low liquidity detected \u2014 deposit may take longer" })
|
|
901
|
+
] })
|
|
902
|
+
) : /* @__PURE__ */ jsxs3("div", { className: "rs-amount-error", role: "status", children: [
|
|
903
|
+
/* @__PURE__ */ jsx3(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
904
|
+
/* @__PURE__ */ jsx3("span", { children: liquidityWarning.kind === "unavailable" ? "Route may be unavailable" : "Liquidity check failed" })
|
|
905
|
+
] })),
|
|
906
|
+
error && /* @__PURE__ */ jsxs3("div", { className: "rs-amount-error", role: "alert", children: [
|
|
907
|
+
/* @__PURE__ */ jsx3(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
908
|
+
/* @__PURE__ */ jsx3("span", { children: error })
|
|
1070
909
|
] }),
|
|
1071
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsx3(
|
|
1072
911
|
Button,
|
|
1073
912
|
{
|
|
1074
913
|
onClick: handleConfirm,
|
|
@@ -1080,16 +919,16 @@ function ConfirmStep({
|
|
|
1080
919
|
}
|
|
1081
920
|
)
|
|
1082
921
|
] }),
|
|
1083
|
-
/* @__PURE__ */
|
|
922
|
+
/* @__PURE__ */ jsx3(PoweredBy, {})
|
|
1084
923
|
] });
|
|
1085
924
|
}
|
|
1086
925
|
|
|
1087
926
|
// src/components/steps/DepositAddressStep.tsx
|
|
1088
927
|
import {
|
|
1089
|
-
useState as
|
|
1090
|
-
useEffect as
|
|
1091
|
-
useCallback as
|
|
1092
|
-
useRef as
|
|
928
|
+
useState as useState5,
|
|
929
|
+
useEffect as useEffect5,
|
|
930
|
+
useCallback as useCallback2,
|
|
931
|
+
useRef as useRef4,
|
|
1093
932
|
useMemo as useMemo3,
|
|
1094
933
|
lazy,
|
|
1095
934
|
Suspense
|
|
@@ -1097,8 +936,8 @@ import {
|
|
|
1097
936
|
import { formatUnits as formatUnits3 } from "viem";
|
|
1098
937
|
|
|
1099
938
|
// src/components/ui/DepositNotification.tsx
|
|
1100
|
-
import { useState as
|
|
1101
|
-
import { jsx as
|
|
939
|
+
import { useState as useState4, useEffect as useEffect4, useRef as useRef3, useCallback } from "react";
|
|
940
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1102
941
|
var INITIAL_POLL_INTERVAL = 3e3;
|
|
1103
942
|
var MAX_POLL_INTERVAL = 3e4;
|
|
1104
943
|
var BACKOFF_MULTIPLIER = 1.5;
|
|
@@ -1155,7 +994,7 @@ function formatBridgeFailedMessage(event) {
|
|
|
1155
994
|
}
|
|
1156
995
|
return "Bridge failed";
|
|
1157
996
|
}
|
|
1158
|
-
var txLinkIcon = /* @__PURE__ */
|
|
997
|
+
var txLinkIcon = /* @__PURE__ */ jsx4(ExternalLinkIcon, { className: "rs-deposit-notification-link-icon" });
|
|
1159
998
|
function DepositNotification({
|
|
1160
999
|
deposit,
|
|
1161
1000
|
smartAccount,
|
|
@@ -1170,19 +1009,19 @@ function DepositNotification({
|
|
|
1170
1009
|
onDismiss
|
|
1171
1010
|
}) {
|
|
1172
1011
|
const { txHash, sourceChain, amount, token, detectedAt, directTransfer } = deposit;
|
|
1173
|
-
const [status, setStatus] =
|
|
1012
|
+
const [status, setStatus] = useState4(
|
|
1174
1013
|
directTransfer ? "complete" : "processing"
|
|
1175
1014
|
);
|
|
1176
|
-
const [expanded, setExpanded] =
|
|
1177
|
-
const [completedAt, setCompletedAt] =
|
|
1015
|
+
const [expanded, setExpanded] = useState4(false);
|
|
1016
|
+
const [completedAt, setCompletedAt] = useState4(
|
|
1178
1017
|
directTransfer ? detectedAt : null
|
|
1179
1018
|
);
|
|
1180
|
-
const [destinationTxHash, setDestinationTxHash] =
|
|
1019
|
+
const [destinationTxHash, setDestinationTxHash] = useState4(
|
|
1181
1020
|
null
|
|
1182
1021
|
);
|
|
1183
|
-
const pollIntervalRef =
|
|
1184
|
-
const pollTimeoutRef =
|
|
1185
|
-
const completedRef =
|
|
1022
|
+
const pollIntervalRef = useRef3(INITIAL_POLL_INTERVAL);
|
|
1023
|
+
const pollTimeoutRef = useRef3(null);
|
|
1024
|
+
const completedRef = useRef3(directTransfer ?? false);
|
|
1186
1025
|
const depositContextRef = useLatestRef({
|
|
1187
1026
|
amount,
|
|
1188
1027
|
sourceChain,
|
|
@@ -1194,7 +1033,7 @@ function DepositNotification({
|
|
|
1194
1033
|
});
|
|
1195
1034
|
const onCompleteRef = useLatestRef(onComplete);
|
|
1196
1035
|
const onFailedRef = useLatestRef(onFailed);
|
|
1197
|
-
const handleComplete =
|
|
1036
|
+
const handleComplete = useCallback(
|
|
1198
1037
|
(destTxHash) => {
|
|
1199
1038
|
if (completedRef.current) return;
|
|
1200
1039
|
completedRef.current = true;
|
|
@@ -1212,7 +1051,7 @@ function DepositNotification({
|
|
|
1212
1051
|
},
|
|
1213
1052
|
[depositContextRef, onCompleteRef, txHash]
|
|
1214
1053
|
);
|
|
1215
|
-
const handleFailed =
|
|
1054
|
+
const handleFailed = useCallback(
|
|
1216
1055
|
(error) => {
|
|
1217
1056
|
if (completedRef.current) return;
|
|
1218
1057
|
completedRef.current = true;
|
|
@@ -1221,7 +1060,7 @@ function DepositNotification({
|
|
|
1221
1060
|
},
|
|
1222
1061
|
[onFailedRef, txHash]
|
|
1223
1062
|
);
|
|
1224
|
-
|
|
1063
|
+
useEffect4(() => {
|
|
1225
1064
|
if (directTransfer) {
|
|
1226
1065
|
handleComplete(void 0);
|
|
1227
1066
|
return;
|
|
@@ -1301,33 +1140,33 @@ function DepositNotification({
|
|
|
1301
1140
|
const destExplorerUrl = destinationTxHash ? getExplorerTxUrl(targetChain, destinationTxHash) : null;
|
|
1302
1141
|
const title = status === "complete" ? "Deposit completed" : status === "failed" ? "Deposit failed" : "Deposit received and processing\u2026";
|
|
1303
1142
|
const subtitle = status === "complete" ? "Your deposit has been credited to your account." : status === "failed" ? "Your deposit could not be processed." : "Your deposit will be credited to your account shortly.";
|
|
1304
|
-
const statusIcon = status === "complete" ? /* @__PURE__ */
|
|
1305
|
-
return /* @__PURE__ */
|
|
1143
|
+
const statusIcon = status === "complete" ? /* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-badge rs-deposit-notification-badge--complete", children: /* @__PURE__ */ jsx4(CheckIcon, {}) }) : status === "failed" ? /* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-badge rs-deposit-notification-badge--failed", children: /* @__PURE__ */ jsx4(CloseIcon, {}) }) : /* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-badge rs-deposit-notification-badge--processing", children: /* @__PURE__ */ jsx4(Spinner, {}) });
|
|
1144
|
+
return /* @__PURE__ */ jsxs4(
|
|
1306
1145
|
"div",
|
|
1307
1146
|
{
|
|
1308
1147
|
className: `rs-deposit-notification rs-deposit-notification--${status}`,
|
|
1309
1148
|
children: [
|
|
1310
|
-
/* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-header", children: [
|
|
1150
|
+
/* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-icon", children: statusIcon }),
|
|
1151
|
+
/* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-content", children: [
|
|
1152
|
+
/* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-title", children: title }),
|
|
1153
|
+
/* @__PURE__ */ jsx4("div", { className: "rs-deposit-notification-subtitle", children: subtitle })
|
|
1315
1154
|
] }),
|
|
1316
|
-
/* @__PURE__ */
|
|
1155
|
+
/* @__PURE__ */ jsx4(
|
|
1317
1156
|
"button",
|
|
1318
1157
|
{
|
|
1319
1158
|
type: "button",
|
|
1320
1159
|
className: "rs-deposit-notification-close",
|
|
1321
1160
|
onClick: () => onDismiss(deposit.id),
|
|
1322
1161
|
"aria-label": "Dismiss",
|
|
1323
|
-
children: /* @__PURE__ */
|
|
1162
|
+
children: /* @__PURE__ */ jsx4(CloseIcon, {})
|
|
1324
1163
|
}
|
|
1325
1164
|
)
|
|
1326
1165
|
] }),
|
|
1327
|
-
expanded && /* @__PURE__ */
|
|
1328
|
-
/* @__PURE__ */
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1166
|
+
expanded && /* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-details", children: [
|
|
1167
|
+
/* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-row", children: [
|
|
1168
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-label", children: "Deposit tx" }),
|
|
1169
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-value", children: sourceExplorerUrl ? /* @__PURE__ */ jsxs4(
|
|
1331
1170
|
"a",
|
|
1332
1171
|
{
|
|
1333
1172
|
href: sourceExplorerUrl,
|
|
@@ -1341,9 +1180,9 @@ function DepositNotification({
|
|
|
1341
1180
|
}
|
|
1342
1181
|
) : truncateHash(txHash) })
|
|
1343
1182
|
] }),
|
|
1344
|
-
destinationTxHash && /* @__PURE__ */
|
|
1345
|
-
/* @__PURE__ */
|
|
1346
|
-
/* @__PURE__ */
|
|
1183
|
+
destinationTxHash && /* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-row", children: [
|
|
1184
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-label", children: "Completion tx" }),
|
|
1185
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-value", children: destExplorerUrl ? /* @__PURE__ */ jsxs4(
|
|
1347
1186
|
"a",
|
|
1348
1187
|
{
|
|
1349
1188
|
href: destExplorerUrl,
|
|
@@ -1357,16 +1196,16 @@ function DepositNotification({
|
|
|
1357
1196
|
}
|
|
1358
1197
|
) : truncateHash(destinationTxHash) })
|
|
1359
1198
|
] }),
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
-
/* @__PURE__ */
|
|
1199
|
+
/* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-row", children: [
|
|
1200
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-label", children: "Order submitted" }),
|
|
1201
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-value", children: formatTimestamp(detectedAt) })
|
|
1363
1202
|
] }),
|
|
1364
|
-
completedAt && /* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
/* @__PURE__ */
|
|
1203
|
+
completedAt && /* @__PURE__ */ jsxs4("div", { className: "rs-deposit-notification-row", children: [
|
|
1204
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-label", children: "Order filled" }),
|
|
1205
|
+
/* @__PURE__ */ jsx4("span", { className: "rs-deposit-notification-value", children: formatTimestamp(completedAt) })
|
|
1367
1206
|
] })
|
|
1368
1207
|
] }),
|
|
1369
|
-
/* @__PURE__ */
|
|
1208
|
+
/* @__PURE__ */ jsx4(
|
|
1370
1209
|
"button",
|
|
1371
1210
|
{
|
|
1372
1211
|
type: "button",
|
|
@@ -1498,7 +1337,7 @@ async function sendSolanaTransaction(provider, _connection, transaction) {
|
|
|
1498
1337
|
}
|
|
1499
1338
|
|
|
1500
1339
|
// src/components/steps/DepositAddressStep.tsx
|
|
1501
|
-
import { jsx as
|
|
1340
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1502
1341
|
var QRCode = lazy(
|
|
1503
1342
|
() => import("./QRCode-YMQTKSSK.mjs").then((m) => ({ default: m.QRCode }))
|
|
1504
1343
|
);
|
|
@@ -1590,6 +1429,7 @@ function DepositAddressStep({
|
|
|
1590
1429
|
onDepositComplete,
|
|
1591
1430
|
onDepositFailed,
|
|
1592
1431
|
onCopyAddress,
|
|
1432
|
+
onRequestWalletPicker,
|
|
1593
1433
|
onError
|
|
1594
1434
|
}) {
|
|
1595
1435
|
const hasSolana = Boolean(solanaDepositAddress);
|
|
@@ -1613,37 +1453,37 @@ function DepositAddressStep({
|
|
|
1613
1453
|
}, [evmChainIds, hasSolana]);
|
|
1614
1454
|
const BASE_CHAIN_ID = 8453;
|
|
1615
1455
|
const defaultChainId = evmChainIds.includes(BASE_CHAIN_ID) ? BASE_CHAIN_ID : evmChainIds[0];
|
|
1616
|
-
const [sourceChainId, setSourceChainId] =
|
|
1456
|
+
const [sourceChainId, setSourceChainId] = useState5(defaultChainId);
|
|
1617
1457
|
const isSolana = sourceChainId === "solana";
|
|
1618
1458
|
const tokensForChain = useMemo3(() => {
|
|
1619
1459
|
const all = isSolana ? SOLANA_TOKENS.map((t) => t.symbol) : getTargetTokenSymbolsForChain(sourceChainId);
|
|
1620
1460
|
return allowedTokenSet ? all.filter((s) => allowedTokenSet.has(s.toUpperCase())) : all;
|
|
1621
1461
|
}, [sourceChainId, isSolana, allowedTokenSet]);
|
|
1622
1462
|
const defaultToken = tokensForChain.includes("USDC") ? "USDC" : tokensForChain[0] ?? "USDC";
|
|
1623
|
-
const [sourceTokenSymbol, setSourceTokenSymbol] =
|
|
1624
|
-
|
|
1463
|
+
const [sourceTokenSymbol, setSourceTokenSymbol] = useState5(defaultToken);
|
|
1464
|
+
useEffect5(() => {
|
|
1625
1465
|
if (!tokensForChain.includes(sourceTokenSymbol)) {
|
|
1626
1466
|
const fallback = tokensForChain.includes("USDC") ? "USDC" : tokensForChain[0] ?? "USDC";
|
|
1627
1467
|
setSourceTokenSymbol(fallback);
|
|
1628
1468
|
}
|
|
1629
1469
|
}, [tokensForChain, sourceTokenSymbol]);
|
|
1630
|
-
const [copied, setCopied] =
|
|
1631
|
-
const [pollingError, setPollingError] =
|
|
1632
|
-
const [chainDropdownOpen, setChainDropdownOpen] =
|
|
1633
|
-
const [tokenDropdownOpen, setTokenDropdownOpen] =
|
|
1634
|
-
const [priceImpactExpanded, setPriceImpactExpanded] =
|
|
1635
|
-
const chainDropdownRef =
|
|
1636
|
-
const tokenDropdownRef =
|
|
1637
|
-
const [notifications, setNotifications] =
|
|
1638
|
-
const isTrackingRef =
|
|
1639
|
-
const baselineTxHashRef =
|
|
1640
|
-
const notificationIdRef =
|
|
1641
|
-
const sourceSelectionRef =
|
|
1470
|
+
const [copied, setCopied] = useState5(false);
|
|
1471
|
+
const [pollingError, setPollingError] = useState5(null);
|
|
1472
|
+
const [chainDropdownOpen, setChainDropdownOpen] = useState5(false);
|
|
1473
|
+
const [tokenDropdownOpen, setTokenDropdownOpen] = useState5(false);
|
|
1474
|
+
const [priceImpactExpanded, setPriceImpactExpanded] = useState5(false);
|
|
1475
|
+
const chainDropdownRef = useRef4(null);
|
|
1476
|
+
const tokenDropdownRef = useRef4(null);
|
|
1477
|
+
const [notifications, setNotifications] = useState5([]);
|
|
1478
|
+
const isTrackingRef = useRef4(false);
|
|
1479
|
+
const baselineTxHashRef = useRef4(void 0);
|
|
1480
|
+
const notificationIdRef = useRef4(0);
|
|
1481
|
+
const sourceSelectionRef = useRef4({
|
|
1642
1482
|
chainId: defaultChainId,
|
|
1643
1483
|
token: typeof defaultChainId === "number" ? getTokenAddress(defaultToken, defaultChainId) : void 0,
|
|
1644
1484
|
sourceSymbol: defaultToken
|
|
1645
1485
|
});
|
|
1646
|
-
|
|
1486
|
+
useEffect5(() => {
|
|
1647
1487
|
if (isSolana) {
|
|
1648
1488
|
const matched = SOLANA_TOKENS.find((t) => t.symbol === sourceTokenSymbol) ?? SOLANA_TOKENS[0];
|
|
1649
1489
|
sourceSelectionRef.current = {
|
|
@@ -1660,10 +1500,10 @@ function DepositAddressStep({
|
|
|
1660
1500
|
sourceSymbol: sourceTokenSymbol
|
|
1661
1501
|
};
|
|
1662
1502
|
}, [sourceChainId, sourceTokenSymbol, isSolana]);
|
|
1663
|
-
const [liquidityHelper, setLiquidityHelper] =
|
|
1503
|
+
const [liquidityHelper, setLiquidityHelper] = useState5({
|
|
1664
1504
|
kind: "idle"
|
|
1665
1505
|
});
|
|
1666
|
-
|
|
1506
|
+
useEffect5(() => {
|
|
1667
1507
|
if (isSolana) {
|
|
1668
1508
|
setLiquidityHelper({ kind: "idle" });
|
|
1669
1509
|
return;
|
|
@@ -1714,7 +1554,7 @@ function DepositAddressStep({
|
|
|
1714
1554
|
service
|
|
1715
1555
|
]);
|
|
1716
1556
|
const displayAddress = isSolana && solanaDepositAddress ? solanaDepositAddress : smartAccount;
|
|
1717
|
-
|
|
1557
|
+
useEffect5(() => {
|
|
1718
1558
|
if (!chainDropdownOpen && !tokenDropdownOpen) return;
|
|
1719
1559
|
function handlePointerDown(event) {
|
|
1720
1560
|
const target = event.target;
|
|
@@ -1732,7 +1572,7 @@ function DepositAddressStep({
|
|
|
1732
1572
|
document.removeEventListener("touchstart", handlePointerDown);
|
|
1733
1573
|
};
|
|
1734
1574
|
}, [chainDropdownOpen, tokenDropdownOpen]);
|
|
1735
|
-
const handleCopy =
|
|
1575
|
+
const handleCopy = useCallback2(async () => {
|
|
1736
1576
|
onCopyAddress?.();
|
|
1737
1577
|
try {
|
|
1738
1578
|
await navigator.clipboard.writeText(displayAddress);
|
|
@@ -1751,24 +1591,24 @@ function DepositAddressStep({
|
|
|
1751
1591
|
setTimeout(() => setCopied(false), 2e3);
|
|
1752
1592
|
}
|
|
1753
1593
|
}, [displayAddress, onCopyAddress]);
|
|
1754
|
-
|
|
1594
|
+
useEffect5(() => {
|
|
1755
1595
|
setCopied(false);
|
|
1756
1596
|
setChainDropdownOpen(false);
|
|
1757
1597
|
setTokenDropdownOpen(false);
|
|
1758
1598
|
}, [sourceChainId]);
|
|
1759
|
-
const onDepositSubmittedRef =
|
|
1599
|
+
const onDepositSubmittedRef = useRef4(onDepositSubmitted);
|
|
1760
1600
|
onDepositSubmittedRef.current = onDepositSubmitted;
|
|
1761
|
-
const onDepositCompleteRef =
|
|
1601
|
+
const onDepositCompleteRef = useRef4(onDepositComplete);
|
|
1762
1602
|
onDepositCompleteRef.current = onDepositComplete;
|
|
1763
|
-
const onDepositFailedRef =
|
|
1603
|
+
const onDepositFailedRef = useRef4(onDepositFailed);
|
|
1764
1604
|
onDepositFailedRef.current = onDepositFailed;
|
|
1765
|
-
const onErrorRef =
|
|
1605
|
+
const onErrorRef = useRef4(onError);
|
|
1766
1606
|
onErrorRef.current = onError;
|
|
1767
|
-
const targetChainRef =
|
|
1607
|
+
const targetChainRef = useRef4(targetChain);
|
|
1768
1608
|
targetChainRef.current = targetChain;
|
|
1769
|
-
const targetTokenRef =
|
|
1609
|
+
const targetTokenRef = useRef4(targetToken);
|
|
1770
1610
|
targetTokenRef.current = targetToken;
|
|
1771
|
-
|
|
1611
|
+
useEffect5(() => {
|
|
1772
1612
|
baselineTxHashRef.current = void 0;
|
|
1773
1613
|
isTrackingRef.current = false;
|
|
1774
1614
|
setPollingError(null);
|
|
@@ -1863,31 +1703,31 @@ function DepositAddressStep({
|
|
|
1863
1703
|
clearTimeout(timeoutId);
|
|
1864
1704
|
};
|
|
1865
1705
|
}, [smartAccount, solanaDepositAddress, service]);
|
|
1866
|
-
const handleNotificationComplete =
|
|
1706
|
+
const handleNotificationComplete = useCallback2(
|
|
1867
1707
|
(txHash, destinationTxHash, context) => {
|
|
1868
1708
|
isTrackingRef.current = false;
|
|
1869
1709
|
onDepositCompleteRef.current?.(txHash, destinationTxHash, context);
|
|
1870
1710
|
},
|
|
1871
1711
|
[]
|
|
1872
1712
|
);
|
|
1873
|
-
const handleNotificationFailed =
|
|
1713
|
+
const handleNotificationFailed = useCallback2(
|
|
1874
1714
|
(txHash, error) => {
|
|
1875
1715
|
isTrackingRef.current = false;
|
|
1876
1716
|
onDepositFailedRef.current?.(txHash, error);
|
|
1877
1717
|
},
|
|
1878
1718
|
[]
|
|
1879
1719
|
);
|
|
1880
|
-
const handleNotificationDismiss =
|
|
1720
|
+
const handleNotificationDismiss = useCallback2((id) => {
|
|
1881
1721
|
setNotifications((prev) => prev.filter((n) => n.id !== id));
|
|
1882
1722
|
}, []);
|
|
1883
1723
|
const qrIconSrc = getChainIcon(sourceChainId);
|
|
1884
|
-
return /* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
1887
|
-
/* @__PURE__ */
|
|
1888
|
-
/* @__PURE__ */
|
|
1889
|
-
/* @__PURE__ */
|
|
1890
|
-
/* @__PURE__ */
|
|
1724
|
+
return /* @__PURE__ */ jsxs5("div", { className: "rs-screen rs-step--with-notifications", children: [
|
|
1725
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-screen-body", children: [
|
|
1726
|
+
/* @__PURE__ */ jsx5(BodyHeader, { icon: /* @__PURE__ */ jsx5(CoinsIcon, {}), title: "Transfer crypto" }),
|
|
1727
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-deposit-address-selectors", children: [
|
|
1728
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-deposit-address-dropdown", ref: chainDropdownRef, children: [
|
|
1729
|
+
/* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-dropdown-label", children: "Supported chain" }),
|
|
1730
|
+
/* @__PURE__ */ jsxs5(
|
|
1891
1731
|
"button",
|
|
1892
1732
|
{
|
|
1893
1733
|
type: "button",
|
|
@@ -1897,7 +1737,7 @@ function DepositAddressStep({
|
|
|
1897
1737
|
setTokenDropdownOpen(false);
|
|
1898
1738
|
},
|
|
1899
1739
|
children: [
|
|
1900
|
-
getChainIcon(sourceChainId) && /* @__PURE__ */
|
|
1740
|
+
getChainIcon(sourceChainId) && /* @__PURE__ */ jsx5(
|
|
1901
1741
|
"img",
|
|
1902
1742
|
{
|
|
1903
1743
|
src: getChainIcon(sourceChainId),
|
|
@@ -1905,12 +1745,12 @@ function DepositAddressStep({
|
|
|
1905
1745
|
className: "rs-deposit-address-dropdown-icon"
|
|
1906
1746
|
}
|
|
1907
1747
|
),
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
/* @__PURE__ */
|
|
1748
|
+
/* @__PURE__ */ jsx5("span", { children: getChainName(sourceChainId) }),
|
|
1749
|
+
/* @__PURE__ */ jsx5(ChevronDownIcon, { className: "rs-deposit-address-dropdown-chevron" })
|
|
1910
1750
|
]
|
|
1911
1751
|
}
|
|
1912
1752
|
),
|
|
1913
|
-
chainDropdownOpen && /* @__PURE__ */
|
|
1753
|
+
chainDropdownOpen && /* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-dropdown-menu", children: chainOptions.map((chainId) => /* @__PURE__ */ jsxs5(
|
|
1914
1754
|
"button",
|
|
1915
1755
|
{
|
|
1916
1756
|
type: "button",
|
|
@@ -1920,7 +1760,7 @@ function DepositAddressStep({
|
|
|
1920
1760
|
setChainDropdownOpen(false);
|
|
1921
1761
|
},
|
|
1922
1762
|
children: [
|
|
1923
|
-
getChainIcon(chainId) && /* @__PURE__ */
|
|
1763
|
+
getChainIcon(chainId) && /* @__PURE__ */ jsx5(
|
|
1924
1764
|
"img",
|
|
1925
1765
|
{
|
|
1926
1766
|
src: getChainIcon(chainId),
|
|
@@ -1928,19 +1768,19 @@ function DepositAddressStep({
|
|
|
1928
1768
|
className: "rs-deposit-address-dropdown-icon"
|
|
1929
1769
|
}
|
|
1930
1770
|
),
|
|
1931
|
-
/* @__PURE__ */
|
|
1771
|
+
/* @__PURE__ */ jsx5("span", { children: getChainName(chainId) })
|
|
1932
1772
|
]
|
|
1933
1773
|
},
|
|
1934
1774
|
String(chainId)
|
|
1935
1775
|
)) })
|
|
1936
1776
|
] }),
|
|
1937
|
-
/* @__PURE__ */
|
|
1938
|
-
/* @__PURE__ */
|
|
1939
|
-
/* @__PURE__ */
|
|
1940
|
-
/* @__PURE__ */
|
|
1777
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-deposit-address-dropdown", ref: tokenDropdownRef, children: [
|
|
1778
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-deposit-address-dropdown-label rs-deposit-address-dropdown-label--with-min", children: [
|
|
1779
|
+
/* @__PURE__ */ jsx5("span", { children: "Supported token" }),
|
|
1780
|
+
/* @__PURE__ */ jsxs5("span", { className: "rs-deposit-address-min", children: [
|
|
1941
1781
|
"Min.$",
|
|
1942
1782
|
uiConfig?.minDepositUsd ?? 0.1,
|
|
1943
|
-
/* @__PURE__ */
|
|
1783
|
+
/* @__PURE__ */ jsx5(Tooltip, { content: "Minimum deposit amount required for the selected chain.", children: /* @__PURE__ */ jsx5(
|
|
1944
1784
|
InfoIcon,
|
|
1945
1785
|
{
|
|
1946
1786
|
className: "rs-deposit-address-min-icon",
|
|
@@ -1949,7 +1789,7 @@ function DepositAddressStep({
|
|
|
1949
1789
|
) })
|
|
1950
1790
|
] })
|
|
1951
1791
|
] }),
|
|
1952
|
-
/* @__PURE__ */
|
|
1792
|
+
/* @__PURE__ */ jsxs5(
|
|
1953
1793
|
"button",
|
|
1954
1794
|
{
|
|
1955
1795
|
type: "button",
|
|
@@ -1959,7 +1799,7 @@ function DepositAddressStep({
|
|
|
1959
1799
|
setChainDropdownOpen(false);
|
|
1960
1800
|
},
|
|
1961
1801
|
children: [
|
|
1962
|
-
getTokenIcon(sourceTokenSymbol) && /* @__PURE__ */
|
|
1802
|
+
getTokenIcon(sourceTokenSymbol) && /* @__PURE__ */ jsx5(
|
|
1963
1803
|
"img",
|
|
1964
1804
|
{
|
|
1965
1805
|
src: getTokenIcon(sourceTokenSymbol),
|
|
@@ -1967,12 +1807,12 @@ function DepositAddressStep({
|
|
|
1967
1807
|
className: "rs-deposit-address-dropdown-icon"
|
|
1968
1808
|
}
|
|
1969
1809
|
),
|
|
1970
|
-
/* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
1810
|
+
/* @__PURE__ */ jsx5("span", { children: sourceTokenSymbol }),
|
|
1811
|
+
/* @__PURE__ */ jsx5(ChevronDownIcon, { className: "rs-deposit-address-dropdown-chevron" })
|
|
1972
1812
|
]
|
|
1973
1813
|
}
|
|
1974
1814
|
),
|
|
1975
|
-
tokenDropdownOpen && /* @__PURE__ */
|
|
1815
|
+
tokenDropdownOpen && /* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-dropdown-menu", children: tokensForChain.map((symbol) => /* @__PURE__ */ jsxs5(
|
|
1976
1816
|
"button",
|
|
1977
1817
|
{
|
|
1978
1818
|
type: "button",
|
|
@@ -1982,7 +1822,7 @@ function DepositAddressStep({
|
|
|
1982
1822
|
setTokenDropdownOpen(false);
|
|
1983
1823
|
},
|
|
1984
1824
|
children: [
|
|
1985
|
-
getTokenIcon(symbol) && /* @__PURE__ */
|
|
1825
|
+
getTokenIcon(symbol) && /* @__PURE__ */ jsx5(
|
|
1986
1826
|
"img",
|
|
1987
1827
|
{
|
|
1988
1828
|
src: getTokenIcon(symbol),
|
|
@@ -1990,23 +1830,23 @@ function DepositAddressStep({
|
|
|
1990
1830
|
className: "rs-deposit-address-dropdown-icon"
|
|
1991
1831
|
}
|
|
1992
1832
|
),
|
|
1993
|
-
/* @__PURE__ */
|
|
1833
|
+
/* @__PURE__ */ jsx5("span", { children: symbol })
|
|
1994
1834
|
]
|
|
1995
1835
|
},
|
|
1996
1836
|
symbol
|
|
1997
1837
|
)) })
|
|
1998
1838
|
] })
|
|
1999
1839
|
] }),
|
|
2000
|
-
/* @__PURE__ */
|
|
1840
|
+
/* @__PURE__ */ jsxs5(
|
|
2001
1841
|
"div",
|
|
2002
1842
|
{
|
|
2003
1843
|
style: { display: "flex", flexDirection: "column", gap: 4, width: "100%" },
|
|
2004
1844
|
children: [
|
|
2005
|
-
/* @__PURE__ */
|
|
2006
|
-
/* @__PURE__ */
|
|
1845
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-deposit-address-well", children: [
|
|
1846
|
+
/* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-qr", children: /* @__PURE__ */ jsx5(
|
|
2007
1847
|
Suspense,
|
|
2008
1848
|
{
|
|
2009
|
-
fallback: /* @__PURE__ */
|
|
1849
|
+
fallback: /* @__PURE__ */ jsx5(
|
|
2010
1850
|
"div",
|
|
2011
1851
|
{
|
|
2012
1852
|
style: {
|
|
@@ -2016,22 +1856,22 @@ function DepositAddressStep({
|
|
|
2016
1856
|
alignItems: "center",
|
|
2017
1857
|
justifyContent: "center"
|
|
2018
1858
|
},
|
|
2019
|
-
children: /* @__PURE__ */
|
|
1859
|
+
children: /* @__PURE__ */ jsx5(Spinner, {})
|
|
2020
1860
|
}
|
|
2021
1861
|
),
|
|
2022
|
-
children: /* @__PURE__ */
|
|
1862
|
+
children: /* @__PURE__ */ jsx5(QRCode, { value: displayAddress, size: 220, iconSrc: qrIconSrc })
|
|
2023
1863
|
}
|
|
2024
1864
|
) }),
|
|
2025
|
-
/* @__PURE__ */
|
|
1865
|
+
/* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-value", children: displayAddress })
|
|
2026
1866
|
] }),
|
|
2027
|
-
/* @__PURE__ */
|
|
1867
|
+
/* @__PURE__ */ jsxs5(
|
|
2028
1868
|
"button",
|
|
2029
1869
|
{
|
|
2030
1870
|
type: "button",
|
|
2031
1871
|
className: "rs-deposit-address-copy",
|
|
2032
1872
|
onClick: handleCopy,
|
|
2033
1873
|
children: [
|
|
2034
|
-
copied ? /* @__PURE__ */
|
|
1874
|
+
copied ? /* @__PURE__ */ jsx5(CheckIcon, {}) : /* @__PURE__ */ jsx5(CopyIcon, {}),
|
|
2035
1875
|
copied ? "Copied!" : "Copy address"
|
|
2036
1876
|
]
|
|
2037
1877
|
}
|
|
@@ -2039,12 +1879,12 @@ function DepositAddressStep({
|
|
|
2039
1879
|
]
|
|
2040
1880
|
}
|
|
2041
1881
|
),
|
|
2042
|
-
/* @__PURE__ */
|
|
1882
|
+
/* @__PURE__ */ jsxs5(
|
|
2043
1883
|
"div",
|
|
2044
1884
|
{
|
|
2045
1885
|
className: `rs-price-impact ${priceImpactExpanded ? "rs-price-impact--open" : ""}`,
|
|
2046
1886
|
children: [
|
|
2047
|
-
/* @__PURE__ */
|
|
1887
|
+
/* @__PURE__ */ jsxs5(
|
|
2048
1888
|
"button",
|
|
2049
1889
|
{
|
|
2050
1890
|
type: "button",
|
|
@@ -2052,19 +1892,19 @@ function DepositAddressStep({
|
|
|
2052
1892
|
onClick: () => setPriceImpactExpanded((v) => !v),
|
|
2053
1893
|
"aria-expanded": priceImpactExpanded,
|
|
2054
1894
|
children: [
|
|
2055
|
-
/* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
2057
|
-
/* @__PURE__ */
|
|
2058
|
-
/* @__PURE__ */
|
|
1895
|
+
/* @__PURE__ */ jsxs5("span", { className: "rs-price-impact-header-left", children: [
|
|
1896
|
+
/* @__PURE__ */ jsx5("span", { className: "rs-price-impact-label", children: "Price impact" }),
|
|
1897
|
+
/* @__PURE__ */ jsx5("span", { className: "rs-price-impact-label", children: /* @__PURE__ */ jsx5("strong", { children: "0.00%" }) }),
|
|
1898
|
+
/* @__PURE__ */ jsx5(
|
|
2059
1899
|
Tooltip,
|
|
2060
1900
|
{
|
|
2061
1901
|
className: "rs-price-impact-info",
|
|
2062
1902
|
content: "Price impact is the difference between expected and execution price, due to trade size and liquidity.",
|
|
2063
|
-
children: /* @__PURE__ */
|
|
1903
|
+
children: /* @__PURE__ */ jsx5(InfoIcon, { "aria-hidden": "true" })
|
|
2064
1904
|
}
|
|
2065
1905
|
)
|
|
2066
1906
|
] }),
|
|
2067
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ jsx5(
|
|
2068
1908
|
ChevronDownIcon,
|
|
2069
1909
|
{
|
|
2070
1910
|
className: "rs-price-impact-chevron",
|
|
@@ -2074,35 +1914,35 @@ function DepositAddressStep({
|
|
|
2074
1914
|
]
|
|
2075
1915
|
}
|
|
2076
1916
|
),
|
|
2077
|
-
/* @__PURE__ */
|
|
2078
|
-
/* @__PURE__ */
|
|
2079
|
-
/* @__PURE__ */
|
|
2080
|
-
/* @__PURE__ */
|
|
1917
|
+
/* @__PURE__ */ jsx5("div", { className: "rs-price-impact-panel", children: /* @__PURE__ */ jsxs5("div", { className: "rs-price-impact-panel-inner", children: [
|
|
1918
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-price-impact-row", children: [
|
|
1919
|
+
/* @__PURE__ */ jsx5("span", { className: "rs-price-impact-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(PercentIcon, {}) }),
|
|
1920
|
+
/* @__PURE__ */ jsxs5("span", { className: "rs-price-impact-label", children: [
|
|
2081
1921
|
"Max slippage: ",
|
|
2082
|
-
/* @__PURE__ */
|
|
1922
|
+
/* @__PURE__ */ jsx5("strong", { children: "0.2%" })
|
|
2083
1923
|
] }),
|
|
2084
|
-
/* @__PURE__ */
|
|
1924
|
+
/* @__PURE__ */ jsx5(
|
|
2085
1925
|
Tooltip,
|
|
2086
1926
|
{
|
|
2087
1927
|
className: "rs-price-impact-info",
|
|
2088
1928
|
content: "Slippage accounts for price changes during execution. Slippage is adjusted per pair to ensure reliable execution.",
|
|
2089
|
-
children: /* @__PURE__ */
|
|
1929
|
+
children: /* @__PURE__ */ jsx5(InfoIcon, { "aria-hidden": "true" })
|
|
2090
1930
|
}
|
|
2091
1931
|
)
|
|
2092
1932
|
] }),
|
|
2093
|
-
/* @__PURE__ */
|
|
2094
|
-
/* @__PURE__ */
|
|
2095
|
-
/* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-price-impact-row", children: [
|
|
1934
|
+
/* @__PURE__ */ jsx5("span", { className: "rs-price-impact-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(ClockIcon, {}) }),
|
|
1935
|
+
/* @__PURE__ */ jsxs5("span", { className: "rs-price-impact-label", children: [
|
|
2096
1936
|
"Processing time: ",
|
|
2097
|
-
/* @__PURE__ */
|
|
1937
|
+
/* @__PURE__ */ jsx5("strong", { children: "< 1 min" })
|
|
2098
1938
|
] })
|
|
2099
1939
|
] }),
|
|
2100
|
-
/* @__PURE__ */
|
|
2101
|
-
/* @__PURE__ */
|
|
2102
|
-
/* @__PURE__ */
|
|
1940
|
+
/* @__PURE__ */ jsxs5("div", { className: "rs-price-impact-row", children: [
|
|
1941
|
+
/* @__PURE__ */ jsx5("span", { className: "rs-price-impact-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(PlusCircleIcon, {}) }),
|
|
1942
|
+
/* @__PURE__ */ jsxs5("span", { className: "rs-price-impact-label", children: [
|
|
2103
1943
|
"Max deposit:",
|
|
2104
1944
|
" ",
|
|
2105
|
-
/* @__PURE__ */
|
|
1945
|
+
/* @__PURE__ */ jsx5("strong", { children: liquidityHelper.kind === "max" ? `${formatUnits3(
|
|
2106
1946
|
BigInt(liquidityHelper.maxAmount),
|
|
2107
1947
|
liquidityHelper.decimals
|
|
2108
1948
|
)} ${liquidityHelper.symbol}` : liquidityHelper.kind === "unlimited" ? "Unlimited" : liquidityHelper.kind === "unavailable" ? "Unavailable" : liquidityHelper.kind === "error" ? "\u2014" : "\u2026" })
|
|
@@ -2112,9 +1952,18 @@ function DepositAddressStep({
|
|
|
2112
1952
|
]
|
|
2113
1953
|
}
|
|
2114
1954
|
),
|
|
2115
|
-
pollingError && /* @__PURE__ */
|
|
1955
|
+
pollingError && /* @__PURE__ */ jsx5("div", { className: "rs-deposit-address-error", children: pollingError }),
|
|
1956
|
+
onRequestWalletPicker && /* @__PURE__ */ jsx5(
|
|
1957
|
+
"button",
|
|
1958
|
+
{
|
|
1959
|
+
type: "button",
|
|
1960
|
+
className: "rs-connect-wallet-manage",
|
|
1961
|
+
onClick: onRequestWalletPicker,
|
|
1962
|
+
children: "Use a wallet to deposit instead"
|
|
1963
|
+
}
|
|
1964
|
+
)
|
|
2116
1965
|
] }),
|
|
2117
|
-
notifications.length > 0 && /* @__PURE__ */
|
|
1966
|
+
notifications.length > 0 && /* @__PURE__ */ jsx5("div", { className: "rs-deposit-notifications", children: notifications.map((deposit) => /* @__PURE__ */ jsx5(
|
|
2118
1967
|
DepositNotification,
|
|
2119
1968
|
{
|
|
2120
1969
|
deposit,
|
|
@@ -2131,15 +1980,15 @@ function DepositAddressStep({
|
|
|
2131
1980
|
},
|
|
2132
1981
|
deposit.id
|
|
2133
1982
|
)) }),
|
|
2134
|
-
/* @__PURE__ */
|
|
1983
|
+
/* @__PURE__ */ jsx5(PoweredBy, {})
|
|
2135
1984
|
] });
|
|
2136
1985
|
}
|
|
2137
1986
|
DepositAddressStep.displayName = "DepositAddressStep";
|
|
2138
1987
|
|
|
2139
1988
|
// src/components/steps/SolanaTokenSelectStep.tsx
|
|
2140
|
-
import { useState as
|
|
1989
|
+
import { useState as useState6, useEffect as useEffect6, useMemo as useMemo4 } from "react";
|
|
2141
1990
|
import { formatUnits as formatUnits4 } from "viem";
|
|
2142
|
-
import { jsx as
|
|
1991
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2143
1992
|
function SolanaTokenSelectStep({
|
|
2144
1993
|
solanaAddress,
|
|
2145
1994
|
service,
|
|
@@ -2147,11 +1996,11 @@ function SolanaTokenSelectStep({
|
|
|
2147
1996
|
onTotalBalanceComputed,
|
|
2148
1997
|
debug
|
|
2149
1998
|
}) {
|
|
2150
|
-
const [tokenBalances, setTokenBalances] =
|
|
2151
|
-
const [selectedSymbol, setSelectedSymbol] =
|
|
2152
|
-
const [loading, setLoading] =
|
|
2153
|
-
const [error, setError] =
|
|
2154
|
-
|
|
1999
|
+
const [tokenBalances, setTokenBalances] = useState6([]);
|
|
2000
|
+
const [selectedSymbol, setSelectedSymbol] = useState6(null);
|
|
2001
|
+
const [loading, setLoading] = useState6(true);
|
|
2002
|
+
const [error, setError] = useState6(null);
|
|
2003
|
+
useEffect6(() => {
|
|
2155
2004
|
let active = true;
|
|
2156
2005
|
async function loadBalances() {
|
|
2157
2006
|
if (!solanaAddress) {
|
|
@@ -2233,37 +2082,37 @@ function SolanaTokenSelectStep({
|
|
|
2233
2082
|
);
|
|
2234
2083
|
const selectedEntry = selectedSymbol ? rows.find((r) => r.token.symbol === selectedSymbol) : null;
|
|
2235
2084
|
if (error) {
|
|
2236
|
-
return /* @__PURE__ */
|
|
2085
|
+
return /* @__PURE__ */ jsx6("div", { className: "rs-step", children: /* @__PURE__ */ jsx6("div", { className: "rs-step-body", children: /* @__PURE__ */ jsx6("div", { className: "rs-alert rs-alert--error", children: /* @__PURE__ */ jsx6("span", { className: "rs-alert-text", children: error }) }) }) });
|
|
2237
2086
|
}
|
|
2238
|
-
return /* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2087
|
+
return /* @__PURE__ */ jsxs6("div", { className: "rs-step", children: [
|
|
2088
|
+
/* @__PURE__ */ jsx6("div", { style: { padding: "0 12px 12px" }, children: /* @__PURE__ */ jsx6(
|
|
2240
2089
|
BodyHeader,
|
|
2241
2090
|
{
|
|
2242
|
-
icon: /* @__PURE__ */
|
|
2091
|
+
icon: /* @__PURE__ */ jsx6(CoinsIcon, {}),
|
|
2243
2092
|
title: "Select asset",
|
|
2244
2093
|
subtitle: "Pick a Solana token to deposit"
|
|
2245
2094
|
}
|
|
2246
2095
|
) }),
|
|
2247
|
-
/* @__PURE__ */
|
|
2096
|
+
/* @__PURE__ */ jsxs6(
|
|
2248
2097
|
"div",
|
|
2249
2098
|
{
|
|
2250
2099
|
className: "rs-step-body",
|
|
2251
2100
|
style: { paddingTop: 4, overflow: "auto", maxHeight: 340 },
|
|
2252
2101
|
children: [
|
|
2253
|
-
loading && /* @__PURE__ */
|
|
2254
|
-
/* @__PURE__ */
|
|
2255
|
-
/* @__PURE__ */
|
|
2102
|
+
loading && /* @__PURE__ */ jsxs6("div", { className: "rs-loading-state", style: { padding: "40px 12px" }, children: [
|
|
2103
|
+
/* @__PURE__ */ jsx6(Spinner, { className: "rs-text-tertiary" }),
|
|
2104
|
+
/* @__PURE__ */ jsx6("span", { className: "rs-text-sm rs-text-tertiary", children: "Loading balances" })
|
|
2256
2105
|
] }),
|
|
2257
|
-
!loading && rows.length === 0 && /* @__PURE__ */
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2260
|
-
/* @__PURE__ */
|
|
2106
|
+
!loading && rows.length === 0 && /* @__PURE__ */ jsxs6("div", { className: "rs-empty-state", children: [
|
|
2107
|
+
/* @__PURE__ */ jsx6(WalletIcon, { className: "rs-empty-icon" }),
|
|
2108
|
+
/* @__PURE__ */ jsx6("div", { className: "rs-empty-text", children: "No funds in connected wallet" }),
|
|
2109
|
+
/* @__PURE__ */ jsxs6("div", { className: "rs-empty-address", children: [
|
|
2261
2110
|
solanaAddress.slice(0, 6),
|
|
2262
2111
|
"...",
|
|
2263
2112
|
solanaAddress.slice(-4)
|
|
2264
2113
|
] })
|
|
2265
2114
|
] }),
|
|
2266
|
-
!loading && rows.length > 0 && /* @__PURE__ */
|
|
2115
|
+
!loading && rows.length > 0 && /* @__PURE__ */ jsx6("div", { className: "rs-asset-list", children: rows.map((entry) => {
|
|
2267
2116
|
const isSelected = selectedSymbol === entry.token.symbol;
|
|
2268
2117
|
const tokenIcon = getTokenIcon(entry.token.symbol);
|
|
2269
2118
|
const chainIcon = getChainIcon("solana");
|
|
@@ -2275,7 +2124,7 @@ function SolanaTokenSelectStep({
|
|
|
2275
2124
|
} catch {
|
|
2276
2125
|
formattedBalance = "...";
|
|
2277
2126
|
}
|
|
2278
|
-
return /* @__PURE__ */
|
|
2127
|
+
return /* @__PURE__ */ jsxs6(
|
|
2279
2128
|
"button",
|
|
2280
2129
|
{
|
|
2281
2130
|
type: "button",
|
|
@@ -2283,9 +2132,9 @@ function SolanaTokenSelectStep({
|
|
|
2283
2132
|
className: `rs-asset-row ${isSelected ? "rs-asset-row--selected" : ""}`,
|
|
2284
2133
|
style: { textAlign: "left" },
|
|
2285
2134
|
children: [
|
|
2286
|
-
/* @__PURE__ */
|
|
2287
|
-
/* @__PURE__ */
|
|
2288
|
-
tokenIcon ? /* @__PURE__ */
|
|
2135
|
+
/* @__PURE__ */ jsxs6("div", { className: "rs-asset-info", children: [
|
|
2136
|
+
/* @__PURE__ */ jsxs6("div", { className: "rs-asset-icon-wrapper", children: [
|
|
2137
|
+
tokenIcon ? /* @__PURE__ */ jsx6(
|
|
2289
2138
|
"img",
|
|
2290
2139
|
{
|
|
2291
2140
|
src: tokenIcon,
|
|
@@ -2293,8 +2142,8 @@ function SolanaTokenSelectStep({
|
|
|
2293
2142
|
className: "rs-asset-icon",
|
|
2294
2143
|
style: { background: "transparent" }
|
|
2295
2144
|
}
|
|
2296
|
-
) : /* @__PURE__ */
|
|
2297
|
-
chainIcon && /* @__PURE__ */
|
|
2145
|
+
) : /* @__PURE__ */ jsx6("div", { className: "rs-asset-icon", children: entry.token.symbol.slice(0, 4) }),
|
|
2146
|
+
chainIcon && /* @__PURE__ */ jsx6(
|
|
2298
2147
|
"img",
|
|
2299
2148
|
{
|
|
2300
2149
|
src: chainIcon,
|
|
@@ -2303,19 +2152,19 @@ function SolanaTokenSelectStep({
|
|
|
2303
2152
|
}
|
|
2304
2153
|
)
|
|
2305
2154
|
] }),
|
|
2306
|
-
/* @__PURE__ */
|
|
2307
|
-
/* @__PURE__ */
|
|
2155
|
+
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2156
|
+
/* @__PURE__ */ jsxs6("div", { className: "rs-asset-name", children: [
|
|
2308
2157
|
entry.token.symbol,
|
|
2309
|
-
/* @__PURE__ */
|
|
2158
|
+
/* @__PURE__ */ jsx6("span", { className: "rs-asset-chain", children: " on Solana" })
|
|
2310
2159
|
] }),
|
|
2311
|
-
/* @__PURE__ */
|
|
2160
|
+
/* @__PURE__ */ jsxs6("div", { className: "rs-asset-balance-small", children: [
|
|
2312
2161
|
formattedBalance,
|
|
2313
2162
|
" ",
|
|
2314
2163
|
entry.token.symbol
|
|
2315
2164
|
] })
|
|
2316
2165
|
] })
|
|
2317
2166
|
] }),
|
|
2318
|
-
/* @__PURE__ */
|
|
2167
|
+
/* @__PURE__ */ jsx6("div", { className: "rs-asset-balance", children: entry.balanceUsd > 0 ? currencyFormatter.format(entry.balanceUsd) : `${formattedBalance} ${entry.token.symbol}` })
|
|
2319
2168
|
]
|
|
2320
2169
|
},
|
|
2321
2170
|
entry.token.symbol
|
|
@@ -2324,7 +2173,7 @@ function SolanaTokenSelectStep({
|
|
|
2324
2173
|
]
|
|
2325
2174
|
}
|
|
2326
2175
|
),
|
|
2327
|
-
/* @__PURE__ */
|
|
2176
|
+
/* @__PURE__ */ jsx6("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx6(
|
|
2328
2177
|
Button,
|
|
2329
2178
|
{
|
|
2330
2179
|
onClick: () => selectedEntry && onContinue(
|
|
@@ -2337,14 +2186,14 @@ function SolanaTokenSelectStep({
|
|
|
2337
2186
|
children: "Continue"
|
|
2338
2187
|
}
|
|
2339
2188
|
) }),
|
|
2340
|
-
/* @__PURE__ */
|
|
2189
|
+
/* @__PURE__ */ jsx6(PoweredBy, {})
|
|
2341
2190
|
] });
|
|
2342
2191
|
}
|
|
2343
2192
|
|
|
2344
2193
|
// src/components/steps/SolanaAmountStep.tsx
|
|
2345
|
-
import { useEffect as
|
|
2194
|
+
import { useEffect as useEffect7, useMemo as useMemo5, useState as useState7 } from "react";
|
|
2346
2195
|
import { formatUnits as formatUnits5, parseUnits as parseUnits3 } from "viem";
|
|
2347
|
-
import { Fragment as Fragment2, jsx as
|
|
2196
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2348
2197
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
2349
2198
|
var PRESETS2 = [
|
|
2350
2199
|
{ value: 25, label: "25%" },
|
|
@@ -2365,8 +2214,8 @@ function SolanaAmountStep({
|
|
|
2365
2214
|
onContinue,
|
|
2366
2215
|
debug
|
|
2367
2216
|
}) {
|
|
2368
|
-
const [amount, setAmount] =
|
|
2369
|
-
const [error, setError] =
|
|
2217
|
+
const [amount, setAmount] = useState7("");
|
|
2218
|
+
const [error, setError] = useState7(null);
|
|
2370
2219
|
const isSourceStablecoin = isStablecoinSymbol(token.symbol);
|
|
2371
2220
|
const tokenPriceUsd = useMemo5(() => {
|
|
2372
2221
|
if (isSourceStablecoin) return 1;
|
|
@@ -2382,7 +2231,7 @@ function SolanaAmountStep({
|
|
|
2382
2231
|
}
|
|
2383
2232
|
}, [isSourceStablecoin, balance, token.decimals, balanceUsd]);
|
|
2384
2233
|
const hasPricing = tokenPriceUsd !== null;
|
|
2385
|
-
|
|
2234
|
+
useEffect7(() => {
|
|
2386
2235
|
if (defaultAmount && !amount) {
|
|
2387
2236
|
const parsed = Number(defaultAmount);
|
|
2388
2237
|
if (Number.isFinite(parsed) && parsed > 0) {
|
|
@@ -2519,14 +2368,14 @@ function SolanaAmountStep({
|
|
|
2519
2368
|
const continueLabel = exceedsBalance ? "Insufficient balance" : isAboveMax ? "Continue with max allowed deposit" : isBelowMin ? "Continue with minimum deposit" : "Continue";
|
|
2520
2369
|
const continueDisabled = exceedsBalance || numericAmount === 0 && !isBelowMin;
|
|
2521
2370
|
const sourceTokenIcon = getTokenIcon(token.symbol);
|
|
2522
|
-
return /* @__PURE__ */
|
|
2523
|
-
/* @__PURE__ */
|
|
2524
|
-
/* @__PURE__ */
|
|
2525
|
-
/* @__PURE__ */
|
|
2526
|
-
/* @__PURE__ */
|
|
2527
|
-
/* @__PURE__ */
|
|
2528
|
-
/* @__PURE__ */
|
|
2529
|
-
/* @__PURE__ */
|
|
2371
|
+
return /* @__PURE__ */ jsxs7("div", { className: "rs-screen", children: [
|
|
2372
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
2373
|
+
/* @__PURE__ */ jsx7(BodyHeader, { icon: /* @__PURE__ */ jsx7(WalletIcon, {}), title: "Wallet deposit" }),
|
|
2374
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-section", children: [
|
|
2375
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-display", children: [
|
|
2376
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-input-row", children: [
|
|
2377
|
+
/* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: "$" }),
|
|
2378
|
+
/* @__PURE__ */ jsx7(
|
|
2530
2379
|
"input",
|
|
2531
2380
|
{
|
|
2532
2381
|
type: "text",
|
|
@@ -2539,25 +2388,25 @@ function SolanaAmountStep({
|
|
|
2539
2388
|
}
|
|
2540
2389
|
)
|
|
2541
2390
|
] }),
|
|
2542
|
-
/* @__PURE__ */
|
|
2543
|
-
/* @__PURE__ */
|
|
2391
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-meta", children: [
|
|
2392
|
+
/* @__PURE__ */ jsxs7("span", { className: "rs-amount-meta-balance", children: [
|
|
2544
2393
|
formattedBalance,
|
|
2545
2394
|
" ",
|
|
2546
2395
|
token.symbol,
|
|
2547
2396
|
" available",
|
|
2548
|
-
computedBalanceUsd !== null && /* @__PURE__ */
|
|
2397
|
+
computedBalanceUsd !== null && /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
2549
2398
|
" (~",
|
|
2550
2399
|
currencyFormatter.format(computedBalanceUsd),
|
|
2551
2400
|
")"
|
|
2552
2401
|
] })
|
|
2553
2402
|
] }),
|
|
2554
|
-
minDepositUsd !== null && /* @__PURE__ */
|
|
2403
|
+
minDepositUsd !== null && /* @__PURE__ */ jsxs7("span", { className: "rs-amount-meta-minimum", children: [
|
|
2555
2404
|
"Min. deposit ",
|
|
2556
2405
|
currencyFormatter.format(minDepositUsd)
|
|
2557
2406
|
] })
|
|
2558
2407
|
] })
|
|
2559
2408
|
] }),
|
|
2560
|
-
/* @__PURE__ */
|
|
2409
|
+
/* @__PURE__ */ jsx7("div", { className: "rs-amount-presets", children: PRESETS2.map((preset) => /* @__PURE__ */ jsx7(
|
|
2561
2410
|
"button",
|
|
2562
2411
|
{
|
|
2563
2412
|
type: "button",
|
|
@@ -2568,38 +2417,38 @@ function SolanaAmountStep({
|
|
|
2568
2417
|
preset.value
|
|
2569
2418
|
)) })
|
|
2570
2419
|
] }),
|
|
2571
|
-
/* @__PURE__ */
|
|
2572
|
-
/* @__PURE__ */
|
|
2573
|
-
/* @__PURE__ */
|
|
2574
|
-
/* @__PURE__ */
|
|
2575
|
-
/* @__PURE__ */
|
|
2420
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-details", children: [
|
|
2421
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-amount-detail-row", children: [
|
|
2422
|
+
/* @__PURE__ */ jsx7("span", { children: "You send" }),
|
|
2423
|
+
/* @__PURE__ */ jsxs7("span", { className: "rs-amount-detail-value", children: [
|
|
2424
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
2576
2425
|
"Solana ",
|
|
2577
2426
|
token.symbol
|
|
2578
2427
|
] }),
|
|
2579
|
-
sourceTokenIcon && /* @__PURE__ */
|
|
2428
|
+
sourceTokenIcon && /* @__PURE__ */ jsx7("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx7("img", { src: sourceTokenIcon, alt: "" }) })
|
|
2580
2429
|
] })
|
|
2581
2430
|
] }),
|
|
2582
|
-
targetChainName && targetTokenSymbol && /* @__PURE__ */
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2585
|
-
/* @__PURE__ */
|
|
2431
|
+
targetChainName && targetTokenSymbol && /* @__PURE__ */ jsxs7("div", { className: "rs-amount-detail-row", children: [
|
|
2432
|
+
/* @__PURE__ */ jsx7("span", { children: "Receive" }),
|
|
2433
|
+
/* @__PURE__ */ jsxs7("span", { className: "rs-amount-detail-value", children: [
|
|
2434
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
2586
2435
|
targetChainName,
|
|
2587
2436
|
" ",
|
|
2588
2437
|
targetTokenSymbol
|
|
2589
2438
|
] }),
|
|
2590
|
-
targetTokenIcon && /* @__PURE__ */
|
|
2439
|
+
targetTokenIcon && /* @__PURE__ */ jsx7("span", { className: "rs-amount-detail-icon", children: /* @__PURE__ */ jsx7("img", { src: targetTokenIcon, alt: "" }) })
|
|
2591
2440
|
] })
|
|
2592
2441
|
] }),
|
|
2593
|
-
balanceAfterUsd !== null && /* @__PURE__ */
|
|
2594
|
-
/* @__PURE__ */
|
|
2595
|
-
/* @__PURE__ */
|
|
2442
|
+
balanceAfterUsd !== null && /* @__PURE__ */ jsxs7("div", { className: "rs-amount-detail-row", children: [
|
|
2443
|
+
/* @__PURE__ */ jsx7("span", { children: "Balance after deposit" }),
|
|
2444
|
+
/* @__PURE__ */ jsx7("span", { className: "rs-amount-detail-value", children: currencyFormatter.format(balanceAfterUsd) })
|
|
2596
2445
|
] })
|
|
2597
2446
|
] }),
|
|
2598
|
-
error && /* @__PURE__ */
|
|
2599
|
-
/* @__PURE__ */
|
|
2600
|
-
/* @__PURE__ */
|
|
2447
|
+
error && /* @__PURE__ */ jsxs7("div", { className: "rs-amount-error", role: "alert", children: [
|
|
2448
|
+
/* @__PURE__ */ jsx7(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
|
|
2449
|
+
/* @__PURE__ */ jsx7("span", { children: error })
|
|
2601
2450
|
] }),
|
|
2602
|
-
/* @__PURE__ */
|
|
2451
|
+
/* @__PURE__ */ jsx7(
|
|
2603
2452
|
Button,
|
|
2604
2453
|
{
|
|
2605
2454
|
onClick: handleContinue,
|
|
@@ -2609,14 +2458,14 @@ function SolanaAmountStep({
|
|
|
2609
2458
|
}
|
|
2610
2459
|
)
|
|
2611
2460
|
] }),
|
|
2612
|
-
/* @__PURE__ */
|
|
2461
|
+
/* @__PURE__ */ jsx7(PoweredBy, {})
|
|
2613
2462
|
] });
|
|
2614
2463
|
}
|
|
2615
2464
|
|
|
2616
2465
|
// src/components/steps/SolanaConfirmStep.tsx
|
|
2617
|
-
import { useState as
|
|
2466
|
+
import { useState as useState8 } from "react";
|
|
2618
2467
|
import { parseUnits as parseUnits4 } from "viem";
|
|
2619
|
-
import { jsx as
|
|
2468
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2620
2469
|
function SolanaConfirmStep({
|
|
2621
2470
|
smartAccount,
|
|
2622
2471
|
solanaAddress,
|
|
@@ -2634,8 +2483,8 @@ function SolanaConfirmStep({
|
|
|
2634
2483
|
onError,
|
|
2635
2484
|
debug
|
|
2636
2485
|
}) {
|
|
2637
|
-
const [isSubmitting, setIsSubmitting] =
|
|
2638
|
-
const [error, setError] =
|
|
2486
|
+
const [isSubmitting, setIsSubmitting] = useState8(false);
|
|
2487
|
+
const [error, setError] = useState8(null);
|
|
2639
2488
|
const targetSymbol = getTokenSymbol(targetToken, targetChain);
|
|
2640
2489
|
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2641
2490
|
const formattedAmount = sourceAmount && !Number.isNaN(Number(sourceAmount)) ? Number(sourceAmount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
@@ -2740,19 +2589,19 @@ function SolanaConfirmStep({
|
|
|
2740
2589
|
setIsSubmitting(false);
|
|
2741
2590
|
}
|
|
2742
2591
|
};
|
|
2743
|
-
return /* @__PURE__ */
|
|
2744
|
-
/* @__PURE__ */
|
|
2745
|
-
/* @__PURE__ */
|
|
2746
|
-
/* @__PURE__ */
|
|
2747
|
-
/* @__PURE__ */
|
|
2748
|
-
/* @__PURE__ */
|
|
2749
|
-
/* @__PURE__ */
|
|
2592
|
+
return /* @__PURE__ */ jsxs8("div", { className: "rs-step", children: [
|
|
2593
|
+
/* @__PURE__ */ jsx8("div", { style: { padding: "0 12px 12px" }, children: /* @__PURE__ */ jsx8(BodyHeader, { icon: /* @__PURE__ */ jsx8(WalletIcon, {}), title: "Review deposit" }) }),
|
|
2594
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-step-body rs-space-y-3", style: { paddingTop: 0 }, children: [
|
|
2595
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card", children: [
|
|
2596
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card-row", children: [
|
|
2597
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-label", children: "Source" }),
|
|
2598
|
+
/* @__PURE__ */ jsxs8(
|
|
2750
2599
|
"span",
|
|
2751
2600
|
{
|
|
2752
2601
|
className: "rs-card-value",
|
|
2753
2602
|
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
2754
2603
|
children: [
|
|
2755
|
-
getChainIcon("solana") && /* @__PURE__ */
|
|
2604
|
+
getChainIcon("solana") && /* @__PURE__ */ jsx8(
|
|
2756
2605
|
"img",
|
|
2757
2606
|
{
|
|
2758
2607
|
src: getChainIcon("solana"),
|
|
@@ -2765,15 +2614,15 @@ function SolanaConfirmStep({
|
|
|
2765
2614
|
}
|
|
2766
2615
|
)
|
|
2767
2616
|
] }),
|
|
2768
|
-
/* @__PURE__ */
|
|
2769
|
-
/* @__PURE__ */
|
|
2770
|
-
/* @__PURE__ */
|
|
2617
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card-row", children: [
|
|
2618
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-label", children: "Destination" }),
|
|
2619
|
+
/* @__PURE__ */ jsxs8(
|
|
2771
2620
|
"span",
|
|
2772
2621
|
{
|
|
2773
2622
|
className: "rs-card-value",
|
|
2774
2623
|
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
2775
2624
|
children: [
|
|
2776
|
-
getChainIcon(targetChain) && /* @__PURE__ */
|
|
2625
|
+
getChainIcon(targetChain) && /* @__PURE__ */ jsx8(
|
|
2777
2626
|
"img",
|
|
2778
2627
|
{
|
|
2779
2628
|
src: getChainIcon(targetChain),
|
|
@@ -2786,21 +2635,21 @@ function SolanaConfirmStep({
|
|
|
2786
2635
|
}
|
|
2787
2636
|
)
|
|
2788
2637
|
] }),
|
|
2789
|
-
/* @__PURE__ */
|
|
2790
|
-
/* @__PURE__ */
|
|
2791
|
-
/* @__PURE__ */
|
|
2638
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card-row", children: [
|
|
2639
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-label", children: "Estimated time" }),
|
|
2640
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-value", children: "< 1 min" })
|
|
2792
2641
|
] })
|
|
2793
2642
|
] }),
|
|
2794
|
-
/* @__PURE__ */
|
|
2795
|
-
/* @__PURE__ */
|
|
2796
|
-
/* @__PURE__ */
|
|
2797
|
-
/* @__PURE__ */
|
|
2643
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card", children: [
|
|
2644
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card-row", children: [
|
|
2645
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-label", children: "You send" }),
|
|
2646
|
+
/* @__PURE__ */ jsxs8(
|
|
2798
2647
|
"span",
|
|
2799
2648
|
{
|
|
2800
2649
|
className: "rs-card-value",
|
|
2801
2650
|
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
2802
2651
|
children: [
|
|
2803
|
-
getTokenIcon(token.symbol) && /* @__PURE__ */
|
|
2652
|
+
getTokenIcon(token.symbol) && /* @__PURE__ */ jsx8(
|
|
2804
2653
|
"img",
|
|
2805
2654
|
{
|
|
2806
2655
|
src: getTokenIcon(token.symbol),
|
|
@@ -2815,15 +2664,15 @@ function SolanaConfirmStep({
|
|
|
2815
2664
|
}
|
|
2816
2665
|
)
|
|
2817
2666
|
] }),
|
|
2818
|
-
/* @__PURE__ */
|
|
2819
|
-
/* @__PURE__ */
|
|
2820
|
-
/* @__PURE__ */
|
|
2667
|
+
/* @__PURE__ */ jsxs8("div", { className: "rs-card-row", children: [
|
|
2668
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-card-label", children: "You receive" }),
|
|
2669
|
+
/* @__PURE__ */ jsxs8(
|
|
2821
2670
|
"span",
|
|
2822
2671
|
{
|
|
2823
2672
|
className: "rs-card-value",
|
|
2824
2673
|
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
2825
2674
|
children: [
|
|
2826
|
-
getTokenIcon(targetSymbol) && /* @__PURE__ */
|
|
2675
|
+
getTokenIcon(targetSymbol) && /* @__PURE__ */ jsx8(
|
|
2827
2676
|
"img",
|
|
2828
2677
|
{
|
|
2829
2678
|
src: getTokenIcon(targetSymbol),
|
|
@@ -2839,12 +2688,12 @@ function SolanaConfirmStep({
|
|
|
2839
2688
|
)
|
|
2840
2689
|
] })
|
|
2841
2690
|
] }),
|
|
2842
|
-
error && /* @__PURE__ */
|
|
2843
|
-
/* @__PURE__ */
|
|
2844
|
-
/* @__PURE__ */
|
|
2691
|
+
error && /* @__PURE__ */ jsxs8("div", { className: "rs-alert rs-alert--error", children: [
|
|
2692
|
+
/* @__PURE__ */ jsx8(AlertTriangleIcon, { className: "rs-alert-icon" }),
|
|
2693
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-alert-text", children: error })
|
|
2845
2694
|
] })
|
|
2846
2695
|
] }),
|
|
2847
|
-
/* @__PURE__ */
|
|
2696
|
+
/* @__PURE__ */ jsx8("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx8(
|
|
2848
2697
|
Button,
|
|
2849
2698
|
{
|
|
2850
2699
|
onClick: handleConfirm,
|
|
@@ -2854,36 +2703,394 @@ function SolanaConfirmStep({
|
|
|
2854
2703
|
children: "Continue"
|
|
2855
2704
|
}
|
|
2856
2705
|
) }),
|
|
2706
|
+
/* @__PURE__ */ jsx8(PoweredBy, {})
|
|
2707
|
+
] });
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
// src/components/steps/DappImportAssetSelectStep.tsx
|
|
2711
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2712
|
+
function DappImportAssetSelectStep({
|
|
2713
|
+
sourceLabel,
|
|
2714
|
+
assets,
|
|
2715
|
+
onSelect
|
|
2716
|
+
}) {
|
|
2717
|
+
return /* @__PURE__ */ jsxs9("div", { className: "rs-screen", children: [
|
|
2718
|
+
/* @__PURE__ */ jsxs9("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
2719
|
+
/* @__PURE__ */ jsx9(
|
|
2720
|
+
BodyHeader,
|
|
2721
|
+
{
|
|
2722
|
+
icon: /* @__PURE__ */ jsx9(HandCoinsIcon, {}),
|
|
2723
|
+
title: `Transfer from ${sourceLabel}`,
|
|
2724
|
+
subtitle: "Pick the balance to import"
|
|
2725
|
+
}
|
|
2726
|
+
),
|
|
2727
|
+
/* @__PURE__ */ jsx9("div", { className: "rs-list", children: assets.map((asset) => {
|
|
2728
|
+
const balanceTokens = asset.balance ? tokenFormatter.format(
|
|
2729
|
+
Number(asset.balance) / 10 ** asset.decimals
|
|
2730
|
+
) : "0";
|
|
2731
|
+
const balanceUsd = asset.balanceUsd && asset.balanceUsd > 0 ? currencyFormatter.format(asset.balanceUsd) : `${balanceTokens} ${asset.symbol}`;
|
|
2732
|
+
const iconSrc = getTokenIcon(asset.symbol);
|
|
2733
|
+
return /* @__PURE__ */ jsx9(
|
|
2734
|
+
ListRow,
|
|
2735
|
+
{
|
|
2736
|
+
leadingMedia: iconSrc || void 0,
|
|
2737
|
+
leading: iconSrc ? void 0 : /* @__PURE__ */ jsx9(HandCoinsIcon, {}),
|
|
2738
|
+
title: asset.symbol,
|
|
2739
|
+
subtitle: `${balanceTokens} on ${getChainName(asset.chainId)}`,
|
|
2740
|
+
meta: balanceUsd,
|
|
2741
|
+
onClick: () => onSelect(asset)
|
|
2742
|
+
},
|
|
2743
|
+
asset.id
|
|
2744
|
+
);
|
|
2745
|
+
}) })
|
|
2746
|
+
] }),
|
|
2857
2747
|
/* @__PURE__ */ jsx9(PoweredBy, {})
|
|
2858
2748
|
] });
|
|
2859
2749
|
}
|
|
2750
|
+
DappImportAssetSelectStep.displayName = "DappImportAssetSelectStep";
|
|
2860
2751
|
|
|
2861
|
-
// src/
|
|
2862
|
-
import {
|
|
2863
|
-
import {
|
|
2864
|
-
import { createStore } from "zustand/vanilla";
|
|
2752
|
+
// src/core/dapp-imports/polymarket/index.ts
|
|
2753
|
+
import { createElement } from "react";
|
|
2754
|
+
import { formatUnits as formatUnits6 } from "viem";
|
|
2865
2755
|
|
|
2866
|
-
// src/
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2756
|
+
// src/core/dapp-imports/polymarket/constants.ts
|
|
2757
|
+
var POLYMARKET_POLYGON_CHAIN_ID = 137;
|
|
2758
|
+
var POLYMARKET_PUSD_ADDRESS = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB";
|
|
2759
|
+
var POLYMARKET_USDCE_ADDRESS = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
2760
|
+
var POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS = "0x2957922Eb93258b93368531d39fAcCA3B4dC5854";
|
|
2761
|
+
var SAFE_MULTI_SEND_CALL_ONLY_ADDRESS = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D";
|
|
2762
|
+
var GAMMA_API_PUBLIC_PROFILE = "https://gamma-api.polymarket.com/public-profile";
|
|
2763
|
+
var POLYMARKET_ICON_URL = "data:image/svg+xml,%3Csvg width='512' height='512' viewBox='0 0 512 512' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='512' height='512' fill='%232E5CFF'/%3E%3Cpath d='M375.84 389.422C375.84 403.572 375.84 410.647 371.212 414.154C366.585 417.662 359.773 415.75 346.15 411.927L127.22 350.493C119.012 348.19 114.907 347.038 112.534 343.907C110.161 340.776 110.161 336.513 110.161 327.988V184.012C110.161 175.487 110.161 171.224 112.534 168.093C114.907 164.962 119.012 163.81 127.22 161.507L346.15 100.072C359.773 96.2495 366.585 94.338 371.212 97.8455C375.84 101.353 375.84 108.428 375.84 122.578V389.422ZM164.761 330.463L346.035 381.337V279.595L164.761 330.463ZM139.963 306.862L321.201 256L139.963 205.138V306.862ZM164.759 181.537L346.035 232.406V130.663L164.759 181.537Z' fill='white'/%3E%3C/svg%3E";
|
|
2764
|
+
|
|
2765
|
+
// src/core/dapp-imports/polymarket/gamma-api.ts
|
|
2766
|
+
import { getAddress, isAddress, zeroAddress } from "viem";
|
|
2767
|
+
async function fetchPolymarketProxyWallet(eoa, signal) {
|
|
2768
|
+
const url = `${GAMMA_API_PUBLIC_PROFILE}?address=${eoa}`;
|
|
2769
|
+
let response;
|
|
2770
|
+
try {
|
|
2771
|
+
response = await fetch(url, { signal });
|
|
2772
|
+
} catch {
|
|
2773
|
+
return null;
|
|
2774
|
+
}
|
|
2775
|
+
if (!response.ok) {
|
|
2776
|
+
return null;
|
|
2777
|
+
}
|
|
2778
|
+
let payload;
|
|
2779
|
+
try {
|
|
2780
|
+
payload = await response.json();
|
|
2781
|
+
} catch {
|
|
2782
|
+
return null;
|
|
2783
|
+
}
|
|
2784
|
+
const raw = payload.proxyWallet;
|
|
2785
|
+
if (!raw || !isAddress(raw)) {
|
|
2786
|
+
return null;
|
|
2787
|
+
}
|
|
2788
|
+
const checksummed = getAddress(raw);
|
|
2789
|
+
if (checksummed === zeroAddress) {
|
|
2790
|
+
return null;
|
|
2791
|
+
}
|
|
2792
|
+
return checksummed;
|
|
2871
2793
|
}
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2794
|
+
|
|
2795
|
+
// src/core/dapp-imports/polymarket/safe.ts
|
|
2796
|
+
import {
|
|
2797
|
+
concat,
|
|
2798
|
+
encodeFunctionData,
|
|
2799
|
+
encodePacked,
|
|
2800
|
+
erc20Abi as erc20Abi3,
|
|
2801
|
+
pad,
|
|
2802
|
+
parseAbi,
|
|
2803
|
+
parseEventLogs,
|
|
2804
|
+
toHex,
|
|
2805
|
+
zeroAddress as zeroAddress2
|
|
2806
|
+
} from "viem";
|
|
2807
|
+
var COLLATERAL_OFFRAMP_ABI = parseAbi([
|
|
2808
|
+
"function unwrap(address _asset, address _to, uint256 _amount)"
|
|
2809
|
+
]);
|
|
2810
|
+
var MULTI_SEND_ABI = parseAbi(["function multiSend(bytes transactions)"]);
|
|
2811
|
+
async function readPolymarketBalances(params) {
|
|
2812
|
+
const { publicClient, proxyWallet } = params;
|
|
2813
|
+
try {
|
|
2814
|
+
const results = await publicClient.multicall({
|
|
2815
|
+
allowFailure: true,
|
|
2816
|
+
contracts: [
|
|
2817
|
+
{
|
|
2818
|
+
address: POLYMARKET_PUSD_ADDRESS,
|
|
2819
|
+
abi: erc20Abi3,
|
|
2820
|
+
functionName: "balanceOf",
|
|
2821
|
+
args: [proxyWallet]
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
address: POLYMARKET_USDCE_ADDRESS,
|
|
2825
|
+
abi: erc20Abi3,
|
|
2826
|
+
functionName: "balanceOf",
|
|
2827
|
+
args: [proxyWallet]
|
|
2828
|
+
}
|
|
2829
|
+
]
|
|
2830
|
+
});
|
|
2831
|
+
return {
|
|
2832
|
+
pusd: results[0].status === "success" ? results[0].result : 0n,
|
|
2833
|
+
usdce: results[1].status === "success" ? results[1].result : 0n
|
|
2834
|
+
};
|
|
2835
|
+
} catch {
|
|
2836
|
+
return { pusd: 0n, usdce: 0n };
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
async function executePolymarketSafeTransfer(params) {
|
|
2840
|
+
const {
|
|
2841
|
+
walletClient,
|
|
2842
|
+
publicClient,
|
|
2843
|
+
safeAddress,
|
|
2844
|
+
recipient,
|
|
2845
|
+
amount,
|
|
2846
|
+
tokenKind
|
|
2847
|
+
} = params;
|
|
2848
|
+
const account = walletClient.account;
|
|
2849
|
+
const chain = walletClient.chain;
|
|
2850
|
+
if (!account || !chain) {
|
|
2851
|
+
throw new Error("Wallet not connected");
|
|
2852
|
+
}
|
|
2853
|
+
if (chain.id !== POLYMARKET_POLYGON_CHAIN_ID) {
|
|
2854
|
+
throw new Error("Switch to Polygon to sign");
|
|
2855
|
+
}
|
|
2856
|
+
const isOwner = await publicClient.readContract({
|
|
2857
|
+
address: safeAddress,
|
|
2858
|
+
abi: SAFE_ABI,
|
|
2859
|
+
functionName: "isOwner",
|
|
2860
|
+
args: [account.address]
|
|
2861
|
+
});
|
|
2862
|
+
if (!isOwner) {
|
|
2863
|
+
throw new Error("Connected wallet is not a Polymarket Safe owner");
|
|
2864
|
+
}
|
|
2865
|
+
const safeTx = tokenKind === "pusd" ? buildPusdUnwrapSafeTx(recipient, amount) : buildUsdceTransferSafeTx(recipient, amount);
|
|
2866
|
+
const signature = concat([
|
|
2867
|
+
pad(account.address, { size: 32 }),
|
|
2868
|
+
pad(toHex(0), { size: 32 }),
|
|
2869
|
+
toHex(1, { size: 1 })
|
|
2870
|
+
]);
|
|
2871
|
+
const txHash = await walletClient.writeContract({
|
|
2872
|
+
account,
|
|
2873
|
+
chain,
|
|
2874
|
+
address: safeAddress,
|
|
2875
|
+
abi: SAFE_ABI,
|
|
2876
|
+
functionName: "execTransaction",
|
|
2877
|
+
args: [
|
|
2878
|
+
safeTx.to,
|
|
2879
|
+
0n,
|
|
2880
|
+
safeTx.data,
|
|
2881
|
+
safeTx.operation,
|
|
2882
|
+
0n,
|
|
2883
|
+
0n,
|
|
2884
|
+
0n,
|
|
2885
|
+
zeroAddress2,
|
|
2886
|
+
zeroAddress2,
|
|
2887
|
+
signature
|
|
2888
|
+
]
|
|
2889
|
+
});
|
|
2890
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
2891
|
+
hash: txHash
|
|
2892
|
+
});
|
|
2893
|
+
const parsed = parseEventLogs({
|
|
2894
|
+
abi: SAFE_ABI,
|
|
2895
|
+
logs: receipt.logs.filter(
|
|
2896
|
+
(log) => log.address.toLowerCase() === safeAddress.toLowerCase()
|
|
2897
|
+
),
|
|
2898
|
+
strict: false
|
|
2899
|
+
});
|
|
2900
|
+
if (parsed.some((log) => log.eventName === "ExecutionFailure")) {
|
|
2901
|
+
throw new Error("Polymarket Safe transaction failed");
|
|
2902
|
+
}
|
|
2903
|
+
if (!parsed.some((log) => log.eventName === "ExecutionSuccess")) {
|
|
2904
|
+
throw new Error("Polymarket Safe transaction status unavailable");
|
|
2905
|
+
}
|
|
2906
|
+
return {
|
|
2907
|
+
txHash,
|
|
2908
|
+
// The smart account always receives USDC.e — pUSD is unwrapped to USDC.e
|
|
2909
|
+
// before it lands at `recipient`.
|
|
2910
|
+
sourceToken: POLYMARKET_USDCE_ADDRESS,
|
|
2911
|
+
sourceSymbol: tokenKind === "pusd" ? "pUSD" : "USDC.e"
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
function buildUsdceTransferSafeTx(recipient, amount) {
|
|
2915
|
+
return {
|
|
2916
|
+
to: POLYMARKET_USDCE_ADDRESS,
|
|
2917
|
+
data: encodeFunctionData({
|
|
2918
|
+
abi: erc20Abi3,
|
|
2919
|
+
functionName: "transfer",
|
|
2920
|
+
args: [recipient, amount]
|
|
2921
|
+
}),
|
|
2922
|
+
operation: 0
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
function buildPusdUnwrapSafeTx(recipient, amount) {
|
|
2926
|
+
const approveData = encodeFunctionData({
|
|
2927
|
+
abi: erc20Abi3,
|
|
2928
|
+
functionName: "approve",
|
|
2929
|
+
args: [POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, amount]
|
|
2930
|
+
});
|
|
2931
|
+
const unwrapData = encodeFunctionData({
|
|
2932
|
+
abi: COLLATERAL_OFFRAMP_ABI,
|
|
2933
|
+
functionName: "unwrap",
|
|
2934
|
+
args: [POLYMARKET_USDCE_ADDRESS, recipient, amount]
|
|
2935
|
+
});
|
|
2936
|
+
return {
|
|
2937
|
+
to: SAFE_MULTI_SEND_CALL_ONLY_ADDRESS,
|
|
2938
|
+
data: encodeFunctionData({
|
|
2939
|
+
abi: MULTI_SEND_ABI,
|
|
2940
|
+
functionName: "multiSend",
|
|
2941
|
+
args: [
|
|
2942
|
+
concat([
|
|
2943
|
+
encodeMultiSendCall(POLYMARKET_PUSD_ADDRESS, approveData),
|
|
2944
|
+
encodeMultiSendCall(POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS, unwrapData)
|
|
2945
|
+
])
|
|
2946
|
+
]
|
|
2947
|
+
}),
|
|
2948
|
+
operation: 1
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
function encodeMultiSendCall(to, data) {
|
|
2952
|
+
return encodePacked(
|
|
2953
|
+
["uint8", "address", "uint256", "uint256", "bytes"],
|
|
2954
|
+
[0, to, 0n, BigInt((data.length - 2) / 2), data]
|
|
2955
|
+
);
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
// src/core/dapp-imports/polymarket/index.ts
|
|
2959
|
+
var PROVIDER_ID = "polymarket";
|
|
2960
|
+
var polymarketProvider = {
|
|
2961
|
+
id: PROVIDER_ID,
|
|
2962
|
+
label: "Transfer from Polymarket",
|
|
2963
|
+
icon: createElement("img", {
|
|
2964
|
+
src: POLYMARKET_ICON_URL,
|
|
2965
|
+
alt: "Polymarket",
|
|
2966
|
+
style: { width: 24, height: 24, borderRadius: 6 }
|
|
2967
|
+
}),
|
|
2968
|
+
chainId: POLYMARKET_POLYGON_CHAIN_ID,
|
|
2969
|
+
async fetchAvailability({ eoa, getPublicClient: getPublicClient2, signal }) {
|
|
2970
|
+
const proxyWallet = await fetchPolymarketProxyWallet(eoa, signal);
|
|
2971
|
+
if (!proxyWallet) return null;
|
|
2972
|
+
if (signal?.aborted) return null;
|
|
2973
|
+
const polygonClient = getPublicClient2(POLYMARKET_POLYGON_CHAIN_ID);
|
|
2974
|
+
if (!polygonClient) return null;
|
|
2975
|
+
const balances = await readPolymarketBalances({
|
|
2976
|
+
publicClient: polygonClient,
|
|
2977
|
+
proxyWallet
|
|
2978
|
+
});
|
|
2979
|
+
if (signal?.aborted) return null;
|
|
2980
|
+
if (balances.pusd === 0n && balances.usdce === 0n) return null;
|
|
2981
|
+
const assets = [];
|
|
2982
|
+
if (balances.pusd > 0n) {
|
|
2983
|
+
assets.push(buildAsset({ tokenKind: "pusd", proxyWallet, balance: balances.pusd }));
|
|
2984
|
+
}
|
|
2985
|
+
if (balances.usdce > 0n) {
|
|
2986
|
+
assets.push(buildAsset({ tokenKind: "usdce", proxyWallet, balance: balances.usdce }));
|
|
2987
|
+
}
|
|
2988
|
+
const totalUsd = assets.reduce((sum, a) => sum + (a.balanceUsd ?? 0), 0);
|
|
2989
|
+
const availability = {
|
|
2990
|
+
providerId: PROVIDER_ID,
|
|
2991
|
+
totalUsd,
|
|
2992
|
+
assets
|
|
2993
|
+
};
|
|
2994
|
+
return availability;
|
|
2995
|
+
},
|
|
2996
|
+
async executeTransfer({ walletClient, publicClient, recipient, asset, amount }) {
|
|
2997
|
+
const metadata = asset.providerMetadata;
|
|
2998
|
+
const result = await executePolymarketSafeTransfer({
|
|
2999
|
+
walletClient,
|
|
3000
|
+
publicClient,
|
|
3001
|
+
safeAddress: metadata.proxyWallet,
|
|
3002
|
+
recipient,
|
|
3003
|
+
amount,
|
|
3004
|
+
tokenKind: metadata.tokenKind
|
|
3005
|
+
});
|
|
3006
|
+
return {
|
|
3007
|
+
txHash: result.txHash,
|
|
3008
|
+
sourceToken: result.sourceToken,
|
|
3009
|
+
sourceSymbol: result.sourceSymbol,
|
|
3010
|
+
sourceDecimals: 6
|
|
3011
|
+
};
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
function buildAsset(params) {
|
|
3015
|
+
const { tokenKind, proxyWallet, balance } = params;
|
|
3016
|
+
const isPusd = tokenKind === "pusd";
|
|
3017
|
+
const tokenAddress = isPusd ? POLYMARKET_PUSD_ADDRESS : POLYMARKET_USDCE_ADDRESS;
|
|
3018
|
+
const symbol = isPusd ? "pUSD" : "USDC.e";
|
|
3019
|
+
const balanceUsd = Number(formatUnits6(balance, 6));
|
|
3020
|
+
const metadata = { proxyWallet, tokenKind };
|
|
3021
|
+
return {
|
|
3022
|
+
id: `polymarket:${tokenKind}`,
|
|
3023
|
+
chainId: POLYMARKET_POLYGON_CHAIN_ID,
|
|
3024
|
+
token: tokenAddress,
|
|
3025
|
+
symbol,
|
|
3026
|
+
name: isPusd ? "Polymarket USD" : "Polygon USDC.e",
|
|
3027
|
+
decimals: 6,
|
|
3028
|
+
balance: balance.toString(),
|
|
3029
|
+
balanceUsd: Number.isFinite(balanceUsd) ? balanceUsd : 0,
|
|
3030
|
+
source: PROVIDER_ID,
|
|
3031
|
+
sourceLabel: "Polymarket",
|
|
3032
|
+
reviewLabel: isPusd ? "You send pUSD from Polymarket" : "You send USDC.e from Polymarket",
|
|
3033
|
+
// pUSD unwraps to USDC.e via the offramp; USDC.e is what actually
|
|
3034
|
+
// arrives at the smart account, so it's also what the orchestrator
|
|
3035
|
+
// bridges from.
|
|
3036
|
+
depositToken: POLYMARKET_USDCE_ADDRESS,
|
|
3037
|
+
depositChainId: POLYMARKET_POLYGON_CHAIN_ID,
|
|
3038
|
+
providerMetadata: metadata
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
// src/core/dapp-imports/registry.ts
|
|
3043
|
+
var DAPP_IMPORT_PROVIDERS = [polymarketProvider];
|
|
3044
|
+
function getEnabledProviders(config) {
|
|
3045
|
+
if (!config) return [];
|
|
3046
|
+
return DAPP_IMPORT_PROVIDERS.filter(
|
|
3047
|
+
(p) => config[p.id] === true
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
// src/store/index.ts
|
|
3052
|
+
import { createContext, createElement as createElement2, useContext } from "react";
|
|
3053
|
+
import { useStore } from "zustand";
|
|
3054
|
+
import { createStore } from "zustand/vanilla";
|
|
3055
|
+
|
|
3056
|
+
// src/store/transitions.ts
|
|
3057
|
+
function unreachable(action) {
|
|
3058
|
+
throw new Error(
|
|
3059
|
+
`[deposit-modal/store] Unhandled action: ${JSON.stringify(action)}`
|
|
3060
|
+
);
|
|
3061
|
+
}
|
|
3062
|
+
var RESET_DEPOSIT_FIELDS = {
|
|
3063
|
+
selectedAsset: null,
|
|
3064
|
+
selectedSolanaToken: null,
|
|
3065
|
+
amount: null,
|
|
3066
|
+
targetAmount: null,
|
|
3067
|
+
targetTokenPriceUsd: null,
|
|
3068
|
+
balance: null,
|
|
3069
|
+
balanceUsd: null,
|
|
3070
|
+
inputAmountUsd: null,
|
|
3071
|
+
liquidityWarning: null,
|
|
3072
|
+
sourceChain: null,
|
|
3073
|
+
sourceToken: null,
|
|
2884
3074
|
sourceSymbol: null,
|
|
2885
3075
|
sourceDecimals: null
|
|
2886
3076
|
};
|
|
3077
|
+
function ownerKey(owner) {
|
|
3078
|
+
return owner.toString().toLowerCase();
|
|
3079
|
+
}
|
|
3080
|
+
function idleEntry(owner) {
|
|
3081
|
+
return {
|
|
3082
|
+
owner,
|
|
3083
|
+
requestKey: null,
|
|
3084
|
+
cacheKey: null,
|
|
3085
|
+
status: "idle",
|
|
3086
|
+
smartAccount: null,
|
|
3087
|
+
sessionOwnerAddress: null,
|
|
3088
|
+
solanaDepositAddress: null,
|
|
3089
|
+
message: null,
|
|
3090
|
+
cacheable: true,
|
|
3091
|
+
attemptNonce: 0
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
2887
3094
|
function applyBack(state, hasWalletOptions) {
|
|
2888
3095
|
const { step, mode } = state.flow;
|
|
2889
3096
|
switch (step) {
|
|
@@ -2898,7 +3105,11 @@ function applyBack(state, hasWalletOptions) {
|
|
|
2898
3105
|
balance: null,
|
|
2899
3106
|
liquidityWarning: null
|
|
2900
3107
|
},
|
|
2901
|
-
flow: {
|
|
3108
|
+
flow: {
|
|
3109
|
+
...state.flow,
|
|
3110
|
+
step: mode === "dapp-import" ? "dapp-import-asset-select" : "select-asset",
|
|
3111
|
+
hasNavigatedBack: true
|
|
3112
|
+
}
|
|
2902
3113
|
};
|
|
2903
3114
|
case "confirm":
|
|
2904
3115
|
return {
|
|
@@ -2940,37 +3151,70 @@ function applyBack(state, hasWalletOptions) {
|
|
|
2940
3151
|
case "select-asset":
|
|
2941
3152
|
case "deposit-address":
|
|
2942
3153
|
case "solana-token-select":
|
|
3154
|
+
case "dapp-import-asset-select":
|
|
2943
3155
|
return {
|
|
2944
3156
|
...state,
|
|
2945
3157
|
flow: {
|
|
2946
3158
|
...state.flow,
|
|
2947
|
-
step: "
|
|
3159
|
+
step: "connect",
|
|
2948
3160
|
mode: null,
|
|
2949
3161
|
isConnectSelectionConfirmed: false,
|
|
2950
|
-
hasNavigatedBack:
|
|
3162
|
+
hasNavigatedBack: true
|
|
2951
3163
|
},
|
|
2952
|
-
deposit: { ...state.deposit, ...RESET_DEPOSIT_FIELDS }
|
|
3164
|
+
deposit: { ...state.deposit, ...RESET_DEPOSIT_FIELDS },
|
|
3165
|
+
dappImport: {
|
|
3166
|
+
...state.dappImport,
|
|
3167
|
+
activeProviderId: null,
|
|
3168
|
+
selectedAsset: null
|
|
3169
|
+
}
|
|
2953
3170
|
};
|
|
3171
|
+
case "connect":
|
|
2954
3172
|
case "setup":
|
|
2955
|
-
if (mode !== null
|
|
3173
|
+
if (mode !== null) {
|
|
2956
3174
|
return {
|
|
2957
3175
|
...state,
|
|
2958
3176
|
flow: {
|
|
2959
3177
|
...state.flow,
|
|
3178
|
+
step: "connect",
|
|
2960
3179
|
mode: null,
|
|
2961
3180
|
isConnectSelectionConfirmed: false,
|
|
2962
|
-
hasNavigatedBack:
|
|
3181
|
+
hasNavigatedBack: hasWalletOptions || state.flow.hasNavigatedBack
|
|
2963
3182
|
}
|
|
2964
3183
|
};
|
|
2965
3184
|
}
|
|
2966
3185
|
return state;
|
|
2967
|
-
case "connect":
|
|
2968
3186
|
case "processing":
|
|
2969
3187
|
return state;
|
|
2970
3188
|
default:
|
|
2971
3189
|
return unreachable(step);
|
|
2972
3190
|
}
|
|
2973
3191
|
}
|
|
3192
|
+
function modeEntryStep(mode) {
|
|
3193
|
+
switch (mode) {
|
|
3194
|
+
case "wallet":
|
|
3195
|
+
return "select-asset";
|
|
3196
|
+
case "deposit-address":
|
|
3197
|
+
return "deposit-address";
|
|
3198
|
+
case "solana-wallet":
|
|
3199
|
+
return "solana-token-select";
|
|
3200
|
+
case "dapp-import":
|
|
3201
|
+
return "dapp-import-asset-select";
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
function updateSetupEntry(state, owner, update) {
|
|
3205
|
+
const key = ownerKey(owner);
|
|
3206
|
+
const existing = state.setup.byOwner[key] ?? idleEntry(owner);
|
|
3207
|
+
return {
|
|
3208
|
+
...state,
|
|
3209
|
+
setup: {
|
|
3210
|
+
...state.setup,
|
|
3211
|
+
byOwner: {
|
|
3212
|
+
...state.setup.byOwner,
|
|
3213
|
+
[key]: update(existing)
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
}
|
|
2974
3218
|
function applyAction(state, action) {
|
|
2975
3219
|
switch (action.type) {
|
|
2976
3220
|
case "flow/mode-set":
|
|
@@ -2995,16 +3239,22 @@ function applyAction(state, action) {
|
|
|
2995
3239
|
mode: null,
|
|
2996
3240
|
isConnectSelectionConfirmed: false
|
|
2997
3241
|
},
|
|
2998
|
-
wallet: { ...state.wallet, selectedWalletId: null }
|
|
3242
|
+
wallet: { ...state.wallet, selectedWalletId: null },
|
|
3243
|
+
dappImport: {
|
|
3244
|
+
...state.dappImport,
|
|
3245
|
+
activeProviderId: null,
|
|
3246
|
+
selectedAsset: null
|
|
3247
|
+
}
|
|
2999
3248
|
};
|
|
3000
3249
|
case "connect/wallet-confirmed":
|
|
3250
|
+
if (!action.mode) return state;
|
|
3001
3251
|
return {
|
|
3002
3252
|
...state,
|
|
3003
3253
|
flow: {
|
|
3004
3254
|
...state.flow,
|
|
3005
3255
|
mode: action.mode,
|
|
3006
3256
|
isConnectSelectionConfirmed: true,
|
|
3007
|
-
step:
|
|
3257
|
+
step: modeEntryStep(action.mode)
|
|
3008
3258
|
},
|
|
3009
3259
|
wallet: { ...state.wallet, selectedWalletId: action.walletId }
|
|
3010
3260
|
};
|
|
@@ -3015,7 +3265,7 @@ function applyAction(state, action) {
|
|
|
3015
3265
|
...state.flow,
|
|
3016
3266
|
mode: "deposit-address",
|
|
3017
3267
|
isConnectSelectionConfirmed: true,
|
|
3018
|
-
step: "
|
|
3268
|
+
step: "deposit-address"
|
|
3019
3269
|
}
|
|
3020
3270
|
};
|
|
3021
3271
|
case "connect/auto-locked":
|
|
@@ -3025,23 +3275,81 @@ function applyAction(state, action) {
|
|
|
3025
3275
|
...state.flow,
|
|
3026
3276
|
mode: "wallet",
|
|
3027
3277
|
isConnectSelectionConfirmed: true,
|
|
3028
|
-
step: "
|
|
3278
|
+
step: "select-asset"
|
|
3029
3279
|
}
|
|
3030
3280
|
};
|
|
3031
|
-
case "
|
|
3281
|
+
case "connect/wallet-picker-requested":
|
|
3032
3282
|
return {
|
|
3033
3283
|
...state,
|
|
3034
|
-
deposit: {
|
|
3035
|
-
...state.deposit,
|
|
3036
|
-
smartAccount: action.smartAccount,
|
|
3037
|
-
smartAccountOwner: action.smartAccountOwner,
|
|
3038
|
-
solanaDepositAddress: action.solanaDepositAddress ?? null
|
|
3039
|
-
},
|
|
3040
3284
|
flow: {
|
|
3041
3285
|
...state.flow,
|
|
3042
|
-
step:
|
|
3286
|
+
step: "connect",
|
|
3287
|
+
mode: null,
|
|
3288
|
+
isConnectSelectionConfirmed: false,
|
|
3289
|
+
hasNavigatedBack: true
|
|
3290
|
+
},
|
|
3291
|
+
deposit: { ...state.deposit, ...RESET_DEPOSIT_FIELDS },
|
|
3292
|
+
dappImport: {
|
|
3293
|
+
...state.dappImport,
|
|
3294
|
+
activeProviderId: null,
|
|
3295
|
+
selectedAsset: null
|
|
3043
3296
|
}
|
|
3044
3297
|
};
|
|
3298
|
+
case "setup/started": {
|
|
3299
|
+
const existing = state.setup.byOwner[ownerKey(action.owner)];
|
|
3300
|
+
return updateSetupEntry(state, action.owner, () => ({
|
|
3301
|
+
owner: action.owner,
|
|
3302
|
+
requestKey: action.requestKey,
|
|
3303
|
+
cacheKey: action.cacheKey,
|
|
3304
|
+
status: "loading",
|
|
3305
|
+
smartAccount: existing?.smartAccount ?? null,
|
|
3306
|
+
sessionOwnerAddress: existing?.sessionOwnerAddress ?? null,
|
|
3307
|
+
solanaDepositAddress: existing?.solanaDepositAddress ?? null,
|
|
3308
|
+
message: null,
|
|
3309
|
+
cacheable: action.cacheable,
|
|
3310
|
+
attemptNonce: existing?.attemptNonce ?? 0
|
|
3311
|
+
}));
|
|
3312
|
+
}
|
|
3313
|
+
case "setup/ready": {
|
|
3314
|
+
const key = ownerKey(action.owner);
|
|
3315
|
+
const existing = state.setup.byOwner[key];
|
|
3316
|
+
if (!existing || existing.requestKey !== action.requestKey) {
|
|
3317
|
+
return state;
|
|
3318
|
+
}
|
|
3319
|
+
return updateSetupEntry(state, action.owner, (entry) => ({
|
|
3320
|
+
...entry,
|
|
3321
|
+
status: "ready",
|
|
3322
|
+
smartAccount: action.result.smartAccount,
|
|
3323
|
+
sessionOwnerAddress: action.result.sessionOwnerAddress,
|
|
3324
|
+
solanaDepositAddress: action.result.solanaDepositAddress ?? null,
|
|
3325
|
+
cacheKey: action.result.cacheKey,
|
|
3326
|
+
message: null
|
|
3327
|
+
}));
|
|
3328
|
+
}
|
|
3329
|
+
case "setup/failed": {
|
|
3330
|
+
const key = ownerKey(action.owner);
|
|
3331
|
+
const existing = state.setup.byOwner[key];
|
|
3332
|
+
if (!existing || existing.requestKey !== action.requestKey) {
|
|
3333
|
+
return state;
|
|
3334
|
+
}
|
|
3335
|
+
return updateSetupEntry(state, action.owner, (entry) => ({
|
|
3336
|
+
...entry,
|
|
3337
|
+
status: "error",
|
|
3338
|
+
message: action.message
|
|
3339
|
+
}));
|
|
3340
|
+
}
|
|
3341
|
+
case "setup/retry-requested":
|
|
3342
|
+
return updateSetupEntry(state, action.owner, (entry) => ({
|
|
3343
|
+
...entry,
|
|
3344
|
+
status: "idle",
|
|
3345
|
+
// Clear requestKey/cacheKey so the BG effect's
|
|
3346
|
+
// "entry.requestKey !== currentRequestKey" check passes even when
|
|
3347
|
+
// inputs haven't changed.
|
|
3348
|
+
requestKey: null,
|
|
3349
|
+
cacheKey: null,
|
|
3350
|
+
message: null,
|
|
3351
|
+
attemptNonce: entry.attemptNonce + 1
|
|
3352
|
+
}));
|
|
3045
3353
|
case "asset/selected":
|
|
3046
3354
|
return {
|
|
3047
3355
|
...state,
|
|
@@ -3112,13 +3420,86 @@ function applyAction(state, action) {
|
|
|
3112
3420
|
},
|
|
3113
3421
|
flow: { ...state.flow, step: "processing" }
|
|
3114
3422
|
};
|
|
3423
|
+
case "dapp-import/availability-loading":
|
|
3424
|
+
return {
|
|
3425
|
+
...state,
|
|
3426
|
+
dappImport: {
|
|
3427
|
+
...state.dappImport,
|
|
3428
|
+
availabilityOwner: action.owner,
|
|
3429
|
+
availability: {
|
|
3430
|
+
...state.dappImport.availabilityOwner && ownerKey(state.dappImport.availabilityOwner) === ownerKey(action.owner) ? state.dappImport.availability : {},
|
|
3431
|
+
[action.providerId]: "loading"
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
case "dapp-import/availability-loaded":
|
|
3436
|
+
if (!state.dappImport.availabilityOwner || ownerKey(state.dappImport.availabilityOwner) !== ownerKey(action.owner)) {
|
|
3437
|
+
return state;
|
|
3438
|
+
}
|
|
3439
|
+
return {
|
|
3440
|
+
...state,
|
|
3441
|
+
dappImport: {
|
|
3442
|
+
...state.dappImport,
|
|
3443
|
+
availability: {
|
|
3444
|
+
...state.dappImport.availability,
|
|
3445
|
+
[action.providerId]: action.availability
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3449
|
+
case "dapp-import/availability-cleared":
|
|
3450
|
+
return {
|
|
3451
|
+
...state,
|
|
3452
|
+
dappImport: {
|
|
3453
|
+
...state.dappImport,
|
|
3454
|
+
availabilityOwner: null,
|
|
3455
|
+
availability: {},
|
|
3456
|
+
activeProviderId: null,
|
|
3457
|
+
selectedAsset: null
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
case "dapp-import/provider-selected":
|
|
3461
|
+
return {
|
|
3462
|
+
...state,
|
|
3463
|
+
flow: {
|
|
3464
|
+
...state.flow,
|
|
3465
|
+
mode: "dapp-import",
|
|
3466
|
+
isConnectSelectionConfirmed: true,
|
|
3467
|
+
step: "dapp-import-asset-select"
|
|
3468
|
+
},
|
|
3469
|
+
dappImport: {
|
|
3470
|
+
...state.dappImport,
|
|
3471
|
+
activeProviderId: action.providerId,
|
|
3472
|
+
selectedAsset: null
|
|
3473
|
+
}
|
|
3474
|
+
};
|
|
3475
|
+
case "dapp-import/asset-selected":
|
|
3476
|
+
return {
|
|
3477
|
+
...state,
|
|
3478
|
+
deposit: {
|
|
3479
|
+
...state.deposit,
|
|
3480
|
+
selectedAsset: action.asset
|
|
3481
|
+
},
|
|
3482
|
+
dappImport: {
|
|
3483
|
+
...state.dappImport,
|
|
3484
|
+
selectedAsset: action.asset
|
|
3485
|
+
},
|
|
3486
|
+
flow: { ...state.flow, step: "amount" }
|
|
3487
|
+
};
|
|
3115
3488
|
case "back/requested":
|
|
3116
3489
|
return applyBack(state, action.hasWalletOptions);
|
|
3117
|
-
case "flow/reset":
|
|
3490
|
+
case "flow/reset": {
|
|
3491
|
+
const preservedByOwner = {};
|
|
3492
|
+
for (const [key, entry] of Object.entries(state.setup.byOwner)) {
|
|
3493
|
+
if (entry.status === "ready" && entry.smartAccount && entry.cacheKey && entry.cacheable) {
|
|
3494
|
+
preservedByOwner[key] = { ...entry, message: null };
|
|
3495
|
+
} else {
|
|
3496
|
+
preservedByOwner[key] = idleEntry(entry.owner);
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3118
3499
|
return {
|
|
3119
3500
|
...state,
|
|
3120
3501
|
flow: {
|
|
3121
|
-
step: "
|
|
3502
|
+
step: "connect",
|
|
3122
3503
|
mode: null,
|
|
3123
3504
|
isConnectSelectionConfirmed: false,
|
|
3124
3505
|
hasNavigatedBack: false
|
|
@@ -3130,9 +3511,18 @@ function applyAction(state, action) {
|
|
|
3130
3511
|
processing: {
|
|
3131
3512
|
txHash: null,
|
|
3132
3513
|
directTransfer: false
|
|
3133
|
-
}
|
|
3514
|
+
},
|
|
3515
|
+
// Preserve fetched availability for its recorded EOA — refetching on
|
|
3516
|
+
// every modal close burns a request. Just clear active selection.
|
|
3517
|
+
dappImport: {
|
|
3518
|
+
...state.dappImport,
|
|
3519
|
+
activeProviderId: null,
|
|
3520
|
+
selectedAsset: null
|
|
3521
|
+
},
|
|
3522
|
+
setup: { byOwner: preservedByOwner }
|
|
3134
3523
|
};
|
|
3135
|
-
|
|
3524
|
+
}
|
|
3525
|
+
case "target/changed": {
|
|
3136
3526
|
if (state.flow.step === "processing") {
|
|
3137
3527
|
return {
|
|
3138
3528
|
...state,
|
|
@@ -3143,18 +3533,20 @@ function applyAction(state, action) {
|
|
|
3143
3533
|
}
|
|
3144
3534
|
};
|
|
3145
3535
|
}
|
|
3536
|
+
const nextStep = state.flow.step === "confirm" ? "amount" : state.flow.step;
|
|
3146
3537
|
return {
|
|
3147
3538
|
...state,
|
|
3148
3539
|
deposit: {
|
|
3149
3540
|
...state.deposit,
|
|
3150
3541
|
targetChain: action.targetChain,
|
|
3151
3542
|
targetToken: action.targetToken,
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3543
|
+
targetAmount: null,
|
|
3544
|
+
targetTokenPriceUsd: null,
|
|
3545
|
+
liquidityWarning: null
|
|
3155
3546
|
},
|
|
3156
|
-
flow: { ...state.flow, step:
|
|
3547
|
+
flow: { ...state.flow, step: nextStep }
|
|
3157
3548
|
};
|
|
3549
|
+
}
|
|
3158
3550
|
default:
|
|
3159
3551
|
return unreachable(action);
|
|
3160
3552
|
}
|
|
@@ -3173,9 +3565,6 @@ function createInitialState(overrides) {
|
|
|
3173
3565
|
selectedWalletId: null
|
|
3174
3566
|
},
|
|
3175
3567
|
deposit: {
|
|
3176
|
-
smartAccount: null,
|
|
3177
|
-
smartAccountOwner: null,
|
|
3178
|
-
solanaDepositAddress: null,
|
|
3179
3568
|
targetChain: overrides.targetChain,
|
|
3180
3569
|
targetToken: overrides.targetToken,
|
|
3181
3570
|
sourceChain: null,
|
|
@@ -3195,12 +3584,38 @@ function createInitialState(overrides) {
|
|
|
3195
3584
|
processing: {
|
|
3196
3585
|
txHash: null,
|
|
3197
3586
|
directTransfer: false
|
|
3587
|
+
},
|
|
3588
|
+
dappImport: {
|
|
3589
|
+
activeProviderId: null,
|
|
3590
|
+
availabilityOwner: null,
|
|
3591
|
+
availability: {},
|
|
3592
|
+
selectedAsset: null
|
|
3593
|
+
},
|
|
3594
|
+
setup: {
|
|
3595
|
+
byOwner: {}
|
|
3198
3596
|
}
|
|
3199
3597
|
};
|
|
3200
3598
|
}
|
|
3201
3599
|
|
|
3202
3600
|
// src/store/selectors.ts
|
|
3203
3601
|
var selectedWalletIdSelector = (state) => state.wallet.selectedWalletId;
|
|
3602
|
+
var IDLE_SETUP_ENTRY = {
|
|
3603
|
+
owner: null,
|
|
3604
|
+
requestKey: null,
|
|
3605
|
+
cacheKey: null,
|
|
3606
|
+
status: "idle",
|
|
3607
|
+
smartAccount: null,
|
|
3608
|
+
sessionOwnerAddress: null,
|
|
3609
|
+
solanaDepositAddress: null,
|
|
3610
|
+
message: null,
|
|
3611
|
+
cacheable: true,
|
|
3612
|
+
attemptNonce: 0
|
|
3613
|
+
};
|
|
3614
|
+
function readSetupForOwner(setup, owner) {
|
|
3615
|
+
if (!owner) return IDLE_SETUP_ENTRY;
|
|
3616
|
+
const entry = setup.byOwner[owner.toLowerCase()];
|
|
3617
|
+
return entry ?? { ...IDLE_SETUP_ENTRY, owner };
|
|
3618
|
+
}
|
|
3204
3619
|
|
|
3205
3620
|
// src/store/index.ts
|
|
3206
3621
|
function createDepositStore(overrides) {
|
|
@@ -3217,7 +3632,7 @@ function DepositStoreProvider({
|
|
|
3217
3632
|
store,
|
|
3218
3633
|
children
|
|
3219
3634
|
}) {
|
|
3220
|
-
return
|
|
3635
|
+
return createElement2(
|
|
3221
3636
|
DepositStoreContext.Provider,
|
|
3222
3637
|
{ value: store },
|
|
3223
3638
|
children
|
|
@@ -3237,8 +3652,229 @@ function useDepositStore(selector) {
|
|
|
3237
3652
|
return useStore(store, selector);
|
|
3238
3653
|
}
|
|
3239
3654
|
|
|
3655
|
+
// src/core/account-setup.ts
|
|
3656
|
+
var SetupError = class extends Error {
|
|
3657
|
+
constructor(message, category) {
|
|
3658
|
+
super(message);
|
|
3659
|
+
this.category = category;
|
|
3660
|
+
this.name = "SetupError";
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3663
|
+
async function resolveSessionOwner(eoaAddress) {
|
|
3664
|
+
const local = loadSessionOwnerFromStorage(eoaAddress);
|
|
3665
|
+
if (local) {
|
|
3666
|
+
return {
|
|
3667
|
+
account: accountFromPrivateKey(local.privateKey),
|
|
3668
|
+
address: local.address
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
const created = createSessionOwnerKey();
|
|
3672
|
+
saveSessionOwnerToStorage(eoaAddress, created.privateKey, created.address);
|
|
3673
|
+
return { account: created.account, address: created.address };
|
|
3674
|
+
}
|
|
3675
|
+
function stableStringify(value) {
|
|
3676
|
+
if (value === null || typeof value !== "object") {
|
|
3677
|
+
return JSON.stringify(value);
|
|
3678
|
+
}
|
|
3679
|
+
if (Array.isArray(value)) {
|
|
3680
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
3681
|
+
}
|
|
3682
|
+
const obj = value;
|
|
3683
|
+
const keys = Object.keys(obj).sort();
|
|
3684
|
+
const entries = keys.filter((k) => obj[k] !== void 0).map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`);
|
|
3685
|
+
return `{${entries.join(",")}}`;
|
|
3686
|
+
}
|
|
3687
|
+
function computeRequestKey(input, sessionOwnerAddress) {
|
|
3688
|
+
return stableStringify({
|
|
3689
|
+
ownerAddress: input.ownerAddress.toLowerCase(),
|
|
3690
|
+
sessionOwnerAddress: sessionOwnerAddress.toLowerCase(),
|
|
3691
|
+
targetChain: input.targetChain,
|
|
3692
|
+
targetToken: input.targetToken.toLowerCase(),
|
|
3693
|
+
recipient: input.recipient?.toLowerCase(),
|
|
3694
|
+
outputTokenRules: input.outputTokenRules ?? null,
|
|
3695
|
+
rejectUnmapped: input.rejectUnmapped ?? null,
|
|
3696
|
+
signerAddress: input.signerAddress.toLowerCase(),
|
|
3697
|
+
sessionChainIds: input.sessionChainIds ?? null,
|
|
3698
|
+
enableSolana: input.enableSolana ?? true,
|
|
3699
|
+
forceRegister: input.forceRegister ?? false,
|
|
3700
|
+
postBridgeActions: input.postBridgeActions ?? null
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3703
|
+
function computeCacheKey(input, sessionOwnerAddress) {
|
|
3704
|
+
return stableStringify({
|
|
3705
|
+
ownerAddress: input.ownerAddress.toLowerCase(),
|
|
3706
|
+
sessionOwnerAddress: sessionOwnerAddress.toLowerCase(),
|
|
3707
|
+
targetChain: input.targetChain,
|
|
3708
|
+
targetToken: input.targetToken.toLowerCase(),
|
|
3709
|
+
recipient: input.recipient?.toLowerCase(),
|
|
3710
|
+
outputTokenRules: input.outputTokenRules ?? null,
|
|
3711
|
+
rejectUnmapped: input.rejectUnmapped ?? null,
|
|
3712
|
+
signerAddress: input.signerAddress.toLowerCase(),
|
|
3713
|
+
sessionChainIds: input.sessionChainIds ?? null,
|
|
3714
|
+
enableSolana: input.enableSolana ?? true
|
|
3715
|
+
});
|
|
3716
|
+
}
|
|
3717
|
+
function computeIsCacheable(input) {
|
|
3718
|
+
return !input.forceRegister && !(input.postBridgeActions?.length ?? 0);
|
|
3719
|
+
}
|
|
3720
|
+
async function runAccountSetup(input, deps) {
|
|
3721
|
+
const { service, debug } = deps;
|
|
3722
|
+
const enableSolana = input.enableSolana ?? true;
|
|
3723
|
+
try {
|
|
3724
|
+
const sessionOwner = await resolveSessionOwner(input.ownerAddress);
|
|
3725
|
+
const cacheKey = computeCacheKey(input, sessionOwner.address);
|
|
3726
|
+
debugLog(debug, "account-setup", "setup:start", {
|
|
3727
|
+
owner: input.ownerAddress,
|
|
3728
|
+
sessionOwner: sessionOwner.address,
|
|
3729
|
+
hasPostBridgeActions: Boolean(input.postBridgeActions?.length),
|
|
3730
|
+
forceRegister: input.forceRegister ?? false
|
|
3731
|
+
});
|
|
3732
|
+
const setup = await service.setupAccount({
|
|
3733
|
+
ownerAddress: input.ownerAddress,
|
|
3734
|
+
sessionOwnerAddress: sessionOwner.address,
|
|
3735
|
+
targetChain: toEvmCaip2(input.targetChain),
|
|
3736
|
+
targetToken: input.targetToken,
|
|
3737
|
+
recipient: input.recipient,
|
|
3738
|
+
postBridgeActions: input.postBridgeActions,
|
|
3739
|
+
outputTokenRules: input.outputTokenRules,
|
|
3740
|
+
rejectUnmapped: input.rejectUnmapped,
|
|
3741
|
+
signerAddress: input.signerAddress,
|
|
3742
|
+
sessionChainIds: input.sessionChainIds,
|
|
3743
|
+
forceRegister: input.forceRegister
|
|
3744
|
+
});
|
|
3745
|
+
const smartAccount = setup.smartAccount;
|
|
3746
|
+
if (!setup.needsRegistration) {
|
|
3747
|
+
return {
|
|
3748
|
+
smartAccount,
|
|
3749
|
+
sessionOwnerAddress: sessionOwner.address,
|
|
3750
|
+
solanaDepositAddress: enableSolana ? setup.solanaDepositAddress : void 0,
|
|
3751
|
+
cacheKey,
|
|
3752
|
+
isRegistered: true
|
|
3753
|
+
};
|
|
3754
|
+
}
|
|
3755
|
+
if (!setup.accountParams || !setup.sessionDetailsUnsigned) {
|
|
3756
|
+
throw new SetupError(
|
|
3757
|
+
"Couldn't prepare account.",
|
|
3758
|
+
"server"
|
|
3759
|
+
);
|
|
3760
|
+
}
|
|
3761
|
+
if (!sessionOwner.account.signTypedData) {
|
|
3762
|
+
throw new SetupError(
|
|
3763
|
+
"Couldn't prepare account.",
|
|
3764
|
+
"client"
|
|
3765
|
+
);
|
|
3766
|
+
}
|
|
3767
|
+
const typedData = setup.sessionDetailsUnsigned.data;
|
|
3768
|
+
const signature = await sessionOwner.account.signTypedData({
|
|
3769
|
+
domain: typedData.domain,
|
|
3770
|
+
types: typedData.types,
|
|
3771
|
+
primaryType: typedData.primaryType,
|
|
3772
|
+
message: typedData.message
|
|
3773
|
+
});
|
|
3774
|
+
const sessionDetails = buildSessionDetails(
|
|
3775
|
+
setup.sessionDetailsUnsigned,
|
|
3776
|
+
signature
|
|
3777
|
+
);
|
|
3778
|
+
const registerResult = await service.registerAccount({
|
|
3779
|
+
address: smartAccount,
|
|
3780
|
+
accountParams: {
|
|
3781
|
+
factory: setup.accountParams.factory,
|
|
3782
|
+
factoryData: setup.accountParams.factoryData,
|
|
3783
|
+
sessionDetails
|
|
3784
|
+
},
|
|
3785
|
+
eoaAddress: input.ownerAddress,
|
|
3786
|
+
sessionOwner: sessionOwner.address,
|
|
3787
|
+
target: {
|
|
3788
|
+
chain: toEvmCaip2(input.targetChain),
|
|
3789
|
+
token: input.targetToken,
|
|
3790
|
+
...input.recipient && { recipient: input.recipient },
|
|
3791
|
+
...input.postBridgeActions?.length && {
|
|
3792
|
+
postBridgeActions: input.postBridgeActions
|
|
3793
|
+
},
|
|
3794
|
+
...input.outputTokenRules?.length && {
|
|
3795
|
+
outputTokenRules: input.outputTokenRules
|
|
3796
|
+
},
|
|
3797
|
+
...input.rejectUnmapped != null && {
|
|
3798
|
+
rejectUnmapped: input.rejectUnmapped
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
});
|
|
3802
|
+
return {
|
|
3803
|
+
smartAccount,
|
|
3804
|
+
sessionOwnerAddress: sessionOwner.address,
|
|
3805
|
+
solanaDepositAddress: enableSolana ? registerResult.solanaDepositAddress : void 0,
|
|
3806
|
+
cacheKey,
|
|
3807
|
+
isRegistered: true
|
|
3808
|
+
};
|
|
3809
|
+
} catch (error) {
|
|
3810
|
+
debugError(debug, "account-setup", "setup:failed", error, {
|
|
3811
|
+
owner: input.ownerAddress
|
|
3812
|
+
});
|
|
3813
|
+
if (error instanceof SetupError) throw error;
|
|
3814
|
+
throw mapError(error);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
function mapError(error) {
|
|
3818
|
+
if (error instanceof TypeError) {
|
|
3819
|
+
return new SetupError(
|
|
3820
|
+
"Couldn't reach the deposit service. Please check your connection.",
|
|
3821
|
+
"network"
|
|
3822
|
+
);
|
|
3823
|
+
}
|
|
3824
|
+
if (error instanceof Error) {
|
|
3825
|
+
const statusMatch = error.message.match(/\b(4\d{2}|5\d{2})\b/);
|
|
3826
|
+
if (statusMatch) {
|
|
3827
|
+
const status = Number(statusMatch[1]);
|
|
3828
|
+
if (status >= 500) {
|
|
3829
|
+
return new SetupError(
|
|
3830
|
+
"Deposit service is temporarily unavailable. Please try again shortly.",
|
|
3831
|
+
"server"
|
|
3832
|
+
);
|
|
3833
|
+
}
|
|
3834
|
+
return new SetupError("Couldn't prepare account.", "client");
|
|
3835
|
+
}
|
|
3836
|
+
return new SetupError(
|
|
3837
|
+
"Deposit service is temporarily unavailable. Please try again shortly.",
|
|
3838
|
+
"unknown"
|
|
3839
|
+
);
|
|
3840
|
+
}
|
|
3841
|
+
return new SetupError(
|
|
3842
|
+
"Deposit service is temporarily unavailable. Please try again shortly.",
|
|
3843
|
+
"unknown"
|
|
3844
|
+
);
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3240
3847
|
// src/DepositFlow.tsx
|
|
3241
|
-
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3848
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3849
|
+
function AccountPreparingSkeleton({
|
|
3850
|
+
errorMessage,
|
|
3851
|
+
onRetry
|
|
3852
|
+
}) {
|
|
3853
|
+
return /* @__PURE__ */ jsxs10("div", { className: "rs-step", children: [
|
|
3854
|
+
/* @__PURE__ */ jsx10("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: /* @__PURE__ */ jsx10("div", { className: "rs-loading-state", children: /* @__PURE__ */ jsx10("div", { className: "rs-loading-text", children: errorMessage ? /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
3855
|
+
/* @__PURE__ */ jsx10("div", { className: "rs-loading-title rs-text-error", children: "Couldn\u2019t prepare account" }),
|
|
3856
|
+
/* @__PURE__ */ jsx10("div", { className: "rs-loading-subtitle", children: errorMessage })
|
|
3857
|
+
] }) : /* @__PURE__ */ jsx10("div", { className: "rs-loading-title", children: "Preparing\u2026" }) }) }) }),
|
|
3858
|
+
errorMessage && onRetry && /* @__PURE__ */ jsx10("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx10(
|
|
3859
|
+
"button",
|
|
3860
|
+
{
|
|
3861
|
+
type: "button",
|
|
3862
|
+
className: "rs-button rs-button--default rs-button--full-width",
|
|
3863
|
+
onClick: onRetry,
|
|
3864
|
+
children: /* @__PURE__ */ jsx10("span", { children: "Try again" })
|
|
3865
|
+
}
|
|
3866
|
+
) })
|
|
3867
|
+
] });
|
|
3868
|
+
}
|
|
3869
|
+
function SetupUpdatingBanner({
|
|
3870
|
+
status,
|
|
3871
|
+
message
|
|
3872
|
+
}) {
|
|
3873
|
+
if (status === "error") {
|
|
3874
|
+
return /* @__PURE__ */ jsx10("div", { className: "rs-deposit-address-error", role: "alert", children: message ?? "Couldn't update deposit details \u2014 please retry." });
|
|
3875
|
+
}
|
|
3876
|
+
return /* @__PURE__ */ jsx10("div", { className: "rs-loading-state", style: { padding: "8px 16px" }, children: /* @__PURE__ */ jsx10("div", { className: "rs-loading-text", children: /* @__PURE__ */ jsx10("div", { className: "rs-loading-subtitle", children: "Updating deposit details\u2026" }) }) });
|
|
3877
|
+
}
|
|
3242
3878
|
var QR_AUTO_ADVANCE_HYDRATION_GRACE_MS = 1e3;
|
|
3243
3879
|
function isSameRoute2(sourceChain, sourceToken, targetChain, targetToken) {
|
|
3244
3880
|
return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
|
|
@@ -3246,37 +3882,39 @@ function isSameRoute2(sourceChain, sourceToken, targetChain, targetToken) {
|
|
|
3246
3882
|
function getAddressKey(address) {
|
|
3247
3883
|
return address ? address.toLowerCase() : null;
|
|
3248
3884
|
}
|
|
3249
|
-
function deriveStep(flow, d, p) {
|
|
3885
|
+
function deriveStep(flow, d, p, activeEntry) {
|
|
3250
3886
|
const flowStep = flow.step;
|
|
3887
|
+
const smartAccount = activeEntry.smartAccount;
|
|
3888
|
+
const solanaDepositAddress = activeEntry.solanaDepositAddress;
|
|
3251
3889
|
switch (flowStep) {
|
|
3252
3890
|
case "connect":
|
|
3253
3891
|
case "setup":
|
|
3254
3892
|
return { type: "setup" };
|
|
3255
3893
|
case "deposit-address":
|
|
3256
|
-
if (!
|
|
3894
|
+
if (!smartAccount) return { type: "setup" };
|
|
3257
3895
|
return {
|
|
3258
3896
|
type: "deposit-address",
|
|
3259
|
-
smartAccount
|
|
3260
|
-
solanaDepositAddress:
|
|
3897
|
+
smartAccount,
|
|
3898
|
+
solanaDepositAddress: solanaDepositAddress ?? void 0
|
|
3261
3899
|
};
|
|
3262
3900
|
case "select-asset":
|
|
3263
|
-
if (!
|
|
3264
|
-
return { type: "select-asset", smartAccount
|
|
3901
|
+
if (!smartAccount) return { type: "setup" };
|
|
3902
|
+
return { type: "select-asset", smartAccount };
|
|
3265
3903
|
case "amount":
|
|
3266
|
-
if (!
|
|
3904
|
+
if (!smartAccount || !d.selectedAsset) return { type: "setup" };
|
|
3267
3905
|
return {
|
|
3268
3906
|
type: "amount",
|
|
3269
|
-
smartAccount
|
|
3907
|
+
smartAccount,
|
|
3270
3908
|
asset: d.selectedAsset,
|
|
3271
3909
|
amount: d.amount ?? void 0
|
|
3272
3910
|
};
|
|
3273
3911
|
case "confirm":
|
|
3274
|
-
if (!
|
|
3912
|
+
if (!smartAccount || !d.selectedAsset || !d.amount || !d.targetAmount) {
|
|
3275
3913
|
return { type: "setup" };
|
|
3276
3914
|
}
|
|
3277
3915
|
return {
|
|
3278
3916
|
type: "confirm",
|
|
3279
|
-
smartAccount
|
|
3917
|
+
smartAccount,
|
|
3280
3918
|
asset: d.selectedAsset,
|
|
3281
3919
|
amount: d.amount,
|
|
3282
3920
|
targetAmount: d.targetAmount,
|
|
@@ -3285,33 +3923,36 @@ function deriveStep(flow, d, p) {
|
|
|
3285
3923
|
liquidityWarning: d.liquidityWarning ?? void 0
|
|
3286
3924
|
};
|
|
3287
3925
|
case "solana-token-select":
|
|
3288
|
-
if (!
|
|
3926
|
+
if (!smartAccount || !solanaDepositAddress) return { type: "setup" };
|
|
3289
3927
|
return {
|
|
3290
3928
|
type: "solana-token-select",
|
|
3291
|
-
smartAccount
|
|
3292
|
-
solanaDepositAddress
|
|
3929
|
+
smartAccount,
|
|
3930
|
+
solanaDepositAddress
|
|
3293
3931
|
};
|
|
3294
3932
|
case "solana-amount":
|
|
3295
|
-
if (!
|
|
3933
|
+
if (!smartAccount || !solanaDepositAddress || !d.selectedSolanaToken || d.balance === null || d.balanceUsd === null) {
|
|
3296
3934
|
return { type: "setup" };
|
|
3297
3935
|
}
|
|
3298
3936
|
return {
|
|
3299
3937
|
type: "solana-amount",
|
|
3300
|
-
smartAccount
|
|
3301
|
-
solanaDepositAddress
|
|
3938
|
+
smartAccount,
|
|
3939
|
+
solanaDepositAddress,
|
|
3302
3940
|
token: d.selectedSolanaToken,
|
|
3303
3941
|
balance: d.balance,
|
|
3304
3942
|
balanceUsd: d.balanceUsd,
|
|
3305
3943
|
inputAmountUsd: d.inputAmountUsd ?? void 0
|
|
3306
3944
|
};
|
|
3945
|
+
case "dapp-import-asset-select":
|
|
3946
|
+
if (!smartAccount) return { type: "setup" };
|
|
3947
|
+
return { type: "dapp-import-asset-select", smartAccount };
|
|
3307
3948
|
case "solana-confirm":
|
|
3308
|
-
if (!
|
|
3949
|
+
if (!smartAccount || !solanaDepositAddress || !d.selectedSolanaToken || !d.amount || !d.inputAmountUsd || !d.targetAmount || d.balance === null || d.balanceUsd === null) {
|
|
3309
3950
|
return { type: "setup" };
|
|
3310
3951
|
}
|
|
3311
3952
|
return {
|
|
3312
3953
|
type: "solana-confirm",
|
|
3313
|
-
smartAccount
|
|
3314
|
-
solanaDepositAddress
|
|
3954
|
+
smartAccount,
|
|
3955
|
+
solanaDepositAddress,
|
|
3315
3956
|
token: d.selectedSolanaToken,
|
|
3316
3957
|
sourceAmount: d.amount,
|
|
3317
3958
|
inputAmountUsd: d.inputAmountUsd,
|
|
@@ -3321,13 +3962,13 @@ function deriveStep(flow, d, p) {
|
|
|
3321
3962
|
balanceUsd: d.balanceUsd
|
|
3322
3963
|
};
|
|
3323
3964
|
case "processing":
|
|
3324
|
-
if (!
|
|
3965
|
+
if (!smartAccount || !p.txHash || !d.amount || d.sourceChain === null || d.sourceChain === "unknown" || !d.sourceToken) {
|
|
3325
3966
|
return { type: "setup" };
|
|
3326
3967
|
}
|
|
3327
3968
|
return {
|
|
3328
3969
|
type: "processing",
|
|
3329
|
-
smartAccount
|
|
3330
|
-
solanaDepositAddress:
|
|
3970
|
+
smartAccount,
|
|
3971
|
+
solanaDepositAddress: solanaDepositAddress ?? void 0,
|
|
3331
3972
|
txHash: p.txHash,
|
|
3332
3973
|
sourceChain: d.sourceChain,
|
|
3333
3974
|
sourceToken: d.sourceToken,
|
|
@@ -3338,6 +3979,19 @@ function deriveStep(flow, d, p) {
|
|
|
3338
3979
|
};
|
|
3339
3980
|
}
|
|
3340
3981
|
}
|
|
3982
|
+
function resolveOwnerForMode(mode, ctx) {
|
|
3983
|
+
switch (mode) {
|
|
3984
|
+
case "deposit-address":
|
|
3985
|
+
case "solana-wallet":
|
|
3986
|
+
return ctx.dappAddress ?? null;
|
|
3987
|
+
case "wallet":
|
|
3988
|
+
return ctx.walletOwner ?? null;
|
|
3989
|
+
case "dapp-import":
|
|
3990
|
+
return ctx.dappImportOwner ?? null;
|
|
3991
|
+
default:
|
|
3992
|
+
return null;
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3341
3995
|
function DepositFlow({
|
|
3342
3996
|
dappWalletClient,
|
|
3343
3997
|
dappPublicClient,
|
|
@@ -3358,6 +4012,7 @@ function DepositFlow({
|
|
|
3358
4012
|
forceRegister = false,
|
|
3359
4013
|
waitForFinalTx = true,
|
|
3360
4014
|
enableSolana = true,
|
|
4015
|
+
dappImports,
|
|
3361
4016
|
reownWallet,
|
|
3362
4017
|
onConnect,
|
|
3363
4018
|
onDisconnect,
|
|
@@ -3385,53 +4040,38 @@ function DepositFlow({
|
|
|
3385
4040
|
const flowSlice = useDepositStore((s) => s.flow);
|
|
3386
4041
|
const depositSlice = useDepositStore((s) => s.deposit);
|
|
3387
4042
|
const processingSlice = useDepositStore((s) => s.processing);
|
|
3388
|
-
const
|
|
3389
|
-
() => deriveStep(flowSlice, depositSlice, processingSlice),
|
|
3390
|
-
[flowSlice, depositSlice, processingSlice]
|
|
3391
|
-
);
|
|
4043
|
+
const setupSlice = useDepositStore((s) => s.setup);
|
|
3392
4044
|
const flowMode = flowSlice.mode;
|
|
3393
4045
|
const isConnectSelectionConfirmed = flowSlice.isConnectSelectionConfirmed;
|
|
3394
4046
|
const hasNavigatedBack = flowSlice.hasNavigatedBack;
|
|
3395
4047
|
const selectedWalletId = useDepositStore(selectedWalletIdSelector);
|
|
3396
|
-
const
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
);
|
|
3400
|
-
const
|
|
3401
|
-
|
|
3402
|
-
[storeApi]
|
|
3403
|
-
);
|
|
3404
|
-
const setSelectedWalletId = useCallback4(
|
|
3405
|
-
(walletId) => storeApi.dispatch({ type: "wallet/id-selected", walletId }),
|
|
3406
|
-
[storeApi]
|
|
3407
|
-
);
|
|
3408
|
-
const [totalBalanceUsd, setTotalBalanceUsd] = useState10(0);
|
|
3409
|
-
const [hasQrAutoAdvanceGraceElapsed, setHasQrAutoAdvanceGraceElapsed] = useState10(() => !hasInitialWalletHydrationPending);
|
|
3410
|
-
const portfolioAssetsRef = useRef6([]);
|
|
3411
|
-
const stableWalletSignerRef = useRef6(null);
|
|
3412
|
-
const stableWalletSelectionKeyRef = useRef6(null);
|
|
3413
|
-
const logFlow = useCallback4(
|
|
4048
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = useState9(0);
|
|
4049
|
+
const [hasQrAutoAdvanceGraceElapsed, setHasQrAutoAdvanceGraceElapsed] = useState9(() => !hasInitialWalletHydrationPending);
|
|
4050
|
+
const portfolioAssetsRef = useRef5([]);
|
|
4051
|
+
const stableWalletSignerRef = useRef5(null);
|
|
4052
|
+
const stableWalletSelectionKeyRef = useRef5(null);
|
|
4053
|
+
const logFlow = useCallback3(
|
|
3414
4054
|
(message, data) => {
|
|
3415
4055
|
debugLog(debug, "deposit-flow", message, data);
|
|
3416
4056
|
},
|
|
3417
4057
|
[debug]
|
|
3418
4058
|
);
|
|
3419
|
-
const logFlowError =
|
|
4059
|
+
const logFlowError = useCallback3(
|
|
3420
4060
|
(message, error, data) => {
|
|
3421
4061
|
debugError(debug, "deposit-flow", message, error, data);
|
|
3422
4062
|
},
|
|
3423
4063
|
[debug]
|
|
3424
4064
|
);
|
|
3425
|
-
const handleAssetsLoaded =
|
|
4065
|
+
const handleAssetsLoaded = useCallback3((assets) => {
|
|
3426
4066
|
portfolioAssetsRef.current = assets;
|
|
3427
4067
|
}, []);
|
|
3428
|
-
const getTokenPriceUsd =
|
|
4068
|
+
const getTokenPriceUsd = useCallback3((symbol) => {
|
|
3429
4069
|
const sym = symbol.toLowerCase();
|
|
3430
4070
|
for (const asset of portfolioAssetsRef.current) {
|
|
3431
4071
|
if (asset.symbol.toLowerCase() === sym && asset.balanceUsd && asset.balance) {
|
|
3432
4072
|
try {
|
|
3433
4073
|
const balanceUnits = Number(
|
|
3434
|
-
|
|
4074
|
+
formatUnits7(BigInt(asset.balance), asset.decimals)
|
|
3435
4075
|
);
|
|
3436
4076
|
if (balanceUnits > 0) return asset.balanceUsd / balanceUnits;
|
|
3437
4077
|
} catch {
|
|
@@ -3507,8 +4147,8 @@ function DepositFlow({
|
|
|
3507
4147
|
const isWalletHydrationPending = Boolean(
|
|
3508
4148
|
dappAddress && !hasWalletOptions && (hasDappWalletClientProp && dappWalletClient === void 0 || reownWallet && !hasReownSession && !reownWallet.isReady)
|
|
3509
4149
|
);
|
|
3510
|
-
const showConnectStep = flowMode === null && !
|
|
3511
|
-
|
|
4150
|
+
const showConnectStep = flowMode === null && !isConnectSelectionConfirmed;
|
|
4151
|
+
useEffect8(() => {
|
|
3512
4152
|
if (!isWalletHydrationPending) {
|
|
3513
4153
|
setHasQrAutoAdvanceGraceElapsed(true);
|
|
3514
4154
|
return;
|
|
@@ -3520,7 +4160,7 @@ function DepositFlow({
|
|
|
3520
4160
|
return () => window.clearTimeout(timeout);
|
|
3521
4161
|
}, [isWalletHydrationPending]);
|
|
3522
4162
|
const walletSelectionKey = useMemo6(() => {
|
|
3523
|
-
if (flowMode !== "wallet") return null;
|
|
4163
|
+
if (flowMode !== "wallet" && flowMode !== "dapp-import") return null;
|
|
3524
4164
|
if (canAutoLock) {
|
|
3525
4165
|
return getAddressKey(connectedWalletAddress);
|
|
3526
4166
|
}
|
|
@@ -3599,8 +4239,8 @@ function DepositFlow({
|
|
|
3599
4239
|
reownWallet,
|
|
3600
4240
|
targetChain
|
|
3601
4241
|
]);
|
|
3602
|
-
|
|
3603
|
-
if (flowMode !== "wallet") {
|
|
4242
|
+
useEffect8(() => {
|
|
4243
|
+
if (flowMode !== "wallet" && flowMode !== "dapp-import") {
|
|
3604
4244
|
stableWalletSelectionKeyRef.current = null;
|
|
3605
4245
|
stableWalletSignerRef.current = null;
|
|
3606
4246
|
return;
|
|
@@ -3624,7 +4264,7 @@ function DepositFlow({
|
|
|
3624
4264
|
switchChain: void 0
|
|
3625
4265
|
};
|
|
3626
4266
|
}
|
|
3627
|
-
if (flowMode !== "wallet") {
|
|
4267
|
+
if (flowMode !== "wallet" && flowMode !== "dapp-import") {
|
|
3628
4268
|
return null;
|
|
3629
4269
|
}
|
|
3630
4270
|
if (walletSignerContext) {
|
|
@@ -3642,8 +4282,93 @@ function DepositFlow({
|
|
|
3642
4282
|
walletSignerContext,
|
|
3643
4283
|
walletSelectionKey
|
|
3644
4284
|
]);
|
|
3645
|
-
const
|
|
3646
|
-
|
|
4285
|
+
const selectedEvmWalletOwner = useMemo6(() => {
|
|
4286
|
+
if (!selectedWalletId) return null;
|
|
4287
|
+
const opt = walletOptions.find((o) => o.id === selectedWalletId);
|
|
4288
|
+
if (opt?.kind === "external" && opt.address) {
|
|
4289
|
+
return opt.address;
|
|
4290
|
+
}
|
|
4291
|
+
if (opt?.kind === "connected" && opt.address) {
|
|
4292
|
+
return opt.address;
|
|
4293
|
+
}
|
|
4294
|
+
return null;
|
|
4295
|
+
}, [selectedWalletId, walletOptions]);
|
|
4296
|
+
const dappImportOwner = useMemo6(() => {
|
|
4297
|
+
if (selectedEvmWalletOwner) return selectedEvmWalletOwner;
|
|
4298
|
+
if (reownWallet?.address && reownWallet.isConnected) {
|
|
4299
|
+
return reownWallet.address;
|
|
4300
|
+
}
|
|
4301
|
+
if (connectedWalletAddress) return connectedWalletAddress;
|
|
4302
|
+
return null;
|
|
4303
|
+
}, [
|
|
4304
|
+
selectedEvmWalletOwner,
|
|
4305
|
+
reownWallet?.address,
|
|
4306
|
+
reownWallet?.isConnected,
|
|
4307
|
+
connectedWalletAddress
|
|
4308
|
+
]);
|
|
4309
|
+
const activeOwner = useMemo6(
|
|
4310
|
+
() => resolveOwnerForMode(flowMode, {
|
|
4311
|
+
dappAddress,
|
|
4312
|
+
walletOwner: signerContext?.ownerAddress ?? (canAutoLock ? connectedWalletAddress : selectedEvmWalletOwner),
|
|
4313
|
+
dappImportOwner
|
|
4314
|
+
}),
|
|
4315
|
+
[
|
|
4316
|
+
flowMode,
|
|
4317
|
+
dappAddress,
|
|
4318
|
+
signerContext?.ownerAddress,
|
|
4319
|
+
canAutoLock,
|
|
4320
|
+
connectedWalletAddress,
|
|
4321
|
+
selectedEvmWalletOwner,
|
|
4322
|
+
dappImportOwner
|
|
4323
|
+
]
|
|
4324
|
+
);
|
|
4325
|
+
const activeEntry = useMemo6(
|
|
4326
|
+
() => readSetupForOwner(setupSlice, activeOwner),
|
|
4327
|
+
[setupSlice, activeOwner]
|
|
4328
|
+
);
|
|
4329
|
+
const lastActiveSetupLifecycleKeyRef = useRef5(null);
|
|
4330
|
+
useEffect8(() => {
|
|
4331
|
+
if (!flowMode || !isConnectSelectionConfirmed) {
|
|
4332
|
+
lastActiveSetupLifecycleKeyRef.current = null;
|
|
4333
|
+
return;
|
|
4334
|
+
}
|
|
4335
|
+
if (!activeOwner || activeEntry.status !== "ready" || !activeEntry.smartAccount) {
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
const lifecycleKey = [
|
|
4339
|
+
activeOwner.toLowerCase(),
|
|
4340
|
+
activeEntry.smartAccount.toLowerCase(),
|
|
4341
|
+
activeEntry.solanaDepositAddress ?? ""
|
|
4342
|
+
].join(":");
|
|
4343
|
+
if (lastActiveSetupLifecycleKeyRef.current === lifecycleKey) {
|
|
4344
|
+
return;
|
|
4345
|
+
}
|
|
4346
|
+
lastActiveSetupLifecycleKeyRef.current = lifecycleKey;
|
|
4347
|
+
onLifecycleRef.current?.({
|
|
4348
|
+
type: "smart-account-changed",
|
|
4349
|
+
evm: activeEntry.smartAccount,
|
|
4350
|
+
solana: activeEntry.solanaDepositAddress ?? null
|
|
4351
|
+
});
|
|
4352
|
+
onLifecycleRef.current?.({
|
|
4353
|
+
type: "connected",
|
|
4354
|
+
address: activeOwner,
|
|
4355
|
+
smartAccount: activeEntry.smartAccount
|
|
4356
|
+
});
|
|
4357
|
+
}, [
|
|
4358
|
+
flowMode,
|
|
4359
|
+
isConnectSelectionConfirmed,
|
|
4360
|
+
activeOwner,
|
|
4361
|
+
activeEntry.status,
|
|
4362
|
+
activeEntry.smartAccount,
|
|
4363
|
+
activeEntry.solanaDepositAddress,
|
|
4364
|
+
onLifecycleRef
|
|
4365
|
+
]);
|
|
4366
|
+
const effectiveStep = useMemo6(
|
|
4367
|
+
() => deriveStep(flowSlice, depositSlice, processingSlice, activeEntry),
|
|
4368
|
+
[flowSlice, depositSlice, processingSlice, activeEntry]
|
|
4369
|
+
);
|
|
4370
|
+
const step = effectiveStep;
|
|
4371
|
+
const handleBack = useCallback3(() => {
|
|
3647
4372
|
const stepBeforeBack = storeApi.getState().flow.step;
|
|
3648
4373
|
storeApi.dispatch({
|
|
3649
4374
|
type: "back/requested",
|
|
@@ -3653,16 +4378,16 @@ function DepositFlow({
|
|
|
3653
4378
|
portfolioAssetsRef.current = [];
|
|
3654
4379
|
}
|
|
3655
4380
|
}, [storeApi, hasWalletOptions, reownWallet]);
|
|
3656
|
-
const canGoBackFromHere =
|
|
4381
|
+
const canGoBackFromHere = effectiveStep.type === "deposit-address" || effectiveStep.type === "solana-token-select" || effectiveStep.type === "solana-amount" || effectiveStep.type === "solana-confirm" || effectiveStep.type === "amount" || effectiveStep.type === "confirm" || effectiveStep.type === "dapp-import-asset-select" || effectiveStep.type === "select-asset" && signerContext && !canAutoLock;
|
|
3657
4382
|
const currentBackHandler = canGoBackFromHere ? handleBack : void 0;
|
|
3658
|
-
const currentScreen = showConnectStep ? "connect" :
|
|
3659
|
-
|
|
4383
|
+
const currentScreen = showConnectStep ? "connect" : effectiveStep.type;
|
|
4384
|
+
useEffect8(() => {
|
|
3660
4385
|
onStepChangeRef.current?.(currentBackHandler, currentScreen);
|
|
3661
4386
|
}, [currentBackHandler, currentScreen, onStepChangeRef]);
|
|
3662
|
-
const stepSendToken =
|
|
3663
|
-
const stepOpenEventKey =
|
|
3664
|
-
const lastStepOpenEventKeyRef =
|
|
3665
|
-
|
|
4387
|
+
const stepSendToken = effectiveStep.type === "amount" ? effectiveStep.asset.symbol : null;
|
|
4388
|
+
const stepOpenEventKey = effectiveStep.type === "select-asset" ? "select-asset" : effectiveStep.type === "deposit-address" ? "deposit-address" : effectiveStep.type === "amount" && stepSendToken ? `amount:${stepSendToken.toLowerCase()}` : null;
|
|
4389
|
+
const lastStepOpenEventKeyRef = useRef5(null);
|
|
4390
|
+
useEffect8(() => {
|
|
3666
4391
|
if (!stepOpenEventKey) {
|
|
3667
4392
|
lastStepOpenEventKeyRef.current = null;
|
|
3668
4393
|
return;
|
|
@@ -3671,13 +4396,13 @@ function DepositFlow({
|
|
|
3671
4396
|
return;
|
|
3672
4397
|
}
|
|
3673
4398
|
lastStepOpenEventKeyRef.current = stepOpenEventKey;
|
|
3674
|
-
if (
|
|
4399
|
+
if (effectiveStep.type === "select-asset") {
|
|
3675
4400
|
onEventRef.current?.({
|
|
3676
4401
|
type: "deposit_modal_connected_wallet_select_source_open",
|
|
3677
4402
|
total_balance_in_external_wallet: totalBalanceUsd,
|
|
3678
4403
|
pred_balance: totalBalanceUsd
|
|
3679
4404
|
});
|
|
3680
|
-
} else if (
|
|
4405
|
+
} else if (effectiveStep.type === "deposit-address") {
|
|
3681
4406
|
const chainName = getChainName(targetChain);
|
|
3682
4407
|
const tokenSymbol = getTokenSymbol(targetToken, targetChain);
|
|
3683
4408
|
onEventRef.current?.({
|
|
@@ -3686,7 +4411,7 @@ function DepositFlow({
|
|
|
3686
4411
|
default_token: tokenSymbol,
|
|
3687
4412
|
pred_balance: totalBalanceUsd
|
|
3688
4413
|
});
|
|
3689
|
-
} else if (
|
|
4414
|
+
} else if (effectiveStep.type === "amount" && stepSendToken) {
|
|
3690
4415
|
const receiveSymbol = getTokenSymbol(targetToken, targetChain);
|
|
3691
4416
|
onEventRef.current?.({
|
|
3692
4417
|
type: "deposit_modal_connected_wallet_enter_value_open",
|
|
@@ -3696,7 +4421,7 @@ function DepositFlow({
|
|
|
3696
4421
|
});
|
|
3697
4422
|
}
|
|
3698
4423
|
}, [
|
|
3699
|
-
|
|
4424
|
+
effectiveStep.type,
|
|
3700
4425
|
stepOpenEventKey,
|
|
3701
4426
|
stepSendToken,
|
|
3702
4427
|
targetChain,
|
|
@@ -3704,9 +4429,9 @@ function DepositFlow({
|
|
|
3704
4429
|
totalBalanceUsd,
|
|
3705
4430
|
onEventRef
|
|
3706
4431
|
]);
|
|
3707
|
-
|
|
4432
|
+
useEffect8(() => {
|
|
3708
4433
|
logFlow("state:changed", {
|
|
3709
|
-
step:
|
|
4434
|
+
step: effectiveStep.type,
|
|
3710
4435
|
flowMode,
|
|
3711
4436
|
targetChain,
|
|
3712
4437
|
targetToken,
|
|
@@ -3716,11 +4441,11 @@ function DepositFlow({
|
|
|
3716
4441
|
flowMode,
|
|
3717
4442
|
logFlow,
|
|
3718
4443
|
selectedWalletId,
|
|
3719
|
-
|
|
4444
|
+
effectiveStep.type,
|
|
3720
4445
|
targetChain,
|
|
3721
4446
|
targetToken
|
|
3722
4447
|
]);
|
|
3723
|
-
|
|
4448
|
+
useEffect8(() => {
|
|
3724
4449
|
onLifecycleRef.current?.({
|
|
3725
4450
|
type: "balance-changed",
|
|
3726
4451
|
totalUsd: totalBalanceUsd
|
|
@@ -3728,16 +4453,170 @@ function DepositFlow({
|
|
|
3728
4453
|
}, [totalBalanceUsd, onLifecycleRef]);
|
|
3729
4454
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
3730
4455
|
const isSolanaWalletMode = flowMode === "solana-wallet";
|
|
3731
|
-
const
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
4456
|
+
const isDappImportMode = flowMode === "dapp-import";
|
|
4457
|
+
const handleSelectTransferCrypto = useCallback3(() => {
|
|
4458
|
+
storeApi.dispatch({ type: "connect/transfer-crypto-selected" });
|
|
4459
|
+
}, [storeApi]);
|
|
4460
|
+
const handleConfirmWallet = useCallback3(
|
|
4461
|
+
(walletId) => {
|
|
4462
|
+
const selectedOption = walletOptions.find((o) => o.id === walletId);
|
|
4463
|
+
const mode = enableSolana && selectedOption?.kind === "solana" ? "solana-wallet" : "wallet";
|
|
4464
|
+
storeApi.dispatch({
|
|
4465
|
+
type: "connect/wallet-confirmed",
|
|
4466
|
+
walletId,
|
|
4467
|
+
mode
|
|
4468
|
+
});
|
|
4469
|
+
},
|
|
4470
|
+
[walletOptions, enableSolana, storeApi]
|
|
4471
|
+
);
|
|
4472
|
+
const enabledDappImportProviders = useMemo6(
|
|
4473
|
+
() => getEnabledProviders(dappImports),
|
|
4474
|
+
[dappImports]
|
|
4475
|
+
);
|
|
4476
|
+
const handleSelectDappImport = useCallback3(
|
|
4477
|
+
(providerId) => {
|
|
4478
|
+
const owner = dappImportOwner;
|
|
4479
|
+
if (owner) {
|
|
4480
|
+
const wallet = walletOptions.find(
|
|
4481
|
+
(o) => (o.address ?? null)?.toLowerCase() === owner.toLowerCase()
|
|
4482
|
+
);
|
|
4483
|
+
if (wallet) {
|
|
4484
|
+
storeApi.dispatch({
|
|
4485
|
+
type: "wallet/id-selected",
|
|
4486
|
+
walletId: wallet.id
|
|
4487
|
+
});
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
storeApi.dispatch({
|
|
4491
|
+
type: "dapp-import/provider-selected",
|
|
4492
|
+
providerId
|
|
4493
|
+
});
|
|
4494
|
+
},
|
|
4495
|
+
[storeApi, walletOptions, dappImportOwner]
|
|
4496
|
+
);
|
|
4497
|
+
const handleDappImportAssetSelected = useCallback3(
|
|
4498
|
+
(asset) => {
|
|
4499
|
+
storeApi.dispatch({ type: "dapp-import/asset-selected", asset });
|
|
4500
|
+
},
|
|
4501
|
+
[storeApi]
|
|
4502
|
+
);
|
|
4503
|
+
useEffect8(() => {
|
|
4504
|
+
if (!dappImportOwner || enabledDappImportProviders.length === 0) {
|
|
4505
|
+
storeApi.dispatch({ type: "dapp-import/availability-cleared" });
|
|
4506
|
+
return;
|
|
4507
|
+
}
|
|
4508
|
+
const controller = new AbortController();
|
|
4509
|
+
for (const provider of enabledDappImportProviders) {
|
|
4510
|
+
storeApi.dispatch({
|
|
4511
|
+
type: "dapp-import/availability-loading",
|
|
4512
|
+
providerId: provider.id,
|
|
4513
|
+
owner: dappImportOwner
|
|
4514
|
+
});
|
|
4515
|
+
provider.fetchAvailability({
|
|
4516
|
+
eoa: dappImportOwner,
|
|
4517
|
+
getPublicClient: (chainId) => {
|
|
4518
|
+
try {
|
|
4519
|
+
return getPublicClient(chainId);
|
|
4520
|
+
} catch {
|
|
4521
|
+
return null;
|
|
4522
|
+
}
|
|
4523
|
+
},
|
|
4524
|
+
signal: controller.signal
|
|
4525
|
+
}).then((availability) => {
|
|
4526
|
+
if (controller.signal.aborted) return;
|
|
4527
|
+
storeApi.dispatch({
|
|
4528
|
+
type: "dapp-import/availability-loaded",
|
|
4529
|
+
providerId: provider.id,
|
|
4530
|
+
owner: dappImportOwner,
|
|
4531
|
+
availability
|
|
4532
|
+
});
|
|
4533
|
+
}).catch(() => {
|
|
4534
|
+
if (controller.signal.aborted) return;
|
|
4535
|
+
storeApi.dispatch({
|
|
4536
|
+
type: "dapp-import/availability-loaded",
|
|
4537
|
+
providerId: provider.id,
|
|
4538
|
+
owner: dappImportOwner,
|
|
4539
|
+
availability: null
|
|
4540
|
+
});
|
|
4541
|
+
});
|
|
4542
|
+
}
|
|
4543
|
+
return () => controller.abort();
|
|
4544
|
+
}, [dappImportOwner, enabledDappImportProviders, storeApi]);
|
|
4545
|
+
const dappImportAvailability = useDepositStore((s) => s.dappImport.availability);
|
|
4546
|
+
const dappImportAvailabilityOwner = useDepositStore(
|
|
4547
|
+
(s) => s.dappImport.availabilityOwner
|
|
4548
|
+
);
|
|
4549
|
+
const activeDappImportProviderId = useDepositStore(
|
|
4550
|
+
(s) => s.dappImport.activeProviderId
|
|
4551
|
+
);
|
|
4552
|
+
const connectStepDappImports = useMemo6(
|
|
4553
|
+
() => enabledDappImportProviders.map((provider) => {
|
|
4554
|
+
const availabilityEntry = dappImportOwner && dappImportAvailabilityOwner?.toLowerCase() === dappImportOwner.toLowerCase() ? dappImportAvailability[provider.id] : void 0;
|
|
4555
|
+
const dappImportSetup = readSetupForOwner(setupSlice, dappImportOwner);
|
|
4556
|
+
const baseRow = {
|
|
4557
|
+
id: provider.id,
|
|
4558
|
+
label: provider.label,
|
|
4559
|
+
icon: provider.icon
|
|
4560
|
+
};
|
|
4561
|
+
if (availabilityEntry === "loading" || availabilityEntry === void 0) {
|
|
4562
|
+
return { ...baseRow, status: "loading" };
|
|
4563
|
+
}
|
|
4564
|
+
if (availabilityEntry === null) {
|
|
4565
|
+
return {
|
|
4566
|
+
...baseRow,
|
|
4567
|
+
status: { enabled: false, reason: "No balance" }
|
|
4568
|
+
};
|
|
4569
|
+
}
|
|
4570
|
+
if (dappImportSetup.status === "loading" || !dappImportOwner) {
|
|
4571
|
+
return { ...baseRow, status: "loading" };
|
|
4572
|
+
}
|
|
4573
|
+
if (dappImportSetup.status === "error") {
|
|
4574
|
+
return {
|
|
4575
|
+
...baseRow,
|
|
4576
|
+
status: {
|
|
4577
|
+
enabled: false,
|
|
4578
|
+
reason: "Couldn't prepare account \u2014 tap to retry",
|
|
4579
|
+
retryable: true
|
|
4580
|
+
}
|
|
4581
|
+
};
|
|
4582
|
+
}
|
|
4583
|
+
return {
|
|
4584
|
+
...baseRow,
|
|
4585
|
+
status: {
|
|
4586
|
+
enabled: true,
|
|
4587
|
+
balanceUsd: availabilityEntry.totalUsd
|
|
4588
|
+
}
|
|
4589
|
+
};
|
|
4590
|
+
}),
|
|
4591
|
+
[
|
|
4592
|
+
enabledDappImportProviders,
|
|
4593
|
+
dappImportAvailability,
|
|
4594
|
+
dappImportAvailabilityOwner,
|
|
4595
|
+
setupSlice,
|
|
4596
|
+
dappImportOwner
|
|
4597
|
+
]
|
|
4598
|
+
);
|
|
4599
|
+
const activeDappImportProvider = useMemo6(() => {
|
|
4600
|
+
if (!activeDappImportProviderId) return null;
|
|
4601
|
+
return enabledDappImportProviders.find(
|
|
4602
|
+
(p) => p.id === activeDappImportProviderId
|
|
4603
|
+
) ?? null;
|
|
4604
|
+
}, [activeDappImportProviderId, enabledDappImportProviders]);
|
|
4605
|
+
const activeDappImportAvailability = useMemo6(() => {
|
|
4606
|
+
if (!activeDappImportProviderId) return null;
|
|
4607
|
+
if (!dappImportOwner || dappImportAvailabilityOwner?.toLowerCase() !== dappImportOwner.toLowerCase()) {
|
|
4608
|
+
return null;
|
|
4609
|
+
}
|
|
4610
|
+
const entry = dappImportAvailability[activeDappImportProviderId];
|
|
4611
|
+
if (!entry || entry === "loading") return null;
|
|
4612
|
+
return entry;
|
|
4613
|
+
}, [
|
|
4614
|
+
activeDappImportProviderId,
|
|
4615
|
+
dappImportAvailability,
|
|
4616
|
+
dappImportAvailabilityOwner,
|
|
4617
|
+
dappImportOwner
|
|
4618
|
+
]);
|
|
4619
|
+
const handleNewDeposit = useCallback3(() => {
|
|
3741
4620
|
onLifecycleRef.current?.({
|
|
3742
4621
|
type: "smart-account-changed",
|
|
3743
4622
|
evm: null,
|
|
@@ -3748,64 +4627,123 @@ function DepositFlow({
|
|
|
3748
4627
|
stableWalletSignerRef.current = null;
|
|
3749
4628
|
stableWalletSelectionKeyRef.current = null;
|
|
3750
4629
|
}, [onLifecycleRef, storeApi]);
|
|
3751
|
-
const
|
|
3752
|
-
(
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
onErrorRef.current?.({
|
|
3765
|
-
message: "Solana deposit address not available. Please try again.",
|
|
3766
|
-
code: "SOLANA_SETUP_FAILED"
|
|
3767
|
-
});
|
|
3768
|
-
return;
|
|
3769
|
-
}
|
|
3770
|
-
if (!sessionKeyAddress) return;
|
|
3771
|
-
storeApi.dispatch({
|
|
3772
|
-
type: "setup/complete",
|
|
3773
|
-
smartAccount,
|
|
3774
|
-
smartAccountOwner: sessionKeyAddress,
|
|
3775
|
-
solanaDepositAddress
|
|
3776
|
-
});
|
|
3777
|
-
},
|
|
4630
|
+
const setupInputBase = useMemo6(
|
|
4631
|
+
() => ({
|
|
4632
|
+
targetChain,
|
|
4633
|
+
targetToken,
|
|
4634
|
+
signerAddress,
|
|
4635
|
+
sessionChainIds,
|
|
4636
|
+
recipient,
|
|
4637
|
+
postBridgeActions,
|
|
4638
|
+
outputTokenRules,
|
|
4639
|
+
rejectUnmapped,
|
|
4640
|
+
forceRegister,
|
|
4641
|
+
enableSolana
|
|
4642
|
+
}),
|
|
3778
4643
|
[
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
4644
|
+
targetChain,
|
|
4645
|
+
targetToken,
|
|
4646
|
+
signerAddress,
|
|
4647
|
+
sessionChainIds,
|
|
4648
|
+
recipient,
|
|
4649
|
+
postBridgeActions,
|
|
4650
|
+
outputTokenRules,
|
|
4651
|
+
rejectUnmapped,
|
|
4652
|
+
forceRegister,
|
|
4653
|
+
enableSolana
|
|
3786
4654
|
]
|
|
3787
4655
|
);
|
|
3788
|
-
const
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
4656
|
+
const desiredOwnersKey = useMemo6(() => {
|
|
4657
|
+
const owners = [];
|
|
4658
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4659
|
+
const push = (addr) => {
|
|
4660
|
+
if (!addr) return;
|
|
4661
|
+
const key = addr.toLowerCase();
|
|
4662
|
+
if (seen.has(key)) return;
|
|
4663
|
+
seen.add(key);
|
|
4664
|
+
owners.push(addr);
|
|
4665
|
+
};
|
|
4666
|
+
push(dappAddress);
|
|
4667
|
+
push(connectedWalletAddress);
|
|
4668
|
+
push(reownWallet?.address);
|
|
4669
|
+
push(dappImportOwner);
|
|
4670
|
+
return owners;
|
|
4671
|
+
}, [
|
|
4672
|
+
dappAddress,
|
|
4673
|
+
connectedWalletAddress,
|
|
4674
|
+
reownWallet?.address,
|
|
4675
|
+
dappImportOwner
|
|
4676
|
+
]);
|
|
4677
|
+
useEffect8(() => {
|
|
4678
|
+
desiredOwnersKey.forEach((owner) => {
|
|
4679
|
+
void (async () => {
|
|
4680
|
+
const input = {
|
|
4681
|
+
ownerAddress: owner,
|
|
4682
|
+
...setupInputBase
|
|
4683
|
+
};
|
|
4684
|
+
let sessionOwner;
|
|
4685
|
+
try {
|
|
4686
|
+
sessionOwner = await resolveSessionOwner(owner);
|
|
4687
|
+
} catch (error) {
|
|
4688
|
+
debugError(
|
|
4689
|
+
debug,
|
|
4690
|
+
"deposit-flow",
|
|
4691
|
+
"session-owner:resolve-failed",
|
|
4692
|
+
error,
|
|
4693
|
+
{ owner }
|
|
4694
|
+
);
|
|
4695
|
+
return;
|
|
4696
|
+
}
|
|
4697
|
+
const requestKey = computeRequestKey(input, sessionOwner.address);
|
|
4698
|
+
const cacheKey = computeCacheKey(input, sessionOwner.address);
|
|
4699
|
+
const cacheable = computeIsCacheable(input);
|
|
4700
|
+
const current = readSetupForOwner(
|
|
4701
|
+
storeApi.getState().setup,
|
|
4702
|
+
owner
|
|
4703
|
+
);
|
|
4704
|
+
if (current.requestKey === requestKey) {
|
|
4705
|
+
return;
|
|
4706
|
+
}
|
|
4707
|
+
storeApi.dispatch({
|
|
4708
|
+
type: "setup/started",
|
|
4709
|
+
owner,
|
|
4710
|
+
requestKey,
|
|
4711
|
+
cacheKey,
|
|
4712
|
+
cacheable
|
|
4713
|
+
});
|
|
4714
|
+
try {
|
|
4715
|
+
const result = await runAccountSetup(input, { service, debug });
|
|
4716
|
+
storeApi.dispatch({
|
|
4717
|
+
type: "setup/ready",
|
|
4718
|
+
owner,
|
|
4719
|
+
requestKey,
|
|
4720
|
+
result: {
|
|
4721
|
+
smartAccount: result.smartAccount,
|
|
4722
|
+
sessionOwnerAddress: result.sessionOwnerAddress,
|
|
4723
|
+
solanaDepositAddress: result.solanaDepositAddress,
|
|
4724
|
+
cacheKey: result.cacheKey
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
} catch (error) {
|
|
4728
|
+
const message = error instanceof SetupError ? error.message : "Deposit service is temporarily unavailable. Please try again shortly.";
|
|
4729
|
+
storeApi.dispatch({
|
|
4730
|
+
type: "setup/failed",
|
|
4731
|
+
owner,
|
|
4732
|
+
requestKey,
|
|
4733
|
+
message
|
|
4734
|
+
});
|
|
4735
|
+
}
|
|
4736
|
+
})();
|
|
4737
|
+
});
|
|
3800
4738
|
}, [
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
4739
|
+
desiredOwnersKey,
|
|
4740
|
+
setupInputBase,
|
|
4741
|
+
service,
|
|
4742
|
+
debug,
|
|
4743
|
+
storeApi,
|
|
4744
|
+
setupSlice.byOwner
|
|
3807
4745
|
]);
|
|
3808
|
-
const handleDepositAddressSubmitted =
|
|
4746
|
+
const handleDepositAddressSubmitted = useCallback3(
|
|
3809
4747
|
(data) => {
|
|
3810
4748
|
logFlow("deposit-address:detected", {
|
|
3811
4749
|
txHash: data.txHash,
|
|
@@ -3816,7 +4754,7 @@ function DepositFlow({
|
|
|
3816
4754
|
},
|
|
3817
4755
|
[logFlow, onLifecycleRef]
|
|
3818
4756
|
);
|
|
3819
|
-
const handleSolanaTokenContinue =
|
|
4757
|
+
const handleSolanaTokenContinue = useCallback3(
|
|
3820
4758
|
(token, balance, balanceUsd) => {
|
|
3821
4759
|
logFlow("solana:token:continue", { token: token.symbol });
|
|
3822
4760
|
storeApi.dispatch({
|
|
@@ -3829,7 +4767,7 @@ function DepositFlow({
|
|
|
3829
4767
|
},
|
|
3830
4768
|
[defaultAmount, logFlow, storeApi]
|
|
3831
4769
|
);
|
|
3832
|
-
const handleSolanaAmountContinue =
|
|
4770
|
+
const handleSolanaAmountContinue = useCallback3(
|
|
3833
4771
|
(token, sourceAmount, inputAmountUsd) => {
|
|
3834
4772
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
3835
4773
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
@@ -3851,7 +4789,7 @@ function DepositFlow({
|
|
|
3851
4789
|
},
|
|
3852
4790
|
[targetToken, targetChain, getTokenPriceUsd, logFlow, storeApi]
|
|
3853
4791
|
);
|
|
3854
|
-
const handleSolanaConfirmed =
|
|
4792
|
+
const handleSolanaConfirmed = useCallback3(
|
|
3855
4793
|
(txHash, amountUnits) => {
|
|
3856
4794
|
const tokenAtSubmit = storeApi.getState().deposit.selectedSolanaToken;
|
|
3857
4795
|
if (!tokenAtSubmit) return;
|
|
@@ -3878,17 +4816,7 @@ function DepositFlow({
|
|
|
3878
4816
|
},
|
|
3879
4817
|
[logFlow, onLifecycleRef, storeApi]
|
|
3880
4818
|
);
|
|
3881
|
-
const
|
|
3882
|
-
(addr, smartAccount) => {
|
|
3883
|
-
onLifecycleRef.current?.({
|
|
3884
|
-
type: "connected",
|
|
3885
|
-
address: addr,
|
|
3886
|
-
smartAccount
|
|
3887
|
-
});
|
|
3888
|
-
},
|
|
3889
|
-
[onLifecycleRef]
|
|
3890
|
-
);
|
|
3891
|
-
const handleAssetContinue = useCallback4(
|
|
4819
|
+
const handleAssetContinue = useCallback3(
|
|
3892
4820
|
(asset) => {
|
|
3893
4821
|
onEventRef.current?.({
|
|
3894
4822
|
type: "deposit_modal_connected_wallet_select_source_cta_click",
|
|
@@ -3906,8 +4834,13 @@ function DepositFlow({
|
|
|
3906
4834
|
},
|
|
3907
4835
|
[defaultAmount, onEventRef, totalBalanceUsd, storeApi]
|
|
3908
4836
|
);
|
|
3909
|
-
const handleAmountContinue =
|
|
4837
|
+
const handleAmountContinue = useCallback3(
|
|
3910
4838
|
(amount, targetAmount, balance, liquidityWarning) => {
|
|
4839
|
+
const entry = readSetupForOwner(
|
|
4840
|
+
storeApi.getState().setup,
|
|
4841
|
+
activeOwner
|
|
4842
|
+
);
|
|
4843
|
+
if (entry.status !== "ready") return;
|
|
3911
4844
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
3912
4845
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
3913
4846
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
@@ -3920,9 +4853,9 @@ function DepositFlow({
|
|
|
3920
4853
|
liquidityWarning
|
|
3921
4854
|
});
|
|
3922
4855
|
},
|
|
3923
|
-
[targetToken, targetChain, getTokenPriceUsd, storeApi]
|
|
4856
|
+
[targetToken, targetChain, getTokenPriceUsd, storeApi, activeOwner]
|
|
3924
4857
|
);
|
|
3925
|
-
const handleDepositSubmitted =
|
|
4858
|
+
const handleDepositSubmitted = useCallback3(
|
|
3926
4859
|
(txHash, chainId, amount, token) => {
|
|
3927
4860
|
logFlow("evm:submitted", {
|
|
3928
4861
|
txHash,
|
|
@@ -3930,18 +4863,22 @@ function DepositFlow({
|
|
|
3930
4863
|
sourceToken: token,
|
|
3931
4864
|
amount
|
|
3932
4865
|
});
|
|
4866
|
+
const asset = storeApi.getState().deposit.selectedAsset;
|
|
4867
|
+
const dappImport = asset && isDappImportAsset(asset) ? asset : null;
|
|
3933
4868
|
storeApi.dispatch({
|
|
3934
4869
|
type: "deposit/submitted",
|
|
3935
4870
|
txHash,
|
|
3936
4871
|
sourceChain: chainId,
|
|
3937
4872
|
sourceToken: token,
|
|
3938
4873
|
amount,
|
|
3939
|
-
|
|
4874
|
+
sourceSymbol: dappImport?.symbol,
|
|
4875
|
+
sourceDecimals: dappImport?.decimals,
|
|
4876
|
+
directTransfer: !dappImport && isSameRoute2(chainId, token, targetChain, targetToken)
|
|
3940
4877
|
});
|
|
3941
4878
|
},
|
|
3942
4879
|
[logFlow, storeApi, targetChain, targetToken]
|
|
3943
4880
|
);
|
|
3944
|
-
const handleDepositSubmittedCallback =
|
|
4881
|
+
const handleDepositSubmittedCallback = useCallback3(
|
|
3945
4882
|
(txHash, sourceChain, amount) => {
|
|
3946
4883
|
onLifecycleRef.current?.({
|
|
3947
4884
|
type: "submitted",
|
|
@@ -3952,7 +4889,7 @@ function DepositFlow({
|
|
|
3952
4889
|
},
|
|
3953
4890
|
[onLifecycleRef]
|
|
3954
4891
|
);
|
|
3955
|
-
const handleDepositComplete =
|
|
4892
|
+
const handleDepositComplete = useCallback3(
|
|
3956
4893
|
(txHash, destinationTxHash, context) => {
|
|
3957
4894
|
logFlow("deposit:complete", { txHash, destinationTxHash, ...context });
|
|
3958
4895
|
onLifecycleRef.current?.({
|
|
@@ -3964,153 +4901,166 @@ function DepositFlow({
|
|
|
3964
4901
|
},
|
|
3965
4902
|
[logFlow, onLifecycleRef]
|
|
3966
4903
|
);
|
|
3967
|
-
const handleDepositFailed =
|
|
4904
|
+
const handleDepositFailed = useCallback3(
|
|
3968
4905
|
(txHash, error) => {
|
|
3969
4906
|
logFlowError("deposit:failed", error, { txHash });
|
|
3970
4907
|
onLifecycleRef.current?.({ type: "failed", txHash, error });
|
|
3971
4908
|
},
|
|
3972
4909
|
[logFlowError, onLifecycleRef]
|
|
3973
4910
|
);
|
|
3974
|
-
const handleError =
|
|
4911
|
+
const handleError = useCallback3(
|
|
3975
4912
|
(message, code) => {
|
|
3976
4913
|
logFlowError("flow:error", message, { code });
|
|
3977
4914
|
onErrorRef.current?.({ message, code });
|
|
3978
4915
|
},
|
|
3979
4916
|
[logFlowError, onErrorRef]
|
|
3980
4917
|
);
|
|
3981
|
-
const handleTotalBalanceComputed =
|
|
4918
|
+
const handleTotalBalanceComputed = useCallback3((total) => {
|
|
3982
4919
|
setTotalBalanceUsd(total);
|
|
3983
4920
|
}, []);
|
|
3984
|
-
const selectedWalletIdEffective = useMemo6(() => {
|
|
3985
|
-
if (selectedWalletId) return selectedWalletId;
|
|
3986
|
-
if (walletOptions.length === 1) {
|
|
3987
|
-
return walletOptions[0].id;
|
|
3988
|
-
}
|
|
3989
|
-
return null;
|
|
3990
|
-
}, [selectedWalletId, walletOptions]);
|
|
3991
4921
|
const walletOptionsKey = useMemo6(
|
|
3992
4922
|
() => walletOptions.map((option) => option.id).join(","),
|
|
3993
4923
|
[walletOptions]
|
|
3994
4924
|
);
|
|
3995
|
-
|
|
4925
|
+
useEffect8(() => {
|
|
3996
4926
|
if (storeApi.getState().flow.mode) {
|
|
3997
4927
|
return;
|
|
3998
4928
|
}
|
|
3999
4929
|
storeApi.dispatch({ type: "wallet/cleared" });
|
|
4000
4930
|
const currentStep = storeApi.getState().flow.step;
|
|
4001
4931
|
if (currentStep !== "processing" && currentStep !== "confirm" && currentStep !== "solana-confirm" && currentStep !== "amount" && currentStep !== "solana-amount") {
|
|
4002
|
-
storeApi.dispatch({ type: "flow/step-set", step: "
|
|
4932
|
+
storeApi.dispatch({ type: "flow/step-set", step: "connect" });
|
|
4003
4933
|
}
|
|
4004
4934
|
}, [walletOptionsKey]);
|
|
4005
|
-
|
|
4006
|
-
if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
|
|
4935
|
+
useEffect8(() => {
|
|
4936
|
+
if (!showConnectStep && isConnectSelectionConfirmed && (flowMode === "wallet" || flowMode === "dapp-import") && !signerContext) {
|
|
4007
4937
|
storeApi.dispatch({ type: "wallet/cleared" });
|
|
4008
4938
|
}
|
|
4009
4939
|
}, [showConnectStep, isConnectSelectionConfirmed, flowMode, signerContext, storeApi]);
|
|
4010
|
-
|
|
4940
|
+
useEffect8(() => {
|
|
4011
4941
|
if (enableSolana || flowMode !== "solana-wallet") {
|
|
4012
4942
|
return;
|
|
4013
4943
|
}
|
|
4014
4944
|
storeApi.dispatch({ type: "wallet/cleared" });
|
|
4015
4945
|
if (storeApi.getState().flow.step !== "processing") {
|
|
4016
|
-
storeApi.dispatch({ type: "flow/step-set", step: "
|
|
4946
|
+
storeApi.dispatch({ type: "flow/step-set", step: "connect" });
|
|
4017
4947
|
}
|
|
4018
4948
|
}, [enableSolana, flowMode, storeApi]);
|
|
4019
|
-
|
|
4949
|
+
useEffect8(() => {
|
|
4020
4950
|
if (hasNavigatedBack || isConnectSelectionConfirmed || flowMode) {
|
|
4021
4951
|
return;
|
|
4022
4952
|
}
|
|
4023
|
-
if (hasWalletOptions) {
|
|
4024
|
-
const walletId = selectedWalletIdEffective;
|
|
4025
|
-
if (walletId) {
|
|
4026
|
-
const selectedOption = walletOptions.find((o) => o.id === walletId);
|
|
4027
|
-
setSelectedWalletId(walletId);
|
|
4028
|
-
if (enableSolana && selectedOption?.kind === "solana") {
|
|
4029
|
-
handleSelectSolanaWallet();
|
|
4030
|
-
} else {
|
|
4031
|
-
handleSelectProvider();
|
|
4032
|
-
}
|
|
4033
|
-
setIsConnectSelectionConfirmed(true);
|
|
4034
|
-
return;
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
4953
|
if (!hasWalletOptions && dappAddress && !hasReownSession && !dappWalletClient && hasQrAutoAdvanceGraceElapsed) {
|
|
4038
4954
|
handleSelectTransferCrypto();
|
|
4039
|
-
setIsConnectSelectionConfirmed(true);
|
|
4040
4955
|
}
|
|
4041
4956
|
}, [
|
|
4042
4957
|
hasWalletOptions,
|
|
4043
4958
|
hasReownSession,
|
|
4044
4959
|
hasQrAutoAdvanceGraceElapsed,
|
|
4045
|
-
enableSolana,
|
|
4046
4960
|
isConnectSelectionConfirmed,
|
|
4047
4961
|
flowMode,
|
|
4048
4962
|
hasNavigatedBack,
|
|
4049
|
-
selectedWalletIdEffective,
|
|
4050
4963
|
dappAddress,
|
|
4051
4964
|
dappWalletClient,
|
|
4052
|
-
|
|
4053
|
-
handleSelectProvider,
|
|
4054
|
-
handleSelectSolanaWallet,
|
|
4055
|
-
handleSelectTransferCrypto,
|
|
4056
|
-
setSelectedWalletId,
|
|
4057
|
-
setIsConnectSelectionConfirmed
|
|
4965
|
+
handleSelectTransferCrypto
|
|
4058
4966
|
]);
|
|
4967
|
+
const walletRows = useMemo6(() => {
|
|
4968
|
+
return walletOptions.map((option) => {
|
|
4969
|
+
const ownerForRow = option.kind === "solana" ? dappAddress : option.address ?? null;
|
|
4970
|
+
const entry = readSetupForOwner(setupSlice, ownerForRow ?? null);
|
|
4971
|
+
const state = entry.status === "ready" ? "ready" : entry.status === "error" ? "error" : "loading";
|
|
4972
|
+
return {
|
|
4973
|
+
id: option.id,
|
|
4974
|
+
kind: option.kind,
|
|
4975
|
+
label: option.label,
|
|
4976
|
+
icon: option.icon,
|
|
4977
|
+
address: option.address ?? option.solanaAddress ?? option.id,
|
|
4978
|
+
state,
|
|
4979
|
+
errorReason: entry.message ?? void 0
|
|
4980
|
+
};
|
|
4981
|
+
});
|
|
4982
|
+
}, [walletOptions, setupSlice, dappAddress]);
|
|
4983
|
+
const transferCryptoEntry = useMemo6(
|
|
4984
|
+
() => readSetupForOwner(setupSlice, dappAddress),
|
|
4985
|
+
[setupSlice, dappAddress]
|
|
4986
|
+
);
|
|
4987
|
+
const transferCryptoState = transferCryptoEntry.status === "ready" ? "ready" : transferCryptoEntry.status === "error" ? "error" : "loading";
|
|
4988
|
+
const handleRetrySetup = useCallback3(
|
|
4989
|
+
(owner) => {
|
|
4990
|
+
storeApi.dispatch({ type: "setup/retry-requested", owner });
|
|
4991
|
+
},
|
|
4992
|
+
[storeApi]
|
|
4993
|
+
);
|
|
4059
4994
|
if (showConnectStep) {
|
|
4060
4995
|
return /* @__PURE__ */ jsx10("div", { className: "rs-modal-body", children: /* @__PURE__ */ jsx10(
|
|
4061
4996
|
ConnectStep,
|
|
4062
4997
|
{
|
|
4063
|
-
|
|
4998
|
+
walletRows,
|
|
4999
|
+
transferCryptoState: dappAddress ? transferCryptoState : void 0,
|
|
5000
|
+
transferCryptoErrorReason: dappAddress ? transferCryptoEntry.message ?? void 0 : void 0,
|
|
4064
5001
|
onSelectTransferCrypto: dappAddress ? () => {
|
|
5002
|
+
if (transferCryptoState === "error") {
|
|
5003
|
+
handleRetrySetup(dappAddress);
|
|
5004
|
+
return;
|
|
5005
|
+
}
|
|
5006
|
+
if (transferCryptoState !== "ready") return;
|
|
4065
5007
|
handleSelectTransferCrypto();
|
|
4066
|
-
setIsConnectSelectionConfirmed(true);
|
|
4067
5008
|
} : void 0,
|
|
4068
5009
|
onRequestConnect,
|
|
4069
5010
|
onConnect,
|
|
4070
5011
|
onDisconnect,
|
|
4071
5012
|
onConfirmWallet: (walletId) => {
|
|
4072
|
-
|
|
4073
|
-
const
|
|
4074
|
-
|
|
5013
|
+
const row = walletRows.find((r) => r.id === walletId);
|
|
5014
|
+
const option = walletOptions.find((o) => o.id === walletId);
|
|
5015
|
+
if (!row || !option) return;
|
|
5016
|
+
if (row.state === "error") {
|
|
5017
|
+
const owner = option.kind === "solana" ? dappAddress : option.address ?? null;
|
|
5018
|
+
if (owner) handleRetrySetup(owner);
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
if (row.state !== "ready") return;
|
|
5022
|
+
handleConfirmWallet(walletId);
|
|
5023
|
+
},
|
|
5024
|
+
dappImports: connectStepDappImports,
|
|
5025
|
+
onSelectDappImport: (providerId) => {
|
|
5026
|
+
const dappImportEntry = readSetupForOwner(
|
|
5027
|
+
setupSlice,
|
|
5028
|
+
dappImportOwner
|
|
4075
5029
|
);
|
|
4076
|
-
if (
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
handleSelectProvider();
|
|
5030
|
+
if (dappImportEntry.status === "error" && dappImportOwner) {
|
|
5031
|
+
handleRetrySetup(dappImportOwner);
|
|
5032
|
+
return;
|
|
4080
5033
|
}
|
|
4081
|
-
|
|
5034
|
+
if (dappImportEntry.status !== "ready") return;
|
|
5035
|
+
handleSelectDappImport(providerId);
|
|
4082
5036
|
}
|
|
4083
5037
|
}
|
|
4084
5038
|
) });
|
|
4085
5039
|
}
|
|
4086
5040
|
if (isDepositAddressMode) {
|
|
4087
|
-
if (!dappAddress
|
|
5041
|
+
if (!dappAddress) return null;
|
|
5042
|
+
const isWalletPickerReachable = walletOptions.length > 0 || Boolean(reownWallet) || Boolean(onConnect);
|
|
5043
|
+
const showBanner = effectiveStep.type !== "setup" && (activeEntry.status === "loading" || activeEntry.status === "error");
|
|
4088
5044
|
return /* @__PURE__ */ jsxs10("div", { className: "rs-modal-body", children: [
|
|
4089
|
-
|
|
4090
|
-
|
|
5045
|
+
showBanner && /* @__PURE__ */ jsx10(
|
|
5046
|
+
SetupUpdatingBanner,
|
|
4091
5047
|
{
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
forceRegister,
|
|
4102
|
-
enableSolana,
|
|
4103
|
-
service,
|
|
4104
|
-
onSetupComplete: handleSetupComplete,
|
|
4105
|
-
onConnected: handleConnected,
|
|
4106
|
-
onError: handleError
|
|
5048
|
+
status: activeEntry.status,
|
|
5049
|
+
message: activeEntry.message ?? void 0
|
|
5050
|
+
}
|
|
5051
|
+
),
|
|
5052
|
+
effectiveStep.type === "setup" && /* @__PURE__ */ jsx10(
|
|
5053
|
+
AccountPreparingSkeleton,
|
|
5054
|
+
{
|
|
5055
|
+
errorMessage: activeEntry.status === "error" ? activeEntry.message ?? void 0 : void 0,
|
|
5056
|
+
onRetry: activeEntry.status === "error" ? () => handleRetrySetup(dappAddress) : void 0
|
|
4107
5057
|
}
|
|
4108
5058
|
),
|
|
4109
|
-
|
|
5059
|
+
effectiveStep.type === "deposit-address" && /* @__PURE__ */ jsx10(
|
|
4110
5060
|
DepositAddressStep,
|
|
4111
5061
|
{
|
|
4112
|
-
smartAccount:
|
|
4113
|
-
solanaDepositAddress: enableSolana ?
|
|
5062
|
+
smartAccount: effectiveStep.smartAccount,
|
|
5063
|
+
solanaDepositAddress: enableSolana ? effectiveStep.solanaDepositAddress : void 0,
|
|
4114
5064
|
service,
|
|
4115
5065
|
allowedRoutes,
|
|
4116
5066
|
targetChain,
|
|
@@ -4132,6 +5082,9 @@ function DepositFlow({
|
|
|
4132
5082
|
cta_name: "copy"
|
|
4133
5083
|
});
|
|
4134
5084
|
},
|
|
5085
|
+
onRequestWalletPicker: isWalletPickerReachable ? () => storeApi.dispatch({
|
|
5086
|
+
type: "connect/wallet-picker-requested"
|
|
5087
|
+
}) : void 0,
|
|
4135
5088
|
onError: handleError,
|
|
4136
5089
|
debug
|
|
4137
5090
|
}
|
|
@@ -4139,31 +5092,26 @@ function DepositFlow({
|
|
|
4139
5092
|
] });
|
|
4140
5093
|
}
|
|
4141
5094
|
if (isSolanaWalletMode) {
|
|
4142
|
-
if (!
|
|
5095
|
+
if (!dappAddress) return null;
|
|
4143
5096
|
const solanaAddr = reownWallet?.solanaAddress;
|
|
4144
5097
|
const solanaProvider = reownWallet?.solanaProvider;
|
|
5098
|
+
const solanaShowBanner = effectiveStep.type !== "setup" && effectiveStep.type !== "processing" && (activeEntry.status === "loading" || activeEntry.status === "error");
|
|
4145
5099
|
return /* @__PURE__ */ jsxs10("div", { className: "rs-modal-body", children: [
|
|
4146
|
-
|
|
4147
|
-
|
|
5100
|
+
solanaShowBanner && /* @__PURE__ */ jsx10(
|
|
5101
|
+
SetupUpdatingBanner,
|
|
4148
5102
|
{
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
targetToken,
|
|
4152
|
-
signerAddress,
|
|
4153
|
-
sessionChainIds,
|
|
4154
|
-
recipient,
|
|
4155
|
-
postBridgeActions,
|
|
4156
|
-
outputTokenRules,
|
|
4157
|
-
rejectUnmapped,
|
|
4158
|
-
forceRegister,
|
|
4159
|
-
enableSolana,
|
|
4160
|
-
service,
|
|
4161
|
-
onSetupComplete: handleSetupComplete,
|
|
4162
|
-
onConnected: handleConnected,
|
|
4163
|
-
onError: handleError
|
|
5103
|
+
status: activeEntry.status,
|
|
5104
|
+
message: activeEntry.message ?? void 0
|
|
4164
5105
|
}
|
|
4165
5106
|
),
|
|
4166
|
-
|
|
5107
|
+
effectiveStep.type === "setup" && /* @__PURE__ */ jsx10(
|
|
5108
|
+
AccountPreparingSkeleton,
|
|
5109
|
+
{
|
|
5110
|
+
errorMessage: activeEntry.status === "error" ? activeEntry.message ?? void 0 : void 0,
|
|
5111
|
+
onRetry: activeEntry.status === "error" ? () => handleRetrySetup(dappAddress) : void 0
|
|
5112
|
+
}
|
|
5113
|
+
),
|
|
5114
|
+
effectiveStep.type === "solana-token-select" && solanaAddr && /* @__PURE__ */ jsx10(
|
|
4167
5115
|
SolanaTokenSelectStep,
|
|
4168
5116
|
{
|
|
4169
5117
|
solanaAddress: solanaAddr,
|
|
@@ -4173,13 +5121,13 @@ function DepositFlow({
|
|
|
4173
5121
|
debug
|
|
4174
5122
|
}
|
|
4175
5123
|
),
|
|
4176
|
-
|
|
5124
|
+
effectiveStep.type === "solana-amount" && /* @__PURE__ */ jsx10(
|
|
4177
5125
|
SolanaAmountStep,
|
|
4178
5126
|
{
|
|
4179
|
-
token:
|
|
4180
|
-
balance:
|
|
4181
|
-
balanceUsd:
|
|
4182
|
-
defaultAmount:
|
|
5127
|
+
token: effectiveStep.token,
|
|
5128
|
+
balance: effectiveStep.balance,
|
|
5129
|
+
balanceUsd: effectiveStep.balanceUsd,
|
|
5130
|
+
defaultAmount: effectiveStep.inputAmountUsd,
|
|
4183
5131
|
uiConfig,
|
|
4184
5132
|
targetChainName: getChainName(targetChain),
|
|
4185
5133
|
targetTokenSymbol: getTokenSymbol(targetToken, targetChain),
|
|
@@ -4190,17 +5138,17 @@ function DepositFlow({
|
|
|
4190
5138
|
debug
|
|
4191
5139
|
}
|
|
4192
5140
|
),
|
|
4193
|
-
|
|
5141
|
+
effectiveStep.type === "solana-confirm" && solanaAddr && solanaProvider ? /* @__PURE__ */ jsx10(
|
|
4194
5142
|
SolanaConfirmStep,
|
|
4195
5143
|
{
|
|
4196
|
-
smartAccount:
|
|
5144
|
+
smartAccount: effectiveStep.smartAccount,
|
|
4197
5145
|
solanaAddress: solanaAddr,
|
|
4198
|
-
solanaDepositAddress:
|
|
4199
|
-
token:
|
|
4200
|
-
sourceAmount:
|
|
4201
|
-
inputAmountUsd:
|
|
4202
|
-
targetAmount:
|
|
4203
|
-
targetTokenPriceUsd:
|
|
5146
|
+
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
5147
|
+
token: effectiveStep.token,
|
|
5148
|
+
sourceAmount: effectiveStep.sourceAmount,
|
|
5149
|
+
inputAmountUsd: effectiveStep.inputAmountUsd,
|
|
5150
|
+
targetAmount: effectiveStep.targetAmount,
|
|
5151
|
+
targetTokenPriceUsd: effectiveStep.targetTokenPriceUsd,
|
|
4204
5152
|
targetChain,
|
|
4205
5153
|
targetToken,
|
|
4206
5154
|
service,
|
|
@@ -4209,7 +5157,7 @@ function DepositFlow({
|
|
|
4209
5157
|
onError: handleError,
|
|
4210
5158
|
debug
|
|
4211
5159
|
}
|
|
4212
|
-
) :
|
|
5160
|
+
) : effectiveStep.type === "solana-confirm" ? /* @__PURE__ */ jsxs10("div", { className: "rs-step", children: [
|
|
4213
5161
|
/* @__PURE__ */ jsxs10("div", { className: "rs-loading-state", children: [
|
|
4214
5162
|
/* @__PURE__ */ jsx10("div", { className: "rs-step-icon rs-step-icon--error", children: /* @__PURE__ */ jsx10(
|
|
4215
5163
|
"svg",
|
|
@@ -4243,23 +5191,23 @@ function DepositFlow({
|
|
|
4243
5191
|
}
|
|
4244
5192
|
) })
|
|
4245
5193
|
] }) : null,
|
|
4246
|
-
|
|
5194
|
+
effectiveStep.type === "processing" && /* @__PURE__ */ jsx10(
|
|
4247
5195
|
ProcessingStep,
|
|
4248
5196
|
{
|
|
4249
|
-
smartAccount:
|
|
4250
|
-
solanaDepositAddress:
|
|
4251
|
-
txHash:
|
|
4252
|
-
sourceChain:
|
|
4253
|
-
sourceToken:
|
|
5197
|
+
smartAccount: effectiveStep.smartAccount,
|
|
5198
|
+
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
5199
|
+
txHash: effectiveStep.txHash,
|
|
5200
|
+
sourceChain: effectiveStep.sourceChain,
|
|
5201
|
+
sourceToken: effectiveStep.sourceToken,
|
|
4254
5202
|
targetChain,
|
|
4255
5203
|
targetToken,
|
|
4256
|
-
amount:
|
|
4257
|
-
sourceSymbol:
|
|
4258
|
-
sourceDecimals:
|
|
5204
|
+
amount: effectiveStep.amount,
|
|
5205
|
+
sourceSymbol: effectiveStep.sourceSymbol,
|
|
5206
|
+
sourceDecimals: effectiveStep.sourceDecimals,
|
|
4259
5207
|
waitForFinalTx,
|
|
4260
5208
|
hasPostBridgeActions: Boolean(postBridgeActions?.length),
|
|
4261
5209
|
service,
|
|
4262
|
-
directTransfer:
|
|
5210
|
+
directTransfer: effectiveStep.directTransfer,
|
|
4263
5211
|
onClose,
|
|
4264
5212
|
onNewDeposit: handleNewDeposit,
|
|
4265
5213
|
onDepositComplete: handleDepositComplete,
|
|
@@ -4281,29 +5229,23 @@ function DepositFlow({
|
|
|
4281
5229
|
}
|
|
4282
5230
|
return getPublicClient(chainId);
|
|
4283
5231
|
};
|
|
5232
|
+
const walletShowBanner = effectiveStep.type !== "setup" && effectiveStep.type !== "processing" && (activeEntry.status === "loading" || activeEntry.status === "error");
|
|
4284
5233
|
return /* @__PURE__ */ jsxs10("div", { className: "rs-modal-body", children: [
|
|
4285
|
-
|
|
4286
|
-
|
|
5234
|
+
walletShowBanner && /* @__PURE__ */ jsx10(
|
|
5235
|
+
SetupUpdatingBanner,
|
|
4287
5236
|
{
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
rejectUnmapped,
|
|
4298
|
-
forceRegister,
|
|
4299
|
-
enableSolana,
|
|
4300
|
-
service,
|
|
4301
|
-
onSetupComplete: handleSetupComplete,
|
|
4302
|
-
onConnected: handleConnected,
|
|
4303
|
-
onError: handleError
|
|
5237
|
+
status: activeEntry.status,
|
|
5238
|
+
message: activeEntry.message ?? void 0
|
|
5239
|
+
}
|
|
5240
|
+
),
|
|
5241
|
+
effectiveStep.type === "setup" && /* @__PURE__ */ jsx10(
|
|
5242
|
+
AccountPreparingSkeleton,
|
|
5243
|
+
{
|
|
5244
|
+
errorMessage: activeEntry.status === "error" ? activeEntry.message ?? void 0 : void 0,
|
|
5245
|
+
onRetry: activeEntry.status === "error" ? () => handleRetrySetup(ownerAddress) : void 0
|
|
4304
5246
|
}
|
|
4305
5247
|
),
|
|
4306
|
-
|
|
5248
|
+
effectiveStep.type === "select-asset" && /* @__PURE__ */ jsx10(
|
|
4307
5249
|
AssetSelectStep,
|
|
4308
5250
|
{
|
|
4309
5251
|
address: ownerAddress,
|
|
@@ -4321,14 +5263,27 @@ function DepositFlow({
|
|
|
4321
5263
|
} : void 0
|
|
4322
5264
|
}
|
|
4323
5265
|
),
|
|
4324
|
-
|
|
5266
|
+
effectiveStep.type === "dapp-import-asset-select" && activeDappImportProvider && activeDappImportAvailability && /* @__PURE__ */ jsx10(
|
|
5267
|
+
DappImportAssetSelectStep,
|
|
5268
|
+
{
|
|
5269
|
+
sourceLabel: activeDappImportAvailability.assets[0]?.sourceLabel ?? activeDappImportProvider.label,
|
|
5270
|
+
assets: activeDappImportAvailability.assets,
|
|
5271
|
+
onSelect: handleDappImportAssetSelected
|
|
5272
|
+
}
|
|
5273
|
+
),
|
|
5274
|
+
effectiveStep.type === "amount" && /* @__PURE__ */ jsx10(
|
|
4325
5275
|
AmountStep,
|
|
4326
5276
|
{
|
|
4327
5277
|
walletClient: signerContext.walletClient,
|
|
4328
|
-
publicClient: getReadClientForChain(
|
|
5278
|
+
publicClient: getReadClientForChain(effectiveStep.asset.chainId),
|
|
4329
5279
|
address: ownerAddress,
|
|
4330
|
-
|
|
4331
|
-
|
|
5280
|
+
balanceAddress: isDappImportAsset(effectiveStep.asset) ? effectiveStep.asset.providerMetadata.proxyWallet : void 0,
|
|
5281
|
+
asset: effectiveStep.asset,
|
|
5282
|
+
liquiditySource: isDappImportAsset(effectiveStep.asset) ? {
|
|
5283
|
+
chainId: effectiveStep.asset.depositChainId,
|
|
5284
|
+
token: effectiveStep.asset.depositToken
|
|
5285
|
+
} : void 0,
|
|
5286
|
+
defaultAmount: effectiveStep.amount ?? defaultAmount,
|
|
4332
5287
|
switchChain: signerContext.switchChain,
|
|
4333
5288
|
targetChain,
|
|
4334
5289
|
targetToken,
|
|
@@ -4339,7 +5294,7 @@ function DepositFlow({
|
|
|
4339
5294
|
const receiveSymbol = getTokenSymbol(targetToken, targetChain);
|
|
4340
5295
|
onEvent?.({
|
|
4341
5296
|
type: "deposit_modal_connected_wallet_enter_value_cta_click",
|
|
4342
|
-
send_token:
|
|
5297
|
+
send_token: effectiveStep.asset.symbol,
|
|
4343
5298
|
receive_token: receiveSymbol,
|
|
4344
5299
|
pred_balance: totalBalanceUsd,
|
|
4345
5300
|
cta_name: ctaName
|
|
@@ -4347,45 +5302,62 @@ function DepositFlow({
|
|
|
4347
5302
|
}
|
|
4348
5303
|
}
|
|
4349
5304
|
),
|
|
4350
|
-
|
|
5305
|
+
effectiveStep.type === "confirm" && /* @__PURE__ */ jsx10(
|
|
4351
5306
|
ConfirmStep,
|
|
4352
5307
|
{
|
|
4353
5308
|
walletClient: signerContext.walletClient,
|
|
4354
5309
|
address: ownerAddress,
|
|
4355
|
-
smartAccount:
|
|
5310
|
+
smartAccount: effectiveStep.smartAccount,
|
|
4356
5311
|
recipient,
|
|
4357
|
-
asset:
|
|
4358
|
-
amount:
|
|
4359
|
-
targetAmount:
|
|
4360
|
-
targetTokenPriceUsd:
|
|
4361
|
-
balance:
|
|
5312
|
+
asset: effectiveStep.asset,
|
|
5313
|
+
amount: effectiveStep.amount,
|
|
5314
|
+
targetAmount: effectiveStep.targetAmount,
|
|
5315
|
+
targetTokenPriceUsd: effectiveStep.targetTokenPriceUsd,
|
|
5316
|
+
balance: effectiveStep.balance,
|
|
4362
5317
|
targetChain,
|
|
4363
5318
|
targetToken,
|
|
4364
5319
|
switchChain: signerContext.switchChain,
|
|
4365
|
-
liquidityWarning:
|
|
5320
|
+
liquidityWarning: effectiveStep.liquidityWarning,
|
|
4366
5321
|
uiConfig,
|
|
5322
|
+
executeTransfer: isDappImportMode && activeDappImportProvider && isDappImportAsset(effectiveStep.asset) ? async (amountUnits) => {
|
|
5323
|
+
const result = await activeDappImportProvider.executeTransfer(
|
|
5324
|
+
{
|
|
5325
|
+
walletClient: signerContext.walletClient,
|
|
5326
|
+
publicClient: getReadClientForChain(
|
|
5327
|
+
activeDappImportProvider.chainId
|
|
5328
|
+
),
|
|
5329
|
+
recipient: effectiveStep.smartAccount,
|
|
5330
|
+
asset: effectiveStep.asset,
|
|
5331
|
+
amount: amountUnits
|
|
5332
|
+
}
|
|
5333
|
+
);
|
|
5334
|
+
return {
|
|
5335
|
+
txHash: result.txHash,
|
|
5336
|
+
sourceToken: result.sourceToken
|
|
5337
|
+
};
|
|
5338
|
+
} : void 0,
|
|
4367
5339
|
onConfirm: handleDepositSubmitted,
|
|
4368
5340
|
onDepositSubmitted: handleDepositSubmittedCallback,
|
|
4369
5341
|
onError: handleError
|
|
4370
5342
|
}
|
|
4371
5343
|
),
|
|
4372
|
-
|
|
5344
|
+
effectiveStep.type === "processing" && /* @__PURE__ */ jsx10(
|
|
4373
5345
|
ProcessingStep,
|
|
4374
5346
|
{
|
|
4375
|
-
smartAccount:
|
|
4376
|
-
solanaDepositAddress:
|
|
4377
|
-
txHash:
|
|
4378
|
-
sourceChain:
|
|
4379
|
-
sourceToken:
|
|
5347
|
+
smartAccount: effectiveStep.smartAccount,
|
|
5348
|
+
solanaDepositAddress: effectiveStep.solanaDepositAddress,
|
|
5349
|
+
txHash: effectiveStep.txHash,
|
|
5350
|
+
sourceChain: effectiveStep.sourceChain,
|
|
5351
|
+
sourceToken: effectiveStep.sourceToken,
|
|
4380
5352
|
targetChain,
|
|
4381
5353
|
targetToken,
|
|
4382
|
-
amount:
|
|
4383
|
-
sourceSymbol:
|
|
4384
|
-
sourceDecimals:
|
|
5354
|
+
amount: effectiveStep.amount,
|
|
5355
|
+
sourceSymbol: effectiveStep.sourceSymbol,
|
|
5356
|
+
sourceDecimals: effectiveStep.sourceDecimals,
|
|
4385
5357
|
waitForFinalTx,
|
|
4386
5358
|
hasPostBridgeActions: Boolean(postBridgeActions?.length),
|
|
4387
5359
|
service,
|
|
4388
|
-
directTransfer:
|
|
5360
|
+
directTransfer: effectiveStep.directTransfer,
|
|
4389
5361
|
uiConfig,
|
|
4390
5362
|
onClose,
|
|
4391
5363
|
onNewDeposit: handleNewDeposit,
|
|
@@ -4400,7 +5372,7 @@ function DepositFlow({
|
|
|
4400
5372
|
}
|
|
4401
5373
|
|
|
4402
5374
|
// src/components/history/DepositHistoryPanel.tsx
|
|
4403
|
-
import { useCallback as
|
|
5375
|
+
import { useCallback as useCallback4, useState as useState10 } from "react";
|
|
4404
5376
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4405
5377
|
function shortenHash(hash) {
|
|
4406
5378
|
if (hash.length <= 14) return hash;
|
|
@@ -4512,7 +5484,7 @@ function DepositHistoryPanel({
|
|
|
4512
5484
|
onClose,
|
|
4513
5485
|
onCloseModal
|
|
4514
5486
|
}) {
|
|
4515
|
-
const handleKeyDown =
|
|
5487
|
+
const handleKeyDown = useCallback4(
|
|
4516
5488
|
(e) => {
|
|
4517
5489
|
if (e.key === "Escape") {
|
|
4518
5490
|
e.stopPropagation();
|
|
@@ -4597,7 +5569,7 @@ function DepositHistoryPanel({
|
|
|
4597
5569
|
);
|
|
4598
5570
|
}
|
|
4599
5571
|
function HistoryCard({ deposit }) {
|
|
4600
|
-
const [expanded, setExpanded] =
|
|
5572
|
+
const [expanded, setExpanded] = useState10(false);
|
|
4601
5573
|
const status = normalizeStatus(deposit.status, deposit.isSpam);
|
|
4602
5574
|
const sourceChainId = resolveChainId(deposit.chain);
|
|
4603
5575
|
const targetChainId = resolveChainId(deposit.targetChain);
|
|
@@ -4679,7 +5651,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
|
|
|
4679
5651
|
// src/DepositModal.tsx
|
|
4680
5652
|
import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4681
5653
|
var ReownDepositInner = lazy2(
|
|
4682
|
-
() => import("./DepositModalReown-
|
|
5654
|
+
() => import("./DepositModalReown-6QBOLFNL.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
4683
5655
|
);
|
|
4684
5656
|
function sortByCreatedAtDesc(items) {
|
|
4685
5657
|
return [...items].sort((a, b) => {
|
|
@@ -4734,6 +5706,7 @@ function DepositModalInner({
|
|
|
4734
5706
|
forceRegister = false,
|
|
4735
5707
|
waitForFinalTx = true,
|
|
4736
5708
|
enableSolana = true,
|
|
5709
|
+
dappImports,
|
|
4737
5710
|
postBridgeActions,
|
|
4738
5711
|
outputTokenRules,
|
|
4739
5712
|
rejectUnmapped,
|
|
@@ -4751,28 +5724,23 @@ function DepositModalInner({
|
|
|
4751
5724
|
onError,
|
|
4752
5725
|
debug
|
|
4753
5726
|
}) {
|
|
4754
|
-
const modalRef =
|
|
5727
|
+
const modalRef = useRef6(null);
|
|
4755
5728
|
const onReadyRef = useLatestRef(onReady);
|
|
4756
|
-
const [currentScreen, setCurrentScreen] =
|
|
4757
|
-
const [backHandler, setBackHandler] =
|
|
5729
|
+
const [currentScreen, setCurrentScreen] = useState11("connect");
|
|
5730
|
+
const [backHandler, setBackHandler] = useState11(
|
|
4758
5731
|
void 0
|
|
4759
5732
|
);
|
|
4760
5733
|
const showHistoryButton = uiConfig?.showHistoryButton ?? false;
|
|
4761
|
-
const historyButtonVisible = showHistoryButton && (currentScreen === "
|
|
4762
|
-
const [
|
|
4763
|
-
const [
|
|
4764
|
-
|
|
4765
|
-
);
|
|
4766
|
-
const [
|
|
4767
|
-
const [
|
|
4768
|
-
const
|
|
4769
|
-
const
|
|
4770
|
-
const
|
|
4771
|
-
const [historyError, setHistoryError] = useState12(null);
|
|
4772
|
-
const evmCursorRef = useRef7(null);
|
|
4773
|
-
const solanaCursorRef = useRef7(null);
|
|
4774
|
-
const historyStaleRef = useRef7(false);
|
|
4775
|
-
const historyLoadedRef = useRef7(false);
|
|
5734
|
+
const historyButtonVisible = showHistoryButton && (currentScreen === "select-asset" || currentScreen === "deposit-address");
|
|
5735
|
+
const [historyOpen, setHistoryOpen] = useState11(false);
|
|
5736
|
+
const [historyDeposits, setHistoryDeposits] = useState11([]);
|
|
5737
|
+
const [hasMoreHistory, setHasMoreHistory] = useState11(false);
|
|
5738
|
+
const [historyLoading, setHistoryLoading] = useState11(false);
|
|
5739
|
+
const [historyLoadingMore, setHistoryLoadingMore] = useState11(false);
|
|
5740
|
+
const [historyError, setHistoryError] = useState11(null);
|
|
5741
|
+
const cursorRef = useRef6(null);
|
|
5742
|
+
const historyStaleRef = useRef6(false);
|
|
5743
|
+
const historyLoadedRef = useRef6(false);
|
|
4776
5744
|
const targetChain = getChainId(targetChainProp);
|
|
4777
5745
|
const sourceChain = sourceChainProp ? getChainId(sourceChainProp) : void 0;
|
|
4778
5746
|
const service = useMemo7(
|
|
@@ -4787,32 +5755,32 @@ function DepositModalInner({
|
|
|
4787
5755
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4788
5756
|
[]
|
|
4789
5757
|
);
|
|
4790
|
-
|
|
5758
|
+
useEffect9(() => {
|
|
4791
5759
|
store.dispatch({ type: "target/changed", targetChain, targetToken });
|
|
4792
5760
|
}, [store, targetChain, targetToken]);
|
|
4793
|
-
|
|
5761
|
+
useEffect9(() => {
|
|
4794
5762
|
if (isOpen && modalRef.current) {
|
|
4795
5763
|
applyTheme(modalRef.current, theme);
|
|
4796
5764
|
}
|
|
4797
5765
|
}, [isOpen, theme]);
|
|
4798
|
-
|
|
5766
|
+
useEffect9(() => {
|
|
4799
5767
|
configureSolanaRpcUrl(solanaRpcUrl);
|
|
4800
5768
|
}, [solanaRpcUrl]);
|
|
4801
|
-
|
|
5769
|
+
useEffect9(() => {
|
|
4802
5770
|
if (isOpen) {
|
|
4803
5771
|
onReadyRef.current?.();
|
|
4804
5772
|
}
|
|
4805
5773
|
}, [isOpen, onReadyRef]);
|
|
4806
|
-
const handleStepChange =
|
|
5774
|
+
const handleStepChange = useCallback5(
|
|
4807
5775
|
(onBack, screen) => {
|
|
4808
5776
|
setBackHandler(() => onBack);
|
|
4809
5777
|
if (screen) setCurrentScreen(screen);
|
|
4810
5778
|
},
|
|
4811
5779
|
[]
|
|
4812
5780
|
);
|
|
4813
|
-
const fetchHistory =
|
|
5781
|
+
const fetchHistory = useCallback5(
|
|
4814
5782
|
async (mode = "initial") => {
|
|
4815
|
-
if (!
|
|
5783
|
+
if (!recipient) return;
|
|
4816
5784
|
const isInitial = mode === "initial";
|
|
4817
5785
|
if (isInitial) {
|
|
4818
5786
|
setHistoryLoading(true);
|
|
@@ -4821,44 +5789,18 @@ function DepositModalInner({
|
|
|
4821
5789
|
}
|
|
4822
5790
|
setHistoryError(null);
|
|
4823
5791
|
try {
|
|
4824
|
-
const
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
requests.push(
|
|
4829
|
-
service.fetchDepositHistory({
|
|
4830
|
-
account: activeEvmAccount,
|
|
4831
|
-
limit: 20,
|
|
4832
|
-
cursor: evmCursor ?? void 0
|
|
4833
|
-
}).then((r) => ({
|
|
4834
|
-
deposits: r.deposits,
|
|
4835
|
-
nextCursor: r.nextCursor ?? null,
|
|
4836
|
-
source: "evm"
|
|
4837
|
-
}))
|
|
4838
|
-
);
|
|
4839
|
-
}
|
|
4840
|
-
if (activeSolanaAccount && (isInitial || solanaCursor)) {
|
|
4841
|
-
requests.push(
|
|
4842
|
-
service.fetchDepositHistory({
|
|
4843
|
-
account: activeSolanaAccount,
|
|
4844
|
-
limit: 20,
|
|
4845
|
-
cursor: solanaCursor ?? void 0
|
|
4846
|
-
}).then((r) => ({
|
|
4847
|
-
deposits: r.deposits,
|
|
4848
|
-
nextCursor: r.nextCursor ?? null,
|
|
4849
|
-
source: "solana"
|
|
4850
|
-
}))
|
|
4851
|
-
);
|
|
4852
|
-
}
|
|
4853
|
-
const results = await Promise.all(requests);
|
|
4854
|
-
let nextEvm = isInitial ? null : evmCursor;
|
|
4855
|
-
let nextSolana = isInitial ? null : solanaCursor;
|
|
4856
|
-
const incoming = [];
|
|
4857
|
-
for (const r of results) {
|
|
4858
|
-
incoming.push(...r.deposits);
|
|
4859
|
-
if (r.source === "evm") nextEvm = r.nextCursor;
|
|
4860
|
-
else nextSolana = r.nextCursor;
|
|
5792
|
+
const cursor = isInitial ? null : cursorRef.current;
|
|
5793
|
+
if (!isInitial && !cursor) {
|
|
5794
|
+
setHasMoreHistory(false);
|
|
5795
|
+
return;
|
|
4861
5796
|
}
|
|
5797
|
+
const result = await service.fetchDepositHistory({
|
|
5798
|
+
recipient,
|
|
5799
|
+
limit: 20,
|
|
5800
|
+
cursor: cursor ?? void 0
|
|
5801
|
+
});
|
|
5802
|
+
const incoming = result.deposits;
|
|
5803
|
+
const nextCursor = result.nextCursor ?? null;
|
|
4862
5804
|
if (isInitial) {
|
|
4863
5805
|
setHistoryDeposits(sortByCreatedAtDesc(incoming));
|
|
4864
5806
|
} else {
|
|
@@ -4866,9 +5808,8 @@ function DepositModalInner({
|
|
|
4866
5808
|
(prev) => sortByCreatedAtDesc([...prev, ...incoming])
|
|
4867
5809
|
);
|
|
4868
5810
|
}
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
setHasMoreHistory(Boolean(nextEvm || nextSolana));
|
|
5811
|
+
cursorRef.current = nextCursor;
|
|
5812
|
+
setHasMoreHistory(Boolean(nextCursor));
|
|
4872
5813
|
historyStaleRef.current = false;
|
|
4873
5814
|
historyLoadedRef.current = true;
|
|
4874
5815
|
} catch (err) {
|
|
@@ -4883,36 +5824,32 @@ function DepositModalInner({
|
|
|
4883
5824
|
}
|
|
4884
5825
|
}
|
|
4885
5826
|
},
|
|
4886
|
-
[
|
|
5827
|
+
[recipient, service]
|
|
4887
5828
|
);
|
|
4888
|
-
const handleHistoryOpen =
|
|
5829
|
+
const handleHistoryOpen = useCallback5(() => {
|
|
4889
5830
|
setHistoryOpen(true);
|
|
4890
5831
|
if (!historyLoadedRef.current || historyStaleRef.current) {
|
|
4891
5832
|
fetchHistory("initial");
|
|
4892
5833
|
}
|
|
4893
5834
|
}, [fetchHistory]);
|
|
4894
|
-
const handleHistoryClose =
|
|
5835
|
+
const handleHistoryClose = useCallback5(() => {
|
|
4895
5836
|
setHistoryOpen(false);
|
|
4896
5837
|
}, []);
|
|
4897
|
-
const handleHistoryLoadMore =
|
|
5838
|
+
const handleHistoryLoadMore = useCallback5(() => {
|
|
4898
5839
|
fetchHistory("more");
|
|
4899
5840
|
}, [fetchHistory]);
|
|
4900
|
-
const markHistoryStale =
|
|
5841
|
+
const markHistoryStale = useCallback5(() => {
|
|
4901
5842
|
historyStaleRef.current = true;
|
|
4902
5843
|
if (historyOpen) {
|
|
4903
5844
|
fetchHistory("initial");
|
|
4904
5845
|
}
|
|
4905
5846
|
}, [historyOpen, fetchHistory]);
|
|
4906
5847
|
const onLifecycleRef = useLatestRef(onLifecycle);
|
|
4907
|
-
const handleLifecycle =
|
|
5848
|
+
const handleLifecycle = useCallback5(
|
|
4908
5849
|
(event) => {
|
|
4909
5850
|
onLifecycleRef.current?.(event);
|
|
4910
|
-
if (event.type === "smart-account-changed") {
|
|
4911
|
-
|
|
4912
|
-
setActiveSolanaAccount(event.solana);
|
|
4913
|
-
if (!event.evm && !event.solana) {
|
|
4914
|
-
historyStaleRef.current = true;
|
|
4915
|
-
}
|
|
5851
|
+
if (event.type === "smart-account-changed" && !event.evm && !event.solana) {
|
|
5852
|
+
historyStaleRef.current = true;
|
|
4916
5853
|
}
|
|
4917
5854
|
if (showHistoryButton && (event.type === "submitted" || event.type === "complete" || event.type === "failed")) {
|
|
4918
5855
|
markHistoryStale();
|
|
@@ -4920,21 +5857,18 @@ function DepositModalInner({
|
|
|
4920
5857
|
},
|
|
4921
5858
|
[onLifecycleRef, showHistoryButton, markHistoryStale]
|
|
4922
5859
|
);
|
|
4923
|
-
|
|
5860
|
+
useEffect9(() => {
|
|
4924
5861
|
if (!isOpen) {
|
|
4925
5862
|
setHistoryOpen(false);
|
|
4926
5863
|
setHistoryDeposits([]);
|
|
4927
5864
|
setHasMoreHistory(false);
|
|
4928
5865
|
setHistoryError(null);
|
|
4929
|
-
|
|
4930
|
-
setActiveSolanaAccount(null);
|
|
4931
|
-
evmCursorRef.current = null;
|
|
4932
|
-
solanaCursorRef.current = null;
|
|
5866
|
+
cursorRef.current = null;
|
|
4933
5867
|
historyStaleRef.current = false;
|
|
4934
5868
|
historyLoadedRef.current = false;
|
|
4935
5869
|
}
|
|
4936
5870
|
}, [isOpen]);
|
|
4937
|
-
|
|
5871
|
+
useEffect9(() => {
|
|
4938
5872
|
if (!isOpen) {
|
|
4939
5873
|
store.dispatch({ type: "flow/reset" });
|
|
4940
5874
|
}
|
|
@@ -4969,7 +5903,7 @@ function DepositModalInner({
|
|
|
4969
5903
|
className: "rs-modal-header-history",
|
|
4970
5904
|
"aria-label": "Deposit history",
|
|
4971
5905
|
onClick: handleHistoryOpen,
|
|
4972
|
-
disabled: !
|
|
5906
|
+
disabled: !recipient,
|
|
4973
5907
|
children: /* @__PURE__ */ jsx12(HistoryIcon, {})
|
|
4974
5908
|
}
|
|
4975
5909
|
),
|
|
@@ -5007,6 +5941,7 @@ function DepositModalInner({
|
|
|
5007
5941
|
forceRegister,
|
|
5008
5942
|
waitForFinalTx,
|
|
5009
5943
|
enableSolana,
|
|
5944
|
+
dappImports,
|
|
5010
5945
|
reownWallet,
|
|
5011
5946
|
onConnect,
|
|
5012
5947
|
onDisconnect,
|