@unifold/connect-react 0.1.69 → 0.1.70-beta.1
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/headless.d.mts +1 -0
- package/dist/headless.d.ts +1 -0
- package/dist/headless.js +24 -0
- package/dist/headless.mjs +2 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +634 -191
- package/dist/index.mjs +671 -228
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +10 -4
package/dist/index.mjs
CHANGED
|
@@ -1144,13 +1144,16 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
1144
1144
|
});
|
|
1145
1145
|
|
|
1146
1146
|
// src/provider.tsx
|
|
1147
|
-
import React38, { useState as useState39, useCallback as
|
|
1147
|
+
import React38, { useState as useState39, useCallback as useCallback15, useMemo as useMemo19, useEffect as useEffect40 } from "react";
|
|
1148
1148
|
|
|
1149
1149
|
// ../react-provider/dist/index.mjs
|
|
1150
1150
|
import { createContext, useContext, useState, useEffect, useMemo, useRef } from "react";
|
|
1151
1151
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
1152
1152
|
import { jsx } from "react/jsx-runtime";
|
|
1153
|
-
var
|
|
1153
|
+
var UNIFOLD_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("unifold.react-provider.context");
|
|
1154
|
+
var globalRef = globalThis;
|
|
1155
|
+
var UnifoldContext = globalRef[UNIFOLD_CONTEXT_KEY] ?? createContext(null);
|
|
1156
|
+
globalRef[UNIFOLD_CONTEXT_KEY] = UnifoldContext;
|
|
1154
1157
|
var createQueryClient = () => new QueryClient({
|
|
1155
1158
|
defaultOptions: {
|
|
1156
1159
|
queries: {
|
|
@@ -1216,7 +1219,7 @@ import {
|
|
|
1216
1219
|
useState as useState40,
|
|
1217
1220
|
useEffect as useEffect34,
|
|
1218
1221
|
useLayoutEffect as useLayoutEffect22,
|
|
1219
|
-
useCallback as
|
|
1222
|
+
useCallback as useCallback11,
|
|
1220
1223
|
useRef as useRef132,
|
|
1221
1224
|
useMemo as useMemo14
|
|
1222
1225
|
} from "react";
|
|
@@ -6142,6 +6145,9 @@ import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
|
6142
6145
|
|
|
6143
6146
|
// ../core/dist/index.mjs
|
|
6144
6147
|
import { useQuery } from "@tanstack/react-query";
|
|
6148
|
+
var __defProp2 = Object.defineProperty;
|
|
6149
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6150
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6145
6151
|
function formatStablecoinAmount(baseUnits, decimals) {
|
|
6146
6152
|
const raw = Number(baseUnits) / 10 ** decimals;
|
|
6147
6153
|
const floored = Math.floor(raw * 100) / 100;
|
|
@@ -6235,6 +6241,16 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
|
6235
6241
|
ActionType2["Withdraw"] = "withdraw";
|
|
6236
6242
|
return ActionType2;
|
|
6237
6243
|
})(ActionType || {});
|
|
6244
|
+
var DepositAddressValidationError = class extends Error {
|
|
6245
|
+
constructor(message) {
|
|
6246
|
+
super(message);
|
|
6247
|
+
__publicField(this, "isDepositAddressValidationError", true);
|
|
6248
|
+
this.name = "DepositAddressValidationError";
|
|
6249
|
+
}
|
|
6250
|
+
};
|
|
6251
|
+
function isDepositAddressValidationError(error) {
|
|
6252
|
+
return error instanceof Error && error.isDepositAddressValidationError === true;
|
|
6253
|
+
}
|
|
6238
6254
|
async function createDepositAddress(overrides, publishableKey) {
|
|
6239
6255
|
if (!overrides?.external_user_id) {
|
|
6240
6256
|
throw new Error("external_user_id is required");
|
|
@@ -6262,6 +6278,13 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
6262
6278
|
body: JSON.stringify(payload)
|
|
6263
6279
|
});
|
|
6264
6280
|
if (!response.ok) {
|
|
6281
|
+
if (response.status === 400) {
|
|
6282
|
+
const body = await response.json().catch(() => null);
|
|
6283
|
+
if (body?.error_type === "validation_error") {
|
|
6284
|
+
const firstError = Array.isArray(body.details?.errors) ? body.details?.errors[0] : void 0;
|
|
6285
|
+
throw new DepositAddressValidationError(firstError ?? "Invalid recipient address");
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6265
6288
|
throw new Error(`Failed to create EOA: ${response.statusText}`);
|
|
6266
6289
|
}
|
|
6267
6290
|
return response.json();
|
|
@@ -6618,6 +6641,21 @@ async function getProjectConfig(publishableKey, options) {
|
|
|
6618
6641
|
const data = await response.json();
|
|
6619
6642
|
return data;
|
|
6620
6643
|
}
|
|
6644
|
+
async function getPublicIncident(publishableKey) {
|
|
6645
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6646
|
+
validatePublishableKey(pk);
|
|
6647
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/projects/incident`, {
|
|
6648
|
+
method: "GET",
|
|
6649
|
+
headers: {
|
|
6650
|
+
accept: "application/json",
|
|
6651
|
+
"x-publishable-key": pk
|
|
6652
|
+
}
|
|
6653
|
+
});
|
|
6654
|
+
if (!response.ok) {
|
|
6655
|
+
throw new Error(`Failed to fetch public incident: ${response.statusText}`);
|
|
6656
|
+
}
|
|
6657
|
+
return response.json();
|
|
6658
|
+
}
|
|
6621
6659
|
async function getIpAddress() {
|
|
6622
6660
|
const response = await fetch(`${API_BASE_URL}/v1/public/ip_address`, {
|
|
6623
6661
|
method: "GET",
|
|
@@ -6673,7 +6711,7 @@ async function getExternalWallets(publishableKey) {
|
|
|
6673
6711
|
const data = await response.json();
|
|
6674
6712
|
return data;
|
|
6675
6713
|
}
|
|
6676
|
-
async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey) {
|
|
6714
|
+
async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey, amountUsd) {
|
|
6677
6715
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6678
6716
|
validatePublishableKey(pk);
|
|
6679
6717
|
const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets/mobile_deeplink`, {
|
|
@@ -6683,7 +6721,11 @@ async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey)
|
|
|
6683
6721
|
accept: "application/json",
|
|
6684
6722
|
"x-publishable-key": pk
|
|
6685
6723
|
},
|
|
6686
|
-
body: JSON.stringify({
|
|
6724
|
+
body: JSON.stringify({
|
|
6725
|
+
wallet,
|
|
6726
|
+
deposit_addresses: depositAddresses,
|
|
6727
|
+
...amountUsd ? { amount_usd: amountUsd } : {}
|
|
6728
|
+
})
|
|
6687
6729
|
});
|
|
6688
6730
|
if (!response.ok) {
|
|
6689
6731
|
throw new Error(`Failed to generate wallet deep link: ${response.statusText}`);
|
|
@@ -6728,6 +6770,15 @@ async function verifyRecipientAddress(request, publishableKey) {
|
|
|
6728
6770
|
body: JSON.stringify(request)
|
|
6729
6771
|
});
|
|
6730
6772
|
if (!response.ok) {
|
|
6773
|
+
const body = await response.json().catch(() => null);
|
|
6774
|
+
if (response.status === 400 && body?.error_type === "validation_error") {
|
|
6775
|
+
const firstError = Array.isArray(body.details?.errors) ? body.details?.errors[0] : void 0;
|
|
6776
|
+
return {
|
|
6777
|
+
valid: false,
|
|
6778
|
+
failure_code: "validation_error",
|
|
6779
|
+
message: firstError ?? "Invalid recipient address"
|
|
6780
|
+
};
|
|
6781
|
+
}
|
|
6731
6782
|
throw new Error(`Failed to verify recipient address: ${response.statusText}`);
|
|
6732
6783
|
}
|
|
6733
6784
|
return response.json();
|
|
@@ -8073,6 +8124,7 @@ import { Fragment as Fragment72, jsx as jsx45, jsxs as jsxs422 } from "react/jsx
|
|
|
8073
8124
|
import { useQuery as useQuery12 } from "@tanstack/react-query";
|
|
8074
8125
|
import { useQuery as useQuery13 } from "@tanstack/react-query";
|
|
8075
8126
|
import { useQuery as useQuery14 } from "@tanstack/react-query";
|
|
8127
|
+
import { useQuery as useQuery15 } from "@tanstack/react-query";
|
|
8076
8128
|
import { useState as useState36, useEffect as useEffect302, useMemo as useMemo112 } from "react";
|
|
8077
8129
|
import { useEffect as useEffect272, useState as useState31 } from "react";
|
|
8078
8130
|
import * as React322 from "react";
|
|
@@ -10081,7 +10133,7 @@ Fuse.use = function(...plugins) {
|
|
|
10081
10133
|
|
|
10082
10134
|
// ../ui-react/dist/index.mjs
|
|
10083
10135
|
import { jsx as jsx49, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
10084
|
-
import { useState as useState33, useEffect as useEffect292, useRef as useRef112 } from "react";
|
|
10136
|
+
import { useState as useState33, useEffect as useEffect292, useRef as useRef112, useCallback as useCallback82 } from "react";
|
|
10085
10137
|
import { jsx as jsx50, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
10086
10138
|
import { Fragment as Fragment92, jsx as jsx51, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
10087
10139
|
import { useState as useState34 } from "react";
|
|
@@ -12823,7 +12875,7 @@ var Content22 = TooltipContent;
|
|
|
12823
12875
|
|
|
12824
12876
|
// ../ui-react/dist/index.mjs
|
|
12825
12877
|
import { jsx as jsx522 } from "react/jsx-runtime";
|
|
12826
|
-
import { useQuery as
|
|
12878
|
+
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
12827
12879
|
import { jsx as jsx53, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
12828
12880
|
import { Fragment as Fragment10, jsx as jsx54, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
12829
12881
|
import { useState as useState37, useEffect as useEffect312, useMemo as useMemo122 } from "react";
|
|
@@ -14065,8 +14117,8 @@ var Separator = SelectSeparator;
|
|
|
14065
14117
|
import { jsx as jsx55, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
14066
14118
|
import { jsx as jsx56, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
14067
14119
|
import * as React352 from "react";
|
|
14068
|
-
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
14069
14120
|
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
14121
|
+
import { useQuery as useQuery18 } from "@tanstack/react-query";
|
|
14070
14122
|
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
14071
14123
|
import { jsx as jsx58, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
14072
14124
|
import { Fragment as Fragment11, jsx as jsx59, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
@@ -14075,20 +14127,20 @@ import { useEffect as useEffect322, useState as useState382 } from "react";
|
|
|
14075
14127
|
import { Fragment as Fragment13, jsx as jsx61, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
14076
14128
|
import { jsx as jsx622, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
14077
14129
|
import { Fragment as Fragment14, jsx as jsx63, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
14078
|
-
import { useState as useState41, useEffect as useEffect35, useLayoutEffect as useLayoutEffect32, useCallback as
|
|
14079
|
-
import { useQuery as useQuery18 } from "@tanstack/react-query";
|
|
14080
|
-
import { Fragment as Fragment15, jsx as jsx64, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
14081
|
-
import { useState as useState45, useEffect as useEffect39, useLayoutEffect as useLayoutEffect42, useCallback as useCallback132, useRef as useRef162 } from "react";
|
|
14130
|
+
import { useState as useState41, useEffect as useEffect35, useLayoutEffect as useLayoutEffect32, useCallback as useCallback122, useRef as useRef142, useMemo as useMemo152 } from "react";
|
|
14082
14131
|
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
14132
|
+
import { Fragment as Fragment15, jsx as jsx64, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
14133
|
+
import { useState as useState45, useEffect as useEffect39, useLayoutEffect as useLayoutEffect42, useCallback as useCallback14, useRef as useRef162 } from "react";
|
|
14083
14134
|
import { useQuery as useQuery20 } from "@tanstack/react-query";
|
|
14084
14135
|
import { useQuery as useQuery21 } from "@tanstack/react-query";
|
|
14085
14136
|
import { useQuery as useQuery222 } from "@tanstack/react-query";
|
|
14137
|
+
import { useQuery as useQuery23 } from "@tanstack/react-query";
|
|
14086
14138
|
import { useState as useState42, useEffect as useEffect36, useRef as useRef152 } from "react";
|
|
14087
14139
|
import { jsx as jsx65, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
14088
|
-
import { useState as useState43, useCallback as
|
|
14089
|
-
import { useQuery as useQuery23 } from "@tanstack/react-query";
|
|
14090
|
-
import { useMemo as useMemo16 } from "react";
|
|
14140
|
+
import { useState as useState43, useCallback as useCallback132, useMemo as useMemo17, useEffect as useEffect37 } from "react";
|
|
14091
14141
|
import { useQuery as useQuery24 } from "@tanstack/react-query";
|
|
14142
|
+
import { useMemo as useMemo16 } from "react";
|
|
14143
|
+
import { useQuery as useQuery25 } from "@tanstack/react-query";
|
|
14092
14144
|
import { Fragment as Fragment16, jsx as jsx66, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
14093
14145
|
import { jsx as jsx67, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
14094
14146
|
import { useState as useState44, useEffect as useEffect38 } from "react";
|
|
@@ -14677,7 +14729,13 @@ function useDepositAddress(params) {
|
|
|
14677
14729
|
// 24 hours in cache
|
|
14678
14730
|
refetchOnMount: false,
|
|
14679
14731
|
refetchOnWindowFocus: false,
|
|
14680
|
-
retry
|
|
14732
|
+
// Don't retry recipient-address validation errors — they're deterministic
|
|
14733
|
+
// (a 400 won't succeed on retry) and we want to surface the invalid-address
|
|
14734
|
+
// screen immediately rather than after 3 backoff attempts.
|
|
14735
|
+
retry: (failureCount, error) => {
|
|
14736
|
+
if (isDepositAddressValidationError(error)) return false;
|
|
14737
|
+
return failureCount < 3;
|
|
14738
|
+
},
|
|
14681
14739
|
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
14682
14740
|
// 1s, 2s, 4s (max 10s)
|
|
14683
14741
|
});
|
|
@@ -14885,7 +14943,8 @@ function DepositHeader({
|
|
|
14885
14943
|
balanceChainId,
|
|
14886
14944
|
balanceTokenAddress,
|
|
14887
14945
|
projectName,
|
|
14888
|
-
publishableKey
|
|
14946
|
+
publishableKey,
|
|
14947
|
+
incident
|
|
14889
14948
|
}) {
|
|
14890
14949
|
const { colors: colors2, fonts, components } = useTheme();
|
|
14891
14950
|
const [balance, setBalance] = useState32(null);
|
|
@@ -14983,19 +15042,64 @@ function DepositHeader({
|
|
|
14983
15042
|
balanceTokenAddress,
|
|
14984
15043
|
publishableKey
|
|
14985
15044
|
]);
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
15045
|
+
const incidentMessages = incident?.messages ?? [];
|
|
15046
|
+
const showIncident = incident?.enabled && incidentMessages.length > 0;
|
|
15047
|
+
const incidentSeverity = incident?.severity ?? "degraded";
|
|
15048
|
+
const incidentSeverityLabel = incidentSeverity === "outage" ? "Outage" : incidentSeverity === "info" ? "Info" : "Degraded service";
|
|
15049
|
+
const incidentStyles = incidentSeverity === "outage" ? {
|
|
15050
|
+
bg: "rgba(239, 68, 68, 0.12)",
|
|
15051
|
+
border: "rgba(239, 68, 68, 0.35)",
|
|
15052
|
+
text: "#fca5a5",
|
|
15053
|
+
link: "#fca5a5"
|
|
15054
|
+
} : incidentSeverity === "info" ? {
|
|
15055
|
+
bg: "rgba(59, 130, 246, 0.12)",
|
|
15056
|
+
border: "rgba(59, 130, 246, 0.35)",
|
|
15057
|
+
text: "#93c5fd",
|
|
15058
|
+
link: "#93c5fd"
|
|
15059
|
+
} : {
|
|
15060
|
+
bg: "rgba(245, 158, 11, 0.12)",
|
|
15061
|
+
border: "rgba(245, 158, 11, 0.35)",
|
|
15062
|
+
text: "#fcd34d",
|
|
15063
|
+
link: "#fcd34d"
|
|
15064
|
+
};
|
|
15065
|
+
const IncidentIcon = incidentSeverity === "info" ? Info : TriangleAlert;
|
|
15066
|
+
return /* @__PURE__ */ jsxs32("div", { children: [
|
|
15067
|
+
/* @__PURE__ */ jsxs32("div", { className: "uf-flex uf-items-center uf-justify-between uf-pb-6", children: [
|
|
15068
|
+
showBack ? /* @__PURE__ */ jsx42(
|
|
15069
|
+
"button",
|
|
15070
|
+
{
|
|
15071
|
+
onClick: onBack,
|
|
15072
|
+
className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
|
|
15073
|
+
style: { color: components.header.buttonColor },
|
|
15074
|
+
children: /* @__PURE__ */ jsx42(ArrowLeft, { className: "uf-w-5 uf-h-5" })
|
|
15075
|
+
}
|
|
15076
|
+
) : /* @__PURE__ */ jsx42("div", { className: "uf-w-5 uf-h-5 uf-invisible" }),
|
|
15077
|
+
/* @__PURE__ */ jsxs32("div", { className: "uf-flex uf-flex-col uf-items-center", children: [
|
|
15078
|
+
badge ? /* @__PURE__ */ jsxs32("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
15079
|
+
/* @__PURE__ */ jsx42(
|
|
15080
|
+
DialogTitle2,
|
|
15081
|
+
{
|
|
15082
|
+
className: "uf-text-center uf-text-base",
|
|
15083
|
+
style: {
|
|
15084
|
+
color: components.header.titleColor,
|
|
15085
|
+
fontFamily: fonts.medium
|
|
15086
|
+
},
|
|
15087
|
+
children: title
|
|
15088
|
+
}
|
|
15089
|
+
),
|
|
15090
|
+
/* @__PURE__ */ jsx42(
|
|
15091
|
+
"div",
|
|
15092
|
+
{
|
|
15093
|
+
className: "uf-px-2 uf-py-0.5 uf-rounded-full uf-text-[10px]",
|
|
15094
|
+
style: {
|
|
15095
|
+
backgroundColor: colors2.card,
|
|
15096
|
+
color: colors2.foregroundMuted,
|
|
15097
|
+
fontFamily: fonts.regular
|
|
15098
|
+
},
|
|
15099
|
+
children: badge.count
|
|
15100
|
+
}
|
|
15101
|
+
)
|
|
15102
|
+
] }) : /* @__PURE__ */ jsx42(
|
|
14999
15103
|
DialogTitle2,
|
|
15000
15104
|
{
|
|
15001
15105
|
className: "uf-text-center uf-text-base",
|
|
@@ -15006,61 +15110,91 @@ function DepositHeader({
|
|
|
15006
15110
|
children: title
|
|
15007
15111
|
}
|
|
15008
15112
|
),
|
|
15009
|
-
/* @__PURE__ */ jsx42(
|
|
15113
|
+
subtitle ? /* @__PURE__ */ jsx42(
|
|
15010
15114
|
"div",
|
|
15011
15115
|
{
|
|
15012
|
-
className: "uf-
|
|
15116
|
+
className: "uf-text-xs uf-mt-1",
|
|
15013
15117
|
style: {
|
|
15014
|
-
backgroundColor: colors2.card,
|
|
15015
15118
|
color: colors2.foregroundMuted,
|
|
15016
15119
|
fontFamily: fonts.regular
|
|
15017
15120
|
},
|
|
15018
|
-
children:
|
|
15121
|
+
children: subtitle
|
|
15019
15122
|
}
|
|
15020
|
-
)
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
),
|
|
15032
|
-
|
|
15033
|
-
"
|
|
15034
|
-
{
|
|
15035
|
-
className: "uf-text-xs uf-mt-1",
|
|
15036
|
-
style: {
|
|
15037
|
-
color: colors2.foregroundMuted,
|
|
15038
|
-
fontFamily: fonts.regular
|
|
15039
|
-
},
|
|
15040
|
-
children: subtitle
|
|
15041
|
-
}
|
|
15042
|
-
) : showBalanceBlock ? isLoadingBalance && showBalanceSkeleton ? /* @__PURE__ */ jsx42("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-1" }) : balance ? /* @__PURE__ */ jsx42(
|
|
15043
|
-
"div",
|
|
15123
|
+
) : showBalanceBlock ? isLoadingBalance && showBalanceSkeleton ? /* @__PURE__ */ jsx42("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-1" }) : balance ? /* @__PURE__ */ jsx42(
|
|
15124
|
+
"div",
|
|
15125
|
+
{
|
|
15126
|
+
className: "uf-text-xs uf-mt-1",
|
|
15127
|
+
style: {
|
|
15128
|
+
color: colors2.foregroundMuted,
|
|
15129
|
+
fontFamily: fonts.regular
|
|
15130
|
+
},
|
|
15131
|
+
children: formatBalanceDisplay(balance, projectName)
|
|
15132
|
+
}
|
|
15133
|
+
) : null : null
|
|
15134
|
+
] }),
|
|
15135
|
+
showClose ? /* @__PURE__ */ jsx42(
|
|
15136
|
+
"button",
|
|
15044
15137
|
{
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
},
|
|
15050
|
-
children: formatBalanceDisplay(balance, projectName)
|
|
15138
|
+
onClick: onClose,
|
|
15139
|
+
className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
|
|
15140
|
+
style: { color: components.header.buttonColor },
|
|
15141
|
+
children: /* @__PURE__ */ jsx42(X, { className: "uf-w-5 uf-h-5" })
|
|
15051
15142
|
}
|
|
15052
|
-
) :
|
|
15143
|
+
) : /* @__PURE__ */ jsx42("div", { className: "uf-w-5 uf-h-5 uf-invisible" })
|
|
15053
15144
|
] }),
|
|
15054
|
-
|
|
15055
|
-
"
|
|
15145
|
+
showIncident && /* @__PURE__ */ jsx42(
|
|
15146
|
+
"div",
|
|
15056
15147
|
{
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15148
|
+
className: "uf-rounded-lg uf-px-3 uf-py-2.5 uf-mb-4",
|
|
15149
|
+
style: {
|
|
15150
|
+
backgroundColor: incidentStyles.bg,
|
|
15151
|
+
border: `1px solid ${incidentStyles.border}`
|
|
15152
|
+
},
|
|
15153
|
+
children: /* @__PURE__ */ jsxs32("div", { className: "uf-flex uf-items-start uf-gap-2.5", children: [
|
|
15154
|
+
/* @__PURE__ */ jsx42(
|
|
15155
|
+
IncidentIcon,
|
|
15156
|
+
{
|
|
15157
|
+
className: "uf-w-4 uf-h-4 uf-mt-0.5 uf-shrink-0",
|
|
15158
|
+
style: { color: incidentStyles.text }
|
|
15159
|
+
}
|
|
15160
|
+
),
|
|
15161
|
+
/* @__PURE__ */ jsxs32("div", { className: "uf-min-w-0 uf-flex-1", children: [
|
|
15162
|
+
/* @__PURE__ */ jsx42("div", { className: "uf-flex uf-items-center uf-gap-2 uf-mb-1.5", children: /* @__PURE__ */ jsx42(
|
|
15163
|
+
"span",
|
|
15164
|
+
{
|
|
15165
|
+
className: "uf-text-[11px] uf-leading-none uf-px-1.5 uf-py-1 uf-rounded-md",
|
|
15166
|
+
style: {
|
|
15167
|
+
color: incidentStyles.text,
|
|
15168
|
+
border: `1px solid ${incidentStyles.border}`,
|
|
15169
|
+
fontFamily: fonts.medium
|
|
15170
|
+
},
|
|
15171
|
+
children: incidentSeverityLabel
|
|
15172
|
+
}
|
|
15173
|
+
) }),
|
|
15174
|
+
/* @__PURE__ */ jsx42(
|
|
15175
|
+
"div",
|
|
15176
|
+
{
|
|
15177
|
+
className: "uf-space-y-1",
|
|
15178
|
+
style: { color: incidentStyles.text, fontFamily: fonts.regular },
|
|
15179
|
+
children: incidentMessages.map((message, index2) => /* @__PURE__ */ jsx42("p", { className: "uf-text-xs uf-leading-relaxed", children: message }, `${message}-${index2}`))
|
|
15180
|
+
}
|
|
15181
|
+
),
|
|
15182
|
+
incident.statusPageUrl && /* @__PURE__ */ jsx42(
|
|
15183
|
+
"a",
|
|
15184
|
+
{
|
|
15185
|
+
href: incident.statusPageUrl,
|
|
15186
|
+
target: "_blank",
|
|
15187
|
+
rel: "noreferrer",
|
|
15188
|
+
className: "uf-inline-block uf-mt-1.5 uf-text-xs uf-underline uf-underline-offset-2",
|
|
15189
|
+
style: { color: incidentStyles.link, fontFamily: fonts.medium },
|
|
15190
|
+
children: "View status"
|
|
15191
|
+
}
|
|
15192
|
+
)
|
|
15193
|
+
] })
|
|
15194
|
+
] })
|
|
15061
15195
|
}
|
|
15062
|
-
)
|
|
15063
|
-
] })
|
|
15196
|
+
)
|
|
15197
|
+
] });
|
|
15064
15198
|
}
|
|
15065
15199
|
function CurrencyListItem({ currency, isSelected, onSelect }) {
|
|
15066
15200
|
const { colors: colors2, fonts, components } = useTheme();
|
|
@@ -15380,7 +15514,8 @@ var en_default2 = {
|
|
|
15380
15514
|
},
|
|
15381
15515
|
stripeLink: {
|
|
15382
15516
|
title: "Pay with Link",
|
|
15383
|
-
subtitle: "Buy with card or bank"
|
|
15517
|
+
subtitle: "Buy with card or bank",
|
|
15518
|
+
unavailableInRegionMessage: "Pay with Link is currently unavailable in your region."
|
|
15384
15519
|
},
|
|
15385
15520
|
browserWallet: {
|
|
15386
15521
|
title: "Connect Wallet",
|
|
@@ -21687,7 +21822,7 @@ function AppleLogo({ className, style }) {
|
|
|
21687
21822
|
}
|
|
21688
21823
|
);
|
|
21689
21824
|
}
|
|
21690
|
-
function ApplePayButton({ onClick, title, subtitle }) {
|
|
21825
|
+
function ApplePayButton({ onClick, title, subtitle, iconUrl }) {
|
|
21691
21826
|
const { colors: colors2, fonts, components } = useTheme();
|
|
21692
21827
|
const [isHovered, setIsHovered] = React142.useState(false);
|
|
21693
21828
|
const [isTouchDevice, setIsTouchDevice] = React142.useState(false);
|
|
@@ -21709,7 +21844,14 @@ function ApplePayButton({ onClick, title, subtitle }) {
|
|
|
21709
21844
|
},
|
|
21710
21845
|
children: [
|
|
21711
21846
|
/* @__PURE__ */ jsxs23("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
21712
|
-
/* @__PURE__ */ jsx26("div", { className: "uf-rounded-lg uf-
|
|
21847
|
+
/* @__PURE__ */ jsx26("div", { className: "uf-rounded-lg uf-overflow-hidden uf-w-9 uf-h-9 uf-flex uf-items-center uf-justify-center", children: iconUrl ? /* @__PURE__ */ jsx26("img", { src: iconUrl, alt: "Apple Pay", width: 36, height: 36, className: "uf-rounded-lg" }) : /* @__PURE__ */ jsx26(
|
|
21848
|
+
"div",
|
|
21849
|
+
{
|
|
21850
|
+
className: "uf-w-9 uf-h-9 uf-rounded-lg uf-flex uf-items-center uf-justify-center",
|
|
21851
|
+
style: { backgroundColor: "#000" },
|
|
21852
|
+
children: /* @__PURE__ */ jsx26(AppleLogo, { className: "uf-w-5 uf-h-5", style: { color: "#fff" } })
|
|
21853
|
+
}
|
|
21854
|
+
) }),
|
|
21713
21855
|
/* @__PURE__ */ jsxs23("div", { className: "uf-text-left", children: [
|
|
21714
21856
|
/* @__PURE__ */ jsx26(
|
|
21715
21857
|
"div",
|
|
@@ -21925,13 +22067,6 @@ function solanaCandidate(provider, type, name, icon) {
|
|
|
21925
22067
|
if (provider.isConnected && provider.publicKey) {
|
|
21926
22068
|
return { type, name, address: provider.publicKey.toString(), icon };
|
|
21927
22069
|
}
|
|
21928
|
-
try {
|
|
21929
|
-
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
21930
|
-
if (resp.publicKey) {
|
|
21931
|
-
return { type, name, address: resp.publicKey.toString(), icon };
|
|
21932
|
-
}
|
|
21933
|
-
} catch {
|
|
21934
|
-
}
|
|
21935
22070
|
return null;
|
|
21936
22071
|
}
|
|
21937
22072
|
};
|
|
@@ -22155,6 +22290,178 @@ async function disconnectInjectedBrowserWallet(wallet) {
|
|
|
22155
22290
|
collectEthereumProvidersForDisconnect(window)
|
|
22156
22291
|
);
|
|
22157
22292
|
}
|
|
22293
|
+
var STORED_TYPE_TO_EIP6963_WALLET_ID = {
|
|
22294
|
+
metamask: "metamask",
|
|
22295
|
+
"phantom-ethereum": "phantom",
|
|
22296
|
+
coinbase: "coinbase",
|
|
22297
|
+
trust: "trust",
|
|
22298
|
+
rainbow: "rainbow",
|
|
22299
|
+
rabby: "rabby",
|
|
22300
|
+
okx: "okx"
|
|
22301
|
+
};
|
|
22302
|
+
var EIP6963_WALLET_ID_TO_INFO = {
|
|
22303
|
+
metamask: { walletType: "metamask", name: "MetaMask", icon: "metamask" },
|
|
22304
|
+
phantom: { walletType: "phantom-ethereum", name: "Phantom", icon: "phantom" },
|
|
22305
|
+
coinbase: { walletType: "coinbase", name: "Coinbase Wallet", icon: "coinbase" },
|
|
22306
|
+
trust: { walletType: "trust", name: "Trust Wallet", icon: "trust" },
|
|
22307
|
+
rainbow: { walletType: "rainbow", name: "Rainbow", icon: "rainbow" },
|
|
22308
|
+
rabby: { walletType: "rabby", name: "Rabby", icon: "rabby" },
|
|
22309
|
+
okx: { walletType: "okx", name: "OKX Wallet", icon: "okx" }
|
|
22310
|
+
};
|
|
22311
|
+
var WALLET_ID_TO_WALLET_TYPE = {
|
|
22312
|
+
phantom: "phantom-ethereum",
|
|
22313
|
+
coinbase: "coinbase",
|
|
22314
|
+
trust: "trust",
|
|
22315
|
+
rainbow: "rainbow",
|
|
22316
|
+
rabby: "rabby",
|
|
22317
|
+
okx: "okx",
|
|
22318
|
+
metamask: "metamask"
|
|
22319
|
+
};
|
|
22320
|
+
var WALLET_TYPE_TO_WALLET_ID = {
|
|
22321
|
+
"phantom-ethereum": "phantom",
|
|
22322
|
+
coinbase: "coinbase",
|
|
22323
|
+
trust: "trust",
|
|
22324
|
+
okx: "okx",
|
|
22325
|
+
rainbow: "rainbow",
|
|
22326
|
+
rabby: "rabby",
|
|
22327
|
+
metamask: "metamask"
|
|
22328
|
+
};
|
|
22329
|
+
function isWalletType(value) {
|
|
22330
|
+
return value === "phantom-solana" || value === "phantom-ethereum" || value === "metamask" || value === "coinbase" || value === "solflare" || value === "backpack" || value === "glow" || value === "trust" || value === "rainbow" || value === "rabby" || value === "okx";
|
|
22331
|
+
}
|
|
22332
|
+
function walletIdToWalletType(walletId) {
|
|
22333
|
+
return WALLET_ID_TO_WALLET_TYPE[walletId] || "metamask";
|
|
22334
|
+
}
|
|
22335
|
+
function walletTypeToWalletId(walletType) {
|
|
22336
|
+
return WALLET_TYPE_TO_WALLET_ID[walletType] || walletType;
|
|
22337
|
+
}
|
|
22338
|
+
function getLegacyEvmProviders(win) {
|
|
22339
|
+
if (!win) return {};
|
|
22340
|
+
const anyWin = win;
|
|
22341
|
+
return {
|
|
22342
|
+
ethereum: anyWin.ethereum,
|
|
22343
|
+
phantomEthereum: anyWin.phantom?.ethereum,
|
|
22344
|
+
coinbaseEthereum: anyWin.coinbaseWalletExtension,
|
|
22345
|
+
trustEthereum: anyWin.trustwallet?.ethereum,
|
|
22346
|
+
okxEthereum: anyWin.okxwallet
|
|
22347
|
+
};
|
|
22348
|
+
}
|
|
22349
|
+
function getInjectedSolanaProviders(win) {
|
|
22350
|
+
if (!win) return {};
|
|
22351
|
+
const anyWin = win;
|
|
22352
|
+
return {
|
|
22353
|
+
phantomSolana: anyWin.phantom?.solana,
|
|
22354
|
+
solflare: anyWin.solflare,
|
|
22355
|
+
backpack: anyWin.backpack,
|
|
22356
|
+
glow: anyWin.glow,
|
|
22357
|
+
coinbaseSolana: anyWin.coinbaseSolana || anyWin.coinbaseWalletExtension?.solana,
|
|
22358
|
+
trustSolana: anyWin.trustwallet?.solana
|
|
22359
|
+
};
|
|
22360
|
+
}
|
|
22361
|
+
function describeEip6963Provider(wp) {
|
|
22362
|
+
const mapped = EIP6963_WALLET_ID_TO_INFO[wp.walletId];
|
|
22363
|
+
return {
|
|
22364
|
+
provider: wp.provider,
|
|
22365
|
+
walletType: mapped?.walletType ?? "metamask",
|
|
22366
|
+
name: mapped?.name ?? wp.info.name,
|
|
22367
|
+
icon: mapped?.icon ?? wp.info.icon
|
|
22368
|
+
};
|
|
22369
|
+
}
|
|
22370
|
+
function resolveQuickConnectEvmProvider(win) {
|
|
22371
|
+
const eip6963Providers = getEip6963Providers();
|
|
22372
|
+
if (eip6963Providers.length > 0) {
|
|
22373
|
+
const stored = getStoredWalletState();
|
|
22374
|
+
const preferredWalletId = stored?.walletType && isWalletType(stored.walletType) ? STORED_TYPE_TO_EIP6963_WALLET_ID[stored.walletType] : void 0;
|
|
22375
|
+
if (preferredWalletId) {
|
|
22376
|
+
const preferred = findProviderByWalletId(preferredWalletId);
|
|
22377
|
+
if (preferred) return describeEip6963Provider(preferred);
|
|
22378
|
+
}
|
|
22379
|
+
if (eip6963Providers.length === 1) {
|
|
22380
|
+
return describeEip6963Provider(eip6963Providers[0]);
|
|
22381
|
+
}
|
|
22382
|
+
return void 0;
|
|
22383
|
+
}
|
|
22384
|
+
const anyWin = win;
|
|
22385
|
+
const legacy = anyWin.phantom?.ethereum || anyWin.ethereum;
|
|
22386
|
+
if (!legacy) return void 0;
|
|
22387
|
+
const isPhantom = legacy.isPhantom;
|
|
22388
|
+
return {
|
|
22389
|
+
provider: legacy,
|
|
22390
|
+
walletType: isPhantom ? "phantom-ethereum" : "metamask",
|
|
22391
|
+
name: isPhantom ? "Phantom" : "MetaMask",
|
|
22392
|
+
icon: isPhantom ? "phantom" : "metamask"
|
|
22393
|
+
};
|
|
22394
|
+
}
|
|
22395
|
+
function resolveSolanaPublicKey(provider, response) {
|
|
22396
|
+
if (response?.publicKey) return { publicKey: response.publicKey };
|
|
22397
|
+
if (provider.publicKey) return { publicKey: provider.publicKey };
|
|
22398
|
+
return null;
|
|
22399
|
+
}
|
|
22400
|
+
function isUserRejectedSolanaConnectError(error) {
|
|
22401
|
+
if (!error || typeof error !== "object") return false;
|
|
22402
|
+
const maybeCode = "code" in error ? error.code : void 0;
|
|
22403
|
+
if (maybeCode === 4001) return true;
|
|
22404
|
+
const msg = "message" in error && typeof error.message === "string" ? error.message.toLowerCase() : "";
|
|
22405
|
+
return msg.includes("user rejected") || msg.includes("user denied") || msg.includes("rejected the request") || msg.includes("declined");
|
|
22406
|
+
}
|
|
22407
|
+
function isSolanaConnectTimeoutError(error) {
|
|
22408
|
+
return error instanceof Error && error.message.toLowerCase().includes("did not respond to the connection request");
|
|
22409
|
+
}
|
|
22410
|
+
async function connectSolanaProviderWithRecovery(provider, walletId, walletName) {
|
|
22411
|
+
if (provider.isConnected && provider.publicKey) {
|
|
22412
|
+
return { publicKey: provider.publicKey };
|
|
22413
|
+
}
|
|
22414
|
+
const connectOnce = () => provider.connect(walletId === "solflare" ? { onlyIfTrusted: false } : void 0);
|
|
22415
|
+
const withTimeout = async (ms = 2e4) => await Promise.race([
|
|
22416
|
+
connectOnce(),
|
|
22417
|
+
new Promise(
|
|
22418
|
+
(resolve, reject) => setTimeout(() => {
|
|
22419
|
+
const connected = resolveSolanaPublicKey(provider);
|
|
22420
|
+
if (connected) {
|
|
22421
|
+
resolve(connected);
|
|
22422
|
+
return;
|
|
22423
|
+
}
|
|
22424
|
+
reject(
|
|
22425
|
+
new Error(
|
|
22426
|
+
`${walletName} did not respond to the connection request. Please unlock the wallet and try again.`
|
|
22427
|
+
)
|
|
22428
|
+
);
|
|
22429
|
+
}, ms)
|
|
22430
|
+
)
|
|
22431
|
+
]);
|
|
22432
|
+
if (walletId === "solflare") {
|
|
22433
|
+
await provider.disconnect?.().catch(() => {
|
|
22434
|
+
});
|
|
22435
|
+
}
|
|
22436
|
+
const connectAndResolve = async () => {
|
|
22437
|
+
try {
|
|
22438
|
+
const response = await withTimeout();
|
|
22439
|
+
const resolved = resolveSolanaPublicKey(provider, response);
|
|
22440
|
+
if (resolved) return resolved;
|
|
22441
|
+
await new Promise((resolve) => setTimeout(resolve, 120));
|
|
22442
|
+
const delayedResolved = resolveSolanaPublicKey(provider);
|
|
22443
|
+
if (delayedResolved) return delayedResolved;
|
|
22444
|
+
throw new Error(`${walletName} connected but did not expose a public key.`);
|
|
22445
|
+
} catch (error) {
|
|
22446
|
+
const connected = resolveSolanaPublicKey(provider);
|
|
22447
|
+
if (connected) return connected;
|
|
22448
|
+
throw error;
|
|
22449
|
+
}
|
|
22450
|
+
};
|
|
22451
|
+
try {
|
|
22452
|
+
return await connectAndResolve();
|
|
22453
|
+
} catch (err) {
|
|
22454
|
+
if (isUserRejectedSolanaConnectError(err)) throw err;
|
|
22455
|
+
if (isSolanaConnectTimeoutError(err)) throw err;
|
|
22456
|
+
if (walletId === "solflare") {
|
|
22457
|
+
await provider.disconnect?.().catch(() => {
|
|
22458
|
+
});
|
|
22459
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
22460
|
+
return await connectAndResolve();
|
|
22461
|
+
}
|
|
22462
|
+
throw err;
|
|
22463
|
+
}
|
|
22464
|
+
}
|
|
22158
22465
|
function MetamaskIcon({ size: size4 = 24, className, variant = "color" }) {
|
|
22159
22466
|
const id = React172.useId();
|
|
22160
22467
|
if (variant === "light" || variant === "dark") {
|
|
@@ -24014,21 +24321,19 @@ function BrowserWalletButton({
|
|
|
24014
24321
|
}
|
|
24015
24322
|
}
|
|
24016
24323
|
if (!chainType || chainType === "ethereum") {
|
|
24017
|
-
const
|
|
24018
|
-
if (
|
|
24019
|
-
const accounts = await
|
|
24324
|
+
const resolved = resolveQuickConnectEvmProvider(window);
|
|
24325
|
+
if (resolved) {
|
|
24326
|
+
const accounts = await resolved.provider.request({
|
|
24020
24327
|
method: "eth_requestAccounts"
|
|
24021
24328
|
});
|
|
24022
24329
|
if (accounts && accounts.length > 0) {
|
|
24023
24330
|
setUserDisconnectedWallet(false);
|
|
24024
|
-
|
|
24025
|
-
const walletType = isPhantom ? "phantom-ethereum" : "metamask";
|
|
24026
|
-
setStoredWalletState(walletType);
|
|
24331
|
+
setStoredWalletState(resolved.walletType);
|
|
24027
24332
|
setWallet({
|
|
24028
|
-
type: walletType,
|
|
24029
|
-
name:
|
|
24333
|
+
type: resolved.walletType,
|
|
24334
|
+
name: resolved.name,
|
|
24030
24335
|
address: accounts[0],
|
|
24031
|
-
icon:
|
|
24336
|
+
icon: resolved.icon
|
|
24032
24337
|
});
|
|
24033
24338
|
}
|
|
24034
24339
|
}
|
|
@@ -24062,7 +24367,10 @@ function BrowserWalletButton({
|
|
|
24062
24367
|
if (isLoading) {
|
|
24063
24368
|
return null;
|
|
24064
24369
|
}
|
|
24065
|
-
const
|
|
24370
|
+
const eip6963EvmProviderCount = getEip6963Providers().length;
|
|
24371
|
+
const legacyEvmProviders = getLegacyEvmProviders(window);
|
|
24372
|
+
const hasLegacyEvmProvider = eip6963EvmProviderCount === 0 && !!(legacyEvmProviders.ethereum || legacyEvmProviders.phantomEthereum || legacyEvmProviders.coinbaseEthereum || legacyEvmProviders.trustEthereum || legacyEvmProviders.okxEthereum);
|
|
24373
|
+
const hasWalletExtension = (!chainType || chainType === "ethereum") && eip6963EvmProviderCount > 0 || (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) || (!chainType || chainType === "ethereum") && hasLegacyEvmProvider;
|
|
24066
24374
|
if (!onConnectClick && !wallet && !hasWalletExtension) {
|
|
24067
24375
|
return null;
|
|
24068
24376
|
}
|
|
@@ -24072,11 +24380,25 @@ function BrowserWalletButton({
|
|
|
24072
24380
|
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
24073
24381
|
};
|
|
24074
24382
|
const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
|
|
24383
|
+
const isImageIcon = !!wallet && (wallet.icon.startsWith("data:") || wallet.icon.startsWith("http"));
|
|
24075
24384
|
const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React292.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
|
|
24076
24385
|
size: 36,
|
|
24077
24386
|
className: "uf-rounded-lg",
|
|
24078
24387
|
variant: "color"
|
|
24079
|
-
}) :
|
|
24388
|
+
}) : isImageIcon ? (
|
|
24389
|
+
// Wallet announced via EIP-6963 with no internal icon component: render its
|
|
24390
|
+
// own advertised icon (`info.icon`) rather than a generic placeholder.
|
|
24391
|
+
/* @__PURE__ */ jsx41(
|
|
24392
|
+
"img",
|
|
24393
|
+
{
|
|
24394
|
+
src: wallet.icon,
|
|
24395
|
+
alt: wallet.name,
|
|
24396
|
+
width: 36,
|
|
24397
|
+
height: 36,
|
|
24398
|
+
className: "uf-rounded-lg uf-w-9 uf-h-9"
|
|
24399
|
+
}
|
|
24400
|
+
)
|
|
24401
|
+
) : /* @__PURE__ */ jsx41("div", { className: "uf-w-9 uf-h-9 uf-rounded-lg uf-bg-gray-500" }) : /* @__PURE__ */ jsx41("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ jsx41(Wallet, { className: "uf-w-5 uf-h-5", style: { color: components.card.iconColor } }) });
|
|
24080
24402
|
const titleSubtitleBlock = /* @__PURE__ */ jsxs38("div", { className: "uf-text-left uf-min-w-0", children: [
|
|
24081
24403
|
/* @__PURE__ */ jsx41(
|
|
24082
24404
|
"div",
|
|
@@ -30034,11 +30356,29 @@ function useExchanges({
|
|
|
30034
30356
|
});
|
|
30035
30357
|
return { exchanges, isLoading };
|
|
30036
30358
|
}
|
|
30359
|
+
function usePublicIncident({
|
|
30360
|
+
publishableKey,
|
|
30361
|
+
enabled = true
|
|
30362
|
+
}) {
|
|
30363
|
+
const {
|
|
30364
|
+
data: incident,
|
|
30365
|
+
isLoading,
|
|
30366
|
+
error
|
|
30367
|
+
} = useQuery13({
|
|
30368
|
+
queryKey: ["unifold", "publicIncident", publishableKey],
|
|
30369
|
+
queryFn: () => getPublicIncident(publishableKey),
|
|
30370
|
+
enabled,
|
|
30371
|
+
staleTime: 1e3 * 30,
|
|
30372
|
+
refetchInterval: 1e3 * 30,
|
|
30373
|
+
refetchOnWindowFocus: true
|
|
30374
|
+
});
|
|
30375
|
+
return { incident, isLoading, error: error ?? null };
|
|
30376
|
+
}
|
|
30037
30377
|
function useApplePayProviders({
|
|
30038
30378
|
publishableKey,
|
|
30039
30379
|
enabled = true
|
|
30040
30380
|
}) {
|
|
30041
|
-
const { data: providers, isLoading } =
|
|
30381
|
+
const { data: providers, isLoading } = useQuery14({
|
|
30042
30382
|
queryKey: ["unifold", "applePayProviders", publishableKey],
|
|
30043
30383
|
queryFn: () => getApplePayProviders(publishableKey),
|
|
30044
30384
|
enabled,
|
|
@@ -30098,7 +30438,7 @@ function useAddressValidation({
|
|
|
30098
30438
|
refetchOnMount = false
|
|
30099
30439
|
}) {
|
|
30100
30440
|
const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
30101
|
-
const { data, isLoading, error } =
|
|
30441
|
+
const { data, isLoading, error } = useQuery15({
|
|
30102
30442
|
queryKey: [
|
|
30103
30443
|
"unifold",
|
|
30104
30444
|
"addressValidation",
|
|
@@ -30129,6 +30469,7 @@ function useAddressValidation({
|
|
|
30129
30469
|
return {
|
|
30130
30470
|
isValid: null,
|
|
30131
30471
|
failureCode: null,
|
|
30472
|
+
message: null,
|
|
30132
30473
|
metadata: null,
|
|
30133
30474
|
isLoading: false,
|
|
30134
30475
|
error: null
|
|
@@ -30137,6 +30478,7 @@ function useAddressValidation({
|
|
|
30137
30478
|
return {
|
|
30138
30479
|
isValid: data?.valid ?? null,
|
|
30139
30480
|
failureCode: data?.failure_code ?? null,
|
|
30481
|
+
message: data?.message ?? null,
|
|
30140
30482
|
metadata: data?.metadata ?? null,
|
|
30141
30483
|
isLoading,
|
|
30142
30484
|
error: error ?? null
|
|
@@ -30962,6 +31304,37 @@ function TokenSelectorSheet({
|
|
|
30962
31304
|
var getChainKey = (chainId, chainType) => {
|
|
30963
31305
|
return `${chainType}:${chainId}`;
|
|
30964
31306
|
};
|
|
31307
|
+
function getStoredSelection(key) {
|
|
31308
|
+
if (typeof window === "undefined") return null;
|
|
31309
|
+
try {
|
|
31310
|
+
const raw = localStorage.getItem(key);
|
|
31311
|
+
if (!raw) return null;
|
|
31312
|
+
const parsed = JSON.parse(raw);
|
|
31313
|
+
if (parsed && typeof parsed.symbol === "string" && typeof parsed.chainType === "string" && typeof parsed.chainId === "string") {
|
|
31314
|
+
return parsed;
|
|
31315
|
+
}
|
|
31316
|
+
} catch {
|
|
31317
|
+
}
|
|
31318
|
+
return null;
|
|
31319
|
+
}
|
|
31320
|
+
function saveStoredSelection(key, symbol, chainType, chainId) {
|
|
31321
|
+
if (typeof window === "undefined") return;
|
|
31322
|
+
try {
|
|
31323
|
+
localStorage.setItem(key, JSON.stringify({ symbol, chainType, chainId }));
|
|
31324
|
+
} catch {
|
|
31325
|
+
}
|
|
31326
|
+
}
|
|
31327
|
+
function resolveFromStorage(tokens, stored) {
|
|
31328
|
+
for (const t13 of tokens) {
|
|
31329
|
+
if (t13.symbol !== stored.symbol) continue;
|
|
31330
|
+
const matchedChain = t13.chains.find(
|
|
31331
|
+
(c) => c.chain_type === stored.chainType && c.chain_id === stored.chainId
|
|
31332
|
+
);
|
|
31333
|
+
if (matchedChain) return { token: t13, chain: matchedChain };
|
|
31334
|
+
if (t13.chains.length > 0) return { token: t13, chain: t13.chains[0] };
|
|
31335
|
+
}
|
|
31336
|
+
return null;
|
|
31337
|
+
}
|
|
30965
31338
|
function resolveToken(tokens, defaultChainType, defaultChainId, defaultTokenAddress, defaultSymbol) {
|
|
30966
31339
|
if (!tokens.length) return null;
|
|
30967
31340
|
let selectedToken;
|
|
@@ -31011,27 +31384,73 @@ function useDefaultToken({
|
|
|
31011
31384
|
defaultChainType,
|
|
31012
31385
|
defaultChainId,
|
|
31013
31386
|
defaultTokenAddress,
|
|
31014
|
-
defaultSymbol
|
|
31387
|
+
defaultSymbol,
|
|
31388
|
+
storageKey: storageKey2
|
|
31015
31389
|
}) {
|
|
31016
|
-
const [token,
|
|
31017
|
-
const [chain,
|
|
31390
|
+
const [token, setTokenState] = useState33(null);
|
|
31391
|
+
const [chain, setChainState] = useState33(null);
|
|
31018
31392
|
const [initialSelectionDone, setInitialSelectionDone] = useState33(false);
|
|
31019
31393
|
const appliedDefaultsRef = useRef112("");
|
|
31394
|
+
const tokenRef = useRef112(null);
|
|
31395
|
+
const chainRef = useRef112(null);
|
|
31396
|
+
tokenRef.current = token;
|
|
31397
|
+
chainRef.current = chain;
|
|
31398
|
+
const setToken = useCallback82(
|
|
31399
|
+
(newToken) => {
|
|
31400
|
+
tokenRef.current = newToken;
|
|
31401
|
+
setTokenState(newToken);
|
|
31402
|
+
if (storageKey2 && chainRef.current) {
|
|
31403
|
+
const [chainType, chainId] = chainRef.current.split(":");
|
|
31404
|
+
saveStoredSelection(storageKey2, newToken, chainType, chainId);
|
|
31405
|
+
}
|
|
31406
|
+
},
|
|
31407
|
+
[storageKey2]
|
|
31408
|
+
);
|
|
31409
|
+
const setChain = useCallback82(
|
|
31410
|
+
(newChain) => {
|
|
31411
|
+
chainRef.current = newChain;
|
|
31412
|
+
setChainState(newChain);
|
|
31413
|
+
if (storageKey2 && tokenRef.current) {
|
|
31414
|
+
const [chainType, chainId] = newChain.split(":");
|
|
31415
|
+
saveStoredSelection(storageKey2, tokenRef.current, chainType, chainId);
|
|
31416
|
+
}
|
|
31417
|
+
},
|
|
31418
|
+
[storageKey2]
|
|
31419
|
+
);
|
|
31020
31420
|
useEffect292(() => {
|
|
31021
31421
|
if (!tokens.length) return;
|
|
31022
31422
|
const defaultsKey = `${defaultTokenAddress ?? ""}|${defaultSymbol ?? ""}|${defaultChainType ?? ""}|${defaultChainId ?? ""}`;
|
|
31023
31423
|
const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
|
|
31024
31424
|
if (initialSelectionDone && !defaultsChanged) return;
|
|
31025
|
-
const
|
|
31026
|
-
|
|
31027
|
-
|
|
31028
|
-
|
|
31029
|
-
|
|
31030
|
-
|
|
31031
|
-
|
|
31425
|
+
const hasExplicitDefaults = defaultTokenAddress && defaultChainType && defaultChainId || defaultSymbol && defaultChainType && defaultChainId;
|
|
31426
|
+
let result = null;
|
|
31427
|
+
if (hasExplicitDefaults) {
|
|
31428
|
+
result = resolveToken(
|
|
31429
|
+
tokens,
|
|
31430
|
+
defaultChainType,
|
|
31431
|
+
defaultChainId,
|
|
31432
|
+
defaultTokenAddress,
|
|
31433
|
+
defaultSymbol
|
|
31434
|
+
);
|
|
31435
|
+
if (result) {
|
|
31436
|
+
const matched = defaultTokenAddress && result.chain.token_address.toLowerCase() === defaultTokenAddress.toLowerCase() && result.chain.chain_type === defaultChainType && result.chain.chain_id === defaultChainId || defaultSymbol && result.token.symbol === defaultSymbol && result.chain.chain_type === defaultChainType && result.chain.chain_id === defaultChainId;
|
|
31437
|
+
if (!matched) {
|
|
31438
|
+
result = null;
|
|
31439
|
+
}
|
|
31440
|
+
}
|
|
31441
|
+
}
|
|
31442
|
+
if (!result && storageKey2) {
|
|
31443
|
+
const stored = getStoredSelection(storageKey2);
|
|
31444
|
+
if (stored) {
|
|
31445
|
+
result = resolveFromStorage(tokens, stored);
|
|
31446
|
+
}
|
|
31447
|
+
}
|
|
31448
|
+
if (!result) {
|
|
31449
|
+
result = resolveToken(tokens);
|
|
31450
|
+
}
|
|
31032
31451
|
if (result) {
|
|
31033
|
-
|
|
31034
|
-
|
|
31452
|
+
setTokenState(result.token.symbol);
|
|
31453
|
+
setChainState(getChainKey(result.chain.chain_id, result.chain.chain_type));
|
|
31035
31454
|
appliedDefaultsRef.current = defaultsKey;
|
|
31036
31455
|
setInitialSelectionDone(true);
|
|
31037
31456
|
}
|
|
@@ -31041,7 +31460,8 @@ function useDefaultToken({
|
|
|
31041
31460
|
defaultSymbol,
|
|
31042
31461
|
defaultChainType,
|
|
31043
31462
|
defaultChainId,
|
|
31044
|
-
initialSelectionDone
|
|
31463
|
+
initialSelectionDone,
|
|
31464
|
+
storageKey2
|
|
31045
31465
|
]);
|
|
31046
31466
|
useEffect292(() => {
|
|
31047
31467
|
if (!tokens.length || !token) return;
|
|
@@ -31052,11 +31472,12 @@ function useDefaultToken({
|
|
|
31052
31472
|
});
|
|
31053
31473
|
if (!isChainAvailable) {
|
|
31054
31474
|
const firstChain = currentToken.chains[0];
|
|
31055
|
-
|
|
31475
|
+
setChainState(getChainKey(firstChain.chain_id, firstChain.chain_type));
|
|
31056
31476
|
}
|
|
31057
31477
|
}, [token, tokens, chain]);
|
|
31058
31478
|
return { token, chain, setToken, setChain, initialSelectionDone };
|
|
31059
31479
|
}
|
|
31480
|
+
var STORAGE_KEY2 = "unifold_last_deposit_from_token";
|
|
31060
31481
|
function useDefaultSourceToken({
|
|
31061
31482
|
supportedTokens,
|
|
31062
31483
|
defaultSourceChainType,
|
|
@@ -31069,7 +31490,8 @@ function useDefaultSourceToken({
|
|
|
31069
31490
|
defaultChainType: defaultSourceChainType,
|
|
31070
31491
|
defaultChainId: defaultSourceChainId,
|
|
31071
31492
|
defaultTokenAddress: defaultSourceTokenAddress,
|
|
31072
|
-
defaultSymbol: defaultSourceSymbol
|
|
31493
|
+
defaultSymbol: defaultSourceSymbol,
|
|
31494
|
+
storageKey: STORAGE_KEY2
|
|
31073
31495
|
});
|
|
31074
31496
|
}
|
|
31075
31497
|
function DepositFooterLinks({ onGlossaryClick, leftElement }) {
|
|
@@ -31400,7 +31822,7 @@ function useHypercoreActivation(params) {
|
|
|
31400
31822
|
const recipient = recipientAddress?.trim() ?? "";
|
|
31401
31823
|
const source = sourceAddress?.trim() ?? "";
|
|
31402
31824
|
const hasAddresses = !!recipient && !!source;
|
|
31403
|
-
const { data, isLoading } =
|
|
31825
|
+
const { data, isLoading } = useQuery16({
|
|
31404
31826
|
queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
|
|
31405
31827
|
queryFn: () => checkHypercoreActivation(
|
|
31406
31828
|
{
|
|
@@ -32968,7 +33390,7 @@ function useDepositQuote(params) {
|
|
|
32968
33390
|
...adjustForSlippage ? { adjust_for_slippage: true } : {},
|
|
32969
33391
|
...stablecoinParity ? { stablecoin_parity: true } : {}
|
|
32970
33392
|
};
|
|
32971
|
-
return
|
|
33393
|
+
return useQuery17({
|
|
32972
33394
|
queryKey: [
|
|
32973
33395
|
"unifold",
|
|
32974
33396
|
"depositQuote",
|
|
@@ -32998,7 +33420,7 @@ function useExternalWallets({
|
|
|
32998
33420
|
publishableKey,
|
|
32999
33421
|
enabled = true
|
|
33000
33422
|
}) {
|
|
33001
|
-
const { data: wallets = [], isLoading } =
|
|
33423
|
+
const { data: wallets = [], isLoading } = useQuery18({
|
|
33002
33424
|
queryKey: ["unifold", "external-wallets", publishableKey],
|
|
33003
33425
|
queryFn: () => getExternalWallets(publishableKey).then((res) => res.data),
|
|
33004
33426
|
enabled: enabled && !!publishableKey,
|
|
@@ -34081,33 +34503,11 @@ function balancesRepresentSameToken(a, b) {
|
|
|
34081
34503
|
if (!tokenA || !tokenB) return false;
|
|
34082
34504
|
return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
|
|
34083
34505
|
}
|
|
34084
|
-
function getSolanaProviders() {
|
|
34085
|
-
if (typeof window === "undefined") return {};
|
|
34086
|
-
const win = window;
|
|
34087
|
-
return {
|
|
34088
|
-
phantomSolana: win.phantom?.solana,
|
|
34089
|
-
solflare: win.solflare,
|
|
34090
|
-
backpack: win.backpack,
|
|
34091
|
-
glow: win.glow,
|
|
34092
|
-
coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
|
|
34093
|
-
};
|
|
34094
|
-
}
|
|
34095
|
-
function getLegacyEvmProviders() {
|
|
34096
|
-
if (typeof window === "undefined") return {};
|
|
34097
|
-
const win = window;
|
|
34098
|
-
return {
|
|
34099
|
-
ethereum: win.ethereum,
|
|
34100
|
-
phantomEthereum: win.phantom?.ethereum,
|
|
34101
|
-
coinbaseEthereum: win.coinbaseWalletExtension,
|
|
34102
|
-
trustEthereum: win.trustwallet?.ethereum,
|
|
34103
|
-
okxEthereum: win.okxwallet
|
|
34104
|
-
};
|
|
34105
|
-
}
|
|
34106
34506
|
function detectAvailableWallets(definitions, recentWalletId, filterChainType) {
|
|
34107
|
-
const solProviders = getSolanaProviders();
|
|
34108
|
-
const legacyEvm = getLegacyEvmProviders();
|
|
34109
|
-
const eip6963List = getEip6963Providers();
|
|
34110
34507
|
const win = typeof window !== "undefined" ? window : null;
|
|
34508
|
+
const solProviders = getInjectedSolanaProviders(win);
|
|
34509
|
+
const legacyEvm = getLegacyEvmProviders(win);
|
|
34510
|
+
const eip6963List = getEip6963Providers();
|
|
34111
34511
|
const hasEip6963 = (walletId) => eip6963List.some((d) => {
|
|
34112
34512
|
const rdns = d.info?.rdns || "";
|
|
34113
34513
|
switch (walletId) {
|
|
@@ -34376,10 +34776,13 @@ function WalletConnect({
|
|
|
34376
34776
|
};
|
|
34377
34777
|
const openMobileWalletBrowse = async (wallet, depositAddresses) => {
|
|
34378
34778
|
try {
|
|
34779
|
+
const cleanedAmountUsd = amountUsd?.replace(/[^0-9.]/g, "") ?? "";
|
|
34780
|
+
const forwardedAmountUsd = parseFloat(cleanedAmountUsd) > 0 ? cleanedAmountUsd : void 0;
|
|
34379
34781
|
const res = await getWalletMobileDeepLink(
|
|
34380
34782
|
wallet.id,
|
|
34381
34783
|
depositAddresses,
|
|
34382
|
-
publishableKey
|
|
34784
|
+
publishableKey,
|
|
34785
|
+
forwardedAmountUsd
|
|
34383
34786
|
);
|
|
34384
34787
|
if (res.deeplink) {
|
|
34385
34788
|
setMobileRedirect({ walletId: wallet.id, walletName: wallet.name, deeplink: res.deeplink });
|
|
@@ -34468,7 +34871,7 @@ function WalletConnect({
|
|
|
34468
34871
|
const eip6963Match = findProviderByWalletId(wallet.id);
|
|
34469
34872
|
let provider = eip6963Match?.provider;
|
|
34470
34873
|
if (!provider) {
|
|
34471
|
-
const legacyEvm = getLegacyEvmProviders();
|
|
34874
|
+
const legacyEvm = getLegacyEvmProviders(win);
|
|
34472
34875
|
switch (wallet.id) {
|
|
34473
34876
|
case "metamask":
|
|
34474
34877
|
if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom)
|
|
@@ -34500,16 +34903,7 @@ function WalletConnect({
|
|
|
34500
34903
|
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
34501
34904
|
if (!accounts?.length) throw new Error("No accounts returned from wallet");
|
|
34502
34905
|
setUserDisconnectedWallet(false);
|
|
34503
|
-
const
|
|
34504
|
-
phantom: "phantom-ethereum",
|
|
34505
|
-
coinbase: "coinbase",
|
|
34506
|
-
trust: "trust",
|
|
34507
|
-
rainbow: "rainbow",
|
|
34508
|
-
rabby: "rabby",
|
|
34509
|
-
okx: "okx",
|
|
34510
|
-
metamask: "metamask"
|
|
34511
|
-
};
|
|
34512
|
-
const walletType = walletIdToType[wallet.id] || "metamask";
|
|
34906
|
+
const walletType = walletIdToWalletType(wallet.id);
|
|
34513
34907
|
setStoredWalletState(walletType);
|
|
34514
34908
|
connectedInfo = {
|
|
34515
34909
|
type: walletType,
|
|
@@ -34518,7 +34912,7 @@ function WalletConnect({
|
|
|
34518
34912
|
icon: wallet.id
|
|
34519
34913
|
};
|
|
34520
34914
|
} else {
|
|
34521
|
-
const solProviders =
|
|
34915
|
+
const solProviders = getInjectedSolanaProviders(win);
|
|
34522
34916
|
let provider;
|
|
34523
34917
|
switch (wallet.id) {
|
|
34524
34918
|
case "phantom":
|
|
@@ -34537,11 +34931,11 @@ function WalletConnect({
|
|
|
34537
34931
|
provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
|
|
34538
34932
|
break;
|
|
34539
34933
|
case "trust":
|
|
34540
|
-
provider =
|
|
34934
|
+
provider = solProviders.trustSolana;
|
|
34541
34935
|
break;
|
|
34542
34936
|
}
|
|
34543
34937
|
if (!provider) throw new Error(`${wallet.name} Solana wallet not found.`);
|
|
34544
|
-
const response = await provider.
|
|
34938
|
+
const response = await connectSolanaProviderWithRecovery(provider, wallet.id, wallet.name);
|
|
34545
34939
|
setUserDisconnectedWallet(false);
|
|
34546
34940
|
const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
|
|
34547
34941
|
setStoredWalletState(walletType);
|
|
@@ -34892,16 +35286,7 @@ function WalletConnect({
|
|
|
34892
35286
|
return (integerPart + decimalPart.padEnd(decimals, "0").slice(0, decimals)).replace(/^0+/, "") || "0";
|
|
34893
35287
|
};
|
|
34894
35288
|
const resolveEvmProvider = () => {
|
|
34895
|
-
const
|
|
34896
|
-
"phantom-ethereum": "phantom",
|
|
34897
|
-
coinbase: "coinbase",
|
|
34898
|
-
trust: "trust",
|
|
34899
|
-
okx: "okx",
|
|
34900
|
-
rainbow: "rainbow",
|
|
34901
|
-
rabby: "rabby",
|
|
34902
|
-
metamask: "metamask"
|
|
34903
|
-
};
|
|
34904
|
-
const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
|
|
35289
|
+
const lookupId = walletTypeToWalletId(walletInfo.type);
|
|
34905
35290
|
const eip6963Match = findProviderByWalletId(lookupId);
|
|
34906
35291
|
let provider = eip6963Match?.provider;
|
|
34907
35292
|
if (!provider) {
|
|
@@ -35630,6 +36015,7 @@ function DepositModal({
|
|
|
35630
36015
|
applePayTitle = "Pay with Apple Pay",
|
|
35631
36016
|
applePaySubTitle = "Instant",
|
|
35632
36017
|
enableBankTransfer,
|
|
36018
|
+
enableIncidentBanner = false,
|
|
35633
36019
|
// No default: left undefined so the backend `stripe_link.enabled` can govern
|
|
35634
36020
|
// (via the `??` chain in showStripeLink) once a dashboard toggle exists.
|
|
35635
36021
|
enableStripeLink,
|
|
@@ -35654,7 +36040,7 @@ function DepositModal({
|
|
|
35654
36040
|
() => normalizePrefilledUsdAmount(prefilledAmountUsd),
|
|
35655
36041
|
[prefilledAmountUsd]
|
|
35656
36042
|
);
|
|
35657
|
-
const onDepositSuccessFor =
|
|
36043
|
+
const onDepositSuccessFor = useCallback11(
|
|
35658
36044
|
(method) => onDepositSuccess || onEvent ? (data) => {
|
|
35659
36045
|
const payload = { ...data, method };
|
|
35660
36046
|
onDepositSuccess?.(payload);
|
|
@@ -35667,7 +36053,7 @@ function DepositModal({
|
|
|
35667
36053
|
} : void 0,
|
|
35668
36054
|
[onDepositSuccess, onEvent]
|
|
35669
36055
|
);
|
|
35670
|
-
const onDepositErrorFor =
|
|
36056
|
+
const onDepositErrorFor = useCallback11(
|
|
35671
36057
|
(method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
|
|
35672
36058
|
[onDepositError]
|
|
35673
36059
|
);
|
|
@@ -35675,7 +36061,7 @@ function DepositModal({
|
|
|
35675
36061
|
const s = initialScreen ?? "main";
|
|
35676
36062
|
if (s === "tracker" && hideDepositTracker === true) return "main";
|
|
35677
36063
|
if (s === "cashapp" && enableCashApp === false) return "main";
|
|
35678
|
-
if (s === "stripe_link" &&
|
|
36064
|
+
if (s === "stripe_link" && enableStripeLink === false) return "main";
|
|
35679
36065
|
if (s === "apple_pay" && enableApplePay === false) return "main";
|
|
35680
36066
|
if (s === "card" && enableFiatOnramp === false) return "main";
|
|
35681
36067
|
if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
|
|
@@ -35697,7 +36083,7 @@ function DepositModal({
|
|
|
35697
36083
|
enableStripeLink
|
|
35698
36084
|
]);
|
|
35699
36085
|
const [containerEl, setContainerEl] = useState40(null);
|
|
35700
|
-
const containerCallbackRef =
|
|
36086
|
+
const containerCallbackRef = useCallback11((el) => {
|
|
35701
36087
|
setContainerEl(el);
|
|
35702
36088
|
}, []);
|
|
35703
36089
|
const [view, setView] = useState40(effectiveInitialScreen);
|
|
@@ -35734,6 +36120,16 @@ function DepositModal({
|
|
|
35734
36120
|
const showApplePay = enableApplePay ?? projectConfig?.apple_pay?.enabled ?? true;
|
|
35735
36121
|
const showBankTransfer = enableBankTransfer ?? projectConfig?.bank_transfer?.enabled ?? true;
|
|
35736
36122
|
const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
|
|
36123
|
+
const { incident: publicIncident } = usePublicIncident({
|
|
36124
|
+
publishableKey,
|
|
36125
|
+
enabled: open && enableIncidentBanner
|
|
36126
|
+
});
|
|
36127
|
+
const activeIncident = enableIncidentBanner && publicIncident?.enabled && (publicIncident.messages?.length ?? 0) > 0 ? {
|
|
36128
|
+
enabled: true,
|
|
36129
|
+
messages: publicIncident.messages,
|
|
36130
|
+
severity: publicIncident.severity,
|
|
36131
|
+
statusPageUrl: publicIncident.status_page_url
|
|
36132
|
+
} : void 0;
|
|
35737
36133
|
const [integrationExchanges, setIntegrationExchanges] = useState40([]);
|
|
35738
36134
|
useEffect34(() => {
|
|
35739
36135
|
if (!showConnectExchange || !open) return;
|
|
@@ -35800,7 +36196,11 @@ function DepositModal({
|
|
|
35800
36196
|
setConnectedExchange((prev) => prev ? { ...prev, iconUrl } : prev);
|
|
35801
36197
|
}
|
|
35802
36198
|
}, [integrationExchanges, connectedExchange]);
|
|
35803
|
-
const {
|
|
36199
|
+
const {
|
|
36200
|
+
data: depositAddressResponse,
|
|
36201
|
+
isLoading: walletsLoading,
|
|
36202
|
+
error: walletsError
|
|
36203
|
+
} = useDepositAddress({
|
|
35804
36204
|
userId,
|
|
35805
36205
|
publishableKey,
|
|
35806
36206
|
recipientAddress,
|
|
@@ -35933,6 +36333,7 @@ function DepositModal({
|
|
|
35933
36333
|
const {
|
|
35934
36334
|
isValid: isAddressValid,
|
|
35935
36335
|
failureCode: addressFailureCode,
|
|
36336
|
+
message: addressFailureMessage,
|
|
35936
36337
|
metadata: addressFailureMetadata,
|
|
35937
36338
|
isLoading: isAddressValidationLoading
|
|
35938
36339
|
} = useAddressValidation({
|
|
@@ -35946,17 +36347,31 @@ function DepositModal({
|
|
|
35946
36347
|
refetchOnMount: "always"
|
|
35947
36348
|
});
|
|
35948
36349
|
const addressValidationMessages = i18n2.transferCrypto.addressValidation;
|
|
35949
|
-
const getAddressValidationErrorMessage = (code, metadata) => {
|
|
36350
|
+
const getAddressValidationErrorMessage = (message, code, metadata) => {
|
|
36351
|
+
if (message && message.trim().length > 0) return message;
|
|
35950
36352
|
if (!code) return addressValidationMessages.defaultError;
|
|
35951
36353
|
const errors = addressValidationMessages.errors;
|
|
35952
36354
|
const template = errors[code] ?? addressValidationMessages.defaultError;
|
|
35953
36355
|
return interpolate(template, metadata);
|
|
35954
36356
|
};
|
|
36357
|
+
const walletsRecipientError = isDepositAddressValidationError(walletsError) ? walletsError.message : null;
|
|
36358
|
+
const isRecipientAddressInvalid = isAddressValid === false || walletsRecipientError !== null;
|
|
36359
|
+
const recipientInvalidMessage = getAddressValidationErrorMessage(
|
|
36360
|
+
addressFailureMessage ?? walletsRecipientError,
|
|
36361
|
+
addressFailureCode,
|
|
36362
|
+
addressFailureMetadata
|
|
36363
|
+
);
|
|
35955
36364
|
const openingScreen = effectiveInitialScreen;
|
|
35956
36365
|
const sessionOpenedFromMenu = openingScreen === "main";
|
|
35957
36366
|
const standaloneNeedsDepositPrereq = openingScreen !== "main" && (view === "transfer" || view === "card");
|
|
35958
36367
|
let depositPrerequisiteBody;
|
|
35959
|
-
if (
|
|
36368
|
+
if (isRecipientAddressInvalid) {
|
|
36369
|
+
depositPrerequisiteBody = /* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
36370
|
+
/* @__PURE__ */ jsx63("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ jsx63(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
36371
|
+
/* @__PURE__ */ jsx63("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: addressValidationMessages.unableToReceiveFunds }),
|
|
36372
|
+
/* @__PURE__ */ jsx63("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: recipientInvalidMessage })
|
|
36373
|
+
] });
|
|
36374
|
+
} else if (isCountryLoading || isAddressValidationLoading || tokensLoading || walletsLoading || !projectConfig || // Bank-transfer row visibility depends on the country-gated providers
|
|
35960
36375
|
// fetch — block the menu on it so the row never flashes in or out.
|
|
35961
36376
|
showBankTransfer && bankTransferProvidersLoading || // Same for Apple Pay: row visibility depends on the geo/platform-gated
|
|
35962
36377
|
// providers fetch — block the menu so the row doesn't pop in or out.
|
|
@@ -35978,12 +36393,6 @@ function DepositModal({
|
|
|
35978
36393
|
/* @__PURE__ */ jsx63("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: "No Tokens Available" }),
|
|
35979
36394
|
/* @__PURE__ */ jsx63("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: "There are no supported tokens available from your current location." })
|
|
35980
36395
|
] });
|
|
35981
|
-
} else if (isAddressValid === false) {
|
|
35982
|
-
depositPrerequisiteBody = /* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
35983
|
-
/* @__PURE__ */ jsx63("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ jsx63(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
35984
|
-
/* @__PURE__ */ jsx63("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: addressValidationMessages.unableToReceiveFunds }),
|
|
35985
|
-
/* @__PURE__ */ jsx63("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: getAddressValidationErrorMessage(addressFailureCode, addressFailureMetadata) })
|
|
35986
|
-
] });
|
|
35987
36396
|
} else {
|
|
35988
36397
|
depositPrerequisiteBody = null;
|
|
35989
36398
|
}
|
|
@@ -36477,6 +36886,7 @@ function DepositModal({
|
|
|
36477
36886
|
title: modalTitle || "Deposit",
|
|
36478
36887
|
showClose: !hideOverlay,
|
|
36479
36888
|
onClose: handleClose,
|
|
36889
|
+
incident: activeIncident,
|
|
36480
36890
|
showBalance: showBalanceHeader,
|
|
36481
36891
|
balanceAddress: recipientAddress,
|
|
36482
36892
|
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
|
|
@@ -36496,6 +36906,7 @@ function DepositModal({
|
|
|
36496
36906
|
showBack: showBackTransfer,
|
|
36497
36907
|
onBack: handleBack,
|
|
36498
36908
|
onClose: handleClose,
|
|
36909
|
+
incident: activeIncident,
|
|
36499
36910
|
showBalance: showBalanceHeader,
|
|
36500
36911
|
balanceAddress: recipientAddress,
|
|
36501
36912
|
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
|
|
@@ -36556,7 +36967,8 @@ function DepositModal({
|
|
|
36556
36967
|
title: selectedExecution ? "Deposit Details" : depositTrackerTitle,
|
|
36557
36968
|
showBack: showBackTracker,
|
|
36558
36969
|
onBack: handleBack,
|
|
36559
|
-
onClose: handleClose
|
|
36970
|
+
onClose: handleClose,
|
|
36971
|
+
incident: activeIncident
|
|
36560
36972
|
}
|
|
36561
36973
|
),
|
|
36562
36974
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -36588,6 +37000,7 @@ function DepositModal({
|
|
|
36588
37000
|
showBack: showBackCard,
|
|
36589
37001
|
onBack: handleBack,
|
|
36590
37002
|
onClose: handleClose,
|
|
37003
|
+
incident: activeIncident,
|
|
36591
37004
|
badge: cardView === "quotes" ? { count: quotesCount } : void 0,
|
|
36592
37005
|
showBalance: showBalanceHeader,
|
|
36593
37006
|
balanceAddress: recipientAddress,
|
|
@@ -36637,7 +37050,8 @@ function DepositModal({
|
|
|
36637
37050
|
title: payWithExchangeTitle,
|
|
36638
37051
|
showBack: exchangeView === "pending" || sessionOpenedFromMenu,
|
|
36639
37052
|
onBack: handleBack,
|
|
36640
|
-
onClose: handleClose
|
|
37053
|
+
onClose: handleClose,
|
|
37054
|
+
incident: activeIncident
|
|
36641
37055
|
}
|
|
36642
37056
|
),
|
|
36643
37057
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -36751,7 +37165,8 @@ function DepositModal({
|
|
|
36751
37165
|
title: t8.bankTransfer.title,
|
|
36752
37166
|
showBack: bankTransferView !== "providers" || sessionOpenedFromMenu,
|
|
36753
37167
|
onBack: handleBack,
|
|
36754
|
-
onClose: handleClose
|
|
37168
|
+
onClose: handleClose,
|
|
37169
|
+
incident: activeIncident
|
|
36755
37170
|
}
|
|
36756
37171
|
),
|
|
36757
37172
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -36785,26 +37200,24 @@ function DepositModal({
|
|
|
36785
37200
|
title: "Deposit with Link",
|
|
36786
37201
|
showBack: stripeLinkStep !== "checkout" && stripeLinkStep !== "success",
|
|
36787
37202
|
onBack: handleBack,
|
|
37203
|
+
incident: activeIncident,
|
|
36788
37204
|
showClose: stripeLinkStep !== "checkout" && stripeLinkStep !== "auth",
|
|
36789
37205
|
onClose: handleClose
|
|
36790
37206
|
}
|
|
36791
37207
|
),
|
|
36792
37208
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
36793
37209
|
isLoadingIp ? (
|
|
36794
|
-
//
|
|
36795
|
-
// PayWithStripeLink (which kicks off config/OAuth work) for a
|
|
36796
|
-
// deep-link user who turns out to be outside the US.
|
|
37210
|
+
// Wait for location so the first config fetch is region-aware.
|
|
36797
37211
|
/* @__PURE__ */ jsx63(SkeletonButton, { variant: "with-icons" })
|
|
36798
37212
|
) : !showStripeLink ? (
|
|
36799
|
-
//
|
|
36800
|
-
//
|
|
36801
|
-
//
|
|
36802
|
-
// the Link UI.
|
|
37213
|
+
// Direct opens (initialScreen="stripe_link") have no menu row
|
|
37214
|
+
// to fall back to, so render an unavailable state when backend
|
|
37215
|
+
// config resolves Stripe Link disabled/hidden.
|
|
36803
37216
|
/* @__PURE__ */ jsx63(
|
|
36804
37217
|
GeoRestrictionScreen,
|
|
36805
37218
|
{
|
|
36806
37219
|
methodName: t8.stripeLink.title,
|
|
36807
|
-
message:
|
|
37220
|
+
message: t8.stripeLink.unavailableInRegionMessage
|
|
36808
37221
|
}
|
|
36809
37222
|
)
|
|
36810
37223
|
) : /* @__PURE__ */ jsx63(
|
|
@@ -36837,7 +37250,8 @@ function DepositModal({
|
|
|
36837
37250
|
title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
|
|
36838
37251
|
showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
|
|
36839
37252
|
onBack: handleBack,
|
|
36840
|
-
onClose: handleClose
|
|
37253
|
+
onClose: handleClose,
|
|
37254
|
+
incident: activeIncident
|
|
36841
37255
|
}
|
|
36842
37256
|
),
|
|
36843
37257
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -36873,7 +37287,8 @@ function DepositModal({
|
|
|
36873
37287
|
const handled = applePayHandleRef.current?.requestBack() ?? false;
|
|
36874
37288
|
if (!handled) handleBack();
|
|
36875
37289
|
},
|
|
36876
|
-
onClose: handleClose
|
|
37290
|
+
onClose: handleClose,
|
|
37291
|
+
incident: activeIncident
|
|
36877
37292
|
}
|
|
36878
37293
|
),
|
|
36879
37294
|
/* @__PURE__ */ jsxs57("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -36916,7 +37331,7 @@ function DepositModal({
|
|
|
36916
37331
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
|
|
36917
37332
|
function usePaymentIntent(params) {
|
|
36918
37333
|
const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
|
|
36919
|
-
return
|
|
37334
|
+
return useQuery19({
|
|
36920
37335
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
36921
37336
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
36922
37337
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
@@ -36988,6 +37403,7 @@ function CheckoutModal({
|
|
|
36988
37403
|
modalTitle,
|
|
36989
37404
|
enableTransferCrypto,
|
|
36990
37405
|
enableConnectWallet,
|
|
37406
|
+
enableIncidentBanner = false,
|
|
36991
37407
|
defaultSourceChainType,
|
|
36992
37408
|
defaultSourceChainId,
|
|
36993
37409
|
defaultSourceTokenAddress,
|
|
@@ -37003,7 +37419,7 @@ function CheckoutModal({
|
|
|
37003
37419
|
const [browserWalletInfo, setBrowserWalletInfo] = useState41(null);
|
|
37004
37420
|
const [browserWalletChainType, setBrowserWalletChainType] = useState41(() => getStoredWalletState()?.chainType);
|
|
37005
37421
|
const lastCheckoutMethodRef = useRef142(void 0);
|
|
37006
|
-
const emitCheckoutSuccess =
|
|
37422
|
+
const emitCheckoutSuccess = useCallback122(
|
|
37007
37423
|
(data, method) => {
|
|
37008
37424
|
const isSucceeded = data.status === "succeeded";
|
|
37009
37425
|
const richIntent = isSucceeded && data.paymentIntent ? mapToCheckoutPaymentIntent(data.paymentIntent) : void 0;
|
|
@@ -37059,6 +37475,16 @@ function CheckoutModal({
|
|
|
37059
37475
|
});
|
|
37060
37476
|
const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
|
|
37061
37477
|
const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
|
|
37478
|
+
const { incident: publicIncident } = usePublicIncident({
|
|
37479
|
+
publishableKey,
|
|
37480
|
+
enabled: open && enableIncidentBanner
|
|
37481
|
+
});
|
|
37482
|
+
const activeIncident = enableIncidentBanner && publicIncident?.enabled && (publicIncident.messages?.length ?? 0) > 0 ? {
|
|
37483
|
+
enabled: true,
|
|
37484
|
+
messages: publicIncident.messages,
|
|
37485
|
+
severity: publicIncident.severity,
|
|
37486
|
+
statusPageUrl: publicIncident.status_page_url
|
|
37487
|
+
} : void 0;
|
|
37062
37488
|
useEffect35(() => {
|
|
37063
37489
|
if (view === "transfer" && !showTransferCrypto) {
|
|
37064
37490
|
setView("main");
|
|
@@ -37154,7 +37580,7 @@ function CheckoutModal({
|
|
|
37154
37580
|
sourceAmountUsd: minUsd.toFixed(2)
|
|
37155
37581
|
};
|
|
37156
37582
|
}, [sourceQuote, selectedSource]);
|
|
37157
|
-
const handleBrowserWalletClick =
|
|
37583
|
+
const handleBrowserWalletClick = useCallback122(
|
|
37158
37584
|
(walletInfo) => {
|
|
37159
37585
|
const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
|
|
37160
37586
|
setStoredWalletState(walletInfo.type);
|
|
@@ -37177,19 +37603,19 @@ function CheckoutModal({
|
|
|
37177
37603
|
},
|
|
37178
37604
|
[wallets, onCheckoutError]
|
|
37179
37605
|
);
|
|
37180
|
-
const handleWalletConnectClick =
|
|
37606
|
+
const handleWalletConnectClick = useCallback122(() => {
|
|
37181
37607
|
setBrowserWalletInfo(null);
|
|
37182
37608
|
lastCheckoutMethodRef.current = "wallet_connect";
|
|
37183
37609
|
setView("wallet_connect");
|
|
37184
37610
|
}, []);
|
|
37185
|
-
const handleWalletDisconnect =
|
|
37611
|
+
const handleWalletDisconnect = useCallback122(() => {
|
|
37186
37612
|
setUserDisconnectedWallet(true);
|
|
37187
37613
|
clearStoredWalletState();
|
|
37188
37614
|
setBrowserWalletChainType(void 0);
|
|
37189
37615
|
setBrowserWalletInfo(null);
|
|
37190
37616
|
setView("main");
|
|
37191
37617
|
}, []);
|
|
37192
|
-
const handleClose =
|
|
37618
|
+
const handleClose = useCallback122(() => {
|
|
37193
37619
|
onOpenChange(false);
|
|
37194
37620
|
if (resetViewTimeoutRef.current) {
|
|
37195
37621
|
clearTimeout(resetViewTimeoutRef.current);
|
|
@@ -37219,7 +37645,7 @@ function CheckoutModal({
|
|
|
37219
37645
|
},
|
|
37220
37646
|
[]
|
|
37221
37647
|
);
|
|
37222
|
-
const handleBack =
|
|
37648
|
+
const handleBack = useCallback122(() => {
|
|
37223
37649
|
setView("main");
|
|
37224
37650
|
}, []);
|
|
37225
37651
|
const poweredByFooter = /* @__PURE__ */ jsx64("div", { className: "uf-pt-3", children: /* @__PURE__ */ jsx64(
|
|
@@ -37360,7 +37786,15 @@ function CheckoutModal({
|
|
|
37360
37786
|
{
|
|
37361
37787
|
className: view === "wallet_connect" ? "uf-flex uf-min-h-0 uf-flex-col" : void 0,
|
|
37362
37788
|
children: view === "main" ? /* @__PURE__ */ jsxs58(Fragment15, { children: [
|
|
37363
|
-
/* @__PURE__ */ jsx64(
|
|
37789
|
+
/* @__PURE__ */ jsx64(
|
|
37790
|
+
DepositHeader,
|
|
37791
|
+
{
|
|
37792
|
+
title: modalTitle || "Checkout",
|
|
37793
|
+
showClose: true,
|
|
37794
|
+
onClose: handleClose,
|
|
37795
|
+
incident: activeIncident
|
|
37796
|
+
}
|
|
37797
|
+
),
|
|
37364
37798
|
/* @__PURE__ */ jsxs58("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
37365
37799
|
piLoading ? /* @__PURE__ */ jsxs58("div", { className: "uf-space-y-3", children: [
|
|
37366
37800
|
/* @__PURE__ */ jsx64(
|
|
@@ -37458,7 +37892,8 @@ function CheckoutModal({
|
|
|
37458
37892
|
title: modalTitle || "Checkout",
|
|
37459
37893
|
showBack: true,
|
|
37460
37894
|
onBack: handleBack,
|
|
37461
|
-
onClose: handleClose
|
|
37895
|
+
onClose: handleClose,
|
|
37896
|
+
incident: activeIncident
|
|
37462
37897
|
}
|
|
37463
37898
|
),
|
|
37464
37899
|
/* @__PURE__ */ jsxs58("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
@@ -37618,7 +38053,7 @@ function CheckoutModal({
|
|
|
37618
38053
|
) }) });
|
|
37619
38054
|
}
|
|
37620
38055
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
37621
|
-
return
|
|
38056
|
+
return useQuery20({
|
|
37622
38057
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
37623
38058
|
queryFn: () => getSupportedDestinationTokens(publishableKey),
|
|
37624
38059
|
staleTime: 1e3 * 60 * 5,
|
|
@@ -37628,6 +38063,7 @@ function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
|
37628
38063
|
enabled
|
|
37629
38064
|
});
|
|
37630
38065
|
}
|
|
38066
|
+
var STORAGE_KEY3 = "unifold_last_withdraw_to_token";
|
|
37631
38067
|
function useDefaultDestinationToken({
|
|
37632
38068
|
destinationTokens,
|
|
37633
38069
|
defaultDestinationChainType,
|
|
@@ -37640,7 +38076,8 @@ function useDefaultDestinationToken({
|
|
|
37640
38076
|
defaultChainType: defaultDestinationChainType,
|
|
37641
38077
|
defaultChainId: defaultDestinationChainId,
|
|
37642
38078
|
defaultTokenAddress: defaultDestinationTokenAddress,
|
|
37643
|
-
defaultSymbol: defaultDestinationSymbol
|
|
38079
|
+
defaultSymbol: defaultDestinationSymbol,
|
|
38080
|
+
storageKey: STORAGE_KEY3
|
|
37644
38081
|
});
|
|
37645
38082
|
}
|
|
37646
38083
|
function useSourceTokenValidation(params) {
|
|
@@ -37653,7 +38090,7 @@ function useSourceTokenValidation(params) {
|
|
|
37653
38090
|
enabled = true
|
|
37654
38091
|
} = params;
|
|
37655
38092
|
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
37656
|
-
return
|
|
38093
|
+
return useQuery21({
|
|
37657
38094
|
queryKey: [
|
|
37658
38095
|
"unifold",
|
|
37659
38096
|
"sourceTokenValidation",
|
|
@@ -37702,7 +38139,7 @@ function useSourceTokenValidation(params) {
|
|
|
37702
38139
|
function useAddressBalance(params) {
|
|
37703
38140
|
const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
|
|
37704
38141
|
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
37705
|
-
return
|
|
38142
|
+
return useQuery222({
|
|
37706
38143
|
queryKey: [
|
|
37707
38144
|
"unifold",
|
|
37708
38145
|
"addressBalance",
|
|
@@ -37758,7 +38195,7 @@ function useAddressBalance(params) {
|
|
|
37758
38195
|
}
|
|
37759
38196
|
function useExecutions(userId, publishableKey, options) {
|
|
37760
38197
|
const actionType = options?.actionType ?? ActionType.Deposit;
|
|
37761
|
-
return
|
|
38198
|
+
return useQuery23({
|
|
37762
38199
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
37763
38200
|
queryFn: () => queryExecutions(userId, publishableKey, actionType),
|
|
37764
38201
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
@@ -38084,7 +38521,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
38084
38521
|
} = params;
|
|
38085
38522
|
const trimmedAddress = recipientAddress?.trim() || "";
|
|
38086
38523
|
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
38087
|
-
return
|
|
38524
|
+
return useQuery24({
|
|
38088
38525
|
queryKey: [
|
|
38089
38526
|
"unifold",
|
|
38090
38527
|
"verifyRecipientAddress",
|
|
@@ -38123,7 +38560,7 @@ function useGetDepositAddress(params) {
|
|
|
38123
38560
|
enabled = true
|
|
38124
38561
|
} = params;
|
|
38125
38562
|
const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
38126
|
-
return
|
|
38563
|
+
return useQuery25({
|
|
38127
38564
|
queryKey: [
|
|
38128
38565
|
"unifold",
|
|
38129
38566
|
"getDepositAddress",
|
|
@@ -38314,6 +38751,9 @@ function WithdrawForm({
|
|
|
38314
38751
|
if (isDebouncing || isVerifyingAddress) return null;
|
|
38315
38752
|
if (verifyError) return t10.invalidAddress;
|
|
38316
38753
|
if (addressVerification && !addressVerification.valid) {
|
|
38754
|
+
if (addressVerification.message && addressVerification.message.trim().length > 0) {
|
|
38755
|
+
return addressVerification.message;
|
|
38756
|
+
}
|
|
38317
38757
|
if (addressVerification.failure_code === "account_not_found")
|
|
38318
38758
|
return `Account not found on ${selectedChain?.chain_name}`;
|
|
38319
38759
|
if (addressVerification.failure_code === "not_opted_in")
|
|
@@ -38411,7 +38851,7 @@ function WithdrawForm({
|
|
|
38411
38851
|
tokenSymbol,
|
|
38412
38852
|
isStablecoin
|
|
38413
38853
|
]);
|
|
38414
|
-
const handleSwitchUnit =
|
|
38854
|
+
const handleSwitchUnit = useCallback132(() => {
|
|
38415
38855
|
if (isMaxed && balanceData) {
|
|
38416
38856
|
if (inputUnit === "crypto") {
|
|
38417
38857
|
setAmount((Math.round(balanceUsdNum * 100) / 100).toFixed(2));
|
|
@@ -38438,7 +38878,7 @@ function WithdrawForm({
|
|
|
38438
38878
|
setInputUnit("crypto");
|
|
38439
38879
|
}
|
|
38440
38880
|
}, [amount, inputUnit, exchangeRate, sourceDecimals, isMaxed, balanceData, balanceUsdNum]);
|
|
38441
|
-
const handleMaxClick =
|
|
38881
|
+
const handleMaxClick = useCallback132(() => {
|
|
38442
38882
|
if (inputUnit === "crypto") {
|
|
38443
38883
|
if (balanceCrypto <= 0) return;
|
|
38444
38884
|
setAmount(balanceData?.balanceHuman ?? "0");
|
|
@@ -38452,7 +38892,7 @@ function WithdrawForm({
|
|
|
38452
38892
|
const isBelowMinimum = minimumWithdrawAmountUsd !== null && fiatAmountFromInput > 0 && Math.round(fiatAmountFromInput * 100) / 100 < minimumWithdrawAmountUsd;
|
|
38453
38893
|
const isOverBalance = inputUnit === "crypto" ? cryptoAmountFromInput > 0 && balanceCrypto > 0 && cryptoAmountFromInput > balanceCrypto : fiatAmountFromInput > 0 && balanceUsdNum > 0 && Math.round(fiatAmountFromInput * 100) / 100 > Math.round(balanceUsdNum * 100) / 100;
|
|
38454
38894
|
const isFormValid = trimmedAddress.length > 0 && amount.trim().length > 0 && cryptoAmountFromInput > 0 && isAddressValid && !isBelowMinimum && !isOverBalance && !isBalanceBelowMinimum && !!balanceData;
|
|
38455
|
-
const handleWithdraw =
|
|
38895
|
+
const handleWithdraw = useCallback132(async () => {
|
|
38456
38896
|
if (!selectedToken || !selectedChain) return;
|
|
38457
38897
|
if (!isFormValid) return;
|
|
38458
38898
|
setIsSubmitting(true);
|
|
@@ -39225,7 +39665,7 @@ function WithdrawModal({
|
|
|
39225
39665
|
theme = "dark",
|
|
39226
39666
|
hideOverlay = false
|
|
39227
39667
|
}) {
|
|
39228
|
-
const onWithdrawSuccessFor =
|
|
39668
|
+
const onWithdrawSuccessFor = useCallback14(
|
|
39229
39669
|
(data) => {
|
|
39230
39670
|
onWithdrawSuccess?.(data);
|
|
39231
39671
|
if (data.execution) {
|
|
@@ -39236,7 +39676,7 @@ function WithdrawModal({
|
|
|
39236
39676
|
);
|
|
39237
39677
|
const { colors: colors2, fonts, components } = useTheme();
|
|
39238
39678
|
const [containerEl, setContainerEl] = useState45(null);
|
|
39239
|
-
const containerCallbackRef =
|
|
39679
|
+
const containerCallbackRef = useCallback14((el) => {
|
|
39240
39680
|
setContainerEl(el);
|
|
39241
39681
|
}, []);
|
|
39242
39682
|
const [resolvedTheme, setResolvedTheme] = useState45(
|
|
@@ -39309,7 +39749,7 @@ function WithdrawModal({
|
|
|
39309
39749
|
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
39310
39750
|
});
|
|
39311
39751
|
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
39312
|
-
const handleDepositWalletCreation =
|
|
39752
|
+
const handleDepositWalletCreation = useCallback14(
|
|
39313
39753
|
async (params) => {
|
|
39314
39754
|
const { data: wallets } = await createDepositAddress(
|
|
39315
39755
|
{
|
|
@@ -39332,12 +39772,12 @@ function WithdrawModal({
|
|
|
39332
39772
|
},
|
|
39333
39773
|
[externalUserId, publishableKey, sourceChainType]
|
|
39334
39774
|
);
|
|
39335
|
-
const handleWithdrawSubmitted =
|
|
39775
|
+
const handleWithdrawSubmitted = useCallback14((txInfo) => {
|
|
39336
39776
|
setSubmittedTxInfo(txInfo);
|
|
39337
39777
|
setView("confirming");
|
|
39338
39778
|
}, []);
|
|
39339
39779
|
const resetViewTimeoutRef = useRef162(null);
|
|
39340
|
-
const handleClose =
|
|
39780
|
+
const handleClose = useCallback14(() => {
|
|
39341
39781
|
onOpenChange(false);
|
|
39342
39782
|
if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
|
|
39343
39783
|
resetViewTimeoutRef.current = setTimeout(() => {
|
|
@@ -39365,13 +39805,13 @@ function WithdrawModal({
|
|
|
39365
39805
|
},
|
|
39366
39806
|
[]
|
|
39367
39807
|
);
|
|
39368
|
-
const handleTokenSymbolChange =
|
|
39808
|
+
const handleTokenSymbolChange = useCallback14(
|
|
39369
39809
|
(symbol) => {
|
|
39370
39810
|
setSelectedTokenSymbol(symbol);
|
|
39371
39811
|
},
|
|
39372
39812
|
[setSelectedTokenSymbol]
|
|
39373
39813
|
);
|
|
39374
|
-
const handleChainKeyChange =
|
|
39814
|
+
const handleChainKeyChange = useCallback14(
|
|
39375
39815
|
(chainKey) => {
|
|
39376
39816
|
setSelectedChainKey(chainKey);
|
|
39377
39817
|
},
|
|
@@ -39573,6 +40013,7 @@ function UnifoldProvider2({
|
|
|
39573
40013
|
const [isWithdrawOpen, setIsWithdrawOpen] = useState39(false);
|
|
39574
40014
|
const [withdrawConfig, setWithdrawConfig] = useState39(null);
|
|
39575
40015
|
const [resolvedTheme, setResolvedTheme] = React38.useState("dark");
|
|
40016
|
+
const incidentBannerEnabled = config?.notifications?.incidentBanner;
|
|
39576
40017
|
useEffect40(() => {
|
|
39577
40018
|
if (publishableKey) {
|
|
39578
40019
|
setApiConfig({ publishableKey });
|
|
@@ -39603,7 +40044,7 @@ function UnifoldProvider2({
|
|
|
39603
40044
|
withdrawConfigRef.current = withdrawConfig;
|
|
39604
40045
|
const withdrawCloseTimeoutRef = React38.useRef(null);
|
|
39605
40046
|
const withdrawCloseGuardRef = React38.useRef(false);
|
|
39606
|
-
const beginDeposit =
|
|
40047
|
+
const beginDeposit = useCallback15((config2) => {
|
|
39607
40048
|
if (closeTimeoutRef.current) {
|
|
39608
40049
|
clearTimeout(closeTimeoutRef.current);
|
|
39609
40050
|
closeTimeoutRef.current = null;
|
|
@@ -39638,7 +40079,7 @@ function UnifoldProvider2({
|
|
|
39638
40079
|
setIsOpen(true);
|
|
39639
40080
|
return promise;
|
|
39640
40081
|
}, []);
|
|
39641
|
-
const closeDeposit =
|
|
40082
|
+
const closeDeposit = useCallback15(() => {
|
|
39642
40083
|
if (closeGuardRef.current) {
|
|
39643
40084
|
return;
|
|
39644
40085
|
}
|
|
@@ -39660,7 +40101,7 @@ function UnifoldProvider2({
|
|
|
39660
40101
|
closeTimeoutRef.current = null;
|
|
39661
40102
|
}, 200);
|
|
39662
40103
|
}, []);
|
|
39663
|
-
const handleDepositSuccess =
|
|
40104
|
+
const handleDepositSuccess = useCallback15(
|
|
39664
40105
|
(data) => {
|
|
39665
40106
|
if (depositConfig?.onSuccess) {
|
|
39666
40107
|
depositConfig.onSuccess(data);
|
|
@@ -39672,7 +40113,7 @@ function UnifoldProvider2({
|
|
|
39672
40113
|
},
|
|
39673
40114
|
[depositConfig]
|
|
39674
40115
|
);
|
|
39675
|
-
const handleDepositError =
|
|
40116
|
+
const handleDepositError = useCallback15(
|
|
39676
40117
|
(error) => {
|
|
39677
40118
|
console.error("[UnifoldProvider] Deposit error:", error);
|
|
39678
40119
|
if (depositConfig?.onError) {
|
|
@@ -39690,7 +40131,7 @@ function UnifoldProvider2({
|
|
|
39690
40131
|
checkoutConfigRef.current = checkoutConfig;
|
|
39691
40132
|
const checkoutCloseTimeoutRef = React38.useRef(null);
|
|
39692
40133
|
const checkoutCloseGuardRef = React38.useRef(false);
|
|
39693
|
-
const beginCheckout =
|
|
40134
|
+
const beginCheckout = useCallback15((config2) => {
|
|
39694
40135
|
if (checkoutCloseTimeoutRef.current) {
|
|
39695
40136
|
clearTimeout(checkoutCloseTimeoutRef.current);
|
|
39696
40137
|
checkoutCloseTimeoutRef.current = null;
|
|
@@ -39715,7 +40156,7 @@ function UnifoldProvider2({
|
|
|
39715
40156
|
setIsCheckoutOpen(true);
|
|
39716
40157
|
return promise;
|
|
39717
40158
|
}, []);
|
|
39718
|
-
const closeCheckout =
|
|
40159
|
+
const closeCheckout = useCallback15(() => {
|
|
39719
40160
|
if (checkoutCloseGuardRef.current) {
|
|
39720
40161
|
return;
|
|
39721
40162
|
}
|
|
@@ -39737,7 +40178,7 @@ function UnifoldProvider2({
|
|
|
39737
40178
|
checkoutCloseTimeoutRef.current = null;
|
|
39738
40179
|
}, 200);
|
|
39739
40180
|
}, []);
|
|
39740
|
-
const handleCheckoutSuccess =
|
|
40181
|
+
const handleCheckoutSuccess = useCallback15(
|
|
39741
40182
|
(data) => {
|
|
39742
40183
|
if (checkoutConfig?.onSuccess) {
|
|
39743
40184
|
checkoutConfig.onSuccess(data);
|
|
@@ -39749,7 +40190,7 @@ function UnifoldProvider2({
|
|
|
39749
40190
|
},
|
|
39750
40191
|
[checkoutConfig]
|
|
39751
40192
|
);
|
|
39752
|
-
const handleCheckoutError =
|
|
40193
|
+
const handleCheckoutError = useCallback15(
|
|
39753
40194
|
(error) => {
|
|
39754
40195
|
console.error("[UnifoldProvider] Checkout error:", error);
|
|
39755
40196
|
if (checkoutConfig?.onError) {
|
|
@@ -39762,7 +40203,7 @@ function UnifoldProvider2({
|
|
|
39762
40203
|
},
|
|
39763
40204
|
[checkoutConfig]
|
|
39764
40205
|
);
|
|
39765
|
-
const beginWithdraw =
|
|
40206
|
+
const beginWithdraw = useCallback15((config2) => {
|
|
39766
40207
|
if (withdrawCloseTimeoutRef.current) {
|
|
39767
40208
|
clearTimeout(withdrawCloseTimeoutRef.current);
|
|
39768
40209
|
withdrawCloseTimeoutRef.current = null;
|
|
@@ -39787,7 +40228,7 @@ function UnifoldProvider2({
|
|
|
39787
40228
|
setIsWithdrawOpen(true);
|
|
39788
40229
|
return promise;
|
|
39789
40230
|
}, []);
|
|
39790
|
-
const closeWithdraw =
|
|
40231
|
+
const closeWithdraw = useCallback15(() => {
|
|
39791
40232
|
if (withdrawCloseGuardRef.current) {
|
|
39792
40233
|
return;
|
|
39793
40234
|
}
|
|
@@ -39809,7 +40250,7 @@ function UnifoldProvider2({
|
|
|
39809
40250
|
withdrawCloseTimeoutRef.current = null;
|
|
39810
40251
|
}, 200);
|
|
39811
40252
|
}, []);
|
|
39812
|
-
const handleWithdrawSuccess =
|
|
40253
|
+
const handleWithdrawSuccess = useCallback15((data) => {
|
|
39813
40254
|
if (withdrawConfigRef.current?.onSuccess) {
|
|
39814
40255
|
withdrawConfigRef.current.onSuccess(data);
|
|
39815
40256
|
}
|
|
@@ -39818,7 +40259,7 @@ function UnifoldProvider2({
|
|
|
39818
40259
|
withdrawPromiseRef.current = null;
|
|
39819
40260
|
}
|
|
39820
40261
|
}, []);
|
|
39821
|
-
const handleWithdrawError =
|
|
40262
|
+
const handleWithdrawError = useCallback15((error) => {
|
|
39822
40263
|
console.error("[UnifoldProvider] Withdraw error:", error);
|
|
39823
40264
|
if (withdrawConfigRef.current?.onError) {
|
|
39824
40265
|
withdrawConfigRef.current.onError(error);
|
|
@@ -39870,6 +40311,7 @@ function UnifoldProvider2({
|
|
|
39870
40311
|
publishableKey,
|
|
39871
40312
|
enableTransferCrypto: config?.enableTransferCrypto,
|
|
39872
40313
|
enableConnectWallet: config?.enableConnectWallet,
|
|
40314
|
+
enableIncidentBanner: incidentBannerEnabled,
|
|
39873
40315
|
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
39874
40316
|
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
39875
40317
|
defaultSourceTokenAddress: checkoutConfig.defaultSourceTokenAddress,
|
|
@@ -39937,6 +40379,7 @@ function UnifoldProvider2({
|
|
|
39937
40379
|
enableConnectExchange: config?.enableConnectExchange,
|
|
39938
40380
|
enableCashApp: config?.enableCashApp,
|
|
39939
40381
|
enableStripeLink: config?.enableStripeLink,
|
|
40382
|
+
enableIncidentBanner: incidentBannerEnabled,
|
|
39940
40383
|
enableApplePay: config?.enableApplePay,
|
|
39941
40384
|
applePayTitle: config?.applePayTitle,
|
|
39942
40385
|
applePaySubTitle: config?.applePaySubTitle,
|