@rhinestone/deposit-modal 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DepositModalReown-6KUAO5ZC.mjs → DepositModalReown-MTWT6Y66.mjs} +5 -5
- package/dist/{DepositModalReown-XC5RIU7Z.cjs → DepositModalReown-S3DSFXTX.cjs} +9 -9
- package/dist/{chunk-4WB2FHGC.mjs → chunk-5NJYW5FT.mjs} +3 -3
- package/dist/{chunk-OSI2CFGL.mjs → chunk-5OEWGJR4.mjs} +1 -1
- package/dist/{chunk-VOGZAZB2.mjs → chunk-7TV7GLJB.mjs} +62 -1
- package/dist/{chunk-NMIMRASD.cjs → chunk-A42XAHIB.cjs} +66 -66
- package/dist/{chunk-PAGMU4RQ.cjs → chunk-DEF767BA.cjs} +52 -52
- package/dist/{chunk-LGVJWVSS.mjs → chunk-KW32UBUQ.mjs} +2 -2
- package/dist/{chunk-E4G5BOZP.mjs → chunk-LR7MKHYV.mjs} +2 -2
- package/dist/{chunk-KKHLNFSA.mjs → chunk-MHIOMTMM.mjs} +281 -119
- package/dist/{chunk-NEXUCY4B.cjs → chunk-NF4NBRUP.cjs} +1 -1
- package/dist/{chunk-VN4BLZYC.cjs → chunk-PUJHXHRA.cjs} +108 -47
- package/dist/{chunk-DIX7M3SP.cjs → chunk-UMCDZJMG.cjs} +57 -57
- package/dist/{chunk-WYXBY2MQ.mjs → chunk-VDGT6NZQ.mjs} +1 -1
- package/dist/{chunk-T7LGQFP3.cjs → chunk-VTVOHNXM.cjs} +3 -3
- package/dist/{chunk-22RV33LK.cjs → chunk-W4YAOJPG.cjs} +621 -459
- package/dist/claim.cjs +5 -5
- package/dist/claim.mjs +4 -4
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +6 -6
- package/dist/deposit.mjs +5 -5
- package/dist/index.cjs +8 -8
- package/dist/index.mjs +7 -7
- package/dist/styles.css +14 -0
- package/dist/withdraw.cjs +5 -5
- package/dist/withdraw.mjs +4 -4
- package/package.json +1 -1
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
runAccountSetupDeduped,
|
|
19
19
|
txRefsMatch,
|
|
20
20
|
warnRemovedProps
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-VDGT6NZQ.mjs";
|
|
22
22
|
import {
|
|
23
23
|
ListRow
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-KW32UBUQ.mjs";
|
|
25
25
|
import {
|
|
26
26
|
AlertTriangleIcon,
|
|
27
27
|
AppleIcon,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
useLatestRef,
|
|
78
78
|
useRpcUrls,
|
|
79
79
|
useStableRpcUrls
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-7TV7GLJB.mjs";
|
|
81
81
|
import {
|
|
82
82
|
POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS,
|
|
83
83
|
POLYMARKET_ICON_URL,
|
|
@@ -90,6 +90,7 @@ import {
|
|
|
90
90
|
readPolymarketBalances
|
|
91
91
|
} from "./chunk-ILT2PITN.mjs";
|
|
92
92
|
import {
|
|
93
|
+
CHAIN_BY_ID,
|
|
93
94
|
HYPERCORE_CHAIN_ID,
|
|
94
95
|
HYPERCORE_MIN_DEPOSIT_USD,
|
|
95
96
|
NATIVE_TOKEN_ADDRESS,
|
|
@@ -262,18 +263,17 @@ var DAPP_IMPORT_CATALOG = [
|
|
|
262
263
|
label: "Polymarket",
|
|
263
264
|
iconUrl: cdnIconUrl("dapps", "polymarket")
|
|
264
265
|
},
|
|
266
|
+
{
|
|
267
|
+
id: "aave",
|
|
268
|
+
label: "Aave",
|
|
269
|
+
iconUrl: cdnIconUrl("dapps", "aave")
|
|
270
|
+
},
|
|
265
271
|
{
|
|
266
272
|
id: "hyperliquid",
|
|
267
273
|
label: "Hyperliquid",
|
|
268
274
|
iconUrl: cdnIconUrl("dapps", "hyperliquid"),
|
|
269
275
|
comingSoon: true
|
|
270
276
|
},
|
|
271
|
-
{
|
|
272
|
-
id: "aave",
|
|
273
|
-
label: "Aave",
|
|
274
|
-
iconUrl: cdnIconUrl("dapps", "aave"),
|
|
275
|
-
comingSoon: true
|
|
276
|
-
},
|
|
277
277
|
{
|
|
278
278
|
id: "morpho",
|
|
279
279
|
label: "Morpho",
|
|
@@ -474,8 +474,7 @@ function ConnectStep({
|
|
|
474
474
|
title = "Deposit",
|
|
475
475
|
subtitle,
|
|
476
476
|
defaultMethodTab = "crypto",
|
|
477
|
-
onMethodTabChange
|
|
478
|
-
onInteract
|
|
477
|
+
onMethodTabChange
|
|
479
478
|
}) {
|
|
480
479
|
const rows = walletRows ?? [];
|
|
481
480
|
const handleConnect = onConnect ?? onRequestConnect;
|
|
@@ -617,58 +616,49 @@ function ConnectStep({
|
|
|
617
616
|
}
|
|
618
617
|
onPrefetchFiatMethod(recommendedMethod);
|
|
619
618
|
}, [activeTab, onPrefetchFiatMethod, recommendedMethod]);
|
|
620
|
-
return /* @__PURE__ */ jsxs4(
|
|
621
|
-
"div",
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
BodyHeader,
|
|
631
|
-
{
|
|
632
|
-
icon: /* @__PURE__ */ jsx5(HandCoinsIcon, {}),
|
|
633
|
-
title,
|
|
634
|
-
subtitle: subtitle ?? defaultSubtitle,
|
|
635
|
-
aside: showToggle ? /* @__PURE__ */ jsx5(
|
|
636
|
-
SegmentedToggle,
|
|
637
|
-
{
|
|
638
|
-
ariaLabel: "Deposit method type",
|
|
639
|
-
value: activeTab,
|
|
640
|
-
onChange: handleTabChange,
|
|
641
|
-
options: [
|
|
642
|
-
{ value: "crypto", label: "Crypto" },
|
|
643
|
-
{ value: "cash", label: "Cash" }
|
|
644
|
-
]
|
|
645
|
-
}
|
|
646
|
-
) : void 0
|
|
647
|
-
}
|
|
648
|
-
),
|
|
649
|
-
/* @__PURE__ */ jsx5(
|
|
650
|
-
"div",
|
|
619
|
+
return /* @__PURE__ */ jsxs4("div", { className: "rs-screen", children: [
|
|
620
|
+
/* @__PURE__ */ jsxs4("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
|
|
621
|
+
/* @__PURE__ */ jsx5(
|
|
622
|
+
BodyHeader,
|
|
623
|
+
{
|
|
624
|
+
icon: /* @__PURE__ */ jsx5(HandCoinsIcon, {}),
|
|
625
|
+
title,
|
|
626
|
+
subtitle: subtitle ?? defaultSubtitle,
|
|
627
|
+
aside: showToggle ? /* @__PURE__ */ jsx5(
|
|
628
|
+
SegmentedToggle,
|
|
651
629
|
{
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
630
|
+
ariaLabel: "Deposit method type",
|
|
631
|
+
value: activeTab,
|
|
632
|
+
onChange: handleTabChange,
|
|
633
|
+
options: [
|
|
634
|
+
{ value: "crypto", label: "Crypto" },
|
|
635
|
+
{ value: "cash", label: "Cash" }
|
|
636
|
+
]
|
|
656
637
|
}
|
|
657
|
-
)
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
638
|
+
) : void 0
|
|
639
|
+
}
|
|
640
|
+
),
|
|
641
|
+
/* @__PURE__ */ jsx5(
|
|
642
|
+
"div",
|
|
643
|
+
{
|
|
644
|
+
className: "rs-list",
|
|
645
|
+
"aria-live": activeTab === "cash" ? "polite" : void 0,
|
|
646
|
+
"aria-busy": activeTab === "cash" && fiatLoading ? true : void 0,
|
|
647
|
+
children: activeRows
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
] }),
|
|
651
|
+
onDisconnect && hasReownWallet && /* @__PURE__ */ jsx5("div", { className: "rs-screen-tight-row", children: /* @__PURE__ */ jsx5(
|
|
652
|
+
"button",
|
|
653
|
+
{
|
|
654
|
+
type: "button",
|
|
655
|
+
className: "rs-connect-wallet-manage",
|
|
656
|
+
onClick: onDisconnect,
|
|
657
|
+
children: "Disconnect wallet"
|
|
658
|
+
}
|
|
659
|
+
) }),
|
|
660
|
+
/* @__PURE__ */ jsx5(PoweredBy, {})
|
|
661
|
+
] });
|
|
672
662
|
}
|
|
673
663
|
ConnectStep.displayName = "ConnectStep";
|
|
674
664
|
|
|
@@ -1046,6 +1036,7 @@ function AmountStep({
|
|
|
1046
1036
|
publicClient,
|
|
1047
1037
|
address,
|
|
1048
1038
|
balanceAddress,
|
|
1039
|
+
declaredBalance,
|
|
1049
1040
|
asset,
|
|
1050
1041
|
defaultAmount,
|
|
1051
1042
|
switchChain,
|
|
@@ -1088,6 +1079,10 @@ function AmountStep({
|
|
|
1088
1079
|
const hasPricing = tokenPriceUsd !== null;
|
|
1089
1080
|
useEffect3(() => {
|
|
1090
1081
|
let active = true;
|
|
1082
|
+
if (declaredBalance !== void 0) {
|
|
1083
|
+
setBalance(declaredBalance);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1091
1086
|
async function fetchBalance() {
|
|
1092
1087
|
const balanceTarget = balanceAddress ?? address;
|
|
1093
1088
|
if (!balanceTarget || !publicClient) return;
|
|
@@ -1107,7 +1102,7 @@ function AmountStep({
|
|
|
1107
1102
|
return () => {
|
|
1108
1103
|
active = false;
|
|
1109
1104
|
};
|
|
1110
|
-
}, [address, balanceAddress, publicClient, asset]);
|
|
1105
|
+
}, [address, balanceAddress, declaredBalance, publicClient, asset]);
|
|
1111
1106
|
useEffect3(() => {
|
|
1112
1107
|
if (chainMismatch && switchChain && !hasAttemptedSwitch.current) {
|
|
1113
1108
|
hasAttemptedSwitch.current = true;
|
|
@@ -4395,6 +4390,7 @@ import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
|
4395
4390
|
function DappImportAssetSelectStep({
|
|
4396
4391
|
sourceLabel,
|
|
4397
4392
|
assets,
|
|
4393
|
+
incompleteSummary,
|
|
4398
4394
|
onSelect
|
|
4399
4395
|
}) {
|
|
4400
4396
|
return /* @__PURE__ */ jsxs19("div", { className: "rs-screen", children: [
|
|
@@ -4407,6 +4403,7 @@ function DappImportAssetSelectStep({
|
|
|
4407
4403
|
subtitle: "Pick the balance to import"
|
|
4408
4404
|
}
|
|
4409
4405
|
),
|
|
4406
|
+
incompleteSummary && /* @__PURE__ */ jsx22("div", { className: "rs-asset-notice", role: "status", children: incompleteSummary }),
|
|
4410
4407
|
/* @__PURE__ */ jsx22("div", { className: "rs-asset-list", children: assets.map((asset) => {
|
|
4411
4408
|
const tokenAmount = asset.balance ? tokenFormatter.format(
|
|
4412
4409
|
Number(asset.balance) / 10 ** asset.decimals
|
|
@@ -4445,7 +4442,8 @@ function DappImportAssetSelectStep({
|
|
|
4445
4442
|
/* @__PURE__ */ jsx22("span", { className: "rs-asset-name", children: asset.symbol }),
|
|
4446
4443
|
/* @__PURE__ */ jsxs19("span", { className: "rs-asset-chain", children: [
|
|
4447
4444
|
"on ",
|
|
4448
|
-
asset.sourceLabel
|
|
4445
|
+
asset.sourceLabel,
|
|
4446
|
+
asset.qualifier ? ` \xB7 ${asset.qualifier}` : ""
|
|
4449
4447
|
] })
|
|
4450
4448
|
] }),
|
|
4451
4449
|
/* @__PURE__ */ jsxs19("div", { className: "rs-asset-balance-small", children: [
|
|
@@ -4603,7 +4601,7 @@ function DappImportAssetSelectSkeleton({
|
|
|
4603
4601
|
DappImportAssetSelectSkeleton.displayName = "DappImportAssetSelectSkeleton";
|
|
4604
4602
|
|
|
4605
4603
|
// src/core/fiat-methods.ts
|
|
4606
|
-
var
|
|
4604
|
+
var REGIONAL_METHODS_TIMEOUT_MS = 3e3;
|
|
4607
4605
|
var BUILT_IN_ICON_METHODS = /* @__PURE__ */ new Set([
|
|
4608
4606
|
"creditcard",
|
|
4609
4607
|
"bank-transfer",
|
|
@@ -4659,6 +4657,188 @@ function composeFiatMethods(regional, fallbackMethods) {
|
|
|
4659
4657
|
};
|
|
4660
4658
|
}
|
|
4661
4659
|
|
|
4660
|
+
// src/core/dapp-imports/balance-source.ts
|
|
4661
|
+
function dappImportBalanceSource(asset) {
|
|
4662
|
+
if (!isDappImportAsset(asset)) return {};
|
|
4663
|
+
if (asset.balanceAddress) return { balanceAddress: asset.balanceAddress };
|
|
4664
|
+
if (asset.balance === void 0) return {};
|
|
4665
|
+
try {
|
|
4666
|
+
return { declaredBalance: BigInt(asset.balance) };
|
|
4667
|
+
} catch {
|
|
4668
|
+
return {};
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
// src/core/dapp-imports/aave/index.ts
|
|
4673
|
+
var PROVIDER_ID = "aave";
|
|
4674
|
+
var SOURCE_LABEL = "Aave";
|
|
4675
|
+
var POLICY_REFUSED = [
|
|
4676
|
+
"below_deposit_floor",
|
|
4677
|
+
"deposit_not_whitelisted"
|
|
4678
|
+
];
|
|
4679
|
+
var aaveProvider = {
|
|
4680
|
+
id: PROVIDER_ID,
|
|
4681
|
+
sourceLabel: SOURCE_LABEL,
|
|
4682
|
+
async fetchAvailability({ eoa, backend, signal }) {
|
|
4683
|
+
if (!backend) {
|
|
4684
|
+
throw new Error("Aave positions require a backend connection");
|
|
4685
|
+
}
|
|
4686
|
+
const response = await backend.getPositions(eoa);
|
|
4687
|
+
if (signal?.aborted) return null;
|
|
4688
|
+
const assets = toImportableAssets(response.positions);
|
|
4689
|
+
const failures = response.failures ?? [];
|
|
4690
|
+
if (assets.length === 0) {
|
|
4691
|
+
if (failures.length > 0) {
|
|
4692
|
+
throw new Error(
|
|
4693
|
+
`Could not read Aave positions: ${failures.map((failure) => failure.reason).join("; ")}`
|
|
4694
|
+
);
|
|
4695
|
+
}
|
|
4696
|
+
return null;
|
|
4697
|
+
}
|
|
4698
|
+
const availability = {
|
|
4699
|
+
providerId: PROVIDER_ID,
|
|
4700
|
+
// Deliberately the sum over importable assets rather than
|
|
4701
|
+
// `response.totalUsd`: the latter counts positions this flow filters out,
|
|
4702
|
+
// so using it would show a balance the user then cannot find.
|
|
4703
|
+
totalUsd: assets.reduce((sum, asset) => sum + (asset.balanceUsd ?? 0), 0),
|
|
4704
|
+
assets,
|
|
4705
|
+
// Some markets read, some did not. Erroring would discard positions the
|
|
4706
|
+
// user can migrate right now — and with ~29 markets on a keyless API, one
|
|
4707
|
+
// failing is the expected case, so erroring would be the normal outcome.
|
|
4708
|
+
// The list therefore stands, marked as a floor. The upstream reason names
|
|
4709
|
+
// an internal market, so it is summarised rather than surfaced.
|
|
4710
|
+
...failures.length > 0 ? {
|
|
4711
|
+
incomplete: {
|
|
4712
|
+
summary: failures.length === 1 ? "One Aave market couldn't be loaded, so a position may be missing." : `${failures.length} Aave markets couldn't be loaded, so positions may be missing.`
|
|
4713
|
+
}
|
|
4714
|
+
} : {}
|
|
4715
|
+
};
|
|
4716
|
+
return availability;
|
|
4717
|
+
},
|
|
4718
|
+
async executeTransfer({ walletClient, recipient, asset, amount, backend }) {
|
|
4719
|
+
if (!backend) {
|
|
4720
|
+
throw new Error("Aave withdrawals require a backend connection");
|
|
4721
|
+
}
|
|
4722
|
+
const metadata = asset.providerMetadata;
|
|
4723
|
+
const account = walletClient.account;
|
|
4724
|
+
const chain = walletClient.chain;
|
|
4725
|
+
if (!account || !chain) {
|
|
4726
|
+
throw new Error("Wallet not connected");
|
|
4727
|
+
}
|
|
4728
|
+
if (chain.id !== metadata.chainId) {
|
|
4729
|
+
throw new Error(
|
|
4730
|
+
`Switch to ${metadata.marketName} chain (${metadata.chainId}) to sign`
|
|
4731
|
+
);
|
|
4732
|
+
}
|
|
4733
|
+
const prepared = await backend.prepareUnwind({
|
|
4734
|
+
address: account.address,
|
|
4735
|
+
// The backend resolves the recipient from this account rather than
|
|
4736
|
+
// trusting a supplied address. `amount` is always explicit — expressing
|
|
4737
|
+
// "everything" is the backend's call, since only it knows whether sweeping
|
|
4738
|
+
// accrued interest could push the delivered amount past a whitelist
|
|
4739
|
+
// ceiling and get the proceeds rejected after the withdraw succeeded.
|
|
4740
|
+
account: recipient,
|
|
4741
|
+
market: metadata.market,
|
|
4742
|
+
chainId: metadata.chainId,
|
|
4743
|
+
asset: metadata.asset,
|
|
4744
|
+
amount: amount.toString()
|
|
4745
|
+
});
|
|
4746
|
+
if (prepared.recipient.toLowerCase() !== recipient.toLowerCase()) {
|
|
4747
|
+
throw new Error(
|
|
4748
|
+
"Aave withdrawal would send funds to an unexpected address"
|
|
4749
|
+
);
|
|
4750
|
+
}
|
|
4751
|
+
if (prepared.transaction.chainId !== metadata.chainId) {
|
|
4752
|
+
throw new Error("Aave withdrawal was prepared for a different chain");
|
|
4753
|
+
}
|
|
4754
|
+
const txHash = await walletClient.sendTransaction({
|
|
4755
|
+
account,
|
|
4756
|
+
chain,
|
|
4757
|
+
to: prepared.transaction.to,
|
|
4758
|
+
data: prepared.transaction.data,
|
|
4759
|
+
value: BigInt(prepared.transaction.value)
|
|
4760
|
+
});
|
|
4761
|
+
return {
|
|
4762
|
+
txHash,
|
|
4763
|
+
// Aave pays out the underlying straight to the deposit address — no
|
|
4764
|
+
// unwrap, no swap, so what arrives is what was supplied.
|
|
4765
|
+
sourceToken: metadata.asset,
|
|
4766
|
+
sourceSymbol: asset.symbol,
|
|
4767
|
+
sourceDecimals: asset.decimals
|
|
4768
|
+
};
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
function toImportableAssets(positions) {
|
|
4772
|
+
const assets = [];
|
|
4773
|
+
for (const position of positions) {
|
|
4774
|
+
const chainId = parseEvmChainId(position.chain);
|
|
4775
|
+
if (chainId === null) continue;
|
|
4776
|
+
if (!CHAIN_BY_ID[chainId]) continue;
|
|
4777
|
+
if (BigInt(position.maxWithdrawable) <= 0n) continue;
|
|
4778
|
+
if (position.constraints.some((c) => POLICY_REFUSED.includes(c))) continue;
|
|
4779
|
+
assets.push(buildAsset(position, chainId));
|
|
4780
|
+
}
|
|
4781
|
+
return qualifyAmbiguousMarkets(assets);
|
|
4782
|
+
}
|
|
4783
|
+
function buildAsset(position, chainId) {
|
|
4784
|
+
const { asset, market } = position;
|
|
4785
|
+
const token = asset.address.toLowerCase();
|
|
4786
|
+
const metadata = {
|
|
4787
|
+
market: market.address,
|
|
4788
|
+
marketName: market.name,
|
|
4789
|
+
chainId,
|
|
4790
|
+
asset: asset.address
|
|
4791
|
+
};
|
|
4792
|
+
return {
|
|
4793
|
+
// Market-keyed, so one chain holding the same token in two markets yields
|
|
4794
|
+
// two distinct rows rather than one that silently shadows the other.
|
|
4795
|
+
id: `aave:${chainId}:${market.address.toLowerCase()}:${token}`,
|
|
4796
|
+
chainId,
|
|
4797
|
+
token,
|
|
4798
|
+
symbol: asset.symbol,
|
|
4799
|
+
// The market name, not a token description: it is what tells four Aave v3
|
|
4800
|
+
// markets on Ethereum apart.
|
|
4801
|
+
name: market.name,
|
|
4802
|
+
decimals: asset.decimals,
|
|
4803
|
+
// `maxWithdrawable`, NOT the supplied balance. The amount selector lets the
|
|
4804
|
+
// user pick up to this, and seeding it with the supplied balance would let
|
|
4805
|
+
// them choose above the cap and sign a withdraw the pool rejects.
|
|
4806
|
+
balance: position.maxWithdrawable,
|
|
4807
|
+
balanceUsd: withdrawableUsd(position),
|
|
4808
|
+
source: PROVIDER_ID,
|
|
4809
|
+
sourceLabel: SOURCE_LABEL,
|
|
4810
|
+
reviewLabel: `You withdraw ${asset.symbol} from Aave`,
|
|
4811
|
+
// Aave sends the underlying itself to the deposit address, so the token the
|
|
4812
|
+
// orchestrator sees land is the same one and on the same chain.
|
|
4813
|
+
depositToken: token,
|
|
4814
|
+
depositChainId: chainId,
|
|
4815
|
+
providerMetadata: metadata
|
|
4816
|
+
};
|
|
4817
|
+
}
|
|
4818
|
+
function qualifyAmbiguousMarkets(assets) {
|
|
4819
|
+
const counts = /* @__PURE__ */ new Map();
|
|
4820
|
+
for (const asset of assets) {
|
|
4821
|
+
const key = `${asset.chainId}:${asset.token}`;
|
|
4822
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
4823
|
+
}
|
|
4824
|
+
return assets.map(
|
|
4825
|
+
(asset) => (counts.get(`${asset.chainId}:${asset.token}`) ?? 0) > 1 ? {
|
|
4826
|
+
...asset,
|
|
4827
|
+
qualifier: asset.providerMetadata.marketName
|
|
4828
|
+
} : asset
|
|
4829
|
+
);
|
|
4830
|
+
}
|
|
4831
|
+
function withdrawableUsd(position) {
|
|
4832
|
+
const amount = BigInt(position.amount);
|
|
4833
|
+
const withdrawable = BigInt(position.maxWithdrawable);
|
|
4834
|
+
if (amount === 0n) return 0;
|
|
4835
|
+
if (withdrawable === amount) return position.usdValue;
|
|
4836
|
+
const SCALE = 1000000n;
|
|
4837
|
+
const ratio = Number(withdrawable * SCALE / amount) / Number(SCALE);
|
|
4838
|
+
const usd = position.usdValue * ratio;
|
|
4839
|
+
return Number.isFinite(usd) ? usd : 0;
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4662
4842
|
// src/core/dapp-imports/polymarket/index.ts
|
|
4663
4843
|
import { formatUnits as formatUnits6 } from "viem";
|
|
4664
4844
|
|
|
@@ -4829,11 +5009,10 @@ function buildPusdUnwrapCalls(recipient, amount) {
|
|
|
4829
5009
|
}
|
|
4830
5010
|
|
|
4831
5011
|
// src/core/dapp-imports/polymarket/index.ts
|
|
4832
|
-
var
|
|
5012
|
+
var PROVIDER_ID2 = "polymarket";
|
|
4833
5013
|
var polymarketProvider = {
|
|
4834
|
-
id:
|
|
5014
|
+
id: PROVIDER_ID2,
|
|
4835
5015
|
sourceLabel: "Polymarket",
|
|
4836
|
-
chainId: POLYMARKET_POLYGON_CHAIN_ID,
|
|
4837
5016
|
async fetchAvailability({ eoa, getPublicClient: getPublicClient2, signal }) {
|
|
4838
5017
|
const proxyWallet = await fetchPolymarketProxyWallet(eoa, signal);
|
|
4839
5018
|
if (!proxyWallet) return null;
|
|
@@ -4856,17 +5035,17 @@ var polymarketProvider = {
|
|
|
4856
5035
|
const assets = [];
|
|
4857
5036
|
if (balances.pusd > 0n) {
|
|
4858
5037
|
assets.push(
|
|
4859
|
-
|
|
5038
|
+
buildAsset2({ tokenKind: "pusd", proxyWallet, walletKind, balance: balances.pusd })
|
|
4860
5039
|
);
|
|
4861
5040
|
}
|
|
4862
5041
|
if (balances.usdce > 0n) {
|
|
4863
5042
|
assets.push(
|
|
4864
|
-
|
|
5043
|
+
buildAsset2({ tokenKind: "usdce", proxyWallet, walletKind, balance: balances.usdce })
|
|
4865
5044
|
);
|
|
4866
5045
|
}
|
|
4867
5046
|
const totalUsd = assets.reduce((sum, a) => sum + (a.balanceUsd ?? 0), 0);
|
|
4868
5047
|
const availability = {
|
|
4869
|
-
providerId:
|
|
5048
|
+
providerId: PROVIDER_ID2,
|
|
4870
5049
|
totalUsd,
|
|
4871
5050
|
assets
|
|
4872
5051
|
};
|
|
@@ -4914,7 +5093,7 @@ var polymarketProvider = {
|
|
|
4914
5093
|
};
|
|
4915
5094
|
}
|
|
4916
5095
|
};
|
|
4917
|
-
function
|
|
5096
|
+
function buildAsset2(params) {
|
|
4918
5097
|
const { tokenKind, proxyWallet, walletKind, balance } = params;
|
|
4919
5098
|
const isPusd = tokenKind === "pusd";
|
|
4920
5099
|
const tokenAddress = isPusd ? POLYMARKET_PUSD_ADDRESS : POLYMARKET_USDCE_ADDRESS;
|
|
@@ -4931,8 +5110,11 @@ function buildAsset(params) {
|
|
|
4931
5110
|
decimals: 6,
|
|
4932
5111
|
balance: balance.toString(),
|
|
4933
5112
|
balanceUsd: Number.isFinite(balanceUsd) ? balanceUsd : 0,
|
|
4934
|
-
source:
|
|
5113
|
+
source: PROVIDER_ID2,
|
|
4935
5114
|
sourceLabel: "Polymarket",
|
|
5115
|
+
// The proxy wallet really does hold this ERC-20, so the amount step reads it
|
|
5116
|
+
// live rather than trusting the figure from the availability fetch.
|
|
5117
|
+
balanceAddress: proxyWallet,
|
|
4936
5118
|
reviewLabel: isPusd ? "You send pUSD from Polymarket" : "You send USDC.e from Polymarket",
|
|
4937
5119
|
// pUSD unwraps to USDC.e via the offramp; USDC.e is what actually
|
|
4938
5120
|
// arrives at the smart account, so it's also what the orchestrator
|
|
@@ -4944,7 +5126,10 @@ function buildAsset(params) {
|
|
|
4944
5126
|
}
|
|
4945
5127
|
|
|
4946
5128
|
// src/core/dapp-imports/registry.ts
|
|
4947
|
-
var DAPP_IMPORT_PROVIDERS = [
|
|
5129
|
+
var DAPP_IMPORT_PROVIDERS = [
|
|
5130
|
+
polymarketProvider,
|
|
5131
|
+
aaveProvider
|
|
5132
|
+
];
|
|
4948
5133
|
function getEnabledProviders(config) {
|
|
4949
5134
|
if (!config) return [];
|
|
4950
5135
|
return DAPP_IMPORT_PROVIDERS.filter(
|
|
@@ -6778,6 +6963,9 @@ function DepositFlow({
|
|
|
6778
6963
|
return null;
|
|
6779
6964
|
}
|
|
6780
6965
|
},
|
|
6966
|
+
// Providers whose positions live behind the Rhinestone API rather than
|
|
6967
|
+
// an RPC (Aave) read them through here.
|
|
6968
|
+
backend: service,
|
|
6781
6969
|
signal: controller.signal
|
|
6782
6970
|
}).then((availability) => {
|
|
6783
6971
|
if (controller.signal.aborted) return;
|
|
@@ -6802,7 +6990,8 @@ function DepositFlow({
|
|
|
6802
6990
|
enabledDappImportProviders,
|
|
6803
6991
|
dappImportAttemptNonce,
|
|
6804
6992
|
storeApi,
|
|
6805
|
-
rpcUrls
|
|
6993
|
+
rpcUrls,
|
|
6994
|
+
service
|
|
6806
6995
|
]);
|
|
6807
6996
|
useLayoutEffect2(() => {
|
|
6808
6997
|
if (!initialAssetMigrationProvider) return;
|
|
@@ -7106,9 +7295,6 @@ function DepositFlow({
|
|
|
7106
7295
|
acknowledgedConnectFeeRef.current.clear();
|
|
7107
7296
|
}, [setupSlice.smartAccount]);
|
|
7108
7297
|
const hasConfiguredFiatMethods = fiatMethods !== void 0;
|
|
7109
|
-
const regionalMethodsInteractedRef = useRef8(false);
|
|
7110
|
-
const regionalMethodsAppliedRef = useRef8(false);
|
|
7111
|
-
const [regionalMethodsLocked, setRegionalMethodsLocked] = useState12(false);
|
|
7112
7298
|
const [regionalMethods, setRegionalMethods] = useState12({
|
|
7113
7299
|
status: "loading",
|
|
7114
7300
|
country: null,
|
|
@@ -7118,17 +7304,16 @@ function DepositFlow({
|
|
|
7118
7304
|
useEffect11(() => {
|
|
7119
7305
|
if (!fiatEnabled || hasConfiguredFiatMethods) return;
|
|
7120
7306
|
let cancelled = false;
|
|
7121
|
-
regionalMethodsInteractedRef.current = false;
|
|
7122
|
-
regionalMethodsAppliedRef.current = false;
|
|
7123
|
-
setRegionalMethodsLocked(false);
|
|
7124
7307
|
setRegionalMethods({
|
|
7125
7308
|
status: "loading",
|
|
7126
7309
|
country: null,
|
|
7127
7310
|
methods: [],
|
|
7128
7311
|
recommendedMethod: null
|
|
7129
7312
|
});
|
|
7313
|
+
let settled = false;
|
|
7130
7314
|
const showFallback = () => {
|
|
7131
|
-
if (cancelled) return;
|
|
7315
|
+
if (cancelled || settled) return;
|
|
7316
|
+
settled = true;
|
|
7132
7317
|
setRegionalMethods({
|
|
7133
7318
|
status: "error",
|
|
7134
7319
|
country: null,
|
|
@@ -7136,33 +7321,22 @@ function DepositFlow({
|
|
|
7136
7321
|
recommendedMethod: null
|
|
7137
7322
|
});
|
|
7138
7323
|
};
|
|
7139
|
-
const
|
|
7140
|
-
showFallback,
|
|
7141
|
-
REGIONAL_METHODS_FALLBACK_DELAY_MS
|
|
7142
|
-
);
|
|
7324
|
+
const timeoutTimer = setTimeout(showFallback, REGIONAL_METHODS_TIMEOUT_MS);
|
|
7143
7325
|
service.getSwappedPaymentMethods().then((res) => {
|
|
7144
|
-
if (cancelled) return;
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
showFallback();
|
|
7148
|
-
return;
|
|
7149
|
-
}
|
|
7326
|
+
if (cancelled || settled) return;
|
|
7327
|
+
settled = true;
|
|
7328
|
+
clearTimeout(timeoutTimer);
|
|
7150
7329
|
setRegionalMethods({ status: "ready", ...res });
|
|
7151
7330
|
}).catch(() => {
|
|
7152
7331
|
if (cancelled) return;
|
|
7153
|
-
clearTimeout(
|
|
7332
|
+
clearTimeout(timeoutTimer);
|
|
7154
7333
|
showFallback();
|
|
7155
7334
|
});
|
|
7156
7335
|
return () => {
|
|
7157
7336
|
cancelled = true;
|
|
7158
|
-
clearTimeout(
|
|
7337
|
+
clearTimeout(timeoutTimer);
|
|
7159
7338
|
};
|
|
7160
7339
|
}, [fiatEnabled, hasConfiguredFiatMethods, service]);
|
|
7161
|
-
useLayoutEffect2(() => {
|
|
7162
|
-
if (regionalMethods.status === "ready" && !regionalMethodsLocked) {
|
|
7163
|
-
regionalMethodsAppliedRef.current = true;
|
|
7164
|
-
}
|
|
7165
|
-
}, [regionalMethods.status, regionalMethodsLocked]);
|
|
7166
7340
|
const cashDisplay = useMemo7(() => {
|
|
7167
7341
|
if (!fiatEnabled) return { kind: "hidden" };
|
|
7168
7342
|
if (hasConfiguredFiatMethods) {
|
|
@@ -7174,22 +7348,12 @@ function DepositFlow({
|
|
|
7174
7348
|
source: "configured"
|
|
7175
7349
|
};
|
|
7176
7350
|
}
|
|
7177
|
-
|
|
7178
|
-
status: "error",
|
|
7179
|
-
country: null,
|
|
7180
|
-
methods: [],
|
|
7181
|
-
recommendedMethod: null
|
|
7182
|
-
} : regionalMethods;
|
|
7183
|
-
return composeFiatMethods(
|
|
7184
|
-
effectiveRegionalMethods,
|
|
7185
|
-
FIAT_ONRAMP_METHODS
|
|
7186
|
-
);
|
|
7351
|
+
return composeFiatMethods(regionalMethods, FIAT_ONRAMP_METHODS);
|
|
7187
7352
|
}, [
|
|
7188
7353
|
fiatEnabled,
|
|
7189
7354
|
hasConfiguredFiatMethods,
|
|
7190
7355
|
offeredFiatMethods,
|
|
7191
|
-
regionalMethods
|
|
7192
|
-
regionalMethodsLocked
|
|
7356
|
+
regionalMethods
|
|
7193
7357
|
]);
|
|
7194
7358
|
const lastFiatMethodsRenderedEventRef = useRef8(null);
|
|
7195
7359
|
useEffect11(() => {
|
|
@@ -7211,11 +7375,6 @@ function DepositFlow({
|
|
|
7211
7375
|
source: cashDisplay.source
|
|
7212
7376
|
});
|
|
7213
7377
|
}, [cashDisplay, onEvent, onEventRef]);
|
|
7214
|
-
const markRegionalMethodsInteracted = useCallback7(() => {
|
|
7215
|
-
if (regionalMethodsAppliedRef.current) return;
|
|
7216
|
-
regionalMethodsInteractedRef.current = true;
|
|
7217
|
-
setRegionalMethodsLocked(true);
|
|
7218
|
-
}, []);
|
|
7219
7378
|
const displayedFiatSource = cashDisplay.kind === "list" ? cashDisplay.source : void 0;
|
|
7220
7379
|
const displayedFiatCountry = cashDisplay.kind === "list" ? cashDisplay.country : null;
|
|
7221
7380
|
const handleSelectDisplayedFiatMethod = useCallback7(
|
|
@@ -7695,7 +7854,6 @@ function DepositFlow({
|
|
|
7695
7854
|
walletRows,
|
|
7696
7855
|
defaultMethodTab: flowSlice.methodTab,
|
|
7697
7856
|
onMethodTabChange: (tab) => storeApi.dispatch({ type: "connect/method-tab-changed", tab }),
|
|
7698
|
-
onInteract: fiatEnabled && !hasConfiguredFiatMethods ? markRegionalMethodsInteracted : void 0,
|
|
7699
7857
|
transferCryptoState,
|
|
7700
7858
|
transferCryptoErrorReason: transferCryptoEntry.message ?? void 0,
|
|
7701
7859
|
onSelectTransferCrypto: (
|
|
@@ -8137,6 +8295,7 @@ function DepositFlow({
|
|
|
8137
8295
|
{
|
|
8138
8296
|
sourceLabel: activeDappImportAvailability.assets[0]?.sourceLabel ?? activeDappImportProvider.sourceLabel,
|
|
8139
8297
|
assets: activeDappImportAvailability.assets,
|
|
8298
|
+
incompleteSummary: activeDappImportAvailability.incomplete?.summary,
|
|
8140
8299
|
onSelect: handleDappImportAssetSelected
|
|
8141
8300
|
}
|
|
8142
8301
|
),
|
|
@@ -8146,7 +8305,7 @@ function DepositFlow({
|
|
|
8146
8305
|
walletClient: signerContext.walletClient,
|
|
8147
8306
|
publicClient: getReadClientForChain(effectiveStep.asset.chainId),
|
|
8148
8307
|
address: ownerAddress,
|
|
8149
|
-
|
|
8308
|
+
...dappImportBalanceSource(effectiveStep.asset),
|
|
8150
8309
|
asset: effectiveStep.asset,
|
|
8151
8310
|
defaultAmount: effectiveStep.inputAmountUsd ?? defaultAmount,
|
|
8152
8311
|
switchChain: signerContext.switchChain,
|
|
@@ -8193,8 +8352,11 @@ function DepositFlow({
|
|
|
8193
8352
|
const result = await activeDappImportProvider.executeTransfer(
|
|
8194
8353
|
{
|
|
8195
8354
|
walletClient: signerContext.walletClient,
|
|
8355
|
+
// The asset's chain: a provider's assets can span chains
|
|
8356
|
+
// (Aave positions exist on every deposit-enabled chain), so
|
|
8357
|
+
// there is no single provider-level chain to read from.
|
|
8196
8358
|
publicClient: getReadClientForChain(
|
|
8197
|
-
|
|
8359
|
+
effectiveStep.asset.chainId
|
|
8198
8360
|
),
|
|
8199
8361
|
recipient: effectiveStep.smartAccount,
|
|
8200
8362
|
asset: effectiveStep.asset,
|
|
@@ -8533,7 +8695,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
|
|
|
8533
8695
|
// src/DepositModal.tsx
|
|
8534
8696
|
import { jsx as jsx27, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8535
8697
|
var ReownDepositInner = lazy2(
|
|
8536
|
-
() => import("./DepositModalReown-
|
|
8698
|
+
() => import("./DepositModalReown-MTWT6Y66.mjs").then((m) => ({ default: m.DepositModalReown }))
|
|
8537
8699
|
);
|
|
8538
8700
|
function sortByCreatedAtDesc(items) {
|
|
8539
8701
|
return [...items].sort((a, b) => {
|