@unifold/connect-react 0.1.49 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -23
- package/dist/index.mjs +45 -23
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
|
|
4
|
-
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, WithdrawTransactionInfo } from '@unifold/ui-react';
|
|
4
|
+
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
|
|
5
5
|
import { DepositEvent } from '@unifold/core';
|
|
6
|
-
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
6
|
+
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
7
7
|
|
|
8
8
|
interface UnifoldConnectProviderConfig {
|
|
9
9
|
publishableKey: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
|
|
4
|
-
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, WithdrawTransactionInfo } from '@unifold/ui-react';
|
|
4
|
+
export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, UseSupportedDepositTokensOptions, WithdrawTransactionInfo, useSupportedDepositTokens } from '@unifold/ui-react';
|
|
5
5
|
import { DepositEvent } from '@unifold/core';
|
|
6
|
-
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
6
|
+
export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DepositEvent, DepositEventType, DepositQuote, DepositQuoteRequest, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, LockedQuoteLimits, LockedQuotePreview, LockedQuotePreviewRequest, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionCreatedData, OnrampSessionCreatedEvent, OnrampSessionRequest, OnrampSessionResponse, PaymentIntent, PaymentIntentDepositAddress, PaymentIntentStatus, PaymentIntentType, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SourceToken, SourceTokenNetwork, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedSourceTokensQuery, SupportedSourceTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, generatePrefixedKSUID, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, retrievePaymentIntent, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
|
|
7
7
|
|
|
8
8
|
interface UnifoldConnectProviderConfig {
|
|
9
9
|
publishableKey: string;
|
package/dist/index.js
CHANGED
|
@@ -1165,6 +1165,7 @@ __export(index_exports, {
|
|
|
1165
1165
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
1166
1166
|
getChainName: () => getChainName,
|
|
1167
1167
|
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
1168
|
+
getDepositQuote: () => getDepositQuote,
|
|
1168
1169
|
getFiatCurrencies: () => getFiatCurrencies,
|
|
1169
1170
|
getIconUrl: () => getIconUrl,
|
|
1170
1171
|
getIconUrlWithCdn: () => getIconUrlWithCdn,
|
|
@@ -1178,9 +1179,11 @@ __export(index_exports, {
|
|
|
1178
1179
|
getWalletByChainType: () => getWalletByChainType,
|
|
1179
1180
|
i18n: () => i18n,
|
|
1180
1181
|
queryExecutions: () => queryExecutions,
|
|
1182
|
+
retrievePaymentIntent: () => retrievePaymentIntent,
|
|
1181
1183
|
sendSolanaTransaction: () => sendSolanaTransaction,
|
|
1182
1184
|
setApiConfig: () => setApiConfig,
|
|
1183
1185
|
useAllowedCountry: () => useAllowedCountry2,
|
|
1186
|
+
useSupportedDepositTokens: () => useSupportedDepositTokens,
|
|
1184
1187
|
useUnifold: () => useUnifold2,
|
|
1185
1188
|
useUserIp: () => useUserIp
|
|
1186
1189
|
});
|
|
@@ -6397,6 +6400,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
6397
6400
|
if (request.external_id) {
|
|
6398
6401
|
params.append("external_id", request.external_id);
|
|
6399
6402
|
}
|
|
6403
|
+
if (request.email) {
|
|
6404
|
+
params.append("email", request.email);
|
|
6405
|
+
}
|
|
6400
6406
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
6401
6407
|
}
|
|
6402
6408
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -13663,31 +13669,29 @@ function BuyWithCard({
|
|
|
13663
13669
|
);
|
|
13664
13670
|
if (manualProviderStillExists) {
|
|
13665
13671
|
setSelectedProvider(manualProviderStillExists);
|
|
13666
|
-
const
|
|
13667
|
-
(best, current) => current.destination_amount > best.destination_amount ? current : best
|
|
13668
|
-
);
|
|
13672
|
+
const firstProvider = response.data[0];
|
|
13669
13673
|
if (!autoSelectedProvider) {
|
|
13670
|
-
setAutoSelectedProvider(
|
|
13674
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13671
13675
|
}
|
|
13672
13676
|
setIsAutoSelected(
|
|
13673
13677
|
manualProviderStillExists.service_provider === autoSelectedProvider
|
|
13674
13678
|
);
|
|
13675
|
-
} else {
|
|
13676
|
-
const
|
|
13677
|
-
|
|
13678
|
-
);
|
|
13679
|
-
setSelectedProvider(bestProvider);
|
|
13680
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13679
|
+
} else if (response.data.length > 0) {
|
|
13680
|
+
const firstProvider = response.data[0];
|
|
13681
|
+
setSelectedProvider(firstProvider);
|
|
13682
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13681
13683
|
setIsAutoSelected(true);
|
|
13682
13684
|
setHasManualSelection(false);
|
|
13685
|
+
} else {
|
|
13686
|
+
setSelectedProvider(null);
|
|
13687
|
+
setIsAutoSelected(false);
|
|
13688
|
+
setHasManualSelection(false);
|
|
13683
13689
|
}
|
|
13684
13690
|
} else {
|
|
13685
13691
|
if (response.data.length > 0) {
|
|
13686
|
-
const
|
|
13687
|
-
|
|
13688
|
-
);
|
|
13689
|
-
setSelectedProvider(bestProvider);
|
|
13690
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13692
|
+
const firstProvider = response.data[0];
|
|
13693
|
+
setSelectedProvider(firstProvider);
|
|
13694
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13691
13695
|
setIsAutoSelected(true);
|
|
13692
13696
|
}
|
|
13693
13697
|
}
|
|
@@ -13783,9 +13787,7 @@ function BuyWithCard({
|
|
|
13783
13787
|
window.open(sessionStartUrl, "_blank");
|
|
13784
13788
|
handleViewChange("onramp");
|
|
13785
13789
|
};
|
|
13786
|
-
const sortedQuotes =
|
|
13787
|
-
(a, b) => b.destination_amount - a.destination_amount
|
|
13788
|
-
);
|
|
13790
|
+
const sortedQuotes = quotes;
|
|
13789
13791
|
const currencySymbol = getCurrencySymbol(currency);
|
|
13790
13792
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
13791
13793
|
"div",
|
|
@@ -17777,14 +17779,23 @@ function useAllowedCountry(publishableKey) {
|
|
|
17777
17779
|
let isAllowed = null;
|
|
17778
17780
|
if (ipData && configData) {
|
|
17779
17781
|
const blockedCodes = configData.blocked_country_codes || [];
|
|
17782
|
+
const blockedSubdivisions = configData.blocked_country_subdivisions || [];
|
|
17780
17783
|
const userCountryUpper = ipData.alpha2.toUpperCase();
|
|
17781
|
-
|
|
17784
|
+
const userSubdivision = ipData.subdivision_code || ipData.state || "";
|
|
17785
|
+
const userSubdivisionUpper = userSubdivision.toUpperCase();
|
|
17786
|
+
const isCountryBlocked = blockedCodes.some(
|
|
17782
17787
|
(code) => code.toUpperCase() === userCountryUpper
|
|
17783
17788
|
);
|
|
17789
|
+
const isSubdivisionBlocked = blockedSubdivisions.some((entry) => {
|
|
17790
|
+
if (entry.country_code.toUpperCase() !== userCountryUpper) return false;
|
|
17791
|
+
return entry.subdivision_codes.some(
|
|
17792
|
+
(code) => code.toUpperCase() === userSubdivisionUpper
|
|
17793
|
+
);
|
|
17794
|
+
});
|
|
17795
|
+
isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
|
|
17784
17796
|
}
|
|
17785
17797
|
return {
|
|
17786
17798
|
isAllowed,
|
|
17787
|
-
// Return lowercase for consistency with useUserIp hook
|
|
17788
17799
|
alpha2: ipData?.alpha2?.toLowerCase() ?? null,
|
|
17789
17800
|
country: ipData?.country ?? null,
|
|
17790
17801
|
isLoading,
|
|
@@ -23105,19 +23116,30 @@ function DepositModal({
|
|
|
23105
23116
|
}
|
|
23106
23117
|
) });
|
|
23107
23118
|
}
|
|
23119
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
23120
|
+
"succeeded",
|
|
23121
|
+
"expired",
|
|
23122
|
+
"refunded",
|
|
23123
|
+
"canceled"
|
|
23124
|
+
]);
|
|
23108
23125
|
function usePaymentIntent(params) {
|
|
23109
23126
|
const {
|
|
23110
23127
|
clientSecret,
|
|
23111
23128
|
publishableKey,
|
|
23112
23129
|
enabled = true,
|
|
23113
|
-
pollingInterval =
|
|
23130
|
+
pollingInterval = 3e3
|
|
23114
23131
|
} = params;
|
|
23115
23132
|
return (0, import_react_query11.useQuery)({
|
|
23116
23133
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
23117
23134
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
23118
23135
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
23119
23136
|
staleTime: 0,
|
|
23120
|
-
refetchInterval:
|
|
23137
|
+
refetchInterval: (query) => {
|
|
23138
|
+
if (!pollingInterval) return false;
|
|
23139
|
+
const status = query.state.data?.status;
|
|
23140
|
+
if (status && TERMINAL_STATUSES.has(status)) return false;
|
|
23141
|
+
return pollingInterval;
|
|
23142
|
+
},
|
|
23121
23143
|
refetchOnWindowFocus: true,
|
|
23122
23144
|
retry: 3,
|
|
23123
23145
|
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
@@ -23241,7 +23263,7 @@ function CheckoutModal({
|
|
|
23241
23263
|
clientSecret,
|
|
23242
23264
|
publishableKey,
|
|
23243
23265
|
enabled: open && !!clientSecret,
|
|
23244
|
-
pollingInterval:
|
|
23266
|
+
pollingInterval: 3e3
|
|
23245
23267
|
});
|
|
23246
23268
|
const { projectConfig } = useProjectConfig({
|
|
23247
23269
|
publishableKey,
|
|
@@ -25695,6 +25717,7 @@ function useAllowedCountry2() {
|
|
|
25695
25717
|
getApiBaseUrl,
|
|
25696
25718
|
getChainName,
|
|
25697
25719
|
getDefaultOnrampToken,
|
|
25720
|
+
getDepositQuote,
|
|
25698
25721
|
getFiatCurrencies,
|
|
25699
25722
|
getIconUrl,
|
|
25700
25723
|
getIconUrlWithCdn,
|
|
@@ -25708,9 +25731,11 @@ function useAllowedCountry2() {
|
|
|
25708
25731
|
getWalletByChainType,
|
|
25709
25732
|
i18n,
|
|
25710
25733
|
queryExecutions,
|
|
25734
|
+
retrievePaymentIntent,
|
|
25711
25735
|
sendSolanaTransaction,
|
|
25712
25736
|
setApiConfig,
|
|
25713
25737
|
useAllowedCountry,
|
|
25738
|
+
useSupportedDepositTokens,
|
|
25714
25739
|
useUnifold,
|
|
25715
25740
|
useUserIp
|
|
25716
25741
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -6373,6 +6373,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
6373
6373
|
if (request.external_id) {
|
|
6374
6374
|
params.append("external_id", request.external_id);
|
|
6375
6375
|
}
|
|
6376
|
+
if (request.email) {
|
|
6377
|
+
params.append("email", request.email);
|
|
6378
|
+
}
|
|
6376
6379
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
6377
6380
|
}
|
|
6378
6381
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -13652,31 +13655,29 @@ function BuyWithCard({
|
|
|
13652
13655
|
);
|
|
13653
13656
|
if (manualProviderStillExists) {
|
|
13654
13657
|
setSelectedProvider(manualProviderStillExists);
|
|
13655
|
-
const
|
|
13656
|
-
(best, current) => current.destination_amount > best.destination_amount ? current : best
|
|
13657
|
-
);
|
|
13658
|
+
const firstProvider = response.data[0];
|
|
13658
13659
|
if (!autoSelectedProvider) {
|
|
13659
|
-
setAutoSelectedProvider(
|
|
13660
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13660
13661
|
}
|
|
13661
13662
|
setIsAutoSelected(
|
|
13662
13663
|
manualProviderStillExists.service_provider === autoSelectedProvider
|
|
13663
13664
|
);
|
|
13664
|
-
} else {
|
|
13665
|
-
const
|
|
13666
|
-
|
|
13667
|
-
);
|
|
13668
|
-
setSelectedProvider(bestProvider);
|
|
13669
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13665
|
+
} else if (response.data.length > 0) {
|
|
13666
|
+
const firstProvider = response.data[0];
|
|
13667
|
+
setSelectedProvider(firstProvider);
|
|
13668
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13670
13669
|
setIsAutoSelected(true);
|
|
13671
13670
|
setHasManualSelection(false);
|
|
13671
|
+
} else {
|
|
13672
|
+
setSelectedProvider(null);
|
|
13673
|
+
setIsAutoSelected(false);
|
|
13674
|
+
setHasManualSelection(false);
|
|
13672
13675
|
}
|
|
13673
13676
|
} else {
|
|
13674
13677
|
if (response.data.length > 0) {
|
|
13675
|
-
const
|
|
13676
|
-
|
|
13677
|
-
);
|
|
13678
|
-
setSelectedProvider(bestProvider);
|
|
13679
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13678
|
+
const firstProvider = response.data[0];
|
|
13679
|
+
setSelectedProvider(firstProvider);
|
|
13680
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13680
13681
|
setIsAutoSelected(true);
|
|
13681
13682
|
}
|
|
13682
13683
|
}
|
|
@@ -13772,9 +13773,7 @@ function BuyWithCard({
|
|
|
13772
13773
|
window.open(sessionStartUrl, "_blank");
|
|
13773
13774
|
handleViewChange("onramp");
|
|
13774
13775
|
};
|
|
13775
|
-
const sortedQuotes =
|
|
13776
|
-
(a, b) => b.destination_amount - a.destination_amount
|
|
13777
|
-
);
|
|
13776
|
+
const sortedQuotes = quotes;
|
|
13778
13777
|
const currencySymbol = getCurrencySymbol(currency);
|
|
13779
13778
|
return /* @__PURE__ */ jsxs8(
|
|
13780
13779
|
"div",
|
|
@@ -17766,14 +17765,23 @@ function useAllowedCountry(publishableKey) {
|
|
|
17766
17765
|
let isAllowed = null;
|
|
17767
17766
|
if (ipData && configData) {
|
|
17768
17767
|
const blockedCodes = configData.blocked_country_codes || [];
|
|
17768
|
+
const blockedSubdivisions = configData.blocked_country_subdivisions || [];
|
|
17769
17769
|
const userCountryUpper = ipData.alpha2.toUpperCase();
|
|
17770
|
-
|
|
17770
|
+
const userSubdivision = ipData.subdivision_code || ipData.state || "";
|
|
17771
|
+
const userSubdivisionUpper = userSubdivision.toUpperCase();
|
|
17772
|
+
const isCountryBlocked = blockedCodes.some(
|
|
17771
17773
|
(code) => code.toUpperCase() === userCountryUpper
|
|
17772
17774
|
);
|
|
17775
|
+
const isSubdivisionBlocked = blockedSubdivisions.some((entry) => {
|
|
17776
|
+
if (entry.country_code.toUpperCase() !== userCountryUpper) return false;
|
|
17777
|
+
return entry.subdivision_codes.some(
|
|
17778
|
+
(code) => code.toUpperCase() === userSubdivisionUpper
|
|
17779
|
+
);
|
|
17780
|
+
});
|
|
17781
|
+
isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
|
|
17773
17782
|
}
|
|
17774
17783
|
return {
|
|
17775
17784
|
isAllowed,
|
|
17776
|
-
// Return lowercase for consistency with useUserIp hook
|
|
17777
17785
|
alpha2: ipData?.alpha2?.toLowerCase() ?? null,
|
|
17778
17786
|
country: ipData?.country ?? null,
|
|
17779
17787
|
isLoading,
|
|
@@ -23094,19 +23102,30 @@ function DepositModal({
|
|
|
23094
23102
|
}
|
|
23095
23103
|
) });
|
|
23096
23104
|
}
|
|
23105
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
23106
|
+
"succeeded",
|
|
23107
|
+
"expired",
|
|
23108
|
+
"refunded",
|
|
23109
|
+
"canceled"
|
|
23110
|
+
]);
|
|
23097
23111
|
function usePaymentIntent(params) {
|
|
23098
23112
|
const {
|
|
23099
23113
|
clientSecret,
|
|
23100
23114
|
publishableKey,
|
|
23101
23115
|
enabled = true,
|
|
23102
|
-
pollingInterval =
|
|
23116
|
+
pollingInterval = 3e3
|
|
23103
23117
|
} = params;
|
|
23104
23118
|
return useQuery9({
|
|
23105
23119
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
23106
23120
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
23107
23121
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
23108
23122
|
staleTime: 0,
|
|
23109
|
-
refetchInterval:
|
|
23123
|
+
refetchInterval: (query) => {
|
|
23124
|
+
if (!pollingInterval) return false;
|
|
23125
|
+
const status = query.state.data?.status;
|
|
23126
|
+
if (status && TERMINAL_STATUSES.has(status)) return false;
|
|
23127
|
+
return pollingInterval;
|
|
23128
|
+
},
|
|
23110
23129
|
refetchOnWindowFocus: true,
|
|
23111
23130
|
retry: 3,
|
|
23112
23131
|
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
@@ -23230,7 +23249,7 @@ function CheckoutModal({
|
|
|
23230
23249
|
clientSecret,
|
|
23231
23250
|
publishableKey,
|
|
23232
23251
|
enabled: open && !!clientSecret,
|
|
23233
|
-
pollingInterval:
|
|
23252
|
+
pollingInterval: 3e3
|
|
23234
23253
|
});
|
|
23235
23254
|
const { projectConfig } = useProjectConfig({
|
|
23236
23255
|
publishableKey,
|
|
@@ -25683,6 +25702,7 @@ export {
|
|
|
25683
25702
|
getApiBaseUrl,
|
|
25684
25703
|
getChainName,
|
|
25685
25704
|
getDefaultOnrampToken,
|
|
25705
|
+
getDepositQuote,
|
|
25686
25706
|
getFiatCurrencies,
|
|
25687
25707
|
getIconUrl,
|
|
25688
25708
|
getIconUrlWithCdn,
|
|
@@ -25696,9 +25716,11 @@ export {
|
|
|
25696
25716
|
getWalletByChainType,
|
|
25697
25717
|
i18n,
|
|
25698
25718
|
queryExecutions,
|
|
25719
|
+
retrievePaymentIntent,
|
|
25699
25720
|
sendSolanaTransaction,
|
|
25700
25721
|
setApiConfig,
|
|
25701
25722
|
useAllowedCountry2 as useAllowedCountry,
|
|
25723
|
+
useSupportedDepositTokens,
|
|
25702
25724
|
useUnifold2 as useUnifold,
|
|
25703
25725
|
useUserIp
|
|
25704
25726
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "Unifold Connect React - Complete React SDK with UI components for crypto deposits",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@tanstack/react-query": "^5.90.11",
|
|
29
|
-
"@unifold/core": "0.1.
|
|
30
|
-
"@unifold/
|
|
31
|
-
"@unifold/react
|
|
29
|
+
"@unifold/core": "0.1.50",
|
|
30
|
+
"@unifold/react-provider": "0.1.50",
|
|
31
|
+
"@unifold/ui-react": "0.1.50"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "^19.0.0",
|