@unifold/ui-react 0.1.62 → 0.1.64
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/index.d.mts +32 -14
- package/dist/index.d.ts +32 -14
- package/dist/index.js +1223 -619
- package/dist/index.mjs +1178 -570
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -128,8 +128,32 @@ var import_tailwind_merge = require("tailwind-merge");
|
|
|
128
128
|
function cn(...inputs) {
|
|
129
129
|
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
130
130
|
}
|
|
131
|
-
var
|
|
131
|
+
var WALLET_STATE_STORAGE_KEY = "unifold_wallet_state";
|
|
132
|
+
var LEGACY_WALLET_KEYS = [
|
|
133
|
+
"unifold_last_wallet_type",
|
|
134
|
+
"unifold_last_connected_wallet"
|
|
135
|
+
];
|
|
132
136
|
var WALLET_USER_DISCONNECTED_KEY = "unifold_wallet_user_disconnected";
|
|
137
|
+
var SOLANA_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
138
|
+
"phantom-solana",
|
|
139
|
+
"solflare",
|
|
140
|
+
"backpack",
|
|
141
|
+
"glow"
|
|
142
|
+
]);
|
|
143
|
+
var ETHEREUM_WALLET_TYPES = /* @__PURE__ */ new Set([
|
|
144
|
+
"metamask",
|
|
145
|
+
"phantom-ethereum",
|
|
146
|
+
"coinbase",
|
|
147
|
+
"trust",
|
|
148
|
+
"rainbow",
|
|
149
|
+
"rabby",
|
|
150
|
+
"okx"
|
|
151
|
+
]);
|
|
152
|
+
function walletTypeToChain(t12) {
|
|
153
|
+
if (SOLANA_WALLET_TYPES.has(t12)) return "solana";
|
|
154
|
+
if (ETHEREUM_WALLET_TYPES.has(t12)) return "ethereum";
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
133
157
|
function getUserDisconnectedWallet() {
|
|
134
158
|
if (typeof window === "undefined") return false;
|
|
135
159
|
try {
|
|
@@ -149,26 +173,35 @@ function setUserDisconnectedWallet(disconnected) {
|
|
|
149
173
|
} catch {
|
|
150
174
|
}
|
|
151
175
|
}
|
|
152
|
-
function
|
|
176
|
+
function getStoredWalletState() {
|
|
153
177
|
if (typeof window === "undefined") return void 0;
|
|
154
178
|
try {
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
179
|
+
const raw = localStorage.getItem(WALLET_STATE_STORAGE_KEY);
|
|
180
|
+
if (!raw) return void 0;
|
|
181
|
+
const chainType = walletTypeToChain(raw);
|
|
182
|
+
if (!chainType) {
|
|
183
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
184
|
+
return void 0;
|
|
185
|
+
}
|
|
186
|
+
return { walletType: raw, chainType };
|
|
157
187
|
} catch {
|
|
188
|
+
return void 0;
|
|
158
189
|
}
|
|
159
|
-
return void 0;
|
|
160
190
|
}
|
|
161
|
-
function
|
|
191
|
+
function setStoredWalletState(walletType) {
|
|
162
192
|
if (typeof window === "undefined") return;
|
|
193
|
+
if (!walletTypeToChain(walletType)) return;
|
|
163
194
|
try {
|
|
164
|
-
localStorage.setItem(
|
|
195
|
+
localStorage.setItem(WALLET_STATE_STORAGE_KEY, walletType);
|
|
196
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
165
197
|
} catch {
|
|
166
198
|
}
|
|
167
199
|
}
|
|
168
|
-
function
|
|
200
|
+
function clearStoredWalletState() {
|
|
169
201
|
if (typeof window === "undefined") return;
|
|
170
202
|
try {
|
|
171
|
-
localStorage.removeItem(
|
|
203
|
+
localStorage.removeItem(WALLET_STATE_STORAGE_KEY);
|
|
204
|
+
for (const key of LEGACY_WALLET_KEYS) localStorage.removeItem(key);
|
|
172
205
|
} catch {
|
|
173
206
|
}
|
|
174
207
|
}
|
|
@@ -539,6 +572,36 @@ function ThemeProvider({
|
|
|
539
572
|
);
|
|
540
573
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: contextValue, children });
|
|
541
574
|
}
|
|
575
|
+
function AccentColorOverride({
|
|
576
|
+
accentColor,
|
|
577
|
+
accentForeground,
|
|
578
|
+
children
|
|
579
|
+
}) {
|
|
580
|
+
const parent = useTheme();
|
|
581
|
+
const value = React.useMemo(() => {
|
|
582
|
+
if (!accentColor) return parent;
|
|
583
|
+
const foreground = accentForeground ?? parent.colors.primaryForeground;
|
|
584
|
+
const nextColors = {
|
|
585
|
+
...parent.colors,
|
|
586
|
+
primary: accentColor,
|
|
587
|
+
primaryForeground: foreground
|
|
588
|
+
};
|
|
589
|
+
const nextComponents = {
|
|
590
|
+
...parent.components,
|
|
591
|
+
button: {
|
|
592
|
+
...parent.components.button,
|
|
593
|
+
primaryBackground: accentColor,
|
|
594
|
+
primaryText: foreground
|
|
595
|
+
},
|
|
596
|
+
card: {
|
|
597
|
+
...parent.components.card,
|
|
598
|
+
iconBackgroundColor: `${accentColor}26`
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
return { ...parent, colors: nextColors, components: nextComponents };
|
|
602
|
+
}, [parent, accentColor, accentForeground]);
|
|
603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value, children });
|
|
604
|
+
}
|
|
542
605
|
function useTheme() {
|
|
543
606
|
const context = React.useContext(ThemeContext);
|
|
544
607
|
if (!context) {
|
|
@@ -770,6 +833,60 @@ var import_core3 = require("@unifold/core");
|
|
|
770
833
|
|
|
771
834
|
// src/components/deposits/browser-wallets/utils.ts
|
|
772
835
|
var import_core2 = require("@unifold/core");
|
|
836
|
+
var normalize = (value) => value?.toLowerCase();
|
|
837
|
+
function sourceTokenMatchesDefaultSource(token, defaultSource) {
|
|
838
|
+
if (!token || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
if (token.chain_type !== defaultSource.defaultSourceChainType || token.chain_id !== defaultSource.defaultSourceChainId) {
|
|
842
|
+
return false;
|
|
843
|
+
}
|
|
844
|
+
if (defaultSource.defaultSourceTokenAddress && normalize(token.token_address) === normalize(defaultSource.defaultSourceTokenAddress)) {
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
return !!defaultSource.defaultSourceSymbol && normalize(token.symbol) === normalize(defaultSource.defaultSourceSymbol);
|
|
851
|
+
}
|
|
852
|
+
function isDefaultSourceBalance(balance, defaultSource) {
|
|
853
|
+
return isBalanceEligible(balance) && sourceTokenMatchesDefaultSource(getTokenFromBalance(balance), defaultSource);
|
|
854
|
+
}
|
|
855
|
+
function compareBalancesWithDefaultSource(a, b, defaultSource) {
|
|
856
|
+
const aDefault = isDefaultSourceBalance(a, defaultSource);
|
|
857
|
+
const bDefault = isDefaultSourceBalance(b, defaultSource);
|
|
858
|
+
if (aDefault && !bDefault) return -1;
|
|
859
|
+
if (!aDefault && bDefault) return 1;
|
|
860
|
+
const aEligible = isBalanceEligible(a);
|
|
861
|
+
const bEligible = isBalanceEligible(b);
|
|
862
|
+
if (aEligible && !bEligible) return -1;
|
|
863
|
+
if (!aEligible && bEligible) return 1;
|
|
864
|
+
return 0;
|
|
865
|
+
}
|
|
866
|
+
function resolveDefaultSourceSymbol(supportedTokens, defaultSource) {
|
|
867
|
+
if (!supportedTokens?.length || !defaultSource.defaultSourceChainType || !defaultSource.defaultSourceChainId) {
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
870
|
+
if (defaultSource.defaultSourceTokenAddress) {
|
|
871
|
+
for (const token of supportedTokens) {
|
|
872
|
+
const matchingChain = token.chains.find(
|
|
873
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId && normalize(chain.token_address) === normalize(defaultSource.defaultSourceTokenAddress)
|
|
874
|
+
);
|
|
875
|
+
if (matchingChain) return token.symbol;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (!defaultSource.defaultSourceSymbol) return null;
|
|
879
|
+
for (const token of supportedTokens) {
|
|
880
|
+
if (normalize(token.symbol) !== normalize(defaultSource.defaultSourceSymbol)) {
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
const matchingChain = token.chains.find(
|
|
884
|
+
(chain) => chain.chain_type === defaultSource.defaultSourceChainType && chain.chain_id === defaultSource.defaultSourceChainId
|
|
885
|
+
);
|
|
886
|
+
if (matchingChain) return token.symbol;
|
|
887
|
+
}
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
773
890
|
function formatUsdFromBalancePercent(maxUsdAmount, percent) {
|
|
774
891
|
if (maxUsdAmount <= 0 || percent < 0) return "";
|
|
775
892
|
const raw = maxUsdAmount * percent / 100;
|
|
@@ -1591,6 +1708,7 @@ function useDepositPolling({
|
|
|
1591
1708
|
clientSecret,
|
|
1592
1709
|
depositConfirmationMode = "auto_ui",
|
|
1593
1710
|
depositWalletId,
|
|
1711
|
+
depositWalletIds,
|
|
1594
1712
|
enabled = true,
|
|
1595
1713
|
immediateDirectPolling = false,
|
|
1596
1714
|
onDepositSuccess,
|
|
@@ -1736,21 +1854,25 @@ function useDepositPolling({
|
|
|
1736
1854
|
setIsPolling(false);
|
|
1737
1855
|
};
|
|
1738
1856
|
}, [userId, publishableKey, clientSecret, enabled]);
|
|
1857
|
+
const pollWalletIdsKey = depositWalletIds && depositWalletIds.length > 0 ? Array.from(new Set(depositWalletIds.filter(Boolean))).join(",") : depositWalletId || "";
|
|
1739
1858
|
(0, import_react3.useEffect)(() => {
|
|
1740
|
-
if (!pollingEnabled || !
|
|
1859
|
+
if (!pollingEnabled || !pollWalletIdsKey) return;
|
|
1860
|
+
const ids = pollWalletIdsKey.split(",").filter(Boolean);
|
|
1741
1861
|
const triggerPoll = async () => {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1862
|
+
await Promise.all(
|
|
1863
|
+
ids.map(
|
|
1864
|
+
(id) => (0, import_core6.pollDirectExecutions)(
|
|
1865
|
+
{ deposit_wallet_id: id },
|
|
1866
|
+
publishableKey
|
|
1867
|
+
).catch(() => {
|
|
1868
|
+
})
|
|
1869
|
+
)
|
|
1870
|
+
);
|
|
1749
1871
|
};
|
|
1750
1872
|
triggerPoll();
|
|
1751
1873
|
const interval = setInterval(triggerPoll, POLL_ENDPOINT_INTERVAL_MS);
|
|
1752
1874
|
return () => clearInterval(interval);
|
|
1753
|
-
}, [pollingEnabled,
|
|
1875
|
+
}, [pollingEnabled, pollWalletIdsKey, publishableKey]);
|
|
1754
1876
|
const handleIveDeposited = () => {
|
|
1755
1877
|
setPollingEnabled(true);
|
|
1756
1878
|
setShowWaitingUi(true);
|
|
@@ -2966,6 +3088,7 @@ function BuyWithCard({
|
|
|
2966
3088
|
if (!selectedProvider) return "0.000000";
|
|
2967
3089
|
return selectedProvider.destination_amount.toFixed(6);
|
|
2968
3090
|
};
|
|
3091
|
+
const canOpenProviderSelector = !quotesLoading && quotes.length > 1;
|
|
2969
3092
|
const selectedCurrencyData = fiatCurrencies.find(
|
|
2970
3093
|
(c) => c.currency_code.toLowerCase() === currency.toLowerCase()
|
|
2971
3094
|
);
|
|
@@ -3151,9 +3274,12 @@ function BuyWithCard({
|
|
|
3151
3274
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3152
3275
|
"button",
|
|
3153
3276
|
{
|
|
3154
|
-
onClick: () =>
|
|
3277
|
+
onClick: () => {
|
|
3278
|
+
if (canOpenProviderSelector) handleViewChange("quotes");
|
|
3279
|
+
},
|
|
3155
3280
|
disabled: quotesLoading || quotes.length === 0,
|
|
3156
|
-
|
|
3281
|
+
"aria-disabled": !canOpenProviderSelector,
|
|
3282
|
+
className: `uf-w-full uf-transition-colors uf-p-4 uf-group disabled:uf-opacity-50 disabled:uf-cursor-not-allowed ${canOpenProviderSelector ? "hover:uf-bg-accent uf-cursor-pointer" : "uf-cursor-default"}`,
|
|
3157
3283
|
style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
|
|
3158
3284
|
children: quotesLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "uf-text-left uf-w-full uf-animate-pulse", children: [
|
|
3159
3285
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
@@ -3180,7 +3306,7 @@ function BuyWithCard({
|
|
|
3180
3306
|
)
|
|
3181
3307
|
] })
|
|
3182
3308
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "uf-w-full uf-text-left", children: [
|
|
3183
|
-
isAutoSelected && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3309
|
+
isAutoSelected && canOpenProviderSelector && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3184
3310
|
"div",
|
|
3185
3311
|
{
|
|
3186
3312
|
className: "uf-text-xs uf-font-normal uf-mb-2",
|
|
@@ -3216,7 +3342,7 @@ function BuyWithCard({
|
|
|
3216
3342
|
),
|
|
3217
3343
|
selectedProvider.low_kyc === false && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "uf-text-[10px] uf-text-muted-foreground uf-font-normal", children: "No document upload" }) })
|
|
3218
3344
|
] }),
|
|
3219
|
-
|
|
3345
|
+
canOpenProviderSelector && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3220
3346
|
import_lucide_react7.ChevronRight,
|
|
3221
3347
|
{
|
|
3222
3348
|
className: "uf-w-4 uf-h-4 group-hover:uf-text-foreground uf-transition-colors uf-flex-shrink-0",
|
|
@@ -5419,70 +5545,106 @@ function identifyEthWallet(provider, hint) {
|
|
|
5419
5545
|
}
|
|
5420
5546
|
return { type: "metamask", name: "Wallet", icon: "metamask" };
|
|
5421
5547
|
}
|
|
5548
|
+
var EIP6963_ID_TO_WALLET_TYPE = {
|
|
5549
|
+
metamask: "metamask",
|
|
5550
|
+
phantom: "phantom-ethereum",
|
|
5551
|
+
coinbase: "coinbase",
|
|
5552
|
+
trust: "trust",
|
|
5553
|
+
rainbow: "rainbow",
|
|
5554
|
+
rabby: "rabby",
|
|
5555
|
+
okx: "okx"
|
|
5556
|
+
};
|
|
5557
|
+
function inferEthWalletType(provider, walletId) {
|
|
5558
|
+
if (EIP6963_ID_TO_WALLET_TYPE[walletId]) return EIP6963_ID_TO_WALLET_TYPE[walletId];
|
|
5559
|
+
const any = provider;
|
|
5560
|
+
if (provider.isPhantom) return "phantom-ethereum";
|
|
5561
|
+
if (any.isCoinbaseWallet) return "coinbase";
|
|
5562
|
+
if (any.isRabby) return "rabby";
|
|
5563
|
+
if (any.isTrust) return "trust";
|
|
5564
|
+
if (any.isRainbow) return "rainbow";
|
|
5565
|
+
if (any.isOkxWallet) return "okx";
|
|
5566
|
+
if (provider.isMetaMask && !provider.isPhantom) return "metamask";
|
|
5567
|
+
return null;
|
|
5568
|
+
}
|
|
5569
|
+
function solanaCandidate(provider, type, name, icon) {
|
|
5570
|
+
return {
|
|
5571
|
+
walletType: type,
|
|
5572
|
+
detect: async () => {
|
|
5573
|
+
if (!provider) return null;
|
|
5574
|
+
if (provider.isConnected && provider.publicKey) {
|
|
5575
|
+
return { type, name, address: provider.publicKey.toString(), icon };
|
|
5576
|
+
}
|
|
5577
|
+
try {
|
|
5578
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
5579
|
+
if (resp.publicKey) {
|
|
5580
|
+
return { type, name, address: resp.publicKey.toString(), icon };
|
|
5581
|
+
}
|
|
5582
|
+
} catch {
|
|
5583
|
+
}
|
|
5584
|
+
return null;
|
|
5585
|
+
}
|
|
5586
|
+
};
|
|
5587
|
+
}
|
|
5588
|
+
function ethereumCandidate(provider, walletId) {
|
|
5589
|
+
return {
|
|
5590
|
+
walletType: inferEthWalletType(provider, walletId),
|
|
5591
|
+
detect: async () => {
|
|
5592
|
+
try {
|
|
5593
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
5594
|
+
if (!accounts?.length) return null;
|
|
5595
|
+
const resolved = identifyEthWallet(provider, walletId);
|
|
5596
|
+
return { ...resolved, address: accounts[0] };
|
|
5597
|
+
} catch {
|
|
5598
|
+
return null;
|
|
5599
|
+
}
|
|
5600
|
+
}
|
|
5601
|
+
};
|
|
5602
|
+
}
|
|
5603
|
+
function buildCandidates(win, chainType) {
|
|
5604
|
+
const candidates = [];
|
|
5605
|
+
if (!chainType || chainType === "solana") {
|
|
5606
|
+
candidates.push(
|
|
5607
|
+
solanaCandidate(win.phantom?.solana, "phantom-solana", "Phantom", "phantom"),
|
|
5608
|
+
solanaCandidate(win.solflare, "solflare", "Solflare", "solflare"),
|
|
5609
|
+
solanaCandidate(win.backpack, "backpack", "Backpack", "backpack"),
|
|
5610
|
+
solanaCandidate(win.glow, "glow", "Glow", "glow")
|
|
5611
|
+
);
|
|
5612
|
+
}
|
|
5613
|
+
if (!chainType || chainType === "ethereum") {
|
|
5614
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5615
|
+
const addEth = (provider, walletId) => {
|
|
5616
|
+
if (!provider || seen.has(provider)) return;
|
|
5617
|
+
seen.add(provider);
|
|
5618
|
+
candidates.push(ethereumCandidate(provider, walletId));
|
|
5619
|
+
};
|
|
5620
|
+
for (const { provider, walletId } of getEip6963Providers()) {
|
|
5621
|
+
addEth(
|
|
5622
|
+
provider,
|
|
5623
|
+
walletId === "unknown" ? "default" : walletId
|
|
5624
|
+
);
|
|
5625
|
+
}
|
|
5626
|
+
addEth(win.phantom?.ethereum, "phantom");
|
|
5627
|
+
addEth(win.coinbaseWalletExtension, "coinbase");
|
|
5628
|
+
addEth(win.okxwallet, "okx");
|
|
5629
|
+
addEth(win.trustwallet?.ethereum, "trust");
|
|
5630
|
+
addEth(win.ethereum, "default");
|
|
5631
|
+
}
|
|
5632
|
+
return candidates;
|
|
5633
|
+
}
|
|
5422
5634
|
async function detectConnectedBrowserWallet(chainType) {
|
|
5423
5635
|
if (typeof window === "undefined") return null;
|
|
5424
5636
|
if (getUserDisconnectedWallet()) return null;
|
|
5425
5637
|
try {
|
|
5426
5638
|
const win = window;
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
}
|
|
5433
|
-
try {
|
|
5434
|
-
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
5435
|
-
if (resp.publicKey) {
|
|
5436
|
-
return { type, name, address: resp.publicKey.toString(), icon };
|
|
5437
|
-
}
|
|
5438
|
-
} catch {
|
|
5439
|
-
}
|
|
5440
|
-
return null;
|
|
5441
|
-
};
|
|
5442
|
-
const solanaCandidates = [
|
|
5443
|
-
[win.phantom?.solana, "phantom-solana", "Phantom", "phantom"],
|
|
5444
|
-
[win.solflare, "solflare", "Solflare", "solflare"],
|
|
5445
|
-
[win.backpack, "backpack", "Backpack", "backpack"],
|
|
5446
|
-
[win.glow, "glow", "Glow", "glow"]
|
|
5447
|
-
];
|
|
5448
|
-
for (const [provider, type, name, icon] of solanaCandidates) {
|
|
5449
|
-
const found = await trySilentSolana(provider, type, name, icon);
|
|
5450
|
-
if (found) return found;
|
|
5451
|
-
}
|
|
5639
|
+
const candidates = buildCandidates(win, chainType);
|
|
5640
|
+
const preferred = getStoredWalletState();
|
|
5641
|
+
if (preferred && (!chainType || preferred.chainType === chainType)) {
|
|
5642
|
+
const idx = candidates.findIndex((c) => c.walletType === preferred.walletType);
|
|
5643
|
+
if (idx > 0) candidates.unshift(...candidates.splice(idx, 1));
|
|
5452
5644
|
}
|
|
5453
|
-
|
|
5454
|
-
const
|
|
5455
|
-
|
|
5456
|
-
for (const { provider, walletId } of eip6963) {
|
|
5457
|
-
allProviders.push({
|
|
5458
|
-
provider,
|
|
5459
|
-
walletId: walletId === "unknown" ? "default" : walletId
|
|
5460
|
-
});
|
|
5461
|
-
}
|
|
5462
|
-
if (allProviders.length === 0) {
|
|
5463
|
-
if (win.phantom?.ethereum) {
|
|
5464
|
-
allProviders.push({ provider: win.phantom.ethereum, walletId: "phantom" });
|
|
5465
|
-
}
|
|
5466
|
-
if (win.okxwallet) {
|
|
5467
|
-
allProviders.push({ provider: win.okxwallet, walletId: "okx" });
|
|
5468
|
-
}
|
|
5469
|
-
if (win.coinbaseWalletExtension) {
|
|
5470
|
-
allProviders.push({ provider: win.coinbaseWalletExtension, walletId: "coinbase" });
|
|
5471
|
-
}
|
|
5472
|
-
if (win.ethereum && !allProviders.some((p) => p.provider === win.ethereum)) {
|
|
5473
|
-
allProviders.push({ provider: win.ethereum, walletId: "default" });
|
|
5474
|
-
}
|
|
5475
|
-
}
|
|
5476
|
-
for (const { provider, walletId } of allProviders) {
|
|
5477
|
-
if (!provider) continue;
|
|
5478
|
-
try {
|
|
5479
|
-
const accounts = await provider.request({ method: "eth_accounts" });
|
|
5480
|
-
if (!accounts || accounts.length === 0) continue;
|
|
5481
|
-
const resolved = identifyEthWallet(provider, walletId);
|
|
5482
|
-
return { ...resolved, address: accounts[0] };
|
|
5483
|
-
} catch {
|
|
5484
|
-
}
|
|
5485
|
-
}
|
|
5645
|
+
for (const c of candidates) {
|
|
5646
|
+
const found = await c.detect();
|
|
5647
|
+
if (found) return found;
|
|
5486
5648
|
}
|
|
5487
5649
|
} catch (error) {
|
|
5488
5650
|
console.error("[detectConnectedBrowserWallet] detection error:", error);
|
|
@@ -7686,6 +7848,7 @@ function BrowserWalletButton({
|
|
|
7686
7848
|
if (solanaProvider?.isPhantom) {
|
|
7687
7849
|
const { publicKey } = await solanaProvider.connect();
|
|
7688
7850
|
setUserDisconnectedWallet(false);
|
|
7851
|
+
setStoredWalletState("phantom-solana");
|
|
7689
7852
|
setWallet({
|
|
7690
7853
|
type: "phantom-solana",
|
|
7691
7854
|
name: "Phantom",
|
|
@@ -7705,8 +7868,10 @@ function BrowserWalletButton({
|
|
|
7705
7868
|
if (accounts && accounts.length > 0) {
|
|
7706
7869
|
setUserDisconnectedWallet(false);
|
|
7707
7870
|
const isPhantom = ethProvider.isPhantom;
|
|
7871
|
+
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
7872
|
+
setStoredWalletState(walletType);
|
|
7708
7873
|
setWallet({
|
|
7709
|
-
type:
|
|
7874
|
+
type: walletType,
|
|
7710
7875
|
name: isPhantom ? "Phantom" : "MetaMask",
|
|
7711
7876
|
address: accounts[0],
|
|
7712
7877
|
icon: isPhantom ? "phantom" : "metamask"
|
|
@@ -8038,7 +8203,11 @@ function CoinbaseConnect({
|
|
|
8038
8203
|
onDisconnect,
|
|
8039
8204
|
skipToHoldings,
|
|
8040
8205
|
canGoBack = true,
|
|
8041
|
-
onExecutionsChange
|
|
8206
|
+
onExecutionsChange,
|
|
8207
|
+
defaultSourceChainType,
|
|
8208
|
+
defaultSourceChainId,
|
|
8209
|
+
defaultSourceTokenAddress,
|
|
8210
|
+
defaultSourceSymbol
|
|
8042
8211
|
}) {
|
|
8043
8212
|
const { colors: colors2, fonts, components } = useTheme();
|
|
8044
8213
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
@@ -8103,6 +8272,21 @@ function CoinbaseConnect({
|
|
|
8103
8272
|
params: defaultTokenParams,
|
|
8104
8273
|
publishableKey
|
|
8105
8274
|
});
|
|
8275
|
+
const defaultSourceCurrency = (0, import_react12.useMemo)(
|
|
8276
|
+
() => resolveDefaultSourceSymbol(supportedTokensData?.data, {
|
|
8277
|
+
defaultSourceChainType,
|
|
8278
|
+
defaultSourceChainId,
|
|
8279
|
+
defaultSourceTokenAddress,
|
|
8280
|
+
defaultSourceSymbol
|
|
8281
|
+
})?.toLowerCase() ?? null,
|
|
8282
|
+
[
|
|
8283
|
+
supportedTokensData,
|
|
8284
|
+
defaultSourceChainType,
|
|
8285
|
+
defaultSourceChainId,
|
|
8286
|
+
defaultSourceTokenAddress,
|
|
8287
|
+
defaultSourceSymbol
|
|
8288
|
+
]
|
|
8289
|
+
);
|
|
8106
8290
|
const sortedHoldings = (0, import_react12.useMemo)(() => {
|
|
8107
8291
|
const supported = [];
|
|
8108
8292
|
const unsupported = [];
|
|
@@ -8112,13 +8296,42 @@ function CoinbaseConnect({
|
|
|
8112
8296
|
if (isSupported) supported.push(account);
|
|
8113
8297
|
else unsupported.push(account);
|
|
8114
8298
|
});
|
|
8299
|
+
if (defaultSourceCurrency) {
|
|
8300
|
+
const defaultIndex = supported.findIndex(
|
|
8301
|
+
(account) => account.currency.toLowerCase() === defaultSourceCurrency
|
|
8302
|
+
);
|
|
8303
|
+
if (defaultIndex > 0) {
|
|
8304
|
+
const [defaultHolding] = supported.splice(defaultIndex, 1);
|
|
8305
|
+
supported.unshift(defaultHolding);
|
|
8306
|
+
}
|
|
8307
|
+
}
|
|
8115
8308
|
return [...supported, ...unsupported];
|
|
8116
|
-
}, [
|
|
8309
|
+
}, [
|
|
8310
|
+
holdings,
|
|
8311
|
+
supportedSymbols,
|
|
8312
|
+
exchangeSupportedCurrencies,
|
|
8313
|
+
defaultSourceCurrency
|
|
8314
|
+
]);
|
|
8117
8315
|
const selectedHoldingIsSupported = (0, import_react12.useMemo)(() => {
|
|
8118
8316
|
if (!selectedHolding) return false;
|
|
8119
8317
|
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
8120
8318
|
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
8121
8319
|
}, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
|
|
8320
|
+
(0, import_react12.useEffect)(() => {
|
|
8321
|
+
if (!defaultSourceCurrency || selectedHolding) return;
|
|
8322
|
+
const defaultHolding = sortedHoldings.find((account) => {
|
|
8323
|
+
const currencyLower = account.currency.toLowerCase();
|
|
8324
|
+
return currencyLower === defaultSourceCurrency && (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
8325
|
+
});
|
|
8326
|
+
if (!defaultHolding) return;
|
|
8327
|
+
setSelectedHolding(defaultHolding);
|
|
8328
|
+
}, [
|
|
8329
|
+
defaultSourceCurrency,
|
|
8330
|
+
selectedHolding,
|
|
8331
|
+
sortedHoldings,
|
|
8332
|
+
supportedSymbols,
|
|
8333
|
+
exchangeSupportedCurrencies
|
|
8334
|
+
]);
|
|
8122
8335
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
8123
8336
|
const {
|
|
8124
8337
|
executions: depositExecutions,
|
|
@@ -9897,7 +10110,7 @@ function useDefaultOnrampToken({
|
|
|
9897
10110
|
}
|
|
9898
10111
|
|
|
9899
10112
|
// src/components/deposits/DepositModal.tsx
|
|
9900
|
-
var
|
|
10113
|
+
var import_core30 = require("@unifold/core");
|
|
9901
10114
|
|
|
9902
10115
|
// src/hooks/use-allowed-country.ts
|
|
9903
10116
|
var import_react_query9 = require("@tanstack/react-query");
|
|
@@ -12340,7 +12553,7 @@ function TransferCryptoDoubleInput({
|
|
|
12340
12553
|
// src/components/deposits/WalletConnect.tsx
|
|
12341
12554
|
var React30 = __toESM(require("react"));
|
|
12342
12555
|
var import_lucide_react28 = require("lucide-react");
|
|
12343
|
-
var
|
|
12556
|
+
var import_core29 = require("@unifold/core");
|
|
12344
12557
|
|
|
12345
12558
|
// src/hooks/use-deposit-quote.ts
|
|
12346
12559
|
var import_react_query12 = require("@tanstack/react-query");
|
|
@@ -12397,6 +12610,68 @@ function useDepositQuote(params) {
|
|
|
12397
12610
|
});
|
|
12398
12611
|
}
|
|
12399
12612
|
|
|
12613
|
+
// src/hooks/use-external-wallets.ts
|
|
12614
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
12615
|
+
var import_core28 = require("@unifold/core");
|
|
12616
|
+
function useExternalWallets({
|
|
12617
|
+
publishableKey,
|
|
12618
|
+
enabled = true
|
|
12619
|
+
}) {
|
|
12620
|
+
const { data: wallets = [], isLoading } = (0, import_react_query13.useQuery)({
|
|
12621
|
+
queryKey: ["unifold", "external-wallets", publishableKey],
|
|
12622
|
+
queryFn: () => (0, import_core28.getExternalWallets)(publishableKey).then((res) => res.data),
|
|
12623
|
+
enabled: enabled && !!publishableKey,
|
|
12624
|
+
staleTime: 1e3 * 60 * 30,
|
|
12625
|
+
refetchOnMount: false,
|
|
12626
|
+
refetchOnWindowFocus: false
|
|
12627
|
+
});
|
|
12628
|
+
return { wallets, isLoading };
|
|
12629
|
+
}
|
|
12630
|
+
|
|
12631
|
+
// src/theme/walletBrandColors.ts
|
|
12632
|
+
var WALLET_BRAND_COLORS = {
|
|
12633
|
+
phantom: "#AB9FF2",
|
|
12634
|
+
metamask: "#F6851B",
|
|
12635
|
+
coinbase: "#0052FF",
|
|
12636
|
+
trust: "#3375BB",
|
|
12637
|
+
rainbow: "#5B6CFF",
|
|
12638
|
+
rabby: "#7084FF",
|
|
12639
|
+
okx: "#000000"
|
|
12640
|
+
};
|
|
12641
|
+
function normalizeWalletId(type) {
|
|
12642
|
+
return type.replace(/-(ethereum|solana)$/i, "").toLowerCase();
|
|
12643
|
+
}
|
|
12644
|
+
function getWalletBrandColor(type, mode = "dark") {
|
|
12645
|
+
if (!type) return void 0;
|
|
12646
|
+
const id = normalizeWalletId(type);
|
|
12647
|
+
const color = WALLET_BRAND_COLORS[id];
|
|
12648
|
+
if (!color) return void 0;
|
|
12649
|
+
if (id === "okx") return mode === "dark" ? "#FFFFFF" : "#111111";
|
|
12650
|
+
return color;
|
|
12651
|
+
}
|
|
12652
|
+
function getContrastingTextColor(hex) {
|
|
12653
|
+
const c = hex.replace("#", "");
|
|
12654
|
+
if (c.length !== 6) return "#FFFFFF";
|
|
12655
|
+
const r = parseInt(c.slice(0, 2), 16);
|
|
12656
|
+
const g = parseInt(c.slice(2, 4), 16);
|
|
12657
|
+
const b = parseInt(c.slice(4, 6), 16);
|
|
12658
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
12659
|
+
return luminance > 0.6 ? "#13111C" : "#FFFFFF";
|
|
12660
|
+
}
|
|
12661
|
+
|
|
12662
|
+
// src/components/deposits/browser-wallets/mobileDeepLinks.ts
|
|
12663
|
+
function isMobileDevice() {
|
|
12664
|
+
if (typeof navigator === "undefined") return false;
|
|
12665
|
+
return /android|iphone|ipad|ipod|mobile/i.test(navigator.userAgent);
|
|
12666
|
+
}
|
|
12667
|
+
function getMobilePlatform() {
|
|
12668
|
+
if (typeof navigator === "undefined") return null;
|
|
12669
|
+
const ua = navigator.userAgent;
|
|
12670
|
+
if (/iphone|ipad|ipod/i.test(ua)) return "ios";
|
|
12671
|
+
if (/android/i.test(ua)) return "android";
|
|
12672
|
+
return null;
|
|
12673
|
+
}
|
|
12674
|
+
|
|
12400
12675
|
// src/components/deposits/browser-wallets/SelectTokenView.tsx
|
|
12401
12676
|
var import_lucide_react25 = require("lucide-react");
|
|
12402
12677
|
|
|
@@ -13425,18 +13700,46 @@ var WALLET_ICONS3 = {
|
|
|
13425
13700
|
backpack: BackpackIcon,
|
|
13426
13701
|
glow: GlowIcon
|
|
13427
13702
|
};
|
|
13428
|
-
var
|
|
13429
|
-
{ id: "phantom", name: "Phantom", networks: ["ethereum", "solana"], installUrl: "https://phantom.app/" },
|
|
13430
|
-
{ id: "coinbase", name: "Coinbase Wallet", networks: ["ethereum", "solana"], installUrl: "https://www.coinbase.com/wallet" },
|
|
13431
|
-
{ id: "trust", name: "Trust Wallet", networks: ["ethereum", "solana"], installUrl: "https://trustwallet.com/" },
|
|
13432
|
-
{ id: "metamask", name: "MetaMask", networks: ["ethereum"], installUrl: "https://metamask.io/download/" },
|
|
13433
|
-
{ id: "rainbow", name: "Rainbow", networks: ["ethereum"], installUrl: "https://rainbow.me/" },
|
|
13434
|
-
{ id: "rabby", name: "Rabby", networks: ["ethereum"], installUrl: "https://
|
|
13435
|
-
{ id: "okx", name: "OKX Wallet", networks: ["ethereum"], installUrl: "https://www.okx.com/web3" }
|
|
13436
|
-
{ id: "solflare", name: "Solflare", networks: ["solana"], installUrl: "https://solflare.com/" },
|
|
13437
|
-
{ id: "backpack", name: "Backpack", networks: ["solana"], installUrl: "https://backpack.app/" },
|
|
13438
|
-
{ id: "glow", name: "Glow", networks: ["solana"], installUrl: "https://glow.app/" }
|
|
13703
|
+
var FALLBACK_WALLET_DEFINITIONS = [
|
|
13704
|
+
{ id: "phantom", name: "Phantom", networks: ["ethereum", "solana"], installUrl: "https://phantom.app/", supportsMobileBrowse: true },
|
|
13705
|
+
{ id: "coinbase", name: "Coinbase Wallet", networks: ["ethereum", "solana"], installUrl: "https://www.coinbase.com/wallet", supportsMobileBrowse: true },
|
|
13706
|
+
{ id: "trust", name: "Trust Wallet", networks: ["ethereum", "solana"], installUrl: "https://trustwallet.com/", supportsMobileBrowse: true },
|
|
13707
|
+
{ id: "metamask", name: "MetaMask", networks: ["ethereum"], installUrl: "https://metamask.io/download/", supportsMobileBrowse: true },
|
|
13708
|
+
{ id: "rainbow", name: "Rainbow", networks: ["ethereum"], installUrl: "https://rainbow.me/", supportsMobileBrowse: true },
|
|
13709
|
+
{ id: "rabby", name: "Rabby", networks: ["ethereum"], installUrl: "https://apps.apple.com/app/rabby-wallet/id6450663781", supportsMobileBrowse: true },
|
|
13710
|
+
{ id: "okx", name: "OKX Wallet", networks: ["ethereum"], installUrl: "https://www.okx.com/web3", supportsMobileBrowse: true, mobileBrowsePlatforms: ["ios"] }
|
|
13439
13711
|
];
|
|
13712
|
+
function getMobileInstallUrl(walletId, defaultUrl) {
|
|
13713
|
+
if (!isMobileDevice()) return defaultUrl;
|
|
13714
|
+
const ua = typeof navigator !== "undefined" ? navigator.userAgent : "";
|
|
13715
|
+
const isIOS = /iPhone|iPad|iPod/i.test(ua);
|
|
13716
|
+
const stores = {
|
|
13717
|
+
rabby: {
|
|
13718
|
+
ios: "https://apps.apple.com/app/rabby-wallet/id6450663781",
|
|
13719
|
+
android: "https://play.google.com/store/apps/details?id=com.debank.rabbymobile"
|
|
13720
|
+
},
|
|
13721
|
+
glow: {
|
|
13722
|
+
ios: "https://apps.apple.com/us/app/glow-solana-wallet/id1599584512",
|
|
13723
|
+
android: "https://play.google.com/store/apps/details?id=com.luma.wallet.prod"
|
|
13724
|
+
}
|
|
13725
|
+
};
|
|
13726
|
+
const entry = stores[walletId];
|
|
13727
|
+
if (!entry) return defaultUrl;
|
|
13728
|
+
return isIOS ? entry.ios : entry.android;
|
|
13729
|
+
}
|
|
13730
|
+
function normalizeTokenAddress(address) {
|
|
13731
|
+
const normalized = (address ?? "").toLowerCase();
|
|
13732
|
+
if (normalized === "" || normalized === "native" || normalized === "0x0000000000000000000000000000000000000000") {
|
|
13733
|
+
return "native";
|
|
13734
|
+
}
|
|
13735
|
+
return normalized;
|
|
13736
|
+
}
|
|
13737
|
+
function balancesRepresentSameToken(a, b) {
|
|
13738
|
+
const tokenA = getTokenFromBalance(a);
|
|
13739
|
+
const tokenB = getTokenFromBalance(b);
|
|
13740
|
+
if (!tokenA || !tokenB) return false;
|
|
13741
|
+
return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
|
|
13742
|
+
}
|
|
13440
13743
|
function getSolanaProviders() {
|
|
13441
13744
|
if (typeof window === "undefined") return {};
|
|
13442
13745
|
const win = window;
|
|
@@ -13459,7 +13762,7 @@ function getLegacyEvmProviders() {
|
|
|
13459
13762
|
okxEthereum: win.okxwallet
|
|
13460
13763
|
};
|
|
13461
13764
|
}
|
|
13462
|
-
function detectAvailableWallets(filterChainType) {
|
|
13765
|
+
function detectAvailableWallets(definitions, filterChainType) {
|
|
13463
13766
|
const solProviders = getSolanaProviders();
|
|
13464
13767
|
const legacyEvm = getLegacyEvmProviders();
|
|
13465
13768
|
const eip6963List = getEip6963Providers();
|
|
@@ -13485,7 +13788,7 @@ function detectAvailableWallets(filterChainType) {
|
|
|
13485
13788
|
return false;
|
|
13486
13789
|
}
|
|
13487
13790
|
});
|
|
13488
|
-
return
|
|
13791
|
+
return definitions.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
13489
13792
|
let isInstalled = false;
|
|
13490
13793
|
const detectedNetworks = [];
|
|
13491
13794
|
switch (wallet.id) {
|
|
@@ -13579,13 +13882,17 @@ function WalletConnect({
|
|
|
13579
13882
|
checkoutRemainingBaseUnits,
|
|
13580
13883
|
stablecoinParity = false,
|
|
13581
13884
|
productType,
|
|
13885
|
+
defaultSourceChainType,
|
|
13886
|
+
defaultSourceChainId,
|
|
13887
|
+
defaultSourceTokenAddress,
|
|
13888
|
+
defaultSourceSymbol,
|
|
13582
13889
|
onBack: parentOnBack,
|
|
13583
13890
|
onClose,
|
|
13584
13891
|
canGoBack = true,
|
|
13585
13892
|
depositWalletsLoading = false,
|
|
13586
13893
|
onExecutionsChange
|
|
13587
13894
|
}) {
|
|
13588
|
-
const { colors: colors2, fonts, components } = useTheme();
|
|
13895
|
+
const { colors: colors2, fonts, components, mode } = useTheme();
|
|
13589
13896
|
const walletProvidedAtMount = React30.useRef(!!initialWalletInfo && !!initialDepositWallet);
|
|
13590
13897
|
const [activeWalletInfo, setActiveWalletInfo] = React30.useState(initialWalletInfo ?? null);
|
|
13591
13898
|
const [activeDepositWallet, setActiveDepositWallet] = React30.useState(initialDepositWallet ?? null);
|
|
@@ -13609,7 +13916,37 @@ function WalletConnect({
|
|
|
13609
13916
|
setEip6963ProviderCount(providers.length);
|
|
13610
13917
|
});
|
|
13611
13918
|
}, []);
|
|
13612
|
-
const
|
|
13919
|
+
const { wallets: backendWallets } = useExternalWallets({ publishableKey });
|
|
13920
|
+
const walletDefinitions = React30.useMemo(
|
|
13921
|
+
() => backendWallets.length > 0 ? backendWallets.map((w) => ({
|
|
13922
|
+
id: w.id,
|
|
13923
|
+
name: w.name,
|
|
13924
|
+
networks: w.chain_types,
|
|
13925
|
+
installUrl: w.install_url,
|
|
13926
|
+
supportsMobileBrowse: w.supports_mobile_browse,
|
|
13927
|
+
mobileBrowsePlatforms: w.mobile_browse_platforms ?? null
|
|
13928
|
+
})) : FALLBACK_WALLET_DEFINITIONS,
|
|
13929
|
+
[backendWallets]
|
|
13930
|
+
);
|
|
13931
|
+
const availableWallets = React30.useMemo(
|
|
13932
|
+
() => detectAvailableWallets(walletDefinitions),
|
|
13933
|
+
[walletDefinitions, eip6963ProviderCount]
|
|
13934
|
+
);
|
|
13935
|
+
const [isMobile, setIsMobile] = React30.useState(false);
|
|
13936
|
+
React30.useEffect(() => {
|
|
13937
|
+
setIsMobile(isMobileDevice());
|
|
13938
|
+
}, []);
|
|
13939
|
+
const mobileDepositAddresses = React30.useMemo(
|
|
13940
|
+
() => (depositWallets ?? []).map((w) => ({ chain_type: w.chain_type, address: w.address })),
|
|
13941
|
+
[depositWallets]
|
|
13942
|
+
);
|
|
13943
|
+
const mobileDepositWalletIds = React30.useMemo(
|
|
13944
|
+
() => (depositWallets ?? []).filter((w) => w.chain_type === "ethereum" || w.chain_type === "solana").map((w) => w.id),
|
|
13945
|
+
[depositWallets]
|
|
13946
|
+
);
|
|
13947
|
+
const [mobileRedirect, setMobileRedirect] = React30.useState(null);
|
|
13948
|
+
const [pendingMobileWallet, setPendingMobileWallet] = React30.useState(null);
|
|
13949
|
+
const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React30.useState(false);
|
|
13613
13950
|
React30.useEffect(() => {
|
|
13614
13951
|
if (!standalone || autoResolved || detectingWallet) return;
|
|
13615
13952
|
if (!detectedWallet) {
|
|
@@ -13668,9 +14005,36 @@ function WalletConnect({
|
|
|
13668
14005
|
transform: isTransitioning ? "translateY(4px)" : "translateY(0)",
|
|
13669
14006
|
transition: "opacity 150ms ease, transform 150ms ease"
|
|
13670
14007
|
};
|
|
13671
|
-
const
|
|
14008
|
+
const openMobileWalletBrowse = async (wallet, depositAddresses) => {
|
|
14009
|
+
try {
|
|
14010
|
+
const res = await (0, import_core29.getWalletMobileDeepLink)(
|
|
14011
|
+
wallet.id,
|
|
14012
|
+
depositAddresses,
|
|
14013
|
+
publishableKey
|
|
14014
|
+
);
|
|
14015
|
+
if (res.deeplink) {
|
|
14016
|
+
setMobileRedirect({ walletId: wallet.id, walletName: wallet.name, deeplink: res.deeplink });
|
|
14017
|
+
setAwaitingMobileDeposit(true);
|
|
14018
|
+
transitionTo("mobile_redirect");
|
|
14019
|
+
window.location.href = res.deeplink;
|
|
14020
|
+
return true;
|
|
14021
|
+
}
|
|
14022
|
+
} catch {
|
|
14023
|
+
}
|
|
14024
|
+
return false;
|
|
14025
|
+
};
|
|
14026
|
+
const handleWalletClick = async (wallet) => {
|
|
13672
14027
|
if (!wallet.isInstalled) {
|
|
13673
|
-
|
|
14028
|
+
const platform = getMobilePlatform();
|
|
14029
|
+
const platformAllowed = !wallet.mobileBrowsePlatforms || wallet.mobileBrowsePlatforms.includes(platform ?? "");
|
|
14030
|
+
if (isMobileDevice() && wallet.supportsMobileBrowse !== false && platformAllowed) {
|
|
14031
|
+
if (mobileDepositAddresses.length === 0) {
|
|
14032
|
+
setPendingMobileWallet(wallet);
|
|
14033
|
+
return;
|
|
14034
|
+
}
|
|
14035
|
+
if (await openMobileWalletBrowse(wallet, mobileDepositAddresses)) return;
|
|
14036
|
+
}
|
|
14037
|
+
window.open(getMobileInstallUrl(wallet.id, wallet.installUrl), "_blank", "noopener,noreferrer");
|
|
13674
14038
|
return;
|
|
13675
14039
|
}
|
|
13676
14040
|
setSelectedWalletDef(wallet);
|
|
@@ -13686,6 +14050,27 @@ function WalletConnect({
|
|
|
13686
14050
|
if (!selectedWalletDef) return;
|
|
13687
14051
|
handleConnectWallet(selectedWalletDef, network);
|
|
13688
14052
|
};
|
|
14053
|
+
React30.useEffect(() => {
|
|
14054
|
+
if (!pendingMobileWallet) return;
|
|
14055
|
+
if (mobileDepositAddresses.length > 0) {
|
|
14056
|
+
const wallet = pendingMobileWallet;
|
|
14057
|
+
setPendingMobileWallet(null);
|
|
14058
|
+
void (async () => {
|
|
14059
|
+
if (!await openMobileWalletBrowse(wallet, mobileDepositAddresses)) {
|
|
14060
|
+
window.open(getMobileInstallUrl(wallet.id, wallet.installUrl), "_blank", "noopener,noreferrer");
|
|
14061
|
+
}
|
|
14062
|
+
})();
|
|
14063
|
+
return;
|
|
14064
|
+
}
|
|
14065
|
+
const timeout = setTimeout(() => {
|
|
14066
|
+
setPendingMobileWallet((current) => {
|
|
14067
|
+
if (!current) return null;
|
|
14068
|
+
window.open(getMobileInstallUrl(current.id, current.installUrl), "_blank", "noopener,noreferrer");
|
|
14069
|
+
return null;
|
|
14070
|
+
});
|
|
14071
|
+
}, 8e3);
|
|
14072
|
+
return () => clearTimeout(timeout);
|
|
14073
|
+
}, [pendingMobileWallet, mobileDepositAddresses]);
|
|
13689
14074
|
const handleConnectWallet = async (wallet, network) => {
|
|
13690
14075
|
setConnectingNetwork(network);
|
|
13691
14076
|
transitionTo("connecting");
|
|
@@ -13739,6 +14124,7 @@ function WalletConnect({
|
|
|
13739
14124
|
metamask: "metamask"
|
|
13740
14125
|
};
|
|
13741
14126
|
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
14127
|
+
setStoredWalletState(walletType);
|
|
13742
14128
|
connectedInfo = { type: walletType, name: wallet.name, address: accounts[0], icon: wallet.id };
|
|
13743
14129
|
} else {
|
|
13744
14130
|
const solProviders = getSolanaProviders();
|
|
@@ -13767,6 +14153,7 @@ function WalletConnect({
|
|
|
13767
14153
|
const response = await provider.connect();
|
|
13768
14154
|
setUserDisconnectedWallet(false);
|
|
13769
14155
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
14156
|
+
setStoredWalletState(walletType);
|
|
13770
14157
|
connectedInfo = { type: walletType, name: wallet.name, address: response.publicKey.toString(), icon: wallet.id };
|
|
13771
14158
|
}
|
|
13772
14159
|
const walletChainType = network === "solana" ? "solana" : "ethereum";
|
|
@@ -13828,14 +14215,32 @@ function WalletConnect({
|
|
|
13828
14215
|
userId,
|
|
13829
14216
|
publishableKey,
|
|
13830
14217
|
clientSecret,
|
|
14218
|
+
// In-tab flow: poll the single connected deposit wallet.
|
|
13831
14219
|
depositWalletId: activeDepositWallet?.id ?? "",
|
|
13832
|
-
|
|
14220
|
+
// Mobile redirect flow: the deposit chain isn't known up front, so /poll every
|
|
14221
|
+
// chain's deposit wallet. Detection still happens via the single /query by
|
|
14222
|
+
// external_user_id, which already spans all chains.
|
|
14223
|
+
depositWalletIds: awaitingMobileDeposit ? mobileDepositWalletIds : void 0,
|
|
14224
|
+
enabled: hasSignedTransaction && !!activeDepositWallet || awaitingMobileDeposit,
|
|
13833
14225
|
onDepositSuccess,
|
|
13834
14226
|
onDepositError
|
|
13835
14227
|
});
|
|
13836
14228
|
React30.useEffect(() => {
|
|
13837
14229
|
onExecutionsChange?.(depositExecutions);
|
|
13838
14230
|
}, [depositExecutions, onExecutionsChange]);
|
|
14231
|
+
const latestDepositExecution = React30.useMemo(() => {
|
|
14232
|
+
if (depositExecutions.length === 0) return null;
|
|
14233
|
+
return [...depositExecutions].sort((a, b) => {
|
|
14234
|
+
const ta = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
14235
|
+
const tb = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
14236
|
+
return tb - ta;
|
|
14237
|
+
})[0];
|
|
14238
|
+
}, [depositExecutions]);
|
|
14239
|
+
React30.useEffect(() => {
|
|
14240
|
+
if (awaitingMobileDeposit && latestDepositExecution && (viewRef.current === "mobile_redirect" || viewRef.current === "connecting")) {
|
|
14241
|
+
transitionTo("mobile_deposit_status");
|
|
14242
|
+
}
|
|
14243
|
+
}, [awaitingMobileDeposit, latestDepositExecution, transitionTo]);
|
|
13839
14244
|
React30.useEffect(() => {
|
|
13840
14245
|
if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
|
|
13841
14246
|
const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
|
|
@@ -13854,7 +14259,7 @@ function WalletConnect({
|
|
|
13854
14259
|
const token = getTokenFromBalance(selectedBalance);
|
|
13855
14260
|
if (!token) return;
|
|
13856
14261
|
const options = { destination_token_address: activeDepositWallet.destination_token_address, destination_chain_id: activeDepositWallet.destination_chain_id, destination_chain_type: activeDepositWallet.destination_chain_type, ...productType ? { product_type: productType } : {} };
|
|
13857
|
-
const response = await (0,
|
|
14262
|
+
const response = await (0, import_core29.getSupportedDepositTokens)(publishableKey, options);
|
|
13858
14263
|
if (cancelled) return;
|
|
13859
14264
|
const supportedToken = response.data.find((t12) => t12.symbol.toLowerCase() === token.symbol.toLowerCase());
|
|
13860
14265
|
if (supportedToken) {
|
|
@@ -13878,21 +14283,36 @@ function WalletConnect({
|
|
|
13878
14283
|
setIsLoading(true);
|
|
13879
14284
|
setError(null);
|
|
13880
14285
|
const sct = activeDepositWallet.chain_type === "algorand" || activeDepositWallet.chain_type === "xrpl" ? "ethereum" : activeDepositWallet.chain_type;
|
|
13881
|
-
(0,
|
|
14286
|
+
(0, import_core29.getAddressBalances)(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
13882
14287
|
if (cancelled) return;
|
|
13883
14288
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
13884
|
-
const
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
14289
|
+
const defaultSource = {
|
|
14290
|
+
defaultSourceChainType,
|
|
14291
|
+
defaultSourceChainId,
|
|
14292
|
+
defaultSourceTokenAddress,
|
|
14293
|
+
defaultSourceSymbol
|
|
14294
|
+
};
|
|
14295
|
+
const sorted = [...nonZero].sort(
|
|
14296
|
+
(a, b) => compareBalancesWithDefaultSource(a, b, defaultSource)
|
|
14297
|
+
);
|
|
13891
14298
|
setBalances(sorted);
|
|
13892
14299
|
const totalUsd = nonZero.reduce((sum, b) => b.amount_usd ? sum + parseFloat(b.amount_usd) : sum, 0);
|
|
13893
14300
|
if (totalUsd > 0) setTotalBalanceUsd(totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
13894
14301
|
const eligible = sorted.filter(isBalanceEligible);
|
|
13895
|
-
|
|
14302
|
+
const defaultBalance = sorted.find(
|
|
14303
|
+
(balance) => isDefaultSourceBalance(balance, defaultSource)
|
|
14304
|
+
);
|
|
14305
|
+
setSelectedBalance((current) => {
|
|
14306
|
+
if (current) {
|
|
14307
|
+
const currentInNewBalances = sorted.find(
|
|
14308
|
+
(balance) => balancesRepresentSameToken(balance, current)
|
|
14309
|
+
);
|
|
14310
|
+
if (currentInNewBalances) return currentInNewBalances;
|
|
14311
|
+
}
|
|
14312
|
+
if (defaultBalance) return defaultBalance;
|
|
14313
|
+
if (eligible.length === 1) return eligible[0];
|
|
14314
|
+
return null;
|
|
14315
|
+
});
|
|
13896
14316
|
}).catch((err) => {
|
|
13897
14317
|
if (!cancelled) {
|
|
13898
14318
|
console.error("[WalletConnect] Error fetching balances:", err);
|
|
@@ -13904,7 +14324,15 @@ function WalletConnect({
|
|
|
13904
14324
|
return () => {
|
|
13905
14325
|
cancelled = true;
|
|
13906
14326
|
};
|
|
13907
|
-
}, [
|
|
14327
|
+
}, [
|
|
14328
|
+
activeWalletInfo?.address,
|
|
14329
|
+
activeDepositWallet?.chain_type,
|
|
14330
|
+
publishableKey,
|
|
14331
|
+
defaultSourceChainType,
|
|
14332
|
+
defaultSourceChainId,
|
|
14333
|
+
defaultSourceTokenAddress,
|
|
14334
|
+
defaultSourceSymbol
|
|
14335
|
+
]);
|
|
13908
14336
|
const usdToTokenRate = React30.useMemo(() => {
|
|
13909
14337
|
if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
|
|
13910
14338
|
const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
|
|
@@ -13943,6 +14371,16 @@ function WalletConnect({
|
|
|
13943
14371
|
setSelectedWalletDef(null);
|
|
13944
14372
|
setConnectingNetwork(null);
|
|
13945
14373
|
break;
|
|
14374
|
+
case "mobile_redirect":
|
|
14375
|
+
transitionTo("select_wallet");
|
|
14376
|
+
setMobileRedirect(null);
|
|
14377
|
+
setAwaitingMobileDeposit(false);
|
|
14378
|
+
break;
|
|
14379
|
+
case "mobile_deposit_status":
|
|
14380
|
+
transitionTo("select_wallet");
|
|
14381
|
+
setMobileRedirect(null);
|
|
14382
|
+
setAwaitingMobileDeposit(false);
|
|
14383
|
+
break;
|
|
13946
14384
|
case "select_token":
|
|
13947
14385
|
if (walletProvidedAtMount.current) parentOnBack?.();
|
|
13948
14386
|
else transitionTo("select_wallet");
|
|
@@ -14069,7 +14507,7 @@ function WalletConnect({
|
|
|
14069
14507
|
if (!provider.publicKey) await provider.connect();
|
|
14070
14508
|
const isNative = token.token_address === "native" || token.token_address === "So11111111111111111111111111111111111111112" || token.token_address === "";
|
|
14071
14509
|
const smallestUnit = isNative ? decimalToSmallestUnit(amountStr, 9) : decimalToSmallestUnit(amountStr, token.decimals);
|
|
14072
|
-
const buildResp = await (0,
|
|
14510
|
+
const buildResp = await (0, import_core29.buildSolanaTransaction)({ chain_id: "mainnet", token_address: token.token_address === "" ? "native" : token.token_address, source_address: walletInfo.address, destination_address: recipientAddress, amount: smallestUnit }, publishableKey);
|
|
14073
14511
|
const { VersionedTransaction } = await import(
|
|
14074
14512
|
/* @vite-ignore */
|
|
14075
14513
|
"@solana/web3.js"
|
|
@@ -14082,7 +14520,7 @@ function WalletConnect({
|
|
|
14082
14520
|
const ser = signed.serialize();
|
|
14083
14521
|
let bs = "";
|
|
14084
14522
|
for (let i = 0; i < ser.length; i++) bs += String.fromCharCode(ser[i]);
|
|
14085
|
-
const resp = await (0,
|
|
14523
|
+
const resp = await (0, import_core29.sendSolanaTransaction)({ chain_id: "mainnet", signed_transaction: btoa(bs) }, publishableKey);
|
|
14086
14524
|
return resp.signature;
|
|
14087
14525
|
};
|
|
14088
14526
|
const handleConfirm = async () => {
|
|
@@ -14128,33 +14566,40 @@ function WalletConnect({
|
|
|
14128
14566
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14129
14567
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DepositHeader, { title: "Connect Wallet", showBack: canGoBack, onBack: handleBack, onClose }),
|
|
14130
14568
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-pb-4", children: [
|
|
14131
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "Select a wallet to connect" }),
|
|
14132
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) =>
|
|
14133
|
-
"
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14569
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "uf-text-sm uf-text-center uf-pb-4", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: isMobile ? "Open this page in your wallet's app to connect" : "Select a wallet to connect" }),
|
|
14570
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-space-y-2", style: { maxHeight: 330, overflowY: "auto" }, children: availableWallets.map((wallet) => {
|
|
14571
|
+
const walletPlatformAllowed = !wallet.mobileBrowsePlatforms || wallet.mobileBrowsePlatforms.includes(getMobilePlatform() ?? "");
|
|
14572
|
+
const showOpenInApp = isMobile && !wallet.isInstalled && wallet.supportsMobileBrowse !== false && walletPlatformAllowed;
|
|
14573
|
+
const isPending = pendingMobileWallet?.id === wallet.id;
|
|
14574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
14575
|
+
"button",
|
|
14576
|
+
{
|
|
14577
|
+
onClick: () => void handleWalletClick(wallet),
|
|
14578
|
+
disabled: isWalletConnecting || !!pendingMobileWallet,
|
|
14579
|
+
className: "uf-w-full uf-transition-colors uf-p-3 uf-flex uf-items-center uf-justify-between hover:uf-opacity-90 disabled:uf-opacity-50",
|
|
14580
|
+
style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
|
|
14581
|
+
children: [
|
|
14582
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
14583
|
+
WALLET_ICONS3[wallet.id] ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(WalletIconWithNetwork, { WalletIcon: WALLET_ICONS3[wallet.id], networks: wallet.networks, size: 40, className: "uf-rounded-lg" }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-w-10 uf-h-10 uf-rounded-lg uf-bg-gray-500" }),
|
|
14584
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-text-sm uf-font-medium", style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: wallet.name })
|
|
14585
|
+
] }),
|
|
14586
|
+
isPending ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react28.Loader2, { className: "uf-w-4 uf-h-4 uf-animate-spin", style: { color: colors2.primary } }) : wallet.isInstalled ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "uf-text-xs uf-px-2 uf-py-1 uf-rounded-full", style: { backgroundColor: colors2.primary + "20", color: colors2.primary, fontFamily: fonts.medium }, children: "Detected" }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1", children: [
|
|
14587
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: showOpenInApp ? "Open" : "Install" }),
|
|
14588
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react28.ExternalLink, { className: "uf-w-3 uf-h-3", style: { color: colors2.foregroundMuted } })
|
|
14589
|
+
] })
|
|
14590
|
+
]
|
|
14591
|
+
},
|
|
14592
|
+
wallet.id
|
|
14593
|
+
);
|
|
14594
|
+
}) }),
|
|
14152
14595
|
walletError && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-text-center uf-text-sm uf-mt-4 uf-px-4", style: { color: "#ef4444" }, children: walletError })
|
|
14153
14596
|
] })
|
|
14154
14597
|
] });
|
|
14155
14598
|
}
|
|
14599
|
+
const preConnectAccent = selectedWalletDef ? getWalletBrandColor(selectedWalletDef.id, mode) : void 0;
|
|
14600
|
+
const preConnectFg = preConnectAccent ? getContrastingTextColor(preConnectAccent) : void 0;
|
|
14156
14601
|
if (view === "select_network" && selectedWalletDef) {
|
|
14157
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14158
14603
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DepositHeader, { title: "Select Network", showBack: true, onBack: handleBack, onClose }),
|
|
14159
14604
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-pb-4", children: [
|
|
14160
14605
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pb-4", children: [
|
|
@@ -14184,10 +14629,10 @@ function WalletConnect({
|
|
|
14184
14629
|
)) }),
|
|
14185
14630
|
walletError && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-text-center uf-text-sm uf-mt-4 uf-px-4", style: { color: "#ef4444" }, children: walletError })
|
|
14186
14631
|
] })
|
|
14187
|
-
] });
|
|
14632
|
+
] }) });
|
|
14188
14633
|
}
|
|
14189
14634
|
if (view === "connecting") {
|
|
14190
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14191
14636
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DepositHeader, { title: "Connecting...", showBack: true, onBack: handleBack, onClose }),
|
|
14192
14637
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16", children: [
|
|
14193
14638
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react28.Loader2, { className: "uf-w-12 uf-h-12 uf-animate-spin uf-mb-4", style: { color: colors2.primary } }),
|
|
@@ -14198,47 +14643,155 @@ function WalletConnect({
|
|
|
14198
14643
|
] }),
|
|
14199
14644
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-text-sm uf-mt-2", style: { color: colors2.foregroundMuted }, children: "Please approve the connection in your wallet" })
|
|
14200
14645
|
] })
|
|
14201
|
-
] });
|
|
14202
|
-
}
|
|
14203
|
-
if (!hasWallet) return null;
|
|
14204
|
-
if (view === "select_token") {
|
|
14205
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SelectTokenView, { walletInfo, projectName, assetCdnUrl, balances, isLoading, error, selectedBalance, totalBalanceUsd, onTokenSelect: handleTokenSelect, onContinue: handleContinueToAmount, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14206
|
-
}), onDisconnectWallet: onWalletDisconnect ? () => void handleDisconnect() : void 0, isDisconnectingWallet, checkoutAmountUsd, checkoutReceivedUsd }) });
|
|
14207
|
-
}
|
|
14208
|
-
if (view === "enter_amount" && selectedToken && selectedBalance) {
|
|
14209
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(EnterAmountView, { walletInfo, selectedBalance, selectedToken, amountUsd, formattedTokenAmount, tokenChainDetails, inputUsdNum, maxUsdAmount, isValidAmount, error, onAmountChange: setAmountUsd, onMaxClick: handleMaxClick, onReview: handleReview, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14210
|
-
}), quickSelectMode: amountQuickSelect, checkoutAmountUsd, checkoutReceivedUsd }) });
|
|
14211
|
-
}
|
|
14212
|
-
if (view === "review" && selectedToken) {
|
|
14213
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ReviewView, { walletInfo, recipientAddress, assetCdnUrl, selectedToken, amountUsd, formattedTokenAmount, tokenChainDetails, loadingTokenDetails, showTransactionDetails, isConfirming, error, onToggleDetails: () => setShowTransactionDetails(!showTransactionDetails), onConfirm: handleConfirm, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14214
|
-
}) }) });
|
|
14215
|
-
}
|
|
14216
|
-
if (view === "confirming") {
|
|
14217
|
-
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ConfirmingView, { isConfirming, onClose: onClose ?? (() => {
|
|
14218
|
-
}), executions: depositExecutions, isPolling, onNewDeposit, onDone, paymentIntentStatus, amountReceivedUsd: checkoutReceivedUsd, amountReceivedUsdAtSubmission: receivedUsdAtSubmission }) });
|
|
14646
|
+
] }) });
|
|
14219
14647
|
}
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14648
|
+
if (view === "mobile_redirect" && mobileRedirect) {
|
|
14649
|
+
const Icon2 = WALLET_ICONS3[mobileRedirect.walletId];
|
|
14650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14651
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DepositHeader, { title: mobileRedirect.walletName, showBack: true, onBack: handleBack, onClose }),
|
|
14652
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-px-6 uf-py-10", children: [
|
|
14653
|
+
Icon2 ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Icon2, { size: 64, className: "uf-rounded-2xl uf-mb-5" }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-2xl uf-bg-gray-500 uf-mb-5" }),
|
|
14654
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
14655
|
+
"div",
|
|
14656
|
+
{
|
|
14657
|
+
className: "uf-text-base uf-font-medium uf-text-center uf-mb-1",
|
|
14658
|
+
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
14659
|
+
children: [
|
|
14660
|
+
"Continue in ",
|
|
14661
|
+
mobileRedirect.walletName
|
|
14662
|
+
]
|
|
14663
|
+
}
|
|
14664
|
+
),
|
|
14665
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
14666
|
+
"div",
|
|
14667
|
+
{
|
|
14668
|
+
className: "uf-text-sm uf-text-center uf-mb-6",
|
|
14669
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
14670
|
+
children: [
|
|
14671
|
+
"Complete your deposit in the ",
|
|
14672
|
+
mobileRedirect.walletName,
|
|
14673
|
+
" app"
|
|
14674
|
+
]
|
|
14675
|
+
}
|
|
14676
|
+
),
|
|
14677
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
14678
|
+
"button",
|
|
14679
|
+
{
|
|
14680
|
+
type: "button",
|
|
14681
|
+
onClick: () => {
|
|
14682
|
+
window.location.href = mobileRedirect.deeplink;
|
|
14683
|
+
},
|
|
14684
|
+
className: "uf-w-full uf-transition-colors uf-p-3.5 uf-flex uf-items-center uf-justify-center uf-gap-2 hover:uf-opacity-90",
|
|
14685
|
+
style: {
|
|
14686
|
+
backgroundColor: components.card.backgroundColor,
|
|
14687
|
+
borderRadius: components.card.borderRadius,
|
|
14688
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
|
|
14689
|
+
color: components.card.titleColor,
|
|
14690
|
+
fontFamily: fonts.medium
|
|
14691
|
+
},
|
|
14692
|
+
children: [
|
|
14693
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react28.ExternalLink, { className: "uf-w-4 uf-h-4", style: { color: components.card.iconColor } }),
|
|
14694
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "uf-text-sm uf-font-medium", children: [
|
|
14695
|
+
"Open in ",
|
|
14696
|
+
mobileRedirect.walletName
|
|
14697
|
+
] })
|
|
14698
|
+
]
|
|
14699
|
+
}
|
|
14700
|
+
),
|
|
14701
|
+
awaitingMobileDeposit && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-center uf-gap-2 uf-mt-6", children: [
|
|
14702
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
14703
|
+
import_lucide_react28.Loader2,
|
|
14704
|
+
{
|
|
14705
|
+
className: "uf-w-4 uf-h-4 uf-animate-spin",
|
|
14706
|
+
style: { color: colors2.foregroundMuted }
|
|
14707
|
+
}
|
|
14708
|
+
),
|
|
14709
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
14710
|
+
"span",
|
|
14711
|
+
{
|
|
14712
|
+
className: "uf-text-sm",
|
|
14713
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
14714
|
+
children: "Checking for deposit..."
|
|
14715
|
+
}
|
|
14716
|
+
)
|
|
14717
|
+
] })
|
|
14718
|
+
] })
|
|
14719
|
+
] }) });
|
|
14720
|
+
}
|
|
14721
|
+
if (view === "mobile_deposit_status" && latestDepositExecution) {
|
|
14722
|
+
const isComplete = latestDepositExecution.status === import_core29.ExecutionStatus.SUCCEEDED;
|
|
14723
|
+
const isFailed = latestDepositExecution.status === import_core29.ExecutionStatus.FAILED;
|
|
14724
|
+
const title = isComplete ? "Payment Complete" : isFailed ? "Payment Failed" : "Payment Processing";
|
|
14725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14726
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
14727
|
+
DepositHeader,
|
|
14728
|
+
{
|
|
14729
|
+
title,
|
|
14730
|
+
showBack: false,
|
|
14731
|
+
onClose: isComplete && onDone ? onDone : onClose
|
|
14732
|
+
}
|
|
14733
|
+
),
|
|
14734
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DepositDetailContent, { execution: latestDepositExecution }),
|
|
14735
|
+
isComplete && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-flex uf-gap-2 uf-px-2 uf-pt-4 uf-pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
14736
|
+
"button",
|
|
14737
|
+
{
|
|
14738
|
+
type: "button",
|
|
14739
|
+
onClick: onDone ? onDone : onNewDeposit ? onNewDeposit : onClose ?? (() => {
|
|
14740
|
+
}),
|
|
14741
|
+
className: "uf-flex-1 uf-py-4 uf-text-sm uf-font-medium uf-transition-opacity hover:uf-opacity-80",
|
|
14742
|
+
style: {
|
|
14743
|
+
backgroundColor: colors2.primary,
|
|
14744
|
+
color: colors2.primaryForeground,
|
|
14745
|
+
fontFamily: fonts.medium,
|
|
14746
|
+
borderRadius: components.button.borderRadius,
|
|
14747
|
+
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
14748
|
+
},
|
|
14749
|
+
children: "Done"
|
|
14750
|
+
}
|
|
14751
|
+
) })
|
|
14752
|
+
] }) });
|
|
14753
|
+
}
|
|
14754
|
+
if (!hasWallet) return null;
|
|
14755
|
+
const walletAccent = getWalletBrandColor(walletInfo.type, mode);
|
|
14756
|
+
const walletAccentForeground = walletAccent ? getContrastingTextColor(walletAccent) : void 0;
|
|
14757
|
+
if (view === "select_token") {
|
|
14758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: walletAccent, accentForeground: walletAccentForeground, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SelectTokenView, { walletInfo, projectName, assetCdnUrl, balances, isLoading, error, selectedBalance, totalBalanceUsd, onTokenSelect: handleTokenSelect, onContinue: handleContinueToAmount, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14759
|
+
}), onDisconnectWallet: onWalletDisconnect ? () => void handleDisconnect() : void 0, isDisconnectingWallet, checkoutAmountUsd, checkoutReceivedUsd }) }) });
|
|
14760
|
+
}
|
|
14761
|
+
if (view === "enter_amount" && selectedToken && selectedBalance) {
|
|
14762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: walletAccent, accentForeground: walletAccentForeground, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(EnterAmountView, { walletInfo, selectedBalance, selectedToken, amountUsd, formattedTokenAmount, tokenChainDetails, inputUsdNum, maxUsdAmount, isValidAmount, error, onAmountChange: setAmountUsd, onMaxClick: handleMaxClick, onReview: handleReview, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14763
|
+
}), quickSelectMode: amountQuickSelect, checkoutAmountUsd, checkoutReceivedUsd }) }) });
|
|
14764
|
+
}
|
|
14765
|
+
if (view === "review" && selectedToken) {
|
|
14766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: walletAccent, accentForeground: walletAccentForeground, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ReviewView, { walletInfo, recipientAddress, assetCdnUrl, selectedToken, amountUsd, formattedTokenAmount, tokenChainDetails, loadingTokenDetails, showTransactionDetails, isConfirming, error, onToggleDetails: () => setShowTransactionDetails(!showTransactionDetails), onConfirm: handleConfirm, onBack: handleBack, onClose: onClose ?? (() => {
|
|
14767
|
+
}) }) }) });
|
|
14768
|
+
}
|
|
14769
|
+
if (view === "confirming") {
|
|
14770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: walletAccent, accentForeground: walletAccentForeground, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: viewTransitionStyle, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ConfirmingView, { isConfirming, onClose: onClose ?? (() => {
|
|
14771
|
+
}), executions: depositExecutions, isPolling, onNewDeposit, onDone, paymentIntentStatus, amountReceivedUsd: checkoutReceivedUsd, amountReceivedUsdAtSubmission: receivedUsdAtSubmission }) }) });
|
|
14772
|
+
}
|
|
14773
|
+
return null;
|
|
14774
|
+
}
|
|
14775
|
+
|
|
14776
|
+
// src/components/deposits/DepositModal.tsx
|
|
14777
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
14778
|
+
function SkeletonButton({
|
|
14779
|
+
variant = "default"
|
|
14780
|
+
}) {
|
|
14781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-justify-between uf-animate-pulse", children: [
|
|
14782
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
14783
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-bg-muted uf-rounded-lg uf-w-9 uf-h-9" }),
|
|
14784
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-space-y-1.5", children: [
|
|
14785
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-h-3.5 uf-w-24 uf-bg-muted uf-rounded" }),
|
|
14786
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded" })
|
|
14787
|
+
] })
|
|
14788
|
+
] }),
|
|
14789
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
14790
|
+
variant === "with-icons" && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-flex uf--space-x-1", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14791
|
+
"div",
|
|
14792
|
+
{
|
|
14793
|
+
className: "uf-w-5 uf-h-5 uf-rounded-full uf-bg-muted uf-border-2 uf-border-secondary"
|
|
14794
|
+
},
|
|
14242
14795
|
i
|
|
14243
14796
|
)) }),
|
|
14244
14797
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_lucide_react29.ChevronRight, { className: "uf-w-4 uf-h-4 uf-text-muted" })
|
|
@@ -14262,16 +14815,17 @@ function DepositModal({
|
|
|
14262
14815
|
defaultSourceChainId,
|
|
14263
14816
|
defaultSourceTokenAddress,
|
|
14264
14817
|
defaultSourceSymbol,
|
|
14265
|
-
hideDepositTracker
|
|
14818
|
+
hideDepositTracker,
|
|
14266
14819
|
showBalanceHeader = false,
|
|
14267
14820
|
transferInputVariant = "double_input",
|
|
14268
14821
|
depositConfirmationMode = "auto_ui",
|
|
14269
|
-
|
|
14822
|
+
enableTransferCrypto,
|
|
14823
|
+
enableConnectWallet,
|
|
14270
14824
|
browserWalletAmountQuickSelect = "percentage",
|
|
14271
14825
|
enablePayWithExchange,
|
|
14272
14826
|
enableFiatOnramp,
|
|
14273
|
-
enableConnectExchange
|
|
14274
|
-
enableCashApp
|
|
14827
|
+
enableConnectExchange,
|
|
14828
|
+
enableCashApp,
|
|
14275
14829
|
hideDepositFlowInfo = false,
|
|
14276
14830
|
hideDisplayDescription = false,
|
|
14277
14831
|
onDepositSuccess,
|
|
@@ -14289,12 +14843,13 @@ function DepositModal({
|
|
|
14289
14843
|
const { colors: colors2, fonts, components } = useTheme();
|
|
14290
14844
|
const effectiveInitialScreen = (0, import_react20.useMemo)(() => {
|
|
14291
14845
|
const s = initialScreen ?? "main";
|
|
14292
|
-
if (s === "tracker" && hideDepositTracker) return "main";
|
|
14293
|
-
if (s === "cashapp" &&
|
|
14846
|
+
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
14847
|
+
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
14294
14848
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
14295
14849
|
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
14296
|
-
if (s === "exchange_connect")
|
|
14297
|
-
|
|
14850
|
+
if (s === "exchange_connect")
|
|
14851
|
+
return enableConnectExchange === false ? "main" : "coinbase_connect";
|
|
14852
|
+
if (s === "wallet_connect") return enableConnectWallet === false ? "main" : "wallet_connect";
|
|
14298
14853
|
return s;
|
|
14299
14854
|
}, [
|
|
14300
14855
|
initialScreen,
|
|
@@ -14323,27 +14878,37 @@ function DepositModal({
|
|
|
14323
14878
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react20.useState)(false);
|
|
14324
14879
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react20.useState)(null);
|
|
14325
14880
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react20.useState)(false);
|
|
14326
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react20.useState)(() =>
|
|
14881
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react20.useState)(() => getStoredWalletState()?.chainType);
|
|
14327
14882
|
const [quotesCount, setQuotesCount] = (0, import_react20.useState)(0);
|
|
14328
14883
|
const [allExecutions, setAllExecutions] = (0, import_react20.useState)([]);
|
|
14329
14884
|
const [selectedExecution, setSelectedExecution] = (0, import_react20.useState)(null);
|
|
14330
14885
|
const [depositExecutions, setDepositExecutions] = (0, import_react20.useState)([]);
|
|
14331
|
-
const
|
|
14886
|
+
const { projectConfig } = useProjectConfig({
|
|
14887
|
+
publishableKey,
|
|
14888
|
+
enabled: open
|
|
14889
|
+
});
|
|
14890
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
14891
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
14892
|
+
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
14893
|
+
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
14894
|
+
const showConnectExchange = enableConnectExchange ?? projectConfig?.connect_exchange?.enabled ?? true;
|
|
14895
|
+
const showCashApp = enableCashApp ?? projectConfig?.cash_app?.enabled ?? true;
|
|
14896
|
+
const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
|
|
14332
14897
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react20.useState)([]);
|
|
14333
14898
|
(0, import_react20.useEffect)(() => {
|
|
14334
|
-
if (!
|
|
14335
|
-
(0,
|
|
14899
|
+
if (!showConnectExchange || !open) return;
|
|
14900
|
+
(0, import_core30.getIntegrationExchanges)(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
14336
14901
|
});
|
|
14337
|
-
}, [
|
|
14902
|
+
}, [showConnectExchange, open, publishableKey]);
|
|
14338
14903
|
const [connectedExchange, setConnectedExchange] = (0, import_react20.useState)(() => {
|
|
14339
|
-
if (!
|
|
14340
|
-
const stored = getStoredIntegrationToken(
|
|
14904
|
+
if (!showConnectExchange) return null;
|
|
14905
|
+
const stored = getStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE);
|
|
14341
14906
|
if (!stored) return null;
|
|
14342
14907
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
14343
14908
|
});
|
|
14344
14909
|
(0, import_react20.useEffect)(() => {
|
|
14345
|
-
if (!
|
|
14346
|
-
const stored = getStoredIntegrationToken(
|
|
14910
|
+
if (!showConnectExchange || !open || view !== "main") return;
|
|
14911
|
+
const stored = getStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE);
|
|
14347
14912
|
if (!stored) {
|
|
14348
14913
|
setConnectedExchange(null);
|
|
14349
14914
|
return;
|
|
@@ -14360,28 +14925,28 @@ function DepositModal({
|
|
|
14360
14925
|
const balanceUsd = totalUsd > 0 ? totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
|
|
14361
14926
|
setConnectedExchange((prev) => prev ? { ...prev, balanceUsd, isLoading: false } : null);
|
|
14362
14927
|
};
|
|
14363
|
-
(0,
|
|
14928
|
+
(0, import_core30.getIntegrationHoldings)(import_core30.IntegrationProvider.COINBASE, stored.access_token, publishableKey).then(processHoldings).catch(async () => {
|
|
14364
14929
|
try {
|
|
14365
|
-
const refreshResult = await (0,
|
|
14366
|
-
if (!getStoredIntegrationToken(
|
|
14930
|
+
const refreshResult = await (0, import_core30.refreshIntegrationToken)(stored.access_token, publishableKey);
|
|
14931
|
+
if (!getStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE)) return;
|
|
14367
14932
|
setStoredIntegrationToken({
|
|
14368
|
-
integration_provider:
|
|
14933
|
+
integration_provider: import_core30.IntegrationProvider.COINBASE,
|
|
14369
14934
|
access_token: refreshResult.access_token,
|
|
14370
14935
|
expires_at: refreshResult.expires_at
|
|
14371
14936
|
});
|
|
14372
|
-
const retryResult = await (0,
|
|
14937
|
+
const retryResult = await (0, import_core30.getIntegrationHoldings)(import_core30.IntegrationProvider.COINBASE, refreshResult.access_token, publishableKey);
|
|
14373
14938
|
processHoldings(retryResult);
|
|
14374
14939
|
} catch {
|
|
14375
|
-
if (!getStoredIntegrationToken(
|
|
14376
|
-
clearStoredIntegrationToken(
|
|
14940
|
+
if (!getStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE)) return;
|
|
14941
|
+
clearStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE);
|
|
14377
14942
|
setConnectedExchange(null);
|
|
14378
14943
|
}
|
|
14379
14944
|
});
|
|
14380
|
-
}, [
|
|
14945
|
+
}, [showConnectExchange, open, view, publishableKey]);
|
|
14381
14946
|
(0, import_react20.useEffect)(() => {
|
|
14382
14947
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
14383
14948
|
const cbExchange = integrationExchanges.find(
|
|
14384
|
-
(e) => e.service_provider ===
|
|
14949
|
+
(e) => e.service_provider === import_core30.IntegrationProvider.COINBASE
|
|
14385
14950
|
);
|
|
14386
14951
|
const iconUrl = cbExchange?.icon_urls?.find((u) => u.format === "svg")?.url || cbExchange?.icon_urls?.find((u) => u.format === "png")?.url || cbExchange?.icon_url;
|
|
14387
14952
|
if (iconUrl && iconUrl !== connectedExchange.iconUrl) {
|
|
@@ -14416,18 +14981,33 @@ function DepositModal({
|
|
|
14416
14981
|
setResolvedTheme(theme);
|
|
14417
14982
|
}
|
|
14418
14983
|
}, [theme]);
|
|
14419
|
-
const { projectConfig } = useProjectConfig({
|
|
14420
|
-
publishableKey,
|
|
14421
|
-
enabled: open
|
|
14422
|
-
});
|
|
14423
|
-
const showPayWithExchange = enablePayWithExchange ?? projectConfig?.pay_with_exchange?.enabled ?? true;
|
|
14424
|
-
const showFiatOnramp = enableFiatOnramp ?? projectConfig?.fiat_onramp?.enabled ?? true;
|
|
14425
14984
|
(0, import_react20.useEffect)(() => {
|
|
14426
14985
|
if (view === "card" && !showFiatOnramp) {
|
|
14427
14986
|
setView("main");
|
|
14428
14987
|
setCardView("amount");
|
|
14988
|
+
} else if (view === "transfer" && !showTransferCrypto) {
|
|
14989
|
+
setView("main");
|
|
14990
|
+
} else if (view === "exchange" && !showPayWithExchange) {
|
|
14991
|
+
setView("main");
|
|
14992
|
+
} else if (view === "cashapp" && !showCashApp) {
|
|
14993
|
+
setView("main");
|
|
14994
|
+
} else if (view === "tracker" && !showDepositTracker) {
|
|
14995
|
+
setView("main");
|
|
14996
|
+
} else if (view === "coinbase_connect" && !showConnectExchange) {
|
|
14997
|
+
setView("main");
|
|
14998
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
14999
|
+
setView("main");
|
|
14429
15000
|
}
|
|
14430
|
-
}, [
|
|
15001
|
+
}, [
|
|
15002
|
+
view,
|
|
15003
|
+
showFiatOnramp,
|
|
15004
|
+
showTransferCrypto,
|
|
15005
|
+
showPayWithExchange,
|
|
15006
|
+
showCashApp,
|
|
15007
|
+
showDepositTracker,
|
|
15008
|
+
showConnectExchange,
|
|
15009
|
+
showConnectWallet
|
|
15010
|
+
]);
|
|
14431
15011
|
(0, import_react20.useEffect)(() => {
|
|
14432
15012
|
if (view === "exchange" && !showPayWithExchange) {
|
|
14433
15013
|
setView("main");
|
|
@@ -14452,7 +15032,7 @@ function DepositModal({
|
|
|
14452
15032
|
if (view !== "tracker" || !userId) return;
|
|
14453
15033
|
const fetchExecutions = async () => {
|
|
14454
15034
|
try {
|
|
14455
|
-
const response = await (0,
|
|
15035
|
+
const response = await (0, import_core30.queryExecutions)(userId, publishableKey, import_core30.ActionType.Deposit);
|
|
14456
15036
|
const sorted = [...response.data].sort((a, b) => {
|
|
14457
15037
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
14458
15038
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -14517,7 +15097,7 @@ function DepositModal({
|
|
|
14517
15097
|
depositPrerequisiteBody = standaloneNeedsDepositPrereq ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SkeletonButton, { variant: "with-icons" }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
14518
15098
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
14519
15099
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SkeletonButton, { variant: "with-icons" }),
|
|
14520
|
-
|
|
15100
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(SkeletonButton, {})
|
|
14521
15101
|
] });
|
|
14522
15102
|
} else if (countryError) {
|
|
14523
15103
|
depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
@@ -14549,18 +15129,18 @@ function DepositModal({
|
|
|
14549
15129
|
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
14550
15130
|
const handleWalletDisconnect = () => {
|
|
14551
15131
|
setUserDisconnectedWallet(true);
|
|
14552
|
-
|
|
15132
|
+
clearStoredWalletState();
|
|
14553
15133
|
setBrowserWalletChainType(void 0);
|
|
14554
15134
|
setBrowserWalletInfo(null);
|
|
14555
15135
|
setBrowserWalletModalOpen(false);
|
|
14556
15136
|
if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
|
|
14557
15137
|
};
|
|
14558
15138
|
const handleExchangeDisconnect = () => {
|
|
14559
|
-
const stored = getStoredIntegrationToken(
|
|
15139
|
+
const stored = getStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE);
|
|
14560
15140
|
if (stored) {
|
|
14561
|
-
(0,
|
|
15141
|
+
(0, import_core30.revokeIntegrationToken)(stored.access_token, publishableKey);
|
|
14562
15142
|
}
|
|
14563
|
-
clearStoredIntegrationToken(
|
|
15143
|
+
clearStoredIntegrationToken(import_core30.IntegrationProvider.COINBASE);
|
|
14564
15144
|
setConnectedExchange(null);
|
|
14565
15145
|
if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
|
|
14566
15146
|
};
|
|
@@ -14627,7 +15207,7 @@ function DepositModal({
|
|
|
14627
15207
|
};
|
|
14628
15208
|
const handleBrowserWalletClick = (walletInfo) => {
|
|
14629
15209
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
14630
|
-
|
|
15210
|
+
setStoredWalletState(walletInfo.type);
|
|
14631
15211
|
setBrowserWalletChainType(walletChainType);
|
|
14632
15212
|
const matchingDepositWallet = wallets.find(
|
|
14633
15213
|
(w) => w.chain_type === walletChainType
|
|
@@ -14658,7 +15238,7 @@ function DepositModal({
|
|
|
14658
15238
|
};
|
|
14659
15239
|
const handleWalletConnected = (walletInfo) => {
|
|
14660
15240
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
14661
|
-
|
|
15241
|
+
setStoredWalletState(walletInfo.type);
|
|
14662
15242
|
setBrowserWalletChainType(walletChainType);
|
|
14663
15243
|
const matchingDepositWallet = wallets.find(
|
|
14664
15244
|
(w) => w.chain_type === walletChainType
|
|
@@ -14698,7 +15278,7 @@ function DepositModal({
|
|
|
14698
15278
|
open: hideOverlay || open,
|
|
14699
15279
|
onOpenChange: hideOverlay ? void 0 : handleClose,
|
|
14700
15280
|
modal: !hideOverlay,
|
|
14701
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime55.
|
|
15281
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
14702
15282
|
DialogContent,
|
|
14703
15283
|
{
|
|
14704
15284
|
ref: hideOverlay ? containerCallbackRef : void 0,
|
|
@@ -14707,378 +15287,389 @@ function DepositModal({
|
|
|
14707
15287
|
style: { backgroundColor: colors2.background },
|
|
14708
15288
|
onPointerDownOutside: (e) => e.preventDefault(),
|
|
14709
15289
|
onInteractOutside: (e) => e.preventDefault(),
|
|
14710
|
-
children:
|
|
14711
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
|
|
14719
|
-
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
15290
|
+
children: [
|
|
15291
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DialogTitle, { className: "uf-sr-only", children: modalTitle || "Deposit" }),
|
|
15292
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ThemeStyleInjector, { children: view === "main" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15293
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15294
|
+
DepositHeader,
|
|
15295
|
+
{
|
|
15296
|
+
title: modalTitle || "Deposit",
|
|
15297
|
+
showClose: !hideOverlay,
|
|
15298
|
+
onClose: handleClose,
|
|
15299
|
+
showBalance: showBalanceHeader,
|
|
15300
|
+
balanceAddress: recipientAddress,
|
|
15301
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15302
|
+
balanceChainId: destinationChainId,
|
|
15303
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
15304
|
+
projectName: projectConfig?.project_name,
|
|
15305
|
+
publishableKey
|
|
15306
|
+
}
|
|
15307
|
+
),
|
|
15308
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15309
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-space-y-3", children: depositPrerequisiteBody ?? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15310
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15311
|
+
TransferCryptoButton,
|
|
15312
|
+
{
|
|
15313
|
+
onClick: () => setView("transfer"),
|
|
15314
|
+
title: transferCryptoTitle,
|
|
15315
|
+
subtitle: t7.transferCrypto.subtitle,
|
|
15316
|
+
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
15317
|
+
}
|
|
15318
|
+
),
|
|
15319
|
+
showConnectWallet && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15320
|
+
BrowserWalletButton,
|
|
15321
|
+
{
|
|
15322
|
+
onClick: handleBrowserWalletClick,
|
|
15323
|
+
onConnectClick: handleWalletConnectClick,
|
|
15324
|
+
onDisconnect: handleWalletDisconnect,
|
|
15325
|
+
chainType: browserWalletChainType,
|
|
15326
|
+
publishableKey,
|
|
15327
|
+
featuredWallets: projectConfig?.connect_wallet?.wallets
|
|
15328
|
+
}
|
|
15329
|
+
),
|
|
15330
|
+
showFiatOnramp && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15331
|
+
DepositWithCardButton,
|
|
15332
|
+
{
|
|
15333
|
+
onClick: () => setView("card"),
|
|
15334
|
+
title: depositWithCardTitle,
|
|
15335
|
+
subtitle: t7.depositWithCard.subtitle,
|
|
15336
|
+
paymentNetworks: projectConfig?.payment_networks.networks
|
|
15337
|
+
}
|
|
15338
|
+
),
|
|
15339
|
+
showPayWithExchange && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15340
|
+
PayWithExchangeButton,
|
|
15341
|
+
{
|
|
15342
|
+
onClick: () => setView("exchange"),
|
|
15343
|
+
title: payWithExchangeTitle,
|
|
15344
|
+
subtitle: t7.payWithExchange.subtitle,
|
|
15345
|
+
exchanges,
|
|
15346
|
+
loading: exchangesLoading
|
|
15347
|
+
}
|
|
15348
|
+
),
|
|
15349
|
+
showConnectExchange && connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15350
|
+
ConnectExchangeButton,
|
|
15351
|
+
{
|
|
15352
|
+
onClick: () => {
|
|
15353
|
+
setCoinbaseSkipToHoldings(true);
|
|
15354
|
+
setView("coinbase_connect");
|
|
15355
|
+
},
|
|
15356
|
+
onDisconnect: handleExchangeDisconnect,
|
|
15357
|
+
title: i18n.connectExchange.title,
|
|
15358
|
+
subtitle: i18n.connectExchange.subtitle,
|
|
15359
|
+
exchanges: integrationExchanges,
|
|
15360
|
+
connectedExchange
|
|
15361
|
+
}
|
|
15362
|
+
),
|
|
15363
|
+
showConnectExchange && !connectedExchange && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15364
|
+
ConnectExchangeButton,
|
|
15365
|
+
{
|
|
15366
|
+
onClick: () => {
|
|
15367
|
+
setCoinbaseSkipToHoldings(false);
|
|
15368
|
+
setView("coinbase_connect");
|
|
15369
|
+
},
|
|
15370
|
+
title: i18n.connectExchange.title,
|
|
15371
|
+
subtitle: i18n.connectExchange.subtitle,
|
|
15372
|
+
exchanges: integrationExchanges
|
|
15373
|
+
}
|
|
15374
|
+
),
|
|
15375
|
+
showCashApp && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15376
|
+
CashAppButton,
|
|
15377
|
+
{
|
|
15378
|
+
onClick: () => setView("cashapp"),
|
|
15379
|
+
title: "Pay with Cash App",
|
|
15380
|
+
subtitle: "Deposit via Cash App",
|
|
15381
|
+
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
15382
|
+
}
|
|
15383
|
+
),
|
|
15384
|
+
showDepositTracker && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15385
|
+
DepositTrackerButton,
|
|
15386
|
+
{
|
|
15387
|
+
onClick: () => {
|
|
15388
|
+
setAllExecutions(depositExecutions);
|
|
15389
|
+
setView("tracker");
|
|
15390
|
+
},
|
|
15391
|
+
title: depositTrackerTitle,
|
|
15392
|
+
subtitle: depositTrackerSubTitle,
|
|
15393
|
+
badge: depositExecutions.length > 0 ? depositExecutions.length : void 0
|
|
15394
|
+
}
|
|
15395
|
+
)
|
|
15396
|
+
] }) }),
|
|
15397
|
+
depositPoweredByFooter
|
|
15398
|
+
] })
|
|
15399
|
+
] }) : view === "transfer" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15400
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15401
|
+
DepositHeader,
|
|
15402
|
+
{
|
|
15403
|
+
title: transferCryptoTitle,
|
|
15404
|
+
showBack: showBackTransfer,
|
|
15405
|
+
onBack: handleBack,
|
|
15406
|
+
onClose: handleClose,
|
|
15407
|
+
showBalance: showBalanceHeader,
|
|
15408
|
+
balanceAddress: recipientAddress,
|
|
15409
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15410
|
+
balanceChainId: destinationChainId,
|
|
15411
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
15412
|
+
projectName: projectConfig?.project_name,
|
|
15413
|
+
publishableKey
|
|
15414
|
+
}
|
|
15415
|
+
),
|
|
15416
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15417
|
+
standaloneNeedsDepositPrereq && depositPrerequisiteBody !== null ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: depositPrerequisiteBody }) : transferInputVariant === "single_input" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15418
|
+
TransferCryptoSingleInput,
|
|
14739
15419
|
{
|
|
14740
|
-
|
|
14741
|
-
onConnectClick: handleWalletConnectClick,
|
|
14742
|
-
onDisconnect: handleWalletDisconnect,
|
|
14743
|
-
chainType: browserWalletChainType,
|
|
15420
|
+
userId,
|
|
14744
15421
|
publishableKey,
|
|
14745
|
-
|
|
15422
|
+
recipientAddress,
|
|
15423
|
+
destinationChainType,
|
|
15424
|
+
destinationChainId,
|
|
15425
|
+
destinationTokenAddress,
|
|
15426
|
+
defaultSourceChainType,
|
|
15427
|
+
defaultSourceChainId,
|
|
15428
|
+
defaultSourceTokenAddress,
|
|
15429
|
+
defaultSourceSymbol,
|
|
15430
|
+
depositConfirmationMode,
|
|
15431
|
+
onExecutionsChange: setDepositExecutions,
|
|
15432
|
+
onDepositSuccess,
|
|
15433
|
+
onDepositError,
|
|
15434
|
+
wallets
|
|
14746
15435
|
}
|
|
14747
|
-
),
|
|
14748
|
-
|
|
14749
|
-
DepositWithCardButton,
|
|
15436
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15437
|
+
TransferCryptoDoubleInput,
|
|
14750
15438
|
{
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
15439
|
+
userId,
|
|
15440
|
+
publishableKey,
|
|
15441
|
+
recipientAddress,
|
|
15442
|
+
destinationChainType,
|
|
15443
|
+
destinationChainId,
|
|
15444
|
+
destinationTokenAddress,
|
|
15445
|
+
defaultSourceChainType,
|
|
15446
|
+
defaultSourceChainId,
|
|
15447
|
+
defaultSourceTokenAddress,
|
|
15448
|
+
defaultSourceSymbol,
|
|
15449
|
+
depositConfirmationMode,
|
|
15450
|
+
onExecutionsChange: setDepositExecutions,
|
|
15451
|
+
onDepositSuccess,
|
|
15452
|
+
onDepositError,
|
|
15453
|
+
wallets
|
|
14755
15454
|
}
|
|
14756
15455
|
),
|
|
14757
|
-
|
|
14758
|
-
|
|
15456
|
+
depositPoweredByFooter
|
|
15457
|
+
] })
|
|
15458
|
+
] }) : view === "tracker" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15459
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15460
|
+
DepositHeader,
|
|
15461
|
+
{
|
|
15462
|
+
title: selectedExecution ? "Deposit Details" : depositTrackerTitle,
|
|
15463
|
+
showBack: showBackTracker,
|
|
15464
|
+
onBack: handleBack,
|
|
15465
|
+
onClose: handleClose
|
|
15466
|
+
}
|
|
15467
|
+
),
|
|
15468
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15469
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-h-[460px] uf-overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: selectedExecution ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DepositDetailContent, { execution: selectedExecution }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-space-y-2 uf-pb-8", children: allExecutions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-py-8 uf-px-4 uf-text-center", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15470
|
+
"div",
|
|
14759
15471
|
{
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
exchanges,
|
|
14764
|
-
loading: exchangesLoading
|
|
15472
|
+
className: "uf-text-sm",
|
|
15473
|
+
style: { color: components.container.subtitleColor, fontFamily: fonts.regular },
|
|
15474
|
+
children: "No deposits yet"
|
|
14765
15475
|
}
|
|
14766
|
-
),
|
|
14767
|
-
|
|
14768
|
-
ConnectExchangeButton,
|
|
15476
|
+
) }) : allExecutions.map((execution) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15477
|
+
DepositExecutionItem,
|
|
14769
15478
|
{
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
15479
|
+
execution,
|
|
15480
|
+
onClick: () => setSelectedExecution(execution)
|
|
15481
|
+
},
|
|
15482
|
+
execution.id
|
|
15483
|
+
)) }) }),
|
|
15484
|
+
depositPoweredByFooter
|
|
15485
|
+
] })
|
|
15486
|
+
] }) : view === "card" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15487
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15488
|
+
DepositHeader,
|
|
15489
|
+
{
|
|
15490
|
+
title: cardView === "quotes" ? t7.quotes : depositWithCardTitle,
|
|
15491
|
+
showBack: showBackCard,
|
|
15492
|
+
onBack: handleBack,
|
|
15493
|
+
onClose: handleClose,
|
|
15494
|
+
badge: cardView === "quotes" ? { count: quotesCount } : void 0,
|
|
15495
|
+
showBalance: showBalanceHeader,
|
|
15496
|
+
balanceAddress: recipientAddress,
|
|
15497
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15498
|
+
balanceChainId: destinationChainId,
|
|
15499
|
+
balanceTokenAddress: destinationTokenAddress,
|
|
15500
|
+
projectName: projectConfig?.project_name,
|
|
15501
|
+
publishableKey
|
|
15502
|
+
}
|
|
15503
|
+
),
|
|
15504
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15505
|
+
standaloneNeedsDepositPrereq && depositPrerequisiteBody !== null ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: depositPrerequisiteBody }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15506
|
+
BuyWithCard,
|
|
14783
15507
|
{
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14787
|
-
|
|
14788
|
-
|
|
14789
|
-
|
|
14790
|
-
|
|
15508
|
+
userId,
|
|
15509
|
+
publishableKey,
|
|
15510
|
+
view: cardView,
|
|
15511
|
+
onViewChange: handleCardViewChange,
|
|
15512
|
+
destinationTokenSymbol,
|
|
15513
|
+
recipientAddress,
|
|
15514
|
+
destinationChainType,
|
|
15515
|
+
destinationChainId,
|
|
15516
|
+
destinationTokenAddress,
|
|
15517
|
+
onDepositSuccess,
|
|
15518
|
+
onDepositError,
|
|
15519
|
+
onEvent,
|
|
15520
|
+
themeClass,
|
|
15521
|
+
wallets,
|
|
15522
|
+
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
15523
|
+
hideDepositFlowInfo,
|
|
15524
|
+
hideDisplayDescription
|
|
14791
15525
|
}
|
|
14792
15526
|
),
|
|
14793
|
-
|
|
14794
|
-
|
|
15527
|
+
depositPoweredByFooter
|
|
15528
|
+
] })
|
|
15529
|
+
] }) : view === "exchange" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15530
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15531
|
+
DepositHeader,
|
|
15532
|
+
{
|
|
15533
|
+
title: payWithExchangeTitle,
|
|
15534
|
+
showBack: exchangeView === "pending" || sessionOpenedFromMenu,
|
|
15535
|
+
onBack: handleBack,
|
|
15536
|
+
onClose: handleClose
|
|
15537
|
+
}
|
|
15538
|
+
),
|
|
15539
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15540
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15541
|
+
PayWithExchange,
|
|
14795
15542
|
{
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
15543
|
+
userId,
|
|
15544
|
+
publishableKey,
|
|
15545
|
+
exchanges,
|
|
15546
|
+
view: exchangeView,
|
|
15547
|
+
onViewChange: setExchangeView,
|
|
15548
|
+
destinationTokenSymbol,
|
|
15549
|
+
recipientAddress,
|
|
15550
|
+
destinationChainType,
|
|
15551
|
+
destinationChainId,
|
|
15552
|
+
destinationTokenAddress,
|
|
15553
|
+
onDepositSuccess,
|
|
15554
|
+
onDepositError,
|
|
15555
|
+
wallets,
|
|
15556
|
+
defaultToken: defaultToken ?? null
|
|
14800
15557
|
}
|
|
14801
15558
|
),
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
setView("tracker");
|
|
14808
|
-
},
|
|
14809
|
-
title: depositTrackerTitle,
|
|
14810
|
-
subtitle: depositTrackerSubTitle,
|
|
14811
|
-
badge: depositExecutions.length > 0 ? depositExecutions.length : void 0
|
|
14812
|
-
}
|
|
14813
|
-
)
|
|
14814
|
-
] }) }),
|
|
14815
|
-
depositPoweredByFooter
|
|
14816
|
-
] })
|
|
14817
|
-
] }) : view === "transfer" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
14818
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14819
|
-
DepositHeader,
|
|
14820
|
-
{
|
|
14821
|
-
title: transferCryptoTitle,
|
|
14822
|
-
showBack: showBackTransfer,
|
|
14823
|
-
onBack: handleBack,
|
|
14824
|
-
onClose: handleClose,
|
|
14825
|
-
showBalance: showBalanceHeader,
|
|
14826
|
-
balanceAddress: recipientAddress,
|
|
14827
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
14828
|
-
balanceChainId: destinationChainId,
|
|
14829
|
-
balanceTokenAddress: destinationTokenAddress,
|
|
14830
|
-
projectName: projectConfig?.project_name,
|
|
14831
|
-
publishableKey
|
|
14832
|
-
}
|
|
14833
|
-
),
|
|
14834
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
14835
|
-
standaloneNeedsDepositPrereq && depositPrerequisiteBody !== null ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: depositPrerequisiteBody }) : transferInputVariant === "single_input" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14836
|
-
TransferCryptoSingleInput,
|
|
15559
|
+
depositPoweredByFooter
|
|
15560
|
+
] })
|
|
15561
|
+
] }) : view === "coinbase_connect" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15562
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15563
|
+
CoinbaseConnect,
|
|
14837
15564
|
{
|
|
14838
|
-
userId,
|
|
14839
15565
|
publishableKey,
|
|
14840
|
-
recipientAddress,
|
|
14841
|
-
destinationChainType,
|
|
14842
|
-
destinationChainId,
|
|
14843
|
-
destinationTokenAddress,
|
|
14844
|
-
defaultSourceChainType,
|
|
14845
|
-
defaultSourceChainId,
|
|
14846
|
-
defaultSourceTokenAddress,
|
|
14847
|
-
defaultSourceSymbol,
|
|
14848
|
-
depositConfirmationMode,
|
|
14849
|
-
onExecutionsChange: setDepositExecutions,
|
|
14850
|
-
onDepositSuccess,
|
|
14851
|
-
onDepositError,
|
|
14852
|
-
wallets
|
|
14853
|
-
}
|
|
14854
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14855
|
-
TransferCryptoDoubleInput,
|
|
14856
|
-
{
|
|
14857
15566
|
userId,
|
|
14858
|
-
|
|
15567
|
+
wallets,
|
|
14859
15568
|
recipientAddress,
|
|
14860
|
-
|
|
14861
|
-
destinationChainId,
|
|
14862
|
-
|
|
15569
|
+
destinationTokenAddress: destinationTokenAddress ?? "",
|
|
15570
|
+
destinationChainId: destinationChainId ?? "",
|
|
15571
|
+
destinationChainType: destinationChainType ?? "",
|
|
15572
|
+
onTransferSuccess: (result) => {
|
|
15573
|
+
onDepositSuccess?.({
|
|
15574
|
+
message: "Transfer completed via Coinbase Connect",
|
|
15575
|
+
transaction: result
|
|
15576
|
+
});
|
|
15577
|
+
},
|
|
15578
|
+
onTransferError: (error) => {
|
|
15579
|
+
onDepositError?.({
|
|
15580
|
+
message: error.message,
|
|
15581
|
+
error
|
|
15582
|
+
});
|
|
15583
|
+
},
|
|
15584
|
+
onBack: handleBack,
|
|
15585
|
+
onClose: handleClose,
|
|
15586
|
+
onDisconnect: handleExchangeDisconnect,
|
|
15587
|
+
skipToHoldings: coinbaseSkipToHoldings,
|
|
15588
|
+
canGoBack: sessionOpenedFromMenu,
|
|
15589
|
+
onExecutionsChange: setDepositExecutions,
|
|
14863
15590
|
defaultSourceChainType,
|
|
14864
15591
|
defaultSourceChainId,
|
|
14865
15592
|
defaultSourceTokenAddress,
|
|
14866
|
-
defaultSourceSymbol
|
|
14867
|
-
depositConfirmationMode,
|
|
14868
|
-
onExecutionsChange: setDepositExecutions,
|
|
14869
|
-
onDepositSuccess,
|
|
14870
|
-
onDepositError,
|
|
14871
|
-
wallets
|
|
14872
|
-
}
|
|
14873
|
-
),
|
|
14874
|
-
depositPoweredByFooter
|
|
14875
|
-
] })
|
|
14876
|
-
] }) : view === "tracker" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
14877
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14878
|
-
DepositHeader,
|
|
14879
|
-
{
|
|
14880
|
-
title: selectedExecution ? "Deposit Details" : depositTrackerTitle,
|
|
14881
|
-
showBack: showBackTracker,
|
|
14882
|
-
onBack: handleBack,
|
|
14883
|
-
onClose: handleClose
|
|
14884
|
-
}
|
|
14885
|
-
),
|
|
14886
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
14887
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-h-[460px] uf-overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: selectedExecution ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DepositDetailContent, { execution: selectedExecution }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-space-y-2 uf-pb-8", children: allExecutions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-py-8 uf-px-4 uf-text-center", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14888
|
-
"div",
|
|
14889
|
-
{
|
|
14890
|
-
className: "uf-text-sm",
|
|
14891
|
-
style: { color: components.container.subtitleColor, fontFamily: fonts.regular },
|
|
14892
|
-
children: "No deposits yet"
|
|
14893
|
-
}
|
|
14894
|
-
) }) : allExecutions.map((execution) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14895
|
-
DepositExecutionItem,
|
|
14896
|
-
{
|
|
14897
|
-
execution,
|
|
14898
|
-
onClick: () => setSelectedExecution(execution)
|
|
14899
|
-
},
|
|
14900
|
-
execution.id
|
|
14901
|
-
)) }) }),
|
|
14902
|
-
depositPoweredByFooter
|
|
14903
|
-
] })
|
|
14904
|
-
] }) : view === "card" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
14905
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14906
|
-
DepositHeader,
|
|
14907
|
-
{
|
|
14908
|
-
title: cardView === "quotes" ? t7.quotes : depositWithCardTitle,
|
|
14909
|
-
showBack: showBackCard,
|
|
14910
|
-
onBack: handleBack,
|
|
14911
|
-
onClose: handleClose,
|
|
14912
|
-
badge: cardView === "quotes" ? { count: quotesCount } : void 0,
|
|
14913
|
-
showBalance: showBalanceHeader,
|
|
14914
|
-
balanceAddress: recipientAddress,
|
|
14915
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
14916
|
-
balanceChainId: destinationChainId,
|
|
14917
|
-
balanceTokenAddress: destinationTokenAddress,
|
|
14918
|
-
projectName: projectConfig?.project_name,
|
|
14919
|
-
publishableKey
|
|
14920
|
-
}
|
|
14921
|
-
),
|
|
14922
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
14923
|
-
standaloneNeedsDepositPrereq && depositPrerequisiteBody !== null ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-pb-4 uf-space-y-3", children: depositPrerequisiteBody }) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14924
|
-
BuyWithCard,
|
|
14925
|
-
{
|
|
14926
|
-
userId,
|
|
14927
|
-
publishableKey,
|
|
14928
|
-
view: cardView,
|
|
14929
|
-
onViewChange: handleCardViewChange,
|
|
14930
|
-
destinationTokenSymbol,
|
|
14931
|
-
recipientAddress,
|
|
14932
|
-
destinationChainType,
|
|
14933
|
-
destinationChainId,
|
|
14934
|
-
destinationTokenAddress,
|
|
14935
|
-
onDepositSuccess,
|
|
14936
|
-
onDepositError,
|
|
14937
|
-
onEvent,
|
|
14938
|
-
themeClass,
|
|
14939
|
-
wallets,
|
|
14940
|
-
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
14941
|
-
hideDepositFlowInfo,
|
|
14942
|
-
hideDisplayDescription
|
|
15593
|
+
defaultSourceSymbol
|
|
14943
15594
|
}
|
|
14944
15595
|
),
|
|
14945
15596
|
depositPoweredByFooter
|
|
14946
|
-
] })
|
|
14947
|
-
] }) : view === "exchange" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
14948
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14949
|
-
DepositHeader,
|
|
14950
|
-
{
|
|
14951
|
-
title: payWithExchangeTitle,
|
|
14952
|
-
showBack: exchangeView === "pending" || sessionOpenedFromMenu,
|
|
14953
|
-
onBack: handleBack,
|
|
14954
|
-
onClose: handleClose
|
|
14955
|
-
}
|
|
14956
|
-
),
|
|
14957
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15597
|
+
] }) : view === "wallet_connect" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
14958
15598
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14959
|
-
|
|
15599
|
+
WalletConnect,
|
|
14960
15600
|
{
|
|
15601
|
+
walletInfo: browserWalletInfo ?? void 0,
|
|
15602
|
+
depositWallet: browserWalletInfo?.depositWallet ?? void 0,
|
|
15603
|
+
wallets,
|
|
14961
15604
|
userId,
|
|
14962
15605
|
publishableKey,
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14968
|
-
|
|
14969
|
-
|
|
14970
|
-
|
|
15606
|
+
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
15607
|
+
projectName: projectConfig?.project_name,
|
|
15608
|
+
onSuccess: (txHash) => {
|
|
15609
|
+
onDepositSuccess?.({
|
|
15610
|
+
message: "Transaction sent successfully",
|
|
15611
|
+
transaction: { txHash }
|
|
15612
|
+
});
|
|
15613
|
+
},
|
|
15614
|
+
onError: (error) => {
|
|
15615
|
+
onDepositError?.({
|
|
15616
|
+
message: error.message,
|
|
15617
|
+
error
|
|
15618
|
+
});
|
|
15619
|
+
},
|
|
14971
15620
|
onDepositSuccess,
|
|
14972
15621
|
onDepositError,
|
|
14973
|
-
|
|
14974
|
-
|
|
15622
|
+
amountQuickSelect: browserWalletAmountQuickSelect,
|
|
15623
|
+
onWalletDisconnect: handleWalletDisconnect,
|
|
15624
|
+
onWalletConnected: (info, dw) => {
|
|
15625
|
+
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
15626
|
+
setStoredWalletState(info.type);
|
|
15627
|
+
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
15628
|
+
},
|
|
15629
|
+
onBack: handleBack,
|
|
15630
|
+
onClose: handleClose,
|
|
15631
|
+
defaultSourceChainType,
|
|
15632
|
+
defaultSourceChainId,
|
|
15633
|
+
defaultSourceTokenAddress,
|
|
15634
|
+
defaultSourceSymbol,
|
|
15635
|
+
canGoBack: sessionOpenedFromMenu,
|
|
15636
|
+
depositWalletsLoading: walletsLoading
|
|
14975
15637
|
}
|
|
14976
15638
|
),
|
|
14977
15639
|
depositPoweredByFooter
|
|
14978
|
-
] })
|
|
14979
|
-
] }) : view === "coinbase_connect" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
14980
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
14981
|
-
CoinbaseConnect,
|
|
14982
|
-
{
|
|
14983
|
-
publishableKey,
|
|
14984
|
-
userId,
|
|
14985
|
-
wallets,
|
|
14986
|
-
recipientAddress,
|
|
14987
|
-
destinationTokenAddress: destinationTokenAddress ?? "",
|
|
14988
|
-
destinationChainId: destinationChainId ?? "",
|
|
14989
|
-
destinationChainType: destinationChainType ?? "",
|
|
14990
|
-
onTransferSuccess: (result) => {
|
|
14991
|
-
onDepositSuccess?.({
|
|
14992
|
-
message: "Transfer completed via Coinbase Connect",
|
|
14993
|
-
transaction: result
|
|
14994
|
-
});
|
|
14995
|
-
},
|
|
14996
|
-
onTransferError: (error) => {
|
|
14997
|
-
onDepositError?.({
|
|
14998
|
-
message: error.message,
|
|
14999
|
-
error
|
|
15000
|
-
});
|
|
15001
|
-
},
|
|
15002
|
-
onBack: handleBack,
|
|
15003
|
-
onClose: handleClose,
|
|
15004
|
-
onDisconnect: handleExchangeDisconnect,
|
|
15005
|
-
skipToHoldings: coinbaseSkipToHoldings,
|
|
15006
|
-
canGoBack: sessionOpenedFromMenu,
|
|
15007
|
-
onExecutionsChange: setDepositExecutions
|
|
15008
|
-
}
|
|
15009
|
-
),
|
|
15010
|
-
depositPoweredByFooter
|
|
15011
|
-
] }) : view === "wallet_connect" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15012
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15013
|
-
WalletConnect,
|
|
15014
|
-
{
|
|
15015
|
-
walletInfo: browserWalletInfo ?? void 0,
|
|
15016
|
-
depositWallet: browserWalletInfo?.depositWallet ?? void 0,
|
|
15017
|
-
wallets,
|
|
15018
|
-
userId,
|
|
15019
|
-
publishableKey,
|
|
15020
|
-
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
15021
|
-
projectName: projectConfig?.project_name,
|
|
15022
|
-
onSuccess: (txHash) => {
|
|
15023
|
-
onDepositSuccess?.({
|
|
15024
|
-
message: "Transaction sent successfully",
|
|
15025
|
-
transaction: { txHash }
|
|
15026
|
-
});
|
|
15027
|
-
},
|
|
15028
|
-
onError: (error) => {
|
|
15029
|
-
onDepositError?.({
|
|
15030
|
-
message: error.message,
|
|
15031
|
-
error
|
|
15032
|
-
});
|
|
15033
|
-
},
|
|
15034
|
-
onDepositSuccess,
|
|
15035
|
-
onDepositError,
|
|
15036
|
-
amountQuickSelect: browserWalletAmountQuickSelect,
|
|
15037
|
-
onWalletDisconnect: handleWalletDisconnect,
|
|
15038
|
-
onWalletConnected: (info, dw) => {
|
|
15039
|
-
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
15040
|
-
setStoredWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
15041
|
-
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
15042
|
-
},
|
|
15043
|
-
onBack: handleBack,
|
|
15044
|
-
onClose: handleClose,
|
|
15045
|
-
canGoBack: sessionOpenedFromMenu,
|
|
15046
|
-
depositWalletsLoading: walletsLoading
|
|
15047
|
-
}
|
|
15048
|
-
),
|
|
15049
|
-
depositPoweredByFooter
|
|
15050
|
-
] }) : view === "cashapp" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15051
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15052
|
-
DepositHeader,
|
|
15053
|
-
{
|
|
15054
|
-
title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
|
|
15055
|
-
showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
|
|
15056
|
-
onBack: handleBack,
|
|
15057
|
-
onClose: handleClose
|
|
15058
|
-
}
|
|
15059
|
-
),
|
|
15060
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15640
|
+
] }) : view === "cashapp" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
15061
15641
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15062
|
-
|
|
15642
|
+
DepositHeader,
|
|
15063
15643
|
{
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
destinationChainId,
|
|
15069
|
-
destinationTokenAddress,
|
|
15070
|
-
cashAppIconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0,
|
|
15071
|
-
view: cashAppView,
|
|
15072
|
-
onViewChange: setCashAppView,
|
|
15073
|
-
onAmountChange: setCashAppAmount,
|
|
15074
|
-
onEvent,
|
|
15075
|
-
onDepositSuccess,
|
|
15076
|
-
onDepositError
|
|
15644
|
+
title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
|
|
15645
|
+
showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
|
|
15646
|
+
onBack: handleBack,
|
|
15647
|
+
onClose: handleClose
|
|
15077
15648
|
}
|
|
15078
15649
|
),
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15650
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15651
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15652
|
+
PayWithCashApp,
|
|
15653
|
+
{
|
|
15654
|
+
userId,
|
|
15655
|
+
publishableKey,
|
|
15656
|
+
recipientAddress,
|
|
15657
|
+
destinationChainType,
|
|
15658
|
+
destinationChainId,
|
|
15659
|
+
destinationTokenAddress,
|
|
15660
|
+
cashAppIconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0,
|
|
15661
|
+
view: cashAppView,
|
|
15662
|
+
onViewChange: setCashAppView,
|
|
15663
|
+
onAmountChange: setCashAppAmount,
|
|
15664
|
+
onEvent,
|
|
15665
|
+
onDepositSuccess,
|
|
15666
|
+
onDepositError
|
|
15667
|
+
}
|
|
15668
|
+
),
|
|
15669
|
+
depositPoweredByFooter
|
|
15670
|
+
] })
|
|
15671
|
+
] }) : null })
|
|
15672
|
+
]
|
|
15082
15673
|
}
|
|
15083
15674
|
)
|
|
15084
15675
|
}
|
|
@@ -15090,8 +15681,8 @@ var import_react21 = require("react");
|
|
|
15090
15681
|
var import_lucide_react30 = require("lucide-react");
|
|
15091
15682
|
|
|
15092
15683
|
// src/hooks/use-payment-intent.ts
|
|
15093
|
-
var
|
|
15094
|
-
var
|
|
15684
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
15685
|
+
var import_core31 = require("@unifold/core");
|
|
15095
15686
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
15096
15687
|
"succeeded",
|
|
15097
15688
|
"expired",
|
|
@@ -15105,9 +15696,9 @@ function usePaymentIntent(params) {
|
|
|
15105
15696
|
enabled = true,
|
|
15106
15697
|
pollingInterval = 3e3
|
|
15107
15698
|
} = params;
|
|
15108
|
-
return (0,
|
|
15699
|
+
return (0, import_react_query14.useQuery)({
|
|
15109
15700
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
15110
|
-
queryFn: () => (0,
|
|
15701
|
+
queryFn: () => (0, import_core31.retrievePaymentIntent)(clientSecret, publishableKey),
|
|
15111
15702
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
15112
15703
|
staleTime: 0,
|
|
15113
15704
|
refetchInterval: (query) => {
|
|
@@ -15155,7 +15746,8 @@ function CheckoutModal({
|
|
|
15155
15746
|
clientSecret,
|
|
15156
15747
|
publishableKey,
|
|
15157
15748
|
modalTitle,
|
|
15158
|
-
|
|
15749
|
+
enableTransferCrypto,
|
|
15750
|
+
enableConnectWallet,
|
|
15159
15751
|
defaultSourceChainType,
|
|
15160
15752
|
defaultSourceChainId,
|
|
15161
15753
|
defaultSourceTokenAddress,
|
|
@@ -15172,8 +15764,7 @@ function CheckoutModal({
|
|
|
15172
15764
|
const [browserWalletModalOpen, setBrowserWalletModalOpen] = (0, import_react21.useState)(false);
|
|
15173
15765
|
const [browserWalletInfo, setBrowserWalletInfo] = (0, import_react21.useState)(null);
|
|
15174
15766
|
const [walletSelectionModalOpen, setWalletSelectionModalOpen] = (0, import_react21.useState)(false);
|
|
15175
|
-
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react21.useState)(() =>
|
|
15176
|
-
const isMobileView = useIsMobileViewport();
|
|
15767
|
+
const [browserWalletChainType, setBrowserWalletChainType] = (0, import_react21.useState)(() => getStoredWalletState()?.chainType);
|
|
15177
15768
|
const [resolvedTheme, setResolvedTheme] = (0, import_react21.useState)(
|
|
15178
15769
|
theme === "auto" ? "dark" : theme
|
|
15179
15770
|
);
|
|
@@ -15205,6 +15796,15 @@ function CheckoutModal({
|
|
|
15205
15796
|
publishableKey,
|
|
15206
15797
|
enabled: open
|
|
15207
15798
|
});
|
|
15799
|
+
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
15800
|
+
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
15801
|
+
(0, import_react21.useEffect)(() => {
|
|
15802
|
+
if (view === "transfer" && !showTransferCrypto) {
|
|
15803
|
+
setView("main");
|
|
15804
|
+
} else if (view === "wallet_connect" && !showConnectWallet) {
|
|
15805
|
+
setView("main");
|
|
15806
|
+
}
|
|
15807
|
+
}, [showConnectWallet, showTransferCrypto, view]);
|
|
15208
15808
|
const prevStatusRef = (0, import_react21.useRef)(null);
|
|
15209
15809
|
(0, import_react21.useEffect)(() => {
|
|
15210
15810
|
if (!paymentIntent) return;
|
|
@@ -15295,7 +15895,7 @@ function CheckoutModal({
|
|
|
15295
15895
|
const handleBrowserWalletClick = (0, import_react21.useCallback)(
|
|
15296
15896
|
(walletInfo) => {
|
|
15297
15897
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
15298
|
-
|
|
15898
|
+
setStoredWalletState(walletInfo.type);
|
|
15299
15899
|
setBrowserWalletChainType(walletChainType);
|
|
15300
15900
|
const matchingDepositWallet = wallets.find(
|
|
15301
15901
|
(w) => w.chain_type === walletChainType
|
|
@@ -15322,7 +15922,7 @@ function CheckoutModal({
|
|
|
15322
15922
|
const handleWalletConnected = (0, import_react21.useCallback)(
|
|
15323
15923
|
(walletInfo) => {
|
|
15324
15924
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
15325
|
-
|
|
15925
|
+
setStoredWalletState(walletInfo.type);
|
|
15326
15926
|
setBrowserWalletChainType(walletChainType);
|
|
15327
15927
|
const matchingDepositWallet = wallets.find(
|
|
15328
15928
|
(w) => w.chain_type === walletChainType
|
|
@@ -15346,7 +15946,7 @@ function CheckoutModal({
|
|
|
15346
15946
|
);
|
|
15347
15947
|
const handleWalletDisconnect = (0, import_react21.useCallback)(() => {
|
|
15348
15948
|
setUserDisconnectedWallet(true);
|
|
15349
|
-
|
|
15949
|
+
clearStoredWalletState();
|
|
15350
15950
|
setBrowserWalletChainType(void 0);
|
|
15351
15951
|
setBrowserWalletInfo(null);
|
|
15352
15952
|
setBrowserWalletModalOpen(false);
|
|
@@ -15581,7 +16181,7 @@ function CheckoutModal({
|
|
|
15581
16181
|
] }) : paymentIntent ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
15582
16182
|
progressSection,
|
|
15583
16183
|
(paymentIntent.status === "requires_payment" || paymentIntent.status === "processing") && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
|
|
15584
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
16184
|
+
showTransferCrypto && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
15585
16185
|
TransferCryptoButton,
|
|
15586
16186
|
{
|
|
15587
16187
|
onClick: () => setView("transfer"),
|
|
@@ -15590,7 +16190,7 @@ function CheckoutModal({
|
|
|
15590
16190
|
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
15591
16191
|
}
|
|
15592
16192
|
),
|
|
15593
|
-
|
|
16193
|
+
showConnectWallet && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
15594
16194
|
BrowserWalletButton,
|
|
15595
16195
|
{
|
|
15596
16196
|
onClick: handleBrowserWalletClick,
|
|
@@ -15731,14 +16331,18 @@ function CheckoutModal({
|
|
|
15731
16331
|
onWalletDisconnect: handleWalletDisconnect,
|
|
15732
16332
|
onWalletConnected: (info, dw) => {
|
|
15733
16333
|
setBrowserWalletInfo({ ...info, depositWallet: dw });
|
|
15734
|
-
|
|
16334
|
+
setStoredWalletState(info.type);
|
|
15735
16335
|
setBrowserWalletChainType(dw.chain_type === "solana" ? "solana" : "ethereum");
|
|
15736
16336
|
},
|
|
15737
16337
|
onNewDeposit: () => setView("main"),
|
|
15738
16338
|
onDone: () => setView("main"),
|
|
15739
16339
|
paymentIntentStatus: paymentIntent.status,
|
|
15740
16340
|
onBack: handleBack,
|
|
15741
|
-
onClose: handleClose
|
|
16341
|
+
onClose: handleClose,
|
|
16342
|
+
defaultSourceChainType,
|
|
16343
|
+
defaultSourceChainId,
|
|
16344
|
+
defaultSourceTokenAddress,
|
|
16345
|
+
defaultSourceSymbol
|
|
15742
16346
|
}
|
|
15743
16347
|
),
|
|
15744
16348
|
poweredByFooter
|
|
@@ -15752,12 +16356,12 @@ var import_react26 = require("react");
|
|
|
15752
16356
|
var import_lucide_react33 = require("lucide-react");
|
|
15753
16357
|
|
|
15754
16358
|
// src/hooks/use-supported-destination-tokens.ts
|
|
15755
|
-
var
|
|
15756
|
-
var
|
|
16359
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
16360
|
+
var import_core32 = require("@unifold/core");
|
|
15757
16361
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
15758
|
-
return (0,
|
|
16362
|
+
return (0, import_react_query15.useQuery)({
|
|
15759
16363
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
15760
|
-
queryFn: () => (0,
|
|
16364
|
+
queryFn: () => (0, import_core32.getSupportedDestinationTokens)(publishableKey),
|
|
15761
16365
|
staleTime: 1e3 * 60 * 5,
|
|
15762
16366
|
gcTime: 1e3 * 60 * 30,
|
|
15763
16367
|
refetchOnMount: false,
|
|
@@ -15784,8 +16388,8 @@ function useDefaultDestinationToken({
|
|
|
15784
16388
|
}
|
|
15785
16389
|
|
|
15786
16390
|
// src/hooks/use-source-token-validation.ts
|
|
15787
|
-
var
|
|
15788
|
-
var
|
|
16391
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
16392
|
+
var import_core33 = require("@unifold/core");
|
|
15789
16393
|
function useSourceTokenValidation(params) {
|
|
15790
16394
|
const {
|
|
15791
16395
|
sourceChainType,
|
|
@@ -15796,7 +16400,7 @@ function useSourceTokenValidation(params) {
|
|
|
15796
16400
|
enabled = true
|
|
15797
16401
|
} = params;
|
|
15798
16402
|
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
15799
|
-
return (0,
|
|
16403
|
+
return (0, import_react_query16.useQuery)({
|
|
15800
16404
|
queryKey: [
|
|
15801
16405
|
"unifold",
|
|
15802
16406
|
"sourceTokenValidation",
|
|
@@ -15806,7 +16410,7 @@ function useSourceTokenValidation(params) {
|
|
|
15806
16410
|
publishableKey
|
|
15807
16411
|
],
|
|
15808
16412
|
queryFn: async () => {
|
|
15809
|
-
const res = await (0,
|
|
16413
|
+
const res = await (0, import_core33.getSupportedDepositTokens)(publishableKey);
|
|
15810
16414
|
let matchedMinUsd = null;
|
|
15811
16415
|
let matchedProcessingTime = null;
|
|
15812
16416
|
let matchedSlippage = null;
|
|
@@ -15844,8 +16448,8 @@ function useSourceTokenValidation(params) {
|
|
|
15844
16448
|
}
|
|
15845
16449
|
|
|
15846
16450
|
// src/hooks/use-address-balance.ts
|
|
15847
|
-
var
|
|
15848
|
-
var
|
|
16451
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
16452
|
+
var import_core34 = require("@unifold/core");
|
|
15849
16453
|
function useAddressBalance(params) {
|
|
15850
16454
|
const {
|
|
15851
16455
|
address,
|
|
@@ -15856,7 +16460,7 @@ function useAddressBalance(params) {
|
|
|
15856
16460
|
enabled = true
|
|
15857
16461
|
} = params;
|
|
15858
16462
|
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
15859
|
-
return (0,
|
|
16463
|
+
return (0, import_react_query17.useQuery)({
|
|
15860
16464
|
queryKey: [
|
|
15861
16465
|
"unifold",
|
|
15862
16466
|
"addressBalance",
|
|
@@ -15867,7 +16471,7 @@ function useAddressBalance(params) {
|
|
|
15867
16471
|
publishableKey
|
|
15868
16472
|
],
|
|
15869
16473
|
queryFn: async () => {
|
|
15870
|
-
const res = await (0,
|
|
16474
|
+
const res = await (0, import_core34.getAddressBalance)(
|
|
15871
16475
|
address,
|
|
15872
16476
|
chainType,
|
|
15873
16477
|
chainId,
|
|
@@ -15905,13 +16509,13 @@ function useAddressBalance(params) {
|
|
|
15905
16509
|
}
|
|
15906
16510
|
|
|
15907
16511
|
// src/hooks/use-executions.ts
|
|
15908
|
-
var
|
|
15909
|
-
var
|
|
16512
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
16513
|
+
var import_core35 = require("@unifold/core");
|
|
15910
16514
|
function useExecutions(userId, publishableKey, options) {
|
|
15911
|
-
const actionType = options?.actionType ??
|
|
15912
|
-
return (0,
|
|
16515
|
+
const actionType = options?.actionType ?? import_core35.ActionType.Deposit;
|
|
16516
|
+
return (0, import_react_query18.useQuery)({
|
|
15913
16517
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
15914
|
-
queryFn: () => (0,
|
|
16518
|
+
queryFn: () => (0, import_core35.queryExecutions)(userId, publishableKey, actionType),
|
|
15915
16519
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
15916
16520
|
refetchInterval: options?.refetchInterval ?? 3e3,
|
|
15917
16521
|
staleTime: 0,
|
|
@@ -15922,7 +16526,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
15922
16526
|
|
|
15923
16527
|
// src/hooks/use-withdraw-polling.ts
|
|
15924
16528
|
var import_react22 = require("react");
|
|
15925
|
-
var
|
|
16529
|
+
var import_core36 = require("@unifold/core");
|
|
15926
16530
|
var POLL_INTERVAL_MS3 = 2500;
|
|
15927
16531
|
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
15928
16532
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
@@ -15962,15 +16566,15 @@ function useWithdrawPolling({
|
|
|
15962
16566
|
const enabledAt = enabledAtRef.current;
|
|
15963
16567
|
const poll = async () => {
|
|
15964
16568
|
try {
|
|
15965
|
-
const response = await (0,
|
|
16569
|
+
const response = await (0, import_core36.queryExecutions)(userId, publishableKey, import_core36.ActionType.Withdraw);
|
|
15966
16570
|
const cutoff = new Date(enabledAt.getTime() - CUTOFF_BUFFER_MS2);
|
|
15967
16571
|
const sorted = [...response.data].sort((a, b) => {
|
|
15968
16572
|
const tA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
15969
16573
|
const tB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
15970
16574
|
return tB - tA;
|
|
15971
16575
|
});
|
|
15972
|
-
const inProgress = [
|
|
15973
|
-
const terminal = [
|
|
16576
|
+
const inProgress = [import_core36.ExecutionStatus.PENDING, import_core36.ExecutionStatus.WAITING, import_core36.ExecutionStatus.DELAYED];
|
|
16577
|
+
const terminal = [import_core36.ExecutionStatus.SUCCEEDED, import_core36.ExecutionStatus.FAILED];
|
|
15974
16578
|
let target = null;
|
|
15975
16579
|
for (const ex of sorted) {
|
|
15976
16580
|
const t12 = ex.created_at ? new Date(ex.created_at) : null;
|
|
@@ -16000,9 +16604,9 @@ function useWithdrawPolling({
|
|
|
16000
16604
|
}
|
|
16001
16605
|
return [...list, ex];
|
|
16002
16606
|
});
|
|
16003
|
-
if (ex.status ===
|
|
16607
|
+
if (ex.status === import_core36.ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
|
|
16004
16608
|
onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
|
|
16005
|
-
} else if (ex.status ===
|
|
16609
|
+
} else if (ex.status === import_core36.ExecutionStatus.FAILED && prev !== import_core36.ExecutionStatus.FAILED) {
|
|
16006
16610
|
onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
|
|
16007
16611
|
}
|
|
16008
16612
|
}
|
|
@@ -16023,7 +16627,7 @@ function useWithdrawPolling({
|
|
|
16023
16627
|
if (!enabled || !depositWalletId) return;
|
|
16024
16628
|
const trigger = async () => {
|
|
16025
16629
|
try {
|
|
16026
|
-
await (0,
|
|
16630
|
+
await (0, import_core36.pollDirectExecutions)({ deposit_wallet_id: depositWalletId }, publishableKey);
|
|
16027
16631
|
} catch {
|
|
16028
16632
|
}
|
|
16029
16633
|
};
|
|
@@ -16192,11 +16796,11 @@ function WithdrawDoubleInput({
|
|
|
16192
16796
|
// src/components/withdrawals/WithdrawForm.tsx
|
|
16193
16797
|
var import_react24 = require("react");
|
|
16194
16798
|
var import_lucide_react31 = require("lucide-react");
|
|
16195
|
-
var
|
|
16799
|
+
var import_core41 = require("@unifold/core");
|
|
16196
16800
|
|
|
16197
16801
|
// src/hooks/use-verify-recipient-address.ts
|
|
16198
|
-
var
|
|
16199
|
-
var
|
|
16802
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
16803
|
+
var import_core37 = require("@unifold/core");
|
|
16200
16804
|
function useVerifyRecipientAddress(params) {
|
|
16201
16805
|
const {
|
|
16202
16806
|
chainType,
|
|
@@ -16208,7 +16812,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
16208
16812
|
} = params;
|
|
16209
16813
|
const trimmedAddress = recipientAddress?.trim() || "";
|
|
16210
16814
|
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
16211
|
-
return (0,
|
|
16815
|
+
return (0, import_react_query19.useQuery)({
|
|
16212
16816
|
queryKey: [
|
|
16213
16817
|
"unifold",
|
|
16214
16818
|
"verifyRecipientAddress",
|
|
@@ -16218,7 +16822,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
16218
16822
|
trimmedAddress,
|
|
16219
16823
|
publishableKey
|
|
16220
16824
|
],
|
|
16221
|
-
queryFn: () => (0,
|
|
16825
|
+
queryFn: () => (0, import_core37.verifyRecipientAddress)(
|
|
16222
16826
|
{
|
|
16223
16827
|
chain_type: chainType,
|
|
16224
16828
|
chain_id: chainId,
|
|
@@ -16237,7 +16841,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
16237
16841
|
}
|
|
16238
16842
|
|
|
16239
16843
|
// src/components/withdrawals/send-withdraw.ts
|
|
16240
|
-
var
|
|
16844
|
+
var import_core38 = require("@unifold/core");
|
|
16241
16845
|
async function sendEvmWithdraw(params) {
|
|
16242
16846
|
const {
|
|
16243
16847
|
provider,
|
|
@@ -16315,7 +16919,7 @@ async function sendSolanaWithdraw(params) {
|
|
|
16315
16919
|
if (!provider.publicKey) {
|
|
16316
16920
|
await provider.connect();
|
|
16317
16921
|
}
|
|
16318
|
-
const buildResponse = await (0,
|
|
16922
|
+
const buildResponse = await (0, import_core38.buildSolanaTransaction)(
|
|
16319
16923
|
{
|
|
16320
16924
|
chain_id: "mainnet",
|
|
16321
16925
|
token_address: sourceTokenAddress === "" ? "native" : sourceTokenAddress,
|
|
@@ -16341,7 +16945,7 @@ async function sendSolanaWithdraw(params) {
|
|
|
16341
16945
|
for (let i = 0; i < serialized.length; i++) {
|
|
16342
16946
|
binaryStr += String.fromCharCode(serialized[i]);
|
|
16343
16947
|
}
|
|
16344
|
-
const sendResponse = await (0,
|
|
16948
|
+
const sendResponse = await (0, import_core38.sendSolanaTransaction)(
|
|
16345
16949
|
{ chain_id: "mainnet", signed_transaction: btoa(binaryStr) },
|
|
16346
16950
|
publishableKey
|
|
16347
16951
|
);
|
|
@@ -16367,7 +16971,7 @@ async function sendHypercoreWithdraw(params) {
|
|
|
16367
16971
|
params: []
|
|
16368
16972
|
});
|
|
16369
16973
|
const activeChainId = String(parseInt(currentChainHex, 16));
|
|
16370
|
-
const buildResult = await (0,
|
|
16974
|
+
const buildResult = await (0, import_core38.buildHypercoreTransaction)(
|
|
16371
16975
|
{
|
|
16372
16976
|
action_type: isSpot ? "spot_send" : "usd_send",
|
|
16373
16977
|
signature_chain_type: "ethereum",
|
|
@@ -16383,7 +16987,7 @@ async function sendHypercoreWithdraw(params) {
|
|
|
16383
16987
|
method: "eth_signTypedData_v4",
|
|
16384
16988
|
params: [fromAddress, JSON.stringify(buildResult.typed_data)]
|
|
16385
16989
|
});
|
|
16386
|
-
await (0,
|
|
16990
|
+
await (0, import_core38.sendHypercoreTransaction)(
|
|
16387
16991
|
{
|
|
16388
16992
|
action_payload: buildResult.action_payload,
|
|
16389
16993
|
signature,
|
|
@@ -16472,11 +17076,11 @@ async function detectBrowserWallet(chainType, senderAddress) {
|
|
|
16472
17076
|
|
|
16473
17077
|
// src/hooks/use-hypercore-withdraw-activation.ts
|
|
16474
17078
|
var import_react23 = require("react");
|
|
16475
|
-
var
|
|
17079
|
+
var import_core40 = require("@unifold/core");
|
|
16476
17080
|
|
|
16477
17081
|
// src/hooks/use-get-deposit-address.ts
|
|
16478
|
-
var
|
|
16479
|
-
var
|
|
17082
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
17083
|
+
var import_core39 = require("@unifold/core");
|
|
16480
17084
|
function useGetDepositAddress(params) {
|
|
16481
17085
|
const {
|
|
16482
17086
|
userId,
|
|
@@ -16489,7 +17093,7 @@ function useGetDepositAddress(params) {
|
|
|
16489
17093
|
enabled = true
|
|
16490
17094
|
} = params;
|
|
16491
17095
|
const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
16492
|
-
return (0,
|
|
17096
|
+
return (0, import_react_query20.useQuery)({
|
|
16493
17097
|
queryKey: [
|
|
16494
17098
|
"unifold",
|
|
16495
17099
|
"getDepositAddress",
|
|
@@ -16501,7 +17105,7 @@ function useGetDepositAddress(params) {
|
|
|
16501
17105
|
actionType ?? null,
|
|
16502
17106
|
publishableKey
|
|
16503
17107
|
],
|
|
16504
|
-
queryFn: () => (0,
|
|
17108
|
+
queryFn: () => (0, import_core39.getDepositAddress)(
|
|
16505
17109
|
{
|
|
16506
17110
|
external_user_id: userId,
|
|
16507
17111
|
recipient_address: recipientAddress,
|
|
@@ -16555,7 +17159,7 @@ function useHypercoreWithdrawActivation(params) {
|
|
|
16555
17159
|
destinationChainType,
|
|
16556
17160
|
destinationChainId,
|
|
16557
17161
|
destinationTokenAddress,
|
|
16558
|
-
actionType:
|
|
17162
|
+
actionType: import_core40.ActionType.Withdraw,
|
|
16559
17163
|
enabled: enabled && isHypercore(sourceChainId)
|
|
16560
17164
|
});
|
|
16561
17165
|
const depositWalletAddress = (0, import_react23.useMemo)(() => {
|
|
@@ -16824,7 +17428,7 @@ function WithdrawForm({
|
|
|
16824
17428
|
let humanAmount = isMaxed ? balanceData.balanceHuman : toSafeDecimalString(cryptoAmountFromInput, sourceDecimals);
|
|
16825
17429
|
if (isHypercoreChain(sourceChainId)) {
|
|
16826
17430
|
try {
|
|
16827
|
-
const check = await (0,
|
|
17431
|
+
const check = await (0, import_core41.checkHypercoreActivation)(
|
|
16828
17432
|
{
|
|
16829
17433
|
source_address: senderAddress,
|
|
16830
17434
|
recipient_address: depositWallet.address
|
|
@@ -17141,14 +17745,14 @@ function WithdrawForm({
|
|
|
17141
17745
|
|
|
17142
17746
|
// src/components/withdrawals/WithdrawExecutionItem.tsx
|
|
17143
17747
|
var import_lucide_react32 = require("lucide-react");
|
|
17144
|
-
var
|
|
17748
|
+
var import_core42 = require("@unifold/core");
|
|
17145
17749
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
17146
17750
|
function WithdrawExecutionItem({
|
|
17147
17751
|
execution,
|
|
17148
17752
|
onClick
|
|
17149
17753
|
}) {
|
|
17150
17754
|
const { colors: colors2, fonts, components } = useTheme();
|
|
17151
|
-
const isPending = execution.status ===
|
|
17755
|
+
const isPending = execution.status === import_core42.ExecutionStatus.PENDING || execution.status === import_core42.ExecutionStatus.WAITING || execution.status === import_core42.ExecutionStatus.DELAYED;
|
|
17152
17756
|
const formatDateTime = (timestamp) => {
|
|
17153
17757
|
try {
|
|
17154
17758
|
const date = new Date(timestamp);
|
|
@@ -17195,7 +17799,7 @@ function WithdrawExecutionItem({
|
|
|
17195
17799
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
17196
17800
|
"img",
|
|
17197
17801
|
{
|
|
17198
|
-
src: execution.destination_token_metadata?.icon_url || (0,
|
|
17802
|
+
src: execution.destination_token_metadata?.icon_url || (0, import_core42.getIconUrl)("/icons/tokens/svg/usdc.svg"),
|
|
17199
17803
|
alt: "Token",
|
|
17200
17804
|
width: 36,
|
|
17201
17805
|
height: 36,
|
|
@@ -17454,7 +18058,7 @@ function WithdrawConfirmingView({
|
|
|
17454
18058
|
}
|
|
17455
18059
|
|
|
17456
18060
|
// src/components/withdrawals/WithdrawModal.tsx
|
|
17457
|
-
var
|
|
18061
|
+
var import_core43 = require("@unifold/core");
|
|
17458
18062
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
17459
18063
|
var t10 = i18n.withdrawModal;
|
|
17460
18064
|
var getChainKey5 = (chainId, chainType) => `${chainType}:${chainId}`;
|
|
@@ -17545,25 +18149,25 @@ function WithdrawModal({
|
|
|
17545
18149
|
onWithdrawError
|
|
17546
18150
|
});
|
|
17547
18151
|
const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
|
|
17548
|
-
actionType:
|
|
18152
|
+
actionType: import_core43.ActionType.Withdraw,
|
|
17549
18153
|
enabled: open,
|
|
17550
18154
|
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
17551
18155
|
});
|
|
17552
18156
|
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
17553
18157
|
const handleDepositWalletCreation = (0, import_react26.useCallback)(async (params) => {
|
|
17554
|
-
const { data: wallets } = await (0,
|
|
18158
|
+
const { data: wallets } = await (0, import_core43.createDepositAddress)(
|
|
17555
18159
|
{
|
|
17556
18160
|
external_user_id: externalUserId,
|
|
17557
18161
|
destination_chain_type: params.destinationChainType,
|
|
17558
18162
|
destination_chain_id: params.destinationChainId,
|
|
17559
18163
|
destination_token_address: params.destinationTokenAddress,
|
|
17560
18164
|
recipient_address: params.recipientAddress,
|
|
17561
|
-
action_type:
|
|
18165
|
+
action_type: import_core43.ActionType.Withdraw,
|
|
17562
18166
|
source_chain_type: sourceChainType
|
|
17563
18167
|
},
|
|
17564
18168
|
publishableKey
|
|
17565
18169
|
);
|
|
17566
|
-
const depositWallet = (0,
|
|
18170
|
+
const depositWallet = (0, import_core43.getWalletByChainType)(wallets, sourceChainType);
|
|
17567
18171
|
if (!depositWallet) {
|
|
17568
18172
|
throw new Error(`No deposit wallet available for ${sourceChainType}`);
|
|
17569
18173
|
}
|