@unifold/ui-react 0.1.50 → 0.1.52

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 CHANGED
@@ -93,7 +93,8 @@ interface EthereumProvider {
93
93
  params?: unknown[];
94
94
  }): Promise<unknown>;
95
95
  on(event: string, callback: (...args: unknown[]) => void): void;
96
- removeListener(event: string, callback: (...args: unknown[]) => void): void;
96
+ off?(event: string, callback: (...args: unknown[]) => void): void;
97
+ removeListener?(event: string, callback: (...args: unknown[]) => void): void;
97
98
  }
98
99
 
99
100
  /** Quick amount chips on the browser wallet "Enter amount" step */
@@ -126,7 +127,8 @@ interface EvmWalletProvider {
126
127
  params?: unknown[];
127
128
  }): Promise<unknown>;
128
129
  on(event: string, callback: (...args: unknown[]) => void): void;
129
- removeListener(event: string, callback: (...args: unknown[]) => void): void;
130
+ off?(event: string, callback: (...args: unknown[]) => void): void;
131
+ removeListener?(event: string, callback: (...args: unknown[]) => void): void;
130
132
  }
131
133
 
132
134
  type DepositModalInitialScreen = "main" | "transfer" | "card" | "tracker";
@@ -773,12 +775,14 @@ declare const TooltipContent: React$1.ForwardRefExoticComponent<Omit<TooltipPrim
773
775
  * Result of the useAllowedCountry hook
774
776
  */
775
777
  interface AllowedCountryResult {
776
- /** Whether the user is in an allowed country. null while loading. */
778
+ /** Whether the user is in an allowed country/subdivision. null while loading. */
777
779
  isAllowed: boolean | null;
778
780
  /** ISO 3166-1 alpha-2 country code in lowercase (e.g., "us", "pt") */
779
781
  alpha2: string | null;
780
782
  /** Full country name (e.g., "United States", "Portugal") */
781
783
  country: string | null;
784
+ /** ISO 3166-2 subdivision code in lowercase (e.g., "ny", "43"), null if unavailable */
785
+ subdivisionCode: string | null;
782
786
  /** Whether the hook is still loading data */
783
787
  isLoading: boolean;
784
788
  /** Error if either API call failed */
package/dist/index.d.ts CHANGED
@@ -93,7 +93,8 @@ interface EthereumProvider {
93
93
  params?: unknown[];
94
94
  }): Promise<unknown>;
95
95
  on(event: string, callback: (...args: unknown[]) => void): void;
96
- removeListener(event: string, callback: (...args: unknown[]) => void): void;
96
+ off?(event: string, callback: (...args: unknown[]) => void): void;
97
+ removeListener?(event: string, callback: (...args: unknown[]) => void): void;
97
98
  }
98
99
 
99
100
  /** Quick amount chips on the browser wallet "Enter amount" step */
@@ -126,7 +127,8 @@ interface EvmWalletProvider {
126
127
  params?: unknown[];
127
128
  }): Promise<unknown>;
128
129
  on(event: string, callback: (...args: unknown[]) => void): void;
129
- removeListener(event: string, callback: (...args: unknown[]) => void): void;
130
+ off?(event: string, callback: (...args: unknown[]) => void): void;
131
+ removeListener?(event: string, callback: (...args: unknown[]) => void): void;
130
132
  }
131
133
 
132
134
  type DepositModalInitialScreen = "main" | "transfer" | "card" | "tracker";
@@ -773,12 +775,14 @@ declare const TooltipContent: React$1.ForwardRefExoticComponent<Omit<TooltipPrim
773
775
  * Result of the useAllowedCountry hook
774
776
  */
