@unifold/ui-react 0.1.78 → 0.1.79
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 +295 -313
- package/dist/index.mjs +52 -70
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9405,23 +9405,7 @@ function PayWithExchange({
|
|
|
9405
9405
|
// src/components/deposits/PayWithCashApp.tsx
|
|
9406
9406
|
var import_react18 = require("react");
|
|
9407
9407
|
var import_lucide_react13 = require("lucide-react");
|
|
9408
|
-
var import_core19 = require("@unifold/core");
|
|
9409
|
-
|
|
9410
|
-
// src/hooks/use-cashapp-limits.ts
|
|
9411
|
-
var import_react_query9 = require("@tanstack/react-query");
|
|
9412
9408
|
var import_core18 = require("@unifold/core");
|
|
9413
|
-
function useCashAppLimits({ publishableKey, currency = "usd" }) {
|
|
9414
|
-
return (0, import_react_query9.useQuery)({
|
|
9415
|
-
queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
|
|
9416
|
-
queryFn: () => (0, import_core18.getCashAppLimits)(currency, publishableKey),
|
|
9417
|
-
enabled: !!publishableKey,
|
|
9418
|
-
staleTime: 2 * 60 * 6e4,
|
|
9419
|
-
gcTime: 4 * 60 * 6e4,
|
|
9420
|
-
retry: 2
|
|
9421
|
-
});
|
|
9422
|
-
}
|
|
9423
|
-
|
|
9424
|
-
// src/components/deposits/PayWithCashApp.tsx
|
|
9425
9409
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
9426
9410
|
var POLL_INTERVAL_MS3 = 5e3;
|
|
9427
9411
|
var FALLBACK_MIN_USD = 5;
|
|
@@ -9458,9 +9442,11 @@ function PayWithCashApp({
|
|
|
9458
9442
|
const b = parseInt(bg.slice(4, 6), 16);
|
|
9459
9443
|
return (r * 299 + g * 587 + b * 114) / 1e3 < 128;
|
|
9460
9444
|
})();
|
|
9461
|
-
const { data:
|
|
9462
|
-
|
|
9463
|
-
|
|
9445
|
+
const { data: fiatCurrencies, isLoading: limitsLoading } = useFiatCurrencies({
|
|
9446
|
+
publishableKey
|
|
9447
|
+
});
|
|
9448
|
+
const minUsd = fiatCurrencies?.data.find((entry) => entry.currency_code.toLowerCase() === "usd")?.minimum_amount ?? FALLBACK_MIN_USD;
|
|
9449
|
+
const quickAmounts = SUGGESTED_AMOUNTS.filter((value) => value >= minUsd);
|
|
9464
9450
|
const [amount, setAmount] = (0, import_react18.useState)(() => sanitizePrefilledUsd(prefilledAmountUsd));
|
|
9465
9451
|
const [loading, setLoading] = (0, import_react18.useState)(false);
|
|
9466
9452
|
const [session, setSession] = (0, import_react18.useState)(null);
|
|
@@ -9515,11 +9501,13 @@ function PayWithCashApp({
|
|
|
9515
9501
|
setError(strings.depositModal.cashAppErrors.missingFields);
|
|
9516
9502
|
return;
|
|
9517
9503
|
}
|
|
9504
|
+
const amountNum2 = parseFloat(amount);
|
|
9505
|
+
if (isNaN(amountNum2) || amountNum2 < minUsd) return;
|
|
9518
9506
|
setLoading(true);
|
|
9519
9507
|
setError(null);
|
|
9520
9508
|
try {
|
|
9521
|
-
const externalId = (0,
|
|
9522
|
-
const result = await (0,
|
|
9509
|
+
const externalId = (0, import_core18.generatePrefixedKSUID)("ca");
|
|
9510
|
+
const result = await (0, import_core18.createCashAppSession)(
|
|
9523
9511
|
{
|
|
9524
9512
|
external_user_id: userId,
|
|
9525
9513
|
destination_chain_type: destinationChainType,
|
|
@@ -9547,8 +9535,8 @@ function PayWithCashApp({
|
|
|
9547
9535
|
deposit_wallet_id: depositWalletId
|
|
9548
9536
|
});
|
|
9549
9537
|
onEvent?.({
|
|
9550
|
-
id: (0,
|
|
9551
|
-
type:
|
|
9538
|
+
id: (0, import_core18.generatePrefixedKSUID)("sevt"),
|
|
9539
|
+
type: import_core18.DepositEventType.ONRAMP_SESSION_CREATED,
|
|
9552
9540
|
created: Math.floor(Date.now() / 1e3),
|
|
9553
9541
|
sessionId: getSessionId() ?? "",
|
|
9554
9542
|
method: "cashapp",
|
|
@@ -9563,6 +9551,7 @@ function PayWithCashApp({
|
|
|
9563
9551
|
}
|
|
9564
9552
|
}, [
|
|
9565
9553
|
amount,
|
|
9554
|
+
minUsd,
|
|
9566
9555
|
userId,
|
|
9567
9556
|
publishableKey,
|
|
9568
9557
|
recipientAddress,
|
|
@@ -9581,7 +9570,7 @@ function PayWithCashApp({
|
|
|
9581
9570
|
if (status === "completed" || status === "failed") return;
|
|
9582
9571
|
const poll = async () => {
|
|
9583
9572
|
try {
|
|
9584
|
-
const result = await (0,
|
|
9573
|
+
const result = await (0, import_core18.getCashAppSessionStatus)(session.external_id, publishableKey);
|
|
9585
9574
|
setStatus(result.status);
|
|
9586
9575
|
if (result.status === "failed") {
|
|
9587
9576
|
setError(strings.depositModal.cashAppErrors.paymentFailed);
|
|
@@ -9666,8 +9655,7 @@ function PayWithCashApp({
|
|
|
9666
9655
|
const amountNum = parseFloat(amount);
|
|
9667
9656
|
const hasInput = !isNaN(amountNum) && amountNum > 0;
|
|
9668
9657
|
const belowMin = hasInput && amountNum < minUsd;
|
|
9669
|
-
const
|
|
9670
|
-
const isValidAmount = hasInput && !belowMin && !aboveMax;
|
|
9658
|
+
const isValidAmount = hasInput && !belowMin;
|
|
9671
9659
|
if (view === "amount") {
|
|
9672
9660
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
9673
9661
|
"div",
|
|
@@ -9696,7 +9684,7 @@ function PayWithCashApp({
|
|
|
9696
9684
|
}
|
|
9697
9685
|
}
|
|
9698
9686
|
) }) }),
|
|
9699
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-gap-3 uf-justify-center", children:
|
|
9687
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-flex uf-gap-3 uf-justify-center", children: quickAmounts.map((quickAmount) => {
|
|
9700
9688
|
const isSelected = parseFloat(amount) === quickAmount;
|
|
9701
9689
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
9702
9690
|
"button",
|
|
@@ -9722,23 +9710,17 @@ function PayWithCashApp({
|
|
|
9722
9710
|
quickAmount
|
|
9723
9711
|
);
|
|
9724
9712
|
}) }),
|
|
9725
|
-
|
|
9713
|
+
!limitsLoading && minUsd > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
9726
9714
|
"div",
|
|
9727
9715
|
{
|
|
9728
|
-
className: "uf-text-
|
|
9729
|
-
style: { color: colors2.
|
|
9730
|
-
children: interpolate(strings.common.
|
|
9731
|
-
|
|
9732
|
-
) : amount && maxUsd !== null && amountNum > maxUsd && !error ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
9733
|
-
"div",
|
|
9734
|
-
{
|
|
9735
|
-
className: "uf-text-sm uf-text-center uf-mt-3 uf-px-2",
|
|
9736
|
-
style: { color: colors2.error, fontFamily: fonts.regular },
|
|
9737
|
-
children: interpolate(strings.common.maximumAmount, {
|
|
9738
|
-
amount: `$${maxUsd.toLocaleString()}`
|
|
9716
|
+
className: "uf-text-center uf-text-xs uf-mt-4",
|
|
9717
|
+
style: { color: colors2.warning, fontFamily: fonts.regular },
|
|
9718
|
+
children: interpolate(strings.common.minimumDeposit, {
|
|
9719
|
+
amount: `$${minUsd.toFixed(2)}`
|
|
9739
9720
|
})
|
|
9740
9721
|
}
|
|
9741
|
-
)
|
|
9722
|
+
),
|
|
9723
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
9742
9724
|
"div",
|
|
9743
9725
|
{
|
|
9744
9726
|
className: "uf-text-sm uf-text-center uf-mt-3 uf-px-2",
|
|
@@ -9747,7 +9729,7 @@ function PayWithCashApp({
|
|
|
9747
9729
|
}
|
|
9748
9730
|
) : null
|
|
9749
9731
|
] }),
|
|
9750
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-px-1", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
9732
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "uf-px-1 uf-mt-5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
9751
9733
|
"button",
|
|
9752
9734
|
{
|
|
9753
9735
|
onClick: handleCreateSession,
|
|
@@ -9966,20 +9948,20 @@ function PayWithCashApp({
|
|
|
9966
9948
|
// src/components/deposits/BankTransfer.tsx
|
|
9967
9949
|
var import_react19 = require("react");
|
|
9968
9950
|
var import_lucide_react14 = require("lucide-react");
|
|
9969
|
-
var
|
|
9951
|
+
var import_core20 = require("@unifold/core");
|
|
9970
9952
|
|
|
9971
9953
|
// src/hooks/use-bank-transfer-providers.ts
|
|
9972
|
-
var
|
|
9973
|
-
var
|
|
9954
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
9955
|
+
var import_core19 = require("@unifold/core");
|
|
9974
9956
|
function useBankTransferProviders({
|
|
9975
9957
|
publishableKey,
|
|
9976
9958
|
enabled = true,
|
|
9977
9959
|
countryCode
|
|
9978
9960
|
}) {
|
|
9979
9961
|
const normalizedCountry = countryCode?.toUpperCase();
|
|
9980
|
-
const { data: providers, isLoading } = (0,
|
|
9962
|
+
const { data: providers, isLoading } = (0, import_react_query9.useQuery)({
|
|
9981
9963
|
queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
|
|
9982
|
-
queryFn: () => (0,
|
|
9964
|
+
queryFn: () => (0, import_core19.getBankTransferProviders)(publishableKey, { countryCode: normalizedCountry }),
|
|
9983
9965
|
enabled,
|
|
9984
9966
|
staleTime: 1e3 * 60 * 30,
|
|
9985
9967
|
refetchOnMount: true,
|
|
@@ -10062,7 +10044,7 @@ function BankTransfer({
|
|
|
10062
10044
|
const providers = providersResponse?.data ?? [];
|
|
10063
10045
|
const pollingWalletId = (0, import_react19.useMemo)(() => {
|
|
10064
10046
|
if (!defaultToken) return void 0;
|
|
10065
|
-
return (0,
|
|
10047
|
+
return (0, import_core20.getWalletByChainType)(
|
|
10066
10048
|
wallets,
|
|
10067
10049
|
defaultToken.destination_token_metadata.chain_type
|
|
10068
10050
|
)?.id;
|
|
@@ -10095,7 +10077,7 @@ function BankTransfer({
|
|
|
10095
10077
|
let rate = sourceCurrency2 === "usd" ? 1 : fiatExchangeRates[sourceCurrency2];
|
|
10096
10078
|
if ((!rate || rate <= 0) && sourceCurrency2 !== "usd") {
|
|
10097
10079
|
try {
|
|
10098
|
-
const response = await (0,
|
|
10080
|
+
const response = await (0, import_core20.getFiatExchangeRates)({}, publishableKey);
|
|
10099
10081
|
if (response?.rates) {
|
|
10100
10082
|
setFiatExchangeRates((prev) => ({
|
|
10101
10083
|
...prev,
|
|
@@ -10128,7 +10110,7 @@ function BankTransfer({
|
|
|
10128
10110
|
setSessionError(strings.buyWithCard.errors.destinationTokenUnresolved);
|
|
10129
10111
|
return;
|
|
10130
10112
|
}
|
|
10131
|
-
const wallet = (0,
|
|
10113
|
+
const wallet = (0, import_core20.getWalletByChainType)(
|
|
10132
10114
|
wallets,
|
|
10133
10115
|
defaultToken.destination_token_metadata.chain_type
|
|
10134
10116
|
);
|
|
@@ -10177,9 +10159,9 @@ function BankTransfer({
|
|
|
10177
10159
|
setView("pending");
|
|
10178
10160
|
};
|
|
10179
10161
|
const openSession = (request) => {
|
|
10180
|
-
const externalId = (0,
|
|
10162
|
+
const externalId = (0, import_core20.generatePrefixedKSUID)("orsext");
|
|
10181
10163
|
const requestWithId = { ...request, external_id: externalId };
|
|
10182
|
-
const sessionStartUrl = (0,
|
|
10164
|
+
const sessionStartUrl = (0, import_core20.getOnrampSessionStartUrl)(requestWithId, publishableKey);
|
|
10183
10165
|
track("flow_started", {
|
|
10184
10166
|
method: "bank_transfer",
|
|
10185
10167
|
flow_type: "deposit",
|
|
@@ -10190,8 +10172,8 @@ function BankTransfer({
|
|
|
10190
10172
|
deposit_wallet_id: pollingWalletId
|
|
10191
10173
|
});
|
|
10192
10174
|
onEvent?.({
|
|
10193
|
-
id: (0,
|
|
10194
|
-
type:
|
|
10175
|
+
id: (0, import_core20.generatePrefixedKSUID)("sevt"),
|
|
10176
|
+
type: import_core20.DepositEventType.ONRAMP_SESSION_CREATED,
|
|
10195
10177
|
created: Math.floor(Date.now() / 1e3),
|
|
10196
10178
|
sessionId: getSessionId() ?? "",
|
|
10197
10179
|
method: "bank_transfer",
|
|
@@ -10205,7 +10187,7 @@ function BankTransfer({
|
|
|
10205
10187
|
};
|
|
10206
10188
|
const offerable = providers.filter((provider) => provider.enabled);
|
|
10207
10189
|
const noEnabledProviders = providers.length > 0 && offerable.length === 0;
|
|
10208
|
-
const sourceCurrencyIcon = assetCdnUrl ? (0,
|
|
10190
|
+
const sourceCurrencyIcon = assetCdnUrl ? (0, import_core20.getIconUrlWithCdn)(`/icons/currencies/png/${sourceCurrency}.png`, assetCdnUrl) : void 0;
|
|
10209
10191
|
const onrampTokenIcon = defaultToken?.destination_token_metadata?.icon_url;
|
|
10210
10192
|
const onrampChainIcon = defaultToken?.destination_token_metadata?.chain?.icon_url;
|
|
10211
10193
|
const onrampTokenSymbol = defaultToken?.destination_token_metadata?.symbol?.toUpperCase() ?? "USDC";
|
|
@@ -10666,12 +10648,12 @@ function BankTransfer({
|
|
|
10666
10648
|
|
|
10667
10649
|
// src/components/deposits/DepositExecutionItem.tsx
|
|
10668
10650
|
var import_lucide_react15 = require("lucide-react");
|
|
10669
|
-
var
|
|
10651
|
+
var import_core21 = require("@unifold/core");
|
|
10670
10652
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
10671
10653
|
function DepositExecutionItem({ execution, onClick }) {
|
|
10672
10654
|
const { colors: colors2, fonts, components } = useTheme();
|
|
10673
10655
|
const { t: strings, locale } = useI18n();
|
|
10674
|
-
const isPending = execution.status ===
|
|
10656
|
+
const isPending = execution.status === import_core21.ExecutionStatus.PENDING || execution.status === import_core21.ExecutionStatus.WAITING || execution.status === import_core21.ExecutionStatus.DELAYED;
|
|
10675
10657
|
const formatDateTime = (timestamp) => {
|
|
10676
10658
|
try {
|
|
10677
10659
|
const date = new Date(timestamp);
|
|
@@ -10718,7 +10700,7 @@ function DepositExecutionItem({ execution, onClick }) {
|
|
|
10718
10700
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
10719
10701
|
"img",
|
|
10720
10702
|
{
|
|
10721
|
-
src: execution.destination_token_metadata?.icon_url || (0,
|
|
10703
|
+
src: execution.destination_token_metadata?.icon_url || (0, import_core21.getIconUrl)("/icons/tokens/svg/usdc.svg"),
|
|
10722
10704
|
alt: "Token",
|
|
10723
10705
|
width: 36,
|
|
10724
10706
|
height: 36,
|
|
@@ -11731,7 +11713,7 @@ function BankTransferButton({
|
|
|
11731
11713
|
// src/components/deposits/buttons/BrowserWalletButton.tsx
|
|
11732
11714
|
var React33 = __toESM(require("react"));
|
|
11733
11715
|
var import_lucide_react25 = require("lucide-react");
|
|
11734
|
-
var
|
|
11716
|
+
var import_core22 = require("@unifold/core");
|
|
11735
11717
|
|
|
11736
11718
|
// src/lib/eip6963-store.ts
|
|
11737
11719
|
var import_mipd = require("mipd");
|
|
@@ -14221,7 +14203,7 @@ function BrowserWalletButton({
|
|
|
14221
14203
|
let cancelled = false;
|
|
14222
14204
|
const walletChainType = wallet.type === "phantom-solana" || wallet.type === "solflare" || wallet.type === "backpack" || wallet.type === "glow" ? "solana" : "ethereum";
|
|
14223
14205
|
setIsLoadingBalance(true);
|
|
14224
|
-
(0,
|
|
14206
|
+
(0, import_core22.getAddressBalances)(wallet.address, walletChainType, publishableKey).then((response) => {
|
|
14225
14207
|
if (cancelled) return;
|
|
14226
14208
|
if (response.balances && response.balances.length > 0) {
|
|
14227
14209
|
const totalUsd = response.balances.reduce((sum, balance) => {
|
|
@@ -14787,7 +14769,7 @@ function capitalize(s) {
|
|
|
14787
14769
|
}
|
|
14788
14770
|
|
|
14789
14771
|
// src/components/deposits/stripe-link/PayWithStripeLink.tsx
|
|
14790
|
-
var
|
|
14772
|
+
var import_core23 = require("@unifold/core");
|
|
14791
14773
|
|
|
14792
14774
|
// src/components/deposits/stripe-link/use-stripe-onramp.ts
|
|
14793
14775
|
var import_react20 = require("react");
|
|
@@ -14945,7 +14927,7 @@ var STRIPE_SESSION_STATUS = {
|
|
|
14945
14927
|
var STRIPE_SESSION_POLL_INTERVAL_MS = 3e3;
|
|
14946
14928
|
var STRIPE_CONSUMED_PAYMENT_METHOD_CODE = "payment_method_unexpected_state";
|
|
14947
14929
|
function isConsumedPaymentMethodError(err) {
|
|
14948
|
-
return err instanceof
|
|
14930
|
+
return err instanceof import_core23.StripeApiResponseError && (err.errorType === "stripe_onramp_payment_method_consumed" || err.stripeCode === STRIPE_CONSUMED_PAYMENT_METHOD_CODE);
|
|
14949
14931
|
}
|
|
14950
14932
|
function describeStripePaymentFailure(reason) {
|
|
14951
14933
|
if (!reason) return null;
|
|
@@ -15103,7 +15085,7 @@ function PayWithStripeLink({
|
|
|
15103
15085
|
let active = true;
|
|
15104
15086
|
const fetchConfig = async () => {
|
|
15105
15087
|
try {
|
|
15106
|
-
const cfg = await (0,
|
|
15088
|
+
const cfg = await (0, import_core23.stripeGetConfig)(publishableKey);
|
|
15107
15089
|
if (active && cfg.publishable_key) setResolvedStripeKey(cfg.publishable_key);
|
|
15108
15090
|
else if (active) {
|
|
15109
15091
|
console.error("[PayWithStripeLink] Config response missing publishable_key");
|
|
@@ -15125,7 +15107,7 @@ function PayWithStripeLink({
|
|
|
15125
15107
|
let active = true;
|
|
15126
15108
|
const retryConfig = async () => {
|
|
15127
15109
|
try {
|
|
15128
|
-
const cfg = await (0,
|
|
15110
|
+
const cfg = await (0, import_core23.stripeGetConfig)(publishableKey);
|
|
15129
15111
|
if (active && cfg.publishable_key) setResolvedStripeKey(cfg.publishable_key);
|
|
15130
15112
|
} catch (err) {
|
|
15131
15113
|
const msg = err instanceof Error ? err.message : t.formErrors.configLoadFailed;
|
|
@@ -15191,7 +15173,7 @@ function PayWithStripeLink({
|
|
|
15191
15173
|
if (!rt) return null;
|
|
15192
15174
|
const doRefresh = async () => {
|
|
15193
15175
|
try {
|
|
15194
|
-
const res = await (0,
|
|
15176
|
+
const res = await (0, import_core23.stripeRefreshToken)(rt, publishableKey);
|
|
15195
15177
|
const newToken = res.access_token;
|
|
15196
15178
|
const newRefresh = extractRefreshToken(res) || rt;
|
|
15197
15179
|
setOauthToken(newToken);
|
|
@@ -15225,7 +15207,7 @@ function PayWithStripeLink({
|
|
|
15225
15207
|
try {
|
|
15226
15208
|
return await fn(token);
|
|
15227
15209
|
} catch (err) {
|
|
15228
|
-
const is403 = err instanceof
|
|
15210
|
+
const is403 = err instanceof import_core23.StripeApiResponseError && err.statusCode === 403 || err instanceof Error && (err.message.includes("403") || err.message.toLowerCase().includes("forbidden"));
|
|
15229
15211
|
if (is403) {
|
|
15230
15212
|
if (!refreshTokenRef.current) {
|
|
15231
15213
|
setStep("email");
|
|
@@ -15260,7 +15242,7 @@ function PayWithStripeLink({
|
|
|
15260
15242
|
return;
|
|
15261
15243
|
}
|
|
15262
15244
|
try {
|
|
15263
|
-
const res = await (0,
|
|
15245
|
+
const res = await (0, import_core23.stripeRefreshToken)(stored.refreshToken, publishableKey);
|
|
15264
15246
|
if (cancelled) return;
|
|
15265
15247
|
token = res.access_token;
|
|
15266
15248
|
refresh = extractRefreshToken(res) || stored.refreshToken;
|
|
@@ -15283,7 +15265,7 @@ function PayWithStripeLink({
|
|
|
15283
15265
|
refreshTokenRef.current = refresh;
|
|
15284
15266
|
if (stored.email) setEmail(stored.email);
|
|
15285
15267
|
try {
|
|
15286
|
-
const cust = await (0,
|
|
15268
|
+
const cust = await (0, import_core23.stripeGetCustomer)(stored.customerId, token, publishableKey);
|
|
15287
15269
|
if (cancelled) return;
|
|
15288
15270
|
setCustomer(cust);
|
|
15289
15271
|
const tiers = cust.kyc_tiers ?? [];
|
|
@@ -15292,7 +15274,7 @@ function PayWithStripeLink({
|
|
|
15292
15274
|
const hasPending = ["l0", "l1", "l2"].some((t2) => getTierStatus(t2) === "pending");
|
|
15293
15275
|
if (l1Status === "verified" && !hasPending) {
|
|
15294
15276
|
try {
|
|
15295
|
-
const pmResult = await (0,
|
|
15277
|
+
const pmResult = await (0, import_core23.stripeListPaymentTokens)(
|
|
15296
15278
|
stored.customerId,
|
|
15297
15279
|
token,
|
|
15298
15280
|
publishableKey
|
|
@@ -15452,7 +15434,7 @@ function PayWithStripeLink({
|
|
|
15452
15434
|
(0, import_react21.useEffect)(() => {
|
|
15453
15435
|
if (!destinationTokenAddress || !destinationChainId || !destinationChainType) return;
|
|
15454
15436
|
let cancelled = false;
|
|
15455
|
-
(0,
|
|
15437
|
+
(0, import_core23.stripeGetDefaultToken)(
|
|
15456
15438
|
{
|
|
15457
15439
|
tokenAddress: destinationTokenAddress,
|
|
15458
15440
|
chainId: destinationChainId,
|
|
@@ -15522,7 +15504,7 @@ function PayWithStripeLink({
|
|
|
15522
15504
|
enabled: !externalWallets?.length
|
|
15523
15505
|
});
|
|
15524
15506
|
const depositWallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
|
|
15525
|
-
const onrampWalletAddress = (0,
|
|
15507
|
+
const onrampWalletAddress = (0, import_core23.getWalletByChainType)(depositWallets, stripeDestChainType)?.address;
|
|
15526
15508
|
const [registeredWalletKey, setRegisteredWalletKey] = (0, import_react21.useState)(null);
|
|
15527
15509
|
const walletKeyFor = (address) => `${stripeDestNetwork}:${stripeDestChainType === "ethereum" ? address.toLowerCase() : address}`;
|
|
15528
15510
|
const isOnrampWalletRegistered = !!onrampWalletAddress && registeredWalletKey === walletKeyFor(onrampWalletAddress);
|
|
@@ -15535,7 +15517,7 @@ function PayWithStripeLink({
|
|
|
15535
15517
|
);
|
|
15536
15518
|
}
|
|
15537
15519
|
}, [depositWallets, onrampWalletAddress, stripeDestChainType]);
|
|
15538
|
-
const depositWalletId = (0,
|
|
15520
|
+
const depositWalletId = (0, import_core23.getWalletByChainType)(depositWallets, stripeDestChainType)?.id;
|
|
15539
15521
|
const depositPollingActive = step === "checkout" || step === "success";
|
|
15540
15522
|
const { executions } = useDepositPolling({
|
|
15541
15523
|
userId,
|
|
@@ -15562,7 +15544,7 @@ function PayWithStripeLink({
|
|
|
15562
15544
|
executionReconciledSessionRef.current = confirmedSessionId;
|
|
15563
15545
|
handledTerminalSessionRef.current = confirmedSessionId;
|
|
15564
15546
|
let cancelled = false;
|
|
15565
|
-
void withTokenRefresh((tok) => (0,
|
|
15547
|
+
void withTokenRefresh((tok) => (0, import_core23.stripeGetSession)(confirmedSessionId, tok, publishableKey)).then((session) => {
|
|
15566
15548
|
if (cancelled) return;
|
|
15567
15549
|
setSessionStatus(
|
|
15568
15550
|
session.status === STRIPE_SESSION_STATUS.REJECTED || session.status === STRIPE_SESSION_STATUS.EXPIRED ? session.status : STRIPE_SESSION_STATUS.FULFILLMENT_COMPLETE
|
|
@@ -15588,7 +15570,7 @@ function PayWithStripeLink({
|
|
|
15588
15570
|
const poll = async () => {
|
|
15589
15571
|
try {
|
|
15590
15572
|
const session = await withTokenRefresh(
|
|
15591
|
-
(tok) => (0,
|
|
15573
|
+
(tok) => (0, import_core23.stripeGetSession)(confirmedSessionId, tok, publishableKey)
|
|
15592
15574
|
);
|
|
15593
15575
|
if (cancelled) return;
|
|
15594
15576
|
setSessionStatus(session.status);
|
|
@@ -15627,7 +15609,7 @@ function PayWithStripeLink({
|
|
|
15627
15609
|
setLoading(true);
|
|
15628
15610
|
setError(null);
|
|
15629
15611
|
try {
|
|
15630
|
-
const result = await (0,
|
|
15612
|
+
const result = await (0, import_core23.stripeCreateAuthIntent)(emailToUse.trim(), publishableKey);
|
|
15631
15613
|
setAuthIntentId(result.auth_intent_id);
|
|
15632
15614
|
setStep("auth");
|
|
15633
15615
|
} catch (err) {
|
|
@@ -15661,7 +15643,7 @@ function PayWithStripeLink({
|
|
|
15661
15643
|
}
|
|
15662
15644
|
const formattedPhone = `+1${digits}`;
|
|
15663
15645
|
await sdk.registerLinkUser(email.trim(), formattedPhone, "US");
|
|
15664
|
-
const result = await (0,
|
|
15646
|
+
const result = await (0, import_core23.stripeCreateAuthIntent)(email.trim(), publishableKey);
|
|
15665
15647
|
setAuthIntentId(result.auth_intent_id);
|
|
15666
15648
|
setStep("auth");
|
|
15667
15649
|
} catch (err) {
|
|
@@ -15704,7 +15686,7 @@ function PayWithStripeLink({
|
|
|
15704
15686
|
return;
|
|
15705
15687
|
}
|
|
15706
15688
|
try {
|
|
15707
|
-
const authResult = await (0,
|
|
15689
|
+
const authResult = await (0, import_core23.stripeCreateAuthIntent)(knownEmail, publishableKey);
|
|
15708
15690
|
setAuthIntentId(authResult.auth_intent_id);
|
|
15709
15691
|
setStep("auth");
|
|
15710
15692
|
} catch (err) {
|
|
@@ -15731,7 +15713,7 @@ function PayWithStripeLink({
|
|
|
15731
15713
|
setCustomerId(result.crypto_customer_id);
|
|
15732
15714
|
sdkAuthenticatedRef.current = true;
|
|
15733
15715
|
everAuthenticatedRef.current = true;
|
|
15734
|
-
const tokens = await (0,
|
|
15716
|
+
const tokens = await (0, import_core23.stripeExchangeTokens)(
|
|
15735
15717
|
authIntentId,
|
|
15736
15718
|
publishableKey,
|
|
15737
15719
|
result.crypto_customer_id
|
|
@@ -15809,7 +15791,7 @@ function PayWithStripeLink({
|
|
|
15809
15791
|
}
|
|
15810
15792
|
try {
|
|
15811
15793
|
const cust = await withTokenRefresh(
|
|
15812
|
-
(tok) => (0,
|
|
15794
|
+
(tok) => (0, import_core23.stripeGetCustomer)(customerId, tok, publishableKey)
|
|
15813
15795
|
);
|
|
15814
15796
|
if (!mounted) return;
|
|
15815
15797
|
setCustomer(cust);
|
|
@@ -16008,7 +15990,7 @@ function PayWithStripeLink({
|
|
|
16008
15990
|
try {
|
|
16009
15991
|
if (!onrampWalletAddress) return;
|
|
16010
15992
|
const existingWallets = await withTokenRefresh(
|
|
16011
|
-
(tok) => (0,
|
|
15993
|
+
(tok) => (0, import_core23.stripeListWallets)(customerId, tok, publishableKey)
|
|
16012
15994
|
);
|
|
16013
15995
|
if (!mounted) return;
|
|
16014
15996
|
setWallets(existingWallets.data);
|
|
@@ -16068,7 +16050,7 @@ function PayWithStripeLink({
|
|
|
16068
16050
|
return isEvm ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
16069
16051
|
};
|
|
16070
16052
|
const list = await withTokenRefresh(
|
|
16071
|
-
(tok) => (0,
|
|
16053
|
+
(tok) => (0, import_core23.stripeListWallets)(customerId, tok, publishableKey)
|
|
16072
16054
|
);
|
|
16073
16055
|
if (cancelled) return;
|
|
16074
16056
|
setWallets(list.data);
|
|
@@ -16118,7 +16100,7 @@ function PayWithStripeLink({
|
|
|
16118
16100
|
setLoading(true);
|
|
16119
16101
|
try {
|
|
16120
16102
|
const existing = await withTokenRefresh(
|
|
16121
|
-
(tok) => (0,
|
|
16103
|
+
(tok) => (0, import_core23.stripeListPaymentTokens)(customerId, tok, publishableKey)
|
|
16122
16104
|
);
|
|
16123
16105
|
if (!mounted) return;
|
|
16124
16106
|
setPaymentTokens(existing.data);
|
|
@@ -16138,7 +16120,7 @@ function PayWithStripeLink({
|
|
|
16138
16120
|
try {
|
|
16139
16121
|
const sdk = await initialize();
|
|
16140
16122
|
if (!sdk) throw new Error("SDK failed to load");
|
|
16141
|
-
const authResult = await (0,
|
|
16123
|
+
const authResult = await (0, import_core23.stripeCreateAuthIntent)(email, publishableKey);
|
|
16142
16124
|
if (!mounted) return;
|
|
16143
16125
|
setAuthIntentId(authResult.auth_intent_id);
|
|
16144
16126
|
setStep("auth");
|
|
@@ -16189,7 +16171,7 @@ function PayWithStripeLink({
|
|
|
16189
16171
|
if (!sdkAuthenticatedRef.current) {
|
|
16190
16172
|
if (email) {
|
|
16191
16173
|
pendingAddPaymentRef.current = true;
|
|
16192
|
-
const authResult = await (0,
|
|
16174
|
+
const authResult = await (0, import_core23.stripeCreateAuthIntent)(email, publishableKey);
|
|
16193
16175
|
if (!mounted) return;
|
|
16194
16176
|
setAuthIntentId(authResult.auth_intent_id);
|
|
16195
16177
|
setStep("auth");
|
|
@@ -16224,7 +16206,7 @@ function PayWithStripeLink({
|
|
|
16224
16206
|
if (display) {
|
|
16225
16207
|
applyAndAdvance();
|
|
16226
16208
|
if (customerId && accessTokenRef.current) {
|
|
16227
|
-
(0,
|
|
16209
|
+
(0, import_core23.stripeListPaymentTokens)(customerId, accessTokenRef.current, publishableKey).then((tokens) => {
|
|
16228
16210
|
if (mounted) setPaymentTokens(tokens.data);
|
|
16229
16211
|
}).catch(() => {
|
|
16230
16212
|
});
|
|
@@ -16233,7 +16215,7 @@ function PayWithStripeLink({
|
|
|
16233
16215
|
}
|
|
16234
16216
|
try {
|
|
16235
16217
|
if (customerId && accessTokenRef.current) {
|
|
16236
|
-
const tokens = await (0,
|
|
16218
|
+
const tokens = await (0, import_core23.stripeListPaymentTokens)(
|
|
16237
16219
|
customerId,
|
|
16238
16220
|
accessTokenRef.current,
|
|
16239
16221
|
publishableKey
|
|
@@ -16294,10 +16276,10 @@ function PayWithStripeLink({
|
|
|
16294
16276
|
setRequiredStepUp(tier ?? null);
|
|
16295
16277
|
setStep("amount");
|
|
16296
16278
|
if (customerId && onrampWalletAddress) {
|
|
16297
|
-
void withTokenRefresh((tok) => (0,
|
|
16279
|
+
void withTokenRefresh((tok) => (0, import_core23.stripeGetCustomer)(customerId, tok, publishableKey)).then((cust) => setCustomer(cust)).catch(() => {
|
|
16298
16280
|
});
|
|
16299
16281
|
void withTokenRefresh(
|
|
16300
|
-
(tok) => (0,
|
|
16282
|
+
(tok) => (0, import_core23.stripeGetTransactionLimits)(
|
|
16301
16283
|
{
|
|
16302
16284
|
cryptoCustomerId: customerId,
|
|
16303
16285
|
destinationNetwork: getStripeNetwork(),
|
|
@@ -16358,13 +16340,13 @@ function PayWithStripeLink({
|
|
|
16358
16340
|
return coordinator.performCheckout(sid, async (onrampSessionId) => {
|
|
16359
16341
|
try {
|
|
16360
16342
|
await withTokenRefresh(
|
|
16361
|
-
(tok) => (0,
|
|
16343
|
+
(tok) => (0, import_core23.stripeRefreshQuote)(onrampSessionId, tok, publishableKey)
|
|
16362
16344
|
);
|
|
16363
16345
|
} catch {
|
|
16364
16346
|
}
|
|
16365
16347
|
try {
|
|
16366
16348
|
const confirmResponse = await withTokenRefresh(
|
|
16367
|
-
(tok) => (0,
|
|
16349
|
+
(tok) => (0, import_core23.stripeConfirmSession)(onrampSessionId, tok, {}, publishableKey)
|
|
16368
16350
|
);
|
|
16369
16351
|
lastConfirmError = null;
|
|
16370
16352
|
return confirmResponse.client_secret ?? "";
|
|
@@ -16376,13 +16358,13 @@ function PayWithStripeLink({
|
|
|
16376
16358
|
};
|
|
16377
16359
|
const lastErrorFor = async (sid) => {
|
|
16378
16360
|
const sessionState = await withTokenRefresh(
|
|
16379
|
-
(tok) => (0,
|
|
16361
|
+
(tok) => (0, import_core23.stripeGetSession)(sid, tok, publishableKey)
|
|
16380
16362
|
);
|
|
16381
16363
|
return sessionState.transaction_details?.last_error ?? null;
|
|
16382
16364
|
};
|
|
16383
16365
|
const createFreshSession = async () => {
|
|
16384
16366
|
const fresh = await withTokenRefresh(
|
|
16385
|
-
(tok) => (0,
|
|
16367
|
+
(tok) => (0, import_core23.stripeCreateSession)(
|
|
16386
16368
|
{
|
|
16387
16369
|
cryptoCustomerId: customerId,
|
|
16388
16370
|
paymentToken: selectedPaymentToken,
|
|
@@ -16454,7 +16436,7 @@ function PayWithStripeLink({
|
|
|
16454
16436
|
} else if (isConsumedPaymentMethodError(lastConfirmError)) {
|
|
16455
16437
|
dropConsumedToken(CONSUMED_TOKEN_MESSAGE, lastConfirmError);
|
|
16456
16438
|
} else {
|
|
16457
|
-
const confirmErr = lastConfirmError instanceof
|
|
16439
|
+
const confirmErr = lastConfirmError instanceof import_core23.StripeApiResponseError ? lastConfirmError : void 0;
|
|
16458
16440
|
const reason = describeStripePaymentFailure(lastError) ?? describeStripePaymentFailure(confirmErr?.stripeCode) ?? unmappedPaymentFailureMessage(confirmErr?.stripeMessage);
|
|
16459
16441
|
if (!isRetriablePaymentToken(selectedPaymentToken)) {
|
|
16460
16442
|
dropConsumedToken(reason, lastConfirmError ?? void 0);
|
|
@@ -16472,7 +16454,7 @@ function PayWithStripeLink({
|
|
|
16472
16454
|
}
|
|
16473
16455
|
} catch (err) {
|
|
16474
16456
|
if (isStale()) return;
|
|
16475
|
-
const stripeErr = lastConfirmError instanceof
|
|
16457
|
+
const stripeErr = lastConfirmError instanceof import_core23.StripeApiResponseError ? lastConfirmError : err instanceof import_core23.StripeApiResponseError ? err : void 0;
|
|
16476
16458
|
const effectiveError = stripeErr ?? err;
|
|
16477
16459
|
const msg = stripeErr?.message ?? (err instanceof Error ? err.message : t.formErrors.checkoutFailed);
|
|
16478
16460
|
const errorType = stripeErr?.errorType;
|
|
@@ -16520,7 +16502,7 @@ function PayWithStripeLink({
|
|
|
16520
16502
|
if (!customerId) return;
|
|
16521
16503
|
try {
|
|
16522
16504
|
const existing = await withTokenRefresh(
|
|
16523
|
-
(tok) => (0,
|
|
16505
|
+
(tok) => (0, import_core23.stripeListPaymentTokens)(customerId, tok, publishableKey)
|
|
16524
16506
|
);
|
|
16525
16507
|
setPaymentTokens(existing.data);
|
|
16526
16508
|
const stored = getStoredSelectedToken(customerId);
|
|
@@ -16557,7 +16539,7 @@ function PayWithStripeLink({
|
|
|
16557
16539
|
const fetchLimits = async () => {
|
|
16558
16540
|
try {
|
|
16559
16541
|
const result = await withTokenRefresh(
|
|
16560
|
-
(tok) => (0,
|
|
16542
|
+
(tok) => (0, import_core23.stripeGetTransactionLimits)(
|
|
16561
16543
|
{
|
|
16562
16544
|
cryptoCustomerId: customerId,
|
|
16563
16545
|
destinationNetwork: getStripeNetwork(),
|
|
@@ -16633,8 +16615,8 @@ function PayWithStripeLink({
|
|
|
16633
16615
|
const canRefreshExisting = step === "review" && existing != null && existing.amount === amount && existing.paymentToken === selectedPaymentToken && // Never refresh (and thereby reuse) a session already checked out —
|
|
16634
16616
|
// its PaymentIntent is spent. Build a fresh one instead.
|
|
16635
16617
|
!spentSessionIdsRef.current.has(existing.id);
|
|
16636
|
-
const session = canRefreshExisting ? await withTokenRefresh((tok) => (0,
|
|
16637
|
-
(tok) => (0,
|
|
16618
|
+
const session = canRefreshExisting ? await withTokenRefresh((tok) => (0, import_core23.stripeRefreshQuote)(existing.id, tok, publishableKey)) : await withTokenRefresh(
|
|
16619
|
+
(tok) => (0, import_core23.stripeCreateSession)(
|
|
16638
16620
|
{
|
|
16639
16621
|
cryptoCustomerId: customerId,
|
|
16640
16622
|
paymentToken: selectedPaymentToken,
|
|
@@ -16676,7 +16658,7 @@ function PayWithStripeLink({
|
|
|
16676
16658
|
}
|
|
16677
16659
|
} else {
|
|
16678
16660
|
setSessionForCheckout(null);
|
|
16679
|
-
const result = await (0,
|
|
16661
|
+
const result = await (0, import_core23.stripeGetQuotes)(
|
|
16680
16662
|
{
|
|
16681
16663
|
sourceAmount: amount,
|
|
16682
16664
|
sourceCurrency: "usd",
|
|
@@ -16704,7 +16686,7 @@ function PayWithStripeLink({
|
|
|
16704
16686
|
if (!active) return;
|
|
16705
16687
|
setQuote(null);
|
|
16706
16688
|
setSessionForCheckout(null);
|
|
16707
|
-
const qErrorType = err instanceof
|
|
16689
|
+
const qErrorType = err instanceof import_core23.StripeApiResponseError ? err.errorType : void 0;
|
|
16708
16690
|
if (qErrorType === "stripe_onramp_missing_document_verification") {
|
|
16709
16691
|
setLimitReachedAmount(num);
|
|
16710
16692
|
setRequiredStepUp("l2");
|
|
@@ -18487,11 +18469,11 @@ function PayWithStripeLink({
|
|
|
18487
18469
|
// src/components/deposits/CoinbaseConnect.tsx
|
|
18488
18470
|
var import_react22 = require("react");
|
|
18489
18471
|
var import_lucide_react29 = require("lucide-react");
|
|
18490
|
-
var
|
|
18472
|
+
var import_core26 = require("@unifold/core");
|
|
18491
18473
|
|
|
18492
18474
|
// src/hooks/use-project-config.ts
|
|
18493
|
-
var
|
|
18494
|
-
var
|
|
18475
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
18476
|
+
var import_core24 = require("@unifold/core");
|
|
18495
18477
|
function useProjectConfig({
|
|
18496
18478
|
publishableKey,
|
|
18497
18479
|
enabled = true,
|
|
@@ -18502,17 +18484,17 @@ function useProjectConfig({
|
|
|
18502
18484
|
data: projectConfig,
|
|
18503
18485
|
isLoading,
|
|
18504
18486
|
error
|
|
18505
|
-
} = (0,
|
|
18487
|
+
} = (0, import_react_query10.useQuery)({
|
|
18506
18488
|
// Country is part of the key so a region change refetches the region-aware
|
|
18507
18489
|
// config. Omitted when undefined so callers that don't pass a country keep
|
|
18508
18490
|
// sharing the base cache entry.
|
|
18509
18491
|
queryKey: countryCode ? ["unifold", "projectConfig", publishableKey, countryCode, subdivisionCode ?? null] : ["unifold", "projectConfig", publishableKey],
|
|
18510
|
-
queryFn: () => (0,
|
|
18492
|
+
queryFn: () => (0, import_core24.getProjectConfig)(publishableKey, countryCode ? { countryCode, subdivisionCode } : void 0),
|
|
18511
18493
|
enabled,
|
|
18512
18494
|
// Keep the previous (e.g. no-country) config visible while the region-aware
|
|
18513
18495
|
// config refetches after the country resolves, so unrelated config-driven
|
|
18514
18496
|
// UI doesn't flash back to defaults.
|
|
18515
|
-
placeholderData:
|
|
18497
|
+
placeholderData: import_react_query10.keepPreviousData,
|
|
18516
18498
|
staleTime: 1e3 * 60 * 30,
|
|
18517
18499
|
refetchOnMount: true,
|
|
18518
18500
|
refetchOnWindowFocus: true
|
|
@@ -18521,14 +18503,14 @@ function useProjectConfig({
|
|
|
18521
18503
|
}
|
|
18522
18504
|
|
|
18523
18505
|
// src/hooks/use-integration-transfer-default-token.ts
|
|
18524
|
-
var
|
|
18525
|
-
var
|
|
18506
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
18507
|
+
var import_core25 = require("@unifold/core");
|
|
18526
18508
|
function useIntegrationTransferDefaultToken({
|
|
18527
18509
|
params,
|
|
18528
18510
|
publishableKey,
|
|
18529
18511
|
enabled = true
|
|
18530
18512
|
}) {
|
|
18531
|
-
return (0,
|
|
18513
|
+
return (0, import_react_query11.useQuery)({
|
|
18532
18514
|
queryKey: [
|
|
18533
18515
|
"unifold",
|
|
18534
18516
|
"integrationTransferDefaultToken",
|
|
@@ -18541,7 +18523,7 @@ function useIntegrationTransferDefaultToken({
|
|
|
18541
18523
|
params?.country_code ?? null,
|
|
18542
18524
|
params?.subdivision_code ?? null
|
|
18543
18525
|
],
|
|
18544
|
-
queryFn: () => (0,
|
|
18526
|
+
queryFn: () => (0, import_core25.getIntegrationTransferDefaultToken)(params, publishableKey),
|
|
18545
18527
|
enabled: enabled && !!params,
|
|
18546
18528
|
staleTime: 1e3 * 60 * 5,
|
|
18547
18529
|
gcTime: 1e3 * 60 * 30,
|
|
@@ -18645,7 +18627,7 @@ function CoinbaseConnect({
|
|
|
18645
18627
|
const appName = projectConfig?.project_name ?? "Unifold";
|
|
18646
18628
|
const { t: strings } = useI18n();
|
|
18647
18629
|
const t = strings.connectExchange;
|
|
18648
|
-
const initialView = skipToHoldings && getStoredIntegrationToken(
|
|
18630
|
+
const initialView = skipToHoldings && getStoredIntegrationToken(import_core26.IntegrationProvider.COINBASE) ? "holdings" : "select_exchange";
|
|
18649
18631
|
const [view, setView] = (0, import_react22.useState)(initialView);
|
|
18650
18632
|
const [prevView, setPrevView] = (0, import_react22.useState)(initialView);
|
|
18651
18633
|
const [isTransitioning, setIsTransitioning] = (0, import_react22.useState)(false);
|
|
@@ -18681,7 +18663,7 @@ function CoinbaseConnect({
|
|
|
18681
18663
|
}, [selectedExchange]);
|
|
18682
18664
|
const defaultTokenParams = (0, import_react22.useMemo)(
|
|
18683
18665
|
() => selectedAsset ? {
|
|
18684
|
-
integration_provider:
|
|
18666
|
+
integration_provider: import_core26.IntegrationProvider.COINBASE,
|
|
18685
18667
|
source_currency: selectedAsset.currency.toLowerCase(),
|
|
18686
18668
|
destination_token_address: destinationTokenAddress,
|
|
18687
18669
|
destination_chain_id: destinationChainId,
|
|
@@ -18802,16 +18784,16 @@ function CoinbaseConnect({
|
|
|
18802
18784
|
const tryRefreshToken = (0, import_react22.useCallback)(
|
|
18803
18785
|
async (currentToken) => {
|
|
18804
18786
|
try {
|
|
18805
|
-
const result = await (0,
|
|
18787
|
+
const result = await (0, import_core26.refreshIntegrationToken)(currentToken, publishableKey);
|
|
18806
18788
|
setStoredIntegrationToken({
|
|
18807
|
-
integration_provider:
|
|
18789
|
+
integration_provider: import_core26.IntegrationProvider.COINBASE,
|
|
18808
18790
|
access_token: result.access_token,
|
|
18809
18791
|
expires_at: result.expires_at
|
|
18810
18792
|
});
|
|
18811
18793
|
setAccessToken(result.access_token);
|
|
18812
18794
|
return result.access_token;
|
|
18813
18795
|
} catch {
|
|
18814
|
-
clearStoredIntegrationToken(
|
|
18796
|
+
clearStoredIntegrationToken(import_core26.IntegrationProvider.COINBASE);
|
|
18815
18797
|
setAccessToken(null);
|
|
18816
18798
|
return null;
|
|
18817
18799
|
}
|
|
@@ -18819,7 +18801,7 @@ function CoinbaseConnect({
|
|
|
18819
18801
|
[publishableKey]
|
|
18820
18802
|
);
|
|
18821
18803
|
(0, import_react22.useEffect)(() => {
|
|
18822
|
-
const stored = getStoredIntegrationToken(
|
|
18804
|
+
const stored = getStoredIntegrationToken(import_core26.IntegrationProvider.COINBASE);
|
|
18823
18805
|
if (stored) {
|
|
18824
18806
|
setAccessToken(stored.access_token);
|
|
18825
18807
|
if (skipToHoldings) {
|
|
@@ -18831,7 +18813,7 @@ function CoinbaseConnect({
|
|
|
18831
18813
|
const userSubdivisionCode = userIpInfo?.subdivisionCode ?? void 0;
|
|
18832
18814
|
(0, import_react22.useEffect)(() => {
|
|
18833
18815
|
let cancelled = false;
|
|
18834
|
-
(0,
|
|
18816
|
+
(0, import_core26.getIntegrationExchanges)(
|
|
18835
18817
|
publishableKey,
|
|
18836
18818
|
userCountryCode ? {
|
|
18837
18819
|
country_code: userCountryCode,
|
|
@@ -18844,7 +18826,7 @@ function CoinbaseConnect({
|
|
|
18844
18826
|
if (prev) {
|
|
18845
18827
|
return res.data.find((e) => e.service_provider === prev.service_provider) ?? prev;
|
|
18846
18828
|
}
|
|
18847
|
-
return res.data.find((e) => e.service_provider ===
|
|
18829
|
+
return res.data.find((e) => e.service_provider === import_core26.IntegrationProvider.COINBASE) ?? null;
|
|
18848
18830
|
});
|
|
18849
18831
|
}).catch(() => {
|
|
18850
18832
|
}).finally(() => {
|
|
@@ -18858,8 +18840,8 @@ function CoinbaseConnect({
|
|
|
18858
18840
|
async (token) => {
|
|
18859
18841
|
setIsLoading(true);
|
|
18860
18842
|
try {
|
|
18861
|
-
const result = await (0,
|
|
18862
|
-
|
|
18843
|
+
const result = await (0, import_core26.getIntegrationHoldings)(
|
|
18844
|
+
import_core26.IntegrationProvider.COINBASE,
|
|
18863
18845
|
token,
|
|
18864
18846
|
publishableKey
|
|
18865
18847
|
);
|
|
@@ -18876,8 +18858,8 @@ function CoinbaseConnect({
|
|
|
18876
18858
|
const refreshed = await tryRefreshToken(token);
|
|
18877
18859
|
if (refreshed) {
|
|
18878
18860
|
try {
|
|
18879
|
-
const retryResult = await (0,
|
|
18880
|
-
|
|
18861
|
+
const retryResult = await (0, import_core26.getIntegrationHoldings)(
|
|
18862
|
+
import_core26.IntegrationProvider.COINBASE,
|
|
18881
18863
|
refreshed,
|
|
18882
18864
|
publishableKey
|
|
18883
18865
|
);
|
|
@@ -18894,12 +18876,12 @@ function CoinbaseConnect({
|
|
|
18894
18876
|
retryFailed = true;
|
|
18895
18877
|
}
|
|
18896
18878
|
}
|
|
18897
|
-
clearStoredIntegrationToken(
|
|
18879
|
+
clearStoredIntegrationToken(import_core26.IntegrationProvider.COINBASE);
|
|
18898
18880
|
setAccessToken(null);
|
|
18899
18881
|
track("account_connection_failed", {
|
|
18900
18882
|
flow_type: "deposit",
|
|
18901
18883
|
method: "exchange_connect",
|
|
18902
|
-
provider:
|
|
18884
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
18903
18885
|
failure_reason: retryFailed ? "holdings_unavailable" : "token_refresh_failed"
|
|
18904
18886
|
});
|
|
18905
18887
|
transitionTo("select_exchange");
|
|
@@ -18975,7 +18957,7 @@ function CoinbaseConnect({
|
|
|
18975
18957
|
...userIpInfo?.subdivisionCode ? { subdivision_code: userIpInfo.subdivisionCode } : {}
|
|
18976
18958
|
};
|
|
18977
18959
|
setRedirectSession({ exchange, requestParams });
|
|
18978
|
-
window.open((0,
|
|
18960
|
+
window.open((0, import_core26.getIntegrationExchangeSessionStartUrl)(requestParams, publishableKey), "_blank");
|
|
18979
18961
|
transitionTo("redirect_pending");
|
|
18980
18962
|
};
|
|
18981
18963
|
const handleCreateRedirectTransferSession = async () => {
|
|
@@ -18986,7 +18968,7 @@ function CoinbaseConnect({
|
|
|
18986
18968
|
if (redirectMinDepositUsd > 0 && amountNum < redirectMinDepositUsd) return;
|
|
18987
18969
|
setIsLoading(true);
|
|
18988
18970
|
try {
|
|
18989
|
-
const result = await (0,
|
|
18971
|
+
const result = await (0, import_core26.createIntegrationExchangeSession)(
|
|
18990
18972
|
{
|
|
18991
18973
|
service_provider: exchange.service_provider,
|
|
18992
18974
|
wallet_addresses: [{ address: wallet.address, chain_type: wallet.chain_type }],
|
|
@@ -19020,7 +19002,7 @@ function CoinbaseConnect({
|
|
|
19020
19002
|
const handleReopenRedirectExchange = () => {
|
|
19021
19003
|
if (!redirectSession?.requestParams) return;
|
|
19022
19004
|
window.open(
|
|
19023
|
-
(0,
|
|
19005
|
+
(0, import_core26.getIntegrationExchangeSessionStartUrl)(redirectSession.requestParams, publishableKey),
|
|
19024
19006
|
"_blank"
|
|
19025
19007
|
);
|
|
19026
19008
|
};
|
|
@@ -19037,7 +19019,7 @@ function CoinbaseConnect({
|
|
|
19037
19019
|
const externalId = redirectSession.externalId;
|
|
19038
19020
|
const poll = async () => {
|
|
19039
19021
|
try {
|
|
19040
|
-
const result = await (0,
|
|
19022
|
+
const result = await (0, import_core26.getOnrampSessionStatus)(externalId, publishableKey);
|
|
19041
19023
|
setRedirectStatus(result.status);
|
|
19042
19024
|
if (result.status === "failed") {
|
|
19043
19025
|
setErrorMessage("Payment failed");
|
|
@@ -19067,8 +19049,8 @@ function CoinbaseConnect({
|
|
|
19067
19049
|
handleOpenRedirectExchange(exchange);
|
|
19068
19050
|
return;
|
|
19069
19051
|
}
|
|
19070
|
-
if (exchange.service_provider ===
|
|
19071
|
-
const stored = getStoredIntegrationToken(
|
|
19052
|
+
if (exchange.service_provider === import_core26.IntegrationProvider.COINBASE) {
|
|
19053
|
+
const stored = getStoredIntegrationToken(import_core26.IntegrationProvider.COINBASE);
|
|
19072
19054
|
if (stored) {
|
|
19073
19055
|
setAccessToken(stored.access_token);
|
|
19074
19056
|
connectingReasonRef.current = "holdings";
|
|
@@ -19086,20 +19068,20 @@ function CoinbaseConnect({
|
|
|
19086
19068
|
track("account_connection_started", {
|
|
19087
19069
|
flow_type: "deposit",
|
|
19088
19070
|
method: "exchange_connect",
|
|
19089
|
-
provider:
|
|
19071
|
+
provider: import_core26.IntegrationProvider.COINBASE
|
|
19090
19072
|
});
|
|
19091
19073
|
try {
|
|
19092
|
-
const { redirect_url, state } = await (0,
|
|
19074
|
+
const { redirect_url, state } = await (0, import_core26.startIntegrationOAuth)(publishableKey);
|
|
19093
19075
|
popupRef.current = window.open(redirect_url, "_blank", "width=500,height=700");
|
|
19094
19076
|
pollRef.current = setInterval(async () => {
|
|
19095
19077
|
try {
|
|
19096
|
-
const result = await (0,
|
|
19078
|
+
const result = await (0, import_core26.authenticateIntegrationOAuth)({ state }, publishableKey);
|
|
19097
19079
|
if (result.status === "completed") {
|
|
19098
19080
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
19099
19081
|
pollRef.current = null;
|
|
19100
19082
|
if (oauthAbandonedRef.current || viewRef.current !== "connecting") return;
|
|
19101
19083
|
setStoredIntegrationToken({
|
|
19102
|
-
integration_provider:
|
|
19084
|
+
integration_provider: import_core26.IntegrationProvider.COINBASE,
|
|
19103
19085
|
access_token: result.access_token,
|
|
19104
19086
|
expires_at: result.expires_at
|
|
19105
19087
|
});
|
|
@@ -19107,7 +19089,7 @@ function CoinbaseConnect({
|
|
|
19107
19089
|
track("account_connected", {
|
|
19108
19090
|
flow_type: "deposit",
|
|
19109
19091
|
method: "exchange_connect",
|
|
19110
|
-
provider:
|
|
19092
|
+
provider: import_core26.IntegrationProvider.COINBASE
|
|
19111
19093
|
});
|
|
19112
19094
|
transitionTo("connected");
|
|
19113
19095
|
}
|
|
@@ -19119,7 +19101,7 @@ function CoinbaseConnect({
|
|
|
19119
19101
|
track("account_connection_failed", {
|
|
19120
19102
|
flow_type: "deposit",
|
|
19121
19103
|
method: "exchange_connect",
|
|
19122
|
-
provider:
|
|
19104
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19123
19105
|
failure_reason: "oauth_start_failed",
|
|
19124
19106
|
error_code: message
|
|
19125
19107
|
});
|
|
@@ -19165,9 +19147,9 @@ function CoinbaseConnect({
|
|
|
19165
19147
|
if (matchingWallet?.id) {
|
|
19166
19148
|
setTransferDepositWalletId(matchingWallet.id);
|
|
19167
19149
|
}
|
|
19168
|
-
const createTransfer = async (token) => (0,
|
|
19150
|
+
const createTransfer = async (token) => (0, import_core26.createIntegrationTransfer)(
|
|
19169
19151
|
{
|
|
19170
|
-
integration_provider:
|
|
19152
|
+
integration_provider: import_core26.IntegrationProvider.COINBASE,
|
|
19171
19153
|
access_token: token,
|
|
19172
19154
|
currency: selectedAsset.currency.toLowerCase(),
|
|
19173
19155
|
amount: cryptoAmount,
|
|
@@ -19192,7 +19174,7 @@ function CoinbaseConnect({
|
|
|
19192
19174
|
track("account_connection_failed", {
|
|
19193
19175
|
flow_type: "deposit",
|
|
19194
19176
|
method: "exchange_connect",
|
|
19195
|
-
provider:
|
|
19177
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19196
19178
|
failure_reason: "token_refresh_failed"
|
|
19197
19179
|
});
|
|
19198
19180
|
throw new Error("Session expired. Please reconnect your exchange.");
|
|
@@ -19210,12 +19192,12 @@ function CoinbaseConnect({
|
|
|
19210
19192
|
setIsLoading(false);
|
|
19211
19193
|
}
|
|
19212
19194
|
};
|
|
19213
|
-
const transferErrorType = (err) => err instanceof
|
|
19195
|
+
const transferErrorType = (err) => err instanceof import_core26.IntegrationTransferError ? err.errorType : void 0;
|
|
19214
19196
|
const trackTransferStarted = () => {
|
|
19215
19197
|
track("flow_started", {
|
|
19216
19198
|
flow_type: "deposit",
|
|
19217
19199
|
method: "exchange_connect",
|
|
19218
|
-
provider:
|
|
19200
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19219
19201
|
// No execution yet — one appears when the exchange's transfer lands on
|
|
19220
19202
|
// this wallet, carrying the same id.
|
|
19221
19203
|
deposit_wallet_id: transferDepositWalletId,
|
|
@@ -19231,7 +19213,7 @@ function CoinbaseConnect({
|
|
|
19231
19213
|
track("verification_started", {
|
|
19232
19214
|
flow_type: "deposit",
|
|
19233
19215
|
method: "exchange_connect",
|
|
19234
|
-
provider:
|
|
19216
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19235
19217
|
verification_type: "mfa",
|
|
19236
19218
|
verification_status: result.status
|
|
19237
19219
|
});
|
|
@@ -19260,7 +19242,7 @@ function CoinbaseConnect({
|
|
|
19260
19242
|
let sessionExpired = false;
|
|
19261
19243
|
try {
|
|
19262
19244
|
let token = accessToken;
|
|
19263
|
-
const result = await (0,
|
|
19245
|
+
const result = await (0, import_core26.confirmIntegrationTransfer)(
|
|
19264
19246
|
transferIntent.id,
|
|
19265
19247
|
token,
|
|
19266
19248
|
void 0,
|
|
@@ -19272,7 +19254,7 @@ function CoinbaseConnect({
|
|
|
19272
19254
|
const refreshed = await tryRefreshToken(token);
|
|
19273
19255
|
if (refreshed) {
|
|
19274
19256
|
token = refreshed;
|
|
19275
|
-
return (0,
|
|
19257
|
+
return (0, import_core26.confirmIntegrationTransfer)(
|
|
19276
19258
|
transferIntent.id,
|
|
19277
19259
|
refreshed,
|
|
19278
19260
|
void 0,
|
|
@@ -19283,7 +19265,7 @@ function CoinbaseConnect({
|
|
|
19283
19265
|
track("account_connection_failed", {
|
|
19284
19266
|
flow_type: "deposit",
|
|
19285
19267
|
method: "exchange_connect",
|
|
19286
|
-
provider:
|
|
19268
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19287
19269
|
failure_reason: "token_refresh_failed"
|
|
19288
19270
|
});
|
|
19289
19271
|
throw err;
|
|
@@ -19308,11 +19290,11 @@ function CoinbaseConnect({
|
|
|
19308
19290
|
track("verification_submitted", {
|
|
19309
19291
|
flow_type: "deposit",
|
|
19310
19292
|
method: "exchange_connect",
|
|
19311
|
-
provider:
|
|
19293
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19312
19294
|
verification_type: "mfa"
|
|
19313
19295
|
});
|
|
19314
19296
|
try {
|
|
19315
|
-
const result = await (0,
|
|
19297
|
+
const result = await (0, import_core26.confirmIntegrationTransfer)(
|
|
19316
19298
|
transferIntent.id,
|
|
19317
19299
|
accessToken,
|
|
19318
19300
|
mfaCode,
|
|
@@ -19322,7 +19304,7 @@ function CoinbaseConnect({
|
|
|
19322
19304
|
track("verification_failed", {
|
|
19323
19305
|
flow_type: "deposit",
|
|
19324
19306
|
method: "exchange_connect",
|
|
19325
|
-
provider:
|
|
19307
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19326
19308
|
verification_type: "mfa",
|
|
19327
19309
|
verification_status: result.status,
|
|
19328
19310
|
failure_reason: "invalid_code"
|
|
@@ -19333,7 +19315,7 @@ function CoinbaseConnect({
|
|
|
19333
19315
|
track("verification_completed", {
|
|
19334
19316
|
flow_type: "deposit",
|
|
19335
19317
|
method: "exchange_connect",
|
|
19336
|
-
provider:
|
|
19318
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19337
19319
|
verification_type: "mfa",
|
|
19338
19320
|
verification_status: result.status
|
|
19339
19321
|
});
|
|
@@ -19345,7 +19327,7 @@ function CoinbaseConnect({
|
|
|
19345
19327
|
track("verification_failed", {
|
|
19346
19328
|
flow_type: "deposit",
|
|
19347
19329
|
method: "exchange_connect",
|
|
19348
|
-
provider:
|
|
19330
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19349
19331
|
verification_type: "mfa",
|
|
19350
19332
|
verification_status: result.status,
|
|
19351
19333
|
failure_reason: result.message || "transfer_failed"
|
|
@@ -19362,7 +19344,7 @@ function CoinbaseConnect({
|
|
|
19362
19344
|
track("verification_failed", {
|
|
19363
19345
|
flow_type: "deposit",
|
|
19364
19346
|
method: "exchange_connect",
|
|
19365
|
-
provider:
|
|
19347
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19366
19348
|
verification_type: "mfa",
|
|
19367
19349
|
failure_reason: errorType || (err instanceof Error ? err.message : "mfa_request_failed")
|
|
19368
19350
|
});
|
|
@@ -19395,14 +19377,14 @@ function CoinbaseConnect({
|
|
|
19395
19377
|
track("account_connection_failed", {
|
|
19396
19378
|
flow_type: "deposit",
|
|
19397
19379
|
method: "exchange_connect",
|
|
19398
|
-
provider:
|
|
19380
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19399
19381
|
failure_reason: "abandoned"
|
|
19400
19382
|
});
|
|
19401
19383
|
} else if (view === "mfa") {
|
|
19402
19384
|
track("verification_failed", {
|
|
19403
19385
|
flow_type: "deposit",
|
|
19404
19386
|
method: "exchange_connect",
|
|
19405
|
-
provider:
|
|
19387
|
+
provider: import_core26.IntegrationProvider.COINBASE,
|
|
19406
19388
|
verification_type: "mfa",
|
|
19407
19389
|
failure_reason: "abandoned"
|
|
19408
19390
|
});
|
|
@@ -19563,7 +19545,7 @@ function CoinbaseConnect({
|
|
|
19563
19545
|
},
|
|
19564
19546
|
children: t.comingSoon
|
|
19565
19547
|
}
|
|
19566
|
-
) : accessToken && exchange.service_provider ===
|
|
19548
|
+
) : accessToken && exchange.service_provider === import_core26.IntegrationProvider.COINBASE ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
19567
19549
|
"span",
|
|
19568
19550
|
{
|
|
19569
19551
|
className: "uf-text-xs uf-px-2.5 uf-py-1 uf-rounded-full",
|
|
@@ -21338,15 +21320,15 @@ function resolveDepositMenuLayout(layout, displayMode) {
|
|
|
21338
21320
|
}
|
|
21339
21321
|
|
|
21340
21322
|
// src/hooks/use-exchanges.ts
|
|
21341
|
-
var
|
|
21342
|
-
var
|
|
21323
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
21324
|
+
var import_core27 = require("@unifold/core");
|
|
21343
21325
|
function useExchanges({
|
|
21344
21326
|
publishableKey,
|
|
21345
21327
|
enabled = true
|
|
21346
21328
|
}) {
|
|
21347
|
-
const { data: exchanges = [], isLoading } = (0,
|
|
21329
|
+
const { data: exchanges = [], isLoading } = (0, import_react_query12.useQuery)({
|
|
21348
21330
|
queryKey: ["unifold", "exchanges", publishableKey],
|
|
21349
|
-
queryFn: () => (0,
|
|
21331
|
+
queryFn: () => (0, import_core27.getExchanges)(void 0, publishableKey).then((res) => res.data),
|
|
21350
21332
|
enabled,
|
|
21351
21333
|
staleTime: 1e3 * 60 * 30,
|
|
21352
21334
|
refetchOnMount: false,
|
|
@@ -21356,8 +21338,8 @@ function useExchanges({
|
|
|
21356
21338
|
}
|
|
21357
21339
|
|
|
21358
21340
|
// src/hooks/use-public-incident.ts
|
|
21359
|
-
var
|
|
21360
|
-
var
|
|
21341
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
21342
|
+
var import_core28 = require("@unifold/core");
|
|
21361
21343
|
function usePublicIncident({
|
|
21362
21344
|
publishableKey,
|
|
21363
21345
|
enabled = true
|
|
@@ -21366,9 +21348,9 @@ function usePublicIncident({
|
|
|
21366
21348
|
data: incident,
|
|
21367
21349
|
isLoading,
|
|
21368
21350
|
error
|
|
21369
|
-
} = (0,
|
|
21351
|
+
} = (0, import_react_query13.useQuery)({
|
|
21370
21352
|
queryKey: ["unifold", "publicIncident", publishableKey],
|
|
21371
|
-
queryFn: () => (0,
|
|
21353
|
+
queryFn: () => (0, import_core28.getPublicIncident)(publishableKey),
|
|
21372
21354
|
enabled,
|
|
21373
21355
|
staleTime: 1e3 * 30,
|
|
21374
21356
|
refetchInterval: 1e3 * 30,
|
|
@@ -21378,16 +21360,16 @@ function usePublicIncident({
|
|
|
21378
21360
|
}
|
|
21379
21361
|
|
|
21380
21362
|
// src/hooks/use-wallet-pay-providers.ts
|
|
21381
|
-
var
|
|
21382
|
-
var
|
|
21363
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
21364
|
+
var import_core29 = require("@unifold/core");
|
|
21383
21365
|
function useWalletPayProviders({
|
|
21384
21366
|
method,
|
|
21385
21367
|
publishableKey,
|
|
21386
21368
|
enabled = true
|
|
21387
21369
|
}) {
|
|
21388
|
-
const { data: providers, isLoading } = (0,
|
|
21370
|
+
const { data: providers, isLoading } = (0, import_react_query14.useQuery)({
|
|
21389
21371
|
queryKey: ["unifold", "walletPayProviders", method, publishableKey],
|
|
21390
|
-
queryFn: () => (0,
|
|
21372
|
+
queryFn: () => (0, import_core29.getWalletPayProviders)(method, publishableKey),
|
|
21391
21373
|
enabled,
|
|
21392
21374
|
staleTime: 1e3 * 60 * 30,
|
|
21393
21375
|
refetchOnMount: true,
|
|
@@ -21403,11 +21385,11 @@ function platformSupportsWalletPay(method, platform) {
|
|
|
21403
21385
|
}
|
|
21404
21386
|
|
|
21405
21387
|
// src/components/deposits/DepositModal.tsx
|
|
21406
|
-
var
|
|
21388
|
+
var import_core42 = require("@unifold/core");
|
|
21407
21389
|
|
|
21408
21390
|
// src/hooks/use-forward-deposit-events.ts
|
|
21409
21391
|
var import_react23 = require("react");
|
|
21410
|
-
var
|
|
21392
|
+
var import_core32 = require("@unifold/core");
|
|
21411
21393
|
var import_analytics = require("@unifold/analytics");
|
|
21412
21394
|
|
|
21413
21395
|
// src/lib/selection-events.ts
|
|
@@ -21480,11 +21462,11 @@ function walletConnectionPayload(event) {
|
|
|
21480
21462
|
}
|
|
21481
21463
|
|
|
21482
21464
|
// src/lib/account-connection-events.ts
|
|
21483
|
-
var
|
|
21465
|
+
var import_core30 = require("@unifold/core");
|
|
21484
21466
|
var ACCOUNT_CONNECTION_EVENTS = {
|
|
21485
|
-
account_connection_started:
|
|
21486
|
-
account_connected:
|
|
21487
|
-
account_connection_failed:
|
|
21467
|
+
account_connection_started: import_core30.DepositEventType.ACCOUNT_CONNECTION_STARTED,
|
|
21468
|
+
account_connected: import_core30.DepositEventType.ACCOUNT_CONNECTED,
|
|
21469
|
+
account_connection_failed: import_core30.DepositEventType.ACCOUNT_CONNECTION_FAILED
|
|
21488
21470
|
};
|
|
21489
21471
|
var str3 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
21490
21472
|
function accountConnectionPayload(event) {
|
|
@@ -21504,11 +21486,11 @@ function accountConnectionPayload(event) {
|
|
|
21504
21486
|
}
|
|
21505
21487
|
|
|
21506
21488
|
// src/lib/verification-events.ts
|
|
21507
|
-
var
|
|
21489
|
+
var import_core31 = require("@unifold/core");
|
|
21508
21490
|
var VERIFICATION_EVENTS = {
|
|
21509
|
-
verification_started:
|
|
21510
|
-
verification_completed:
|
|
21511
|
-
verification_failed:
|
|
21491
|
+
verification_started: import_core31.DepositEventType.VERIFICATION_STARTED,
|
|
21492
|
+
verification_completed: import_core31.DepositEventType.VERIFICATION_COMPLETED,
|
|
21493
|
+
verification_failed: import_core31.DepositEventType.VERIFICATION_FAILED
|
|
21512
21494
|
};
|
|
21513
21495
|
function verificationPayload(event) {
|
|
21514
21496
|
const type = VERIFICATION_EVENTS[event.event];
|
|
@@ -21522,9 +21504,9 @@ function verificationPayload(event) {
|
|
|
21522
21504
|
|
|
21523
21505
|
// src/hooks/use-forward-deposit-events.ts
|
|
21524
21506
|
var WALLET_CONNECTION_TYPES = {
|
|
21525
|
-
started:
|
|
21526
|
-
connected:
|
|
21527
|
-
failed:
|
|
21507
|
+
started: import_core32.DepositEventType.WALLET_CONNECTION_STARTED,
|
|
21508
|
+
connected: import_core32.DepositEventType.WALLET_CONNECTED,
|
|
21509
|
+
failed: import_core32.DepositEventType.WALLET_CONNECTION_FAILED
|
|
21528
21510
|
};
|
|
21529
21511
|
function depositMethodFromAnalytics(method) {
|
|
21530
21512
|
if (typeof method !== "string") return void 0;
|
|
@@ -21548,7 +21530,7 @@ function useForwardDepositEvents(onEvent) {
|
|
|
21548
21530
|
if (event.event === "flow_started") {
|
|
21549
21531
|
onEventRef.current?.({
|
|
21550
21532
|
...base,
|
|
21551
|
-
type:
|
|
21533
|
+
type: import_core32.DepositEventType.FLOW_STARTED,
|
|
21552
21534
|
...withMethod,
|
|
21553
21535
|
data: {
|
|
21554
21536
|
object: {
|
|
@@ -21597,7 +21579,7 @@ function useForwardDepositEvents(onEvent) {
|
|
|
21597
21579
|
case "token":
|
|
21598
21580
|
onEventRef.current?.({
|
|
21599
21581
|
...base,
|
|
21600
|
-
type:
|
|
21582
|
+
type: import_core32.DepositEventType.TOKEN_SELECTED,
|
|
21601
21583
|
...withMethod,
|
|
21602
21584
|
data: { object: selection.data }
|
|
21603
21585
|
});
|
|
@@ -21605,7 +21587,7 @@ function useForwardDepositEvents(onEvent) {
|
|
|
21605
21587
|
case "wallet":
|
|
21606
21588
|
onEventRef.current?.({
|
|
21607
21589
|
...base,
|
|
21608
|
-
type:
|
|
21590
|
+
type: import_core32.DepositEventType.WALLET_SELECTED,
|
|
21609
21591
|
...withMethod,
|
|
21610
21592
|
data: { object: selection.data }
|
|
21611
21593
|
});
|
|
@@ -21613,7 +21595,7 @@ function useForwardDepositEvents(onEvent) {
|
|
|
21613
21595
|
case "provider":
|
|
21614
21596
|
onEventRef.current?.({
|
|
21615
21597
|
...base,
|
|
21616
|
-
type:
|
|
21598
|
+
type: import_core32.DepositEventType.PROVIDER_SELECTED,
|
|
21617
21599
|
...withMethod,
|
|
21618
21600
|
data: { object: selection.data }
|
|
21619
21601
|
});
|
|
@@ -21667,8 +21649,8 @@ function useAllowedCountry(publishableKey) {
|
|
|
21667
21649
|
}
|
|
21668
21650
|
|
|
21669
21651
|
// src/hooks/use-address-validation.ts
|
|
21670
|
-
var
|
|
21671
|
-
var
|
|
21652
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
21653
|
+
var import_core33 = require("@unifold/core");
|
|
21672
21654
|
function useAddressValidation({
|
|
21673
21655
|
recipientAddress,
|
|
21674
21656
|
destinationChainType,
|
|
@@ -21679,7 +21661,7 @@ function useAddressValidation({
|
|
|
21679
21661
|
refetchOnMount = false
|
|
21680
21662
|
}) {
|
|
21681
21663
|
const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
21682
|
-
const { data, isLoading, error } = (0,
|
|
21664
|
+
const { data, isLoading, error } = (0, import_react_query15.useQuery)({
|
|
21683
21665
|
queryKey: [
|
|
21684
21666
|
"unifold",
|
|
21685
21667
|
"addressValidation",
|
|
@@ -21688,7 +21670,7 @@ function useAddressValidation({
|
|
|
21688
21670
|
destinationChainId,
|
|
21689
21671
|
destinationTokenAddress
|
|
21690
21672
|
],
|
|
21691
|
-
queryFn: () => (0,
|
|
21673
|
+
queryFn: () => (0, import_core33.verifyRecipientAddress)(
|
|
21692
21674
|
{
|
|
21693
21675
|
chain_type: destinationChainType,
|
|
21694
21676
|
chain_id: destinationChainId,
|
|
@@ -21971,7 +21953,7 @@ function PoweredByUnifold({
|
|
|
21971
21953
|
}
|
|
21972
21954
|
|
|
21973
21955
|
// src/components/deposits/DepositsModal.tsx
|
|
21974
|
-
var
|
|
21956
|
+
var import_core34 = require("@unifold/core");
|
|
21975
21957
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
21976
21958
|
function DepositsModal({
|
|
21977
21959
|
open,
|
|
@@ -21990,7 +21972,7 @@ function DepositsModal({
|
|
|
21990
21972
|
if (!open || !userId) return;
|
|
21991
21973
|
const fetchExecutions = async () => {
|
|
21992
21974
|
try {
|
|
21993
|
-
const response = await (0,
|
|
21975
|
+
const response = await (0, import_core34.queryExecutions)(userId, publishableKey, import_core34.ActionType.Deposit);
|
|
21994
21976
|
const sorted = [...response.data].sort((a, b) => {
|
|
21995
21977
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
21996
21978
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -23125,11 +23107,11 @@ var TooltipContent = React37.forwardRef(({ className, sideOffset = 4, ...props }
|
|
|
23125
23107
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
23126
23108
|
|
|
23127
23109
|
// src/components/deposits/TransferCryptoSingleInput.tsx
|
|
23128
|
-
var
|
|
23110
|
+
var import_core36 = require("@unifold/core");
|
|
23129
23111
|
|
|
23130
23112
|
// src/hooks/use-hypercore-activation.ts
|
|
23131
|
-
var
|
|
23132
|
-
var
|
|
23113
|
+
var import_react_query16 = require("@tanstack/react-query");
|
|
23114
|
+
var import_core35 = require("@unifold/core");
|
|
23133
23115
|
|
|
23134
23116
|
// src/lib/constants.ts
|
|
23135
23117
|
var HYPERCORE_CHAIN_ID = "1337";
|
|
@@ -23147,9 +23129,9 @@ function useHypercoreActivation(params) {
|
|
|
23147
23129
|
const recipient = recipientAddress?.trim() ?? "";
|
|
23148
23130
|
const source = sourceAddress?.trim() ?? "";
|
|
23149
23131
|
const hasAddresses = !!recipient && !!source;
|
|
23150
|
-
const { data, isLoading } = (0,
|
|
23132
|
+
const { data, isLoading } = (0, import_react_query16.useQuery)({
|
|
23151
23133
|
queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
|
|
23152
|
-
queryFn: () => (0,
|
|
23134
|
+
queryFn: () => (0, import_core35.checkHypercoreActivation)(
|
|
23153
23135
|
{
|
|
23154
23136
|
source_address: source,
|
|
23155
23137
|
recipient_address: recipient
|
|
@@ -23302,7 +23284,7 @@ function TransferCryptoSingleInput({
|
|
|
23302
23284
|
(c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
|
|
23303
23285
|
) : void 0;
|
|
23304
23286
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
23305
|
-
const currentWallet = (0,
|
|
23287
|
+
const currentWallet = (0, import_core36.getWalletByChainType)(wallets, currentChainType);
|
|
23306
23288
|
const depositAddress = currentWallet?.address || "";
|
|
23307
23289
|
const {
|
|
23308
23290
|
executions: depositExecutions,
|
|
@@ -23544,7 +23526,7 @@ function TransferCryptoSingleInput({
|
|
|
23544
23526
|
className: "uf-text-sm uf-font-semibold",
|
|
23545
23527
|
style: { color: components.card.titleColor, fontFamily: fonts.semibold },
|
|
23546
23528
|
children: [
|
|
23547
|
-
checkoutQuote.isStablecoin ? (0,
|
|
23529
|
+
checkoutQuote.isStablecoin ? (0, import_core36.formatStablecoinAmount)(
|
|
23548
23530
|
checkoutQuote.sourceAmount,
|
|
23549
23531
|
checkoutQuote.sourceTokenDecimals
|
|
23550
23532
|
) : (Number(checkoutQuote.sourceAmount) / 10 ** checkoutQuote.sourceTokenDecimals).toFixed(Math.min(checkoutQuote.sourceTokenDecimals, 6)),
|
|
@@ -24044,7 +24026,7 @@ var SelectSeparator = React38.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
24044
24026
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
24045
24027
|
|
|
24046
24028
|
// src/components/deposits/TransferCryptoDoubleInput.tsx
|
|
24047
|
-
var
|
|
24029
|
+
var import_core37 = require("@unifold/core");
|
|
24048
24030
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
24049
24031
|
var getChainKey3 = (chainId, chainType) => {
|
|
24050
24032
|
return `${chainType}:${chainId}`;
|
|
@@ -24151,7 +24133,7 @@ function TransferCryptoDoubleInput({
|
|
|
24151
24133
|
(c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
|
|
24152
24134
|
) : void 0;
|
|
24153
24135
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
24154
|
-
const currentWallet = (0,
|
|
24136
|
+
const currentWallet = (0, import_core37.getWalletByChainType)(wallets, currentChainType);
|
|
24155
24137
|
const depositAddress = currentWallet?.address || "";
|
|
24156
24138
|
const {
|
|
24157
24139
|
executions: depositExecutions,
|
|
@@ -24721,7 +24703,7 @@ function TransferCryptoDoubleInput({
|
|
|
24721
24703
|
// src/components/deposits/WalletConnect.tsx
|
|
24722
24704
|
var React39 = __toESM(require("react"));
|
|
24723
24705
|
var import_lucide_react39 = require("lucide-react");
|
|
24724
|
-
var
|
|
24706
|
+
var import_core41 = require("@unifold/core");
|
|
24725
24707
|
|
|
24726
24708
|
// src/lib/wallet-errors.ts
|
|
24727
24709
|
function messageOf(err) {
|
|
@@ -24901,7 +24883,7 @@ function describeWalletError(err, action) {
|
|
|
24901
24883
|
}
|
|
24902
24884
|
|
|
24903
24885
|
// src/lib/send-hypercore.ts
|
|
24904
|
-
var
|
|
24886
|
+
var import_core38 = require("@unifold/core");
|
|
24905
24887
|
function isHypercoreChain(chainId) {
|
|
24906
24888
|
return chainId === HYPERCORE_CHAIN_ID;
|
|
24907
24889
|
}
|
|
@@ -24912,7 +24894,7 @@ async function sendHypercoreEvmTransfer(params) {
|
|
|
24912
24894
|
params: []
|
|
24913
24895
|
});
|
|
24914
24896
|
const activeChainId = String(parseInt(currentChainHex, 16));
|
|
24915
|
-
const buildResult = await (0,
|
|
24897
|
+
const buildResult = await (0, import_core38.buildHypercoreTransaction)(
|
|
24916
24898
|
{
|
|
24917
24899
|
signature_chain_id: activeChainId,
|
|
24918
24900
|
recipient_address: recipientAddress,
|
|
@@ -24925,7 +24907,7 @@ async function sendHypercoreEvmTransfer(params) {
|
|
|
24925
24907
|
method: "eth_signTypedData_v4",
|
|
24926
24908
|
params: [fromAddress, JSON.stringify(buildResult.typed_data)]
|
|
24927
24909
|
});
|
|
24928
|
-
await (0,
|
|
24910
|
+
await (0, import_core38.sendHypercoreTransaction)(
|
|
24929
24911
|
{
|
|
24930
24912
|
action_payload: buildResult.action_payload,
|
|
24931
24913
|
signature,
|
|
@@ -24937,8 +24919,8 @@ async function sendHypercoreEvmTransfer(params) {
|
|
|
24937
24919
|
}
|
|
24938
24920
|
|
|
24939
24921
|
// src/hooks/use-deposit-quote.ts
|
|
24940
|
-
var
|
|
24941
|
-
var
|
|
24922
|
+
var import_react_query17 = require("@tanstack/react-query");
|
|
24923
|
+
var import_core39 = require("@unifold/core");
|
|
24942
24924
|
function useDepositQuote(params) {
|
|
24943
24925
|
const {
|
|
24944
24926
|
publishableKey,
|
|
@@ -24964,7 +24946,7 @@ function useDepositQuote(params) {
|
|
|
24964
24946
|
...adjustForSlippage ? { adjust_for_slippage: true } : {},
|
|
24965
24947
|
...stablecoinParity ? { stablecoin_parity: true } : {}
|
|
24966
24948
|
};
|
|
24967
|
-
return (0,
|
|
24949
|
+
return (0, import_react_query17.useQuery)({
|
|
24968
24950
|
queryKey: [
|
|
24969
24951
|
"unifold",
|
|
24970
24952
|
"depositQuote",
|
|
@@ -24979,7 +24961,7 @@ function useDepositQuote(params) {
|
|
|
24979
24961
|
stablecoinParity,
|
|
24980
24962
|
publishableKey
|
|
24981
24963
|
],
|
|
24982
|
-
queryFn: () => (0,
|
|
24964
|
+
queryFn: () => (0, import_core39.getDepositQuote)(request, publishableKey),
|
|
24983
24965
|
enabled: enabled && !!publishableKey && !!sourceChainType && !!sourceChainId && !!sourceTokenAddress && !!destinationAmount && destinationAmount !== "0" && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress,
|
|
24984
24966
|
staleTime: 3e4,
|
|
24985
24967
|
gcTime: 5 * 6e4,
|
|
@@ -24992,15 +24974,15 @@ function useDepositQuote(params) {
|
|
|
24992
24974
|
}
|
|
24993
24975
|
|
|
24994
24976
|
// src/hooks/use-external-wallets.ts
|
|
24995
|
-
var
|
|
24996
|
-
var
|
|
24977
|
+
var import_react_query18 = require("@tanstack/react-query");
|
|
24978
|
+
var import_core40 = require("@unifold/core");
|
|
24997
24979
|
function useExternalWallets({
|
|
24998
24980
|
publishableKey,
|
|
24999
24981
|
enabled = true
|
|
25000
24982
|
}) {
|
|
25001
|
-
const { data: wallets = [], isLoading } = (0,
|
|
24983
|
+
const { data: wallets = [], isLoading } = (0, import_react_query18.useQuery)({
|
|
25002
24984
|
queryKey: ["unifold", "external-wallets", publishableKey],
|
|
25003
|
-
queryFn: () => (0,
|
|
24985
|
+
queryFn: () => (0, import_core40.getExternalWallets)(publishableKey).then((res) => res.data),
|
|
25004
24986
|
enabled: enabled && !!publishableKey,
|
|
25005
24987
|
staleTime: 1e3 * 60 * 30,
|
|
25006
24988
|
refetchOnMount: false,
|
|
@@ -26411,7 +26393,7 @@ function WalletConnect({
|
|
|
26411
26393
|
try {
|
|
26412
26394
|
const cleanedAmountUsd = amountUsd?.replace(/[^0-9.]/g, "") ?? "";
|
|
26413
26395
|
const forwardedAmountUsd = parseFloat(cleanedAmountUsd) > 0 ? cleanedAmountUsd : void 0;
|
|
26414
|
-
const res = await (0,
|
|
26396
|
+
const res = await (0, import_core41.getWalletMobileDeepLink)(
|
|
26415
26397
|
wallet.id,
|
|
26416
26398
|
depositAddresses,
|
|
26417
26399
|
publishableKey,
|
|
@@ -26743,7 +26725,7 @@ function WalletConnect({
|
|
|
26743
26725
|
destination_chain_type: activeDepositWallet.destination_chain_type,
|
|
26744
26726
|
...productType ? { product_type: productType } : {}
|
|
26745
26727
|
};
|
|
26746
|
-
const response = await (0,
|
|
26728
|
+
const response = await (0, import_core41.getSupportedDepositTokens)(publishableKey, options);
|
|
26747
26729
|
if (cancelled) return;
|
|
26748
26730
|
const supportedToken = response.data.find(
|
|
26749
26731
|
(t2) => t2.symbol.toLowerCase() === token.symbol.toLowerCase()
|
|
@@ -26771,7 +26753,7 @@ function WalletConnect({
|
|
|
26771
26753
|
setIsLoading(true);
|
|
26772
26754
|
setError(null);
|
|
26773
26755
|
const sct = activeDepositWallet.chain_type === "algorand" || activeDepositWallet.chain_type === "xrpl" || activeDepositWallet.chain_type === "cardano" || activeDepositWallet.chain_type === "n1" || activeDepositWallet.chain_type === "tron" ? "ethereum" : activeDepositWallet.chain_type;
|
|
26774
|
-
(0,
|
|
26756
|
+
(0, import_core41.getAddressBalances)(activeWalletInfo.address, sct, publishableKey).then((response) => {
|
|
26775
26757
|
if (cancelled) return;
|
|
26776
26758
|
const nonZero = response.balances.filter((b) => b.amount !== "0");
|
|
26777
26759
|
const defaultSource = {
|
|
@@ -27064,7 +27046,7 @@ function WalletConnect({
|
|
|
27064
27046
|
if (!provider.publicKey) await provider.connect();
|
|
27065
27047
|
const isNative = token.token_address === "native" || token.token_address === "So11111111111111111111111111111111111111112" || token.token_address === "";
|
|
27066
27048
|
const smallestUnit = isNative ? decimalToSmallestUnit(amountStr, 9) : decimalToSmallestUnit(amountStr, token.decimals);
|
|
27067
|
-
const buildResp = await (0,
|
|
27049
|
+
const buildResp = await (0, import_core41.buildSolanaTransaction)(
|
|
27068
27050
|
{
|
|
27069
27051
|
chain_id: "mainnet",
|
|
27070
27052
|
token_address: token.token_address === "" ? "native" : token.token_address,
|
|
@@ -27086,7 +27068,7 @@ function WalletConnect({
|
|
|
27086
27068
|
const ser = signed.serialize();
|
|
27087
27069
|
let bs = "";
|
|
27088
27070
|
for (let i = 0; i < ser.length; i++) bs += String.fromCharCode(ser[i]);
|
|
27089
|
-
const resp = await (0,
|
|
27071
|
+
const resp = await (0, import_core41.sendSolanaTransaction)(
|
|
27090
27072
|
{ chain_id: "mainnet", signed_transaction: btoa(bs) },
|
|
27091
27073
|
publishableKey
|
|
27092
27074
|
);
|
|
@@ -27132,7 +27114,7 @@ function WalletConnect({
|
|
|
27132
27114
|
} else if (isHypercoreToken) {
|
|
27133
27115
|
let sendAmount = tokenAmount;
|
|
27134
27116
|
try {
|
|
27135
|
-
const activation = await (0,
|
|
27117
|
+
const activation = await (0, import_core41.checkHypercoreActivation)(
|
|
27136
27118
|
{ source_address: walletInfo.address, recipient_address: recipientAddress },
|
|
27137
27119
|
publishableKey
|
|
27138
27120
|
);
|
|
@@ -27493,8 +27475,8 @@ function WalletConnect({
|
|
|
27493
27475
|
] }) });
|
|
27494
27476
|
}
|
|
27495
27477
|
if (view === "mobile_deposit_status" && latestDepositExecution) {
|
|
27496
|
-
const isComplete = latestDepositExecution.status ===
|
|
27497
|
-
const isFailed = latestDepositExecution.status ===
|
|
27478
|
+
const isComplete = latestDepositExecution.status === import_core41.ExecutionStatus.SUCCEEDED;
|
|
27479
|
+
const isFailed = latestDepositExecution.status === import_core41.ExecutionStatus.FAILED;
|
|
27498
27480
|
const title = isComplete ? t.paymentComplete : isFailed ? t.paymentFailed : t.paymentProcessing;
|
|
27499
27481
|
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(AccentColorOverride, { accentColor: preConnectAccent, accentForeground: preConnectFg, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { style: viewTransitionStyle, children: [
|
|
27500
27482
|
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
@@ -27772,8 +27754,8 @@ function DepositModal({
|
|
|
27772
27754
|
(method) => {
|
|
27773
27755
|
track("payment_method_selected", { method: analyticsMethod(method), flow_type: "deposit" });
|
|
27774
27756
|
emitEvent({
|
|
27775
|
-
id: (0,
|
|
27776
|
-
type:
|
|
27757
|
+
id: (0, import_core42.generatePrefixedKSUID)("sevt"),
|
|
27758
|
+
type: import_core42.DepositEventType.METHOD_SELECTED,
|
|
27777
27759
|
created: Math.floor(Date.now() / 1e3),
|
|
27778
27760
|
sessionId: getSessionId() ?? "",
|
|
27779
27761
|
method,
|
|
@@ -27829,8 +27811,8 @@ function DepositModal({
|
|
|
27829
27811
|
});
|
|
27830
27812
|
onDepositError?.({ ...error, method });
|
|
27831
27813
|
emitEvent({
|
|
27832
|
-
id: (0,
|
|
27833
|
-
type:
|
|
27814
|
+
id: (0, import_core42.generatePrefixedKSUID)("sevt"),
|
|
27815
|
+
type: import_core42.DepositEventType.FLOW_FAILED,
|
|
27834
27816
|
created: Math.floor(Date.now() / 1e3),
|
|
27835
27817
|
sessionId: getSessionId() ?? "",
|
|
27836
27818
|
method,
|
|
@@ -27936,7 +27918,7 @@ function DepositModal({
|
|
|
27936
27918
|
const [integrationExchanges, setIntegrationExchanges] = (0, import_react31.useState)([]);
|
|
27937
27919
|
(0, import_react31.useEffect)(() => {
|
|
27938
27920
|
if (!showConnectExchange || !open) return;
|
|
27939
|
-
(0,
|
|
27921
|
+
(0, import_core42.getIntegrationExchanges)(
|
|
27940
27922
|
publishableKey,
|
|
27941
27923
|
userIpInfo?.alpha2 ? {
|
|
27942
27924
|
country_code: userIpInfo.alpha2,
|
|
@@ -27947,13 +27929,13 @@ function DepositModal({
|
|
|
27947
27929
|
}, [showConnectExchange, open, publishableKey, userIpInfo?.alpha2, userIpInfo?.subdivisionCode]);
|
|
27948
27930
|
const [connectedExchange, setConnectedExchange] = (0, import_react31.useState)(() => {
|
|
27949
27931
|
if (!showConnectExchange) return null;
|
|
27950
|
-
const stored = getStoredIntegrationToken(
|
|
27932
|
+
const stored = getStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE);
|
|
27951
27933
|
if (!stored) return null;
|
|
27952
27934
|
return { name: "Coinbase", iconUrl: void 0, balanceUsd: null, isLoading: true };
|
|
27953
27935
|
});
|
|
27954
27936
|
(0, import_react31.useEffect)(() => {
|
|
27955
27937
|
if (!showConnectExchange || !open || view !== "main") return;
|
|
27956
|
-
const stored = getStoredIntegrationToken(
|
|
27938
|
+
const stored = getStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE);
|
|
27957
27939
|
if (!stored) {
|
|
27958
27940
|
setConnectedExchange(null);
|
|
27959
27941
|
return;
|
|
@@ -27973,24 +27955,24 @@ function DepositModal({
|
|
|
27973
27955
|
}) : null;
|
|
27974
27956
|
setConnectedExchange((prev) => prev ? { ...prev, balanceUsd, isLoading: false } : null);
|
|
27975
27957
|
};
|
|
27976
|
-
(0,
|
|
27958
|
+
(0, import_core42.getIntegrationHoldings)(import_core42.IntegrationProvider.COINBASE, stored.access_token, publishableKey).then(processHoldings).catch(async () => {
|
|
27977
27959
|
try {
|
|
27978
|
-
const refreshResult = await (0,
|
|
27979
|
-
if (!getStoredIntegrationToken(
|
|
27960
|
+
const refreshResult = await (0, import_core42.refreshIntegrationToken)(stored.access_token, publishableKey);
|
|
27961
|
+
if (!getStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE)) return;
|
|
27980
27962
|
setStoredIntegrationToken({
|
|
27981
|
-
integration_provider:
|
|
27963
|
+
integration_provider: import_core42.IntegrationProvider.COINBASE,
|
|
27982
27964
|
access_token: refreshResult.access_token,
|
|
27983
27965
|
expires_at: refreshResult.expires_at
|
|
27984
27966
|
});
|
|
27985
|
-
const retryResult = await (0,
|
|
27986
|
-
|
|
27967
|
+
const retryResult = await (0, import_core42.getIntegrationHoldings)(
|
|
27968
|
+
import_core42.IntegrationProvider.COINBASE,
|
|
27987
27969
|
refreshResult.access_token,
|
|
27988
27970
|
publishableKey
|
|
27989
27971
|
);
|
|
27990
27972
|
processHoldings(retryResult);
|
|
27991
27973
|
} catch {
|
|
27992
|
-
if (!getStoredIntegrationToken(
|
|
27993
|
-
clearStoredIntegrationToken(
|
|
27974
|
+
if (!getStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE)) return;
|
|
27975
|
+
clearStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE);
|
|
27994
27976
|
setConnectedExchange(null);
|
|
27995
27977
|
}
|
|
27996
27978
|
});
|
|
@@ -27998,7 +27980,7 @@ function DepositModal({
|
|
|
27998
27980
|
(0, import_react31.useEffect)(() => {
|
|
27999
27981
|
if (!connectedExchange || integrationExchanges.length === 0) return;
|
|
28000
27982
|
const cbExchange = integrationExchanges.find(
|
|
28001
|
-
(e) => e.service_provider ===
|
|
27983
|
+
(e) => e.service_provider === import_core42.IntegrationProvider.COINBASE
|
|
28002
27984
|
);
|
|
28003
27985
|
const iconUrl = cbExchange?.icon_urls?.find((u) => u.format === "svg")?.url || cbExchange?.icon_urls?.find((u) => u.format === "png")?.url || cbExchange?.icon_url;
|
|
28004
27986
|
if (iconUrl && iconUrl !== connectedExchange.iconUrl) {
|
|
@@ -28117,7 +28099,7 @@ function DepositModal({
|
|
|
28117
28099
|
if (view !== "tracker" || !userId) return;
|
|
28118
28100
|
const fetchExecutions = async () => {
|
|
28119
28101
|
try {
|
|
28120
|
-
const response = await (0,
|
|
28102
|
+
const response = await (0, import_core42.queryExecutions)(userId, publishableKey, import_core42.ActionType.Deposit);
|
|
28121
28103
|
const sorted = [...response.data].sort((a, b) => {
|
|
28122
28104
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
28123
28105
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -28173,7 +28155,7 @@ function DepositModal({
|
|
|
28173
28155
|
const template = errors[code] ?? addressValidationMessages.defaultError;
|
|
28174
28156
|
return interpolate(template, metadata);
|
|
28175
28157
|
};
|
|
28176
|
-
const walletsRecipientError = (0,
|
|
28158
|
+
const walletsRecipientError = (0, import_core42.isDepositAddressValidationError)(walletsError) ? walletsError.message : null;
|
|
28177
28159
|
const isRecipientAddressInvalid = isAddressValid === false || walletsRecipientError !== null;
|
|
28178
28160
|
const recipientInvalidMessage = getAddressValidationErrorMessage(
|
|
28179
28161
|
addressFailureMessage ?? walletsRecipientError,
|
|
@@ -28231,11 +28213,11 @@ function DepositModal({
|
|
|
28231
28213
|
if (view === "wallet_connect" && sessionOpenedFromMenu) setView("main");
|
|
28232
28214
|
};
|
|
28233
28215
|
const handleExchangeDisconnect = () => {
|
|
28234
|
-
const stored = getStoredIntegrationToken(
|
|
28216
|
+
const stored = getStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE);
|
|
28235
28217
|
if (stored) {
|
|
28236
|
-
(0,
|
|
28218
|
+
(0, import_core42.revokeIntegrationToken)(stored.access_token, publishableKey);
|
|
28237
28219
|
}
|
|
28238
|
-
clearStoredIntegrationToken(
|
|
28220
|
+
clearStoredIntegrationToken(import_core42.IntegrationProvider.COINBASE);
|
|
28239
28221
|
setConnectedExchange(null);
|
|
28240
28222
|
if (view === "coinbase_connect" && sessionOpenedFromMenu) setView("main");
|
|
28241
28223
|
};
|
|
@@ -29294,12 +29276,12 @@ var import_lucide_react41 = require("lucide-react");
|
|
|
29294
29276
|
|
|
29295
29277
|
// src/hooks/use-forward-checkout-events.ts
|
|
29296
29278
|
var import_react32 = require("react");
|
|
29297
|
-
var
|
|
29279
|
+
var import_core43 = require("@unifold/core");
|
|
29298
29280
|
var import_analytics2 = require("@unifold/analytics");
|
|
29299
29281
|
var WALLET_CONNECTION_TYPES2 = {
|
|
29300
|
-
started:
|
|
29301
|
-
connected:
|
|
29302
|
-
failed:
|
|
29282
|
+
started: import_core43.CheckoutEventType.WALLET_CONNECTION_STARTED,
|
|
29283
|
+
connected: import_core43.CheckoutEventType.WALLET_CONNECTED,
|
|
29284
|
+
failed: import_core43.CheckoutEventType.WALLET_CONNECTION_FAILED
|
|
29303
29285
|
};
|
|
29304
29286
|
function checkoutMethodFromAnalytics(method) {
|
|
29305
29287
|
if (method !== "transfer_crypto" && method !== "transfer" && method !== "wallet_connect") {
|
|
@@ -29325,7 +29307,7 @@ function useForwardCheckoutEvents(onEvent, journeySessionId) {
|
|
|
29325
29307
|
if (event.event === "flow_started") {
|
|
29326
29308
|
onEventRef.current?.({
|
|
29327
29309
|
...base,
|
|
29328
|
-
type:
|
|
29310
|
+
type: import_core43.CheckoutEventType.FLOW_STARTED,
|
|
29329
29311
|
...withMethod,
|
|
29330
29312
|
data: {
|
|
29331
29313
|
object: {
|
|
@@ -29353,7 +29335,7 @@ function useForwardCheckoutEvents(onEvent, journeySessionId) {
|
|
|
29353
29335
|
case "token":
|
|
29354
29336
|
onEventRef.current?.({
|
|
29355
29337
|
...base,
|
|
29356
|
-
type:
|
|
29338
|
+
type: import_core43.CheckoutEventType.TOKEN_SELECTED,
|
|
29357
29339
|
...withMethod,
|
|
29358
29340
|
data: { object: selection.data }
|
|
29359
29341
|
});
|
|
@@ -29361,7 +29343,7 @@ function useForwardCheckoutEvents(onEvent, journeySessionId) {
|
|
|
29361
29343
|
case "wallet":
|
|
29362
29344
|
onEventRef.current?.({
|
|
29363
29345
|
...base,
|
|
29364
|
-
type:
|
|
29346
|
+
type: import_core43.CheckoutEventType.WALLET_SELECTED,
|
|
29365
29347
|
...withMethod,
|
|
29366
29348
|
data: { object: selection.data }
|
|
29367
29349
|
});
|
|
@@ -29377,14 +29359,14 @@ function useForwardCheckoutEvents(onEvent, journeySessionId) {
|
|
|
29377
29359
|
}
|
|
29378
29360
|
|
|
29379
29361
|
// src/hooks/use-payment-intent.ts
|
|
29380
|
-
var
|
|
29381
|
-
var
|
|
29362
|
+
var import_react_query19 = require("@tanstack/react-query");
|
|
29363
|
+
var import_core44 = require("@unifold/core");
|
|
29382
29364
|
var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
|
|
29383
29365
|
function usePaymentIntent(params) {
|
|
29384
29366
|
const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
|
|
29385
|
-
return (0,
|
|
29367
|
+
return (0, import_react_query19.useQuery)({
|
|
29386
29368
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
29387
|
-
queryFn: () => (0,
|
|
29369
|
+
queryFn: () => (0, import_core44.retrievePaymentIntent)(clientSecret, publishableKey),
|
|
29388
29370
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
29389
29371
|
staleTime: 0,
|
|
29390
29372
|
refetchInterval: (query) => {
|
|
@@ -29400,7 +29382,7 @@ function usePaymentIntent(params) {
|
|
|
29400
29382
|
}
|
|
29401
29383
|
|
|
29402
29384
|
// src/components/checkout/CheckoutModal.tsx
|
|
29403
|
-
var
|
|
29385
|
+
var import_core45 = require("@unifold/core");
|
|
29404
29386
|
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
29405
29387
|
function mapToCheckoutPaymentIntent(pi) {
|
|
29406
29388
|
return {
|
|
@@ -29503,8 +29485,8 @@ function CheckoutModal({
|
|
|
29503
29485
|
flow_type: "checkout"
|
|
29504
29486
|
});
|
|
29505
29487
|
emitEvent({
|
|
29506
|
-
id: (0,
|
|
29507
|
-
type:
|
|
29488
|
+
id: (0, import_core45.generatePrefixedKSUID)("sevt"),
|
|
29489
|
+
type: import_core45.CheckoutEventType.METHOD_SELECTED,
|
|
29508
29490
|
created: Math.floor(Date.now() / 1e3),
|
|
29509
29491
|
sessionId: getSessionId() ?? "",
|
|
29510
29492
|
method,
|
|
@@ -29522,8 +29504,8 @@ function CheckoutModal({
|
|
|
29522
29504
|
});
|
|
29523
29505
|
onCheckoutError?.(error);
|
|
29524
29506
|
emitEvent({
|
|
29525
|
-
id: (0,
|
|
29526
|
-
type:
|
|
29507
|
+
id: (0, import_core45.generatePrefixedKSUID)("sevt"),
|
|
29508
|
+
type: import_core45.CheckoutEventType.FLOW_FAILED,
|
|
29527
29509
|
created: Math.floor(Date.now() / 1e3),
|
|
29528
29510
|
sessionId: journeySessionIdRef.current ?? getSessionId() ?? "",
|
|
29529
29511
|
method: error.method,
|
|
@@ -29562,8 +29544,8 @@ function CheckoutModal({
|
|
|
29562
29544
|
if (isSucceeded && richIntent) {
|
|
29563
29545
|
const createdSec = data.paymentIntent?.updated_at ? Math.floor(new Date(data.paymentIntent.updated_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3);
|
|
29564
29546
|
emitEvent({
|
|
29565
|
-
id: (0,
|
|
29566
|
-
type:
|
|
29547
|
+
id: (0, import_core45.generatePrefixedKSUID)("sevt"),
|
|
29548
|
+
type: import_core45.CheckoutEventType.PAYMENT_INTENT_SUCCEEDED,
|
|
29567
29549
|
// A poll can land after the journey ends, when getSessionId() is
|
|
29568
29550
|
// either empty or already another flow's. The payment belongs to
|
|
29569
29551
|
// the journey that started it.
|
|
@@ -30221,12 +30203,12 @@ var import_react38 = require("react");
|
|
|
30221
30203
|
var import_lucide_react44 = require("lucide-react");
|
|
30222
30204
|
|
|
30223
30205
|
// src/hooks/use-supported-destination-tokens.ts
|
|
30224
|
-
var
|
|
30225
|
-
var
|
|
30206
|
+
var import_react_query20 = require("@tanstack/react-query");
|
|
30207
|
+
var import_core46 = require("@unifold/core");
|
|
30226
30208
|
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
30227
|
-
return (0,
|
|
30209
|
+
return (0, import_react_query20.useQuery)({
|
|
30228
30210
|
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
30229
|
-
queryFn: () => (0,
|
|
30211
|
+
queryFn: () => (0, import_core46.getSupportedDestinationTokens)(publishableKey),
|
|
30230
30212
|
staleTime: 1e3 * 60 * 5,
|
|
30231
30213
|
gcTime: 1e3 * 60 * 30,
|
|
30232
30214
|
refetchOnMount: false,
|
|
@@ -30256,8 +30238,8 @@ function useDefaultDestinationToken({
|
|
|
30256
30238
|
}
|
|
30257
30239
|
|
|
30258
30240
|
// src/hooks/use-source-token-validation.ts
|
|
30259
|
-
var
|
|
30260
|
-
var
|
|
30241
|
+
var import_react_query21 = require("@tanstack/react-query");
|
|
30242
|
+
var import_core47 = require("@unifold/core");
|
|
30261
30243
|
function useSourceTokenValidation(params) {
|
|
30262
30244
|
const {
|
|
30263
30245
|
sourceChainType,
|
|
@@ -30268,7 +30250,7 @@ function useSourceTokenValidation(params) {
|
|
|
30268
30250
|
enabled = true
|
|
30269
30251
|
} = params;
|
|
30270
30252
|
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
30271
|
-
return (0,
|
|
30253
|
+
return (0, import_react_query21.useQuery)({
|
|
30272
30254
|
queryKey: [
|
|
30273
30255
|
"unifold",
|
|
30274
30256
|
"sourceTokenValidation",
|
|
@@ -30278,7 +30260,7 @@ function useSourceTokenValidation(params) {
|
|
|
30278
30260
|
publishableKey
|
|
30279
30261
|
],
|
|
30280
30262
|
queryFn: async () => {
|
|
30281
|
-
const res = await (0,
|
|
30263
|
+
const res = await (0, import_core47.getSupportedDepositTokens)(publishableKey);
|
|
30282
30264
|
let matchedMinUsd = null;
|
|
30283
30265
|
let matchedProcessingTime = null;
|
|
30284
30266
|
let matchedSlippage = null;
|
|
@@ -30318,12 +30300,12 @@ function useSourceTokenValidation(params) {
|
|
|
30318
30300
|
}
|
|
30319
30301
|
|
|
30320
30302
|
// src/hooks/use-address-balance.ts
|
|
30321
|
-
var
|
|
30322
|
-
var
|
|
30303
|
+
var import_react_query22 = require("@tanstack/react-query");
|
|
30304
|
+
var import_core48 = require("@unifold/core");
|
|
30323
30305
|
function useAddressBalance(params) {
|
|
30324
30306
|
const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
|
|
30325
30307
|
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
30326
|
-
return (0,
|
|
30308
|
+
return (0, import_react_query22.useQuery)({
|
|
30327
30309
|
queryKey: [
|
|
30328
30310
|
"unifold",
|
|
30329
30311
|
"addressBalance",
|
|
@@ -30334,7 +30316,7 @@ function useAddressBalance(params) {
|
|
|
30334
30316
|
publishableKey
|
|
30335
30317
|
],
|
|
30336
30318
|
queryFn: async () => {
|
|
30337
|
-
const res = await (0,
|
|
30319
|
+
const res = await (0, import_core48.getAddressBalance)(
|
|
30338
30320
|
address,
|
|
30339
30321
|
chainType,
|
|
30340
30322
|
chainId,
|
|
@@ -30379,13 +30361,13 @@ function useAddressBalance(params) {
|
|
|
30379
30361
|
}
|
|
30380
30362
|
|
|
30381
30363
|
// src/hooks/use-executions.ts
|
|
30382
|
-
var
|
|
30383
|
-
var
|
|
30364
|
+
var import_react_query23 = require("@tanstack/react-query");
|
|
30365
|
+
var import_core49 = require("@unifold/core");
|
|
30384
30366
|
function useExecutions(userId, publishableKey, options) {
|
|
30385
|
-
const actionType = options?.actionType ??
|
|
30386
|
-
const query = (0,
|
|
30367
|
+
const actionType = options?.actionType ?? import_core49.ActionType.Deposit;
|
|
30368
|
+
const query = (0, import_react_query23.useQuery)({
|
|
30387
30369
|
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
30388
|
-
queryFn: () => (0,
|
|
30370
|
+
queryFn: () => (0, import_core49.queryExecutions)(userId, publishableKey, actionType),
|
|
30389
30371
|
enabled: (options?.enabled ?? true) && !!userId,
|
|
30390
30372
|
refetchInterval: options?.refetchInterval ?? 3e3,
|
|
30391
30373
|
staleTime: 0,
|
|
@@ -30398,7 +30380,7 @@ function useExecutions(userId, publishableKey, options) {
|
|
|
30398
30380
|
|
|
30399
30381
|
// src/hooks/use-withdraw-polling.ts
|
|
30400
30382
|
var import_react34 = require("react");
|
|
30401
|
-
var
|
|
30383
|
+
var import_core50 = require("@unifold/core");
|
|
30402
30384
|
var POLL_INTERVAL_MS4 = 2500;
|
|
30403
30385
|
var POLL_ENDPOINT_INTERVAL_MS2 = 5e3;
|
|
30404
30386
|
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
@@ -30421,15 +30403,15 @@ function useWithdrawPolling({
|
|
|
30421
30403
|
const journeySessionId = () => sessionIdRef.current || (getSessionId() ?? "");
|
|
30422
30404
|
const executionCreatedSec = (execution) => execution.updated_at ? Math.floor(new Date(execution.updated_at).getTime() / 1e3) : execution.created_at ? Math.floor(new Date(execution.created_at).getTime() / 1e3) : Math.floor(Date.now() / 1e3);
|
|
30423
30405
|
const createExecutionSuccessEvent = (execution) => ({
|
|
30424
|
-
id: (0,
|
|
30425
|
-
type:
|
|
30406
|
+
id: (0, import_core50.generatePrefixedKSUID)("sevt"),
|
|
30407
|
+
type: import_core50.WithdrawEventType.DIRECT_EXECUTION_SUCCEEDED,
|
|
30426
30408
|
created: executionCreatedSec(execution),
|
|
30427
30409
|
sessionId: journeySessionId(),
|
|
30428
30410
|
data: { object: mapToDirectExecution(execution) }
|
|
30429
30411
|
});
|
|
30430
30412
|
const createExecutionFailedEvent = (execution) => ({
|
|
30431
|
-
id: (0,
|
|
30432
|
-
type:
|
|
30413
|
+
id: (0, import_core50.generatePrefixedKSUID)("sevt"),
|
|
30414
|
+
type: import_core50.WithdrawEventType.DIRECT_EXECUTION_FAILED,
|
|
30433
30415
|
created: executionCreatedSec(execution),
|
|
30434
30416
|
sessionId: journeySessionId(),
|
|
30435
30417
|
data: { object: mapToDirectExecution(execution) }
|
|
@@ -30481,7 +30463,7 @@ function useWithdrawPolling({
|
|
|
30481
30463
|
const enabledAt = enabledAtRef.current;
|
|
30482
30464
|
const poll = async () => {
|
|
30483
30465
|
try {
|
|
30484
|
-
const response = await (0,
|
|
30466
|
+
const response = await (0, import_core50.queryExecutions)(userId, publishableKey, import_core50.ActionType.Withdraw);
|
|
30485
30467
|
const cutoff = new Date(enabledAt.getTime() - CUTOFF_BUFFER_MS2);
|
|
30486
30468
|
const sorted = [...response.data].sort((a, b) => {
|
|
30487
30469
|
const tA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
@@ -30489,11 +30471,11 @@ function useWithdrawPolling({
|
|
|
30489
30471
|
return tB - tA;
|
|
30490
30472
|
});
|
|
30491
30473
|
const inProgress = [
|
|
30492
|
-
|
|
30493
|
-
|
|
30494
|
-
|
|
30474
|
+
import_core50.ExecutionStatus.PENDING,
|
|
30475
|
+
import_core50.ExecutionStatus.WAITING,
|
|
30476
|
+
import_core50.ExecutionStatus.DELAYED
|
|
30495
30477
|
];
|
|
30496
|
-
const terminal = [
|
|
30478
|
+
const terminal = [import_core50.ExecutionStatus.SUCCEEDED, import_core50.ExecutionStatus.FAILED];
|
|
30497
30479
|
let target = null;
|
|
30498
30480
|
for (const ex of sorted) {
|
|
30499
30481
|
const t = ex.created_at ? new Date(ex.created_at) : null;
|
|
@@ -30523,7 +30505,7 @@ function useWithdrawPolling({
|
|
|
30523
30505
|
}
|
|
30524
30506
|
return [...list, ex];
|
|
30525
30507
|
});
|
|
30526
|
-
if (ex.status ===
|
|
30508
|
+
if (ex.status === import_core50.ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
|
|
30527
30509
|
onSuccessRef.current?.({
|
|
30528
30510
|
message: "Withdrawal completed successfully",
|
|
30529
30511
|
executionId: ex.id,
|
|
@@ -30531,7 +30513,7 @@ function useWithdrawPolling({
|
|
|
30531
30513
|
transaction: ex,
|
|
30532
30514
|
execution: createExecutionSuccessEvent(ex)
|
|
30533
30515
|
});
|
|
30534
|
-
} else if (ex.status ===
|
|
30516
|
+
} else if (ex.status === import_core50.ExecutionStatus.FAILED && prev !== import_core50.ExecutionStatus.FAILED) {
|
|
30535
30517
|
onErrorRef.current?.({
|
|
30536
30518
|
message: "Withdrawal failed",
|
|
30537
30519
|
code: "WITHDRAW_FAILED",
|
|
@@ -30561,7 +30543,7 @@ function useWithdrawPolling({
|
|
|
30561
30543
|
if (!enabled || !depositWalletId) return;
|
|
30562
30544
|
const trigger = async () => {
|
|
30563
30545
|
try {
|
|
30564
|
-
await (0,
|
|
30546
|
+
await (0, import_core50.pollDirectExecutions)({ deposit_wallet_id: depositWalletId }, publishableKey);
|
|
30565
30547
|
} catch {
|
|
30566
30548
|
}
|
|
30567
30549
|
};
|
|
@@ -30730,11 +30712,11 @@ function WithdrawDoubleInput({
|
|
|
30730
30712
|
// src/components/withdrawals/WithdrawForm.tsx
|
|
30731
30713
|
var import_react36 = require("react");
|
|
30732
30714
|
var import_lucide_react42 = require("lucide-react");
|
|
30733
|
-
var
|
|
30715
|
+
var import_core55 = require("@unifold/core");
|
|
30734
30716
|
|
|
30735
30717
|
// src/hooks/use-verify-recipient-address.ts
|
|
30736
|
-
var
|
|
30737
|
-
var
|
|
30718
|
+
var import_react_query24 = require("@tanstack/react-query");
|
|
30719
|
+
var import_core51 = require("@unifold/core");
|
|
30738
30720
|
function useVerifyRecipientAddress(params) {
|
|
30739
30721
|
const {
|
|
30740
30722
|
chainType,
|
|
@@ -30746,7 +30728,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
30746
30728
|
} = params;
|
|
30747
30729
|
const trimmedAddress = recipientAddress?.trim() || "";
|
|
30748
30730
|
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
30749
|
-
return (0,
|
|
30731
|
+
return (0, import_react_query24.useQuery)({
|
|
30750
30732
|
queryKey: [
|
|
30751
30733
|
"unifold",
|
|
30752
30734
|
"verifyRecipientAddress",
|
|
@@ -30756,7 +30738,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
30756
30738
|
trimmedAddress,
|
|
30757
30739
|
publishableKey
|
|
30758
30740
|
],
|
|
30759
|
-
queryFn: () => (0,
|
|
30741
|
+
queryFn: () => (0, import_core51.verifyRecipientAddress)(
|
|
30760
30742
|
{
|
|
30761
30743
|
chain_type: chainType,
|
|
30762
30744
|
chain_id: chainId,
|
|
@@ -30775,7 +30757,7 @@ function useVerifyRecipientAddress(params) {
|
|
|
30775
30757
|
}
|
|
30776
30758
|
|
|
30777
30759
|
// src/components/withdrawals/send-withdraw.ts
|
|
30778
|
-
var
|
|
30760
|
+
var import_core52 = require("@unifold/core");
|
|
30779
30761
|
async function sendEvmWithdraw(params) {
|
|
30780
30762
|
const {
|
|
30781
30763
|
provider,
|
|
@@ -30864,7 +30846,7 @@ async function sendSolanaWithdraw(params) {
|
|
|
30864
30846
|
if (!provider.publicKey) {
|
|
30865
30847
|
await provider.connect();
|
|
30866
30848
|
}
|
|
30867
|
-
const buildResponse = await (0,
|
|
30849
|
+
const buildResponse = await (0, import_core52.buildSolanaTransaction)(
|
|
30868
30850
|
{
|
|
30869
30851
|
chain_id: "mainnet",
|
|
30870
30852
|
token_address: sourceTokenAddress === "" ? "native" : sourceTokenAddress,
|
|
@@ -30890,7 +30872,7 @@ async function sendSolanaWithdraw(params) {
|
|
|
30890
30872
|
for (let i = 0; i < serialized.length; i++) {
|
|
30891
30873
|
binaryStr += String.fromCharCode(serialized[i]);
|
|
30892
30874
|
}
|
|
30893
|
-
const sendResponse = await (0,
|
|
30875
|
+
const sendResponse = await (0, import_core52.sendSolanaTransaction)(
|
|
30894
30876
|
{ chain_id: "mainnet", signed_transaction: btoa(binaryStr) },
|
|
30895
30877
|
publishableKey
|
|
30896
30878
|
);
|
|
@@ -30992,11 +30974,11 @@ async function detectBrowserWallet(chainType, senderAddress) {
|
|
|
30992
30974
|
|
|
30993
30975
|
// src/hooks/use-hypercore-withdraw-activation.ts
|
|
30994
30976
|
var import_react35 = require("react");
|
|
30995
|
-
var
|
|
30977
|
+
var import_core54 = require("@unifold/core");
|
|
30996
30978
|
|
|
30997
30979
|
// src/hooks/use-get-deposit-address.ts
|
|
30998
|
-
var
|
|
30999
|
-
var
|
|
30980
|
+
var import_react_query25 = require("@tanstack/react-query");
|
|
30981
|
+
var import_core53 = require("@unifold/core");
|
|
31000
30982
|
function useGetDepositAddress(params) {
|
|
31001
30983
|
const {
|
|
31002
30984
|
userId,
|
|
@@ -31009,7 +30991,7 @@ function useGetDepositAddress(params) {
|
|
|
31009
30991
|
enabled = true
|
|
31010
30992
|
} = params;
|
|
31011
30993
|
const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
|
|
31012
|
-
const query = (0,
|
|
30994
|
+
const query = (0, import_react_query25.useQuery)({
|
|
31013
30995
|
queryKey: [
|
|
31014
30996
|
"unifold",
|
|
31015
30997
|
"getDepositAddress",
|
|
@@ -31021,7 +31003,7 @@ function useGetDepositAddress(params) {
|
|
|
31021
31003
|
actionType ?? null,
|
|
31022
31004
|
publishableKey
|
|
31023
31005
|
],
|
|
31024
|
-
queryFn: () => (0,
|
|
31006
|
+
queryFn: () => (0, import_core53.getDepositAddress)(
|
|
31025
31007
|
{
|
|
31026
31008
|
external_user_id: userId,
|
|
31027
31009
|
recipient_address: recipientAddress,
|
|
@@ -31077,7 +31059,7 @@ function useHypercoreWithdrawActivation(params) {
|
|
|
31077
31059
|
destinationChainType,
|
|
31078
31060
|
destinationChainId,
|
|
31079
31061
|
destinationTokenAddress,
|
|
31080
|
-
actionType:
|
|
31062
|
+
actionType: import_core54.ActionType.Withdraw,
|
|
31081
31063
|
enabled: enabled && isHypercore(sourceChainId)
|
|
31082
31064
|
});
|
|
31083
31065
|
const depositWalletAddress = (0, import_react35.useMemo)(() => {
|
|
@@ -31380,7 +31362,7 @@ function WithdrawForm({
|
|
|
31380
31362
|
let humanAmount = isMaxed ? balanceData.balanceHuman : toSafeDecimalString(cryptoAmountFromInput, sourceDecimals);
|
|
31381
31363
|
if (isHypercoreChain(sourceChainId)) {
|
|
31382
31364
|
try {
|
|
31383
|
-
const check = await (0,
|
|
31365
|
+
const check = await (0, import_core55.checkHypercoreActivation)(
|
|
31384
31366
|
{
|
|
31385
31367
|
source_address: senderAddress,
|
|
31386
31368
|
recipient_address: depositWallet.address
|
|
@@ -31836,12 +31818,12 @@ function WithdrawForm({
|
|
|
31836
31818
|
|
|
31837
31819
|
// src/components/withdrawals/WithdrawExecutionItem.tsx
|
|
31838
31820
|
var import_lucide_react43 = require("lucide-react");
|
|
31839
|
-
var
|
|
31821
|
+
var import_core56 = require("@unifold/core");
|
|
31840
31822
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
31841
31823
|
function WithdrawExecutionItem({ execution, onClick }) {
|
|
31842
31824
|
const { colors: colors2, fonts, components } = useTheme();
|
|
31843
31825
|
const { t: strings, locale } = useI18n();
|
|
31844
|
-
const isPending = execution.status ===
|
|
31826
|
+
const isPending = execution.status === import_core56.ExecutionStatus.PENDING || execution.status === import_core56.ExecutionStatus.WAITING || execution.status === import_core56.ExecutionStatus.DELAYED;
|
|
31845
31827
|
const formatDateTime = (timestamp) => {
|
|
31846
31828
|
try {
|
|
31847
31829
|
const date = new Date(timestamp);
|
|
@@ -31888,7 +31870,7 @@ function WithdrawExecutionItem({ execution, onClick }) {
|
|
|
31888
31870
|
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
31889
31871
|
"img",
|
|
31890
31872
|
{
|
|
31891
|
-
src: execution.destination_token_metadata?.icon_url || (0,
|
|
31873
|
+
src: execution.destination_token_metadata?.icon_url || (0, import_core56.getIconUrl)("/icons/tokens/svg/usdc.svg"),
|
|
31892
31874
|
alt: "Token",
|
|
31893
31875
|
width: 36,
|
|
31894
31876
|
height: 36,
|
|
@@ -32126,7 +32108,7 @@ function WithdrawConfirmingView({
|
|
|
32126
32108
|
}
|
|
32127
32109
|
|
|
32128
32110
|
// src/components/withdrawals/WithdrawModal.tsx
|
|
32129
|
-
var
|
|
32111
|
+
var import_core57 = require("@unifold/core");
|
|
32130
32112
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
32131
32113
|
var getChainKey5 = (chainId, chainType) => `${chainType}:${chainId}`;
|
|
32132
32114
|
function WithdrawModal({
|
|
@@ -32167,10 +32149,10 @@ function WithdrawModal({
|
|
|
32167
32149
|
const selection = selectionPayload(event);
|
|
32168
32150
|
if (selection?.kind !== "token") return;
|
|
32169
32151
|
onEventRef.current?.({
|
|
32170
|
-
id: (0,
|
|
32152
|
+
id: (0, import_core57.generatePrefixedKSUID)("sevt"),
|
|
32171
32153
|
created: Math.floor(Date.now() / 1e3),
|
|
32172
32154
|
sessionId: getSessionId() ?? "",
|
|
32173
|
-
type:
|
|
32155
|
+
type: import_core57.WithdrawEventType.TOKEN_SELECTED,
|
|
32174
32156
|
data: { object: selection.data }
|
|
32175
32157
|
});
|
|
32176
32158
|
}),
|
|
@@ -32294,21 +32276,21 @@ function WithdrawModal({
|
|
|
32294
32276
|
onWithdrawError: onWithdrawErrorFor
|
|
32295
32277
|
});
|
|
32296
32278
|
const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
|
|
32297
|
-
actionType:
|
|
32279
|
+
actionType: import_core57.ActionType.Withdraw,
|
|
32298
32280
|
enabled: open,
|
|
32299
32281
|
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
32300
32282
|
});
|
|
32301
32283
|
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
32302
32284
|
const handleDepositWalletCreation = (0, import_react38.useCallback)(
|
|
32303
32285
|
async (params) => {
|
|
32304
|
-
const response = await (0,
|
|
32286
|
+
const response = await (0, import_core57.createDepositAddress)(
|
|
32305
32287
|
{
|
|
32306
32288
|
external_user_id: externalUserId,
|
|
32307
32289
|
destination_chain_type: params.destinationChainType,
|
|
32308
32290
|
destination_chain_id: params.destinationChainId,
|
|
32309
32291
|
destination_token_address: params.destinationTokenAddress,
|
|
32310
32292
|
recipient_address: params.recipientAddress,
|
|
32311
|
-
action_type:
|
|
32293
|
+
action_type: import_core57.ActionType.Withdraw,
|
|
32312
32294
|
source_chain_type: sourceChainType
|
|
32313
32295
|
},
|
|
32314
32296
|
publishableKey
|
|
@@ -32316,7 +32298,7 @@ function WithdrawModal({
|
|
|
32316
32298
|
if (response.user_id) {
|
|
32317
32299
|
setUserId(response.user_id);
|
|
32318
32300
|
}
|
|
32319
|
-
const depositWallet = (0,
|
|
32301
|
+
const depositWallet = (0, import_core57.getWalletByChainType)(response.data, sourceChainType);
|
|
32320
32302
|
if (!depositWallet) {
|
|
32321
32303
|
throw new Error(`No deposit wallet available for ${sourceChainType}`);
|
|
32322
32304
|
}
|
|
@@ -32348,8 +32330,8 @@ function WithdrawModal({
|
|
|
32348
32330
|
deposit_wallet_id: withdrawDepositWalletIdRef.current
|
|
32349
32331
|
});
|
|
32350
32332
|
emitEvent({
|
|
32351
|
-
id: (0,
|
|
32352
|
-
type:
|
|
32333
|
+
id: (0, import_core57.generatePrefixedKSUID)("sevt"),
|
|
32334
|
+
type: import_core57.WithdrawEventType.FLOW_STARTED,
|
|
32353
32335
|
created: Math.floor(Date.now() / 1e3),
|
|
32354
32336
|
sessionId: getSessionId() ?? "",
|
|
32355
32337
|
data: {
|