@unifold/ui-react 0.1.64 → 0.1.66
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 +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +417 -218
- package/dist/index.mjs +363 -162
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -205,6 +205,22 @@ function clearStoredWalletState() {
|
|
|
205
205
|
} catch {
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
+
var LAST_OPENED_WALLET_KEY = "unifold_last_opened_wallet";
|
|
209
|
+
function getLastOpenedWallet() {
|
|
210
|
+
if (typeof window === "undefined") return void 0;
|
|
211
|
+
try {
|
|
212
|
+
return localStorage.getItem(LAST_OPENED_WALLET_KEY) ?? void 0;
|
|
213
|
+
} catch {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function setLastOpenedWallet(walletId) {
|
|
218
|
+
if (typeof window === "undefined") return;
|
|
219
|
+
try {
|
|
220
|
+
localStorage.setItem(LAST_OPENED_WALLET_KEY, walletId);
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
208
224
|
var MOBILE_VIEWPORT_MEDIA_QUERY = "(max-width: 768px)";
|
|
209
225
|
function isMobileViewport() {
|
|
210
226
|
if (typeof window === "undefined") return false;
|
|
@@ -1052,7 +1068,7 @@ function DepositHeader({
|
|
|
1052
1068
|
setShowBalanceSkeleton(false);
|
|
1053
1069
|
return;
|
|
1054
1070
|
}
|
|
1055
|
-
const supportedChainTypes = ["ethereum", "solana", "bitcoin"];
|
|
1071
|
+
const supportedChainTypes = ["ethereum", "solana", "bitcoin", "n1"];
|
|
1056
1072
|
if (!supportedChainTypes.includes(
|
|
1057
1073
|
balanceChainType
|
|
1058
1074
|
)) {
|
|
@@ -10110,7 +10126,7 @@ function useDefaultOnrampToken({
|
|
|
10110
10126
|
}
|
|
10111
10127
|
|
|
10112
10128
|
// src/components/deposits/DepositModal.tsx
|
|
10113
|
-
var
|
|
10129
|
+
var import_core31 = require("@unifold/core");
|
|
10114
10130
|
|
|
10115
10131
|
// src/hooks/use-allowed-country.ts
|
|
10116
10132
|
var import_react_query9 = require("@tanstack/react-query");
|
|
@@ -11381,7 +11397,7 @@ function useHypercoreActivation(params) {
|
|
|
11381
11397
|
publishableKey,
|
|
11382
11398
|
enabled = true
|
|
11383
11399
|
} = params;
|
|
11384
|
-
const isHypercore2 = destinationChainId === HYPERCORE_CHAIN_ID;
|
|
11400
|
+
const isHypercore2 = String(destinationChainId) === HYPERCORE_CHAIN_ID;
|
|
11385
11401
|
const recipient = recipientAddress?.trim() ?? "";
|
|
11386
11402
|
const source = sourceAddress?.trim() ?? "";
|
|
11387
11403
|
const hasAddresses = !!recipient && !!source;
|
|
@@ -12553,11 +12569,54 @@ function TransferCryptoDoubleInput({
|
|
|
12553
12569
|
// src/components/deposits/WalletConnect.tsx
|
|
12554
12570
|
var React30 = __toESM(require("react"));
|
|
12555
12571
|
var import_lucide_react28 = require("lucide-react");
|
|
12556
|
-
var
|
|
12572
|
+
var import_core30 = require("@unifold/core");
|
|
12573
|
+
|
|
12574
|
+
// src/lib/send-hypercore.ts
|
|
12575
|
+
var import_core27 = require("@unifold/core");
|
|
12576
|
+
function isHypercoreChain(chainId) {
|
|
12577
|
+
return chainId === HYPERCORE_CHAIN_ID;
|
|
12578
|
+
}
|
|
12579
|
+
async function sendHypercoreEvmTransfer(params) {
|
|
12580
|
+
const {
|
|
12581
|
+
provider,
|
|
12582
|
+
fromAddress,
|
|
12583
|
+
recipientAddress,
|
|
12584
|
+
sourceTokenAddress,
|
|
12585
|
+
amount,
|
|
12586
|
+
publishableKey
|
|
12587
|
+
} = params;
|
|
12588
|
+
const currentChainHex = await provider.request({
|
|
12589
|
+
method: "eth_chainId",
|
|
12590
|
+
params: []
|
|
12591
|
+
});
|
|
12592
|
+
const activeChainId = String(parseInt(currentChainHex, 16));
|
|
12593
|
+
const buildResult = await (0, import_core27.buildHypercoreTransaction)(
|
|
12594
|
+
{
|
|
12595
|
+
signature_chain_id: activeChainId,
|
|
12596
|
+
recipient_address: recipientAddress,
|
|
12597
|
+
token_address: sourceTokenAddress,
|
|
12598
|
+
amount
|
|
12599
|
+
},
|
|
12600
|
+
publishableKey
|
|
12601
|
+
);
|
|
12602
|
+
const signature = await provider.request({
|
|
12603
|
+
method: "eth_signTypedData_v4",
|
|
12604
|
+
params: [fromAddress, JSON.stringify(buildResult.typed_data)]
|
|
12605
|
+
});
|
|
12606
|
+
await (0, import_core27.sendHypercoreTransaction)(
|
|
12607
|
+
{
|
|
12608
|
+
action_payload: buildResult.action_payload,
|
|
12609
|
+
signature,
|
|
12610
|
+
nonce: buildResult.nonce
|
|
12611
|
+
},
|
|
12612
|
+
publishableKey
|
|
12613
|
+
);
|
|
12614
|
+
return { signature };
|
|
12615
|
+
}
|
|
12557
12616
|
|
|
12558
12617
|
// src/hooks/use-deposit-quote.ts
|
|
12559
12618
|
var import_react_query12 = require("@tanstack/react-query");
|
|
12560
|
-
var
|
|
12619
|
+
var import_core28 = require("@unifold/core");
|
|
12561
12620
|
function useDepositQuote(params) {
|
|
12562
12621
|
const {
|
|
12563
12622
|
publishableKey,
|
|
@@ -12598,7 +12657,7 @@ function useDepositQuote(params) {
|
|
|
12598
12657
|
stablecoinParity,
|
|
12599
12658
|
publishableKey
|
|
12600
12659
|
],
|
|
12601
|
-
queryFn: () => (0,
|
|
12660
|
+
queryFn: () => (0, import_core28.getDepositQuote)(request, publishableKey),
|
|
12602
12661
|
enabled: enabled && !!publishableKey && !!sourceChainType && !!sourceChainId && !!sourceTokenAddress && !!destinationAmount && destinationAmount !== "0" && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress,
|
|
12603
12662
|
staleTime: 3e4,
|
|
12604
12663
|
gcTime: 5 * 6e4,
|
|
@@ -12612,14 +12671,14 @@ function useDepositQuote(params) {
|
|
|
12612
12671
|
|
|
12613
12672
|
// src/hooks/use-external-wallets.ts
|
|
12614
12673
|
var import_react_query13 = require("@tanstack/react-query");
|
|
12615
|
-
var
|
|
12674
|
+
var import_core29 = require("@unifold/core");
|
|
12616
12675
|
function useExternalWallets({
|
|
12617
12676
|
publishableKey,
|
|
12618
12677
|
enabled = true
|
|
12619
12678
|
}) {
|
|
12620
12679
|
const { data: wallets = [], isLoading } = (0, import_react_query13.useQuery)({
|
|
12621
12680
|
queryKey: ["unifold", "external-wallets", publishableKey],
|
|
12622
|
-
queryFn: () => (0,
|
|
12681
|
+
queryFn: () => (0, import_core29.getExternalWallets)(publishableKey).then((res) => res.data),
|
|
12623
12682
|
enabled: enabled && !!publishableKey,
|
|
12624
12683
|
staleTime: 1e3 * 60 * 30,
|
|
12625
12684
|
refetchOnMount: false,
|
|
@@ -12985,7 +13044,8 @@ function EnterAmountView({
|
|
|
12985
13044
|
onClose,
|
|
12986
13045
|
quickSelectMode,
|
|
12987
13046
|
checkoutAmountUsd,
|
|
12988
|
-
checkoutReceivedUsd
|
|
13047
|
+
checkoutReceivedUsd,
|
|
13048
|
+
footer
|
|
12989
13049
|
}) {
|
|
12990
13050
|
const { colors: colors2, fonts, components } = useTheme();
|
|
12991
13051
|
const isCheckout = !!checkoutAmountUsd;
|
|
@@ -13241,6 +13301,7 @@ function EnterAmountView({
|
|
|
13241
13301
|
)
|
|
13242
13302
|
] })
|
|
13243
13303
|
] }),
|
|
13304
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "uf-shrink-0 uf-pt-2", children: footer }),
|
|
13244
13305
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "uf-shrink-0 uf-pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
13245
13306
|
"button",
|
|
13246
13307
|
{
|
|
@@ -13702,7 +13763,7 @@ var WALLET_ICONS3 = {
|
|
|
13702
13763
|
};
|
|
13703
13764
|
var FALLBACK_WALLET_DEFINITIONS = [
|
|
13704
13765
|
{ id: "phantom", name: "Phantom", networks: ["ethereum", "solana"], installUrl: "https://phantom.app/", supportsMobileBrowse: true },
|
|
13705
|
-
{ id: "coinbase", name: "Coinbase Wallet", networks: ["ethereum"
|
|
13766
|
+
{ id: "coinbase", name: "Coinbase Wallet", networks: ["ethereum"], installUrl: "https://www.coinbase.com/wallet", supportsMobileBrowse: true },
|
|
13706
13767
|
{ id: "trust", name: "Trust Wallet", networks: ["ethereum", "solana"], installUrl: "https://trustwallet.com/", supportsMobileBrowse: true },
|
|
13707
13768
|
{ id: "metamask", name: "MetaMask", networks: ["ethereum"], installUrl: "https://metamask.io/download/", supportsMobileBrowse: true },
|
|
13708
13769
|
{ id: "rainbow", name: "Rainbow", networks: ["ethereum"], installUrl: "https://rainbow.me/", supportsMobileBrowse: true },
|
|
@@ -13762,7 +13823,7 @@ function getLegacyEvmProviders() {
|
|
|
13762
13823
|
okxEthereum: win.okxwallet
|
|
13763
13824
|
};
|
|
13764
13825
|
}
|
|
13765
|
-
function detectAvailableWallets(definitions, filterChainType) {
|
|
13826
|
+
function detectAvailableWallets(definitions, recentWalletId, filterChainType) {
|
|
13766
13827
|
const solProviders = getSolanaProviders();
|
|
13767
13828
|
const legacyEvm = getLegacyEvmProviders();
|
|
13768
13829
|
const eip6963List = getEip6963Providers();
|
|
@@ -13788,7 +13849,7 @@ function detectAvailableWallets(definitions, filterChainType) {
|
|
|
13788
13849
|
return false;
|
|
13789
13850
|
}
|
|
13790
13851
|
});
|
|
13791
|
-
|
|
13852
|
+
const sorted = definitions.filter((w) => !filterChainType || w.networks.includes(filterChainType)).map((wallet) => {
|
|
13792
13853
|
let isInstalled = false;
|
|
13793
13854
|
const detectedNetworks = [];
|
|
13794
13855
|
switch (wallet.id) {
|
|
@@ -13811,8 +13872,6 @@ function detectAvailableWallets(definitions, filterChainType) {
|
|
|
13811
13872
|
isInstalled = true;
|
|
13812
13873
|
detectedNetworks.push("ethereum");
|
|
13813
13874
|
}
|
|
13814
|
-
if (solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana) detectedNetworks.push("solana");
|
|
13815
|
-
if (isInstalled && wallet.networks.includes("solana") && !detectedNetworks.includes("solana")) detectedNetworks.push("solana");
|
|
13816
13875
|
break;
|
|
13817
13876
|
case "trust":
|
|
13818
13877
|
if (hasEip6963("trust") || legacyEvm.trustEthereum || legacyEvm.ethereum?.isTrust || win?.trustwallet) {
|
|
@@ -13849,11 +13908,17 @@ function detectAvailableWallets(definitions, filterChainType) {
|
|
|
13849
13908
|
}
|
|
13850
13909
|
return { ...wallet, isInstalled, detectedNetworks };
|
|
13851
13910
|
}).sort((a, b) => {
|
|
13911
|
+
if (recentWalletId) {
|
|
13912
|
+
const aRecent = a.id === recentWalletId ? 1 : 0;
|
|
13913
|
+
const bRecent = b.id === recentWalletId ? 1 : 0;
|
|
13914
|
+
if (aRecent !== bRecent) return bRecent - aRecent;
|
|
13915
|
+
}
|
|
13852
13916
|
if (a.isInstalled && !b.isInstalled) return -1;
|
|
13853
13917
|
if (!a.isInstalled && b.isInstalled) return 1;
|
|
13854
13918
|
if (a.isInstalled && b.isInstalled) return b.networks.length - a.networks.length;
|
|
13855
13919
|
return 0;
|
|
13856
13920
|
});
|
|
13921
|
+
return sorted;
|
|
13857
13922
|
}
|
|
13858
13923
|
function WalletConnect({
|
|
13859
13924
|
walletInfo: initialWalletInfo,
|
|
@@ -13928,9 +13993,15 @@ function WalletConnect({
|
|
|
13928
13993
|
})) : FALLBACK_WALLET_DEFINITIONS,
|
|
13929
13994
|
[backendWallets]
|
|
13930
13995
|
);
|
|
13996
|
+
const [recentWalletId, setRecentWalletIdState] = React30.useState(getLastOpenedWallet);
|
|
13997
|
+
React30.useEffect(() => {
|
|
13998
|
+
if (view === "select_wallet") {
|
|
13999
|
+
setRecentWalletIdState(getLastOpenedWallet());
|
|
14000
|
+
}
|
|
14001
|
+
}, [view]);
|
|
13931
14002
|
const availableWallets = React30.useMemo(
|
|
13932
|
-
() => detectAvailableWallets(walletDefinitions),
|
|
13933
|
-
[walletDefinitions, eip6963ProviderCount]
|
|
14003
|
+
() => detectAvailableWallets(walletDefinitions, recentWalletId),
|
|
14004
|
+
[walletDefinitions, eip6963ProviderCount, recentWalletId]
|
|
13934
14005
|
);
|
|
13935
14006
|
const [isMobile, setIsMobile] = React30.useState(false);
|
|
13936
14007
|
React30.useEffect(() => {
|
|
@@ -13990,7 +14061,7 @@ function WalletConnect({
|
|
|
13990
14061
|
const chainType = activeDepositWallet?.chain_type ?? "ethereum";
|
|
13991
14062
|
const recipientAddress = activeDepositWallet?.address ?? "";
|
|
13992
14063
|
const isCheckoutMode = !!checkoutAmountUsd;
|
|
13993
|
-
const supportedChainType = chainType === "algorand" || chainType === "xrpl" ? "ethereum" : chainType;
|
|
14064
|
+
const supportedChainType = chainType === "algorand" || chainType === "xrpl" || chainType === "cardano" || chainType === "n1" ? "ethereum" : chainType;
|
|
13994
14065
|
const transitionTo = React30.useCallback((nextView) => {
|
|
13995
14066
|
if (nextView === viewRef.current) return;
|
|
13996
14067
|
setIsTransitioning(true);
|
|
@@ -14007,13 +14078,15 @@ function WalletConnect({
|
|
|
14007
14078
|
};
|
|
14008
14079
|
const openMobileWalletBrowse = async (wallet, depositAddresses) => {
|
|
14009
14080
|
try {
|
|
14010
|
-
const res = await (0,
|
|
14081
|
+
const res = await (0, import_core30.getWalletMobileDeepLink)(
|
|
14011
14082
|
wallet.id,
|
|
14012
14083
|
depositAddresses,
|
|
14013
14084
|
publishableKey
|
|
14014
14085
|
);
|
|
14015
14086
|
if (res.deeplink) {
|
|
14016
14087
|
setMobileRedirect({ walletId: wallet.id, walletName: wallet.name, deeplink: res.deeplink });
|
|
14088
|
+
setLastOpenedWallet(wallet.id);
|
|
14089
|
+
setRecentWalletIdState(wallet.id);
|
|
14017
14090
|
setAwaitingMobileDeposit(true);
|
|
14018
14091
|
transitionTo("mobile_redirect");
|
|
14019
14092
|
window.location.href = res.deeplink;
|
|
@@ -14074,6 +14147,8 @@ function WalletConnect({
|
|
|
14074
14147
|
const handleConnectWallet = async (wallet, network) => {
|
|
14075
14148
|
setConnectingNetwork(network);
|
|
14076
14149
|
transitionTo("connecting");
|
|
14150
|
+
setLastOpenedWallet(wallet.id);
|
|
14151
|
+
setRecentWalletIdState(wallet.id);
|
|
14077
14152
|
setWalletError(null);
|
|
14078
14153
|
setIsWalletConnecting(true);
|
|
14079
14154
|
try {
|
|
@@ -14178,6 +14253,13 @@ function WalletConnect({
|
|
|
14178
14253
|
}
|
|
14179
14254
|
};
|
|
14180
14255
|
const selectedToken = selectedBalance ? getTokenFromBalance(selectedBalance) : null;
|
|
14256
|
+
const { needsActivation: hypercoreNeedsActivation, activationFee: hypercoreActivationFee, sponsored: hypercoreActivationSponsored } = useHypercoreActivation({
|
|
14257
|
+
recipientAddress,
|
|
14258
|
+
sourceAddress: activeWalletInfo?.address,
|
|
14259
|
+
destinationChainId: selectedToken?.chain_id,
|
|
14260
|
+
publishableKey,
|
|
14261
|
+
enabled: !!activeWalletInfo && !!recipientAddress
|
|
14262
|
+
});
|
|
14181
14263
|
const effectiveDestinationAmount = React30.useMemo(() => {
|
|
14182
14264
|
if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
|
|
14183
14265
|
if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
|
|
@@ -14259,7 +14341,7 @@ function WalletConnect({
|
|
|
14259
14341
|
const token = getTokenFromBalance(selectedBalance);
|
|
14260
14342
|
if (!token) return;
|
|
14261
14343
|
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 } : {} };
|
|
14262
|
-
const response = await (0,
|
|
14344
|
+
const response = await (0, import_core30.getSupportedDepositTokens)(publishableKey, options);
|
|
14263
14345
|
if (cancelled) return;
|
|
14264
14346
|
const supportedToken = response.data.find((t12) => t12.symbol.toLowerCase() === token.symbol.toLowerCase());
|
|
14265
14347
|
if (supportedToken) {
|
|
@@ -14282,8 +14364,8 @@ function WalletConnect({
|
|
|
14282
14364
|
let cancelled = false;
|
|
14283
14365
|
setIsLoading(true);
|
|
14284
14366
|
setError(null);
|
|
14285
|
-
const sct = activeDepositWallet.chain_type === "algorand" || activeDepositWallet.chain_type === "xrpl" ? "ethereum" : activeDepositWallet.chain_type;
|
|
14286
|
-
(0,
|
|
14367
|
+
const sct = activeDepositWallet.chain_type === "algorand" || activeDepositWallet.chain_type === "xrpl" || activeDepositWallet.chain_type === "cardano" || activeDepositWallet.chain_type === "n1" ? "ethereum" : activeDepositWallet.chain_type;
|
|
14368
|
+
(0, import_core30.getAddressBalances)(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
14287
14369
|
if (cancelled) return;
|
|
14288
14370
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
14289
14371
|
const defaultSource = {
|
|
@@ -14448,9 +14530,16 @@ function WalletConnect({
|
|
|
14448
14530
|
const [integerPart = "0", decimalPart = ""] = amountStr.trim().split(".");
|
|
14449
14531
|
return (integerPart + decimalPart.padEnd(decimals, "0").slice(0, decimals)).replace(/^0+/, "") || "0";
|
|
14450
14532
|
};
|
|
14451
|
-
const
|
|
14452
|
-
|
|
14453
|
-
|
|
14533
|
+
const resolveEvmProvider = () => {
|
|
14534
|
+
const walletIdMap = {
|
|
14535
|
+
"phantom-ethereum": "phantom",
|
|
14536
|
+
coinbase: "coinbase",
|
|
14537
|
+
trust: "trust",
|
|
14538
|
+
okx: "okx",
|
|
14539
|
+
rainbow: "rainbow",
|
|
14540
|
+
rabby: "rabby",
|
|
14541
|
+
metamask: "metamask"
|
|
14542
|
+
};
|
|
14454
14543
|
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
14455
14544
|
const eip6963Match = findProviderByWalletId(lookupId);
|
|
14456
14545
|
let provider = eip6963Match?.provider;
|
|
@@ -14459,6 +14548,11 @@ function WalletConnect({
|
|
|
14459
14548
|
else if (walletInfo.type === "coinbase") provider = window.coinbaseWalletExtension || window.ethereum;
|
|
14460
14549
|
else provider = window.ethereum;
|
|
14461
14550
|
}
|
|
14551
|
+
return provider;
|
|
14552
|
+
};
|
|
14553
|
+
const sendEthereumTransaction = async (token, amountStr) => {
|
|
14554
|
+
if (!recipientAddress || !/^0x[a-fA-F0-9]{40}$/.test(recipientAddress)) throw new Error(`Invalid recipient address.`);
|
|
14555
|
+
const provider = resolveEvmProvider();
|
|
14462
14556
|
if (!provider) throw new Error("Ethereum wallet not found");
|
|
14463
14557
|
const currentChainIdHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
14464
14558
|
if (parseInt(currentChainIdHex, 16).toString() !== token.chain_id) {
|
|
@@ -14507,7 +14601,7 @@ function WalletConnect({
|
|
|
14507
14601
|
if (!provider.publicKey) await provider.connect();
|
|
14508
14602
|
const isNative = token.token_address === "native" || token.token_address === "So11111111111111111111111111111111111111112" || token.token_address === "";
|
|
14509
14603
|
const smallestUnit = isNative ? decimalToSmallestUnit(amountStr, 9) : decimalToSmallestUnit(amountStr, token.decimals);
|
|
14510
|
-
const buildResp = await (0,
|
|
14604
|
+
const buildResp = await (0, import_core30.buildSolanaTransaction)({ chain_id: "mainnet", token_address: token.token_address === "" ? "native" : token.token_address, source_address: walletInfo.address, destination_address: recipientAddress, amount: smallestUnit }, publishableKey);
|
|
14511
14605
|
const { VersionedTransaction } = await import(
|
|
14512
14606
|
/* @vite-ignore */
|
|
14513
14607
|
"@solana/web3.js"
|
|
@@ -14520,9 +14614,22 @@ function WalletConnect({
|
|
|
14520
14614
|
const ser = signed.serialize();
|
|
14521
14615
|
let bs = "";
|
|
14522
14616
|
for (let i = 0; i < ser.length; i++) bs += String.fromCharCode(ser[i]);
|
|
14523
|
-
const resp = await (0,
|
|
14617
|
+
const resp = await (0, import_core30.sendSolanaTransaction)({ chain_id: "mainnet", signed_transaction: btoa(bs) }, publishableKey);
|
|
14524
14618
|
return resp.signature;
|
|
14525
14619
|
};
|
|
14620
|
+
const sendHypercoreDeposit = async (token, amountStr) => {
|
|
14621
|
+
const provider = resolveEvmProvider();
|
|
14622
|
+
if (!provider) throw new Error("Ethereum wallet not found");
|
|
14623
|
+
const { signature } = await sendHypercoreEvmTransfer({
|
|
14624
|
+
provider,
|
|
14625
|
+
fromAddress: walletInfo.address,
|
|
14626
|
+
recipientAddress,
|
|
14627
|
+
sourceTokenAddress: token.token_address,
|
|
14628
|
+
amount: amountStr,
|
|
14629
|
+
publishableKey
|
|
14630
|
+
});
|
|
14631
|
+
return signature;
|
|
14632
|
+
};
|
|
14526
14633
|
const handleConfirm = async () => {
|
|
14527
14634
|
if (!hasWallet || !selectedBalance || !amountUsd || tokenAmount === 0 || !recipientAddress) return;
|
|
14528
14635
|
const token = getTokenFromBalance(selectedBalance);
|
|
@@ -14542,7 +14649,33 @@ function WalletConnect({
|
|
|
14542
14649
|
setIsConfirming(true);
|
|
14543
14650
|
setError(null);
|
|
14544
14651
|
try {
|
|
14545
|
-
const
|
|
14652
|
+
const isHypercoreToken = String(token.chain_id) === HYPERCORE_CHAIN_ID;
|
|
14653
|
+
let txHash;
|
|
14654
|
+
if (token.chain_type === "solana") {
|
|
14655
|
+
txHash = await sendSolanaTransaction(token, tokenAmount.toString());
|
|
14656
|
+
} else if (isHypercoreToken) {
|
|
14657
|
+
let sendAmount = tokenAmount;
|
|
14658
|
+
try {
|
|
14659
|
+
const activation = await (0, import_core30.checkHypercoreActivation)(
|
|
14660
|
+
{ source_address: walletInfo.address, recipient_address: recipientAddress },
|
|
14661
|
+
publishableKey
|
|
14662
|
+
);
|
|
14663
|
+
if (!activation.user_exists) {
|
|
14664
|
+
const fee = activation.activation_fee;
|
|
14665
|
+
if (!Number.isFinite(tokenAmount) || tokenAmount <= fee) {
|
|
14666
|
+
throw new Error(
|
|
14667
|
+
`Insufficient amount. A ${fee} USDC activation fee is required for the first transfer to this address.`
|
|
14668
|
+
);
|
|
14669
|
+
}
|
|
14670
|
+
sendAmount = tokenAmount - fee;
|
|
14671
|
+
}
|
|
14672
|
+
} catch (e) {
|
|
14673
|
+
if (e instanceof Error && e.message.includes("activation fee")) throw e;
|
|
14674
|
+
}
|
|
14675
|
+
txHash = await sendHypercoreDeposit(token, sendAmount.toString());
|
|
14676
|
+
} else {
|
|
14677
|
+
txHash = await sendEthereumTransaction(token, tokenAmount.toString());
|
|
14678
|
+
}
|
|
14546
14679
|
setReceivedUsdAtSubmission(checkoutReceivedUsd ?? "0");
|
|
14547
14680
|
setHasSignedTransaction(true);
|
|
14548
14681
|
handleIveDeposited();
|
|
@@ -14581,7 +14714,10 @@ function WalletConnect({
|
|
|
14581
14714
|
children: [
|
|
14582
14715
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
14583
14716
|
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.
|
|
14717
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
14718
|
+
/* @__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 }),
|
|
14719
|
+
wallet.id === recentWalletId && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "uf-text-xs uf-px-2 uf-py-0.5 uf-rounded-full", style: { backgroundColor: colors2.primary + "20", color: colors2.primary, fontFamily: fonts.medium }, children: "Last used" })
|
|
14720
|
+
] })
|
|
14585
14721
|
] }),
|
|
14586
14722
|
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
14723
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: showOpenInApp ? "Open" : "Install" }),
|
|
@@ -14719,8 +14855,8 @@ function WalletConnect({
|
|
|
14719
14855
|
] }) });
|
|
14720
14856
|
}
|
|
14721
14857
|
if (view === "mobile_deposit_status" && latestDepositExecution) {
|
|
14722
|
-
const isComplete = latestDepositExecution.status ===
|
|
14723
|
-
const isFailed = latestDepositExecution.status ===
|
|
14858
|
+
const isComplete = latestDepositExecution.status === import_core30.ExecutionStatus.SUCCEEDED;
|
|
14859
|
+
const isFailed = latestDepositExecution.status === import_core30.ExecutionStatus.FAILED;
|
|
14724
14860
|
const title = isComplete ? "Payment Complete" : isFailed ? "Payment Failed" : "Payment Processing";
|
|
14725
14861
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
14726
14862
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
@@ -14760,7 +14896,7 @@ function WalletConnect({
|
|
|
14760
14896
|
}
|
|
14761
14897
|
if (view === "enter_amount" && selectedToken && selectedBalance) {
|
|
14762
14898
|
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 }) }) });
|
|
14899
|
+
}), quickSelectMode: amountQuickSelect, checkoutAmountUsd, checkoutReceivedUsd, footer: hypercoreNeedsActivation && !hypercoreActivationSponsored ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(HypercoreActivationWarning, { activationFee: hypercoreActivationFee }) : void 0 }) }) });
|
|
14764
14900
|
}
|
|
14765
14901
|
if (view === "review" && selectedToken) {
|
|
14766
14902
|
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 ?? (() => {
|
|
@@ -14799,6 +14935,9 @@ function SkeletonButton({
|
|
|
14799
14935
|
] });
|
|
14800
14936
|
}
|
|
14801
14937
|
var t7 = i18n.depositModal;
|
|
14938
|
+
function depositTabForScreen(screen) {
|
|
14939
|
+
return screen === "card" || screen === "cashapp" ? "cash" : "crypto";
|
|
14940
|
+
}
|
|
14802
14941
|
function DepositModal({
|
|
14803
14942
|
open,
|
|
14804
14943
|
onOpenChange,
|
|
@@ -14834,6 +14973,7 @@ function DepositModal({
|
|
|
14834
14973
|
theme = "dark",
|
|
14835
14974
|
hideOverlay = false,
|
|
14836
14975
|
initialScreen = "main",
|
|
14976
|
+
displayMode = "stacked",
|
|
14837
14977
|
transferCryptoTitle = t7.transferCrypto.title,
|
|
14838
14978
|
depositWithCardTitle = t7.depositWithCard.title,
|
|
14839
14979
|
payWithExchangeTitle = t7.payWithExchange.title,
|
|
@@ -14868,6 +15008,9 @@ function DepositModal({
|
|
|
14868
15008
|
effectiveInitialScreen
|
|
14869
15009
|
);
|
|
14870
15010
|
const [coinbaseSkipToHoldings, setCoinbaseSkipToHoldings] = (0, import_react20.useState)(false);
|
|
15011
|
+
const [depositTab, setDepositTab] = (0, import_react20.useState)(
|
|
15012
|
+
() => depositTabForScreen(effectiveInitialScreen)
|
|
15013
|
+
);
|
|
14871
15014
|
const resetViewTimeoutRef = (0, import_react20.useRef)(null);
|
|
14872
15015
|
const [cardView, setCardView] = (0, import_react20.useState)(
|
|
14873
15016
|
"amount"
|
|
@@ -14897,18 +15040,18 @@ function DepositModal({
|
|
|
14897
15040
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react20.useState)([]);
|
|
14898
15041
|
(0, import_react20.useEffect)(() => {
|
|
14899
15042
|
if (!showConnectExchange || !open) return;
|
|
14900
|
-
(0,
|
|
15043
|
+
(0, import_core31.getIntegrationExchanges)(publishableKey).then((res) => setIntegrationExchanges(res.data)).catch(() => {
|
|
14901
15044
|
});
|
|
14902
15045
|
}, [showConnectExchange, open, publishableKey]);
|
|
14903
15046
|
const [connectedExchange, setConnectedExchange] = (0, import_react20.useState)(() => {
|
|
14904
15047
|
if (!showConnectExchange) return null;
|
|
14905
|
-
const stored = getStoredIntegrationToken(
|
|
15048
|
+
const stored = getStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE);
|
|
14906
15049
|
if (!stored) return null;
|
|
14907
15050
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
14908
15051
|
});
|
|
14909
15052
|
(0, import_react20.useEffect)(() => {
|
|
14910
15053
|
if (!showConnectExchange || !open || view !== "main") return;
|
|
14911
|
-
const stored = getStoredIntegrationToken(
|
|
15054
|
+
const stored = getStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE);
|
|
14912
15055
|
if (!stored) {
|
|
14913
15056
|
setConnectedExchange(null);
|
|
14914
15057
|
return;
|
|
@@ -14925,20 +15068,20 @@ function DepositModal({
|
|
|
14925
15068
|
const balanceUsd = totalUsd > 0 ? totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
|
|
14926
15069
|
setConnectedExchange((prev) => prev ? { ...prev, balanceUsd, isLoading: false } : null);
|
|
14927
15070
|
};
|
|
14928
|
-
(0,
|
|
15071
|
+
(0, import_core31.getIntegrationHoldings)(import_core31.IntegrationProvider.COINBASE, stored.access_token, publishableKey).then(processHoldings).catch(async () => {
|
|
14929
15072
|
try {
|
|
14930
|
-
const refreshResult = await (0,
|
|
14931
|
-
if (!getStoredIntegrationToken(
|
|
15073
|
+
const refreshResult = await (0, import_core31.refreshIntegrationToken)(stored.access_token, publishableKey);
|
|
15074
|
+
if (!getStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE)) return;
|
|
14932
15075
|
setStoredIntegrationToken({
|
|
14933
|
-
integration_provider:
|
|
15076
|
+
integration_provider: import_core31.IntegrationProvider.COINBASE,
|
|
14934
15077
|
access_token: refreshResult.access_token,
|
|
14935
15078
|
expires_at: refreshResult.expires_at
|
|
14936
15079
|
});
|
|
14937
|
-
const retryResult = await (0,
|
|
15080
|
+
const retryResult = await (0, import_core31.getIntegrationHoldings)(import_core31.IntegrationProvider.COINBASE, refreshResult.access_token, publishableKey);
|
|
14938
15081
|
processHoldings(retryResult);
|
|
14939
15082
|
} catch {
|
|
14940
|
-
if (!getStoredIntegrationToken(
|
|
14941
|
-
clearStoredIntegrationToken(
|
|
15083
|
+
if (!getStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE)) return;
|
|
15084
|
+
clearStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE);
|
|
14942
15085
|
setConnectedExchange(null);
|
|
14943
15086
|
}
|
|
14944
15087
|
});
|
|
@@ -14946,7 +15089,7 @@ function DepositModal({
|
|
|
14946
15089
|
(0, import_react20.useEffect)(() => {
|
|
14947
15090
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
14948
15091
|
const cbExchange = integrationExchanges.find(
|
|
14949
|
-
(e) => e.service_provider ===
|
|
15092
|
+
(e) => e.service_provider === import_core31.IntegrationProvider.COINBASE
|
|
14950
15093
|
);
|
|
14951
15094
|
const iconUrl = cbExchange?.icon_urls?.find((u) => u.format === "svg")?.url || cbExchange?.icon_urls?.find((u) => u.format === "png")?.url || cbExchange?.icon_url;
|
|
14952
15095
|
if (iconUrl && iconUrl !== connectedExchange.iconUrl) {
|
|
@@ -15032,7 +15175,7 @@ function DepositModal({
|
|
|
15032
15175
|
if (view !== "tracker" || !userId) return;
|
|
15033
15176
|
const fetchExecutions = async () => {
|
|
15034
15177
|
try {
|
|
15035
|
-
const response = await (0,
|
|
15178
|
+
const response = await (0, import_core31.queryExecutions)(userId, publishableKey, import_core31.ActionType.Deposit);
|
|
15036
15179
|
const sorted = [...response.data].sort((a, b) => {
|
|
15037
15180
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
15038
15181
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -15136,11 +15279,11 @@ function DepositModal({
|
|
|
15136
15279
|
if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
|
|
15137
15280
|
};
|
|
15138
15281
|
const handleExchangeDisconnect = () => {
|
|
15139
|
-
const stored = getStoredIntegrationToken(
|
|
15282
|
+
const stored = getStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE);
|
|
15140
15283
|
if (stored) {
|
|
15141
|
-
(0,
|
|
15284
|
+
(0, import_core31.revokeIntegrationToken)(stored.access_token, publishableKey);
|
|
15142
15285
|
}
|
|
15143
|
-
clearStoredIntegrationToken(
|
|
15286
|
+
clearStoredIntegrationToken(import_core31.IntegrationProvider.COINBASE);
|
|
15144
15287
|
setConnectedExchange(null);
|
|
15145
15288
|
if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
|
|
15146
15289
|
};
|
|
@@ -15165,6 +15308,7 @@ function DepositModal({
|
|
|
15165
15308
|
resetViewTimeoutRef.current = null;
|
|
15166
15309
|
}
|
|
15167
15310
|
setView(effectiveInitialScreen);
|
|
15311
|
+
setDepositTab(depositTabForScreen(effectiveInitialScreen));
|
|
15168
15312
|
setCardView("amount");
|
|
15169
15313
|
setExchangeView("providers");
|
|
15170
15314
|
setBrowserWalletInfo(null);
|
|
@@ -15193,6 +15337,7 @@ function DepositModal({
|
|
|
15193
15337
|
} else if (view === "cashapp" && cashAppView !== "amount") {
|
|
15194
15338
|
setCashAppView("amount");
|
|
15195
15339
|
} else {
|
|
15340
|
+
setDepositTab(depositTabForScreen(view));
|
|
15196
15341
|
setView("main");
|
|
15197
15342
|
setCardView("amount");
|
|
15198
15343
|
setExchangeView("providers");
|
|
@@ -15272,6 +15417,184 @@ function DepositModal({
|
|
|
15272
15417
|
className: "uf-flex uf-justify-center uf-shrink-0"
|
|
15273
15418
|
}
|
|
15274
15419
|
) });
|
|
15420
|
+
const transferCryptoMenuButton = showTransferCrypto ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15421
|
+
TransferCryptoButton,
|
|
15422
|
+
{
|
|
15423
|
+
onClick: () => setView("transfer"),
|
|
15424
|
+
title: transferCryptoTitle,
|
|
15425
|
+
subtitle: t7.transferCrypto.subtitle,
|
|
15426
|
+
featuredTokens: projectConfig?.transfer_crypto.networks
|
|
15427
|
+
},
|
|
15428
|
+
"transfer"
|
|
15429
|
+
) : null;
|
|
15430
|
+
const connectWalletMenuButton = showConnectWallet ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15431
|
+
BrowserWalletButton,
|
|
15432
|
+
{
|
|
15433
|
+
onClick: handleBrowserWalletClick,
|
|
15434
|
+
onConnectClick: handleWalletConnectClick,
|
|
15435
|
+
onDisconnect: handleWalletDisconnect,
|
|
15436
|
+
chainType: browserWalletChainType,
|
|
15437
|
+
publishableKey,
|
|
15438
|
+
featuredWallets: projectConfig?.connect_wallet?.wallets
|
|
15439
|
+
},
|
|
15440
|
+
"wallet"
|
|
15441
|
+
) : null;
|
|
15442
|
+
const depositWithCardMenuButton = showFiatOnramp ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15443
|
+
DepositWithCardButton,
|
|
15444
|
+
{
|
|
15445
|
+
onClick: () => setView("card"),
|
|
15446
|
+
title: depositWithCardTitle,
|
|
15447
|
+
subtitle: t7.depositWithCard.subtitle,
|
|
15448
|
+
paymentNetworks: projectConfig?.payment_networks.networks
|
|
15449
|
+
},
|
|
15450
|
+
"card"
|
|
15451
|
+
) : null;
|
|
15452
|
+
const payWithExchangeMenuButton = showPayWithExchange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15453
|
+
PayWithExchangeButton,
|
|
15454
|
+
{
|
|
15455
|
+
onClick: () => setView("exchange"),
|
|
15456
|
+
title: payWithExchangeTitle,
|
|
15457
|
+
subtitle: t7.payWithExchange.subtitle,
|
|
15458
|
+
exchanges,
|
|
15459
|
+
loading: exchangesLoading
|
|
15460
|
+
},
|
|
15461
|
+
"exchange"
|
|
15462
|
+
) : null;
|
|
15463
|
+
const connectExchangeMenuButton = showConnectExchange && connectedExchange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15464
|
+
ConnectExchangeButton,
|
|
15465
|
+
{
|
|
15466
|
+
onClick: () => {
|
|
15467
|
+
setCoinbaseSkipToHoldings(true);
|
|
15468
|
+
setView("coinbase_connect");
|
|
15469
|
+
},
|
|
15470
|
+
onDisconnect: handleExchangeDisconnect,
|
|
15471
|
+
title: i18n.connectExchange.title,
|
|
15472
|
+
subtitle: i18n.connectExchange.subtitle,
|
|
15473
|
+
exchanges: integrationExchanges,
|
|
15474
|
+
connectedExchange
|
|
15475
|
+
},
|
|
15476
|
+
"connect-exchange"
|
|
15477
|
+
) : showConnectExchange && !connectedExchange ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15478
|
+
ConnectExchangeButton,
|
|
15479
|
+
{
|
|
15480
|
+
onClick: () => {
|
|
15481
|
+
setCoinbaseSkipToHoldings(false);
|
|
15482
|
+
setView("coinbase_connect");
|
|
15483
|
+
},
|
|
15484
|
+
title: i18n.connectExchange.title,
|
|
15485
|
+
subtitle: i18n.connectExchange.subtitle,
|
|
15486
|
+
exchanges: integrationExchanges
|
|
15487
|
+
},
|
|
15488
|
+
"connect-exchange"
|
|
15489
|
+
) : null;
|
|
15490
|
+
const cashAppMenuButton = showCashApp ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15491
|
+
CashAppButton,
|
|
15492
|
+
{
|
|
15493
|
+
onClick: () => setView("cashapp"),
|
|
15494
|
+
title: "Pay with Cash App",
|
|
15495
|
+
subtitle: "Deposit via Cash App",
|
|
15496
|
+
iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/cashapp.svg` : void 0
|
|
15497
|
+
},
|
|
15498
|
+
"cashapp"
|
|
15499
|
+
) : null;
|
|
15500
|
+
const depositTrackerMenuButton = showDepositTracker ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15501
|
+
DepositTrackerButton,
|
|
15502
|
+
{
|
|
15503
|
+
onClick: () => {
|
|
15504
|
+
setAllExecutions(depositExecutions);
|
|
15505
|
+
setView("tracker");
|
|
15506
|
+
},
|
|
15507
|
+
title: depositTrackerTitle,
|
|
15508
|
+
subtitle: depositTrackerSubTitle,
|
|
15509
|
+
badge: depositExecutions.length > 0 ? depositExecutions.length : void 0
|
|
15510
|
+
},
|
|
15511
|
+
"tracker"
|
|
15512
|
+
) : null;
|
|
15513
|
+
const cryptoMenuButtons = [
|
|
15514
|
+
transferCryptoMenuButton,
|
|
15515
|
+
connectWalletMenuButton,
|
|
15516
|
+
payWithExchangeMenuButton,
|
|
15517
|
+
connectExchangeMenuButton
|
|
15518
|
+
].filter(Boolean);
|
|
15519
|
+
const cashMenuButtons = [
|
|
15520
|
+
depositWithCardMenuButton,
|
|
15521
|
+
cashAppMenuButton
|
|
15522
|
+
].filter(Boolean);
|
|
15523
|
+
const depositTabs = [
|
|
15524
|
+
{ id: "crypto", label: "Use Crypto", icon: import_lucide_react29.Bitcoin, buttons: cryptoMenuButtons },
|
|
15525
|
+
{ id: "cash", label: "Use Cash", icon: import_lucide_react29.DollarSign, buttons: cashMenuButtons }
|
|
15526
|
+
].filter((tab) => tab.buttons.length > 0);
|
|
15527
|
+
const activeDepositTab = depositTabs.find((tab) => tab.id === depositTab) ?? depositTabs[0];
|
|
15528
|
+
const renderMainMenuBody = () => {
|
|
15529
|
+
if (depositPrerequisiteBody) {
|
|
15530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-space-y-3", children: depositPrerequisiteBody });
|
|
15531
|
+
}
|
|
15532
|
+
if (displayMode === "tabs" && activeDepositTab) {
|
|
15533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { children: [
|
|
15534
|
+
depositTabs.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15535
|
+
"div",
|
|
15536
|
+
{
|
|
15537
|
+
className: "uf-flex uf-gap-1 uf-p-1 uf-rounded-xl uf-mb-3",
|
|
15538
|
+
style: {
|
|
15539
|
+
// Frosted-glass track: a translucent fill plus a backdrop blur so
|
|
15540
|
+
// the control reads as a soft surface rather than a solid bar.
|
|
15541
|
+
backgroundColor: `color-mix(in srgb, ${colors2.card} 55%, transparent)`,
|
|
15542
|
+
backdropFilter: "blur(12px)",
|
|
15543
|
+
WebkitBackdropFilter: "blur(12px)"
|
|
15544
|
+
},
|
|
15545
|
+
role: "tablist",
|
|
15546
|
+
children: depositTabs.map((tab) => {
|
|
15547
|
+
const active = activeDepositTab.id === tab.id;
|
|
15548
|
+
const TabIcon = tab.icon;
|
|
15549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
15550
|
+
"button",
|
|
15551
|
+
{
|
|
15552
|
+
type: "button",
|
|
15553
|
+
role: "tab",
|
|
15554
|
+
"aria-selected": active,
|
|
15555
|
+
onClick: () => setDepositTab(tab.id),
|
|
15556
|
+
className: "uf-flex-1 uf-py-2 uf-px-3 uf-rounded-lg uf-text-sm uf-transition-all uf-flex uf-items-center uf-justify-center uf-gap-1.5",
|
|
15557
|
+
style: {
|
|
15558
|
+
backgroundColor: active ? `color-mix(in srgb, ${colors2.primary} 22%, transparent)` : "transparent",
|
|
15559
|
+
backdropFilter: active ? "blur(8px)" : void 0,
|
|
15560
|
+
WebkitBackdropFilter: active ? "blur(8px)" : void 0,
|
|
15561
|
+
boxShadow: active ? `0 1px 8px color-mix(in srgb, ${colors2.primary} 25%, transparent)` : void 0,
|
|
15562
|
+
color: active ? colors2.foreground : colors2.foregroundMuted,
|
|
15563
|
+
fontFamily: fonts.medium
|
|
15564
|
+
},
|
|
15565
|
+
children: [
|
|
15566
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15567
|
+
"span",
|
|
15568
|
+
{
|
|
15569
|
+
className: "uf-inline-flex uf-items-center uf-justify-center uf-rounded-full uf-w-5 uf-h-5 uf-flex-shrink-0",
|
|
15570
|
+
style: {
|
|
15571
|
+
backgroundColor: active ? colors2.foreground : colors2.foregroundMuted
|
|
15572
|
+
},
|
|
15573
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(TabIcon, { size: 12, style: { color: active ? colors2.background : colors2.background }, strokeWidth: 2.5 })
|
|
15574
|
+
}
|
|
15575
|
+
),
|
|
15576
|
+
tab.label
|
|
15577
|
+
]
|
|
15578
|
+
},
|
|
15579
|
+
tab.id
|
|
15580
|
+
);
|
|
15581
|
+
})
|
|
15582
|
+
}
|
|
15583
|
+
),
|
|
15584
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-space-y-3", children: activeDepositTab.buttons }),
|
|
15585
|
+
depositTrackerMenuButton && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "uf-mt-3", children: depositTrackerMenuButton })
|
|
15586
|
+
] });
|
|
15587
|
+
}
|
|
15588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-space-y-3", children: [
|
|
15589
|
+
transferCryptoMenuButton,
|
|
15590
|
+
connectWalletMenuButton,
|
|
15591
|
+
depositWithCardMenuButton,
|
|
15592
|
+
payWithExchangeMenuButton,
|
|
15593
|
+
connectExchangeMenuButton,
|
|
15594
|
+
cashAppMenuButton,
|
|
15595
|
+
depositTrackerMenuButton
|
|
15596
|
+
] });
|
|
15597
|
+
};
|
|
15275
15598
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PortalContainerProvider, { value: hideOverlay ? containerEl : null, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15276
15599
|
Dialog,
|
|
15277
15600
|
{
|
|
@@ -15298,7 +15621,7 @@ function DepositModal({
|
|
|
15298
15621
|
onClose: handleClose,
|
|
15299
15622
|
showBalance: showBalanceHeader,
|
|
15300
15623
|
balanceAddress: recipientAddress,
|
|
15301
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15624
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
|
|
15302
15625
|
balanceChainId: destinationChainId,
|
|
15303
15626
|
balanceTokenAddress: destinationTokenAddress,
|
|
15304
15627
|
projectName: projectConfig?.project_name,
|
|
@@ -15306,94 +15629,7 @@ function DepositModal({
|
|
|
15306
15629
|
}
|
|
15307
15630
|
),
|
|
15308
15631
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
15309
|
-
|
|
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
|
-
] }) }),
|
|
15632
|
+
renderMainMenuBody(),
|
|
15397
15633
|
depositPoweredByFooter
|
|
15398
15634
|
] })
|
|
15399
15635
|
] }) : view === "transfer" ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
@@ -15406,7 +15642,7 @@ function DepositModal({
|
|
|
15406
15642
|
onClose: handleClose,
|
|
15407
15643
|
showBalance: showBalanceHeader,
|
|
15408
15644
|
balanceAddress: recipientAddress,
|
|
15409
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15645
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
|
|
15410
15646
|
balanceChainId: destinationChainId,
|
|
15411
15647
|
balanceTokenAddress: destinationTokenAddress,
|
|
15412
15648
|
projectName: projectConfig?.project_name,
|
|
@@ -15494,7 +15730,7 @@ function DepositModal({
|
|
|
15494
15730
|
badge: cardView === "quotes" ? { count: quotesCount } : void 0,
|
|
15495
15731
|
showBalance: showBalanceHeader,
|
|
15496
15732
|
balanceAddress: recipientAddress,
|
|
15497
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
15733
|
+
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
|
|
15498
15734
|
balanceChainId: destinationChainId,
|
|
15499
15735
|
balanceTokenAddress: destinationTokenAddress,
|
|
15500
15736
|
projectName: projectConfig?.project_name,
|
|
@@ -15682,7 +15918,7 @@ var import_lucide_react30 = require("lucide-react");
|
|
|
15682
15918
|
|
|
15683
15919
|
// src/hooks/use-payment-intent.ts
|
|
15684
15920
|
var import_react_query14 = require("@tanstack/react-query");
|
|
15685
|
-
var
|
|
15921
|
+
var import_core32 = require("@unifold/core");
|
|
15686
15922
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
15687
15923
|
"succeeded",
|
|
15688
15924
|
"expired",
|
|
@@ -15698,7 +15934,7 @@ function usePaymentIntent(params) {
|
|
|
15698
15934
|
} = params;
|
|
15699
15935
|
return (0, import_react_query14.useQuery)({
|
|
15700
15936
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
15701
|
-
queryFn: () => (0,
|
|
15937
|
+
queryFn: () => (0, import_core32.retrievePaymentIntent)(clientSecret, publishableKey),
|
|
15702
15938
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
15703
15939
|
staleTime: 0,
|
|
15704
15940
|
refetchInterval: (query) => {
|
|
@@ -16357,11 +16593,11 @@ var import_lucide_react33 = require("lucide-react");
|
|
|
16357
16593
|
|
|
16358
16594
|
// src/hooks/use-supported-destination-tokens.ts
|
|
16359
16595
|
var import_react_query15 = require("@tanstack/react-query");
|
|
16360
|
-
var
|
|
16596
|
+
var import_core33 = require("@unifold/core");
|
|
16361
16597
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
16362
16598
|
return (0, import_react_query15.useQuery)({
|
|
16363
16599
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
16364
|
-
queryFn: () => (0,
|
|
16600
|
+
queryFn: () => (0, import_core33.getSupportedDestinationTokens)(publishableKey),
|
|
16365
16601
|
staleTime: 1e3 * 60 * 5,
|
|
16366
16602
|
gcTime: 1e3 * 60 * 30,
|
|
16367
16603
|
refetchOnMount: false,
|
|
@@ -16389,7 +16625,7 @@ function useDefaultDestinationToken({
|
|
|
16389
16625
|
|
|
16390
16626
|
// src/hooks/use-source-token-validation.ts
|
|
16391
16627
|
var import_react_query16 = require("@tanstack/react-query");
|
|
16392
|
-
var
|
|
16628
|
+
var import_core34 = require("@unifold/core");
|
|
16393
16629
|
function useSourceTokenValidation(params) {
|
|
16394
16630
|
const {
|
|
16395
16631
|
sourceChainType,
|
|
@@ -16410,7 +16646,7 @@ function useSourceTokenValidation(params) {
|
|
|
16410
16646
|
publishableKey
|
|
16411
16647
|
],
|
|
16412
16648
|
queryFn: async () => {
|
|
16413
|
-
const res = await (0,
|
|
16649
|
+
const res = await (0, import_core34.getSupportedDepositTokens)(publishableKey);
|
|
16414
16650
|
let matchedMinUsd = null;
|
|
16415
16651
|
let matchedProcessingTime = null;
|
|
16416
16652
|
let matchedSlippage = null;
|
|
@@ -16449,7 +16685,7 @@ function useSourceTokenValidation(params) {
|
|
|
16449
16685
|
|
|
16450
16686
|
// src/hooks/use-address-balance.ts
|
|
16451
16687
|
var import_react_query17 = require("@tanstack/react-query");
|
|
16452
|
-
var
|
|
16688
|
+
var import_core35 = require("@unifold/core");
|
|
16453
16689
|
function useAddressBalance(params) {
|
|
16454
16690
|
const {
|
|
16455
16691
|
address,
|
|
@@ -16471,7 +16707,7 @@ function useAddressBalance(params) {
|
|
|
16471
16707
|
publishableKey
|
|
16472
16708
|
],
|
|
16473
16709
|
queryFn: async () => {
|
|
16474
|
-
const res = await (0,
|
|
16710
|
+
const res = await (0, import_core35.getAddressBalance)(
|
|
16475
16711
|
address,
|
|
16476
16712
|
chainType,
|
|
16477
16713
|
chainId,
|
|
@@ -16510,12 +16746,12 @@ function useAddressBalance(params) {
|
|
|
16510
16746
|
|
|
16511
16747
|
// src/hooks/use-executions.ts
|
|
16512
16748
|
var import_react_query18 = require("@tanstack/react-query");
|
|
16513
|
-
var
|
|
16749
|
+
var import_core36 = require("@unifold/core");
|
|
16514
16750
|
function useExecutions(userId, publishableKey, options) {
|
|
16515
|
-
const actionType = options?.actionType ??
|
|
16751
|
+
const actionType = options?.actionType ?? import_core36.ActionType.Deposit;
|
|
16516
16752
|
return (0, import_react_query18.useQuery)({
|
|
16517
16753
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
16518
|
-
queryFn: () => (0,
|
|
16754
|
+
queryFn: () => (0, import_core36.queryExecutions)(userId, publishableKey, actionType),
|
|
16519
16755
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
16520
16756
|
refetchInterval: options?.refetchInterval ?? 3e3,
|
|
16521
16757
|
staleTime: 0,
|
|
@@ -16526,7 +16762,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
16526
16762
|
|
|
16527
16763
|
// src/hooks/use-withdraw-polling.ts
|
|
16528
16764
|
var import_react22 = require("react");
|
|
16529
|
-
var
|
|
16765
|
+
var import_core37 = require("@unifold/core");
|
|
16530
16766
|
var POLL_INTERVAL_MS3 = 2500;
|
|
16531
16767
|
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
16532
16768
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
@@ -16566,15 +16802,15 @@ function useWithdrawPolling({
|
|
|
16566
16802
|
const enabledAt = enabledAtRef.current;
|
|
16567
16803
|
const poll = async () => {
|
|
16568
16804
|
try {
|
|
16569
|
-
const response = await (0,
|
|
16805
|
+
const response = await (0, import_core37.queryExecutions)(userId, publishableKey, import_core37.ActionType.Withdraw);
|
|
16570
16806
|
const cutoff = new Date(enabledAt.getTime() - CUTOFF_BUFFER_MS2);
|
|
16571
16807
|
const sorted = [...response.data].sort((a, b) => {
|
|
16572
16808
|
const tA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
16573
16809
|
const tB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
16574
16810
|
return tB - tA;
|
|
16575
16811
|
});
|
|
16576
|
-
const inProgress = [
|
|
16577
|
-
const terminal = [
|
|
16812
|
+
const inProgress = [import_core37.ExecutionStatus.PENDING, import_core37.ExecutionStatus.WAITING, import_core37.ExecutionStatus.DELAYED];
|
|
16813
|
+
const terminal = [import_core37.ExecutionStatus.SUCCEEDED, import_core37.ExecutionStatus.FAILED];
|
|
16578
16814
|
let target = null;
|
|
16579
16815
|
for (const ex of sorted) {
|
|
16580
16816
|
const t12 = ex.created_at ? new Date(ex.created_at) : null;
|
|
@@ -16604,9 +16840,9 @@ function useWithdrawPolling({
|
|
|
16604
16840
|
}
|
|
16605
16841
|
return [...list, ex];
|
|
16606
16842
|
});
|
|
16607
|
-
if (ex.status ===
|
|
16843
|
+
if (ex.status === import_core37.ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
|
|
16608
16844
|
onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
|
|
16609
|
-
} else if (ex.status ===
|
|
16845
|
+
} else if (ex.status === import_core37.ExecutionStatus.FAILED && prev !== import_core37.ExecutionStatus.FAILED) {
|
|
16610
16846
|
onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
|
|
16611
16847
|
}
|
|
16612
16848
|
}
|
|
@@ -16627,7 +16863,7 @@ function useWithdrawPolling({
|
|
|
16627
16863
|
if (!enabled || !depositWalletId) return;
|
|
16628
16864
|
const trigger = async () => {
|
|
16629
16865
|
try {
|
|
16630
|
-
await (0,
|
|
16866
|
+
await (0, import_core37.pollDirectExecutions)({ deposit_wallet_id: depositWalletId }, publishableKey);
|
|
16631
16867
|
} catch {
|
|
16632
16868
|
}
|
|
16633
16869
|
};
|
|
@@ -16796,11 +17032,11 @@ function WithdrawDoubleInput({
|
|
|
16796
17032
|
// src/components/withdrawals/WithdrawForm.tsx
|
|
16797
17033
|
var import_react24 = require("react");
|
|
16798
17034
|
var import_lucide_react31 = require("lucide-react");
|
|
16799
|
-
var
|
|
17035
|
+
var import_core42 = require("@unifold/core");
|
|
16800
17036
|
|
|
16801
17037
|
// src/hooks/use-verify-recipient-address.ts
|
|
16802
17038
|
var import_react_query19 = require("@tanstack/react-query");
|
|
16803
|
-
var
|
|
17039
|
+
var import_core38 = require("@unifold/core");
|
|
16804
17040
|
function useVerifyRecipientAddress(params) {
|
|
16805
17041
|
const {
|
|
16806
17042
|
chainType,
|
|
@@ -16822,7 +17058,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
16822
17058
|
trimmedAddress,
|
|
16823
17059
|
publishableKey
|
|
16824
17060
|
],
|
|
16825
|
-
queryFn: () => (0,
|
|
17061
|
+
queryFn: () => (0, import_core38.verifyRecipientAddress)(
|
|
16826
17062
|
{
|
|
16827
17063
|
chain_type: chainType,
|
|
16828
17064
|
chain_id: chainId,
|
|
@@ -16841,7 +17077,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
16841
17077
|
}
|
|
16842
17078
|
|
|
16843
17079
|
// src/components/withdrawals/send-withdraw.ts
|
|
16844
|
-
var
|
|
17080
|
+
var import_core39 = require("@unifold/core");
|
|
16845
17081
|
async function sendEvmWithdraw(params) {
|
|
16846
17082
|
const {
|
|
16847
17083
|
provider,
|
|
@@ -16919,7 +17155,7 @@ async function sendSolanaWithdraw(params) {
|
|
|
16919
17155
|
if (!provider.publicKey) {
|
|
16920
17156
|
await provider.connect();
|
|
16921
17157
|
}
|
|
16922
|
-
const buildResponse = await (0,
|
|
17158
|
+
const buildResponse = await (0, import_core39.buildSolanaTransaction)(
|
|
16923
17159
|
{
|
|
16924
17160
|
chain_id: "mainnet",
|
|
16925
17161
|
token_address: sourceTokenAddress === "" ? "native" : sourceTokenAddress,
|
|
@@ -16945,56 +17181,21 @@ async function sendSolanaWithdraw(params) {
|
|
|
16945
17181
|
for (let i = 0; i < serialized.length; i++) {
|
|
16946
17182
|
binaryStr += String.fromCharCode(serialized[i]);
|
|
16947
17183
|
}
|
|
16948
|
-
const sendResponse = await (0,
|
|
17184
|
+
const sendResponse = await (0, import_core39.sendSolanaTransaction)(
|
|
16949
17185
|
{ chain_id: "mainnet", signed_transaction: btoa(binaryStr) },
|
|
16950
17186
|
publishableKey
|
|
16951
17187
|
);
|
|
16952
17188
|
return sendResponse.signature;
|
|
16953
17189
|
}
|
|
16954
|
-
var HYPERCORE_SPOT_USDC_ADDRESS = "0x6d1e7cde53ba9467b783cb7c530ce054";
|
|
16955
|
-
function isHypercoreChain(chainId) {
|
|
16956
|
-
return chainId === HYPERCORE_CHAIN_ID;
|
|
16957
|
-
}
|
|
16958
17190
|
async function sendHypercoreWithdraw(params) {
|
|
16959
|
-
|
|
16960
|
-
provider,
|
|
16961
|
-
fromAddress,
|
|
16962
|
-
depositWalletAddress,
|
|
16963
|
-
sourceTokenAddress,
|
|
16964
|
-
amount,
|
|
16965
|
-
|
|
16966
|
-
publishableKey
|
|
16967
|
-
} = params;
|
|
16968
|
-
const isSpot = sourceTokenAddress.toLowerCase() === HYPERCORE_SPOT_USDC_ADDRESS;
|
|
16969
|
-
const currentChainHex = await provider.request({
|
|
16970
|
-
method: "eth_chainId",
|
|
16971
|
-
params: []
|
|
16972
|
-
});
|
|
16973
|
-
const activeChainId = String(parseInt(currentChainHex, 16));
|
|
16974
|
-
const buildResult = await (0, import_core38.buildHypercoreTransaction)(
|
|
16975
|
-
{
|
|
16976
|
-
action_type: isSpot ? "spot_send" : "usd_send",
|
|
16977
|
-
signature_chain_type: "ethereum",
|
|
16978
|
-
signature_chain_id: activeChainId,
|
|
16979
|
-
recipient_address: depositWalletAddress,
|
|
16980
|
-
token_address: sourceTokenAddress,
|
|
16981
|
-
token_symbol: tokenSymbol || void 0,
|
|
16982
|
-
amount
|
|
16983
|
-
},
|
|
16984
|
-
publishableKey
|
|
16985
|
-
);
|
|
16986
|
-
const signature = await provider.request({
|
|
16987
|
-
method: "eth_signTypedData_v4",
|
|
16988
|
-
params: [fromAddress, JSON.stringify(buildResult.typed_data)]
|
|
17191
|
+
await sendHypercoreEvmTransfer({
|
|
17192
|
+
provider: params.provider,
|
|
17193
|
+
fromAddress: params.fromAddress,
|
|
17194
|
+
recipientAddress: params.depositWalletAddress,
|
|
17195
|
+
sourceTokenAddress: params.sourceTokenAddress,
|
|
17196
|
+
amount: params.amount,
|
|
17197
|
+
publishableKey: params.publishableKey
|
|
16989
17198
|
});
|
|
16990
|
-
await (0, import_core38.sendHypercoreTransaction)(
|
|
16991
|
-
{
|
|
16992
|
-
action_payload: buildResult.action_payload,
|
|
16993
|
-
signature,
|
|
16994
|
-
nonce: buildResult.nonce
|
|
16995
|
-
},
|
|
16996
|
-
publishableKey
|
|
16997
|
-
);
|
|
16998
17199
|
}
|
|
16999
17200
|
async function detectBrowserWallet(chainType, senderAddress) {
|
|
17000
17201
|
const win = typeof window !== "undefined" ? window : null;
|
|
@@ -17076,11 +17277,11 @@ async function detectBrowserWallet(chainType, senderAddress) {
|
|
|
17076
17277
|
|
|
17077
17278
|
// src/hooks/use-hypercore-withdraw-activation.ts
|
|
17078
17279
|
var import_react23 = require("react");
|
|
17079
|
-
var
|
|
17280
|
+
var import_core41 = require("@unifold/core");
|
|
17080
17281
|
|
|
17081
17282
|
// src/hooks/use-get-deposit-address.ts
|
|
17082
17283
|
var import_react_query20 = require("@tanstack/react-query");
|
|
17083
|
-
var
|
|
17284
|
+
var import_core40 = require("@unifold/core");
|
|
17084
17285
|
function useGetDepositAddress(params) {
|
|
17085
17286
|
const {
|
|
17086
17287
|
userId,
|
|
@@ -17105,7 +17306,7 @@ function useGetDepositAddress(params) {
|
|
|
17105
17306
|
actionType ?? null,
|
|
17106
17307
|
publishableKey
|
|
17107
17308
|
],
|
|
17108
|
-
queryFn: () => (0,
|
|
17309
|
+
queryFn: () => (0, import_core40.getDepositAddress)(
|
|
17109
17310
|
{
|
|
17110
17311
|
external_user_id: userId,
|
|
17111
17312
|
recipient_address: recipientAddress,
|
|
@@ -17159,7 +17360,7 @@ function useHypercoreWithdrawActivation(params) {
|
|
|
17159
17360
|
destinationChainType,
|
|
17160
17361
|
destinationChainId,
|
|
17161
17362
|
destinationTokenAddress,
|
|
17162
|
-
actionType:
|
|
17363
|
+
actionType: import_core41.ActionType.Withdraw,
|
|
17163
17364
|
enabled: enabled && isHypercore(sourceChainId)
|
|
17164
17365
|
});
|
|
17165
17366
|
const depositWalletAddress = (0, import_react23.useMemo)(() => {
|
|
@@ -17428,7 +17629,7 @@ function WithdrawForm({
|
|
|
17428
17629
|
let humanAmount = isMaxed ? balanceData.balanceHuman : toSafeDecimalString(cryptoAmountFromInput, sourceDecimals);
|
|
17429
17630
|
if (isHypercoreChain(sourceChainId)) {
|
|
17430
17631
|
try {
|
|
17431
|
-
const check = await (0,
|
|
17632
|
+
const check = await (0, import_core42.checkHypercoreActivation)(
|
|
17432
17633
|
{
|
|
17433
17634
|
source_address: senderAddress,
|
|
17434
17635
|
recipient_address: depositWallet.address
|
|
@@ -17745,14 +17946,14 @@ function WithdrawForm({
|
|
|
17745
17946
|
|
|
17746
17947
|
// src/components/withdrawals/WithdrawExecutionItem.tsx
|
|
17747
17948
|
var import_lucide_react32 = require("lucide-react");
|
|
17748
|
-
var
|
|
17949
|
+
var import_core43 = require("@unifold/core");
|
|
17749
17950
|
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
17750
17951
|
function WithdrawExecutionItem({
|
|
17751
17952
|
execution,
|
|
17752
17953
|
onClick
|
|
17753
17954
|
}) {
|
|
17754
17955
|
const { colors: colors2, fonts, components } = useTheme();
|
|
17755
|
-
const isPending = execution.status ===
|
|
17956
|
+
const isPending = execution.status === import_core43.ExecutionStatus.PENDING || execution.status === import_core43.ExecutionStatus.WAITING || execution.status === import_core43.ExecutionStatus.DELAYED;
|
|
17756
17957
|
const formatDateTime = (timestamp) => {
|
|
17757
17958
|
try {
|
|
17758
17959
|
const date = new Date(timestamp);
|
|
@@ -17799,7 +18000,7 @@ function WithdrawExecutionItem({
|
|
|
17799
18000
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
17800
18001
|
"img",
|
|
17801
18002
|
{
|
|
17802
|
-
src: execution.destination_token_metadata?.icon_url || (0,
|
|
18003
|
+
src: execution.destination_token_metadata?.icon_url || (0, import_core43.getIconUrl)("/icons/tokens/svg/usdc.svg"),
|
|
17803
18004
|
alt: "Token",
|
|
17804
18005
|
width: 36,
|
|
17805
18006
|
height: 36,
|
|
@@ -18021,8 +18222,6 @@ function WithdrawConfirmingView({
|
|
|
18021
18222
|
className: "uf-text-sm uf-text-center",
|
|
18022
18223
|
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
18023
18224
|
children: [
|
|
18024
|
-
txInfo.amount,
|
|
18025
|
-
" ",
|
|
18026
18225
|
txInfo.sourceTokenSymbol,
|
|
18027
18226
|
" to",
|
|
18028
18227
|
" ",
|
|
@@ -18058,7 +18257,7 @@ function WithdrawConfirmingView({
|
|
|
18058
18257
|
}
|
|
18059
18258
|
|
|
18060
18259
|
// src/components/withdrawals/WithdrawModal.tsx
|
|
18061
|
-
var
|
|
18260
|
+
var import_core44 = require("@unifold/core");
|
|
18062
18261
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
18063
18262
|
var t10 = i18n.withdrawModal;
|
|
18064
18263
|
var getChainKey5 = (chainId, chainType) => `${chainType}:${chainId}`;
|
|
@@ -18149,25 +18348,25 @@ function WithdrawModal({
|
|
|
18149
18348
|
onWithdrawError
|
|
18150
18349
|
});
|
|
18151
18350
|
const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
|
|
18152
|
-
actionType:
|
|
18351
|
+
actionType: import_core44.ActionType.Withdraw,
|
|
18153
18352
|
enabled: open,
|
|
18154
18353
|
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
18155
18354
|
});
|
|
18156
18355
|
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
18157
18356
|
const handleDepositWalletCreation = (0, import_react26.useCallback)(async (params) => {
|
|
18158
|
-
const { data: wallets } = await (0,
|
|
18357
|
+
const { data: wallets } = await (0, import_core44.createDepositAddress)(
|
|
18159
18358
|
{
|
|
18160
18359
|
external_user_id: externalUserId,
|
|
18161
18360
|
destination_chain_type: params.destinationChainType,
|
|
18162
18361
|
destination_chain_id: params.destinationChainId,
|
|
18163
18362
|
destination_token_address: params.destinationTokenAddress,
|
|
18164
18363
|
recipient_address: params.recipientAddress,
|
|
18165
|
-
action_type:
|
|
18364
|
+
action_type: import_core44.ActionType.Withdraw,
|
|
18166
18365
|
source_chain_type: sourceChainType
|
|
18167
18366
|
},
|
|
18168
18367
|
publishableKey
|
|
18169
18368
|
);
|
|
18170
|
-
const depositWallet = (0,
|
|
18369
|
+
const depositWallet = (0, import_core44.getWalletByChainType)(wallets, sourceChainType);
|
|
18171
18370
|
if (!depositWallet) {
|
|
18172
18371
|
throw new Error(`No deposit wallet available for ${sourceChainType}`);
|
|
18173
18372
|
}
|