775
777
  interface AllowedCountryResult {
776
- /** Whether the user is in an allowed country. null while loading. */
778
+ /** Whether the user is in an allowed country/subdivision. null while loading. */
777
779
  isAllowed: boolean | null;
778
780
  /** ISO 3166-1 alpha-2 country code in lowercase (e.g., "us", "pt") */
779
781
  alpha2: string | null;
780
782
  /** Full country name (e.g., "United States", "Portugal") */
781
783
  country: string | null;
784
+ /** ISO 3166-2 subdivision code in lowercase (e.g., "ny", "43"), null if unavailable */
785
+ subdivisionCode: string | null;
782
786
  /** Whether the hook is still loading data */
783
787
  isLoading: boolean;
784
788
  /** Error if either API call failed */
package/dist/index.js CHANGED
@@ -1327,11 +1327,13 @@ function useUserIp() {
1327
1327
  queryKey: ["unifold", "userIpInfo"],
1328
1328
  queryFn: async () => {
1329
1329
  const data = await (0, import_core5.getIpAddress)();
1330
+ const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
1330
1331
  return {
1331
1332
  alpha2: data.alpha2.toLowerCase(),
1332
1333
  alpha3: data.alpha3?.toLowerCase(),
1333
1334
  country: data.country,
1334
- state: data.state?.toLowerCase() ?? null,
1335
+ state: subdivision,
1336
+ subdivisionCode: subdivision,
1335
1337
  ipAddress: data.ip_address
1336
1338
  };
1337
1339
  },
@@ -2668,7 +2670,7 @@ function BuyWithCard({
2668
2670
  const response = await (0, import_core9.getDefaultOnrampToken)(
2669
2671
  {
2670
2672
  country_code: userIpInfo?.alpha2?.toUpperCase() || "US",
2671
- subdivision_code: userIpInfo?.state || void 0,
2673
+ subdivision_code: userIpInfo?.subdivisionCode || void 0,
2672
2674
  token_address: destinationTokenAddress,
2673
2675
  chain_id: destinationChainId,
2674
2676
  chain_type: destinationChainType
@@ -2751,7 +2753,7 @@ function BuyWithCard({
2751
2753
  source_currency: currency.toLowerCase(),
2752
2754
  destination_currency: defaultToken.destination_currency,
2753
2755
  destination_network: defaultToken.destination_network,
2754
- subdivision_code: userIpInfo?.state || void 0
2756
+ subdivision_code: userIpInfo?.subdivisionCode || void 0
2755
2757
  };
2756
2758
  const response = await (0, import_core9.getOnrampQuotes)(request, publishableKey);
2757
2759
  setQuotes(response.data);
@@ -2858,7 +2860,7 @@ function BuyWithCard({
2858
2860
  destination_currency: selectedProvider.destination_currency,
2859
2861
  destination_network: selectedProvider.destination_network,
2860
2862
  wallet_address: wallet.address,
2861
- subdivision_code: userIpInfo?.state || void 0,
2863
+ subdivision_code: userIpInfo?.subdivisionCode || void 0,
2862
2864
  external_id: externalId
2863
2865
  };
2864
2866
  const sessionStartUrl = (0, import_core9.getOnrampSessionStartUrl)(
@@ -6656,8 +6658,11 @@ function BrowserWalletButton({
6656
6658
  solanaProvider.off("accountChanged", handleAccountsChanged);
6657
6659
  }
6658
6660
  for (const provider of ethProviders) {
6659
- provider.removeListener("accountsChanged", handleEthAccountsChanged);
6660
- provider.removeListener("chainChanged", handleAccountsChanged);
6661
+ const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
6662
+ if (off) {
6663
+ off("accountsChanged", handleEthAccountsChanged);
6664
+ off("chainChanged", handleAccountsChanged);
6665
+ }
6661
6666
  }
6662
6667
  };
6663
6668
  }, [chainType, eip6963ProviderCount]);
@@ -7008,10 +7013,12 @@ function useAllowedCountry(publishableKey) {
7008
7013
  });
7009
7014
  isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
7010
7015
  }
7016
+ const subdivisionCode = (ipData?.subdivision_code || ipData?.state || "").toLowerCase() || null;
7011
7017
  return {
7012
7018
  isAllowed,
7013
7019
  alpha2: ipData?.alpha2?.toLowerCase() ?? null,
7014
7020
  country: ipData?.country ?? null,
7021
+ subdivisionCode,
7015
7022
  isLoading,
7016
7023
  error
7017
7024
  };
package/dist/index.mjs CHANGED
@@ -1236,11 +1236,13 @@ function useUserIp() {
1236
1236
  queryKey: ["unifold", "userIpInfo"],
1237
1237
  queryFn: async () => {
1238
1238
  const data = await getIpAddress();
1239
+ const subdivision = (data.subdivision_code || data.state || "").toLowerCase() || null;
1239
1240
  return {
1240
1241
  alpha2: data.alpha2.toLowerCase(),
1241
1242
  alpha3: data.alpha3?.toLowerCase(),
1242
1243
  country: data.country,
1243
- state: data.state?.toLowerCase() ?? null,
1244
+ state: subdivision,
1245
+ subdivisionCode: subdivision,
1244
1246
  ipAddress: data.ip_address
1245
1247
  };
1246
1248
  },
@@ -2591,7 +2593,7 @@ function BuyWithCard({
2591
2593
  const response = await getDefaultOnrampToken(
2592
2594
  {
2593
2595
  country_code: userIpInfo?.alpha2?.toUpperCase() || "US",
2594
- subdivision_code: userIpInfo?.state || void 0,
2596
+ subdivision_code: userIpInfo?.subdivisionCode || void 0,
2595
2597
  token_address: destinationTokenAddress,
2596
2598
  chain_id: destinationChainId,
2597
2599
  chain_type: destinationChainType
@@ -2674,7 +2676,7 @@ function BuyWithCard({
2674
2676
  source_currency: currency.toLowerCase(),
2675
2677
  destination_currency: defaultToken.destination_currency,
2676
2678
  destination_network: defaultToken.destination_network,
2677
- subdivision_code: userIpInfo?.state || void 0
2679
+ subdivision_code: userIpInfo?.subdivisionCode || void 0
2678
2680
  };
2679
2681
  const response = await getOnrampQuotes(request, publishableKey);
2680
2682
  setQuotes(response.data);
@@ -2781,7 +2783,7 @@ function BuyWithCard({
2781
2783
  destination_currency: selectedProvider.destination_currency,
2782
2784
  destination_network: selectedProvider.destination_network,
2783
2785
  wallet_address: wallet.address,
2784
- subdivision_code: userIpInfo?.state || void 0,
2786
+ subdivision_code: userIpInfo?.subdivisionCode || void 0,
2785
2787
  external_id: externalId
2786
2788
  };
2787
2789
  const sessionStartUrl = getOnrampSessionStartUrl(
@@ -6584,8 +6586,11 @@ function BrowserWalletButton({
6584
6586
  solanaProvider.off("accountChanged", handleAccountsChanged);
6585
6587
  }
6586
6588
  for (const provider of ethProviders) {
6587
- provider.removeListener("accountsChanged", handleEthAccountsChanged);
6588
- provider.removeListener("chainChanged", handleAccountsChanged);
6589
+ const off = provider.off?.bind(provider) ?? provider.removeListener?.bind(provider);
6590
+ if (off) {
6591
+ off("accountsChanged", handleEthAccountsChanged);
6592
+ off("chainChanged", handleAccountsChanged);
6593
+ }
6589
6594
  }
6590
6595
  };
6591
6596
  }, [chainType, eip6963ProviderCount]);
@@ -6944,10 +6949,12 @@ function useAllowedCountry(publishableKey) {
6944
6949
  });
6945
6950
  isAllowed = !isCountryBlocked && !isSubdivisionBlocked;
6946
6951
  }
6952
+ const subdivisionCode = (ipData?.subdivision_code || ipData?.state || "").toLowerCase() || null;
6947
6953
  return {
6948
6954
  isAllowed,
6949
6955
  alpha2: ipData?.alpha2?.toLowerCase() ?? null,
6950
6956
  country: ipData?.country ?? null,
6957
+ subdivisionCode,
6951
6958
  isLoading,
6952
6959
  error
6953
6960
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-react",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "description": "Unifold UI React - Deposit and onramp components for React applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -34,7 +34,7 @@
34
34
  "lucide-react": "^0.454.0",
35
35
  "qr-code-styling": "^1.6.0-rc.1",
36
36
  "tailwind-merge": "^2.0.0",
37
- "@unifold/core": "0.1.50"
37
+ "@unifold/core": "0.1.52"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@solana/web3.js": "^1.87.0",