@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.
Files changed (3) hide show
  1. package/dist/index.js +295 -313
  2. package/dist/index.mjs +52 -70
  3. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -9315,22 +9315,6 @@ import {
9315
9315
  generatePrefixedKSUID as generatePrefixedKSUID5,
9316
9316
  DepositEventType as DepositEventType4
9317
9317
  } from "@unifold/core";
9318
-
9319
- // src/hooks/use-cashapp-limits.ts
9320
- import { useQuery as useQuery9 } from "@tanstack/react-query";
9321
- import { getCashAppLimits } from "@unifold/core";
9322
- function useCashAppLimits({ publishableKey, currency = "usd" }) {
9323
- return useQuery9({
9324
- queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
9325
- queryFn: () => getCashAppLimits(currency, publishableKey),
9326
- enabled: !!publishableKey,
9327
- staleTime: 2 * 60 * 6e4,
9328
- gcTime: 4 * 60 * 6e4,
9329
- retry: 2
9330
- });
9331
- }
9332
-
9333
- // src/components/deposits/PayWithCashApp.tsx
9334
9318
  import { Fragment as Fragment6, jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
9335
9319
  var POLL_INTERVAL_MS3 = 5e3;
9336
9320
  var FALLBACK_MIN_USD = 5;
@@ -9367,9 +9351,11 @@ function PayWithCashApp({
9367
9351
  const b = parseInt(bg.slice(4, 6), 16);
9368
9352
  return (r * 299 + g * 587 + b * 114) / 1e3 < 128;
9369
9353
  })();
9370
- const { data: limits, isLoading: limitsLoading } = useCashAppLimits({ publishableKey });
9371
- const minUsd = limits?.minimum_amount ?? FALLBACK_MIN_USD;
9372
- const maxUsd = limits?.maximum_amount ?? null;
9354
+ const { data: fiatCurrencies, isLoading: limitsLoading } = useFiatCurrencies({
9355
+ publishableKey
9356
+ });
9357
+ const minUsd = fiatCurrencies?.data.find((entry) => entry.currency_code.toLowerCase() === "usd")?.minimum_amount ?? FALLBACK_MIN_USD;
9358
+ const quickAmounts = SUGGESTED_AMOUNTS.filter((value) => value >= minUsd);
9373
9359
  const [amount, setAmount] = useState18(() => sanitizePrefilledUsd(prefilledAmountUsd));
9374
9360
  const [loading, setLoading] = useState18(false);
9375
9361
  const [session, setSession] = useState18(null);
@@ -9424,6 +9410,8 @@ function PayWithCashApp({
9424
9410
  setError(strings.depositModal.cashAppErrors.missingFields);
9425
9411
  return;
9426
9412
  }
9413
+ const amountNum2 = parseFloat(amount);
9414
+ if (isNaN(amountNum2) || amountNum2 < minUsd) return;
9427
9415
  setLoading(true);
9428
9416
  setError(null);
9429
9417
  try {
@@ -9472,6 +9460,7 @@ function PayWithCashApp({
9472
9460
  }
9473
9461
  }, [
9474
9462
  amount,
9463
+ minUsd,
9475
9464
  userId,
9476
9465
  publishableKey,
9477
9466
  recipientAddress,
@@ -9575,8 +9564,7 @@ function PayWithCashApp({
9575
9564
  const amountNum = parseFloat(amount);
9576
9565
  const hasInput = !isNaN(amountNum) && amountNum > 0;
9577
9566
  const belowMin = hasInput && amountNum < minUsd;
9578
- const aboveMax = hasInput && maxUsd !== null && amountNum > maxUsd;
9579
- const isValidAmount = hasInput && !belowMin && !aboveMax;
9567
+ const isValidAmount = hasInput && !belowMin;
9580
9568
  if (view === "amount") {
9581
9569
  return /* @__PURE__ */ jsxs16(
9582
9570
  "div",
@@ -9605,7 +9593,7 @@ function PayWithCashApp({
9605
9593
  }
9606
9594
  }
9607
9595
  ) }) }),
9608
- /* @__PURE__ */ jsx20("div", { className: "uf-flex uf-gap-3 uf-justify-center", children: SUGGESTED_AMOUNTS.map((quickAmount) => {
9596
+ /* @__PURE__ */ jsx20("div", { className: "uf-flex uf-gap-3 uf-justify-center", children: quickAmounts.map((quickAmount) => {
9609
9597
  const isSelected = parseFloat(amount) === quickAmount;
9610
9598
  return /* @__PURE__ */ jsxs16(
9611
9599
  "button",
@@ -9631,23 +9619,17 @@ function PayWithCashApp({
9631
9619
  quickAmount
9632
9620
  );
9633
9621
  }) }),
9634
- amount && amountNum < minUsd && !error ? /* @__PURE__ */ jsx20(
9635
- "div",
9636
- {
9637
- className: "uf-text-sm uf-text-center uf-mt-3 uf-px-2",
9638
- style: { color: colors2.error, fontFamily: fonts.regular },
9639
- children: interpolate(strings.common.minimumAmount, { amount: `$${minUsd}` })
9640
- }
9641
- ) : amount && maxUsd !== null && amountNum > maxUsd && !error ? /* @__PURE__ */ jsx20(
9622
+ !limitsLoading && minUsd > 0 && /* @__PURE__ */ jsx20(
9642
9623
  "div",
9643
9624
  {
9644
- className: "uf-text-sm uf-text-center uf-mt-3 uf-px-2",
9645
- style: { color: colors2.error, fontFamily: fonts.regular },
9646
- children: interpolate(strings.common.maximumAmount, {
9647
- amount: `$${maxUsd.toLocaleString()}`
9625
+ className: "uf-text-center uf-text-xs uf-mt-4",
9626
+ style: { color: colors2.warning, fontFamily: fonts.regular },
9627
+ children: interpolate(strings.common.minimumDeposit, {
9628
+ amount: `$${minUsd.toFixed(2)}`
9648
9629
  })
9649
9630
  }
9650
- ) : error ? /* @__PURE__ */ jsx20(
9631
+ ),
9632
+ error ? /* @__PURE__ */ jsx20(
9651
9633
  "div",
9652
9634
  {
9653
9635
  className: "uf-text-sm uf-text-center uf-mt-3 uf-px-2",
@@ -9656,7 +9638,7 @@ function PayWithCashApp({
9656
9638
  }
9657
9639
  ) : null
9658
9640
  ] }),
9659
- /* @__PURE__ */ jsx20("div", { className: "uf-px-1", children: /* @__PURE__ */ jsx20(
9641
+ /* @__PURE__ */ jsx20("div", { className: "uf-px-1 uf-mt-5", children: /* @__PURE__ */ jsx20(
9660
9642
  "button",
9661
9643
  {
9662
9644
  onClick: handleCreateSession,
@@ -9885,7 +9867,7 @@ import {
9885
9867
  } from "@unifold/core";
9886
9868
 
9887
9869
  // src/hooks/use-bank-transfer-providers.ts
9888
- import { useQuery as useQuery10 } from "@tanstack/react-query";
9870
+ import { useQuery as useQuery9 } from "@tanstack/react-query";
9889
9871
  import { getBankTransferProviders } from "@unifold/core";
9890
9872
  function useBankTransferProviders({
9891
9873
  publishableKey,
@@ -9893,7 +9875,7 @@ function useBankTransferProviders({
9893
9875
  countryCode
9894
9876
  }) {
9895
9877
  const normalizedCountry = countryCode?.toUpperCase();
9896
- const { data: providers, isLoading } = useQuery10({
9878
+ const { data: providers, isLoading } = useQuery9({
9897
9879
  queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
9898
9880
  queryFn: () => getBankTransferProviders(publishableKey, { countryCode: normalizedCountry }),
9899
9881
  enabled,
@@ -18456,7 +18438,7 @@ import {
18456
18438
  } from "@unifold/core";
18457
18439
 
18458
18440
  // src/hooks/use-project-config.ts
18459
- import { useQuery as useQuery11, keepPreviousData } from "@tanstack/react-query";
18441
+ import { useQuery as useQuery10, keepPreviousData } from "@tanstack/react-query";
18460
18442
  import { getProjectConfig } from "@unifold/core";
18461
18443
  function useProjectConfig({
18462
18444
  publishableKey,
@@ -18468,7 +18450,7 @@ function useProjectConfig({
18468
18450
  data: projectConfig,
18469
18451
  isLoading,
18470
18452
  error
18471
- } = useQuery11({
18453
+ } = useQuery10({
18472
18454
  // Country is part of the key so a region change refetches the region-aware
18473
18455
  // config. Omitted when undefined so callers that don't pass a country keep
18474
18456
  // sharing the base cache entry.
@@ -18487,7 +18469,7 @@ function useProjectConfig({
18487
18469
  }
18488
18470
 
18489
18471
  // src/hooks/use-integration-transfer-default-token.ts
18490
- import { useQuery as useQuery12 } from "@tanstack/react-query";
18472
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
18491
18473
  import {
18492
18474
  getIntegrationTransferDefaultToken
18493
18475
  } from "@unifold/core";
@@ -18496,7 +18478,7 @@ function useIntegrationTransferDefaultToken({
18496
18478
  publishableKey,
18497
18479
  enabled = true
18498
18480
  }) {
18499
- return useQuery12({
18481
+ return useQuery11({
18500
18482
  queryKey: [
18501
18483
  "unifold",
18502
18484
  "integrationTransferDefaultToken",
@@ -21306,13 +21288,13 @@ function resolveDepositMenuLayout(layout, displayMode) {
21306
21288
  }
21307
21289
 
21308
21290
  // src/hooks/use-exchanges.ts
21309
- import { useQuery as useQuery13 } from "@tanstack/react-query";
21291
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
21310
21292
  import { getExchanges } from "@unifold/core";
21311
21293
  function useExchanges({
21312
21294
  publishableKey,
21313
21295
  enabled = true
21314
21296
  }) {
21315
- const { data: exchanges = [], isLoading } = useQuery13({
21297
+ const { data: exchanges = [], isLoading } = useQuery12({
21316
21298
  queryKey: ["unifold", "exchanges", publishableKey],
21317
21299
  queryFn: () => getExchanges(void 0, publishableKey).then((res) => res.data),
21318
21300
  enabled,
@@ -21324,7 +21306,7 @@ function useExchanges({
21324
21306
  }
21325
21307
 
21326
21308
  // src/hooks/use-public-incident.ts
21327
- import { useQuery as useQuery14 } from "@tanstack/react-query";
21309
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
21328
21310
  import { getPublicIncident } from "@unifold/core";
21329
21311
  function usePublicIncident({
21330
21312
  publishableKey,
@@ -21334,7 +21316,7 @@ function usePublicIncident({
21334
21316
  data: incident,
21335
21317
  isLoading,
21336
21318
  error
21337
- } = useQuery14({
21319
+ } = useQuery13({
21338
21320
  queryKey: ["unifold", "publicIncident", publishableKey],
21339
21321
  queryFn: () => getPublicIncident(publishableKey),
21340
21322
  enabled,
@@ -21346,7 +21328,7 @@ function usePublicIncident({
21346
21328
  }
21347
21329
 
21348
21330
  // src/hooks/use-wallet-pay-providers.ts
21349
- import { useQuery as useQuery15 } from "@tanstack/react-query";
21331
+ import { useQuery as useQuery14 } from "@tanstack/react-query";
21350
21332
  import {
21351
21333
  getWalletPayProviders
21352
21334
  } from "@unifold/core";
@@ -21355,7 +21337,7 @@ function useWalletPayProviders({
21355
21337
  publishableKey,
21356
21338
  enabled = true
21357
21339
  }) {
21358
- const { data: providers, isLoading } = useQuery15({
21340
+ const { data: providers, isLoading } = useQuery14({
21359
21341
  queryKey: ["unifold", "walletPayProviders", method, publishableKey],
21360
21342
  queryFn: () => getWalletPayProviders(method, publishableKey),
21361
21343
  enabled,
@@ -21648,7 +21630,7 @@ function useAllowedCountry(publishableKey) {
21648
21630
  }
21649
21631
 
21650
21632
  // src/hooks/use-address-validation.ts
21651
- import { useQuery as useQuery16 } from "@tanstack/react-query";
21633
+ import { useQuery as useQuery15 } from "@tanstack/react-query";
21652
21634
  import {
21653
21635
  verifyRecipientAddress
21654
21636
  } from "@unifold/core";
@@ -21662,7 +21644,7 @@ function useAddressValidation({
21662
21644
  refetchOnMount = false
21663
21645
  }) {
21664
21646
  const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
21665
- const { data, isLoading, error } = useQuery16({
21647
+ const { data, isLoading, error } = useQuery15({
21666
21648
  queryKey: [
21667
21649
  "unifold",
21668
21650
  "addressValidation",
@@ -23125,7 +23107,7 @@ import {
23125
23107
  } from "@unifold/core";
23126
23108
 
23127
23109
  // src/hooks/use-hypercore-activation.ts
23128
- import { useQuery as useQuery17 } from "@tanstack/react-query";
23110
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
23129
23111
  import { checkHypercoreActivation } from "@unifold/core";
23130
23112
 
23131
23113
  // src/lib/constants.ts
@@ -23144,7 +23126,7 @@ function useHypercoreActivation(params) {
23144
23126
  const recipient = recipientAddress?.trim() ?? "";
23145
23127
  const source = sourceAddress?.trim() ?? "";
23146
23128
  const hasAddresses = !!recipient && !!source;
23147
- const { data, isLoading } = useQuery17({
23129
+ const { data, isLoading } = useQuery16({
23148
23130
  queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
23149
23131
  queryFn: () => checkHypercoreActivation(
23150
23132
  {
@@ -24958,7 +24940,7 @@ async function sendHypercoreEvmTransfer(params) {
24958
24940
  }
24959
24941
 
24960
24942
  // src/hooks/use-deposit-quote.ts
24961
- import { useQuery as useQuery18 } from "@tanstack/react-query";
24943
+ import { useQuery as useQuery17 } from "@tanstack/react-query";
24962
24944
  import { getDepositQuote } from "@unifold/core";
24963
24945
  function useDepositQuote(params) {
24964
24946
  const {
@@ -24985,7 +24967,7 @@ function useDepositQuote(params) {
24985
24967
  ...adjustForSlippage ? { adjust_for_slippage: true } : {},
24986
24968
  ...stablecoinParity ? { stablecoin_parity: true } : {}
24987
24969
  };
24988
- return useQuery18({
24970
+ return useQuery17({
24989
24971
  queryKey: [
24990
24972
  "unifold",
24991
24973
  "depositQuote",
@@ -25013,13 +24995,13 @@ function useDepositQuote(params) {
25013
24995
  }
25014
24996
 
25015
24997
  // src/hooks/use-external-wallets.ts
25016
- import { useQuery as useQuery19 } from "@tanstack/react-query";
24998
+ import { useQuery as useQuery18 } from "@tanstack/react-query";
25017
24999
  import { getExternalWallets } from "@unifold/core";
25018
25000
  function useExternalWallets({
25019
25001
  publishableKey,
25020
25002
  enabled = true
25021
25003
  }) {
25022
- const { data: wallets = [], isLoading } = useQuery19({
25004
+ const { data: wallets = [], isLoading } = useQuery18({
25023
25005
  queryKey: ["unifold", "external-wallets", publishableKey],
25024
25006
  queryFn: () => getExternalWallets(publishableKey).then((res) => res.data),
25025
25007
  enabled: enabled && !!publishableKey,
@@ -29398,12 +29380,12 @@ function useForwardCheckoutEvents(onEvent, journeySessionId) {
29398
29380
  }
29399
29381
 
29400
29382
  // src/hooks/use-payment-intent.ts
29401
- import { useQuery as useQuery20 } from "@tanstack/react-query";
29383
+ import { useQuery as useQuery19 } from "@tanstack/react-query";
29402
29384
  import { retrievePaymentIntent } from "@unifold/core";
29403
29385
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
29404
29386
  function usePaymentIntent(params) {
29405
29387
  const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
29406
- return useQuery20({
29388
+ return useQuery19({
29407
29389
  queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
29408
29390
  queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
29409
29391
  enabled: enabled && !!clientSecret && !!publishableKey,
@@ -30245,12 +30227,12 @@ import { useState as useState49, useEffect as useEffect47, useLayoutEffect as us
30245
30227
  import { AlertTriangle as AlertTriangle8, ChevronRight as ChevronRight22, Clock as Clock6 } from "lucide-react";
30246
30228
 
30247
30229
  // src/hooks/use-supported-destination-tokens.ts
30248
- import { useQuery as useQuery21 } from "@tanstack/react-query";
30230
+ import { useQuery as useQuery20 } from "@tanstack/react-query";
30249
30231
  import {
30250
30232
  getSupportedDestinationTokens
30251
30233
  } from "@unifold/core";
30252
30234
  function useSupportedDestinationTokens(publishableKey, enabled = true) {
30253
- return useQuery21({
30235
+ return useQuery20({
30254
30236
  queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
30255
30237
  queryFn: () => getSupportedDestinationTokens(publishableKey),
30256
30238
  staleTime: 1e3 * 60 * 5,
@@ -30282,7 +30264,7 @@ function useDefaultDestinationToken({
30282
30264
  }
30283
30265
 
30284
30266
  // src/hooks/use-source-token-validation.ts
30285
- import { useQuery as useQuery22 } from "@tanstack/react-query";
30267
+ import { useQuery as useQuery21 } from "@tanstack/react-query";
30286
30268
  import { getSupportedDepositTokens as getSupportedDepositTokens3 } from "@unifold/core";
30287
30269
  function useSourceTokenValidation(params) {
30288
30270
  const {
@@ -30294,7 +30276,7 @@ function useSourceTokenValidation(params) {
30294
30276
  enabled = true
30295
30277
  } = params;
30296
30278
  const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
30297
- return useQuery22({
30279
+ return useQuery21({
30298
30280
  queryKey: [
30299
30281
  "unifold",
30300
30282
  "sourceTokenValidation",
@@ -30344,12 +30326,12 @@ function useSourceTokenValidation(params) {
30344
30326
  }
30345
30327
 
30346
30328
  // src/hooks/use-address-balance.ts
30347
- import { useQuery as useQuery23 } from "@tanstack/react-query";
30329
+ import { useQuery as useQuery22 } from "@tanstack/react-query";
30348
30330
  import { getAddressBalance as getAddressBalance2 } from "@unifold/core";
30349
30331
  function useAddressBalance(params) {
30350
30332
  const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
30351
30333
  const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
30352
- return useQuery23({
30334
+ return useQuery22({
30353
30335
  queryKey: [
30354
30336
  "unifold",
30355
30337
  "addressBalance",
@@ -30405,11 +30387,11 @@ function useAddressBalance(params) {
30405
30387
  }
30406
30388
 
30407
30389
  // src/hooks/use-executions.ts
30408
- import { useQuery as useQuery24 } from "@tanstack/react-query";
30390
+ import { useQuery as useQuery23 } from "@tanstack/react-query";
30409
30391
  import { queryExecutions as queryExecutions4, ActionType as ActionType4 } from "@unifold/core";
30410
30392
  function useExecutions(userId, publishableKey, options) {
30411
30393
  const actionType = options?.actionType ?? ActionType4.Deposit;
30412
- const query = useQuery24({
30394
+ const query = useQuery23({
30413
30395
  queryKey: ["unifold", "executions", actionType, userId, publishableKey],
30414
30396
  queryFn: () => queryExecutions4(userId, publishableKey, actionType),
30415
30397
  enabled: (options?.enabled ?? true) && !!userId,
@@ -30779,7 +30761,7 @@ import {
30779
30761
  } from "@unifold/core";
30780
30762
 
30781
30763
  // src/hooks/use-verify-recipient-address.ts
30782
- import { useQuery as useQuery25 } from "@tanstack/react-query";
30764
+ import { useQuery as useQuery24 } from "@tanstack/react-query";
30783
30765
  import { verifyRecipientAddress as verifyRecipientAddress2 } from "@unifold/core";
30784
30766
  function useVerifyRecipientAddress(params) {
30785
30767
  const {
@@ -30792,7 +30774,7 @@ function useVerifyRecipientAddress(params) {
30792
30774
  } = params;
30793
30775
  const trimmedAddress = recipientAddress?.trim() || "";
30794
30776
  const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
30795
- return useQuery25({
30777
+ return useQuery24({
30796
30778
  queryKey: [
30797
30779
  "unifold",
30798
30780
  "verifyRecipientAddress",
@@ -31044,7 +31026,7 @@ import { useMemo as useMemo19 } from "react";
31044
31026
  import { ActionType as ActionType6 } from "@unifold/core";
31045
31027
 
31046
31028
  // src/hooks/use-get-deposit-address.ts
31047
- import { useQuery as useQuery26 } from "@tanstack/react-query";
31029
+ import { useQuery as useQuery25 } from "@tanstack/react-query";
31048
31030
  import { getDepositAddress } from "@unifold/core";
31049
31031
  function useGetDepositAddress(params) {
31050
31032
  const {
@@ -31058,7 +31040,7 @@ function useGetDepositAddress(params) {
31058
31040
  enabled = true
31059
31041
  } = params;
31060
31042
  const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
31061
- const query = useQuery26({
31043
+ const query = useQuery25({
31062
31044
  queryKey: [
31063
31045
  "unifold",
31064
31046
  "getDepositAddress",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/ui-react",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
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",
@@ -42,8 +42,8 @@
42
42
  "mipd": "^0.0.7",
43
43
  "qr-code-styling": "^1.6.0-rc.1",
44
44
  "tailwind-merge": "^2.0.0",
45
- "@unifold/analytics": "0.1.78",
46
- "@unifold/core": "0.1.78"
45
+ "@unifold/analytics": "0.1.79",
46
+ "@unifold/core": "0.1.79"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@solana/web3.js": "^1.87.0",