@rhinestone/deposit-modal 0.1.68 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DepositModalReown-WXFTSZSK.cjs → DepositModalReown-66DE7NAY.cjs} +6 -6
- package/dist/{DepositModalReown-RYCOXWMH.mjs → DepositModalReown-PROPLCBI.mjs} +3 -3
- package/dist/{WithdrawModalReown-WHPQDJJJ.cjs → WithdrawModalReown-HXTXSZCJ.cjs} +6 -6
- package/dist/{WithdrawModalReown-6VYKKKJN.mjs → WithdrawModalReown-URF6AERQ.mjs} +3 -3
- package/dist/{chunk-IUW3SJQT.mjs → chunk-3CRG5NPG.mjs} +128 -16
- package/dist/{chunk-MBURQ26S.mjs → chunk-5YXAQB6A.mjs} +10 -0
- package/dist/{chunk-OEB25YZ4.mjs → chunk-7NEVAAPY.mjs} +145 -20
- package/dist/{chunk-LTLFJPHO.cjs → chunk-7TEGUTU4.cjs} +52 -47
- package/dist/{chunk-5FDIQNJJ.mjs → chunk-TKTOPC2W.mjs} +12 -7
- package/dist/{chunk-J7ILKS5N.cjs → chunk-UHQSFV5V.cjs} +248 -123
- package/dist/{chunk-FLVSQDP4.cjs → chunk-XW4M7WDI.cjs} +196 -84
- package/dist/{chunk-N2Y34LQO.cjs → chunk-YQFH2WSW.cjs} +11 -1
- package/dist/deposit.cjs +3 -3
- package/dist/deposit.mjs +2 -2
- package/dist/index.cjs +8 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +7 -3
- package/dist/reown.cjs +8 -4
- package/dist/reown.d.cts +4 -0
- package/dist/reown.d.ts +4 -0
- package/dist/reown.mjs +8 -4
- package/dist/styles.css +5 -5
- package/dist/withdraw.cjs +3 -3
- package/dist/withdraw.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUHQSFV5Vcjs = require('./chunk-UHQSFV5V.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
7
|
+
var _chunkYQFH2WSWcjs = require('./chunk-YQFH2WSW.cjs');
|
|
8
|
+
require('./chunk-XW4M7WDI.cjs');
|
|
9
9
|
require('./chunk-MUWVDVY4.cjs');
|
|
10
10
|
|
|
11
11
|
// src/DepositModalReown.tsx
|
|
@@ -13,7 +13,7 @@ var _react = require('react');
|
|
|
13
13
|
var _react3 = require('@reown/appkit/react');
|
|
14
14
|
var _jsxruntime = require('react/jsx-runtime');
|
|
15
15
|
function DepositModalWithReown(props) {
|
|
16
|
-
const reown =
|
|
16
|
+
const reown = _chunkYQFH2WSWcjs.useReownWallet.call(void 0, );
|
|
17
17
|
const enableSolana = _nullishCoalesce(props.enableSolana, () => ( true));
|
|
18
18
|
const { walletProvider: solanaWalletProvider } = _react3.useAppKitProvider.call(void 0,
|
|
19
19
|
enableSolana ? "solana" : "eip155"
|
|
@@ -32,7 +32,7 @@ function DepositModalWithReown(props) {
|
|
|
32
32
|
reown.disconnect();
|
|
33
33
|
}, [reown.disconnect]);
|
|
34
34
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
35
|
-
|
|
35
|
+
_chunkUHQSFV5Vcjs.DepositModalInner,
|
|
36
36
|
{
|
|
37
37
|
...props,
|
|
38
38
|
reownWallet: reownWithSolana,
|
|
@@ -43,7 +43,7 @@ function DepositModalWithReown(props) {
|
|
|
43
43
|
}
|
|
44
44
|
function DepositModalReown(props) {
|
|
45
45
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
46
|
-
|
|
46
|
+
_chunkYQFH2WSWcjs.ReownWalletProvider,
|
|
47
47
|
{
|
|
48
48
|
projectId: props.reownAppId,
|
|
49
49
|
theme: props.theme,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DepositModalInner
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7NEVAAPY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ReownWalletProvider,
|
|
6
6
|
useReownWallet
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-5YXAQB6A.mjs";
|
|
8
|
+
import "./chunk-3CRG5NPG.mjs";
|
|
9
9
|
import "./chunk-SDZKKUCJ.mjs";
|
|
10
10
|
|
|
11
11
|
// src/DepositModalReown.tsx
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7TEGUTU4cjs = require('./chunk-7TEGUTU4.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
7
|
+
var _chunkYQFH2WSWcjs = require('./chunk-YQFH2WSW.cjs');
|
|
8
|
+
require('./chunk-XW4M7WDI.cjs');
|
|
9
9
|
require('./chunk-MUWVDVY4.cjs');
|
|
10
10
|
|
|
11
11
|
// src/WithdrawModalReown.tsx
|
|
12
12
|
var _react = require('react');
|
|
13
13
|
var _jsxruntime = require('react/jsx-runtime');
|
|
14
14
|
function WithdrawModalWithReown(props) {
|
|
15
|
-
const reown =
|
|
15
|
+
const reown = _chunkYQFH2WSWcjs.useReownWallet.call(void 0, );
|
|
16
16
|
const handleConnect = _react.useCallback.call(void 0, () => {
|
|
17
17
|
reown.openConnect();
|
|
18
18
|
}, [reown.openConnect]);
|
|
@@ -20,7 +20,7 @@ function WithdrawModalWithReown(props) {
|
|
|
20
20
|
reown.disconnect();
|
|
21
21
|
}, [reown.disconnect]);
|
|
22
22
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
23
|
-
|
|
23
|
+
_chunk7TEGUTU4cjs.WithdrawModalInner,
|
|
24
24
|
{
|
|
25
25
|
...props,
|
|
26
26
|
reownWallet: reown,
|
|
@@ -30,7 +30,7 @@ function WithdrawModalWithReown(props) {
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
function WithdrawModalReown(props) {
|
|
33
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
33
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkYQFH2WSWcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WithdrawModalInner
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TKTOPC2W.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ReownWalletProvider,
|
|
6
6
|
useReownWallet
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-5YXAQB6A.mjs";
|
|
8
|
+
import "./chunk-3CRG5NPG.mjs";
|
|
9
9
|
import "./chunk-SDZKKUCJ.mjs";
|
|
10
10
|
|
|
11
11
|
// src/WithdrawModalReown.tsx
|
|
@@ -215,6 +215,69 @@ function isSolanaCaip2(value) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// src/core/deposit-service.ts
|
|
218
|
+
function depositRowToEvent(row) {
|
|
219
|
+
const status = row.status;
|
|
220
|
+
if (!status) return void 0;
|
|
221
|
+
const deposit = {
|
|
222
|
+
transactionHash: row.txHash,
|
|
223
|
+
chain: row.chain,
|
|
224
|
+
amount: row.sourceAmount ?? row.amount,
|
|
225
|
+
asset: row.token,
|
|
226
|
+
token: row.token
|
|
227
|
+
};
|
|
228
|
+
const source = row.sourceTxHash ? { transactionHash: row.sourceTxHash, chain: row.chain } : { transactionHash: row.txHash, chain: row.chain };
|
|
229
|
+
const destination = row.destinationTxHash ? {
|
|
230
|
+
transactionHash: row.destinationTxHash,
|
|
231
|
+
chain: row.targetChain,
|
|
232
|
+
amount: row.destinationAmount ?? void 0
|
|
233
|
+
} : void 0;
|
|
234
|
+
const time = row.completedAt ?? row.createdAt ?? void 0;
|
|
235
|
+
if (status === "completed") {
|
|
236
|
+
return {
|
|
237
|
+
type: "post-bridge-swap-complete",
|
|
238
|
+
time: time ?? void 0,
|
|
239
|
+
data: {
|
|
240
|
+
deposit,
|
|
241
|
+
source,
|
|
242
|
+
...destination && { destination },
|
|
243
|
+
...destination && {
|
|
244
|
+
swap: { transactionHash: destination.transactionHash }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (status === "failed" || status === "refunded") {
|
|
250
|
+
return {
|
|
251
|
+
type: "bridge-failed",
|
|
252
|
+
time: time ?? void 0,
|
|
253
|
+
data: {
|
|
254
|
+
deposit,
|
|
255
|
+
source,
|
|
256
|
+
...row.errorCode && { error: { code: row.errorCode } }
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (status === "processing") {
|
|
261
|
+
return {
|
|
262
|
+
type: "bridge-started",
|
|
263
|
+
time: time ?? void 0,
|
|
264
|
+
data: {
|
|
265
|
+
deposit,
|
|
266
|
+
source
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
type: "deposit-received",
|
|
272
|
+
time: time ?? void 0,
|
|
273
|
+
data: {
|
|
274
|
+
transactionHash: row.txHash,
|
|
275
|
+
chain: row.chain,
|
|
276
|
+
amount: row.amount,
|
|
277
|
+
token: row.token
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
218
281
|
function jsonReplacer(_key, value) {
|
|
219
282
|
return typeof value === "bigint" ? value.toString() : value;
|
|
220
283
|
}
|
|
@@ -488,15 +551,14 @@ function createDepositService(baseUrl, options) {
|
|
|
488
551
|
async fetchStatus(address, txHash) {
|
|
489
552
|
const normalized = txHash.startsWith("0x") || txHash.startsWith("0X") ? txHash.toLowerCase() : txHash;
|
|
490
553
|
const txHashParam = encodeURIComponent(normalized);
|
|
491
|
-
const url = apiUrl(
|
|
492
|
-
|
|
493
|
-
url,
|
|
494
|
-
{
|
|
495
|
-
method: "GET",
|
|
496
|
-
headers: { "Content-Type": "application/json" },
|
|
497
|
-
cache: "no-store"
|
|
498
|
-
}
|
|
554
|
+
const url = apiUrl(
|
|
555
|
+
`/deposits?account=${encodeURIComponent(address)}&txHash=${txHashParam}&limit=1`
|
|
499
556
|
);
|
|
557
|
+
const response = await fetch(url, {
|
|
558
|
+
method: "GET",
|
|
559
|
+
headers: { "Content-Type": "application/json" },
|
|
560
|
+
cache: "no-store"
|
|
561
|
+
});
|
|
500
562
|
if (!response.ok) {
|
|
501
563
|
debugLog(debug, scope, "fetchStatus:miss", {
|
|
502
564
|
address,
|
|
@@ -505,16 +567,20 @@ function createDepositService(baseUrl, options) {
|
|
|
505
567
|
});
|
|
506
568
|
return { lastEvent: void 0 };
|
|
507
569
|
}
|
|
508
|
-
const
|
|
570
|
+
const body = await response.json();
|
|
571
|
+
const row = body.deposits?.[0];
|
|
572
|
+
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
509
573
|
debugLog(debug, scope, "fetchStatus:success", {
|
|
510
574
|
address,
|
|
511
575
|
txHash: shortRef(normalized),
|
|
512
|
-
eventType:
|
|
576
|
+
eventType: lastEvent?.type
|
|
513
577
|
});
|
|
514
|
-
return
|
|
578
|
+
return { lastEvent };
|
|
515
579
|
},
|
|
516
580
|
async fetchLatestStatus(address) {
|
|
517
|
-
const url = apiUrl(
|
|
581
|
+
const url = apiUrl(
|
|
582
|
+
`/deposits?account=${encodeURIComponent(address)}&limit=1`
|
|
583
|
+
);
|
|
518
584
|
const response = await fetch(url, {
|
|
519
585
|
method: "GET",
|
|
520
586
|
headers: { "Content-Type": "application/json" },
|
|
@@ -527,16 +593,18 @@ function createDepositService(baseUrl, options) {
|
|
|
527
593
|
});
|
|
528
594
|
return { lastEvent: void 0 };
|
|
529
595
|
}
|
|
530
|
-
const
|
|
596
|
+
const body = await response.json();
|
|
597
|
+
const row = body.deposits?.[0];
|
|
598
|
+
const lastEvent = row ? depositRowToEvent(row) : void 0;
|
|
531
599
|
debugLog(debug, scope, "fetchLatestStatus:success", {
|
|
532
600
|
address,
|
|
533
|
-
eventType:
|
|
601
|
+
eventType: lastEvent?.type
|
|
534
602
|
});
|
|
535
|
-
return
|
|
603
|
+
return { lastEvent };
|
|
536
604
|
},
|
|
537
605
|
async relayWithdraw(params) {
|
|
538
606
|
const { smartAccount, chainId, safeAddress, safeTransaction, signature } = params;
|
|
539
|
-
const url = apiUrl(`/
|
|
607
|
+
const url = apiUrl(`/safe/withdraw`);
|
|
540
608
|
debugLog(debug, scope, "relayWithdraw:request", {
|
|
541
609
|
url,
|
|
542
610
|
smartAccount,
|
|
@@ -635,6 +703,50 @@ function createDepositService(baseUrl, options) {
|
|
|
635
703
|
hasMore: Boolean(nextCursor)
|
|
636
704
|
});
|
|
637
705
|
return { deposits, nextCursor };
|
|
706
|
+
},
|
|
707
|
+
async checkLiquidity(params) {
|
|
708
|
+
const searchParams = new URLSearchParams({
|
|
709
|
+
sourceChainId: String(params.sourceChainId),
|
|
710
|
+
sourceToken: params.sourceToken,
|
|
711
|
+
destinationChainId: String(params.destinationChainId),
|
|
712
|
+
destinationToken: params.destinationToken,
|
|
713
|
+
amount: params.amount
|
|
714
|
+
});
|
|
715
|
+
const url = apiUrl(`/liquidity?${searchParams.toString()}`);
|
|
716
|
+
debugLog(debug, scope, "checkLiquidity:request", {
|
|
717
|
+
url,
|
|
718
|
+
sourceChainId: params.sourceChainId,
|
|
719
|
+
destinationChainId: params.destinationChainId,
|
|
720
|
+
amount: params.amount
|
|
721
|
+
});
|
|
722
|
+
const response = await fetch(url, {
|
|
723
|
+
method: "GET",
|
|
724
|
+
headers: { "Content-Type": "application/json" },
|
|
725
|
+
cache: "no-store"
|
|
726
|
+
});
|
|
727
|
+
if (!response.ok) {
|
|
728
|
+
const error = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
729
|
+
debugError(debug, scope, "checkLiquidity:failed", error, {
|
|
730
|
+
status: response.status
|
|
731
|
+
});
|
|
732
|
+
throw new Error(
|
|
733
|
+
error.error || `Liquidity check failed: ${response.status}`
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
const data = await response.json();
|
|
737
|
+
const result = {
|
|
738
|
+
hasLiquidity: data.hasLiquidity === true,
|
|
739
|
+
symbol: typeof data.symbol === "string" ? data.symbol : "",
|
|
740
|
+
decimals: typeof data.decimals === "number" ? data.decimals : 0,
|
|
741
|
+
unlimited: data.unlimited === true,
|
|
742
|
+
maxAmount: typeof data.maxAmount === "string" ? data.maxAmount : null
|
|
743
|
+
};
|
|
744
|
+
debugLog(debug, scope, "checkLiquidity:success", {
|
|
745
|
+
hasLiquidity: result.hasLiquidity,
|
|
746
|
+
unlimited: result.unlimited,
|
|
747
|
+
maxAmount: result.maxAmount
|
|
748
|
+
});
|
|
749
|
+
return result;
|
|
638
750
|
}
|
|
639
751
|
};
|
|
640
752
|
}
|
|
@@ -78,6 +78,15 @@ function ReownWalletProvider({
|
|
|
78
78
|
const config = adapter.wagmiConfig;
|
|
79
79
|
return /* @__PURE__ */ jsx(WagmiProvider, { config, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
|
|
80
80
|
}
|
|
81
|
+
async function disconnectWallet() {
|
|
82
|
+
if (!modal) {
|
|
83
|
+
console.warn(
|
|
84
|
+
"[rhinestone] disconnectWallet called before the modal provider mounted; no-op."
|
|
85
|
+
);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
await modal.disconnect();
|
|
89
|
+
}
|
|
81
90
|
function useReownWallet() {
|
|
82
91
|
const { open } = useAppKit();
|
|
83
92
|
const { address, isConnected, caipAddress } = useAppKitAccount();
|
|
@@ -118,5 +127,6 @@ function useReownWallet() {
|
|
|
118
127
|
|
|
119
128
|
export {
|
|
120
129
|
ReownWalletProvider,
|
|
130
|
+
disconnectWallet,
|
|
121
131
|
useReownWallet
|
|
122
132
|
};
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
tokenFormatter,
|
|
29
29
|
txRefsMatch,
|
|
30
30
|
useLatestRef
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-3CRG5NPG.mjs";
|
|
32
32
|
import {
|
|
33
33
|
DEFAULT_BACKEND_URL,
|
|
34
34
|
DEFAULT_SIGNER_ADDRESS,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
|
|
63
63
|
// src/DepositFlow.tsx
|
|
64
64
|
import { useState as useState11, useCallback as useCallback5, useMemo as useMemo6, useEffect as useEffect10, useRef as useRef7 } from "react";
|
|
65
|
-
import { formatUnits as
|
|
65
|
+
import { formatUnits as formatUnits6 } from "viem";
|
|
66
66
|
|
|
67
67
|
// src/components/steps/SetupStep.tsx
|
|
68
68
|
import { useState, useEffect, useRef, useCallback } from "react";
|
|
@@ -119,6 +119,8 @@ function SetupStep({
|
|
|
119
119
|
targetToken,
|
|
120
120
|
recipient,
|
|
121
121
|
postBridgeActions,
|
|
122
|
+
outputTokenRules,
|
|
123
|
+
rejectUnmapped,
|
|
122
124
|
signerAddress,
|
|
123
125
|
sessionChainIds,
|
|
124
126
|
forceRegister
|
|
@@ -187,6 +189,8 @@ function SetupStep({
|
|
|
187
189
|
sessionChainIds,
|
|
188
190
|
recipient,
|
|
189
191
|
postBridgeActions,
|
|
192
|
+
outputTokenRules,
|
|
193
|
+
rejectUnmapped,
|
|
190
194
|
forceRegister,
|
|
191
195
|
enableSolana,
|
|
192
196
|
service,
|
|
@@ -578,12 +582,14 @@ function AmountStep({
|
|
|
578
582
|
tokenPriceUsdOverride,
|
|
579
583
|
onBalanceUsdChange,
|
|
580
584
|
onContinue,
|
|
581
|
-
onCtaClick
|
|
585
|
+
onCtaClick,
|
|
586
|
+
service
|
|
582
587
|
}) {
|
|
583
588
|
const [amount, setAmount] = useState3("");
|
|
584
589
|
const [balance, setBalance] = useState3(null);
|
|
585
590
|
const [error, setError] = useState3(null);
|
|
586
591
|
const [isSwitching, setIsSwitching] = useState3(false);
|
|
592
|
+
const [isCheckingLiquidity, setIsCheckingLiquidity] = useState3(false);
|
|
587
593
|
const hasAttemptedSwitch = useRef2(false);
|
|
588
594
|
const chainMismatch = Boolean(
|
|
589
595
|
walletClient?.chain?.id && walletClient.chain.id !== asset.chainId
|
|
@@ -703,7 +709,7 @@ function AmountStep({
|
|
|
703
709
|
}
|
|
704
710
|
if (error) setError(null);
|
|
705
711
|
};
|
|
706
|
-
const handleContinue = () => {
|
|
712
|
+
const handleContinue = async () => {
|
|
707
713
|
const numericAmount = parseFloat(amount);
|
|
708
714
|
if (isNaN(numericAmount) || numericAmount <= 0) {
|
|
709
715
|
setError("Please enter a valid amount");
|
|
@@ -743,7 +749,34 @@ function AmountStep({
|
|
|
743
749
|
}
|
|
744
750
|
setError(null);
|
|
745
751
|
onCtaClick?.("continue");
|
|
746
|
-
|
|
752
|
+
setIsCheckingLiquidity(true);
|
|
753
|
+
let liquidityWarning;
|
|
754
|
+
try {
|
|
755
|
+
const liquidity = await service.checkLiquidity({
|
|
756
|
+
sourceChainId: asset.chainId,
|
|
757
|
+
sourceToken: asset.token,
|
|
758
|
+
destinationChainId: targetChain,
|
|
759
|
+
destinationToken: targetToken,
|
|
760
|
+
amount: amountInUnits.toString()
|
|
761
|
+
});
|
|
762
|
+
if (liquidity.unlimited || liquidity.hasLiquidity) {
|
|
763
|
+
liquidityWarning = void 0;
|
|
764
|
+
} else if (liquidity.maxAmount !== null) {
|
|
765
|
+
liquidityWarning = {
|
|
766
|
+
kind: "low",
|
|
767
|
+
maxAmount: liquidity.maxAmount,
|
|
768
|
+
decimals: liquidity.decimals,
|
|
769
|
+
symbol: liquidity.symbol
|
|
770
|
+
};
|
|
771
|
+
} else {
|
|
772
|
+
liquidityWarning = { kind: "unavailable" };
|
|
773
|
+
}
|
|
774
|
+
} catch {
|
|
775
|
+
liquidityWarning = { kind: "check-failed" };
|
|
776
|
+
} finally {
|
|
777
|
+
setIsCheckingLiquidity(false);
|
|
778
|
+
}
|
|
779
|
+
onContinue(tokenAmountStr, amount, balance ?? void 0, liquidityWarning);
|
|
747
780
|
};
|
|
748
781
|
return /* @__PURE__ */ jsxs3("div", { className: "rs-step", children: [
|
|
749
782
|
/* @__PURE__ */ jsxs3("div", { className: "rs-step-body", style: { paddingTop: 0 }, children: [
|
|
@@ -941,8 +974,8 @@ function AmountStep({
|
|
|
941
974
|
{
|
|
942
975
|
onClick: handleContinue,
|
|
943
976
|
fullWidth: true,
|
|
944
|
-
disabled: !amount || chainMismatch,
|
|
945
|
-
children: uiConfig?.minDepositUsd && parseFloat(amount) > 0 && parseFloat(amount) < uiConfig.minDepositUsd ? "Update order" : "Continue"
|
|
977
|
+
disabled: !amount || chainMismatch || isCheckingLiquidity,
|
|
978
|
+
children: isCheckingLiquidity ? "Checking liquidity\u2026" : uiConfig?.minDepositUsd && parseFloat(amount) > 0 && parseFloat(amount) < uiConfig.minDepositUsd ? "Update order" : "Continue"
|
|
946
979
|
}
|
|
947
980
|
) }),
|
|
948
981
|
/* @__PURE__ */ jsx3(PoweredBy, {})
|
|
@@ -966,6 +999,7 @@ function ConfirmStep({
|
|
|
966
999
|
targetChain,
|
|
967
1000
|
targetToken,
|
|
968
1001
|
switchChain,
|
|
1002
|
+
liquidityWarning,
|
|
969
1003
|
onConfirm,
|
|
970
1004
|
onError,
|
|
971
1005
|
onDepositSubmitted
|
|
@@ -1161,6 +1195,19 @@ function ConfirmStep({
|
|
|
1161
1195
|
)
|
|
1162
1196
|
] })
|
|
1163
1197
|
] }),
|
|
1198
|
+
liquidityWarning && (liquidityWarning.kind === "unavailable" || liquidityWarning.kind === "check-failed") && /* @__PURE__ */ jsx4(
|
|
1199
|
+
"div",
|
|
1200
|
+
{
|
|
1201
|
+
style: {
|
|
1202
|
+
fontSize: 11,
|
|
1203
|
+
color: "var(--color-amber8)",
|
|
1204
|
+
marginTop: 8,
|
|
1205
|
+
textAlign: "center",
|
|
1206
|
+
opacity: 0.85
|
|
1207
|
+
},
|
|
1208
|
+
children: liquidityWarning.kind === "unavailable" ? "Route may be unavailable" : "Liquidity check failed"
|
|
1209
|
+
}
|
|
1210
|
+
),
|
|
1164
1211
|
error && /* @__PURE__ */ jsxs4("div", { className: "rs-alert rs-alert--error", children: [
|
|
1165
1212
|
/* @__PURE__ */ jsx4(
|
|
1166
1213
|
"svg",
|
|
@@ -1199,6 +1246,7 @@ function ConfirmStep({
|
|
|
1199
1246
|
|
|
1200
1247
|
// src/components/steps/DepositAddressStep.tsx
|
|
1201
1248
|
import { useState as useState7, useEffect as useEffect7, useCallback as useCallback4, useRef as useRef6, useMemo as useMemo3 } from "react";
|
|
1249
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
1202
1250
|
|
|
1203
1251
|
// src/components/ui/QRCode.tsx
|
|
1204
1252
|
import { QRCode as QRCodeCanvas } from "react-qrcode-logo";
|
|
@@ -1945,6 +1993,59 @@ function DepositAddressStep({
|
|
|
1945
1993
|
sourceSymbol: sourceTokenSymbol
|
|
1946
1994
|
};
|
|
1947
1995
|
}, [sourceChainId, sourceTokenSymbol, isSolana]);
|
|
1996
|
+
const [liquidityHelper, setLiquidityHelper] = useState7({
|
|
1997
|
+
kind: "idle"
|
|
1998
|
+
});
|
|
1999
|
+
useEffect7(() => {
|
|
2000
|
+
if (isSolana) {
|
|
2001
|
+
setLiquidityHelper({ kind: "idle" });
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
const sourceTokenAddress = getTokenAddress(
|
|
2005
|
+
sourceTokenSymbol,
|
|
2006
|
+
sourceChainId
|
|
2007
|
+
);
|
|
2008
|
+
if (!sourceTokenAddress) {
|
|
2009
|
+
setLiquidityHelper({ kind: "idle" });
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
let cancelled = false;
|
|
2013
|
+
setLiquidityHelper({ kind: "loading" });
|
|
2014
|
+
service.checkLiquidity({
|
|
2015
|
+
sourceChainId,
|
|
2016
|
+
sourceToken: sourceTokenAddress,
|
|
2017
|
+
destinationChainId: targetChain,
|
|
2018
|
+
destinationToken: targetToken,
|
|
2019
|
+
amount: "1"
|
|
2020
|
+
}).then((result) => {
|
|
2021
|
+
if (cancelled) return;
|
|
2022
|
+
if (result.unlimited) {
|
|
2023
|
+
setLiquidityHelper({ kind: "unlimited" });
|
|
2024
|
+
} else if (result.maxAmount === null) {
|
|
2025
|
+
setLiquidityHelper({ kind: "unavailable" });
|
|
2026
|
+
} else {
|
|
2027
|
+
setLiquidityHelper({
|
|
2028
|
+
kind: "max",
|
|
2029
|
+
maxAmount: result.maxAmount,
|
|
2030
|
+
decimals: result.decimals,
|
|
2031
|
+
symbol: result.symbol || sourceTokenSymbol
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
}).catch(() => {
|
|
2035
|
+
if (cancelled) return;
|
|
2036
|
+
setLiquidityHelper({ kind: "error" });
|
|
2037
|
+
});
|
|
2038
|
+
return () => {
|
|
2039
|
+
cancelled = true;
|
|
2040
|
+
};
|
|
2041
|
+
}, [
|
|
2042
|
+
isSolana,
|
|
2043
|
+
sourceChainId,
|
|
2044
|
+
sourceTokenSymbol,
|
|
2045
|
+
targetChain,
|
|
2046
|
+
targetToken,
|
|
2047
|
+
service
|
|
2048
|
+
]);
|
|
1948
2049
|
const displayAddress = isSolana && solanaDepositAddress ? solanaDepositAddress : smartAccount;
|
|
1949
2050
|
useEffect7(() => {
|
|
1950
2051
|
if (!chainDropdownOpen && !tokenDropdownOpen) return;
|
|
@@ -2372,7 +2473,7 @@ function DepositAddressStep({
|
|
|
2372
2473
|
] }) }),
|
|
2373
2474
|
/* @__PURE__ */ jsxs7("span", { className: "rs-price-impact-label", children: [
|
|
2374
2475
|
"Max slippage: ",
|
|
2375
|
-
/* @__PURE__ */ jsx8("strong", { children: "
|
|
2476
|
+
/* @__PURE__ */ jsx8("strong", { children: "0.2%" })
|
|
2376
2477
|
] }),
|
|
2377
2478
|
/* @__PURE__ */ jsx8(
|
|
2378
2479
|
Tooltip,
|
|
@@ -2395,6 +2496,27 @@ function DepositAddressStep({
|
|
|
2395
2496
|
"Processing time: ",
|
|
2396
2497
|
/* @__PURE__ */ jsx8("strong", { children: "< 1 min" })
|
|
2397
2498
|
] })
|
|
2499
|
+
] }),
|
|
2500
|
+
/* @__PURE__ */ jsxs7("div", { className: "rs-price-impact-row", children: [
|
|
2501
|
+
/* @__PURE__ */ jsx8("span", { className: "rs-price-impact-row-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxs7("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", children: [
|
|
2502
|
+
/* @__PURE__ */ jsx8("circle", { cx: "12", cy: "12", r: "9" }),
|
|
2503
|
+
/* @__PURE__ */ jsx8(
|
|
2504
|
+
"path",
|
|
2505
|
+
{
|
|
2506
|
+
strokeLinecap: "round",
|
|
2507
|
+
strokeLinejoin: "round",
|
|
2508
|
+
d: "M8 12h8M12 8v8"
|
|
2509
|
+
}
|
|
2510
|
+
)
|
|
2511
|
+
] }) }),
|
|
2512
|
+
/* @__PURE__ */ jsxs7("span", { className: "rs-price-impact-label", children: [
|
|
2513
|
+
"Max deposit:",
|
|
2514
|
+
" ",
|
|
2515
|
+
/* @__PURE__ */ jsx8("strong", { children: liquidityHelper.kind === "max" ? `${formatUnits3(
|
|
2516
|
+
BigInt(liquidityHelper.maxAmount),
|
|
2517
|
+
liquidityHelper.decimals
|
|
2518
|
+
)} ${liquidityHelper.symbol}` : liquidityHelper.kind === "unlimited" ? "Unlimited" : liquidityHelper.kind === "unavailable" ? "Unavailable" : liquidityHelper.kind === "error" ? "\u2014" : "\u2026" })
|
|
2519
|
+
] })
|
|
2398
2520
|
] })
|
|
2399
2521
|
] }) })
|
|
2400
2522
|
]
|
|
@@ -2425,7 +2547,7 @@ DepositAddressStep.displayName = "DepositAddressStep";
|
|
|
2425
2547
|
|
|
2426
2548
|
// src/components/steps/SolanaTokenSelectStep.tsx
|
|
2427
2549
|
import { useState as useState8, useEffect as useEffect8, useMemo as useMemo4 } from "react";
|
|
2428
|
-
import { formatUnits as
|
|
2550
|
+
import { formatUnits as formatUnits4 } from "viem";
|
|
2429
2551
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2430
2552
|
function SolanaTokenSelectStep({
|
|
2431
2553
|
solanaAddress,
|
|
@@ -2566,7 +2688,7 @@ function SolanaTokenSelectStep({
|
|
|
2566
2688
|
const chainIcon = getChainIcon("solana");
|
|
2567
2689
|
let formattedBalance;
|
|
2568
2690
|
try {
|
|
2569
|
-
const raw =
|
|
2691
|
+
const raw = formatUnits4(entry.balance, entry.token.decimals);
|
|
2570
2692
|
const numeric = Number(raw);
|
|
2571
2693
|
formattedBalance = Number.isFinite(numeric) ? tokenFormatter.format(numeric) : raw;
|
|
2572
2694
|
} catch {
|
|
@@ -2640,7 +2762,7 @@ function SolanaTokenSelectStep({
|
|
|
2640
2762
|
|
|
2641
2763
|
// src/components/steps/SolanaAmountStep.tsx
|
|
2642
2764
|
import { useEffect as useEffect9, useMemo as useMemo5, useState as useState9 } from "react";
|
|
2643
|
-
import { formatUnits as
|
|
2765
|
+
import { formatUnits as formatUnits5, parseUnits as parseUnits3 } from "viem";
|
|
2644
2766
|
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2645
2767
|
var SOL_FEE_RESERVE_LAMPORTS = 1000000n;
|
|
2646
2768
|
function SolanaAmountStep({
|
|
@@ -2658,7 +2780,7 @@ function SolanaAmountStep({
|
|
|
2658
2780
|
const tokenPriceUsd = useMemo5(() => {
|
|
2659
2781
|
if (isSourceStablecoin) return 1;
|
|
2660
2782
|
try {
|
|
2661
|
-
const balanceUnits = Number(
|
|
2783
|
+
const balanceUnits = Number(formatUnits5(balance, token.decimals));
|
|
2662
2784
|
if (!Number.isFinite(balanceUnits) || balanceUnits <= 0 || balanceUsd <= 0) {
|
|
2663
2785
|
return null;
|
|
2664
2786
|
}
|
|
@@ -2679,7 +2801,7 @@ function SolanaAmountStep({
|
|
|
2679
2801
|
}, [defaultAmount, amount]);
|
|
2680
2802
|
const formattedBalance = useMemo5(() => {
|
|
2681
2803
|
try {
|
|
2682
|
-
const raw =
|
|
2804
|
+
const raw = formatUnits5(balance, token.decimals);
|
|
2683
2805
|
const numeric = Number(raw);
|
|
2684
2806
|
if (!Number.isFinite(numeric)) return raw;
|
|
2685
2807
|
return tokenFormatter.format(numeric);
|
|
@@ -2689,7 +2811,7 @@ function SolanaAmountStep({
|
|
|
2689
2811
|
}, [balance, token.decimals]);
|
|
2690
2812
|
const computedBalanceUsd = useMemo5(() => {
|
|
2691
2813
|
try {
|
|
2692
|
-
const balanceUnits = Number(
|
|
2814
|
+
const balanceUnits = Number(formatUnits5(balance, token.decimals));
|
|
2693
2815
|
if (!Number.isFinite(balanceUnits) || balanceUnits < 0) return null;
|
|
2694
2816
|
if (tokenPriceUsd !== null) return balanceUnits * tokenPriceUsd;
|
|
2695
2817
|
if (Number.isFinite(balanceUsd) && balanceUsd > 0) return balanceUsd;
|
|
@@ -2708,7 +2830,7 @@ function SolanaAmountStep({
|
|
|
2708
2830
|
}, [balance, token]);
|
|
2709
2831
|
const spendableBalanceUsd = useMemo5(() => {
|
|
2710
2832
|
try {
|
|
2711
|
-
const spendableUnits = Number(
|
|
2833
|
+
const spendableUnits = Number(formatUnits5(spendableBalance, token.decimals));
|
|
2712
2834
|
if (!Number.isFinite(spendableUnits) || spendableUnits < 0) return null;
|
|
2713
2835
|
if (tokenPriceUsd !== null) return spendableUnits * tokenPriceUsd;
|
|
2714
2836
|
return null;
|
|
@@ -2718,7 +2840,7 @@ function SolanaAmountStep({
|
|
|
2718
2840
|
}, [spendableBalance, token.decimals, tokenPriceUsd]);
|
|
2719
2841
|
const handlePresetClick = (percentage) => {
|
|
2720
2842
|
try {
|
|
2721
|
-
const spendableUnits = Number(
|
|
2843
|
+
const spendableUnits = Number(formatUnits5(spendableBalance, token.decimals));
|
|
2722
2844
|
if (!Number.isFinite(spendableUnits) || spendableUnits <= 0) return;
|
|
2723
2845
|
const value = isSourceStablecoin || !hasPricing ? spendableUnits * percentage / 100 : (spendableBalanceUsd ?? 0) * percentage / 100;
|
|
2724
2846
|
const maxDecimals = 3;
|
|
@@ -3251,7 +3373,7 @@ function DepositFlow({
|
|
|
3251
3373
|
if (asset.symbol.toLowerCase() === sym && asset.balanceUsd && asset.balance) {
|
|
3252
3374
|
try {
|
|
3253
3375
|
const balanceUnits = Number(
|
|
3254
|
-
|
|
3376
|
+
formatUnits6(BigInt(asset.balance), asset.decimals)
|
|
3255
3377
|
);
|
|
3256
3378
|
if (balanceUnits > 0) return asset.balanceUsd / balanceUnits;
|
|
3257
3379
|
} catch {
|
|
@@ -3774,7 +3896,7 @@ function DepositFlow({
|
|
|
3774
3896
|
[defaultAmount, onEvent, totalBalanceUsd]
|
|
3775
3897
|
);
|
|
3776
3898
|
const handleAmountContinue = useCallback5(
|
|
3777
|
-
(amount, targetAmount, balance) => {
|
|
3899
|
+
(amount, targetAmount, balance, liquidityWarning) => {
|
|
3778
3900
|
const targetSym = getTokenSymbol(targetToken, targetChain);
|
|
3779
3901
|
const isTargetStable = isStablecoinSymbol(targetSym);
|
|
3780
3902
|
const targetTokenPriceUsd = isTargetStable ? 1 : getTokenPriceUsd(targetSym);
|
|
@@ -3787,7 +3909,8 @@ function DepositFlow({
|
|
|
3787
3909
|
amount,
|
|
3788
3910
|
targetAmount,
|
|
3789
3911
|
targetTokenPriceUsd,
|
|
3790
|
-
balance
|
|
3912
|
+
balance,
|
|
3913
|
+
liquidityWarning
|
|
3791
3914
|
};
|
|
3792
3915
|
});
|
|
3793
3916
|
},
|
|
@@ -4200,6 +4323,7 @@ function DepositFlow({
|
|
|
4200
4323
|
targetChain,
|
|
4201
4324
|
targetToken,
|
|
4202
4325
|
uiConfig,
|
|
4326
|
+
service,
|
|
4203
4327
|
onContinue: handleAmountContinue,
|
|
4204
4328
|
onCtaClick: (ctaName) => {
|
|
4205
4329
|
const receiveSymbol = getTokenSymbol(targetToken, targetChain);
|
|
@@ -4228,6 +4352,7 @@ function DepositFlow({
|
|
|
4228
4352
|
targetChain,
|
|
4229
4353
|
targetToken,
|
|
4230
4354
|
switchChain: signerContext.switchChain,
|
|
4355
|
+
liquidityWarning: step.liquidityWarning,
|
|
4231
4356
|
onConfirm: handleDepositSubmitted,
|
|
4232
4357
|
onDepositSubmitted: handleDepositSubmittedCallback,
|
|
4233
4358
|
onError: handleError
|
|
@@ -4526,7 +4651,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
|
|
|
4526
4651
|
// src/DepositModal.tsx
|
|
4527
4652
|
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4528
4653
|
var ReownDepositInner = lazy(
|
|
4529
|
-
() => import("./DepositModalReown-
|
|
4654
|
+
() => import("./DepositModalReown-PROPLCBI.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
4530
4655
|
);
|
|
4531
4656
|
function DepositModal(props) {
|
|
4532
4657
|
const needsReown = !!props.reownAppId;
|