@unifold/connect-react 0.1.56 → 0.1.57
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.js +335 -228
- package/dist/index.mjs +366 -259
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6773,6 +6773,20 @@ async function refreshIntegrationToken(accessToken, publishableKey) {
|
|
|
6773
6773
|
}
|
|
6774
6774
|
return response.json();
|
|
6775
6775
|
}
|
|
6776
|
+
async function revokeIntegrationToken(accessToken, publishableKey) {
|
|
6777
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6778
|
+
validatePublishableKey(pk);
|
|
6779
|
+
await fetch(`${API_BASE_URL}/v1/public/integrations/token/revoke`, {
|
|
6780
|
+
method: "POST",
|
|
6781
|
+
headers: {
|
|
6782
|
+
accept: "application/json",
|
|
6783
|
+
"x-publishable-key": pk,
|
|
6784
|
+
"Content-Type": "application/json"
|
|
6785
|
+
},
|
|
6786
|
+
body: JSON.stringify({ access_token: accessToken })
|
|
6787
|
+
}).catch(() => {
|
|
6788
|
+
});
|
|
6789
|
+
}
|
|
6776
6790
|
async function getIntegrationHoldings(provider, accessToken, publishableKey) {
|
|
6777
6791
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6778
6792
|
validatePublishableKey(pk);
|
|
@@ -7402,12 +7416,13 @@ var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
|
7402
7416
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
7403
7417
|
var import_react20 = require("react");
|
|
7404
7418
|
var import_react_query6 = require("@tanstack/react-query");
|
|
7405
|
-
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
7406
7419
|
var import_react_query7 = require("@tanstack/react-query");
|
|
7407
7420
|
var import_react_query8 = require("@tanstack/react-query");
|
|
7421
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
7408
7422
|
var import_react_query9 = require("@tanstack/react-query");
|
|
7409
7423
|
var import_react_query10 = require("@tanstack/react-query");
|
|
7410
7424
|
var import_react_query11 = require("@tanstack/react-query");
|
|
7425
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
7411
7426
|
var import_react21 = require("react");
|
|
7412
7427
|
var import_react22 = require("react");
|
|
7413
7428
|
var React262 = __toESM(require("react"), 1);
|
|
@@ -10158,7 +10173,7 @@ var Content22 = TooltipContent;
|
|
|
10158
10173
|
|
|
10159
10174
|
// ../ui-react/dist/index.mjs
|
|
10160
10175
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
10161
|
-
var
|
|
10176
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
10162
10177
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
10163
10178
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
10164
10179
|
var import_react26 = require("react");
|
|
@@ -11400,7 +11415,7 @@ var Separator = SelectSeparator;
|
|
|
11400
11415
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
11401
11416
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
11402
11417
|
var React292 = __toESM(require("react"), 1);
|
|
11403
|
-
var
|
|
11418
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
11404
11419
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
11405
11420
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
11406
11421
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
@@ -11412,19 +11427,19 @@ var React302 = __toESM(require("react"), 1);
|
|
|
11412
11427
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
11413
11428
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
11414
11429
|
var import_react28 = require("react");
|
|
11415
|
-
var
|
|
11430
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
11416
11431
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
11417
11432
|
var import_react29 = require("react");
|
|
11418
|
-
var import_react_query15 = require("@tanstack/react-query");
|
|
11419
11433
|
var import_react_query16 = require("@tanstack/react-query");
|
|
11420
11434
|
var import_react_query17 = require("@tanstack/react-query");
|
|
11421
11435
|
var import_react_query18 = require("@tanstack/react-query");
|
|
11436
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
11422
11437
|
var import_react30 = require("react");
|
|
11423
11438
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
11424
11439
|
var import_react31 = require("react");
|
|
11425
|
-
var import_react_query19 = require("@tanstack/react-query");
|
|
11426
|
-
var import_react32 = require("react");
|
|
11427
11440
|
var import_react_query20 = require("@tanstack/react-query");
|
|
11441
|
+
var import_react32 = require("react");
|
|
11442
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
11428
11443
|
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
11429
11444
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
11430
11445
|
var import_react33 = require("react");
|
|
@@ -12773,7 +12788,8 @@ var en_default2 = {
|
|
|
12773
12788
|
title: "Transfer Failed",
|
|
12774
12789
|
tryAgain: "Try Again"
|
|
12775
12790
|
},
|
|
12776
|
-
continue: "Continue"
|
|
12791
|
+
continue: "Continue",
|
|
12792
|
+
disconnect: "Disconnect"
|
|
12777
12793
|
},
|
|
12778
12794
|
buyWithCard: {
|
|
12779
12795
|
onramp: {
|
|
@@ -16020,6 +16036,7 @@ function PayWithExchangeButton({
|
|
|
16020
16036
|
}
|
|
16021
16037
|
function ConnectExchangeButton({
|
|
16022
16038
|
onClick,
|
|
16039
|
+
onDisconnect,
|
|
16023
16040
|
title,
|
|
16024
16041
|
subtitle,
|
|
16025
16042
|
exchanges,
|
|
@@ -16032,6 +16049,109 @@ function ConnectExchangeButton({
|
|
|
16032
16049
|
setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
16033
16050
|
}, []);
|
|
16034
16051
|
const isConnected = connectedExchange != null;
|
|
16052
|
+
const handleDisconnectClick = (e) => {
|
|
16053
|
+
e.preventDefault();
|
|
16054
|
+
e.stopPropagation();
|
|
16055
|
+
onDisconnect?.();
|
|
16056
|
+
};
|
|
16057
|
+
const rowSurfaceStyle = {
|
|
16058
|
+
backgroundColor: isHovered ? colors2.cardHover : components.card.backgroundColor,
|
|
16059
|
+
borderRadius: components.card.borderRadius,
|
|
16060
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
16061
|
+
};
|
|
16062
|
+
const iconBlock = isConnected ? connectedExchange.iconUrl ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16063
|
+
"img",
|
|
16064
|
+
{
|
|
16065
|
+
src: connectedExchange.iconUrl,
|
|
16066
|
+
alt: connectedExchange.name,
|
|
16067
|
+
width: 36,
|
|
16068
|
+
height: 36,
|
|
16069
|
+
className: "uf-rounded-lg"
|
|
16070
|
+
}
|
|
16071
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16072
|
+
"div",
|
|
16073
|
+
{
|
|
16074
|
+
className: "uf-w-9 uf-h-9 uf-rounded-lg uf-flex uf-items-center uf-justify-center",
|
|
16075
|
+
style: { backgroundColor: colors2.card },
|
|
16076
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16077
|
+
"span",
|
|
16078
|
+
{
|
|
16079
|
+
className: "uf-text-xs uf-font-medium",
|
|
16080
|
+
style: { color: components.card.iconColor },
|
|
16081
|
+
children: connectedExchange.name.slice(0, 2).toUpperCase()
|
|
16082
|
+
}
|
|
16083
|
+
)
|
|
16084
|
+
}
|
|
16085
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16086
|
+
Link2,
|
|
16087
|
+
{
|
|
16088
|
+
className: "uf-w-5 uf-h-5",
|
|
16089
|
+
style: { color: components.card.iconColor }
|
|
16090
|
+
}
|
|
16091
|
+
) });
|
|
16092
|
+
const titleSubtitleBlock = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uf-text-left", children: [
|
|
16093
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16094
|
+
"div",
|
|
16095
|
+
{
|
|
16096
|
+
className: "uf-text-sm uf-font-light uf-mb-0.5",
|
|
16097
|
+
style: {
|
|
16098
|
+
color: components.card.titleColor,
|
|
16099
|
+
fontFamily: fonts.regular
|
|
16100
|
+
},
|
|
16101
|
+
children: isConnected ? connectedExchange.name : title
|
|
16102
|
+
}
|
|
16103
|
+
),
|
|
16104
|
+
isConnected && connectedExchange.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uf-h-3 uf-w-24 uf-bg-muted uf-rounded uf-animate-pulse" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16105
|
+
"div",
|
|
16106
|
+
{
|
|
16107
|
+
className: "uf-text-xs uf-font-light",
|
|
16108
|
+
style: {
|
|
16109
|
+
color: components.card.subtitleColor,
|
|
16110
|
+
fontFamily: fonts.regular
|
|
16111
|
+
},
|
|
16112
|
+
children: isConnected ? connectedExchange.balanceUsd ? `$${connectedExchange.balanceUsd} \u2022 2 min` : "Deposit from exchange" : subtitle
|
|
16113
|
+
}
|
|
16114
|
+
)
|
|
16115
|
+
] });
|
|
16116
|
+
if (isConnected && onDisconnect) {
|
|
16117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16118
|
+
"div",
|
|
16119
|
+
{
|
|
16120
|
+
onMouseEnter: () => !isTouchDevice && setIsHovered(true),
|
|
16121
|
+
onMouseLeave: () => setIsHovered(false),
|
|
16122
|
+
onTouchStart: () => setIsHovered(false),
|
|
16123
|
+
className: "uf-w-full uf-transition-colors uf-flex uf-items-stretch uf-group",
|
|
16124
|
+
style: rowSurfaceStyle,
|
|
16125
|
+
children: [
|
|
16126
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16127
|
+
"button",
|
|
16128
|
+
{
|
|
16129
|
+
type: "button",
|
|
16130
|
+
onClick,
|
|
16131
|
+
className: "uf-min-w-0 uf-flex-1 uf-flex uf-items-center uf-gap-3 uf-p-3 uf-pr-1 uf-text-left uf-border-0 uf-bg-transparent hover:uf-bg-transparent",
|
|
16132
|
+
children: [
|
|
16133
|
+
iconBlock,
|
|
16134
|
+
titleSubtitleBlock
|
|
16135
|
+
]
|
|
16136
|
+
}
|
|
16137
|
+
),
|
|
16138
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uf-flex uf-items-center uf-gap-1 uf-shrink-0 uf-pr-2 uf-pl-0", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16139
|
+
"button",
|
|
16140
|
+
{
|
|
16141
|
+
type: "button",
|
|
16142
|
+
onClick: handleDisconnectClick,
|
|
16143
|
+
className: "uf-h-auto uf-min-h-8 uf-py-1.5 uf-px-2 uf-text-xs uf-font-light uf-shrink-0 uf-border-0 uf-bg-transparent uf-cursor-pointer hover:uf-opacity-80 uf-transition-opacity",
|
|
16144
|
+
style: {
|
|
16145
|
+
color: colors2.error,
|
|
16146
|
+
fontFamily: fonts.regular
|
|
16147
|
+
},
|
|
16148
|
+
children: i18n2.connectExchange.disconnect
|
|
16149
|
+
}
|
|
16150
|
+
) })
|
|
16151
|
+
]
|
|
16152
|
+
}
|
|
16153
|
+
);
|
|
16154
|
+
}
|
|
16035
16155
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
16036
16156
|
"button",
|
|
16037
16157
|
{
|
|
@@ -16040,67 +16160,11 @@ function ConnectExchangeButton({
|
|
|
16040
16160
|
onMouseLeave: () => setIsHovered(false),
|
|
16041
16161
|
onTouchStart: () => setIsHovered(false),
|
|
16042
16162
|
className: "uf-w-full uf-transition-colors uf-p-3 uf-flex uf-items-center uf-justify-between uf-group",
|
|
16043
|
-
style:
|
|
16044
|
-
backgroundColor: isHovered ? colors2.cardHover : components.card.backgroundColor,
|
|
16045
|
-
borderRadius: components.card.borderRadius,
|
|
16046
|
-
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
16047
|
-
},
|
|
16163
|
+
style: rowSurfaceStyle,
|
|
16048
16164
|
children: [
|
|
16049
16165
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
{
|
|
16053
|
-
src: connectedExchange.iconUrl,
|
|
16054
|
-
alt: connectedExchange.name,
|
|
16055
|
-
width: 36,
|
|
16056
|
-
height: 36,
|
|
16057
|
-
className: "uf-rounded-lg"
|
|
16058
|
-
}
|
|
16059
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16060
|
-
"div",
|
|
16061
|
-
{
|
|
16062
|
-
className: "uf-w-9 uf-h-9 uf-rounded-lg uf-flex uf-items-center uf-justify-center",
|
|
16063
|
-
style: { backgroundColor: colors2.card },
|
|
16064
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16065
|
-
"span",
|
|
16066
|
-
{
|
|
16067
|
-
className: "uf-text-xs uf-font-medium",
|
|
16068
|
-
style: { color: components.card.iconColor },
|
|
16069
|
-
children: connectedExchange.name.slice(0, 2).toUpperCase()
|
|
16070
|
-
}
|
|
16071
|
-
)
|
|
16072
|
-
}
|
|
16073
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16074
|
-
Link2,
|
|
16075
|
-
{
|
|
16076
|
-
className: "uf-w-5 uf-h-5",
|
|
16077
|
-
style: { color: components.card.iconColor }
|
|
16078
|
-
}
|
|
16079
|
-
) }),
|
|
16080
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uf-text-left", children: [
|
|
16081
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16082
|
-
"div",
|
|
16083
|
-
{
|
|
16084
|
-
className: "uf-text-sm uf-font-light uf-mb-0.5",
|
|
16085
|
-
style: {
|
|
16086
|
-
color: components.card.titleColor,
|
|
16087
|
-
fontFamily: fonts.regular
|
|
16088
|
-
},
|
|
16089
|
-
children: isConnected ? connectedExchange.name : title
|
|
16090
|
-
}
|
|
16091
|
-
),
|
|
16092
|
-
isConnected && connectedExchange.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uf-h-3 uf-w-24 uf-bg-muted uf-rounded uf-animate-pulse" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
16093
|
-
"div",
|
|
16094
|
-
{
|
|
16095
|
-
className: "uf-text-xs uf-font-light",
|
|
16096
|
-
style: {
|
|
16097
|
-
color: components.card.subtitleColor,
|
|
16098
|
-
fontFamily: fonts.regular
|
|
16099
|
-
},
|
|
16100
|
-
children: isConnected ? connectedExchange.balanceUsd ? `$${connectedExchange.balanceUsd} \u2022 2 min` : "Deposit from exchange" : subtitle
|
|
16101
|
-
}
|
|
16102
|
-
)
|
|
16103
|
-
] })
|
|
16166
|
+
iconBlock,
|
|
16167
|
+
titleSubtitleBlock
|
|
16104
16168
|
] }),
|
|
16105
16169
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5", children: [
|
|
16106
16170
|
!isConnected && exchanges && exchanges.length > 0 ? exchanges.slice(0, 4).map((ex, i) => {
|
|
@@ -18905,6 +18969,65 @@ function useProjectConfig({
|
|
|
18905
18969
|
});
|
|
18906
18970
|
return { projectConfig, isLoading };
|
|
18907
18971
|
}
|
|
18972
|
+
function useSupportedDepositTokens(publishableKey, options) {
|
|
18973
|
+
const hasDestination = options?.destination_token_address && options?.destination_chain_id && options?.destination_chain_type;
|
|
18974
|
+
const filteredOptions = {
|
|
18975
|
+
...hasDestination ? {
|
|
18976
|
+
destination_token_address: options.destination_token_address,
|
|
18977
|
+
destination_chain_id: options.destination_chain_id,
|
|
18978
|
+
destination_chain_type: options.destination_chain_type
|
|
18979
|
+
} : {},
|
|
18980
|
+
...options?.product_type ? { product_type: options.product_type } : {}
|
|
18981
|
+
};
|
|
18982
|
+
const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
|
|
18983
|
+
return (0, import_react_query7.useQuery)({
|
|
18984
|
+
queryKey: [
|
|
18985
|
+
"unifold",
|
|
18986
|
+
"supportedDepositTokens",
|
|
18987
|
+
publishableKey,
|
|
18988
|
+
filteredOptions?.destination_token_address ?? null,
|
|
18989
|
+
filteredOptions?.destination_chain_id ?? null,
|
|
18990
|
+
filteredOptions?.destination_chain_type ?? null,
|
|
18991
|
+
filteredOptions?.product_type ?? null
|
|
18992
|
+
],
|
|
18993
|
+
queryFn: () => getSupportedDepositTokens(
|
|
18994
|
+
publishableKey,
|
|
18995
|
+
hasFilteredOptions ? filteredOptions : void 0
|
|
18996
|
+
),
|
|
18997
|
+
staleTime: 1e3 * 60 * 5,
|
|
18998
|
+
// 5 minutes — token list rarely changes
|
|
18999
|
+
gcTime: 1e3 * 60 * 30,
|
|
19000
|
+
// 30 minutes in cache
|
|
19001
|
+
refetchOnMount: false,
|
|
19002
|
+
refetchOnWindowFocus: false
|
|
19003
|
+
});
|
|
19004
|
+
}
|
|
19005
|
+
function useIntegrationTransferDefaultToken({
|
|
19006
|
+
params,
|
|
19007
|
+
publishableKey,
|
|
19008
|
+
enabled = true
|
|
19009
|
+
}) {
|
|
19010
|
+
return (0, import_react_query8.useQuery)({
|
|
19011
|
+
queryKey: [
|
|
19012
|
+
"unifold",
|
|
19013
|
+
"integrationTransferDefaultToken",
|
|
19014
|
+
publishableKey,
|
|
19015
|
+
params?.integration_provider ?? null,
|
|
19016
|
+
params?.source_currency ?? null,
|
|
19017
|
+
params?.destination_token_address ?? null,
|
|
19018
|
+
params?.destination_chain_id ?? null,
|
|
19019
|
+
params?.destination_chain_type ?? null,
|
|
19020
|
+
params?.country_code ?? null,
|
|
19021
|
+
params?.subdivision_code ?? null
|
|
19022
|
+
],
|
|
19023
|
+
queryFn: () => getIntegrationTransferDefaultToken(params, publishableKey),
|
|
19024
|
+
enabled: enabled && !!params,
|
|
19025
|
+
staleTime: 1e3 * 60 * 5,
|
|
19026
|
+
gcTime: 1e3 * 60 * 30,
|
|
19027
|
+
refetchOnMount: false,
|
|
19028
|
+
refetchOnWindowFocus: false
|
|
19029
|
+
});
|
|
19030
|
+
}
|
|
18908
19031
|
var INTEGRATIONS_STORAGE_KEY = "unifold:integrations:connected";
|
|
18909
19032
|
function getStoredIntegrations() {
|
|
18910
19033
|
try {
|
|
@@ -18949,6 +19072,23 @@ function CoinbaseConnect({
|
|
|
18949
19072
|
const { colors: colors2, fonts, components } = useTheme();
|
|
18950
19073
|
const { projectConfig } = useProjectConfig({ publishableKey });
|
|
18951
19074
|
const { userIpInfo } = useUserIp2();
|
|
19075
|
+
const { data: supportedTokensData, isLoading: supportedTokensLoading } = useSupportedDepositTokens(publishableKey, {
|
|
19076
|
+
destination_token_address: destinationTokenAddress,
|
|
19077
|
+
destination_chain_id: destinationChainId,
|
|
19078
|
+
destination_chain_type: destinationChainType
|
|
19079
|
+
});
|
|
19080
|
+
const supportedSymbols = (0, import_react20.useMemo)(() => {
|
|
19081
|
+
const set = /* @__PURE__ */ new Set();
|
|
19082
|
+
supportedTokensData?.data.forEach((token) => set.add(token.symbol.toLowerCase()));
|
|
19083
|
+
return set;
|
|
19084
|
+
}, [supportedTokensData]);
|
|
19085
|
+
const stablecoinSymbols = (0, import_react20.useMemo)(() => {
|
|
19086
|
+
const set = /* @__PURE__ */ new Set();
|
|
19087
|
+
supportedTokensData?.data.forEach((token) => {
|
|
19088
|
+
if (token.is_stablecoin) set.add(token.symbol.toLowerCase());
|
|
19089
|
+
});
|
|
19090
|
+
return set;
|
|
19091
|
+
}, [supportedTokensData]);
|
|
18952
19092
|
const appName = projectConfig?.project_name ?? "Unifold";
|
|
18953
19093
|
const t12 = i18n2.connectExchange;
|
|
18954
19094
|
const initialView = skipToHoldings && getStoredIntegrationToken(IntegrationProvider.COINBASE) ? "holdings" : "select_exchange";
|
|
@@ -18971,7 +19111,43 @@ function CoinbaseConnect({
|
|
|
18971
19111
|
const [confirmResult, setConfirmResult] = (0, import_react20.useState)(null);
|
|
18972
19112
|
const [showTransferDetails, setShowTransferDetails] = (0, import_react20.useState)(false);
|
|
18973
19113
|
const [transferDepositWalletId, setTransferDepositWalletId] = (0, import_react20.useState)(void 0);
|
|
18974
|
-
const
|
|
19114
|
+
const exchangeSupportedCurrencies = (0, import_react20.useMemo)(() => {
|
|
19115
|
+
const set = /* @__PURE__ */ new Set();
|
|
19116
|
+
selectedExchange?.supported_currencies.forEach((c) => set.add(c.toLowerCase()));
|
|
19117
|
+
return set;
|
|
19118
|
+
}, [selectedExchange]);
|
|
19119
|
+
const defaultTokenParams = (0, import_react20.useMemo)(
|
|
19120
|
+
() => selectedAsset ? {
|
|
19121
|
+
integration_provider: IntegrationProvider.COINBASE,
|
|
19122
|
+
source_currency: selectedAsset.currency.toLowerCase(),
|
|
19123
|
+
destination_token_address: destinationTokenAddress,
|
|
19124
|
+
destination_chain_id: destinationChainId,
|
|
19125
|
+
destination_chain_type: destinationChainType,
|
|
19126
|
+
country_code: userIpInfo?.alpha2,
|
|
19127
|
+
subdivision_code: userIpInfo?.subdivisionCode ?? void 0
|
|
19128
|
+
} : null,
|
|
19129
|
+
[selectedAsset, destinationTokenAddress, destinationChainId, destinationChainType, userIpInfo?.alpha2, userIpInfo?.subdivisionCode]
|
|
19130
|
+
);
|
|
19131
|
+
const { data: defaultTokenData, isLoading: defaultTokenLoading } = useIntegrationTransferDefaultToken({
|
|
19132
|
+
params: defaultTokenParams,
|
|
19133
|
+
publishableKey
|
|
19134
|
+
});
|
|
19135
|
+
const sortedHoldings = (0, import_react20.useMemo)(() => {
|
|
19136
|
+
const supported = [];
|
|
19137
|
+
const unsupported = [];
|
|
19138
|
+
holdings.forEach((account) => {
|
|
19139
|
+
const currencyLower = account.currency.toLowerCase();
|
|
19140
|
+
const isSupported = (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
19141
|
+
if (isSupported) supported.push(account);
|
|
19142
|
+
else unsupported.push(account);
|
|
19143
|
+
});
|
|
19144
|
+
return [...supported, ...unsupported];
|
|
19145
|
+
}, [holdings, supportedSymbols, exchangeSupportedCurrencies]);
|
|
19146
|
+
const selectedHoldingIsSupported = (0, import_react20.useMemo)(() => {
|
|
19147
|
+
if (!selectedHolding) return false;
|
|
19148
|
+
const currencyLower = selectedHolding.currency.toLowerCase();
|
|
19149
|
+
return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
19150
|
+
}, [selectedHolding, supportedSymbols, exchangeSupportedCurrencies]);
|
|
18975
19151
|
const exchangeName = selectedExchange?.service_provider_display_name || "Exchange";
|
|
18976
19152
|
const {
|
|
18977
19153
|
executions: depositExecutions,
|
|
@@ -19087,53 +19263,17 @@ function CoinbaseConnect({
|
|
|
19087
19263
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
19088
19264
|
};
|
|
19089
19265
|
}, []);
|
|
19090
|
-
(0, import_react20.
|
|
19091
|
-
if (
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19095
|
-
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19100
|
-
|
|
19101
|
-
destination_chain_id: destinationChainId,
|
|
19102
|
-
destination_chain_type: destinationChainType,
|
|
19103
|
-
country_code: userIpInfo?.alpha2,
|
|
19104
|
-
subdivision_code: userIpInfo?.subdivisionCode ?? void 0
|
|
19105
|
-
},
|
|
19106
|
-
publishableKey
|
|
19107
|
-
),
|
|
19108
|
-
getSupportedDepositTokens(publishableKey, {
|
|
19109
|
-
destination_token_address: destinationTokenAddress,
|
|
19110
|
-
destination_chain_id: destinationChainId,
|
|
19111
|
-
destination_chain_type: destinationChainType
|
|
19112
|
-
})
|
|
19113
|
-
]);
|
|
19114
|
-
if (cancelled) return;
|
|
19115
|
-
const supportedToken = supportedTokens.data.find(
|
|
19116
|
-
(t13) => t13.symbol.toLowerCase() === selectedAsset.currency.toLowerCase()
|
|
19117
|
-
);
|
|
19118
|
-
if (supportedToken && supportedToken.chains.length > 0) {
|
|
19119
|
-
const matchingChain = supportedToken.chains.find(
|
|
19120
|
-
(c) => c.chain_name.toLowerCase() === defaultToken.source_network.toLowerCase()
|
|
19121
|
-
);
|
|
19122
|
-
setMinDepositUsd(
|
|
19123
|
-
matchingChain?.minimum_deposit_amount_usd ?? Math.min(...supportedToken.chains.map((c) => c.minimum_deposit_amount_usd))
|
|
19124
|
-
);
|
|
19125
|
-
} else {
|
|
19126
|
-
setMinDepositUsd(0);
|
|
19127
|
-
}
|
|
19128
|
-
} catch {
|
|
19129
|
-
if (!cancelled) setMinDepositUsd(0);
|
|
19130
|
-
}
|
|
19131
|
-
};
|
|
19132
|
-
fetchMinDeposit();
|
|
19133
|
-
return () => {
|
|
19134
|
-
cancelled = true;
|
|
19135
|
-
};
|
|
19136
|
-
}, [view, selectedAsset, publishableKey, destinationTokenAddress, destinationChainId, destinationChainType, userIpInfo?.alpha2, userIpInfo?.subdivisionCode]);
|
|
19266
|
+
const minDepositUsd = (0, import_react20.useMemo)(() => {
|
|
19267
|
+
if (!selectedAsset || !defaultTokenData) return 0;
|
|
19268
|
+
const supportedToken = supportedTokensData?.data.find(
|
|
19269
|
+
(t13) => t13.symbol.toLowerCase() === selectedAsset.currency.toLowerCase()
|
|
19270
|
+
);
|
|
19271
|
+
if (!supportedToken || supportedToken.chains.length === 0) return 0;
|
|
19272
|
+
const matchingChain = supportedToken.chains.find(
|
|
19273
|
+
(c) => c.chain_name.toLowerCase() === defaultTokenData.source_network.toLowerCase()
|
|
19274
|
+
);
|
|
19275
|
+
return matchingChain?.minimum_deposit_amount_usd ?? Math.min(...supportedToken.chains.map((c) => c.minimum_deposit_amount_usd));
|
|
19276
|
+
}, [selectedAsset, supportedTokensData, defaultTokenData]);
|
|
19137
19277
|
const handleSelectExchange = (exchange) => {
|
|
19138
19278
|
if (!exchange.enabled) return;
|
|
19139
19279
|
setSelectedExchange(exchange);
|
|
@@ -19178,7 +19318,6 @@ function CoinbaseConnect({
|
|
|
19178
19318
|
const handleSelectAsset = (asset) => {
|
|
19179
19319
|
setSelectedAsset(asset);
|
|
19180
19320
|
setSendAmount("");
|
|
19181
|
-
setMinDepositUsd(0);
|
|
19182
19321
|
transitionTo("enter_amount");
|
|
19183
19322
|
};
|
|
19184
19323
|
const handleCreateTransfer = async () => {
|
|
@@ -19190,18 +19329,10 @@ function CoinbaseConnect({
|
|
|
19190
19329
|
const cryptoAmount = (usdAmount / rate).toFixed(8);
|
|
19191
19330
|
setIsLoading(true);
|
|
19192
19331
|
try {
|
|
19193
|
-
|
|
19194
|
-
|
|
19195
|
-
|
|
19196
|
-
|
|
19197
|
-
destination_token_address: destinationTokenAddress,
|
|
19198
|
-
destination_chain_id: destinationChainId,
|
|
19199
|
-
destination_chain_type: destinationChainType,
|
|
19200
|
-
country_code: userIpInfo?.alpha2,
|
|
19201
|
-
subdivision_code: userIpInfo?.subdivisionCode ?? void 0
|
|
19202
|
-
},
|
|
19203
|
-
publishableKey
|
|
19204
|
-
);
|
|
19332
|
+
if (!defaultTokenData) {
|
|
19333
|
+
throw new Error("Transfer details not ready. Please try again.");
|
|
19334
|
+
}
|
|
19335
|
+
const { source_network, source_chain_type } = defaultTokenData;
|
|
19205
19336
|
const matchingWallet = wallets.find((w) => w.chain_type === source_chain_type);
|
|
19206
19337
|
const depositAddress = matchingWallet?.address ?? recipientAddress ?? "";
|
|
19207
19338
|
if (!depositAddress) {
|
|
@@ -19353,13 +19484,12 @@ function CoinbaseConnect({
|
|
|
19353
19484
|
break;
|
|
19354
19485
|
}
|
|
19355
19486
|
};
|
|
19356
|
-
const STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set(["USDC", "USDT", "DAI", "BUSD", "TUSD", "USDP", "GUSD", "FRAX", "LUSD", "PYUSD", "EURC", "USDS"]);
|
|
19357
19487
|
const formatCryptoAmount = (amount, currency) => {
|
|
19358
19488
|
const num = parseFloat(amount);
|
|
19359
19489
|
if (isNaN(num)) return `${amount} ${currency.toUpperCase()}`;
|
|
19360
|
-
const isStable =
|
|
19361
|
-
const maxDecimals = isStable ? 2 :
|
|
19362
|
-
return `${num.toLocaleString(void 0, { minimumFractionDigits:
|
|
19490
|
+
const isStable = stablecoinSymbols.has(currency.toLowerCase());
|
|
19491
|
+
const maxDecimals = isStable ? 2 : 6;
|
|
19492
|
+
return `${num.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: maxDecimals })} ${currency.toUpperCase()}`;
|
|
19363
19493
|
};
|
|
19364
19494
|
const viewTransitionStyle = {
|
|
19365
19495
|
opacity: isTransitioning ? 0 : 1,
|
|
@@ -19961,7 +20091,7 @@ function CoinbaseConnect({
|
|
|
19961
20091
|
className: "uf-w-6 uf-h-6 uf-animate-spin",
|
|
19962
20092
|
style: { color: colors2.foregroundMuted }
|
|
19963
20093
|
}
|
|
19964
|
-
) }) :
|
|
20094
|
+
) }) : sortedHoldings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "uf-text-center uf-py-8", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
19965
20095
|
"div",
|
|
19966
20096
|
{
|
|
19967
20097
|
className: "uf-text-sm",
|
|
@@ -19971,17 +20101,19 @@ function CoinbaseConnect({
|
|
|
19971
20101
|
},
|
|
19972
20102
|
children: "No holdings found"
|
|
19973
20103
|
}
|
|
19974
|
-
) }) :
|
|
20104
|
+
) }) : sortedHoldings.map((account) => {
|
|
19975
20105
|
const iconUrl = account.icon_urls?.find((u) => u.format === "svg")?.url || account.icon_urls?.find((u) => u.format === "png")?.url || account.icon_url;
|
|
19976
|
-
const
|
|
20106
|
+
const currencyLower = account.currency.toLowerCase();
|
|
20107
|
+
const isSupported = (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
|
|
20108
|
+
const isSelected = isSupported && selectedHolding?.id === account.id;
|
|
19977
20109
|
const usdValue = account.amount_usd ? parseFloat(account.amount_usd) : null;
|
|
19978
|
-
const formattedUsd = usdValue != null && usdValue
|
|
20110
|
+
const formattedUsd = usdValue != null && usdValue >= 0.01 ? `$${usdValue.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : usdValue != null && usdValue < 0.01 && usdValue > 0 ? "< $0.01" : "$0.00";
|
|
19979
20111
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
19980
20112
|
"button",
|
|
19981
20113
|
{
|
|
19982
20114
|
onClick: () => setSelectedHolding(account),
|
|
19983
|
-
disabled: isLoading,
|
|
19984
|
-
className:
|
|
20115
|
+
disabled: isLoading || !isSupported,
|
|
20116
|
+
className: `uf-w-full uf-transition-colors uf-p-3 uf-flex uf-items-center uf-justify-between ${!isSupported ? "uf-cursor-not-allowed uf-opacity-50" : ""}`,
|
|
19985
20117
|
style: {
|
|
19986
20118
|
backgroundColor: isSelected ? colors2.primary + "20" : components.card.backgroundColor,
|
|
19987
20119
|
borderRadius: components.list.rowBorderRadius,
|
|
@@ -20071,9 +20203,9 @@ function CoinbaseConnect({
|
|
|
20071
20203
|
"button",
|
|
20072
20204
|
{
|
|
20073
20205
|
onClick: () => {
|
|
20074
|
-
if (selectedHolding) handleSelectAsset(selectedHolding);
|
|
20206
|
+
if (selectedHolding && selectedHoldingIsSupported) handleSelectAsset(selectedHolding);
|
|
20075
20207
|
},
|
|
20076
|
-
disabled: !selectedHolding || isLoading,
|
|
20208
|
+
disabled: !selectedHolding || isLoading || supportedTokensLoading || exchangesLoading || !selectedHoldingIsSupported,
|
|
20077
20209
|
className: "uf-w-full uf-py-3 uf-text-sm uf-font-medium uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed",
|
|
20078
20210
|
style: {
|
|
20079
20211
|
backgroundColor: colors2.primary,
|
|
@@ -20097,22 +20229,16 @@ function CoinbaseConnect({
|
|
|
20097
20229
|
const isValidAmount = inputUsdNum > 0 && (maxUsdAmount == null || inputUsdNum <= maxUsdAmount) && inputUsdNum >= minDepositUsd;
|
|
20098
20230
|
const displayValue = sendAmount || "0";
|
|
20099
20231
|
const formattedBalance = formatCryptoAmount(selectedAsset.amount, selectedAsset.currency);
|
|
20100
|
-
const
|
|
20232
|
+
const balanceSubtitle = maxUsdAmount != null && maxUsdAmount > 0 ? `Balance: $${maxUsdAmount.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} (${formattedBalance})` : `Balance: ${formattedBalance}`;
|
|
20101
20233
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
20102
20234
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
20103
20235
|
DepositHeader,
|
|
20104
20236
|
{
|
|
20105
20237
|
title: "Enter Amount",
|
|
20238
|
+
subtitle: balanceSubtitle,
|
|
20106
20239
|
showBack: true,
|
|
20107
20240
|
onBack: handleBack,
|
|
20108
|
-
onClose
|
|
20109
|
-
showBalance: true,
|
|
20110
|
-
balanceAddress: recipientAddress,
|
|
20111
|
-
balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" ? destinationChainType : void 0,
|
|
20112
|
-
balanceChainId: destinationChainId,
|
|
20113
|
-
balanceTokenAddress: destinationTokenAddress,
|
|
20114
|
-
projectName: projectConfig?.project_name,
|
|
20115
|
-
publishableKey
|
|
20241
|
+
onClose
|
|
20116
20242
|
}
|
|
20117
20243
|
),
|
|
20118
20244
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "uf-flex uf-flex-col uf-pb-4", style: viewTransitionStyle, children: [
|
|
@@ -20234,7 +20360,7 @@ function CoinbaseConnect({
|
|
|
20234
20360
|
"button",
|
|
20235
20361
|
{
|
|
20236
20362
|
onClick: handleCreateTransfer,
|
|
20237
|
-
disabled: !isValidAmount || isLoading,
|
|
20363
|
+
disabled: !isValidAmount || isLoading || defaultTokenLoading || !defaultTokenData,
|
|
20238
20364
|
className: "uf-w-full uf-py-3 uf-text-sm uf-font-medium uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed uf-flex uf-items-center uf-justify-center uf-gap-2",
|
|
20239
20365
|
style: {
|
|
20240
20366
|
backgroundColor: colors2.primary,
|
|
@@ -20243,7 +20369,7 @@ function CoinbaseConnect({
|
|
|
20243
20369
|
borderRadius: components.button.borderRadius,
|
|
20244
20370
|
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
20245
20371
|
},
|
|
20246
|
-
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }) : "Review"
|
|
20372
|
+
children: isLoading || defaultTokenLoading ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }) : "Review"
|
|
20247
20373
|
}
|
|
20248
20374
|
)
|
|
20249
20375
|
] })
|
|
@@ -20714,7 +20840,7 @@ function useExchanges({
|
|
|
20714
20840
|
publishableKey,
|
|
20715
20841
|
enabled = true
|
|
20716
20842
|
}) {
|
|
20717
|
-
const { data: exchanges = [], isLoading } = (0,
|
|
20843
|
+
const { data: exchanges = [], isLoading } = (0, import_react_query9.useQuery)({
|
|
20718
20844
|
queryKey: ["unifold", "exchanges", publishableKey],
|
|
20719
20845
|
queryFn: () => getExchanges(void 0, publishableKey).then((res) => res.data),
|
|
20720
20846
|
enabled,
|
|
@@ -20733,7 +20859,7 @@ function useDefaultOnrampToken({
|
|
|
20733
20859
|
subdivisionCode,
|
|
20734
20860
|
enabled = true
|
|
20735
20861
|
}) {
|
|
20736
|
-
const { data: defaultToken, isLoading } = (0,
|
|
20862
|
+
const { data: defaultToken, isLoading } = (0, import_react_query10.useQuery)({
|
|
20737
20863
|
queryKey: [
|
|
20738
20864
|
"unifold",
|
|
20739
20865
|
"defaultOnrampToken",
|
|
@@ -20766,7 +20892,7 @@ function useAllowedCountry(publishableKey) {
|
|
|
20766
20892
|
data: ipData,
|
|
20767
20893
|
isLoading: isIpLoading,
|
|
20768
20894
|
error: ipError
|
|
20769
|
-
} = (0,
|
|
20895
|
+
} = (0, import_react_query11.useQuery)({
|
|
20770
20896
|
queryKey: ["unifold", "ipAddress"],
|
|
20771
20897
|
queryFn: () => getIpAddress(),
|
|
20772
20898
|
refetchOnMount: false,
|
|
@@ -20781,7 +20907,7 @@ function useAllowedCountry(publishableKey) {
|
|
|
20781
20907
|
data: configData,
|
|
20782
20908
|
isLoading: isConfigLoading,
|
|
20783
20909
|
error: configError
|
|
20784
|
-
} = (0,
|
|
20910
|
+
} = (0, import_react_query11.useQuery)({
|
|
20785
20911
|
queryKey: ["unifold", "projectConfig", publishableKey],
|
|
20786
20912
|
queryFn: () => getProjectConfig(publishableKey),
|
|
20787
20913
|
refetchOnMount: false,
|
|
@@ -20832,7 +20958,7 @@ function useAddressValidation({
|
|
|
20832
20958
|
refetchOnMount = false
|
|
20833
20959
|
}) {
|
|
20834
20960
|
const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
20835
|
-
const { data, isLoading, error } = (0,
|
|
20961
|
+
const { data, isLoading, error } = (0, import_react_query12.useQuery)({
|
|
20836
20962
|
queryKey: [
|
|
20837
20963
|
"unifold",
|
|
20838
20964
|
"addressValidation",
|
|
@@ -20876,39 +21002,6 @@ function useAddressValidation({
|
|
|
20876
21002
|
error: error ?? null
|
|
20877
21003
|
};
|
|
20878
21004
|
}
|
|
20879
|
-
function useSupportedDepositTokens(publishableKey, options) {
|
|
20880
|
-
const hasDestination = options?.destination_token_address && options?.destination_chain_id && options?.destination_chain_type;
|
|
20881
|
-
const filteredOptions = {
|
|
20882
|
-
...hasDestination ? {
|
|
20883
|
-
destination_token_address: options.destination_token_address,
|
|
20884
|
-
destination_chain_id: options.destination_chain_id,
|
|
20885
|
-
destination_chain_type: options.destination_chain_type
|
|
20886
|
-
} : {},
|
|
20887
|
-
...options?.product_type ? { product_type: options.product_type } : {}
|
|
20888
|
-
};
|
|
20889
|
-
const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
|
|
20890
|
-
return (0, import_react_query11.useQuery)({
|
|
20891
|
-
queryKey: [
|
|
20892
|
-
"unifold",
|
|
20893
|
-
"supportedDepositTokens",
|
|
20894
|
-
publishableKey,
|
|
20895
|
-
filteredOptions?.destination_token_address ?? null,
|
|
20896
|
-
filteredOptions?.destination_chain_id ?? null,
|
|
20897
|
-
filteredOptions?.destination_chain_type ?? null,
|
|
20898
|
-
filteredOptions?.product_type ?? null
|
|
20899
|
-
],
|
|
20900
|
-
queryFn: () => getSupportedDepositTokens(
|
|
20901
|
-
publishableKey,
|
|
20902
|
-
hasFilteredOptions ? filteredOptions : void 0
|
|
20903
|
-
),
|
|
20904
|
-
staleTime: 1e3 * 60 * 5,
|
|
20905
|
-
// 5 minutes — token list rarely changes
|
|
20906
|
-
gcTime: 1e3 * 60 * 30,
|
|
20907
|
-
// 30 minutes in cache
|
|
20908
|
-
refetchOnMount: false,
|
|
20909
|
-
refetchOnWindowFocus: false
|
|
20910
|
-
});
|
|
20911
|
-
}
|
|
20912
21005
|
function ThemeStyleInjector({
|
|
20913
21006
|
children,
|
|
20914
21007
|
className
|
|
@@ -21968,7 +22061,7 @@ function useHypercoreActivation(params) {
|
|
|
21968
22061
|
const recipient = recipientAddress?.trim() ?? "";
|
|
21969
22062
|
const source = sourceAddress?.trim() ?? "";
|
|
21970
22063
|
const hasAddresses = !!recipient && !!source;
|
|
21971
|
-
const { data, isLoading } = (0,
|
|
22064
|
+
const { data, isLoading } = (0, import_react_query13.useQuery)({
|
|
21972
22065
|
queryKey: [
|
|
21973
22066
|
"unifold",
|
|
21974
22067
|
"hypercoreActivation",
|
|
@@ -23185,7 +23278,7 @@ function useDepositQuote(params) {
|
|
|
23185
23278
|
...adjustForSlippage ? { adjust_for_slippage: true } : {},
|
|
23186
23279
|
...stablecoinParity ? { stablecoin_parity: true } : {}
|
|
23187
23280
|
};
|
|
23188
|
-
return (0,
|
|
23281
|
+
return (0, import_react_query14.useQuery)({
|
|
23189
23282
|
queryKey: [
|
|
23190
23283
|
"unifold",
|
|
23191
23284
|
"depositQuote",
|
|
@@ -23293,7 +23386,7 @@ function SelectTokenView({
|
|
|
23293
23386
|
),
|
|
23294
23387
|
walletInfoProp ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-flex uf-w-full uf-justify-center uf-mb-6", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(WalletWithNetworkBadge, { walletInfo: walletInfoProp }) }) : null,
|
|
23295
23388
|
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "uf-flex uf-min-h-0 uf-flex-1 uf-flex-col", children: [
|
|
23296
|
-
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-h-[
|
|
23389
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-h-[300px] uf-shrink-0 uf-overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:uf-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-space-y-2", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "uf-flex uf-items-center uf-justify-center uf-py-12", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
23297
23390
|
LoaderCircle,
|
|
23298
23391
|
{
|
|
23299
23392
|
className: "uf-w-6 uf-h-6 uf-animate-spin",
|
|
@@ -25732,11 +25825,12 @@ function DepositModal({
|
|
|
25732
25825
|
return sum + (isNaN(usd) ? 0 : usd);
|
|
25733
25826
|
}, 0);
|
|
25734
25827
|
const balanceUsd = totalUsd > 0 ? totalUsd.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : null;
|
|
25735
|
-
setConnectedExchange((prev) =>
|
|
25828
|
+
setConnectedExchange((prev) => prev ? { ...prev, balanceUsd, isLoading: false } : null);
|
|
25736
25829
|
};
|
|
25737
25830
|
getIntegrationHoldings(IntegrationProvider.COINBASE, stored.access_token, publishableKey).then(processHoldings).catch(async () => {
|
|
25738
25831
|
try {
|
|
25739
25832
|
const refreshResult = await refreshIntegrationToken(stored.access_token, publishableKey);
|
|
25833
|
+
if (!getStoredIntegrationToken(IntegrationProvider.COINBASE)) return;
|
|
25740
25834
|
setStoredIntegrationToken({
|
|
25741
25835
|
integration_provider: IntegrationProvider.COINBASE,
|
|
25742
25836
|
access_token: refreshResult.access_token,
|
|
@@ -25745,6 +25839,7 @@ function DepositModal({
|
|
|
25745
25839
|
const retryResult = await getIntegrationHoldings(IntegrationProvider.COINBASE, refreshResult.access_token, publishableKey);
|
|
25746
25840
|
processHoldings(retryResult);
|
|
25747
25841
|
} catch {
|
|
25842
|
+
if (!getStoredIntegrationToken(IntegrationProvider.COINBASE)) return;
|
|
25748
25843
|
clearStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
25749
25844
|
setConnectedExchange(null);
|
|
25750
25845
|
}
|
|
@@ -25912,6 +26007,14 @@ function DepositModal({
|
|
|
25912
26007
|
setBrowserWalletInfo(null);
|
|
25913
26008
|
setBrowserWalletModalOpen(false);
|
|
25914
26009
|
};
|
|
26010
|
+
const handleExchangeDisconnect = () => {
|
|
26011
|
+
const stored = getStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
26012
|
+
if (stored) {
|
|
26013
|
+
revokeIntegrationToken(stored.access_token, publishableKey);
|
|
26014
|
+
}
|
|
26015
|
+
clearStoredIntegrationToken(IntegrationProvider.COINBASE);
|
|
26016
|
+
setConnectedExchange(null);
|
|
26017
|
+
};
|
|
25915
26018
|
const handleClose = () => {
|
|
25916
26019
|
onOpenChange(false);
|
|
25917
26020
|
if (resetViewTimeoutRef.current) {
|
|
@@ -26117,6 +26220,7 @@ function DepositModal({
|
|
|
26117
26220
|
setCoinbaseSkipToHoldings(true);
|
|
26118
26221
|
setView("coinbase_connect");
|
|
26119
26222
|
},
|
|
26223
|
+
onDisconnect: handleExchangeDisconnect,
|
|
26120
26224
|
title: i18n2.connectExchange.title,
|
|
26121
26225
|
subtitle: i18n2.connectExchange.subtitle,
|
|
26122
26226
|
exchanges: integrationExchanges,
|
|
@@ -26321,34 +26425,37 @@ function DepositModal({
|
|
|
26321
26425
|
),
|
|
26322
26426
|
depositPoweredByFooter
|
|
26323
26427
|
] })
|
|
26324
|
-
] }) : view === "coinbase_connect" ? /* @__PURE__ */ (0, import_jsx_runtime73.
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
|
|
26331
|
-
|
|
26332
|
-
|
|
26333
|
-
|
|
26334
|
-
|
|
26335
|
-
|
|
26336
|
-
|
|
26337
|
-
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26341
|
-
|
|
26342
|
-
|
|
26343
|
-
|
|
26344
|
-
|
|
26345
|
-
|
|
26346
|
-
|
|
26347
|
-
|
|
26348
|
-
|
|
26349
|
-
|
|
26350
|
-
|
|
26351
|
-
|
|
26428
|
+
] }) : view === "coinbase_connect" ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
|
|
26429
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
26430
|
+
CoinbaseConnect,
|
|
26431
|
+
{
|
|
26432
|
+
publishableKey,
|
|
26433
|
+
userId,
|
|
26434
|
+
wallets,
|
|
26435
|
+
recipientAddress,
|
|
26436
|
+
destinationTokenAddress: destinationTokenAddress ?? "",
|
|
26437
|
+
destinationChainId: destinationChainId ?? "",
|
|
26438
|
+
destinationChainType: destinationChainType ?? "",
|
|
26439
|
+
onTransferSuccess: (result) => {
|
|
26440
|
+
onDepositSuccess?.({
|
|
26441
|
+
message: "Transfer completed via Coinbase Connect",
|
|
26442
|
+
transaction: result
|
|
26443
|
+
});
|
|
26444
|
+
},
|
|
26445
|
+
onTransferError: (error) => {
|
|
26446
|
+
onDepositError?.({
|
|
26447
|
+
message: error.message,
|
|
26448
|
+
error
|
|
26449
|
+
});
|
|
26450
|
+
},
|
|
26451
|
+
onBack: handleBack,
|
|
26452
|
+
onClose: handleClose,
|
|
26453
|
+
skipToHoldings: coinbaseSkipToHoldings,
|
|
26454
|
+
onExecutionsChange: setDepositExecutions
|
|
26455
|
+
}
|
|
26456
|
+
),
|
|
26457
|
+
depositPoweredByFooter
|
|
26458
|
+
] }) : view === "cashapp" ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
26352
26459
|
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
26353
26460
|
DepositHeader,
|
|
26354
26461
|
{
|
|
@@ -26441,7 +26548,7 @@ function usePaymentIntent(params) {
|
|
|
26441
26548
|
enabled = true,
|
|
26442
26549
|
pollingInterval = 3e3
|
|
26443
26550
|
} = params;
|
|
26444
|
-
return (0,
|
|
26551
|
+
return (0, import_react_query15.useQuery)({
|
|
26445
26552
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
26446
26553
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
26447
26554
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
@@ -27090,7 +27197,7 @@ function CheckoutModal({
|
|
|
27090
27197
|
] }) });
|
|
27091
27198
|
}
|
|
27092
27199
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
27093
|
-
return (0,
|
|
27200
|
+
return (0, import_react_query16.useQuery)({
|
|
27094
27201
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
27095
27202
|
queryFn: () => getSupportedDestinationTokens(publishableKey),
|
|
27096
27203
|
staleTime: 1e3 * 60 * 5,
|
|
@@ -27125,7 +27232,7 @@ function useSourceTokenValidation(params) {
|
|
|
27125
27232
|
enabled = true
|
|
27126
27233
|
} = params;
|
|
27127
27234
|
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
27128
|
-
return (0,
|
|
27235
|
+
return (0, import_react_query17.useQuery)({
|
|
27129
27236
|
queryKey: [
|
|
27130
27237
|
"unifold",
|
|
27131
27238
|
"sourceTokenValidation",
|
|
@@ -27181,7 +27288,7 @@ function useAddressBalance(params) {
|
|
|
27181
27288
|
enabled = true
|
|
27182
27289
|
} = params;
|
|
27183
27290
|
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
27184
|
-
return (0,
|
|
27291
|
+
return (0, import_react_query18.useQuery)({
|
|
27185
27292
|
queryKey: [
|
|
27186
27293
|
"unifold",
|
|
27187
27294
|
"addressBalance",
|
|
@@ -27230,7 +27337,7 @@ function useAddressBalance(params) {
|
|
|
27230
27337
|
}
|
|
27231
27338
|
function useExecutions(userId, publishableKey, options) {
|
|
27232
27339
|
const actionType = options?.actionType ?? ActionType.Deposit;
|
|
27233
|
-
return (0,
|
|
27340
|
+
return (0, import_react_query19.useQuery)({
|
|
27234
27341
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
27235
27342
|
queryFn: () => queryExecutions(userId, publishableKey, actionType),
|
|
27236
27343
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
@@ -27513,7 +27620,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
27513
27620
|
} = params;
|
|
27514
27621
|
const trimmedAddress = recipientAddress?.trim() || "";
|
|
27515
27622
|
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
27516
|
-
return (0,
|
|
27623
|
+
return (0, import_react_query20.useQuery)({
|
|
27517
27624
|
queryKey: [
|
|
27518
27625
|
"unifold",
|
|
27519
27626
|
"verifyRecipientAddress",
|
|
@@ -27555,7 +27662,7 @@ function useGetDepositAddress(params) {
|
|
|
27555
27662
|
enabled = true
|
|
27556
27663
|
} = params;
|
|
27557
27664
|
const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
27558
|
-
return (0,
|
|
27665
|
+
return (0, import_react_query21.useQuery)({
|
|
27559
27666
|
queryKey: [
|
|
27560
27667
|
"unifold",
|
|
27561
27668
|
"getDepositAddress",
|