@unifold/connect-react 0.1.49 → 0.1.51
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 +59 -28
- package/dist/index.mjs +56 -28
- 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) {
|
|
@@ -6761,11 +6767,13 @@ function useUserIp() {
|
|
|
6761
6767
|
queryKey: ["unifold", "userIpInfo"],
|
|
6762
6768
|
queryFn: async () => {
|
|
6763
6769
|
const data = await getIpAddress();
|
|
6770
|
+
const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
|
|
6764
6771
|
return {
|
|
6765
6772
|
alpha2: data.alpha2.toLowerCase(),
|
|
6766
6773
|
alpha3: data.alpha3?.toLowerCase(),
|
|
6767
6774
|
country: data.country,
|
|
6768
|
-
state:
|
|
6775
|
+
state: subdivision,
|
|
6776
|
+
subdivisionCode: subdivision,
|
|
6769
6777
|
ipAddress: data.ip_address
|
|
6770
6778
|
};
|
|
6771
6779
|
},
|
|
@@ -12258,11 +12266,13 @@ function useUserIp2() {
|
|
|
12258
12266
|
queryKey: ["unifold", "userIpInfo"],
|
|
12259
12267
|
queryFn: async () => {
|
|
12260
12268
|
const data = await getIpAddress();
|
|
12269
|
+
const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
|
|
12261
12270
|
return {
|
|
12262
12271
|
alpha2: data.alpha2.toLowerCase(),
|
|
12263
12272
|
alpha3: data.alpha3?.toLowerCase(),
|
|
12264
12273
|
country: data.country,
|
|
12265
|
-
state:
|
|
12274
|
+
state: subdivision,
|
|
12275
|
+
subdivisionCode: subdivision,
|
|
12266
12276
|
ipAddress: data.ip_address
|
|
12267
12277
|
};
|
|
12268
12278
|
},
|
|
@@ -13568,7 +13578,7 @@ function BuyWithCard({
|
|
|
13568
13578
|
const response = await getDefaultOnrampToken(
|
|
13569
13579
|
{
|
|
13570
13580
|
country_code: userIpInfo?.alpha2?.toUpperCase() || "US",
|
|
13571
|
-
subdivision_code: userIpInfo?.
|
|
13581
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0,
|
|
13572
13582
|
token_address: destinationTokenAddress,
|
|
13573
13583
|
chain_id: destinationChainId,
|
|
13574
13584
|
chain_type: destinationChainType
|
|
@@ -13651,7 +13661,7 @@ function BuyWithCard({
|
|
|
13651
13661
|
source_currency: currency.toLowerCase(),
|
|
13652
13662
|
destination_currency: defaultToken.destination_currency,
|
|
13653
13663
|
destination_network: defaultToken.destination_network,
|
|
13654
|
-
subdivision_code: userIpInfo?.
|
|
13664
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0
|
|
13655
13665
|
};
|
|
13656
13666
|
const response = await getOnrampQuotes(request, publishableKey);
|
|
13657
13667
|
setQuotes(response.data);
|
|
@@ -13663,31 +13673,29 @@ function BuyWithCard({
|
|
|
13663
13673
|
);
|
|
13664
13674
|
if (manualProviderStillExists) {
|
|
13665
13675
|
setSelectedProvider(manualProviderStillExists);
|
|
13666
|
-
const
|
|
13667
|
-
(best, current) => current.destination_amount > best.destination_amount ? current : best
|
|
13668
|
-
);
|
|
13676
|
+
const firstProvider = response.data[0];
|
|
13669
13677
|
if (!autoSelectedProvider) {
|
|
13670
|
-
setAutoSelectedProvider(
|
|
13678
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13671
13679
|
}
|
|
13672
13680
|
setIsAutoSelected(
|
|
13673
13681
|
manualProviderStillExists.service_provider === autoSelectedProvider
|
|
13674
13682
|
);
|
|
13675
|
-
} else {
|
|
13676
|
-
const
|
|
13677
|
-
|
|
13678
|
-
);
|
|
13679
|
-
setSelectedProvider(bestProvider);
|
|
13680
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13683
|
+
} else if (response.data.length > 0) {
|
|
13684
|
+
const firstProvider = response.data[0];
|
|
13685
|
+
setSelectedProvider(firstProvider);
|
|
13686
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13681
13687
|
setIsAutoSelected(true);
|
|
13682
13688
|
setHasManualSelection(false);
|
|
13689
|
+
} else {
|
|
13690
|
+
setSelectedProvider(null);
|
|
13691
|
+
setIsAutoSelected(false);
|
|
13692
|
+
setHasManualSelection(false);
|
|
13683
13693
|
}
|
|
13684
13694
|
} else {
|
|
13685
13695
|
if (response.data.length > 0) {
|
|
13686
|
-
const
|
|
13687
|
-
|
|
13688
|
-
);
|
|
13689
|
-
setSelectedProvider(bestProvider);
|
|
13690
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13696
|
+
const firstProvider = response.data[0];
|
|
13697
|
+
setSelectedProvider(firstProvider);
|
|
13698
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13691
13699
|
setIsAutoSelected(true);
|
|
13692
13700
|
}
|
|
13693
13701
|
}
|
|
@@ -13760,7 +13768,7 @@ function BuyWithCard({
|
|
|
13760
13768
|
destination_currency: selectedProvider.destination_currency,
|
|
13761
13769
|
destination_network: selectedProvider.destination_network,
|
|
13762
13770
|
wallet_address: wallet.address,
|
|
13763
|
-
subdivision_code: userIpInfo?.
|
|
13771
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0,
|
|
13764
13772
|
external_id: externalId
|
|
13765
13773
|
};
|
|
13766
13774
|
const sessionStartUrl = getOnrampSessionStartUrl(
|
|
@@ -13783,9 +13791,7 @@ function BuyWithCard({
|
|
|
13783
13791
|
window.open(sessionStartUrl, "_blank");
|
|
13784
13792
|
handleViewChange("onramp");
|
|
13785
13793
|
};
|
|
13786
|
-
const sortedQuotes =
|
|
13787
|
-
(a, b) => b.destination_amount - a.destination_amount
|
|
13788
|
-
);
|
|
13794
|
+
const sortedQuotes = quotes;
|
|
13789
13795
|
const currencySymbol = getCurrencySymbol(currency);
|
|
13790
13796
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
13791
13797
|
"div",
|
|
@@ -17777,16 +17783,27 @@ function useAllowedCountry(publishableKey) {
|
|
|
17777
17783
|
let isAllowed = null;
|
|
17778
17784
|
if (ipData && configData) {
|
|
17779
17785
|
const blockedCodes = configData.blocked_country_codes || [];
|
|
17786
|
+
const blockedSubdivisions = configData.blocked_country_subdivisions || [];
|
|
17780
17787
|
const userCountryUpper = ipData.alpha2.toUpperCase();
|
|
17781
|
-
|
|
17788
|
+
const userSubdivision = ipData.subdivision_code || ipData.state || "";
|
|
17789
|
+
const userSubdivisionUpper = userSubdivision.toUpperCase();
|
|
17790
|
+
const isCountryBlocked = blockedCodes.some(
|
|
17782
17791
|
(code) => code.toUpperCase() === userCountryUpper
|
|
17783
17792
|
);
|
|
17793
|
+
const isSubdivisionBlocked = blockedSubdivisions.some((entry) => {
|
|
17794
|
+
if (entry.country_code.toUpperCase() !== userCountryUpper) return false;
|
|
17795
|
+
return entry.subdivision_codes.some(
|
|
17796
|
+
(code) => code.toUpperCase() === userSubdivisionUpper
|
|
17797
|
+
);
|
|
17798
|
+
});
|
|
17799
|
+
isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
|
|
17784
17800
|
}
|
|
17801
|
+
const subdivisionCode = (ipData?.subdivision_code || ipData?.state || "").toLowerCase() || null;
|
|
17785
17802
|
return {
|
|
17786
17803
|
isAllowed,
|
|
17787
|
-
// Return lowercase for consistency with useUserIp hook
|
|
17788
17804
|
alpha2: ipData?.alpha2?.toLowerCase() ?? null,
|
|
17789
17805
|
country: ipData?.country ?? null,
|
|
17806
|
+
subdivisionCode,
|
|
17790
17807
|
isLoading,
|
|
17791
17808
|
error
|
|
17792
17809
|
};
|
|
@@ -23105,19 +23122,30 @@ function DepositModal({
|
|
|
23105
23122
|
}
|
|
23106
23123
|
) });
|
|
23107
23124
|
}
|
|
23125
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
23126
|
+
"succeeded",
|
|
23127
|
+
"expired",
|
|
23128
|
+
"refunded",
|
|
23129
|
+
"canceled"
|
|
23130
|
+
]);
|
|
23108
23131
|
function usePaymentIntent(params) {
|
|
23109
23132
|
const {
|
|
23110
23133
|
clientSecret,
|
|
23111
23134
|
publishableKey,
|
|
23112
23135
|
enabled = true,
|
|
23113
|
-
pollingInterval =
|
|
23136
|
+
pollingInterval = 3e3
|
|
23114
23137
|
} = params;
|
|
23115
23138
|
return (0, import_react_query11.useQuery)({
|
|
23116
23139
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
23117
23140
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
23118
23141
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
23119
23142
|
staleTime: 0,
|
|
23120
|
-
refetchInterval:
|
|
23143
|
+
refetchInterval: (query) => {
|
|
23144
|
+
if (!pollingInterval) return false;
|
|
23145
|
+
const status = query.state.data?.status;
|
|
23146
|
+
if (status && TERMINAL_STATUSES.has(status)) return false;
|
|
23147
|
+
return pollingInterval;
|
|
23148
|
+
},
|
|
23121
23149
|
refetchOnWindowFocus: true,
|
|
23122
23150
|
retry: 3,
|
|
23123
23151
|
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
@@ -23241,7 +23269,7 @@ function CheckoutModal({
|
|
|
23241
23269
|
clientSecret,
|
|
23242
23270
|
publishableKey,
|
|
23243
23271
|
enabled: open && !!clientSecret,
|
|
23244
|
-
pollingInterval:
|
|
23272
|
+
pollingInterval: 3e3
|
|
23245
23273
|
});
|
|
23246
23274
|
const { projectConfig } = useProjectConfig({
|
|
23247
23275
|
publishableKey,
|
|
@@ -25695,6 +25723,7 @@ function useAllowedCountry2() {
|
|
|
25695
25723
|
getApiBaseUrl,
|
|
25696
25724
|
getChainName,
|
|
25697
25725
|
getDefaultOnrampToken,
|
|
25726
|
+
getDepositQuote,
|
|
25698
25727
|
getFiatCurrencies,
|
|
25699
25728
|
getIconUrl,
|
|
25700
25729
|
getIconUrlWithCdn,
|
|
@@ -25708,9 +25737,11 @@ function useAllowedCountry2() {
|
|
|
25708
25737
|
getWalletByChainType,
|
|
25709
25738
|
i18n,
|
|
25710
25739
|
queryExecutions,
|
|
25740
|
+
retrievePaymentIntent,
|
|
25711
25741
|
sendSolanaTransaction,
|
|
25712
25742
|
setApiConfig,
|
|
25713
25743
|
useAllowedCountry,
|
|
25744
|
+
useSupportedDepositTokens,
|
|
25714
25745
|
useUnifold,
|
|
25715
25746
|
useUserIp
|
|
25716
25747
|
});
|
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) {
|
|
@@ -6737,11 +6740,13 @@ function useUserIp() {
|
|
|
6737
6740
|
queryKey: ["unifold", "userIpInfo"],
|
|
6738
6741
|
queryFn: async () => {
|
|
6739
6742
|
const data = await getIpAddress();
|
|
6743
|
+
const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
|
|
6740
6744
|
return {
|
|
6741
6745
|
alpha2: data.alpha2.toLowerCase(),
|
|
6742
6746
|
alpha3: data.alpha3?.toLowerCase(),
|
|
6743
6747
|
country: data.country,
|
|
6744
|
-
state:
|
|
6748
|
+
state: subdivision,
|
|
6749
|
+
subdivisionCode: subdivision,
|
|
6745
6750
|
ipAddress: data.ip_address
|
|
6746
6751
|
};
|
|
6747
6752
|
},
|
|
@@ -12247,11 +12252,13 @@ function useUserIp2() {
|
|
|
12247
12252
|
queryKey: ["unifold", "userIpInfo"],
|
|
12248
12253
|
queryFn: async () => {
|
|
12249
12254
|
const data = await getIpAddress();
|
|
12255
|
+
const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
|
|
12250
12256
|
return {
|
|
12251
12257
|
alpha2: data.alpha2.toLowerCase(),
|
|
12252
12258
|
alpha3: data.alpha3?.toLowerCase(),
|
|
12253
12259
|
country: data.country,
|
|
12254
|
-
state:
|
|
12260
|
+
state: subdivision,
|
|
12261
|
+
subdivisionCode: subdivision,
|
|
12255
12262
|
ipAddress: data.ip_address
|
|
12256
12263
|
};
|
|
12257
12264
|
},
|
|
@@ -13557,7 +13564,7 @@ function BuyWithCard({
|
|
|
13557
13564
|
const response = await getDefaultOnrampToken(
|
|
13558
13565
|
{
|
|
13559
13566
|
country_code: userIpInfo?.alpha2?.toUpperCase() || "US",
|
|
13560
|
-
subdivision_code: userIpInfo?.
|
|
13567
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0,
|
|
13561
13568
|
token_address: destinationTokenAddress,
|
|
13562
13569
|
chain_id: destinationChainId,
|
|
13563
13570
|
chain_type: destinationChainType
|
|
@@ -13640,7 +13647,7 @@ function BuyWithCard({
|
|
|
13640
13647
|
source_currency: currency.toLowerCase(),
|
|
13641
13648
|
destination_currency: defaultToken.destination_currency,
|
|
13642
13649
|
destination_network: defaultToken.destination_network,
|
|
13643
|
-
subdivision_code: userIpInfo?.
|
|
13650
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0
|
|
13644
13651
|
};
|
|
13645
13652
|
const response = await getOnrampQuotes(request, publishableKey);
|
|
13646
13653
|
setQuotes(response.data);
|
|
@@ -13652,31 +13659,29 @@ function BuyWithCard({
|
|
|
13652
13659
|
);
|
|
13653
13660
|
if (manualProviderStillExists) {
|
|
13654
13661
|
setSelectedProvider(manualProviderStillExists);
|
|
13655
|
-
const
|
|
13656
|
-
(best, current) => current.destination_amount > best.destination_amount ? current : best
|
|
13657
|
-
);
|
|
13662
|
+
const firstProvider = response.data[0];
|
|
13658
13663
|
if (!autoSelectedProvider) {
|
|
13659
|
-
setAutoSelectedProvider(
|
|
13664
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13660
13665
|
}
|
|
13661
13666
|
setIsAutoSelected(
|
|
13662
13667
|
manualProviderStillExists.service_provider === autoSelectedProvider
|
|
13663
13668
|
);
|
|
13664
|
-
} else {
|
|
13665
|
-
const
|
|
13666
|
-
|
|
13667
|
-
);
|
|
13668
|
-
setSelectedProvider(bestProvider);
|
|
13669
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13669
|
+
} else if (response.data.length > 0) {
|
|
13670
|
+
const firstProvider = response.data[0];
|
|
13671
|
+
setSelectedProvider(firstProvider);
|
|
13672
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13670
13673
|
setIsAutoSelected(true);
|
|
13671
13674
|
setHasManualSelection(false);
|
|
13675
|
+
} else {
|
|
13676
|
+
setSelectedProvider(null);
|
|
13677
|
+
setIsAutoSelected(false);
|
|
13678
|
+
setHasManualSelection(false);
|
|
13672
13679
|
}
|
|
13673
13680
|
} else {
|
|
13674
13681
|
if (response.data.length > 0) {
|
|
13675
|
-
const
|
|
13676
|
-
|
|
13677
|
-
);
|
|
13678
|
-
setSelectedProvider(bestProvider);
|
|
13679
|
-
setAutoSelectedProvider(bestProvider.service_provider);
|
|
13682
|
+
const firstProvider = response.data[0];
|
|
13683
|
+
setSelectedProvider(firstProvider);
|
|
13684
|
+
setAutoSelectedProvider(firstProvider.service_provider);
|
|
13680
13685
|
setIsAutoSelected(true);
|
|
13681
13686
|
}
|
|
13682
13687
|
}
|
|
@@ -13749,7 +13754,7 @@ function BuyWithCard({
|
|
|
13749
13754
|
destination_currency: selectedProvider.destination_currency,
|
|
13750
13755
|
destination_network: selectedProvider.destination_network,
|
|
13751
13756
|
wallet_address: wallet.address,
|
|
13752
|
-
subdivision_code: userIpInfo?.
|
|
13757
|
+
subdivision_code: userIpInfo?.subdivisionCode || void 0,
|
|
13753
13758
|
external_id: externalId
|
|
13754
13759
|
};
|
|
13755
13760
|
const sessionStartUrl = getOnrampSessionStartUrl(
|
|
@@ -13772,9 +13777,7 @@ function BuyWithCard({
|
|
|
13772
13777
|
window.open(sessionStartUrl, "_blank");
|
|
13773
13778
|
handleViewChange("onramp");
|
|
13774
13779
|
};
|
|
13775
|
-
const sortedQuotes =
|
|
13776
|
-
(a, b) => b.destination_amount - a.destination_amount
|
|
13777
|
-
);
|
|
13780
|
+
const sortedQuotes = quotes;
|
|
13778
13781
|
const currencySymbol = getCurrencySymbol(currency);
|
|
13779
13782
|
return /* @__PURE__ */ jsxs8(
|
|
13780
13783
|
"div",
|
|
@@ -17766,16 +17769,27 @@ function useAllowedCountry(publishableKey) {
|
|
|
17766
17769
|
let isAllowed = null;
|
|
17767
17770
|
if (ipData && configData) {
|
|
17768
17771
|
const blockedCodes = configData.blocked_country_codes || [];
|
|
17772
|
+
const blockedSubdivisions = configData.blocked_country_subdivisions || [];
|
|
17769
17773
|
const userCountryUpper = ipData.alpha2.toUpperCase();
|
|
17770
|
-
|
|
17774
|
+
const userSubdivision = ipData.subdivision_code || ipData.state || "";
|
|
17775
|
+
const userSubdivisionUpper = userSubdivision.toUpperCase();
|
|
17776
|
+
const isCountryBlocked = blockedCodes.some(
|
|
17771
17777
|
(code) => code.toUpperCase() === userCountryUpper
|
|
17772
17778
|
);
|
|
17779
|
+
const isSubdivisionBlocked = blockedSubdivisions.some((entry) => {
|
|
17780
|
+
if (entry.country_code.toUpperCase() !== userCountryUpper) return false;
|
|
17781
|
+
return entry.subdivision_codes.some(
|
|
17782
|
+
(code) => code.toUpperCase() === userSubdivisionUpper
|
|
17783
|
+
);
|
|
17784
|
+
});
|
|
17785
|
+
isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
|
|
17773
17786
|
}
|
|
17787
|
+
const subdivisionCode = (ipData?.subdivision_code || ipData?.state || "").toLowerCase() || null;
|
|
17774
17788
|
return {
|
|
17775
17789
|
isAllowed,
|
|
17776
|
-
// Return lowercase for consistency with useUserIp hook
|
|
17777
17790
|
alpha2: ipData?.alpha2?.toLowerCase() ?? null,
|
|
17778
17791
|
country: ipData?.country ?? null,
|
|
17792
|
+
subdivisionCode,
|
|
17779
17793
|
isLoading,
|
|
17780
17794
|
error
|
|
17781
17795
|
};
|
|
@@ -23094,19 +23108,30 @@ function DepositModal({
|
|
|
23094
23108
|
}
|
|
23095
23109
|
) });
|
|
23096
23110
|
}
|
|
23111
|
+
var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
23112
|
+
"succeeded",
|
|
23113
|
+
"expired",
|
|
23114
|
+
"refunded",
|
|
23115
|
+
"canceled"
|
|
23116
|
+
]);
|
|
23097
23117
|
function usePaymentIntent(params) {
|
|
23098
23118
|
const {
|
|
23099
23119
|
clientSecret,
|
|
23100
23120
|
publishableKey,
|
|
23101
23121
|
enabled = true,
|
|
23102
|
-
pollingInterval =
|
|
23122
|
+
pollingInterval = 3e3
|
|
23103
23123
|
} = params;
|
|
23104
23124
|
return useQuery9({
|
|
23105
23125
|
queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
|
|
23106
23126
|
queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
|
|
23107
23127
|
enabled: enabled && !!clientSecret && !!publishableKey,
|
|
23108
23128
|
staleTime: 0,
|
|
23109
|
-
refetchInterval:
|
|
23129
|
+
refetchInterval: (query) => {
|
|
23130
|
+
if (!pollingInterval) return false;
|
|
23131
|
+
const status = query.state.data?.status;
|
|
23132
|
+
if (status && TERMINAL_STATUSES.has(status)) return false;
|
|
23133
|
+
return pollingInterval;
|
|
23134
|
+
},
|
|
23110
23135
|
refetchOnWindowFocus: true,
|
|
23111
23136
|
retry: 3,
|
|
23112
23137
|
retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
|
|
@@ -23230,7 +23255,7 @@ function CheckoutModal({
|
|
|
23230
23255
|
clientSecret,
|
|
23231
23256
|
publishableKey,
|
|
23232
23257
|
enabled: open && !!clientSecret,
|
|
23233
|
-
pollingInterval:
|
|
23258
|
+
pollingInterval: 3e3
|
|
23234
23259
|
});
|
|
23235
23260
|
const { projectConfig } = useProjectConfig({
|
|
23236
23261
|
publishableKey,
|
|
@@ -25683,6 +25708,7 @@ export {
|
|
|
25683
25708
|
getApiBaseUrl,
|
|
25684
25709
|
getChainName,
|
|
25685
25710
|
getDefaultOnrampToken,
|
|
25711
|
+
getDepositQuote,
|
|
25686
25712
|
getFiatCurrencies,
|
|
25687
25713
|
getIconUrl,
|
|
25688
25714
|
getIconUrlWithCdn,
|
|
@@ -25696,9 +25722,11 @@ export {
|
|
|
25696
25722
|
getWalletByChainType,
|
|
25697
25723
|
i18n,
|
|
25698
25724
|
queryExecutions,
|
|
25725
|
+
retrievePaymentIntent,
|
|
25699
25726
|
sendSolanaTransaction,
|
|
25700
25727
|
setApiConfig,
|
|
25701
25728
|
useAllowedCountry2 as useAllowedCountry,
|
|
25729
|
+
useSupportedDepositTokens,
|
|
25702
25730
|
useUnifold2 as useUnifold,
|
|
25703
25731
|
useUserIp
|
|
25704
25732
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/connect-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
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/ui-react": "0.1.
|
|
31
|
-
"@unifold/react-provider": "0.1.
|
|
29
|
+
"@unifold/core": "0.1.51",
|
|
30
|
+
"@unifold/ui-react": "0.1.51",
|
|
31
|
+
"@unifold/react-provider": "0.1.51"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/react": "^19.0.0",
|