@rhinestone/deposit-modal 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{DepositModalReown-3HNOCOOO.mjs → DepositModalReown-3GPEVG26.mjs} +15 -6
- package/dist/{DepositModalReown-ZZKRN6J3.cjs → DepositModalReown-EEXNSXI4.cjs} +17 -8
- package/dist/{WithdrawModalReown-XXCOZYVU.mjs → WithdrawModalReown-7CSCY55U.mjs} +4 -4
- package/dist/{WithdrawModalReown-2CWNDVJD.cjs → WithdrawModalReown-GCOVYZN2.cjs} +7 -7
- package/dist/{chunk-K7BHCDJQ.cjs → chunk-37CTMJMO.cjs} +181 -96
- package/dist/{chunk-3O37UPSC.cjs → chunk-CDHUGROM.cjs} +1630 -362
- package/dist/{chunk-CFLZYWX7.mjs → chunk-KWAFKVV6.mjs} +120 -35
- package/dist/{chunk-AHOFT42H.cjs → chunk-LT3QKJI2.cjs} +458 -115
- package/dist/{chunk-SJEIKMVO.mjs → chunk-MBOH6XW3.mjs} +26 -13
- package/dist/{chunk-FLXTBFMZ.cjs → chunk-NELAYNA3.cjs} +11 -0
- package/dist/{chunk-F5S6RHUI.mjs → chunk-NLL42V7D.mjs} +1568 -300
- package/dist/{chunk-V7I5T4SW.cjs → chunk-PWPW7GFB.cjs} +25 -12
- package/dist/{chunk-IC2M2DZ7.mjs → chunk-QIK6ONMQ.mjs} +392 -49
- package/dist/{chunk-I7RYTI4G.mjs → chunk-ZJQZEIHA.mjs} +11 -0
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +6 -6
- package/dist/constants.d.ts +6 -6
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +4 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +3 -3
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/reown.cjs +5 -5
- package/dist/reown.d.cts +1 -1
- package/dist/reown.d.ts +1 -1
- package/dist/reown.mjs +4 -4
- package/dist/styles.css +66 -0
- package/dist/{types-CIaQPR6F.d.cts → types-CyUiKQ4H.d.cts} +10 -7
- package/dist/{types-Bp2n2RQ3.d.ts → types-DQG7NEBI.d.ts} +10 -7
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +25 -5
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
var _chunkAHOFT42Hcjs = require('./chunk-AHOFT42H.cjs');
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
|
|
28
|
+
var _chunkLT3QKJI2cjs = require('./chunk-LT3QKJI2.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
@@ -38,7 +38,10 @@ var _chunkAHOFT42Hcjs = require('./chunk-AHOFT42H.cjs');
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
var _chunkNELAYNA3cjs = require('./chunk-NELAYNA3.cjs');
|
|
42
45
|
|
|
43
46
|
// src/DepositModal.tsx
|
|
44
47
|
|
|
@@ -53,20 +56,21 @@ var _react = require('react');
|
|
|
53
56
|
|
|
54
57
|
// src/DepositFlow.tsx
|
|
55
58
|
|
|
59
|
+
var _viem = require('viem');
|
|
56
60
|
|
|
57
61
|
// src/components/steps/SetupStep.tsx
|
|
58
62
|
|
|
59
63
|
var _jsxruntime = require('react/jsx-runtime');
|
|
60
64
|
async function resolveSessionOwner(eoaAddress) {
|
|
61
|
-
const localOwner =
|
|
65
|
+
const localOwner = _chunkLT3QKJI2cjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
|
|
62
66
|
if (localOwner) {
|
|
63
67
|
return {
|
|
64
|
-
account:
|
|
68
|
+
account: _chunkLT3QKJI2cjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
|
|
65
69
|
address: localOwner.address
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
|
-
const created =
|
|
69
|
-
|
|
72
|
+
const created = _chunkLT3QKJI2cjs.createSessionOwnerKey.call(void 0, );
|
|
73
|
+
_chunkLT3QKJI2cjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
|
|
70
74
|
return {
|
|
71
75
|
account: created.account,
|
|
72
76
|
address: created.address
|
|
@@ -101,7 +105,7 @@ function SetupStep({
|
|
|
101
105
|
const setup = await service.setupAccount({
|
|
102
106
|
ownerAddress: address,
|
|
103
107
|
sessionOwnerAddress: sessionOwner.address,
|
|
104
|
-
targetChain,
|
|
108
|
+
targetChain: _chunkLT3QKJI2cjs.toEvmCaip2.call(void 0, targetChain),
|
|
105
109
|
targetToken,
|
|
106
110
|
signerAddress,
|
|
107
111
|
sessionChainIds,
|
|
@@ -111,7 +115,7 @@ function SetupStep({
|
|
|
111
115
|
if (!setup.needsRegistration) {
|
|
112
116
|
setState({ type: "ready", smartAccount });
|
|
113
117
|
_optionalChain([onConnected, 'optionalCall', _ => _(address, smartAccount)]);
|
|
114
|
-
onSetupComplete(smartAccount);
|
|
118
|
+
onSetupComplete(smartAccount, setup.solanaDepositAddress);
|
|
115
119
|
return;
|
|
116
120
|
}
|
|
117
121
|
setState({ type: "signing-session" });
|
|
@@ -128,9 +132,9 @@ function SetupStep({
|
|
|
128
132
|
primaryType: typedData.primaryType,
|
|
129
133
|
message: typedData.message
|
|
130
134
|
});
|
|
131
|
-
const sessionDetails =
|
|
135
|
+
const sessionDetails = _chunkLT3QKJI2cjs.buildSessionDetails.call(void 0, setup.sessionDetailsUnsigned, signature);
|
|
132
136
|
setState({ type: "registering" });
|
|
133
|
-
await service.registerAccount({
|
|
137
|
+
const registerResult = await service.registerAccount({
|
|
134
138
|
address: smartAccount,
|
|
135
139
|
accountParams: {
|
|
136
140
|
factory: setup.accountParams.factory,
|
|
@@ -140,14 +144,14 @@ function SetupStep({
|
|
|
140
144
|
eoaAddress: address,
|
|
141
145
|
sessionOwner: sessionOwner.address,
|
|
142
146
|
target: {
|
|
143
|
-
chain: targetChain,
|
|
147
|
+
chain: _chunkLT3QKJI2cjs.toEvmCaip2.call(void 0, targetChain),
|
|
144
148
|
token: targetToken,
|
|
145
149
|
...recipient && { recipient }
|
|
146
150
|
}
|
|
147
151
|
});
|
|
148
152
|
setState({ type: "ready", smartAccount });
|
|
149
153
|
_optionalChain([onConnected, 'optionalCall', _2 => _2(address, smartAccount)]);
|
|
150
|
-
onSetupComplete(smartAccount);
|
|
154
|
+
onSetupComplete(smartAccount, registerResult.solanaDepositAddress);
|
|
151
155
|
} catch (error) {
|
|
152
156
|
const message = error instanceof Error ? error.message : "Setup failed";
|
|
153
157
|
setState({ type: "error", message });
|
|
@@ -199,7 +203,7 @@ function SetupStep({
|
|
|
199
203
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
200
204
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", children: [
|
|
201
205
|
isLoading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
202
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
206
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.Spinner, { className: "rs-spinner--lg rs-text-accent" }),
|
|
203
207
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-text", children: [
|
|
204
208
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: renderStateMessage() }),
|
|
205
209
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "This may take a moment" })
|
|
@@ -236,13 +240,13 @@ function SetupStep({
|
|
|
236
240
|
] })
|
|
237
241
|
] })
|
|
238
242
|
] }),
|
|
239
|
-
isError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
243
|
+
isError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.Button, { onClick: handleRetry, variant: "default", fullWidth: true, children: "Try Again" }) })
|
|
240
244
|
] });
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
// src/components/steps/AssetSelectStep.tsx
|
|
244
248
|
|
|
245
|
-
|
|
249
|
+
|
|
246
250
|
|
|
247
251
|
function AssetSelectStep({
|
|
248
252
|
address,
|
|
@@ -260,7 +264,7 @@ function AssetSelectStep({
|
|
|
260
264
|
const [error, setError] = _react.useState.call(void 0, null);
|
|
261
265
|
const defaultAssetId = _react.useMemo.call(void 0, () => {
|
|
262
266
|
if (!defaultSourceChain || !defaultSourceToken) return null;
|
|
263
|
-
return
|
|
267
|
+
return _chunkLT3QKJI2cjs.getAssetId.call(void 0, {
|
|
264
268
|
chainId: defaultSourceChain,
|
|
265
269
|
token: defaultSourceToken
|
|
266
270
|
});
|
|
@@ -277,10 +281,10 @@ function AssetSelectStep({
|
|
|
277
281
|
try {
|
|
278
282
|
const portfolio = await service.fetchPortfolio(address);
|
|
279
283
|
if (!active) return;
|
|
280
|
-
const portfolioAssets =
|
|
284
|
+
const portfolioAssets = _chunkLT3QKJI2cjs.portfolioToAssets.call(void 0, portfolio.tokens);
|
|
281
285
|
setAssets(portfolioAssets);
|
|
282
286
|
const hasNative = portfolioAssets.some(
|
|
283
|
-
(asset) => asset.token.toLowerCase() ===
|
|
287
|
+
(asset) => asset.token.toLowerCase() === _chunkNELAYNA3cjs.NATIVE_TOKEN_ADDRESS
|
|
284
288
|
);
|
|
285
289
|
if (!hasNative) {
|
|
286
290
|
const nativeAssets = await fetchNativeAssets(
|
|
@@ -346,7 +350,7 @@ function AssetSelectStep({
|
|
|
346
350
|
const raw = _viem.formatUnits.call(void 0, BigInt(asset.balance), asset.decimals);
|
|
347
351
|
const numeric = Number(raw);
|
|
348
352
|
if (!Number.isFinite(numeric)) return raw;
|
|
349
|
-
return
|
|
353
|
+
return _chunkLT3QKJI2cjs.tokenFormatter.format(numeric);
|
|
350
354
|
} catch (e3) {
|
|
351
355
|
return asset.balance;
|
|
352
356
|
}
|
|
@@ -360,7 +364,7 @@ function AssetSelectStep({
|
|
|
360
364
|
style: { paddingTop: 4, overflow: "auto", maxHeight: 340 },
|
|
361
365
|
children: [
|
|
362
366
|
loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", style: { padding: "40px 12px" }, children: [
|
|
363
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
367
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.Spinner, { className: "rs-text-tertiary" }),
|
|
364
368
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-text-sm rs-text-tertiary", children: "Loading balances" })
|
|
365
369
|
] }),
|
|
366
370
|
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-alert rs-alert--error", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-alert-text", children: error }) }),
|
|
@@ -393,9 +397,9 @@ function AssetSelectStep({
|
|
|
393
397
|
!loading && !error && rows.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-list", children: rows.map((asset) => {
|
|
394
398
|
const isSelected = selectedAssetId === asset.id;
|
|
395
399
|
const tokenAmount = formatBalance(asset);
|
|
396
|
-
const badge =
|
|
397
|
-
const tokenIcon =
|
|
398
|
-
const chainIcon =
|
|
400
|
+
const badge = _chunkNELAYNA3cjs.getChainBadge.call(void 0, asset.chainId);
|
|
401
|
+
const tokenIcon = _chunkNELAYNA3cjs.getTokenIcon.call(void 0, asset.symbol);
|
|
402
|
+
const chainIcon = _chunkNELAYNA3cjs.getChainIcon.call(void 0, asset.chainId);
|
|
399
403
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
400
404
|
"button",
|
|
401
405
|
{
|
|
@@ -419,7 +423,7 @@ function AssetSelectStep({
|
|
|
419
423
|
"img",
|
|
420
424
|
{
|
|
421
425
|
src: chainIcon,
|
|
422
|
-
alt:
|
|
426
|
+
alt: _chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId),
|
|
423
427
|
className: "rs-asset-chain-badge"
|
|
424
428
|
}
|
|
425
429
|
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -440,7 +444,7 @@ function AssetSelectStep({
|
|
|
440
444
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-asset-chain", children: [
|
|
441
445
|
" ",
|
|
442
446
|
"on ",
|
|
443
|
-
|
|
447
|
+
_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)
|
|
444
448
|
] })
|
|
445
449
|
] }),
|
|
446
450
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-asset-balance-small", children: [
|
|
@@ -450,7 +454,7 @@ function AssetSelectStep({
|
|
|
450
454
|
] })
|
|
451
455
|
] })
|
|
452
456
|
] }),
|
|
453
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-balance", children: asset.balanceUsd !== void 0 && asset.balanceUsd > 0 ?
|
|
457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-balance", children: asset.balanceUsd !== void 0 && asset.balanceUsd > 0 ? _chunkLT3QKJI2cjs.currencyFormatter.format(asset.balanceUsd) : tokenAmount !== "--" ? `${tokenAmount} ${asset.symbol}` : "--" })
|
|
454
458
|
]
|
|
455
459
|
},
|
|
456
460
|
asset.id
|
|
@@ -460,7 +464,7 @@ function AssetSelectStep({
|
|
|
460
464
|
}
|
|
461
465
|
),
|
|
462
466
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
463
|
-
|
|
467
|
+
_chunkLT3QKJI2cjs.Button,
|
|
464
468
|
{
|
|
465
469
|
onClick: () => selectedAsset && onContinue(selectedAsset),
|
|
466
470
|
disabled: !selectedAsset,
|
|
@@ -468,17 +472,17 @@ function AssetSelectStep({
|
|
|
468
472
|
children: "Continue"
|
|
469
473
|
}
|
|
470
474
|
) }),
|
|
471
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
475
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
472
476
|
] });
|
|
473
477
|
}
|
|
474
478
|
async function fetchNativeAssets(address, publicClient, existing) {
|
|
475
479
|
const existingIds = new Set(existing.map((asset) => asset.id));
|
|
476
480
|
const connectedChainId = _optionalChain([publicClient, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.id]);
|
|
477
481
|
if (!connectedChainId) return [];
|
|
478
|
-
if (!
|
|
479
|
-
const id =
|
|
482
|
+
if (!_chunkNELAYNA3cjs.SOURCE_CHAINS.some((chain) => chain.id === connectedChainId)) return [];
|
|
483
|
+
const id = _chunkLT3QKJI2cjs.getAssetId.call(void 0, {
|
|
480
484
|
chainId: connectedChainId,
|
|
481
|
-
token:
|
|
485
|
+
token: _chunkNELAYNA3cjs.NATIVE_TOKEN_ADDRESS
|
|
482
486
|
});
|
|
483
487
|
if (existingIds.has(id)) return [];
|
|
484
488
|
try {
|
|
@@ -487,7 +491,7 @@ async function fetchNativeAssets(address, publicClient, existing) {
|
|
|
487
491
|
{
|
|
488
492
|
id,
|
|
489
493
|
chainId: connectedChainId,
|
|
490
|
-
token:
|
|
494
|
+
token: _chunkNELAYNA3cjs.NATIVE_TOKEN_ADDRESS,
|
|
491
495
|
symbol: "ETH",
|
|
492
496
|
name: "Ethereum",
|
|
493
497
|
decimals: 18,
|
|
@@ -537,8 +541,8 @@ function AmountStep({
|
|
|
537
541
|
const chainMismatch = Boolean(
|
|
538
542
|
_optionalChain([walletClient, 'optionalAccess', _8 => _8.chain, 'optionalAccess', _9 => _9.id]) && walletClient.chain.id !== asset.chainId
|
|
539
543
|
);
|
|
540
|
-
const targetSymbol =
|
|
541
|
-
const isSourceStablecoin =
|
|
544
|
+
const targetSymbol = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
545
|
+
const isSourceStablecoin = _chunkNELAYNA3cjs.isStablecoinSymbol.call(void 0, asset.symbol);
|
|
542
546
|
const tokenPriceUsd = _react.useMemo.call(void 0, () => {
|
|
543
547
|
if (tokenPriceUsdOverride !== void 0 && tokenPriceUsdOverride > 0)
|
|
544
548
|
return tokenPriceUsdOverride;
|
|
@@ -562,7 +566,7 @@ function AmountStep({
|
|
|
562
566
|
const balanceTarget = _nullishCoalesce(balanceAddress, () => ( address));
|
|
563
567
|
if (!balanceTarget || !publicClient) return;
|
|
564
568
|
try {
|
|
565
|
-
const bal =
|
|
569
|
+
const bal = _chunkLT3QKJI2cjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: balanceTarget }) : await publicClient.readContract({
|
|
566
570
|
address: asset.token,
|
|
567
571
|
abi: _viem.erc20Abi,
|
|
568
572
|
functionName: "balanceOf",
|
|
@@ -588,7 +592,7 @@ function AmountStep({
|
|
|
588
592
|
setIsSwitching(true);
|
|
589
593
|
switchChain(asset.chainId).catch((err) => {
|
|
590
594
|
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
591
|
-
setError(
|
|
595
|
+
setError(_chunkLT3QKJI2cjs.formatUserError.call(void 0, raw));
|
|
592
596
|
}).finally(() => {
|
|
593
597
|
setIsSwitching(false);
|
|
594
598
|
});
|
|
@@ -624,7 +628,7 @@ function AmountStep({
|
|
|
624
628
|
const raw = _viem.formatUnits.call(void 0, balance, asset.decimals);
|
|
625
629
|
const numeric = Number(raw);
|
|
626
630
|
if (!Number.isFinite(numeric)) return raw;
|
|
627
|
-
return
|
|
631
|
+
return _chunkLT3QKJI2cjs.tokenFormatter.format(numeric);
|
|
628
632
|
} catch (e8) {
|
|
629
633
|
return "...";
|
|
630
634
|
}
|
|
@@ -666,13 +670,13 @@ function AmountStep({
|
|
|
666
670
|
const usdValue = numericAmount;
|
|
667
671
|
if (_optionalChain([uiConfig, 'optionalAccess', _11 => _11.maxDepositUsd]) && usdValue > uiConfig.maxDepositUsd) {
|
|
668
672
|
setError(
|
|
669
|
-
`Maximum deposit is ${
|
|
673
|
+
`Maximum deposit is ${_chunkLT3QKJI2cjs.currencyFormatter.format(uiConfig.maxDepositUsd)}`
|
|
670
674
|
);
|
|
671
675
|
return;
|
|
672
676
|
}
|
|
673
677
|
if (_optionalChain([uiConfig, 'optionalAccess', _12 => _12.minDepositUsd]) && usdValue < uiConfig.minDepositUsd) {
|
|
674
678
|
setError(
|
|
675
|
-
`Minimum deposit is ${
|
|
679
|
+
`Minimum deposit is ${_chunkLT3QKJI2cjs.currencyFormatter.format(uiConfig.minDepositUsd)}`
|
|
676
680
|
);
|
|
677
681
|
return;
|
|
678
682
|
}
|
|
@@ -721,7 +725,7 @@ function AmountStep({
|
|
|
721
725
|
hasPricing && balanceUsd !== null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { style: { color: "var(--rs-muted-foreground)" }, children: [
|
|
722
726
|
" ",
|
|
723
727
|
"(",
|
|
724
|
-
|
|
728
|
+
_chunkLT3QKJI2cjs.currencyFormatter.format(balanceUsd),
|
|
725
729
|
")"
|
|
726
730
|
] })
|
|
727
731
|
] }) })
|
|
@@ -735,26 +739,26 @@ function AmountStep({
|
|
|
735
739
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-flow-pill-label", children: "You send" }),
|
|
736
740
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-flow-pill-token", children: [
|
|
737
741
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-flow-pill-token-icon-wrapper", children: [
|
|
738
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-flow-pill-token-icon", children:
|
|
742
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-flow-pill-token-icon", children: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, asset.symbol) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
739
743
|
"img",
|
|
740
744
|
{
|
|
741
|
-
src:
|
|
745
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, asset.symbol),
|
|
742
746
|
alt: asset.symbol
|
|
743
747
|
}
|
|
744
748
|
) : asset.symbol.slice(0, 2) }),
|
|
745
749
|
(() => {
|
|
746
|
-
const chainIcon =
|
|
750
|
+
const chainIcon = _chunkNELAYNA3cjs.getChainIcon.call(void 0, asset.chainId);
|
|
747
751
|
if (chainIcon) {
|
|
748
752
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
749
753
|
"img",
|
|
750
754
|
{
|
|
751
755
|
src: chainIcon,
|
|
752
|
-
alt:
|
|
756
|
+
alt: _chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId),
|
|
753
757
|
className: "rs-flow-pill-chain-badge"
|
|
754
758
|
}
|
|
755
759
|
);
|
|
756
760
|
}
|
|
757
|
-
const badge =
|
|
761
|
+
const badge = _chunkNELAYNA3cjs.getChainBadge.call(void 0, asset.chainId);
|
|
758
762
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
759
763
|
"div",
|
|
760
764
|
{
|
|
@@ -792,26 +796,26 @@ function AmountStep({
|
|
|
792
796
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-flow-pill-label", children: "You receive" }),
|
|
793
797
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-flow-pill-token", children: [
|
|
794
798
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-flow-pill-token-icon-wrapper", children: [
|
|
795
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-flow-pill-token-icon", children:
|
|
799
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-flow-pill-token-icon", children: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
796
800
|
"img",
|
|
797
801
|
{
|
|
798
|
-
src:
|
|
802
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol),
|
|
799
803
|
alt: targetSymbol
|
|
800
804
|
}
|
|
801
805
|
) : targetSymbol.slice(0, 2) }),
|
|
802
806
|
(() => {
|
|
803
|
-
const chainIcon =
|
|
807
|
+
const chainIcon = _chunkNELAYNA3cjs.getChainIcon.call(void 0, targetChain);
|
|
804
808
|
if (chainIcon) {
|
|
805
809
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
806
810
|
"img",
|
|
807
811
|
{
|
|
808
812
|
src: chainIcon,
|
|
809
|
-
alt:
|
|
813
|
+
alt: _chunkNELAYNA3cjs.getChainName.call(void 0, targetChain),
|
|
810
814
|
className: "rs-flow-pill-chain-badge"
|
|
811
815
|
}
|
|
812
816
|
);
|
|
813
817
|
}
|
|
814
|
-
const badge =
|
|
818
|
+
const badge = _chunkNELAYNA3cjs.getChainBadge.call(void 0, targetChain);
|
|
815
819
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
816
820
|
"div",
|
|
817
821
|
{
|
|
@@ -857,7 +861,7 @@ function AmountStep({
|
|
|
857
861
|
}
|
|
858
862
|
)
|
|
859
863
|
] }),
|
|
860
|
-
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", style: { marginTop: 16 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${
|
|
864
|
+
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", style: { marginTop: 16 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)}...` : `Switch your wallet to ${_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)} to continue.` }) }),
|
|
861
865
|
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-error", children: [
|
|
862
866
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
863
867
|
"svg",
|
|
@@ -881,7 +885,7 @@ function AmountStep({
|
|
|
881
885
|
] })
|
|
882
886
|
] }),
|
|
883
887
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
884
|
-
|
|
888
|
+
_chunkLT3QKJI2cjs.Button,
|
|
885
889
|
{
|
|
886
890
|
onClick: handleContinue,
|
|
887
891
|
fullWidth: true,
|
|
@@ -889,7 +893,7 @@ function AmountStep({
|
|
|
889
893
|
children: "Continue"
|
|
890
894
|
}
|
|
891
895
|
) }),
|
|
892
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
896
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
893
897
|
] });
|
|
894
898
|
}
|
|
895
899
|
|
|
@@ -920,7 +924,7 @@ function ConfirmStep({
|
|
|
920
924
|
const hasAttemptedSwitch = _react.useRef.call(void 0, false);
|
|
921
925
|
const chainMismatch = _optionalChain([walletClient, 'optionalAccess', _13 => _13.chain, 'optionalAccess', _14 => _14.id]) && walletClient.chain.id !== asset.chainId;
|
|
922
926
|
const sameRoute = targetChain === asset.chainId && targetToken.toLowerCase() === asset.token.toLowerCase();
|
|
923
|
-
const targetSymbol = sameRoute ? asset.symbol :
|
|
927
|
+
const targetSymbol = sameRoute ? asset.symbol : _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
924
928
|
const formattedSendAmount = amount && !Number.isNaN(Number(amount)) ? Number(amount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
925
929
|
const formattedReceiveAmount = (() => {
|
|
926
930
|
if (sameRoute) return formattedSendAmount;
|
|
@@ -939,7 +943,7 @@ function ConfirmStep({
|
|
|
939
943
|
setIsSwitching(true);
|
|
940
944
|
switchChain(asset.chainId).catch((err) => {
|
|
941
945
|
const raw = err instanceof Error ? err.message : "Failed to switch chain";
|
|
942
|
-
setError(
|
|
946
|
+
setError(_chunkLT3QKJI2cjs.formatUserError.call(void 0, raw));
|
|
943
947
|
}).finally(() => {
|
|
944
948
|
setIsSwitching(false);
|
|
945
949
|
});
|
|
@@ -954,7 +958,7 @@ function ConfirmStep({
|
|
|
954
958
|
return;
|
|
955
959
|
}
|
|
956
960
|
if (chainMismatch) {
|
|
957
|
-
setError(`Switch to ${
|
|
961
|
+
setError(`Switch to ${_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)} to sign`);
|
|
958
962
|
return;
|
|
959
963
|
}
|
|
960
964
|
const parsedAmount = parseFloat(amount);
|
|
@@ -982,7 +986,7 @@ function ConfirmStep({
|
|
|
982
986
|
throw new Error("Wallet not properly connected");
|
|
983
987
|
}
|
|
984
988
|
const transferTo = sameRoute ? recipient : smartAccount;
|
|
985
|
-
const hash =
|
|
989
|
+
const hash = _chunkLT3QKJI2cjs.isNativeAsset.call(void 0, asset) ? await walletClient.sendTransaction({
|
|
986
990
|
account,
|
|
987
991
|
chain,
|
|
988
992
|
to: transferTo,
|
|
@@ -999,7 +1003,7 @@ function ConfirmStep({
|
|
|
999
1003
|
onConfirm(hash, asset.chainId, amountUnits.toString(), asset.token);
|
|
1000
1004
|
} catch (err) {
|
|
1001
1005
|
const raw = err instanceof Error ? err.message : "Transfer failed";
|
|
1002
|
-
const message =
|
|
1006
|
+
const message = _chunkLT3QKJI2cjs.formatUserError.call(void 0, raw);
|
|
1003
1007
|
setError(message);
|
|
1004
1008
|
_optionalChain([onError, 'optionalCall', _16 => _16(message, "TRANSFER_ERROR")]);
|
|
1005
1009
|
} finally {
|
|
@@ -1018,15 +1022,15 @@ function ConfirmStep({
|
|
|
1018
1022
|
className: "rs-card-value",
|
|
1019
1023
|
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
1020
1024
|
children: [
|
|
1021
|
-
|
|
1025
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, asset.chainId) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1022
1026
|
"img",
|
|
1023
1027
|
{
|
|
1024
|
-
src:
|
|
1028
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, asset.chainId),
|
|
1025
1029
|
alt: "",
|
|
1026
1030
|
style: { width: 16, height: 16, borderRadius: 3 }
|
|
1027
1031
|
}
|
|
1028
1032
|
),
|
|
1029
|
-
|
|
1033
|
+
_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)
|
|
1030
1034
|
]
|
|
1031
1035
|
}
|
|
1032
1036
|
)
|
|
@@ -1039,15 +1043,15 @@ function ConfirmStep({
|
|
|
1039
1043
|
className: "rs-card-value",
|
|
1040
1044
|
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
1041
1045
|
children: [
|
|
1042
|
-
|
|
1046
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1043
1047
|
"img",
|
|
1044
1048
|
{
|
|
1045
|
-
src:
|
|
1049
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, targetChain),
|
|
1046
1050
|
alt: "",
|
|
1047
1051
|
style: { width: 16, height: 16, borderRadius: 3 }
|
|
1048
1052
|
}
|
|
1049
1053
|
),
|
|
1050
|
-
|
|
1054
|
+
_chunkNELAYNA3cjs.getChainName.call(void 0, targetChain)
|
|
1051
1055
|
]
|
|
1052
1056
|
}
|
|
1053
1057
|
)
|
|
@@ -1066,10 +1070,10 @@ function ConfirmStep({
|
|
|
1066
1070
|
className: "rs-card-value",
|
|
1067
1071
|
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
1068
1072
|
children: [
|
|
1069
|
-
|
|
1073
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, asset.symbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1070
1074
|
"img",
|
|
1071
1075
|
{
|
|
1072
|
-
src:
|
|
1076
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, asset.symbol),
|
|
1073
1077
|
alt: "",
|
|
1074
1078
|
style: { width: 16, height: 16, borderRadius: "50%" }
|
|
1075
1079
|
}
|
|
@@ -1089,10 +1093,10 @@ function ConfirmStep({
|
|
|
1089
1093
|
className: "rs-card-value",
|
|
1090
1094
|
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
1091
1095
|
children: [
|
|
1092
|
-
|
|
1096
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1093
1097
|
"img",
|
|
1094
1098
|
{
|
|
1095
|
-
src:
|
|
1099
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol),
|
|
1096
1100
|
alt: "",
|
|
1097
1101
|
style: { width: 16, height: 16, borderRadius: "50%" }
|
|
1098
1102
|
}
|
|
@@ -1105,7 +1109,7 @@ function ConfirmStep({
|
|
|
1105
1109
|
)
|
|
1106
1110
|
] })
|
|
1107
1111
|
] }),
|
|
1108
|
-
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${
|
|
1112
|
+
chainMismatch && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)}...` : `Switch your wallet to ${_chunkNELAYNA3cjs.getChainName.call(void 0, asset.chainId)} to sign.` }) }),
|
|
1109
1113
|
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-alert rs-alert--error", children: [
|
|
1110
1114
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1111
1115
|
"svg",
|
|
@@ -1129,7 +1133,7 @@ function ConfirmStep({
|
|
|
1129
1133
|
] })
|
|
1130
1134
|
] }),
|
|
1131
1135
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1132
|
-
|
|
1136
|
+
_chunkLT3QKJI2cjs.Button,
|
|
1133
1137
|
{
|
|
1134
1138
|
onClick: handleConfirm,
|
|
1135
1139
|
loading: isSubmitting,
|
|
@@ -1138,7 +1142,7 @@ function ConfirmStep({
|
|
|
1138
1142
|
children: "Confirm Order"
|
|
1139
1143
|
}
|
|
1140
1144
|
) }),
|
|
1141
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1145
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
1142
1146
|
] });
|
|
1143
1147
|
}
|
|
1144
1148
|
|
|
@@ -1234,28 +1238,223 @@ function QRCode({ value, size = 200, iconSrc, className }) {
|
|
|
1234
1238
|
}
|
|
1235
1239
|
QRCode.displayName = "QRCode";
|
|
1236
1240
|
|
|
1241
|
+
// src/core/solana.ts
|
|
1242
|
+
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
var _web3js = require('@solana/web3.js');
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
var _spltoken = require('@solana/spl-token');
|
|
1253
|
+
var SOLANA_TOKENS = [
|
|
1254
|
+
{ symbol: "SOL", mint: "native", decimals: 9 },
|
|
1255
|
+
{
|
|
1256
|
+
symbol: "USDC",
|
|
1257
|
+
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
1258
|
+
decimals: 6
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
symbol: "USDT",
|
|
1262
|
+
mint: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
1263
|
+
decimals: 6
|
|
1264
|
+
}
|
|
1265
|
+
];
|
|
1266
|
+
var DEFAULT_SOLANA_RPC_URL = "https://api.mainnet.solana.com";
|
|
1267
|
+
var configuredSolanaRpcUrl = null;
|
|
1268
|
+
var cachedConnections = /* @__PURE__ */ new Map();
|
|
1269
|
+
function configureSolanaRpcUrl(rpcUrl) {
|
|
1270
|
+
const normalized = _optionalChain([rpcUrl, 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()]);
|
|
1271
|
+
configuredSolanaRpcUrl = normalized ? normalized : null;
|
|
1272
|
+
cachedConnections.clear();
|
|
1273
|
+
}
|
|
1274
|
+
function getSolanaRpcUrl() {
|
|
1275
|
+
return _nullishCoalesce(configuredSolanaRpcUrl, () => ( DEFAULT_SOLANA_RPC_URL));
|
|
1276
|
+
}
|
|
1277
|
+
function getSolanaConnection() {
|
|
1278
|
+
const rpcUrl = getSolanaRpcUrl();
|
|
1279
|
+
const cached = cachedConnections.get(rpcUrl);
|
|
1280
|
+
if (cached) {
|
|
1281
|
+
return cached;
|
|
1282
|
+
}
|
|
1283
|
+
const next = new (0, _web3js.Connection)(rpcUrl, "confirmed");
|
|
1284
|
+
cachedConnections.set(rpcUrl, next);
|
|
1285
|
+
return next;
|
|
1286
|
+
}
|
|
1287
|
+
function isNativeSol(token) {
|
|
1288
|
+
return token.mint === "native";
|
|
1289
|
+
}
|
|
1290
|
+
async function buildSolTransferTransaction(connection, from, to, lamports) {
|
|
1291
|
+
const fromPubkey = new (0, _web3js.PublicKey)(from);
|
|
1292
|
+
const toPubkey = new (0, _web3js.PublicKey)(to);
|
|
1293
|
+
const tx = new (0, _web3js.Transaction)().add(
|
|
1294
|
+
_web3js.SystemProgram.transfer({
|
|
1295
|
+
fromPubkey,
|
|
1296
|
+
toPubkey,
|
|
1297
|
+
lamports
|
|
1298
|
+
})
|
|
1299
|
+
);
|
|
1300
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1301
|
+
tx.recentBlockhash = blockhash;
|
|
1302
|
+
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
1303
|
+
tx.feePayer = fromPubkey;
|
|
1304
|
+
return tx;
|
|
1305
|
+
}
|
|
1306
|
+
async function buildSplTransferTransaction(connection, from, to, mint, amount) {
|
|
1307
|
+
const fromPubkey = new (0, _web3js.PublicKey)(from);
|
|
1308
|
+
const toPubkey = new (0, _web3js.PublicKey)(to);
|
|
1309
|
+
const mintPubkey = new (0, _web3js.PublicKey)(mint);
|
|
1310
|
+
const fromAta = await _spltoken.getAssociatedTokenAddress.call(void 0, mintPubkey, fromPubkey);
|
|
1311
|
+
const toAta = await _spltoken.getAssociatedTokenAddress.call(void 0, mintPubkey, toPubkey, true);
|
|
1312
|
+
const tx = new (0, _web3js.Transaction)();
|
|
1313
|
+
const toAtaInfo = await connection.getAccountInfo(toAta);
|
|
1314
|
+
if (!toAtaInfo) {
|
|
1315
|
+
tx.add(
|
|
1316
|
+
_spltoken.createAssociatedTokenAccountInstruction.call(void 0,
|
|
1317
|
+
fromPubkey,
|
|
1318
|
+
toAta,
|
|
1319
|
+
toPubkey,
|
|
1320
|
+
mintPubkey
|
|
1321
|
+
)
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
tx.add(_spltoken.createTransferInstruction.call(void 0, fromAta, toAta, fromPubkey, amount));
|
|
1325
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
1326
|
+
tx.recentBlockhash = blockhash;
|
|
1327
|
+
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
1328
|
+
tx.feePayer = fromPubkey;
|
|
1329
|
+
return tx;
|
|
1330
|
+
}
|
|
1331
|
+
function extractSignature(value) {
|
|
1332
|
+
if (typeof value === "string") {
|
|
1333
|
+
return value.length > 0 ? value : null;
|
|
1334
|
+
}
|
|
1335
|
+
if (typeof value.signature === "string" && value.signature.length > 0) {
|
|
1336
|
+
return value.signature;
|
|
1337
|
+
}
|
|
1338
|
+
if (typeof value.hash === "string" && value.hash.length > 0) {
|
|
1339
|
+
return value.hash;
|
|
1340
|
+
}
|
|
1341
|
+
if (typeof value.txid === "string" && value.txid.length > 0) {
|
|
1342
|
+
return value.txid;
|
|
1343
|
+
}
|
|
1344
|
+
if (typeof value.transactionId === "string" && value.transactionId.length > 0) {
|
|
1345
|
+
return value.transactionId;
|
|
1346
|
+
}
|
|
1347
|
+
return null;
|
|
1348
|
+
}
|
|
1349
|
+
async function sendSolanaTransaction(provider, _connection, transaction) {
|
|
1350
|
+
const result = await provider.signAndSendTransaction(transaction);
|
|
1351
|
+
const signature = extractSignature(result);
|
|
1352
|
+
if (!signature) {
|
|
1353
|
+
throw new Error("Transaction sent but wallet did not return a signature");
|
|
1354
|
+
}
|
|
1355
|
+
return signature;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1237
1358
|
// src/components/steps/DepositAddressStep.tsx
|
|
1238
1359
|
|
|
1239
1360
|
var POLL_INTERVAL_MS = 4e3;
|
|
1361
|
+
function isRecord(value) {
|
|
1362
|
+
return typeof value === "object" && value !== null;
|
|
1363
|
+
}
|
|
1364
|
+
function asNumber(value) {
|
|
1365
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1366
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
1367
|
+
const parsed = Number(value);
|
|
1368
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1369
|
+
}
|
|
1370
|
+
return void 0;
|
|
1371
|
+
}
|
|
1372
|
+
function asChainId(value) {
|
|
1373
|
+
if (typeof value === "string") {
|
|
1374
|
+
if (value.startsWith("solana")) return "solana";
|
|
1375
|
+
const eip155Match = value.match(/^eip155:(\d+)$/);
|
|
1376
|
+
if (eip155Match) return Number(eip155Match[1]);
|
|
1377
|
+
}
|
|
1378
|
+
return asNumber(value);
|
|
1379
|
+
}
|
|
1380
|
+
function asAmount(value) {
|
|
1381
|
+
if (typeof value === "string") return value;
|
|
1382
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1383
|
+
return value.toString();
|
|
1384
|
+
}
|
|
1385
|
+
return void 0;
|
|
1386
|
+
}
|
|
1387
|
+
function asString(value) {
|
|
1388
|
+
return typeof value === "string" ? value : void 0;
|
|
1389
|
+
}
|
|
1390
|
+
function resolveSolanaTokenMeta(token) {
|
|
1391
|
+
if (!token) return {};
|
|
1392
|
+
const normalized = token.toLowerCase();
|
|
1393
|
+
const matched = SOLANA_TOKENS.find(
|
|
1394
|
+
(entry) => entry.mint.toLowerCase() === normalized
|
|
1395
|
+
);
|
|
1396
|
+
if (matched) {
|
|
1397
|
+
return { sourceSymbol: matched.symbol, sourceDecimals: matched.decimals };
|
|
1398
|
+
}
|
|
1399
|
+
if (normalized === "native" || normalized === "11111111111111111111111111111111" || normalized === "so11111111111111111111111111111111111111112") {
|
|
1400
|
+
return { sourceSymbol: "SOL", sourceDecimals: 9 };
|
|
1401
|
+
}
|
|
1402
|
+
return {};
|
|
1403
|
+
}
|
|
1404
|
+
function getDepositEventDetails(event) {
|
|
1405
|
+
if (!_optionalChain([event, 'optionalAccess', _19 => _19.type]) || !isRecord(event.data)) return {};
|
|
1406
|
+
if (event.type === "deposit-received") {
|
|
1407
|
+
const chainId = asChainId(event.data.chain);
|
|
1408
|
+
const token = asString(event.data.token);
|
|
1409
|
+
const solanaMeta = chainId === "solana" ? resolveSolanaTokenMeta(token) : {};
|
|
1410
|
+
return {
|
|
1411
|
+
chainId,
|
|
1412
|
+
amount: asAmount(event.data.amount),
|
|
1413
|
+
token,
|
|
1414
|
+
...solanaMeta
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
if (event.type === "bridge-started") {
|
|
1418
|
+
const source = isRecord(event.data.source) ? event.data.source : void 0;
|
|
1419
|
+
const chainId = asChainId(_optionalChain([source, 'optionalAccess', _20 => _20.chain]));
|
|
1420
|
+
const token = asString(_optionalChain([source, 'optionalAccess', _21 => _21.asset]));
|
|
1421
|
+
const solanaMeta = chainId === "solana" ? resolveSolanaTokenMeta(token) : {};
|
|
1422
|
+
return {
|
|
1423
|
+
chainId,
|
|
1424
|
+
amount: asAmount(_optionalChain([source, 'optionalAccess', _22 => _22.amount])),
|
|
1425
|
+
token,
|
|
1426
|
+
...solanaMeta
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
return {};
|
|
1430
|
+
}
|
|
1240
1431
|
function DepositAddressStep({
|
|
1241
1432
|
smartAccount,
|
|
1433
|
+
solanaDepositAddress,
|
|
1242
1434
|
service,
|
|
1243
1435
|
onDepositDetected,
|
|
1244
1436
|
onError
|
|
1245
1437
|
}) {
|
|
1246
|
-
const
|
|
1438
|
+
const hasSolana = Boolean(solanaDepositAddress);
|
|
1439
|
+
const evmChainIds = _react.useMemo.call(void 0, () => _chunkNELAYNA3cjs.getSupportedChainIds.call(void 0, ), []);
|
|
1440
|
+
const chainOptions = _react.useMemo.call(void 0,
|
|
1441
|
+
() => hasSolana ? [...evmChainIds, "solana"] : evmChainIds,
|
|
1442
|
+
[evmChainIds, hasSolana]
|
|
1443
|
+
);
|
|
1247
1444
|
const BASE_CHAIN_ID = 8453;
|
|
1248
|
-
const defaultChainId =
|
|
1445
|
+
const defaultChainId = evmChainIds.includes(BASE_CHAIN_ID) ? BASE_CHAIN_ID : evmChainIds[0];
|
|
1249
1446
|
const [sourceChainId, setSourceChainId] = _react.useState.call(void 0, defaultChainId);
|
|
1447
|
+
const isSolana = sourceChainId === "solana";
|
|
1250
1448
|
const tokensForChain = _react.useMemo.call(void 0,
|
|
1251
|
-
() =>
|
|
1252
|
-
[sourceChainId]
|
|
1449
|
+
() => isSolana ? SOLANA_TOKENS.map((t) => t.symbol) : _chunkNELAYNA3cjs.getTargetTokenSymbolsForChain.call(void 0, sourceChainId),
|
|
1450
|
+
[sourceChainId, isSolana]
|
|
1253
1451
|
);
|
|
1254
1452
|
const defaultToken = tokensForChain.includes("USDC") ? "USDC" : _nullishCoalesce(tokensForChain[0], () => ( "USDC"));
|
|
1255
1453
|
const [sourceTokenSymbol, setSourceTokenSymbol] = _react.useState.call(void 0, defaultToken);
|
|
1256
1454
|
_react.useEffect.call(void 0, () => {
|
|
1257
1455
|
if (!tokensForChain.includes(sourceTokenSymbol)) {
|
|
1258
|
-
|
|
1456
|
+
const fallback = tokensForChain.includes("USDC") ? "USDC" : _nullishCoalesce(tokensForChain[0], () => ( "USDC"));
|
|
1457
|
+
setSourceTokenSymbol(fallback);
|
|
1259
1458
|
}
|
|
1260
1459
|
}, [tokensForChain, sourceTokenSymbol]);
|
|
1261
1460
|
const [copied, setCopied] = _react.useState.call(void 0, false);
|
|
@@ -1267,21 +1466,34 @@ function DepositAddressStep({
|
|
|
1267
1466
|
const depositHandledRef = _react.useRef.call(void 0, false);
|
|
1268
1467
|
const sourceSelectionRef = _react.useRef.call(void 0, {
|
|
1269
1468
|
chainId: defaultChainId,
|
|
1270
|
-
|
|
1469
|
+
token: typeof defaultChainId === "number" ? _chunkNELAYNA3cjs.getTokenAddress.call(void 0, defaultToken, defaultChainId) : void 0,
|
|
1470
|
+
sourceSymbol: defaultToken
|
|
1271
1471
|
});
|
|
1272
1472
|
_react.useEffect.call(void 0, () => {
|
|
1473
|
+
if (isSolana) {
|
|
1474
|
+
const matched = _nullishCoalesce(SOLANA_TOKENS.find((t) => t.symbol === sourceTokenSymbol), () => ( SOLANA_TOKENS[0]));
|
|
1475
|
+
sourceSelectionRef.current = {
|
|
1476
|
+
chainId: "solana",
|
|
1477
|
+
token: _optionalChain([matched, 'optionalAccess', _23 => _23.mint]),
|
|
1478
|
+
sourceSymbol: _optionalChain([matched, 'optionalAccess', _24 => _24.symbol]),
|
|
1479
|
+
sourceDecimals: _optionalChain([matched, 'optionalAccess', _25 => _25.decimals])
|
|
1480
|
+
};
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1273
1483
|
sourceSelectionRef.current = {
|
|
1274
1484
|
chainId: sourceChainId,
|
|
1275
|
-
|
|
1485
|
+
token: _chunkNELAYNA3cjs.getTokenAddress.call(void 0, sourceTokenSymbol, sourceChainId),
|
|
1486
|
+
sourceSymbol: sourceTokenSymbol
|
|
1276
1487
|
};
|
|
1277
|
-
}, [sourceChainId, sourceTokenSymbol]);
|
|
1488
|
+
}, [sourceChainId, sourceTokenSymbol, isSolana]);
|
|
1489
|
+
const displayAddress = isSolana && solanaDepositAddress ? solanaDepositAddress : smartAccount;
|
|
1278
1490
|
_react.useEffect.call(void 0, () => {
|
|
1279
1491
|
if (!chainDropdownOpen && !tokenDropdownOpen) return;
|
|
1280
1492
|
function handlePointerDown(event) {
|
|
1281
1493
|
const target = event.target;
|
|
1282
1494
|
if (!target) return;
|
|
1283
|
-
const clickedChainDropdown = _optionalChain([chainDropdownRef, 'access',
|
|
1284
|
-
const clickedTokenDropdown = _optionalChain([tokenDropdownRef, 'access',
|
|
1495
|
+
const clickedChainDropdown = _optionalChain([chainDropdownRef, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.contains, 'call', _28 => _28(target)]);
|
|
1496
|
+
const clickedTokenDropdown = _optionalChain([tokenDropdownRef, 'access', _29 => _29.current, 'optionalAccess', _30 => _30.contains, 'call', _31 => _31(target)]);
|
|
1285
1497
|
if (clickedChainDropdown || clickedTokenDropdown) return;
|
|
1286
1498
|
setChainDropdownOpen(false);
|
|
1287
1499
|
setTokenDropdownOpen(false);
|
|
@@ -1295,12 +1507,12 @@ function DepositAddressStep({
|
|
|
1295
1507
|
}, [chainDropdownOpen, tokenDropdownOpen]);
|
|
1296
1508
|
const handleCopy = _react.useCallback.call(void 0, async () => {
|
|
1297
1509
|
try {
|
|
1298
|
-
await navigator.clipboard.writeText(
|
|
1510
|
+
await navigator.clipboard.writeText(displayAddress);
|
|
1299
1511
|
setCopied(true);
|
|
1300
1512
|
setTimeout(() => setCopied(false), 2e3);
|
|
1301
1513
|
} catch (e12) {
|
|
1302
1514
|
const textarea = document.createElement("textarea");
|
|
1303
|
-
textarea.value =
|
|
1515
|
+
textarea.value = displayAddress;
|
|
1304
1516
|
textarea.style.position = "fixed";
|
|
1305
1517
|
textarea.style.opacity = "0";
|
|
1306
1518
|
document.body.appendChild(textarea);
|
|
@@ -1310,7 +1522,12 @@ function DepositAddressStep({
|
|
|
1310
1522
|
setCopied(true);
|
|
1311
1523
|
setTimeout(() => setCopied(false), 2e3);
|
|
1312
1524
|
}
|
|
1313
|
-
}, [
|
|
1525
|
+
}, [displayAddress]);
|
|
1526
|
+
_react.useEffect.call(void 0, () => {
|
|
1527
|
+
setCopied(false);
|
|
1528
|
+
setChainDropdownOpen(false);
|
|
1529
|
+
setTokenDropdownOpen(false);
|
|
1530
|
+
}, [sourceChainId]);
|
|
1314
1531
|
_react.useEffect.call(void 0, () => {
|
|
1315
1532
|
depositHandledRef.current = false;
|
|
1316
1533
|
setPollingError(null);
|
|
@@ -1323,18 +1540,27 @@ function DepositAddressStep({
|
|
|
1323
1540
|
const status = await service.fetchLatestStatus(smartAccount);
|
|
1324
1541
|
if (cancelled || depositHandledRef.current) return;
|
|
1325
1542
|
const event = status.lastEvent;
|
|
1326
|
-
const eventTxHash =
|
|
1543
|
+
const eventTxHash = _chunkLT3QKJI2cjs.isDepositEvent.call(void 0, event) ? _nullishCoalesce(_chunkLT3QKJI2cjs.getEventTxHash.call(void 0, event), () => ( null)) : null;
|
|
1327
1544
|
if (baselineTxHash === void 0) {
|
|
1328
1545
|
baselineTxHash = eventTxHash;
|
|
1329
|
-
} else if (eventTxHash && eventTxHash
|
|
1330
|
-
const details =
|
|
1546
|
+
} else if (eventTxHash && (!baselineTxHash || !_chunkLT3QKJI2cjs.txRefsMatch.call(void 0, eventTxHash, baselineTxHash))) {
|
|
1547
|
+
const details = getDepositEventDetails(event);
|
|
1331
1548
|
const fallback = sourceSelectionRef.current;
|
|
1332
1549
|
const chainId = _nullishCoalesce(details.chainId, () => ( fallback.chainId));
|
|
1333
1550
|
const amount = _nullishCoalesce(details.amount, () => ( "0"));
|
|
1334
|
-
const token = _nullishCoalesce(details.token, () => (
|
|
1551
|
+
const token = _nullishCoalesce(details.token, () => ( fallback.token));
|
|
1552
|
+
const sourceSymbol = _nullishCoalesce(details.sourceSymbol, () => ( fallback.sourceSymbol));
|
|
1553
|
+
const sourceDecimals = _nullishCoalesce(details.sourceDecimals, () => ( fallback.sourceDecimals));
|
|
1335
1554
|
if (token) {
|
|
1336
1555
|
depositHandledRef.current = true;
|
|
1337
|
-
onDepositDetected(
|
|
1556
|
+
onDepositDetected(
|
|
1557
|
+
eventTxHash,
|
|
1558
|
+
chainId,
|
|
1559
|
+
amount,
|
|
1560
|
+
token,
|
|
1561
|
+
sourceSymbol,
|
|
1562
|
+
sourceDecimals
|
|
1563
|
+
);
|
|
1338
1564
|
return;
|
|
1339
1565
|
}
|
|
1340
1566
|
}
|
|
@@ -1343,7 +1569,7 @@ function DepositAddressStep({
|
|
|
1343
1569
|
if (!cancelled) {
|
|
1344
1570
|
const msg = err instanceof Error ? err.message : "Failed to check status";
|
|
1345
1571
|
setPollingError(msg);
|
|
1346
|
-
_optionalChain([onError, 'optionalCall',
|
|
1572
|
+
_optionalChain([onError, 'optionalCall', _32 => _32(msg, "STATUS_POLL_ERROR")]);
|
|
1347
1573
|
}
|
|
1348
1574
|
}
|
|
1349
1575
|
if (!cancelled && !depositHandledRef.current) {
|
|
@@ -1356,31 +1582,31 @@ function DepositAddressStep({
|
|
|
1356
1582
|
clearTimeout(timeoutId);
|
|
1357
1583
|
};
|
|
1358
1584
|
}, [smartAccount, service, onDepositDetected, onError]);
|
|
1359
|
-
const
|
|
1585
|
+
const qrIconSrc = _chunkNELAYNA3cjs.getChainIcon.call(void 0, sourceChainId);
|
|
1360
1586
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
1361
1587
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-body", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address", children: [
|
|
1362
1588
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-selectors", children: [
|
|
1363
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-dropdown", ref:
|
|
1364
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-label", children: "
|
|
1589
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-dropdown", ref: chainDropdownRef, children: [
|
|
1590
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-label", children: "Chain" }),
|
|
1365
1591
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1366
1592
|
"button",
|
|
1367
1593
|
{
|
|
1368
1594
|
type: "button",
|
|
1369
1595
|
className: "rs-deposit-address-dropdown-trigger",
|
|
1370
1596
|
onClick: () => {
|
|
1371
|
-
|
|
1372
|
-
|
|
1597
|
+
setChainDropdownOpen(!chainDropdownOpen);
|
|
1598
|
+
setTokenDropdownOpen(false);
|
|
1373
1599
|
},
|
|
1374
1600
|
children: [
|
|
1375
|
-
|
|
1601
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, sourceChainId) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1376
1602
|
"img",
|
|
1377
1603
|
{
|
|
1378
|
-
src:
|
|
1604
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, sourceChainId),
|
|
1379
1605
|
alt: "",
|
|
1380
1606
|
className: "rs-deposit-address-dropdown-icon"
|
|
1381
1607
|
}
|
|
1382
1608
|
),
|
|
1383
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1609
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunkNELAYNA3cjs.getChainName.call(void 0, sourceChainId) }),
|
|
1384
1610
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1385
1611
|
"svg",
|
|
1386
1612
|
{
|
|
@@ -1402,51 +1628,51 @@ function DepositAddressStep({
|
|
|
1402
1628
|
]
|
|
1403
1629
|
}
|
|
1404
1630
|
),
|
|
1405
|
-
|
|
1631
|
+
chainDropdownOpen && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-menu", children: chainOptions.map((chainId) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1406
1632
|
"button",
|
|
1407
1633
|
{
|
|
1408
1634
|
type: "button",
|
|
1409
|
-
className: `rs-deposit-address-dropdown-item ${
|
|
1635
|
+
className: `rs-deposit-address-dropdown-item ${chainId === sourceChainId ? "rs-deposit-address-dropdown-item--active" : ""}`,
|
|
1410
1636
|
onClick: () => {
|
|
1411
|
-
|
|
1412
|
-
|
|
1637
|
+
setSourceChainId(chainId);
|
|
1638
|
+
setChainDropdownOpen(false);
|
|
1413
1639
|
},
|
|
1414
1640
|
children: [
|
|
1415
|
-
|
|
1641
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, chainId) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1416
1642
|
"img",
|
|
1417
1643
|
{
|
|
1418
|
-
src:
|
|
1644
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, chainId),
|
|
1419
1645
|
alt: "",
|
|
1420
1646
|
className: "rs-deposit-address-dropdown-icon"
|
|
1421
1647
|
}
|
|
1422
1648
|
),
|
|
1423
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1649
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunkNELAYNA3cjs.getChainName.call(void 0, chainId) })
|
|
1424
1650
|
]
|
|
1425
1651
|
},
|
|
1426
|
-
|
|
1652
|
+
String(chainId)
|
|
1427
1653
|
)) })
|
|
1428
1654
|
] }),
|
|
1429
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-dropdown", ref:
|
|
1430
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-label", children: "
|
|
1655
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-dropdown", ref: tokenDropdownRef, children: [
|
|
1656
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-label", children: "Token" }),
|
|
1431
1657
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1432
1658
|
"button",
|
|
1433
1659
|
{
|
|
1434
1660
|
type: "button",
|
|
1435
1661
|
className: "rs-deposit-address-dropdown-trigger",
|
|
1436
1662
|
onClick: () => {
|
|
1437
|
-
|
|
1438
|
-
|
|
1663
|
+
setTokenDropdownOpen(!tokenDropdownOpen);
|
|
1664
|
+
setChainDropdownOpen(false);
|
|
1439
1665
|
},
|
|
1440
1666
|
children: [
|
|
1441
|
-
|
|
1667
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, sourceTokenSymbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1442
1668
|
"img",
|
|
1443
1669
|
{
|
|
1444
|
-
src:
|
|
1670
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, sourceTokenSymbol),
|
|
1445
1671
|
alt: "",
|
|
1446
1672
|
className: "rs-deposit-address-dropdown-icon"
|
|
1447
1673
|
}
|
|
1448
1674
|
),
|
|
1449
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1675
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: sourceTokenSymbol }),
|
|
1450
1676
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1451
1677
|
"svg",
|
|
1452
1678
|
{
|
|
@@ -1468,35 +1694,39 @@ function DepositAddressStep({
|
|
|
1468
1694
|
]
|
|
1469
1695
|
}
|
|
1470
1696
|
),
|
|
1471
|
-
|
|
1697
|
+
tokenDropdownOpen && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-dropdown-menu", children: tokensForChain.map((symbol) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1472
1698
|
"button",
|
|
1473
1699
|
{
|
|
1474
1700
|
type: "button",
|
|
1475
|
-
className: `rs-deposit-address-dropdown-item ${
|
|
1701
|
+
className: `rs-deposit-address-dropdown-item ${symbol === sourceTokenSymbol ? "rs-deposit-address-dropdown-item--active" : ""}`,
|
|
1476
1702
|
onClick: () => {
|
|
1477
|
-
|
|
1478
|
-
|
|
1703
|
+
setSourceTokenSymbol(symbol);
|
|
1704
|
+
setTokenDropdownOpen(false);
|
|
1479
1705
|
},
|
|
1480
1706
|
children: [
|
|
1481
|
-
|
|
1707
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, symbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1482
1708
|
"img",
|
|
1483
1709
|
{
|
|
1484
|
-
src:
|
|
1710
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, symbol),
|
|
1485
1711
|
alt: "",
|
|
1486
1712
|
className: "rs-deposit-address-dropdown-icon"
|
|
1487
1713
|
}
|
|
1488
1714
|
),
|
|
1489
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children:
|
|
1715
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: symbol })
|
|
1490
1716
|
]
|
|
1491
1717
|
},
|
|
1492
|
-
|
|
1718
|
+
symbol
|
|
1493
1719
|
)) })
|
|
1494
1720
|
] })
|
|
1495
1721
|
] }),
|
|
1496
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-qr", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QRCode, { value:
|
|
1722
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-qr", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QRCode, { value: displayAddress, size: 200, iconSrc: qrIconSrc }) }),
|
|
1497
1723
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-info", children: [
|
|
1498
|
-
/* @__PURE__ */ _jsxruntime.
|
|
1499
|
-
|
|
1724
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-deposit-address-label", children: [
|
|
1725
|
+
"Your ",
|
|
1726
|
+
isSolana ? "Solana" : "EVM",
|
|
1727
|
+
" deposit address"
|
|
1728
|
+
] }),
|
|
1729
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-value", children: displayAddress }),
|
|
1500
1730
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1501
1731
|
"button",
|
|
1502
1732
|
{
|
|
@@ -1536,180 +1766,900 @@ function DepositAddressStep({
|
|
|
1536
1766
|
] }),
|
|
1537
1767
|
pollingError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-deposit-address-error", children: pollingError })
|
|
1538
1768
|
] }) }),
|
|
1539
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1769
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
1540
1770
|
] });
|
|
1541
1771
|
}
|
|
1542
1772
|
DepositAddressStep.displayName = "DepositAddressStep";
|
|
1543
1773
|
|
|
1544
|
-
// src/
|
|
1774
|
+
// src/components/steps/SolanaTokenSelectStep.tsx
|
|
1545
1775
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
return address ? address.toLowerCase() : null;
|
|
1551
|
-
}
|
|
1552
|
-
function DepositFlow({
|
|
1553
|
-
dappWalletClient,
|
|
1554
|
-
dappPublicClient,
|
|
1555
|
-
dappAddress,
|
|
1556
|
-
targetChain,
|
|
1557
|
-
targetToken,
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
function SolanaTokenSelectStep({
|
|
1779
|
+
solanaAddress,
|
|
1558
1780
|
service,
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
amount: defaultAmount,
|
|
1562
|
-
recipient,
|
|
1563
|
-
signerAddress = _chunkFLXTBFMZcjs.DEFAULT_SIGNER_ADDRESS,
|
|
1564
|
-
sessionChainIds,
|
|
1565
|
-
forceRegister = false,
|
|
1566
|
-
waitForFinalTx = true,
|
|
1567
|
-
reownWallet,
|
|
1568
|
-
onConnect,
|
|
1569
|
-
onDisconnect,
|
|
1570
|
-
onRequestConnect,
|
|
1571
|
-
connectButtonLabel,
|
|
1572
|
-
uiConfig,
|
|
1573
|
-
onStepChange,
|
|
1574
|
-
onTotalBalanceChange,
|
|
1575
|
-
onClose,
|
|
1576
|
-
onConnected,
|
|
1577
|
-
onDepositSubmitted,
|
|
1578
|
-
onDepositComplete,
|
|
1579
|
-
onDepositFailed,
|
|
1580
|
-
onError,
|
|
1781
|
+
onContinue,
|
|
1782
|
+
onTotalBalanceComputed,
|
|
1581
1783
|
debug
|
|
1582
1784
|
}) {
|
|
1583
|
-
const [
|
|
1584
|
-
const [
|
|
1585
|
-
const [
|
|
1586
|
-
const [
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1785
|
+
const [tokenBalances, setTokenBalances] = _react.useState.call(void 0, []);
|
|
1786
|
+
const [selectedSymbol, setSelectedSymbol] = _react.useState.call(void 0, null);
|
|
1787
|
+
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
1788
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
1789
|
+
_react.useEffect.call(void 0, () => {
|
|
1790
|
+
let active = true;
|
|
1791
|
+
async function loadBalances() {
|
|
1792
|
+
if (!solanaAddress) {
|
|
1793
|
+
setLoading(false);
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
setLoading(true);
|
|
1797
|
+
setError(null);
|
|
1798
|
+
const portfolioBySymbol = {};
|
|
1799
|
+
try {
|
|
1800
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-token-select", "portfolio:request", {
|
|
1801
|
+
solanaAddress
|
|
1802
|
+
});
|
|
1803
|
+
const portfolio = await service.fetchSolanaPortfolio(solanaAddress);
|
|
1804
|
+
if (!active) return;
|
|
1805
|
+
for (const t of portfolio.tokens) {
|
|
1806
|
+
const symbol = t.symbol.toUpperCase();
|
|
1807
|
+
if (!SOLANA_TOKENS.some((st) => st.symbol === symbol)) continue;
|
|
1808
|
+
let parsed = 0n;
|
|
1809
|
+
try {
|
|
1810
|
+
parsed = BigInt(t.balance || "0");
|
|
1811
|
+
} catch (e13) {
|
|
1812
|
+
parsed = 0n;
|
|
1813
|
+
}
|
|
1814
|
+
if (parsed <= 0n) continue;
|
|
1815
|
+
const existing = portfolioBySymbol[symbol];
|
|
1816
|
+
if (!existing || (_nullishCoalesce(t.balanceUsd, () => ( 0))) > existing.balanceUsd) {
|
|
1817
|
+
portfolioBySymbol[symbol] = {
|
|
1818
|
+
balance: parsed,
|
|
1819
|
+
balanceUsd: _nullishCoalesce(t.balanceUsd, () => ( 0))
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-token-select", "portfolio:success", {
|
|
1824
|
+
symbols: Object.keys(portfolioBySymbol)
|
|
1825
|
+
});
|
|
1826
|
+
} catch (err) {
|
|
1827
|
+
if (!active) return;
|
|
1828
|
+
_chunkLT3QKJI2cjs.debugError.call(void 0, debug, "solana-token-select", "portfolio:failure", err, {
|
|
1829
|
+
solanaAddress
|
|
1830
|
+
});
|
|
1831
|
+
setError(
|
|
1832
|
+
err instanceof Error ? err.message : "Failed to load balances"
|
|
1833
|
+
);
|
|
1834
|
+
setTokenBalances([]);
|
|
1835
|
+
setLoading(false);
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
const results = [];
|
|
1839
|
+
for (const token of SOLANA_TOKENS) {
|
|
1840
|
+
const fromPortfolio = portfolioBySymbol[token.symbol];
|
|
1841
|
+
if (fromPortfolio && fromPortfolio.balance > 0n) {
|
|
1842
|
+
results.push({
|
|
1843
|
+
token,
|
|
1844
|
+
balance: fromPortfolio.balance,
|
|
1845
|
+
balanceUsd: fromPortfolio.balanceUsd
|
|
1846
|
+
});
|
|
1603
1847
|
}
|
|
1604
1848
|
}
|
|
1849
|
+
if (!active) return;
|
|
1850
|
+
setTokenBalances(results);
|
|
1851
|
+
setLoading(false);
|
|
1852
|
+
const totalUsd = results.reduce((sum, r) => sum + r.balanceUsd, 0);
|
|
1853
|
+
_optionalChain([onTotalBalanceComputed, 'optionalCall', _33 => _33(totalUsd)]);
|
|
1605
1854
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
if (!_optionalChain([dappWalletClient, 'optionalAccess', _26 => _26.switchChain])) return void 0;
|
|
1610
|
-
return async (chainId) => {
|
|
1611
|
-
await _optionalChain([dappWalletClient, 'access', _27 => _27.switchChain, 'optionalCall', _28 => _28({ id: chainId })]);
|
|
1855
|
+
void loadBalances();
|
|
1856
|
+
return () => {
|
|
1857
|
+
active = false;
|
|
1612
1858
|
};
|
|
1613
|
-
}, [
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
kind: "connected"
|
|
1623
|
-
});
|
|
1624
|
-
seen.add(connectedWalletAddress.toLowerCase());
|
|
1625
|
-
}
|
|
1626
|
-
if (_optionalChain([reownWallet, 'optionalAccess', _31 => _31.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(reownWallet.address.toLowerCase())) {
|
|
1627
|
-
options.push({
|
|
1628
|
-
address: reownWallet.address,
|
|
1629
|
-
label: "External Wallet",
|
|
1630
|
-
kind: "external",
|
|
1631
|
-
icon: reownWallet.icon
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
return options;
|
|
1635
|
-
}, [
|
|
1636
|
-
connectedWalletAddress,
|
|
1637
|
-
dappAddress,
|
|
1638
|
-
_optionalChain([reownWallet, 'optionalAccess', _32 => _32.address]),
|
|
1639
|
-
_optionalChain([reownWallet, 'optionalAccess', _33 => _33.isConnected]),
|
|
1640
|
-
_optionalChain([reownWallet, 'optionalAccess', _34 => _34.walletClient]),
|
|
1641
|
-
_optionalChain([reownWallet, 'optionalAccess', _35 => _35.publicClient]),
|
|
1642
|
-
_optionalChain([reownWallet, 'optionalAccess', _36 => _36.icon])
|
|
1643
|
-
]);
|
|
1644
|
-
const canAutoLock = _optionalChain([dappWalletClient, 'optionalAccess', _37 => _37.account]) && dappAddress && !reownWallet;
|
|
1645
|
-
const hasWalletOptions = walletOptions.length > 0;
|
|
1646
|
-
const hasReownSession = Boolean(
|
|
1647
|
-
_optionalChain([reownWallet, 'optionalAccess', _38 => _38.isConnected]) || _optionalChain([reownWallet, 'optionalAccess', _39 => _39.address])
|
|
1859
|
+
}, [debug, solanaAddress, service, onTotalBalanceComputed]);
|
|
1860
|
+
const rows = _react.useMemo.call(void 0,
|
|
1861
|
+
() => [...tokenBalances].sort((a, b) => {
|
|
1862
|
+
if (a.balanceUsd !== b.balanceUsd) return b.balanceUsd - a.balanceUsd;
|
|
1863
|
+
if (b.balance > a.balance) return 1;
|
|
1864
|
+
if (b.balance < a.balance) return -1;
|
|
1865
|
+
return 0;
|
|
1866
|
+
}),
|
|
1867
|
+
[tokenBalances]
|
|
1648
1868
|
);
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1869
|
+
const selectedEntry = selectedSymbol ? rows.find((r) => r.token.symbol === selectedSymbol) : null;
|
|
1870
|
+
if (error) {
|
|
1871
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-alert rs-alert--error", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-alert-text", children: error }) }) }) });
|
|
1872
|
+
}
|
|
1873
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
1874
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-title", children: "Select source asset" }) }),
|
|
1875
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1876
|
+
"div",
|
|
1877
|
+
{
|
|
1878
|
+
className: "rs-step-body",
|
|
1879
|
+
style: { paddingTop: 4, overflow: "auto", maxHeight: 340 },
|
|
1880
|
+
children: [
|
|
1881
|
+
loading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", style: { padding: "40px 12px" }, children: [
|
|
1882
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.Spinner, { className: "rs-text-tertiary" }),
|
|
1883
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-text-sm rs-text-tertiary", children: "Loading balances" })
|
|
1884
|
+
] }),
|
|
1885
|
+
!loading && rows.length === 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-empty-state", children: [
|
|
1886
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1887
|
+
"svg",
|
|
1888
|
+
{
|
|
1889
|
+
className: "rs-empty-icon",
|
|
1890
|
+
viewBox: "0 0 24 24",
|
|
1891
|
+
fill: "none",
|
|
1892
|
+
stroke: "currentColor",
|
|
1893
|
+
strokeWidth: "1.5",
|
|
1894
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1895
|
+
"path",
|
|
1896
|
+
{
|
|
1897
|
+
strokeLinecap: "round",
|
|
1898
|
+
strokeLinejoin: "round",
|
|
1899
|
+
d: "M21 12a2.25 2.25 0 00-2.25-2.25H15a3 3 0 11-6 0H5.25A2.25 2.25 0 003 12m18 0v6a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 18v-6m18 0V9M3 12V9m18 0a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 9m18 0V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v3"
|
|
1900
|
+
}
|
|
1901
|
+
)
|
|
1902
|
+
}
|
|
1903
|
+
),
|
|
1904
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-empty-text", children: "No funds in connected wallet" }),
|
|
1905
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-empty-address", children: [
|
|
1906
|
+
solanaAddress.slice(0, 6),
|
|
1907
|
+
"...",
|
|
1908
|
+
solanaAddress.slice(-4)
|
|
1909
|
+
] })
|
|
1910
|
+
] }),
|
|
1911
|
+
!loading && rows.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-list", children: rows.map((entry) => {
|
|
1912
|
+
const isSelected = selectedSymbol === entry.token.symbol;
|
|
1913
|
+
const tokenIcon = _chunkNELAYNA3cjs.getTokenIcon.call(void 0, entry.token.symbol);
|
|
1914
|
+
const chainIcon = _chunkNELAYNA3cjs.getChainIcon.call(void 0, "solana");
|
|
1915
|
+
let formattedBalance;
|
|
1916
|
+
try {
|
|
1917
|
+
const raw = _viem.formatUnits.call(void 0, entry.balance, entry.token.decimals);
|
|
1918
|
+
const numeric = Number(raw);
|
|
1919
|
+
formattedBalance = Number.isFinite(numeric) ? _chunkLT3QKJI2cjs.tokenFormatter.format(numeric) : raw;
|
|
1920
|
+
} catch (e14) {
|
|
1921
|
+
formattedBalance = "...";
|
|
1922
|
+
}
|
|
1923
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1924
|
+
"button",
|
|
1925
|
+
{
|
|
1926
|
+
type: "button",
|
|
1927
|
+
onClick: () => setSelectedSymbol(entry.token.symbol),
|
|
1928
|
+
className: `rs-asset-row ${isSelected ? "rs-asset-row--selected" : ""}`,
|
|
1929
|
+
style: { textAlign: "left" },
|
|
1930
|
+
children: [
|
|
1931
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-asset-info", children: [
|
|
1932
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-asset-icon-wrapper", children: [
|
|
1933
|
+
tokenIcon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1934
|
+
"img",
|
|
1935
|
+
{
|
|
1936
|
+
src: tokenIcon,
|
|
1937
|
+
alt: entry.token.symbol,
|
|
1938
|
+
className: "rs-asset-icon",
|
|
1939
|
+
style: { background: "transparent" }
|
|
1940
|
+
}
|
|
1941
|
+
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-icon", children: entry.token.symbol.slice(0, 4) }),
|
|
1942
|
+
chainIcon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1943
|
+
"img",
|
|
1944
|
+
{
|
|
1945
|
+
src: chainIcon,
|
|
1946
|
+
alt: "Solana",
|
|
1947
|
+
className: "rs-asset-chain-badge"
|
|
1948
|
+
}
|
|
1949
|
+
)
|
|
1950
|
+
] }),
|
|
1951
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
1952
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-asset-name", children: [
|
|
1953
|
+
entry.token.symbol,
|
|
1954
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-asset-chain", children: " on Solana" })
|
|
1955
|
+
] }),
|
|
1956
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-asset-balance-small", children: [
|
|
1957
|
+
formattedBalance,
|
|
1958
|
+
" ",
|
|
1959
|
+
entry.token.symbol
|
|
1960
|
+
] })
|
|
1961
|
+
] })
|
|
1962
|
+
] }),
|
|
1963
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-asset-balance", children: entry.balanceUsd > 0 ? _chunkLT3QKJI2cjs.currencyFormatter.format(entry.balanceUsd) : `${formattedBalance} ${entry.token.symbol}` })
|
|
1964
|
+
]
|
|
1965
|
+
},
|
|
1966
|
+
entry.token.symbol
|
|
1967
|
+
);
|
|
1968
|
+
}) })
|
|
1969
|
+
]
|
|
1970
|
+
}
|
|
1971
|
+
),
|
|
1972
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1973
|
+
_chunkLT3QKJI2cjs.Button,
|
|
1974
|
+
{
|
|
1975
|
+
onClick: () => selectedEntry && onContinue(
|
|
1976
|
+
selectedEntry.token,
|
|
1977
|
+
selectedEntry.balance,
|
|
1978
|
+
selectedEntry.balanceUsd
|
|
1979
|
+
),
|
|
1980
|
+
disabled: !selectedEntry,
|
|
1981
|
+
fullWidth: true,
|
|
1982
|
+
children: "Continue"
|
|
1983
|
+
}
|
|
1984
|
+
) }),
|
|
1985
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
1986
|
+
] });
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// src/components/steps/SolanaAmountStep.tsx
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
1994
|
+
function SolanaAmountStep({
|
|
1995
|
+
token,
|
|
1996
|
+
balance,
|
|
1997
|
+
balanceUsd,
|
|
1998
|
+
onContinue,
|
|
1999
|
+
debug
|
|
2000
|
+
}) {
|
|
2001
|
+
const [amount, setAmount] = _react.useState.call(void 0, "");
|
|
2002
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
2003
|
+
const formattedBalance = _react.useMemo.call(void 0, () => {
|
|
2004
|
+
try {
|
|
2005
|
+
const raw = _viem.formatUnits.call(void 0, balance, token.decimals);
|
|
2006
|
+
const numeric = Number(raw);
|
|
2007
|
+
if (!Number.isFinite(numeric)) return raw;
|
|
2008
|
+
return _chunkLT3QKJI2cjs.tokenFormatter.format(numeric);
|
|
2009
|
+
} catch (e15) {
|
|
2010
|
+
return "...";
|
|
2011
|
+
}
|
|
2012
|
+
}, [balance, token.decimals]);
|
|
2013
|
+
const formattedBalanceUsd = _react.useMemo.call(void 0, () => {
|
|
2014
|
+
if (!Number.isFinite(balanceUsd) || balanceUsd <= 0) return null;
|
|
2015
|
+
return _chunkLT3QKJI2cjs.currencyFormatter.format(balanceUsd);
|
|
2016
|
+
}, [balanceUsd]);
|
|
2017
|
+
const spendableBalance = _react.useMemo.call(void 0, () => {
|
|
2018
|
+
if (!isNativeSol(token)) return balance;
|
|
2019
|
+
return balance > SOL_FEE_RESERVE_LAMPORTS ? balance - SOL_FEE_RESERVE_LAMPORTS : 0n;
|
|
2020
|
+
}, [balance, token]);
|
|
2021
|
+
const handlePresetClick = (percentage) => {
|
|
2022
|
+
try {
|
|
2023
|
+
const spendableUnits = Number(_viem.formatUnits.call(void 0, spendableBalance, token.decimals));
|
|
2024
|
+
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2025
|
+
const value = spendableUnits * percentage / 100;
|
|
2026
|
+
const maxDecimals = token.decimals > 6 ? 6 : token.decimals;
|
|
2027
|
+
const factor = 10 ** maxDecimals;
|
|
2028
|
+
const truncated = Math.floor(value * factor) / factor;
|
|
2029
|
+
const formatted = truncated.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
2030
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-amount", "amount:preset", {
|
|
2031
|
+
percentage,
|
|
2032
|
+
symbol: token.symbol,
|
|
2033
|
+
formatted
|
|
2034
|
+
});
|
|
2035
|
+
setAmount(formatted);
|
|
2036
|
+
} catch (e16) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
if (error) setError(null);
|
|
2040
|
+
};
|
|
2041
|
+
const handleContinue = () => {
|
|
2042
|
+
const numericAmount = parseFloat(amount);
|
|
2043
|
+
if (isNaN(numericAmount) || numericAmount <= 0) {
|
|
2044
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-amount", "amount:invalid", {
|
|
2045
|
+
amount,
|
|
2046
|
+
reason: "nan-or-non-positive"
|
|
2047
|
+
});
|
|
2048
|
+
setError("Please enter a valid amount");
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
let amountInUnits;
|
|
2052
|
+
try {
|
|
2053
|
+
amountInUnits = _viem.parseUnits.call(void 0, amount, token.decimals);
|
|
2054
|
+
} catch (e17) {
|
|
2055
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-amount", "amount:invalid", {
|
|
2056
|
+
amount,
|
|
2057
|
+
reason: "parse-units-failed"
|
|
2058
|
+
});
|
|
2059
|
+
setError("Please enter a valid amount");
|
|
2060
|
+
return;
|
|
2061
|
+
}
|
|
2062
|
+
if (amountInUnits > spendableBalance) {
|
|
2063
|
+
const isReserveIssue = isNativeSol(token) && amountInUnits <= balance;
|
|
2064
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-amount", "amount:invalid", {
|
|
2065
|
+
amount,
|
|
2066
|
+
balance: balance.toString(),
|
|
2067
|
+
spendableBalance: spendableBalance.toString(),
|
|
2068
|
+
amountInUnits: amountInUnits.toString(),
|
|
2069
|
+
reason: isReserveIssue ? "native-buffer" : "insufficient-balance"
|
|
2070
|
+
});
|
|
2071
|
+
setError(
|
|
2072
|
+
isReserveIssue ? "Use a bit less than your full SOL balance" : "Insufficient balance"
|
|
2073
|
+
);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-amount", "amount:continue", {
|
|
2077
|
+
symbol: token.symbol,
|
|
2078
|
+
amount,
|
|
2079
|
+
amountInUnits: amountInUnits.toString()
|
|
2080
|
+
});
|
|
2081
|
+
setError(null);
|
|
2082
|
+
onContinue(token, amount);
|
|
2083
|
+
};
|
|
2084
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
2085
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { padding: "12px 12px 4px" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-title", children: "Enter amount" }) }),
|
|
2086
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
2087
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-display", children: [
|
|
2088
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-input-wrapper", children: [
|
|
2089
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2090
|
+
"input",
|
|
2091
|
+
{
|
|
2092
|
+
type: "text",
|
|
2093
|
+
inputMode: "decimal",
|
|
2094
|
+
className: "rs-amount-input-large",
|
|
2095
|
+
placeholder: "0.00",
|
|
2096
|
+
value: amount,
|
|
2097
|
+
onChange: (e) => {
|
|
2098
|
+
const raw = e.target.value.replace(/[^0-9.]/g, "");
|
|
2099
|
+
const parts = raw.split(".");
|
|
2100
|
+
if (parts.length > 2) return;
|
|
2101
|
+
setAmount(raw);
|
|
2102
|
+
if (error) setError(null);
|
|
2103
|
+
},
|
|
2104
|
+
autoFocus: true
|
|
2105
|
+
}
|
|
2106
|
+
),
|
|
2107
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-amount-token-value", children: token.symbol })
|
|
2108
|
+
] }),
|
|
2109
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-available", children: [
|
|
2110
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-amount-available-value", children: [
|
|
2111
|
+
formattedBalance,
|
|
2112
|
+
" ",
|
|
2113
|
+
token.symbol,
|
|
2114
|
+
" available"
|
|
2115
|
+
] }),
|
|
2116
|
+
formattedBalanceUsd && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-amount-available-value", children: formattedBalanceUsd })
|
|
2117
|
+
] })
|
|
2118
|
+
] }),
|
|
2119
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-presets", children: [
|
|
2120
|
+
[25, 50, 75].map((pct) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2121
|
+
"button",
|
|
2122
|
+
{
|
|
2123
|
+
type: "button",
|
|
2124
|
+
className: "rs-amount-preset-btn",
|
|
2125
|
+
onClick: () => handlePresetClick(pct),
|
|
2126
|
+
children: [
|
|
2127
|
+
pct,
|
|
2128
|
+
"%"
|
|
2129
|
+
]
|
|
2130
|
+
},
|
|
2131
|
+
pct
|
|
2132
|
+
)),
|
|
2133
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2134
|
+
"button",
|
|
2135
|
+
{
|
|
2136
|
+
type: "button",
|
|
2137
|
+
className: "rs-amount-preset-btn",
|
|
2138
|
+
onClick: () => handlePresetClick(100),
|
|
2139
|
+
children: "Max"
|
|
2140
|
+
}
|
|
2141
|
+
)
|
|
2142
|
+
] }),
|
|
2143
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-amount-error", children: [
|
|
2144
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2145
|
+
"svg",
|
|
2146
|
+
{
|
|
2147
|
+
viewBox: "0 0 24 24",
|
|
2148
|
+
fill: "none",
|
|
2149
|
+
stroke: "currentColor",
|
|
2150
|
+
strokeWidth: "2",
|
|
2151
|
+
style: { width: 16, height: 16, flexShrink: 0 },
|
|
2152
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2153
|
+
"path",
|
|
2154
|
+
{
|
|
2155
|
+
strokeLinecap: "round",
|
|
2156
|
+
strokeLinejoin: "round",
|
|
2157
|
+
d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
|
|
2158
|
+
}
|
|
2159
|
+
)
|
|
2160
|
+
}
|
|
2161
|
+
),
|
|
2162
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: error })
|
|
2163
|
+
] })
|
|
2164
|
+
] }),
|
|
2165
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2166
|
+
_chunkLT3QKJI2cjs.Button,
|
|
2167
|
+
{
|
|
2168
|
+
onClick: handleContinue,
|
|
2169
|
+
fullWidth: true,
|
|
2170
|
+
disabled: !amount,
|
|
2171
|
+
children: "Continue"
|
|
2172
|
+
}
|
|
2173
|
+
) }),
|
|
2174
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
2175
|
+
] });
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
// src/components/steps/SolanaConfirmStep.tsx
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
|
|
2182
|
+
function SolanaConfirmStep({
|
|
2183
|
+
smartAccount,
|
|
2184
|
+
solanaAddress,
|
|
2185
|
+
solanaDepositAddress,
|
|
2186
|
+
token,
|
|
2187
|
+
amount,
|
|
2188
|
+
targetAmount,
|
|
2189
|
+
targetTokenPriceUsd,
|
|
2190
|
+
targetChain,
|
|
2191
|
+
targetToken,
|
|
2192
|
+
service,
|
|
2193
|
+
solanaProvider,
|
|
2194
|
+
onConfirm,
|
|
2195
|
+
onError,
|
|
2196
|
+
debug
|
|
2197
|
+
}) {
|
|
2198
|
+
const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
|
|
2199
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
2200
|
+
const targetSymbol = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
2201
|
+
const isSameToken = token.symbol.toUpperCase() === targetSymbol.toUpperCase();
|
|
2202
|
+
const formattedAmount = amount && !Number.isNaN(Number(amount)) ? Number(amount).toLocaleString("en-US", { maximumFractionDigits: 6 }) : "0";
|
|
2203
|
+
const formattedReceiveAmount = (() => {
|
|
2204
|
+
if (isSameToken) return formattedAmount;
|
|
2205
|
+
const dollarValue = Number(targetAmount);
|
|
2206
|
+
if (!Number.isFinite(dollarValue) || dollarValue <= 0)
|
|
2207
|
+
return formattedAmount;
|
|
2208
|
+
if (targetTokenPriceUsd !== null && targetTokenPriceUsd > 0) {
|
|
2209
|
+
const tokenAmount = dollarValue / targetTokenPriceUsd;
|
|
2210
|
+
return tokenAmount.toLocaleString("en-US", { maximumFractionDigits: 6 });
|
|
2211
|
+
}
|
|
2212
|
+
return formattedAmount;
|
|
2213
|
+
})();
|
|
2214
|
+
const receiveAmount = isSameToken ? formattedReceiveAmount : `~ ${formattedReceiveAmount}`;
|
|
2215
|
+
const handleConfirm = async () => {
|
|
2216
|
+
if (!solanaProvider) {
|
|
2217
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "submit:blocked", {
|
|
2218
|
+
reason: "missing-provider"
|
|
2219
|
+
});
|
|
2220
|
+
setError("Solana wallet not connected");
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
const parsedAmount = parseFloat(amount);
|
|
2224
|
+
if (isNaN(parsedAmount) || parsedAmount <= 0) {
|
|
2225
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "submit:blocked", {
|
|
2226
|
+
reason: "invalid-amount",
|
|
2227
|
+
amount
|
|
2228
|
+
});
|
|
2229
|
+
setError("Please enter a valid amount");
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
setError(null);
|
|
2233
|
+
setIsSubmitting(true);
|
|
2234
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "submit:start", {
|
|
2235
|
+
smartAccount,
|
|
2236
|
+
solanaAddress,
|
|
2237
|
+
solanaDepositAddress,
|
|
2238
|
+
token: token.symbol,
|
|
2239
|
+
amount
|
|
2240
|
+
});
|
|
2241
|
+
try {
|
|
2242
|
+
const check = await service.checkAccount(smartAccount);
|
|
2243
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "check:success", {
|
|
2244
|
+
smartAccount,
|
|
2245
|
+
isRegistered: check.isRegistered,
|
|
2246
|
+
targetChain: check.targetChain,
|
|
2247
|
+
targetToken: check.targetToken
|
|
2248
|
+
});
|
|
2249
|
+
if (!check.isRegistered) {
|
|
2250
|
+
throw new Error(
|
|
2251
|
+
"Deposit account is not registered yet. Please restart setup and try again."
|
|
2252
|
+
);
|
|
2253
|
+
}
|
|
2254
|
+
const connection = getSolanaConnection();
|
|
2255
|
+
const amountUnits = _viem.parseUnits.call(void 0, amount, token.decimals);
|
|
2256
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "tx:build:start", {
|
|
2257
|
+
token: token.symbol,
|
|
2258
|
+
amount,
|
|
2259
|
+
amountUnits: amountUnits.toString()
|
|
2260
|
+
});
|
|
2261
|
+
const transaction = isNativeSol(token) ? await buildSolTransferTransaction(
|
|
2262
|
+
connection,
|
|
2263
|
+
solanaAddress,
|
|
2264
|
+
solanaDepositAddress,
|
|
2265
|
+
amountUnits
|
|
2266
|
+
) : await buildSplTransferTransaction(
|
|
2267
|
+
connection,
|
|
2268
|
+
solanaAddress,
|
|
2269
|
+
solanaDepositAddress,
|
|
2270
|
+
token.mint,
|
|
2271
|
+
amountUnits
|
|
2272
|
+
);
|
|
2273
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "tx:build:success", {
|
|
2274
|
+
token: token.symbol,
|
|
2275
|
+
instructionCount: transaction.instructions.length,
|
|
2276
|
+
feePayer: _optionalChain([transaction, 'access', _34 => _34.feePayer, 'optionalAccess', _35 => _35.toBase58, 'call', _36 => _36()]),
|
|
2277
|
+
recentBlockhash: transaction.recentBlockhash
|
|
2278
|
+
});
|
|
2279
|
+
const txHash = await sendSolanaTransaction(
|
|
2280
|
+
solanaProvider,
|
|
2281
|
+
connection,
|
|
2282
|
+
transaction
|
|
2283
|
+
);
|
|
2284
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "solana-confirm", "tx:sent", {
|
|
2285
|
+
txHash,
|
|
2286
|
+
amountUnits: amountUnits.toString()
|
|
2287
|
+
});
|
|
2288
|
+
onConfirm(txHash, amountUnits.toString());
|
|
2289
|
+
} catch (err) {
|
|
2290
|
+
const raw = err instanceof Error ? err.message : "Transfer failed";
|
|
2291
|
+
const message = _chunkLT3QKJI2cjs.formatUserError.call(void 0, raw);
|
|
2292
|
+
_chunkLT3QKJI2cjs.debugError.call(void 0, debug, "solana-confirm", "submit:failure", err, {
|
|
2293
|
+
smartAccount,
|
|
2294
|
+
token: token.symbol,
|
|
2295
|
+
amount
|
|
2296
|
+
});
|
|
2297
|
+
setError(message);
|
|
2298
|
+
_optionalChain([onError, 'optionalCall', _37 => _37(message, "SOLANA_TRANSFER_ERROR")]);
|
|
2299
|
+
} finally {
|
|
2300
|
+
setIsSubmitting(false);
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2303
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
2304
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { padding: "12px 12px 10px" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-title", children: "Review order" }) }),
|
|
2305
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body rs-space-y-3", style: { paddingTop: 0 }, children: [
|
|
2306
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card", children: [
|
|
2307
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
|
|
2308
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "Source" }),
|
|
2309
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2310
|
+
"span",
|
|
2311
|
+
{
|
|
2312
|
+
className: "rs-card-value",
|
|
2313
|
+
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
2314
|
+
children: [
|
|
2315
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, "solana") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2316
|
+
"img",
|
|
2317
|
+
{
|
|
2318
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, "solana"),
|
|
2319
|
+
alt: "",
|
|
2320
|
+
style: { width: 16, height: 16, borderRadius: 3 }
|
|
2321
|
+
}
|
|
2322
|
+
),
|
|
2323
|
+
_chunkNELAYNA3cjs.getChainName.call(void 0, "solana")
|
|
2324
|
+
]
|
|
2325
|
+
}
|
|
2326
|
+
)
|
|
2327
|
+
] }),
|
|
2328
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
|
|
2329
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "Destination" }),
|
|
2330
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2331
|
+
"span",
|
|
2332
|
+
{
|
|
2333
|
+
className: "rs-card-value",
|
|
2334
|
+
style: { display: "flex", alignItems: "center", gap: 8 },
|
|
2335
|
+
children: [
|
|
2336
|
+
_chunkNELAYNA3cjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2337
|
+
"img",
|
|
2338
|
+
{
|
|
2339
|
+
src: _chunkNELAYNA3cjs.getChainIcon.call(void 0, targetChain),
|
|
2340
|
+
alt: "",
|
|
2341
|
+
style: { width: 16, height: 16, borderRadius: 3 }
|
|
2342
|
+
}
|
|
2343
|
+
),
|
|
2344
|
+
_chunkNELAYNA3cjs.getChainName.call(void 0, targetChain)
|
|
2345
|
+
]
|
|
2346
|
+
}
|
|
2347
|
+
)
|
|
2348
|
+
] }),
|
|
2349
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
|
|
2350
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "Estimated time" }),
|
|
2351
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-value", children: "< 1 min" })
|
|
2352
|
+
] })
|
|
2353
|
+
] }),
|
|
2354
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card", children: [
|
|
2355
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
|
|
2356
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "You send" }),
|
|
2357
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2358
|
+
"span",
|
|
2359
|
+
{
|
|
2360
|
+
className: "rs-card-value",
|
|
2361
|
+
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
2362
|
+
children: [
|
|
2363
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, token.symbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2364
|
+
"img",
|
|
2365
|
+
{
|
|
2366
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, token.symbol),
|
|
2367
|
+
alt: "",
|
|
2368
|
+
style: { width: 16, height: 16, borderRadius: "50%" }
|
|
2369
|
+
}
|
|
2370
|
+
),
|
|
2371
|
+
formattedAmount,
|
|
2372
|
+
" ",
|
|
2373
|
+
token.symbol
|
|
2374
|
+
]
|
|
2375
|
+
}
|
|
2376
|
+
)
|
|
2377
|
+
] }),
|
|
2378
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
|
|
2379
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "You receive" }),
|
|
2380
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2381
|
+
"span",
|
|
2382
|
+
{
|
|
2383
|
+
className: "rs-card-value",
|
|
2384
|
+
style: { display: "flex", alignItems: "center", gap: 6 },
|
|
2385
|
+
children: [
|
|
2386
|
+
_chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2387
|
+
"img",
|
|
2388
|
+
{
|
|
2389
|
+
src: _chunkNELAYNA3cjs.getTokenIcon.call(void 0, targetSymbol),
|
|
2390
|
+
alt: "",
|
|
2391
|
+
style: { width: 16, height: 16, borderRadius: "50%" }
|
|
2392
|
+
}
|
|
2393
|
+
),
|
|
2394
|
+
receiveAmount,
|
|
2395
|
+
" ",
|
|
2396
|
+
targetSymbol
|
|
2397
|
+
]
|
|
2398
|
+
}
|
|
2399
|
+
)
|
|
2400
|
+
] })
|
|
2401
|
+
] }),
|
|
2402
|
+
error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-alert rs-alert--error", children: [
|
|
2403
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2404
|
+
"svg",
|
|
2405
|
+
{
|
|
2406
|
+
className: "rs-alert-icon",
|
|
2407
|
+
viewBox: "0 0 24 24",
|
|
2408
|
+
fill: "none",
|
|
2409
|
+
stroke: "currentColor",
|
|
2410
|
+
strokeWidth: "2",
|
|
2411
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2412
|
+
"path",
|
|
2413
|
+
{
|
|
2414
|
+
strokeLinecap: "round",
|
|
2415
|
+
strokeLinejoin: "round",
|
|
2416
|
+
d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
|
|
2417
|
+
}
|
|
2418
|
+
)
|
|
2419
|
+
}
|
|
2420
|
+
),
|
|
2421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-alert-text", children: error })
|
|
2422
|
+
] })
|
|
2423
|
+
] }),
|
|
2424
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2425
|
+
_chunkLT3QKJI2cjs.Button,
|
|
2426
|
+
{
|
|
2427
|
+
onClick: handleConfirm,
|
|
2428
|
+
loading: isSubmitting,
|
|
2429
|
+
disabled: !amount || Number(amount) <= 0,
|
|
2430
|
+
fullWidth: true,
|
|
2431
|
+
children: "Confirm Order"
|
|
2432
|
+
}
|
|
2433
|
+
) }),
|
|
2434
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkLT3QKJI2cjs.PoweredBy, {})
|
|
2435
|
+
] });
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// src/DepositFlow.tsx
|
|
2439
|
+
|
|
2440
|
+
function isSameRoute(sourceChain, sourceToken, targetChain, targetToken) {
|
|
2441
|
+
return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
|
|
2442
|
+
}
|
|
2443
|
+
function getAddressKey(address) {
|
|
2444
|
+
return address ? address.toLowerCase() : null;
|
|
2445
|
+
}
|
|
2446
|
+
function DepositFlow({
|
|
2447
|
+
dappWalletClient,
|
|
2448
|
+
dappPublicClient,
|
|
2449
|
+
dappAddress,
|
|
2450
|
+
targetChain,
|
|
2451
|
+
targetToken,
|
|
2452
|
+
service,
|
|
2453
|
+
sourceChain: defaultSourceChain,
|
|
2454
|
+
sourceToken: defaultSourceToken,
|
|
2455
|
+
amount: defaultAmount,
|
|
2456
|
+
recipient,
|
|
2457
|
+
signerAddress = _chunkNELAYNA3cjs.DEFAULT_SIGNER_ADDRESS,
|
|
2458
|
+
sessionChainIds,
|
|
2459
|
+
forceRegister = false,
|
|
2460
|
+
waitForFinalTx = true,
|
|
2461
|
+
reownWallet,
|
|
2462
|
+
onConnect,
|
|
2463
|
+
onDisconnect,
|
|
2464
|
+
onRequestConnect,
|
|
2465
|
+
connectButtonLabel,
|
|
2466
|
+
uiConfig,
|
|
2467
|
+
onStepChange,
|
|
2468
|
+
onTotalBalanceChange,
|
|
2469
|
+
onClose,
|
|
2470
|
+
onConnected,
|
|
2471
|
+
onDepositSubmitted,
|
|
2472
|
+
onDepositComplete,
|
|
2473
|
+
onDepositFailed,
|
|
2474
|
+
onError,
|
|
2475
|
+
debug
|
|
2476
|
+
}) {
|
|
2477
|
+
const [step, setStep] = _react.useState.call(void 0, { type: "setup" });
|
|
2478
|
+
const [flowMode, setFlowMode] = _react.useState.call(void 0, null);
|
|
2479
|
+
const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, 0);
|
|
2480
|
+
const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = _react.useState.call(void 0, false);
|
|
2481
|
+
const [selectedWalletId, setSelectedWalletId] = _react.useState.call(void 0, null);
|
|
2482
|
+
const portfolioAssetsRef = _react.useRef.call(void 0, []);
|
|
2483
|
+
const stableWalletSignerRef = _react.useRef.call(void 0, null);
|
|
2484
|
+
const stableWalletSelectionKeyRef = _react.useRef.call(void 0, null);
|
|
2485
|
+
const logFlow = _react.useCallback.call(void 0,
|
|
2486
|
+
(message, data) => {
|
|
2487
|
+
_chunkLT3QKJI2cjs.debugLog.call(void 0, debug, "deposit-flow", message, data);
|
|
2488
|
+
},
|
|
2489
|
+
[debug]
|
|
2490
|
+
);
|
|
2491
|
+
const logFlowError = _react.useCallback.call(void 0,
|
|
2492
|
+
(message, error, data) => {
|
|
2493
|
+
_chunkLT3QKJI2cjs.debugError.call(void 0, debug, "deposit-flow", message, error, data);
|
|
2494
|
+
},
|
|
2495
|
+
[debug]
|
|
2496
|
+
);
|
|
2497
|
+
const handleAssetsLoaded = _react.useCallback.call(void 0, (assets) => {
|
|
2498
|
+
portfolioAssetsRef.current = assets;
|
|
2499
|
+
}, []);
|
|
2500
|
+
const getTokenPriceUsd = _react.useCallback.call(void 0, (symbol) => {
|
|
2501
|
+
const sym = symbol.toLowerCase();
|
|
2502
|
+
for (const asset of portfolioAssetsRef.current) {
|
|
2503
|
+
if (asset.symbol.toLowerCase() === sym && asset.balanceUsd && asset.balance) {
|
|
2504
|
+
try {
|
|
2505
|
+
const balanceUnits = Number(asset.balance) / 10 ** asset.decimals;
|
|
2506
|
+
if (balanceUnits > 0) return asset.balanceUsd / balanceUnits;
|
|
2507
|
+
} catch (e18) {
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
return null;
|
|
2512
|
+
}, []);
|
|
2513
|
+
const dappSwitchChain = _react.useMemo.call(void 0, () => {
|
|
2514
|
+
if (!_optionalChain([dappWalletClient, 'optionalAccess', _38 => _38.switchChain])) return void 0;
|
|
2515
|
+
return async (chainId) => {
|
|
2516
|
+
await _optionalChain([dappWalletClient, 'access', _39 => _39.switchChain, 'optionalCall', _40 => _40({ id: chainId })]);
|
|
2517
|
+
};
|
|
2518
|
+
}, [dappWalletClient]);
|
|
2519
|
+
const connectedWalletAddress = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _41 => _41.account, 'optionalAccess', _42 => _42.address]), () => ( null));
|
|
2520
|
+
const walletOptions = _react.useMemo.call(void 0, () => {
|
|
2521
|
+
const options = [];
|
|
2522
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2523
|
+
if (connectedWalletAddress && dappAddress) {
|
|
2524
|
+
const id = `evm:${connectedWalletAddress.toLowerCase()}`;
|
|
2525
|
+
options.push({
|
|
2526
|
+
id,
|
|
2527
|
+
address: connectedWalletAddress,
|
|
2528
|
+
label: "Connected Wallet",
|
|
2529
|
+
kind: "connected"
|
|
2530
|
+
});
|
|
2531
|
+
seen.add(id);
|
|
2532
|
+
}
|
|
2533
|
+
if (_optionalChain([reownWallet, 'optionalAccess', _43 => _43.isConnected]) && reownWallet.isSolana && reownWallet.solanaAddress && dappAddress) {
|
|
2534
|
+
const id = _nullishCoalesce(reownWallet.caipAddress, () => ( `solana:${reownWallet.solanaAddress}`));
|
|
2535
|
+
if (!seen.has(id)) {
|
|
2536
|
+
options.push({
|
|
2537
|
+
id,
|
|
2538
|
+
solanaAddress: reownWallet.solanaAddress,
|
|
2539
|
+
label: "Solana Wallet",
|
|
2540
|
+
kind: "solana",
|
|
2541
|
+
icon: reownWallet.icon
|
|
2542
|
+
});
|
|
2543
|
+
seen.add(id);
|
|
2544
|
+
}
|
|
2545
|
+
} else if (_optionalChain([reownWallet, 'optionalAccess', _44 => _44.address]) && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(`evm:${reownWallet.address.toLowerCase()}`)) {
|
|
2546
|
+
const id = `evm:${reownWallet.address.toLowerCase()}`;
|
|
2547
|
+
if (!seen.has(id)) {
|
|
2548
|
+
options.push({
|
|
2549
|
+
id,
|
|
2550
|
+
address: reownWallet.address,
|
|
2551
|
+
label: "External Wallet",
|
|
2552
|
+
kind: "external",
|
|
2553
|
+
icon: reownWallet.icon
|
|
2554
|
+
});
|
|
2555
|
+
seen.add(id);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return options;
|
|
2559
|
+
}, [
|
|
2560
|
+
connectedWalletAddress,
|
|
2561
|
+
dappAddress,
|
|
2562
|
+
_optionalChain([reownWallet, 'optionalAccess', _45 => _45.address]),
|
|
2563
|
+
_optionalChain([reownWallet, 'optionalAccess', _46 => _46.isConnected]),
|
|
2564
|
+
_optionalChain([reownWallet, 'optionalAccess', _47 => _47.walletClient]),
|
|
2565
|
+
_optionalChain([reownWallet, 'optionalAccess', _48 => _48.publicClient]),
|
|
2566
|
+
_optionalChain([reownWallet, 'optionalAccess', _49 => _49.icon]),
|
|
2567
|
+
_optionalChain([reownWallet, 'optionalAccess', _50 => _50.isSolana]),
|
|
2568
|
+
_optionalChain([reownWallet, 'optionalAccess', _51 => _51.solanaAddress]),
|
|
2569
|
+
_optionalChain([reownWallet, 'optionalAccess', _52 => _52.caipAddress])
|
|
2570
|
+
]);
|
|
2571
|
+
const canAutoLock = _optionalChain([dappWalletClient, 'optionalAccess', _53 => _53.account]) && dappAddress && !reownWallet;
|
|
2572
|
+
const hasWalletOptions = walletOptions.length > 0;
|
|
2573
|
+
const hasReownSession = Boolean(
|
|
2574
|
+
_optionalChain([reownWallet, 'optionalAccess', _54 => _54.isConnected]) || _optionalChain([reownWallet, 'optionalAccess', _55 => _55.address])
|
|
2575
|
+
);
|
|
2576
|
+
const showConnectStep = flowMode === null && !canAutoLock && !isConnectSelectionConfirmed;
|
|
2577
|
+
const walletSelectionKey = _react.useMemo.call(void 0, () => {
|
|
2578
|
+
if (flowMode !== "wallet") return null;
|
|
2579
|
+
if (canAutoLock) {
|
|
2580
|
+
return getAddressKey(connectedWalletAddress);
|
|
2581
|
+
}
|
|
2582
|
+
if (!isConnectSelectionConfirmed) return null;
|
|
2583
|
+
return selectedWalletId;
|
|
2584
|
+
}, [
|
|
2585
|
+
flowMode,
|
|
2586
|
+
canAutoLock,
|
|
2587
|
+
connectedWalletAddress,
|
|
2588
|
+
isConnectSelectionConfirmed,
|
|
2589
|
+
selectedWalletId
|
|
2590
|
+
]);
|
|
2591
|
+
const walletSignerContext = _react.useMemo.call(void 0, () => {
|
|
2592
|
+
if (flowMode === "deposit-address") {
|
|
2593
|
+
return null;
|
|
2594
|
+
}
|
|
2595
|
+
if (flowMode === "solana-wallet") {
|
|
2596
|
+
if (!dappAddress) return null;
|
|
2597
|
+
return {
|
|
2598
|
+
ownerAddress: dappAddress,
|
|
2599
|
+
walletClient: void 0,
|
|
2600
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, targetChain))),
|
|
2601
|
+
switchChain: void 0
|
|
2602
|
+
};
|
|
2603
|
+
}
|
|
2604
|
+
if (canAutoLock) {
|
|
2605
|
+
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _56 => _56.chain, 'optionalAccess', _57 => _57.id]), () => ( targetChain));
|
|
2606
|
+
return {
|
|
2607
|
+
ownerAddress: dappWalletClient.account.address,
|
|
2608
|
+
walletClient: dappWalletClient,
|
|
2609
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, fallbackChainId))),
|
|
2610
|
+
switchChain: dappSwitchChain
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
if (!isConnectSelectionConfirmed || !selectedWalletId) return null;
|
|
2614
|
+
const selectedOption = walletOptions.find(
|
|
2615
|
+
(option) => option.id === selectedWalletId
|
|
2616
|
+
);
|
|
2617
|
+
if (!selectedOption) return null;
|
|
2618
|
+
if (selectedOption.kind === "solana") {
|
|
2619
|
+
if (!dappAddress) return null;
|
|
2620
|
+
return {
|
|
2621
|
+
ownerAddress: dappAddress,
|
|
2622
|
+
walletClient: void 0,
|
|
2623
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, targetChain))),
|
|
2624
|
+
switchChain: void 0
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
if (selectedOption.kind === "connected" && _optionalChain([dappWalletClient, 'optionalAccess', _58 => _58.account]) && selectedOption.address && dappWalletClient.account.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
2628
|
+
const fallbackChainId = _nullishCoalesce(_optionalChain([dappWalletClient, 'optionalAccess', _59 => _59.chain, 'optionalAccess', _60 => _60.id]), () => ( targetChain));
|
|
2629
|
+
return {
|
|
2630
|
+
ownerAddress: dappWalletClient.account.address,
|
|
2631
|
+
walletClient: dappWalletClient,
|
|
2632
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, fallbackChainId))),
|
|
2633
|
+
switchChain: dappSwitchChain
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
if (selectedOption.kind === "external" && _optionalChain([reownWallet, 'optionalAccess', _61 => _61.address]) && selectedOption.address && reownWallet.address.toLowerCase() === selectedOption.address.toLowerCase()) {
|
|
2637
|
+
return {
|
|
2638
|
+
ownerAddress: reownWallet.address,
|
|
2639
|
+
walletClient: reownWallet.walletClient,
|
|
2640
|
+
publicClient: _nullishCoalesce(reownWallet.publicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, targetChain))),
|
|
2641
|
+
switchChain: reownWallet.switchChain
|
|
2642
|
+
};
|
|
2643
|
+
}
|
|
2644
|
+
return null;
|
|
2645
|
+
}, [
|
|
2646
|
+
canAutoLock,
|
|
2647
|
+
isConnectSelectionConfirmed,
|
|
2648
|
+
selectedWalletId,
|
|
2649
|
+
walletOptions,
|
|
2650
|
+
dappWalletClient,
|
|
2651
|
+
dappPublicClient,
|
|
2652
|
+
dappSwitchChain,
|
|
2653
|
+
dappAddress,
|
|
2654
|
+
reownWallet,
|
|
2655
|
+
targetChain
|
|
2656
|
+
]);
|
|
2657
|
+
_react.useEffect.call(void 0, () => {
|
|
2658
|
+
if (flowMode !== "wallet") {
|
|
2659
|
+
stableWalletSelectionKeyRef.current = null;
|
|
2660
|
+
stableWalletSignerRef.current = null;
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
1713
2663
|
if (walletSelectionKey !== stableWalletSelectionKeyRef.current) {
|
|
1714
2664
|
stableWalletSelectionKeyRef.current = walletSelectionKey;
|
|
1715
2665
|
stableWalletSignerRef.current = null;
|
|
@@ -1725,7 +2675,7 @@ function DepositFlow({
|
|
|
1725
2675
|
return {
|
|
1726
2676
|
ownerAddress: dappAddress,
|
|
1727
2677
|
walletClient: void 0,
|
|
1728
|
-
publicClient: _nullishCoalesce(dappPublicClient, () => (
|
|
2678
|
+
publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkLT3QKJI2cjs.getPublicClient.call(void 0, targetChain))),
|
|
1729
2679
|
switchChain: void 0
|
|
1730
2680
|
};
|
|
1731
2681
|
}
|
|
@@ -1747,7 +2697,7 @@ function DepositFlow({
|
|
|
1747
2697
|
walletSignerContext,
|
|
1748
2698
|
walletSelectionKey
|
|
1749
2699
|
]);
|
|
1750
|
-
const sessionKeyAddress = _nullishCoalesce(_nullishCoalesce(dappAddress, () => ( _optionalChain([signerContext, 'optionalAccess',
|
|
2700
|
+
const sessionKeyAddress = _nullishCoalesce(_nullishCoalesce(dappAddress, () => ( _optionalChain([signerContext, 'optionalAccess', _62 => _62.ownerAddress]))), () => ( null));
|
|
1751
2701
|
const lastTargetRef = _react.useRef.call(void 0, null);
|
|
1752
2702
|
_react.useEffect.call(void 0, () => {
|
|
1753
2703
|
const prev = lastTargetRef.current;
|
|
@@ -1779,6 +2729,37 @@ function DepositFlow({
|
|
|
1779
2729
|
setIsConnectSelectionConfirmed(false);
|
|
1780
2730
|
}
|
|
1781
2731
|
}, [hasWalletOptions, reownWallet]);
|
|
2732
|
+
const handleBackFromSolanaTokenSelect = _react.useCallback.call(void 0, () => {
|
|
2733
|
+
setFlowMode(null);
|
|
2734
|
+
setStep({ type: "setup" });
|
|
2735
|
+
if (hasWalletOptions || reownWallet) {
|
|
2736
|
+
hasNavigatedBackRef.current = true;
|
|
2737
|
+
setIsConnectSelectionConfirmed(false);
|
|
2738
|
+
}
|
|
2739
|
+
}, [hasWalletOptions, reownWallet]);
|
|
2740
|
+
const handleBackFromSolanaAmount = _react.useCallback.call(void 0, () => {
|
|
2741
|
+
setStep((prev) => {
|
|
2742
|
+
if (prev.type !== "solana-amount") return prev;
|
|
2743
|
+
return {
|
|
2744
|
+
type: "solana-token-select",
|
|
2745
|
+
smartAccount: prev.smartAccount,
|
|
2746
|
+
solanaDepositAddress: prev.solanaDepositAddress
|
|
2747
|
+
};
|
|
2748
|
+
});
|
|
2749
|
+
}, []);
|
|
2750
|
+
const handleBackFromSolanaConfirm = _react.useCallback.call(void 0, () => {
|
|
2751
|
+
setStep((prev) => {
|
|
2752
|
+
if (prev.type !== "solana-confirm") return prev;
|
|
2753
|
+
return {
|
|
2754
|
+
type: "solana-amount",
|
|
2755
|
+
smartAccount: prev.smartAccount,
|
|
2756
|
+
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2757
|
+
token: prev.token,
|
|
2758
|
+
balance: prev.balance,
|
|
2759
|
+
balanceUsd: prev.balanceUsd
|
|
2760
|
+
};
|
|
2761
|
+
});
|
|
2762
|
+
}, []);
|
|
1782
2763
|
const handleBackFromConfirm = _react.useCallback.call(void 0, () => {
|
|
1783
2764
|
setStep((prev) => {
|
|
1784
2765
|
if (prev.type !== "confirm") return prev;
|
|
@@ -1789,50 +2770,90 @@ function DepositFlow({
|
|
|
1789
2770
|
};
|
|
1790
2771
|
});
|
|
1791
2772
|
}, []);
|
|
1792
|
-
const stepIndex = step.type === "setup" ? 0 : step.type === "deposit-address" ? 1 : step.type === "select-asset" ? 1 : step.type === "amount" ? 2 : step.type === "confirm" ? 3 : 4;
|
|
1793
|
-
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
|
|
2773
|
+
const stepIndex = step.type === "setup" ? 0 : step.type === "deposit-address" ? 1 : step.type === "select-asset" ? 1 : step.type === "solana-token-select" ? 1 : step.type === "solana-amount" ? 2 : step.type === "amount" ? 2 : step.type === "confirm" ? 3 : step.type === "solana-confirm" ? 3 : 4;
|
|
2774
|
+
const currentBackHandler = step.type === "deposit-address" ? handleBackFromDepositAddress : step.type === "select-asset" && signerContext && !canAutoLock ? handleBackFromSelectAsset : step.type === "solana-token-select" ? handleBackFromSolanaTokenSelect : step.type === "solana-amount" ? handleBackFromSolanaAmount : step.type === "solana-confirm" ? handleBackFromSolanaConfirm : step.type === "amount" ? handleBackFromAmount : step.type === "confirm" ? handleBackFromConfirm : void 0;
|
|
1794
2775
|
_react.useEffect.call(void 0, () => {
|
|
1795
|
-
_optionalChain([onStepChange, 'optionalCall',
|
|
2776
|
+
_optionalChain([onStepChange, 'optionalCall', _63 => _63(stepIndex, currentBackHandler)]);
|
|
1796
2777
|
}, [stepIndex, currentBackHandler, onStepChange]);
|
|
1797
2778
|
_react.useEffect.call(void 0, () => {
|
|
1798
|
-
|
|
2779
|
+
logFlow("state:changed", {
|
|
2780
|
+
step: step.type,
|
|
2781
|
+
flowMode,
|
|
2782
|
+
targetChain,
|
|
2783
|
+
targetToken,
|
|
2784
|
+
selectedWalletId
|
|
2785
|
+
});
|
|
2786
|
+
}, [
|
|
2787
|
+
flowMode,
|
|
2788
|
+
logFlow,
|
|
2789
|
+
selectedWalletId,
|
|
2790
|
+
step.type,
|
|
2791
|
+
targetChain,
|
|
2792
|
+
targetToken
|
|
2793
|
+
]);
|
|
2794
|
+
_react.useEffect.call(void 0, () => {
|
|
2795
|
+
_optionalChain([onTotalBalanceChange, 'optionalCall', _64 => _64(totalBalanceUsd)]);
|
|
1799
2796
|
}, [totalBalanceUsd, onTotalBalanceChange]);
|
|
1800
2797
|
const isDepositAddressMode = flowMode === "deposit-address";
|
|
2798
|
+
const isSolanaWalletMode = flowMode === "solana-wallet";
|
|
1801
2799
|
const handleSelectProvider = _react.useCallback.call(void 0, () => {
|
|
1802
2800
|
setFlowMode("wallet");
|
|
1803
2801
|
}, []);
|
|
2802
|
+
const handleSelectSolanaWallet = _react.useCallback.call(void 0, () => {
|
|
2803
|
+
setFlowMode("solana-wallet");
|
|
2804
|
+
}, []);
|
|
1804
2805
|
const handleSelectTransferCrypto = _react.useCallback.call(void 0, () => {
|
|
1805
2806
|
setFlowMode("deposit-address");
|
|
1806
2807
|
setStep({ type: "setup" });
|
|
1807
2808
|
}, []);
|
|
1808
|
-
const
|
|
1809
|
-
portfolioAssetsRef.current = [];
|
|
1810
|
-
stableWalletSignerRef.current = null;
|
|
1811
|
-
stableWalletSelectionKeyRef.current = null;
|
|
1812
|
-
hasNavigatedBackRef.current = false;
|
|
1813
|
-
setTotalBalanceUsd(0);
|
|
1814
|
-
setSelectedConnectAddress(null);
|
|
1815
|
-
setIsConnectSelectionConfirmed(false);
|
|
2809
|
+
const handleNewDeposit = _react.useCallback.call(void 0, () => {
|
|
1816
2810
|
setFlowMode(null);
|
|
1817
2811
|
setStep({ type: "setup" });
|
|
1818
2812
|
}, []);
|
|
1819
|
-
const handleNewDeposit = _react.useCallback.call(void 0, () => {
|
|
1820
|
-
handleResetFlow();
|
|
1821
|
-
}, [handleResetFlow]);
|
|
1822
2813
|
const handleSetupComplete = _react.useCallback.call(void 0,
|
|
1823
|
-
(smartAccount) => {
|
|
2814
|
+
(smartAccount, solanaDepositAddress) => {
|
|
2815
|
+
logFlow("setup:complete", {
|
|
2816
|
+
smartAccount,
|
|
2817
|
+
hasSolanaDepositAddress: Boolean(solanaDepositAddress),
|
|
2818
|
+
flowMode: isDepositAddressMode ? "deposit-address" : isSolanaWalletMode ? "solana-wallet" : "wallet"
|
|
2819
|
+
});
|
|
1824
2820
|
if (isDepositAddressMode) {
|
|
1825
|
-
setStep({
|
|
2821
|
+
setStep({
|
|
2822
|
+
type: "deposit-address",
|
|
2823
|
+
smartAccount,
|
|
2824
|
+
solanaDepositAddress
|
|
2825
|
+
});
|
|
2826
|
+
} else if (isSolanaWalletMode) {
|
|
2827
|
+
if (solanaDepositAddress) {
|
|
2828
|
+
setStep({
|
|
2829
|
+
type: "solana-token-select",
|
|
2830
|
+
smartAccount,
|
|
2831
|
+
solanaDepositAddress
|
|
2832
|
+
});
|
|
2833
|
+
} else {
|
|
2834
|
+
_optionalChain([onError, 'optionalCall', _65 => _65({
|
|
2835
|
+
message: "Solana deposit address not available. Please try again.",
|
|
2836
|
+
code: "SOLANA_SETUP_FAILED"
|
|
2837
|
+
})]);
|
|
2838
|
+
}
|
|
1826
2839
|
} else {
|
|
1827
2840
|
setStep({ type: "select-asset", smartAccount });
|
|
1828
2841
|
}
|
|
1829
2842
|
},
|
|
1830
|
-
[isDepositAddressMode]
|
|
2843
|
+
[isDepositAddressMode, isSolanaWalletMode, logFlow]
|
|
1831
2844
|
);
|
|
1832
2845
|
const handleDepositAddressDetected = _react.useCallback.call(void 0,
|
|
1833
|
-
(txHash, chainId, amount, token) => {
|
|
2846
|
+
(txHash, chainId, amount, token, sourceSymbol, sourceDecimals) => {
|
|
2847
|
+
logFlow("deposit-address:detected", {
|
|
2848
|
+
txHash,
|
|
2849
|
+
sourceChain: chainId,
|
|
2850
|
+
sourceToken: token,
|
|
2851
|
+
amount
|
|
2852
|
+
});
|
|
1834
2853
|
setStep((prev) => {
|
|
1835
2854
|
if (prev.type !== "deposit-address") return prev;
|
|
2855
|
+
const isEvmToken = /^0x[a-fA-F0-9]{40}$/.test(token);
|
|
2856
|
+
const directTransfer = typeof chainId === "number" && isEvmToken && isSameRoute(chainId, token, targetChain, targetToken);
|
|
1836
2857
|
return {
|
|
1837
2858
|
type: "processing",
|
|
1838
2859
|
smartAccount: prev.smartAccount,
|
|
@@ -1840,16 +2861,97 @@ function DepositFlow({
|
|
|
1840
2861
|
sourceChain: chainId,
|
|
1841
2862
|
sourceToken: token,
|
|
1842
2863
|
amount,
|
|
1843
|
-
|
|
2864
|
+
sourceSymbol,
|
|
2865
|
+
sourceDecimals,
|
|
2866
|
+
directTransfer
|
|
1844
2867
|
};
|
|
1845
2868
|
});
|
|
1846
|
-
_optionalChain([onDepositSubmitted, 'optionalCall',
|
|
2869
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _66 => _66({ txHash, sourceChain: chainId, amount })]);
|
|
1847
2870
|
},
|
|
1848
2871
|
[onDepositSubmitted, targetChain, targetToken]
|
|
1849
2872
|
);
|
|
2873
|
+
const handleSolanaTokenContinue = _react.useCallback.call(void 0,
|
|
2874
|
+
(token, balance, balanceUsd) => {
|
|
2875
|
+
logFlow("solana:token:continue", { token: token.symbol });
|
|
2876
|
+
setStep((prev) => {
|
|
2877
|
+
if (prev.type !== "solana-token-select") return prev;
|
|
2878
|
+
return {
|
|
2879
|
+
type: "solana-amount",
|
|
2880
|
+
smartAccount: prev.smartAccount,
|
|
2881
|
+
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2882
|
+
token,
|
|
2883
|
+
balance,
|
|
2884
|
+
balanceUsd
|
|
2885
|
+
};
|
|
2886
|
+
});
|
|
2887
|
+
},
|
|
2888
|
+
[logFlow]
|
|
2889
|
+
);
|
|
2890
|
+
const handleSolanaAmountContinue = _react.useCallback.call(void 0,
|
|
2891
|
+
(token, amount) => {
|
|
2892
|
+
const targetSym = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
2893
|
+
const isTargetStable = _chunkNELAYNA3cjs.isStablecoinSymbol.call(void 0, targetSym);
|
|
2894
|
+
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
2895
|
+
logFlow("solana:amount:continue", {
|
|
2896
|
+
token: token.symbol,
|
|
2897
|
+
amount,
|
|
2898
|
+
targetSymbol: targetSym,
|
|
2899
|
+
targetTokenPriceUsd
|
|
2900
|
+
});
|
|
2901
|
+
setStep((prev) => {
|
|
2902
|
+
if (prev.type !== "solana-amount") return prev;
|
|
2903
|
+
const sourceBalance = Number(
|
|
2904
|
+
_viem.formatUnits.call(void 0, prev.balance, prev.token.decimals)
|
|
2905
|
+
);
|
|
2906
|
+
const sourceTokenPriceUsd = Number.isFinite(sourceBalance) && sourceBalance > 0 && prev.balanceUsd > 0 ? prev.balanceUsd / sourceBalance : null;
|
|
2907
|
+
const parsedAmount = Number(amount);
|
|
2908
|
+
const targetAmount = sourceTokenPriceUsd !== null && Number.isFinite(parsedAmount) && parsedAmount > 0 ? (parsedAmount * sourceTokenPriceUsd).toString() : amount;
|
|
2909
|
+
return {
|
|
2910
|
+
type: "solana-confirm",
|
|
2911
|
+
smartAccount: prev.smartAccount,
|
|
2912
|
+
solanaDepositAddress: prev.solanaDepositAddress,
|
|
2913
|
+
token,
|
|
2914
|
+
amount,
|
|
2915
|
+
targetAmount,
|
|
2916
|
+
targetTokenPriceUsd,
|
|
2917
|
+
balance: prev.balance,
|
|
2918
|
+
balanceUsd: prev.balanceUsd
|
|
2919
|
+
};
|
|
2920
|
+
});
|
|
2921
|
+
},
|
|
2922
|
+
[targetToken, targetChain, getTokenPriceUsd, logFlow]
|
|
2923
|
+
);
|
|
2924
|
+
const handleSolanaConfirmed = _react.useCallback.call(void 0,
|
|
2925
|
+
(txHash, amountUnits) => {
|
|
2926
|
+
setStep((prev) => {
|
|
2927
|
+
if (prev.type !== "solana-confirm") return prev;
|
|
2928
|
+
logFlow("solana:submitted", {
|
|
2929
|
+
txHash,
|
|
2930
|
+
amountUnits,
|
|
2931
|
+
token: prev.token.symbol
|
|
2932
|
+
});
|
|
2933
|
+
return {
|
|
2934
|
+
type: "processing",
|
|
2935
|
+
smartAccount: prev.smartAccount,
|
|
2936
|
+
txHash,
|
|
2937
|
+
sourceChain: "solana",
|
|
2938
|
+
sourceToken: prev.token.mint,
|
|
2939
|
+
amount: amountUnits,
|
|
2940
|
+
sourceSymbol: prev.token.symbol,
|
|
2941
|
+
sourceDecimals: prev.token.decimals
|
|
2942
|
+
};
|
|
2943
|
+
});
|
|
2944
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _67 => _67({
|
|
2945
|
+
txHash,
|
|
2946
|
+
sourceChain: "solana",
|
|
2947
|
+
amount: amountUnits
|
|
2948
|
+
})]);
|
|
2949
|
+
},
|
|
2950
|
+
[logFlow, onDepositSubmitted]
|
|
2951
|
+
);
|
|
1850
2952
|
const handleConnected = _react.useCallback.call(void 0,
|
|
1851
2953
|
(addr, smartAccount) => {
|
|
1852
|
-
_optionalChain([onConnected, 'optionalCall',
|
|
2954
|
+
_optionalChain([onConnected, 'optionalCall', _68 => _68({ address: addr, smartAccount })]);
|
|
1853
2955
|
},
|
|
1854
2956
|
[onConnected]
|
|
1855
2957
|
);
|
|
@@ -1869,8 +2971,8 @@ function DepositFlow({
|
|
|
1869
2971
|
);
|
|
1870
2972
|
const handleAmountContinue = _react.useCallback.call(void 0,
|
|
1871
2973
|
(amount, targetAmount, balance) => {
|
|
1872
|
-
const targetSym =
|
|
1873
|
-
const isTargetStable =
|
|
2974
|
+
const targetSym = _chunkNELAYNA3cjs.getTokenSymbol.call(void 0, targetToken, targetChain);
|
|
2975
|
+
const isTargetStable = _chunkNELAYNA3cjs.isStablecoinSymbol.call(void 0, targetSym);
|
|
1874
2976
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
1875
2977
|
setStep((prev) => {
|
|
1876
2978
|
if (prev.type !== "amount") return prev;
|
|
@@ -1889,6 +2991,12 @@ function DepositFlow({
|
|
|
1889
2991
|
);
|
|
1890
2992
|
const handleDepositSubmitted = _react.useCallback.call(void 0,
|
|
1891
2993
|
(txHash, chainId, amount, token) => {
|
|
2994
|
+
logFlow("evm:submitted", {
|
|
2995
|
+
txHash,
|
|
2996
|
+
sourceChain: chainId,
|
|
2997
|
+
sourceToken: token,
|
|
2998
|
+
amount
|
|
2999
|
+
});
|
|
1892
3000
|
setStep((prev) => {
|
|
1893
3001
|
if (prev.type !== "confirm") return prev;
|
|
1894
3002
|
return {
|
|
@@ -1906,41 +3014,57 @@ function DepositFlow({
|
|
|
1906
3014
|
);
|
|
1907
3015
|
const handleDepositSubmittedCallback = _react.useCallback.call(void 0,
|
|
1908
3016
|
(txHash, sourceChain, amount) => {
|
|
1909
|
-
_optionalChain([onDepositSubmitted, 'optionalCall',
|
|
3017
|
+
_optionalChain([onDepositSubmitted, 'optionalCall', _69 => _69({ txHash, sourceChain, amount })]);
|
|
1910
3018
|
},
|
|
1911
3019
|
[onDepositSubmitted]
|
|
1912
3020
|
);
|
|
1913
3021
|
const handleDepositComplete = _react.useCallback.call(void 0,
|
|
1914
3022
|
(txHash, destinationTxHash) => {
|
|
1915
|
-
|
|
3023
|
+
logFlow("deposit:complete", { txHash, destinationTxHash });
|
|
3024
|
+
_optionalChain([onDepositComplete, 'optionalCall', _70 => _70({ txHash, destinationTxHash })]);
|
|
1916
3025
|
},
|
|
1917
|
-
[onDepositComplete]
|
|
3026
|
+
[logFlow, onDepositComplete]
|
|
1918
3027
|
);
|
|
1919
3028
|
const handleDepositFailed = _react.useCallback.call(void 0,
|
|
1920
3029
|
(txHash, error) => {
|
|
1921
|
-
|
|
3030
|
+
logFlowError("deposit:failed", error, { txHash });
|
|
3031
|
+
_optionalChain([onDepositFailed, 'optionalCall', _71 => _71({ txHash, error })]);
|
|
1922
3032
|
},
|
|
1923
|
-
[onDepositFailed]
|
|
3033
|
+
[logFlowError, onDepositFailed]
|
|
1924
3034
|
);
|
|
1925
3035
|
const handleError = _react.useCallback.call(void 0,
|
|
1926
3036
|
(message, code) => {
|
|
1927
|
-
|
|
3037
|
+
logFlowError("flow:error", message, { code });
|
|
3038
|
+
_optionalChain([onError, 'optionalCall', _72 => _72({ message, code })]);
|
|
1928
3039
|
},
|
|
1929
|
-
[onError]
|
|
3040
|
+
[logFlowError, onError]
|
|
1930
3041
|
);
|
|
1931
3042
|
const handleTotalBalanceComputed = _react.useCallback.call(void 0, (total) => {
|
|
1932
3043
|
setTotalBalanceUsd(total);
|
|
1933
3044
|
}, []);
|
|
1934
|
-
const
|
|
1935
|
-
if (
|
|
3045
|
+
const selectedWalletIdEffective = _react.useMemo.call(void 0, () => {
|
|
3046
|
+
if (selectedWalletId) return selectedWalletId;
|
|
1936
3047
|
if (walletOptions.length === 1) {
|
|
1937
|
-
return walletOptions[0].
|
|
3048
|
+
return walletOptions[0].id;
|
|
1938
3049
|
}
|
|
1939
3050
|
return null;
|
|
1940
|
-
}, [
|
|
3051
|
+
}, [selectedWalletId, walletOptions]);
|
|
3052
|
+
const walletOptionsKey = _react.useMemo.call(void 0,
|
|
3053
|
+
() => walletOptions.map((option) => option.id).join(","),
|
|
3054
|
+
[walletOptions]
|
|
3055
|
+
);
|
|
3056
|
+
const hasNavigatedBackRef = _react.useRef.call(void 0, false);
|
|
3057
|
+
_react.useEffect.call(void 0, () => {
|
|
3058
|
+
setIsConnectSelectionConfirmed(false);
|
|
3059
|
+
setSelectedWalletId(null);
|
|
3060
|
+
setFlowMode(null);
|
|
3061
|
+
if (step.type !== "processing" && step.type !== "confirm" && step.type !== "solana-confirm" && step.type !== "amount" && step.type !== "solana-amount") {
|
|
3062
|
+
setStep({ type: "setup" });
|
|
3063
|
+
}
|
|
3064
|
+
}, [walletOptionsKey]);
|
|
1941
3065
|
_react.useEffect.call(void 0, () => {
|
|
1942
3066
|
if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
|
|
1943
|
-
|
|
3067
|
+
setSelectedWalletId(null);
|
|
1944
3068
|
setIsConnectSelectionConfirmed(false);
|
|
1945
3069
|
setFlowMode(null);
|
|
1946
3070
|
}
|
|
@@ -1950,10 +3074,15 @@ function DepositFlow({
|
|
|
1950
3074
|
return;
|
|
1951
3075
|
}
|
|
1952
3076
|
if (hasWalletOptions) {
|
|
1953
|
-
const
|
|
1954
|
-
if (
|
|
1955
|
-
|
|
1956
|
-
|
|
3077
|
+
const walletId = selectedWalletIdEffective;
|
|
3078
|
+
if (walletId) {
|
|
3079
|
+
const selectedOption = walletOptions.find((o) => o.id === walletId);
|
|
3080
|
+
setSelectedWalletId(walletId);
|
|
3081
|
+
if (_optionalChain([selectedOption, 'optionalAccess', _73 => _73.kind]) === "solana") {
|
|
3082
|
+
handleSelectSolanaWallet();
|
|
3083
|
+
} else {
|
|
3084
|
+
handleSelectProvider();
|
|
3085
|
+
}
|
|
1957
3086
|
setIsConnectSelectionConfirmed(true);
|
|
1958
3087
|
return;
|
|
1959
3088
|
}
|
|
@@ -1967,18 +3096,20 @@ function DepositFlow({
|
|
|
1967
3096
|
hasReownSession,
|
|
1968
3097
|
isConnectSelectionConfirmed,
|
|
1969
3098
|
flowMode,
|
|
1970
|
-
|
|
3099
|
+
selectedWalletIdEffective,
|
|
1971
3100
|
dappAddress,
|
|
3101
|
+
walletOptions,
|
|
1972
3102
|
handleSelectProvider,
|
|
3103
|
+
handleSelectSolanaWallet,
|
|
1973
3104
|
handleSelectTransferCrypto
|
|
1974
3105
|
]);
|
|
1975
3106
|
if (showConnectStep) {
|
|
1976
3107
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1977
|
-
|
|
3108
|
+
_chunkLT3QKJI2cjs.ConnectStep,
|
|
1978
3109
|
{
|
|
1979
3110
|
walletOptions,
|
|
1980
|
-
|
|
1981
|
-
|
|
3111
|
+
selectedWalletId: selectedWalletIdEffective,
|
|
3112
|
+
onSelectWallet: setSelectedWalletId,
|
|
1982
3113
|
onSelectTransferCrypto: dappAddress ? () => {
|
|
1983
3114
|
handleSelectTransferCrypto();
|
|
1984
3115
|
setIsConnectSelectionConfirmed(true);
|
|
@@ -1987,10 +3118,17 @@ function DepositFlow({
|
|
|
1987
3118
|
onConnect,
|
|
1988
3119
|
onDisconnect,
|
|
1989
3120
|
onContinue: () => {
|
|
1990
|
-
if (
|
|
1991
|
-
|
|
3121
|
+
if (selectedWalletIdEffective) {
|
|
3122
|
+
setSelectedWalletId(selectedWalletIdEffective);
|
|
3123
|
+
}
|
|
3124
|
+
const selectedOption = walletOptions.find(
|
|
3125
|
+
(o) => o.id === selectedWalletIdEffective
|
|
3126
|
+
);
|
|
3127
|
+
if (_optionalChain([selectedOption, 'optionalAccess', _74 => _74.kind]) === "solana") {
|
|
3128
|
+
handleSelectSolanaWallet();
|
|
3129
|
+
} else {
|
|
3130
|
+
handleSelectProvider();
|
|
1992
3131
|
}
|
|
1993
|
-
handleSelectProvider();
|
|
1994
3132
|
setIsConnectSelectionConfirmed(true);
|
|
1995
3133
|
},
|
|
1996
3134
|
connectButtonLabel
|
|
@@ -2020,13 +3158,14 @@ function DepositFlow({
|
|
|
2020
3158
|
DepositAddressStep,
|
|
2021
3159
|
{
|
|
2022
3160
|
smartAccount: step.smartAccount,
|
|
3161
|
+
solanaDepositAddress: step.solanaDepositAddress,
|
|
2023
3162
|
service,
|
|
2024
3163
|
onDepositDetected: handleDepositAddressDetected,
|
|
2025
3164
|
onError: handleError
|
|
2026
3165
|
}
|
|
2027
3166
|
),
|
|
2028
3167
|
step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2029
|
-
|
|
3168
|
+
_chunkLT3QKJI2cjs.ProcessingStep,
|
|
2030
3169
|
{
|
|
2031
3170
|
smartAccount: step.smartAccount,
|
|
2032
3171
|
txHash: step.txHash,
|
|
@@ -2034,6 +3173,8 @@ function DepositFlow({
|
|
|
2034
3173
|
sourceToken: step.sourceToken,
|
|
2035
3174
|
targetChain,
|
|
2036
3175
|
amount: step.amount,
|
|
3176
|
+
sourceSymbol: step.sourceSymbol,
|
|
3177
|
+
sourceDecimals: step.sourceDecimals,
|
|
2037
3178
|
waitForFinalTx,
|
|
2038
3179
|
service,
|
|
2039
3180
|
directTransfer: step.directTransfer,
|
|
@@ -2047,16 +3188,133 @@ function DepositFlow({
|
|
|
2047
3188
|
)
|
|
2048
3189
|
] });
|
|
2049
3190
|
}
|
|
2050
|
-
if (
|
|
2051
|
-
return null;
|
|
3191
|
+
if (isSolanaWalletMode) {
|
|
3192
|
+
if (!sessionKeyAddress) return null;
|
|
3193
|
+
const solanaAddr = _optionalChain([reownWallet, 'optionalAccess', _75 => _75.solanaAddress]);
|
|
3194
|
+
const solanaProvider = _optionalChain([reownWallet, 'optionalAccess', _76 => _76.solanaProvider]);
|
|
3195
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
|
|
3196
|
+
step.type === "setup" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3197
|
+
SetupStep,
|
|
3198
|
+
{
|
|
3199
|
+
address: sessionKeyAddress,
|
|
3200
|
+
targetChain,
|
|
3201
|
+
targetToken,
|
|
3202
|
+
signerAddress,
|
|
3203
|
+
sessionChainIds,
|
|
3204
|
+
recipient,
|
|
3205
|
+
forceRegister,
|
|
3206
|
+
service,
|
|
3207
|
+
onSetupComplete: handleSetupComplete,
|
|
3208
|
+
onConnected: handleConnected,
|
|
3209
|
+
onError: handleError
|
|
3210
|
+
}
|
|
3211
|
+
),
|
|
3212
|
+
step.type === "solana-token-select" && solanaAddr && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3213
|
+
SolanaTokenSelectStep,
|
|
3214
|
+
{
|
|
3215
|
+
solanaAddress: solanaAddr,
|
|
3216
|
+
service,
|
|
3217
|
+
onContinue: handleSolanaTokenContinue,
|
|
3218
|
+
onTotalBalanceComputed: handleTotalBalanceComputed,
|
|
3219
|
+
debug
|
|
3220
|
+
}
|
|
3221
|
+
),
|
|
3222
|
+
step.type === "solana-amount" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3223
|
+
SolanaAmountStep,
|
|
3224
|
+
{
|
|
3225
|
+
token: step.token,
|
|
3226
|
+
balance: step.balance,
|
|
3227
|
+
balanceUsd: step.balanceUsd,
|
|
3228
|
+
onContinue: handleSolanaAmountContinue,
|
|
3229
|
+
debug
|
|
3230
|
+
}
|
|
3231
|
+
),
|
|
3232
|
+
step.type === "solana-confirm" && solanaAddr && solanaProvider ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3233
|
+
SolanaConfirmStep,
|
|
3234
|
+
{
|
|
3235
|
+
smartAccount: step.smartAccount,
|
|
3236
|
+
solanaAddress: solanaAddr,
|
|
3237
|
+
solanaDepositAddress: step.solanaDepositAddress,
|
|
3238
|
+
token: step.token,
|
|
3239
|
+
amount: step.amount,
|
|
3240
|
+
targetAmount: step.targetAmount,
|
|
3241
|
+
targetTokenPriceUsd: step.targetTokenPriceUsd,
|
|
3242
|
+
targetChain,
|
|
3243
|
+
targetToken,
|
|
3244
|
+
service,
|
|
3245
|
+
solanaProvider,
|
|
3246
|
+
onConfirm: handleSolanaConfirmed,
|
|
3247
|
+
onError: handleError,
|
|
3248
|
+
debug
|
|
3249
|
+
}
|
|
3250
|
+
) : step.type === "solana-confirm" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
|
|
3251
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-state", children: [
|
|
3252
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-icon rs-step-icon--error", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3253
|
+
"svg",
|
|
3254
|
+
{
|
|
3255
|
+
viewBox: "0 0 24 24",
|
|
3256
|
+
fill: "none",
|
|
3257
|
+
stroke: "currentColor",
|
|
3258
|
+
strokeWidth: "2",
|
|
3259
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3260
|
+
"path",
|
|
3261
|
+
{
|
|
3262
|
+
strokeLinecap: "round",
|
|
3263
|
+
strokeLinejoin: "round",
|
|
3264
|
+
d: "M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
|
|
3265
|
+
}
|
|
3266
|
+
)
|
|
3267
|
+
}
|
|
3268
|
+
) }),
|
|
3269
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-loading-text", children: [
|
|
3270
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title rs-text-error", children: "Wallet disconnected" }),
|
|
3271
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-subtitle", children: "Please reconnect your Solana wallet to continue." })
|
|
3272
|
+
] })
|
|
3273
|
+
] }),
|
|
3274
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3275
|
+
"button",
|
|
3276
|
+
{
|
|
3277
|
+
type: "button",
|
|
3278
|
+
className: "rs-button rs-button--default rs-button--full-width",
|
|
3279
|
+
onClick: handleBackFromSolanaConfirm,
|
|
3280
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Go Back" })
|
|
3281
|
+
}
|
|
3282
|
+
) })
|
|
3283
|
+
] }) : null,
|
|
3284
|
+
step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3285
|
+
_chunkLT3QKJI2cjs.ProcessingStep,
|
|
3286
|
+
{
|
|
3287
|
+
smartAccount: step.smartAccount,
|
|
3288
|
+
txHash: step.txHash,
|
|
3289
|
+
sourceChain: step.sourceChain,
|
|
3290
|
+
sourceToken: step.sourceToken,
|
|
3291
|
+
targetChain,
|
|
3292
|
+
amount: step.amount,
|
|
3293
|
+
sourceSymbol: step.sourceSymbol,
|
|
3294
|
+
sourceDecimals: step.sourceDecimals,
|
|
3295
|
+
waitForFinalTx,
|
|
3296
|
+
service,
|
|
3297
|
+
directTransfer: step.directTransfer,
|
|
3298
|
+
onClose,
|
|
3299
|
+
onNewDeposit: handleNewDeposit,
|
|
3300
|
+
onDepositComplete: handleDepositComplete,
|
|
3301
|
+
onDepositFailed: handleDepositFailed,
|
|
3302
|
+
onError: handleError,
|
|
3303
|
+
debug
|
|
3304
|
+
}
|
|
3305
|
+
)
|
|
3306
|
+
] });
|
|
3307
|
+
}
|
|
3308
|
+
if (!_optionalChain([signerContext, 'optionalAccess', _77 => _77.walletClient]) || !_optionalChain([signerContext, 'optionalAccess', _78 => _78.publicClient])) {
|
|
3309
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-state", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-text", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-loading-title", children: "Connecting wallet..." }) }) }) }) });
|
|
2052
3310
|
}
|
|
2053
3311
|
const ownerAddress = signerContext.ownerAddress;
|
|
2054
|
-
const ownerChainId = _nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access',
|
|
3312
|
+
const ownerChainId = _nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access', _79 => _79.walletClient, 'optionalAccess', _80 => _80.chain, 'optionalAccess', _81 => _81.id]), () => ( _optionalChain([signerContext, 'access', _82 => _82.publicClient, 'access', _83 => _83.chain, 'optionalAccess', _84 => _84.id]))), () => ( targetChain));
|
|
2055
3313
|
const getReadClientForChain = (chainId) => {
|
|
2056
|
-
if (_optionalChain([signerContext, 'access',
|
|
3314
|
+
if (_optionalChain([signerContext, 'access', _85 => _85.publicClient, 'access', _86 => _86.chain, 'optionalAccess', _87 => _87.id]) === chainId) {
|
|
2057
3315
|
return signerContext.publicClient;
|
|
2058
3316
|
}
|
|
2059
|
-
return
|
|
3317
|
+
return _chunkLT3QKJI2cjs.getPublicClient.call(void 0, chainId);
|
|
2060
3318
|
};
|
|
2061
3319
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
|
|
2062
3320
|
step.type === "setup" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2125,7 +3383,7 @@ function DepositFlow({
|
|
|
2125
3383
|
}
|
|
2126
3384
|
),
|
|
2127
3385
|
step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2128
|
-
|
|
3386
|
+
_chunkLT3QKJI2cjs.ProcessingStep,
|
|
2129
3387
|
{
|
|
2130
3388
|
smartAccount: step.smartAccount,
|
|
2131
3389
|
txHash: step.txHash,
|
|
@@ -2133,6 +3391,8 @@ function DepositFlow({
|
|
|
2133
3391
|
sourceToken: step.sourceToken,
|
|
2134
3392
|
targetChain,
|
|
2135
3393
|
amount: step.amount,
|
|
3394
|
+
sourceSymbol: step.sourceSymbol,
|
|
3395
|
+
sourceDecimals: step.sourceDecimals,
|
|
2136
3396
|
waitForFinalTx,
|
|
2137
3397
|
service,
|
|
2138
3398
|
directTransfer: step.directTransfer,
|
|
@@ -2140,7 +3400,8 @@ function DepositFlow({
|
|
|
2140
3400
|
onNewDeposit: handleNewDeposit,
|
|
2141
3401
|
onDepositComplete: handleDepositComplete,
|
|
2142
3402
|
onDepositFailed: handleDepositFailed,
|
|
2143
|
-
onError: handleError
|
|
3403
|
+
onError: handleError,
|
|
3404
|
+
debug
|
|
2144
3405
|
}
|
|
2145
3406
|
)
|
|
2146
3407
|
] });
|
|
@@ -2149,7 +3410,7 @@ function DepositFlow({
|
|
|
2149
3410
|
// src/DepositModal.tsx
|
|
2150
3411
|
|
|
2151
3412
|
var ReownDepositInner = _react.lazy.call(void 0,
|
|
2152
|
-
() => Promise.resolve().then(() => _interopRequireWildcard(require("./DepositModalReown-
|
|
3413
|
+
() => Promise.resolve().then(() => _interopRequireWildcard(require("./DepositModalReown-EEXNSXI4.cjs"))).then((m) => ({ default: m.DepositModalReown }))
|
|
2153
3414
|
);
|
|
2154
3415
|
function DepositModal(props) {
|
|
2155
3416
|
const needsReown = !!props.reownAppId;
|
|
@@ -2172,8 +3433,9 @@ function DepositModalInner({
|
|
|
2172
3433
|
sourceToken,
|
|
2173
3434
|
defaultAmount,
|
|
2174
3435
|
recipient,
|
|
2175
|
-
backendUrl =
|
|
2176
|
-
|
|
3436
|
+
backendUrl = _chunkNELAYNA3cjs.DEFAULT_BACKEND_URL,
|
|
3437
|
+
solanaRpcUrl,
|
|
3438
|
+
signerAddress = _chunkNELAYNA3cjs.DEFAULT_SIGNER_ADDRESS,
|
|
2177
3439
|
sessionChainIds,
|
|
2178
3440
|
forceRegister = false,
|
|
2179
3441
|
waitForFinalTx = true,
|
|
@@ -2198,27 +3460,33 @@ function DepositModalInner({
|
|
|
2198
3460
|
const [currentStepIndex, setCurrentStepIndex] = _react.useState.call(void 0, 0);
|
|
2199
3461
|
const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, null);
|
|
2200
3462
|
const backHandlerRef = _react.useRef.call(void 0, void 0);
|
|
2201
|
-
const targetChain =
|
|
2202
|
-
const sourceChain = sourceChainProp ?
|
|
2203
|
-
const service = _react.useMemo.call(void 0,
|
|
3463
|
+
const targetChain = _chunkNELAYNA3cjs.getChainId.call(void 0, targetChainProp);
|
|
3464
|
+
const sourceChain = sourceChainProp ? _chunkNELAYNA3cjs.getChainId.call(void 0, sourceChainProp) : void 0;
|
|
3465
|
+
const service = _react.useMemo.call(void 0,
|
|
3466
|
+
() => _chunkLT3QKJI2cjs.createDepositService.call(void 0, backendUrl, {
|
|
3467
|
+
debug,
|
|
3468
|
+
debugScope: "service:deposit"
|
|
3469
|
+
}),
|
|
3470
|
+
[backendUrl, debug]
|
|
3471
|
+
);
|
|
2204
3472
|
_react.useEffect.call(void 0, () => {
|
|
2205
3473
|
if (isOpen && modalRef.current) {
|
|
2206
|
-
|
|
3474
|
+
_chunkLT3QKJI2cjs.applyTheme.call(void 0, modalRef.current, theme);
|
|
2207
3475
|
}
|
|
2208
3476
|
}, [isOpen, theme]);
|
|
3477
|
+
_react.useEffect.call(void 0, () => {
|
|
3478
|
+
configureSolanaRpcUrl(solanaRpcUrl);
|
|
3479
|
+
}, [solanaRpcUrl]);
|
|
2209
3480
|
const hasCalledReady = _react.useRef.call(void 0, false);
|
|
2210
3481
|
_react.useEffect.call(void 0, () => {
|
|
2211
3482
|
if (isOpen && !hasCalledReady.current) {
|
|
2212
3483
|
hasCalledReady.current = true;
|
|
2213
|
-
_optionalChain([onReady, 'optionalCall',
|
|
3484
|
+
_optionalChain([onReady, 'optionalCall', _88 => _88()]);
|
|
2214
3485
|
}
|
|
2215
3486
|
}, [isOpen, onReady]);
|
|
2216
3487
|
_react.useEffect.call(void 0, () => {
|
|
2217
3488
|
if (!isOpen) {
|
|
2218
3489
|
setCurrentStepIndex(0);
|
|
2219
|
-
setTotalBalanceUsd(null);
|
|
2220
|
-
backHandlerRef.current = void 0;
|
|
2221
|
-
hasCalledReady.current = false;
|
|
2222
3490
|
}
|
|
2223
3491
|
}, [isOpen]);
|
|
2224
3492
|
const handleStepChange = _react.useCallback.call(void 0,
|
|
@@ -2232,17 +3500,17 @@ function DepositModalInner({
|
|
|
2232
3500
|
setTotalBalanceUsd(balance2);
|
|
2233
3501
|
}, []);
|
|
2234
3502
|
const handleBack = _react.useCallback.call(void 0, () => {
|
|
2235
|
-
_optionalChain([backHandlerRef, 'access',
|
|
3503
|
+
_optionalChain([backHandlerRef, 'access', _89 => _89.current, 'optionalCall', _90 => _90()]);
|
|
2236
3504
|
}, []);
|
|
2237
|
-
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
2238
|
-
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
2239
|
-
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess',
|
|
2240
|
-
const balance = _optionalChain([uiConfig, 'optionalAccess',
|
|
2241
|
-
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
2242
|
-
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess',
|
|
3505
|
+
const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _91 => _91.showLogo]), () => ( false));
|
|
3506
|
+
const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _92 => _92.showStepper]), () => ( false));
|
|
3507
|
+
const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _93 => _93.showBackButton]), () => ( true));
|
|
3508
|
+
const balance = _optionalChain([uiConfig, 'optionalAccess', _94 => _94.balance]);
|
|
3509
|
+
const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _95 => _95.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
|
|
3510
|
+
const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _96 => _96.title]), () => ( "Deposit"));
|
|
2243
3511
|
const canGoBack = currentStepIndex > 0 && currentStepIndex < 4 && backHandlerRef.current !== void 0;
|
|
2244
3512
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2245
|
-
|
|
3513
|
+
_chunkLT3QKJI2cjs.Modal,
|
|
2246
3514
|
{
|
|
2247
3515
|
isOpen,
|
|
2248
3516
|
onClose,
|
|
@@ -2303,7 +3571,7 @@ function DepositModalInner({
|
|
|
2303
3571
|
balance.title,
|
|
2304
3572
|
":"
|
|
2305
3573
|
] }),
|
|
2306
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ?
|
|
3574
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunkLT3QKJI2cjs.currencyFormatter.format(totalBalanceUsd) : null))) })
|
|
2307
3575
|
] })
|
|
2308
3576
|
] }),
|
|
2309
3577
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|