@funkit/connect-rn 8.0.0 → 8.2.0

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 (177) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +20 -0
  3. package/dist/{chunk-SRVRWQO6.js → chunk-GG2WCQ6N.js} +26 -10
  4. package/dist/chunk-GG2WCQ6N.js.map +7 -0
  5. package/dist/{chunk-KZOSYNGV.js → chunk-J5K2FSAI.js} +225 -17
  6. package/dist/chunk-J5K2FSAI.js.map +7 -0
  7. package/dist/clients/lighter.js +1 -1
  8. package/dist/clients/nado.js +3 -3
  9. package/dist/clients/nado.js.map +2 -2
  10. package/dist/index.js +21070 -18675
  11. package/dist/index.js.map +4 -4
  12. package/dist/src/components/AssetGrid.d.ts.map +1 -1
  13. package/dist/src/components/BlurBand.d.ts +14 -0
  14. package/dist/src/components/BlurBand.d.ts.map +1 -0
  15. package/dist/src/components/GlassSurface.d.ts +14 -0
  16. package/dist/src/components/GlassSurface.d.ts.map +1 -0
  17. package/dist/src/components/InfoTooltip.d.ts +28 -0
  18. package/dist/src/components/InfoTooltip.d.ts.map +1 -0
  19. package/dist/src/components/ScrollingDots.d.ts +24 -0
  20. package/dist/src/components/ScrollingDots.d.ts.map +1 -0
  21. package/dist/src/fiat/FiatBackButton.d.ts +4 -0
  22. package/dist/src/fiat/FiatBackButton.d.ts.map +1 -1
  23. package/dist/src/fiat/FiatBirthDateField.d.ts.map +1 -1
  24. package/dist/src/fiat/FiatChoiceField.d.ts +8 -1
  25. package/dist/src/fiat/FiatChoiceField.d.ts.map +1 -1
  26. package/dist/src/fiat/FiatCountrySheet.d.ts +22 -7
  27. package/dist/src/fiat/FiatCountrySheet.d.ts.map +1 -1
  28. package/dist/src/fiat/FiatDocumentCaptureStep.d.ts +2 -1
  29. package/dist/src/fiat/FiatDocumentCaptureStep.d.ts.map +1 -1
  30. package/dist/src/fiat/FiatFormFieldRow.d.ts.map +1 -1
  31. package/dist/src/fiat/FiatFormScreen.d.ts +1 -1
  32. package/dist/src/fiat/FiatFormScreen.d.ts.map +1 -1
  33. package/dist/src/fiat/FiatIdentityStep.d.ts.map +1 -1
  34. package/dist/src/fiat/FiatKycFieldControl.d.ts +4 -0
  35. package/dist/src/fiat/FiatKycFieldControl.d.ts.map +1 -1
  36. package/dist/src/fiat/FiatKycIntroScreen.d.ts +3 -1
  37. package/dist/src/fiat/FiatKycIntroScreen.d.ts.map +1 -1
  38. package/dist/src/fiat/FiatKycPosition.d.ts +5 -3
  39. package/dist/src/fiat/FiatKycPosition.d.ts.map +1 -1
  40. package/dist/src/fiat/FiatTermsNotice.d.ts +1 -0
  41. package/dist/src/fiat/FiatTermsNotice.d.ts.map +1 -1
  42. package/dist/src/fiat/SurfaceSlot.d.ts +8 -2
  43. package/dist/src/fiat/SurfaceSlot.d.ts.map +1 -1
  44. package/dist/src/fiat/countryListEntries.d.ts +9 -13
  45. package/dist/src/fiat/countryListEntries.d.ts.map +1 -1
  46. package/dist/src/fiat/countrySections.d.ts +12 -6
  47. package/dist/src/fiat/countrySections.d.ts.map +1 -1
  48. package/dist/src/fiat/formLayout.d.ts.map +1 -1
  49. package/dist/src/fiat/kycFieldValidators.d.ts +5 -1
  50. package/dist/src/fiat/kycFieldValidators.d.ts.map +1 -1
  51. package/dist/src/fiat/kycFormTheme.d.ts +0 -2
  52. package/dist/src/fiat/kycFormTheme.d.ts.map +1 -1
  53. package/dist/src/fiat/kycWalk.d.ts +22 -0
  54. package/dist/src/fiat/kycWalk.d.ts.map +1 -0
  55. package/dist/src/fiat/providers/CoinbaseCheckoutSurface.d.ts.map +1 -1
  56. package/dist/src/fiat/providers/HostedControlFrame.d.ts.map +1 -1
  57. package/dist/src/fiat/providers/adapter.d.ts +15 -1
  58. package/dist/src/fiat/providers/adapter.d.ts.map +1 -1
  59. package/dist/src/fiat/providers/applePayButtonMetrics.d.ts +28 -0
  60. package/dist/src/fiat/providers/applePayButtonMetrics.d.ts.map +1 -0
  61. package/dist/src/fiat/providers/applePayPaintGate.d.ts +21 -0
  62. package/dist/src/fiat/providers/applePayPaintGate.d.ts.map +1 -0
  63. package/dist/src/fiat/providers/moonpay.d.ts +4 -0
  64. package/dist/src/fiat/providers/moonpay.d.ts.map +1 -1
  65. package/dist/src/fiat/providers/moonpayApplePayPainted.d.ts +7 -0
  66. package/dist/src/fiat/providers/moonpayApplePayPainted.d.ts.map +1 -0
  67. package/dist/src/fiat/providers/moonpayApplePayStyle.d.ts +12 -0
  68. package/dist/src/fiat/providers/moonpayApplePayStyle.d.ts.map +1 -0
  69. package/dist/src/fiat/renderCaptureSurface.d.ts +4 -0
  70. package/dist/src/fiat/renderCaptureSurface.d.ts.map +1 -1
  71. package/dist/src/fiat/subdivisions.d.ts +15 -0
  72. package/dist/src/fiat/subdivisions.d.ts.map +1 -0
  73. package/dist/src/fiat/useFiatCheckoutPreparation.d.ts.map +1 -1
  74. package/dist/src/flow/AddressCopiedToast.d.ts +3 -1
  75. package/dist/src/flow/AddressCopiedToast.d.ts.map +1 -1
  76. package/dist/src/flow/DepositAssetPicker.d.ts +11 -0
  77. package/dist/src/flow/DepositAssetPicker.d.ts.map +1 -0
  78. package/dist/src/flow/DepositFlowContent.d.ts +1 -1
  79. package/dist/src/flow/DepositFlowContent.d.ts.map +1 -1
  80. package/dist/src/flow/Drawer.d.ts +27 -9
  81. package/dist/src/flow/Drawer.d.ts.map +1 -1
  82. package/dist/src/flow/FiatDepositAmountStep.d.ts.map +1 -1
  83. package/dist/src/flow/FlowPage.d.ts +20 -0
  84. package/dist/src/flow/FlowPage.d.ts.map +1 -0
  85. package/dist/src/flow/FlowSheet.d.ts +8 -1
  86. package/dist/src/flow/FlowSheet.d.ts.map +1 -1
  87. package/dist/src/flow/FunkitFlowProvider.d.ts.map +1 -1
  88. package/dist/src/flow/SheetMaterial.d.ts +18 -4
  89. package/dist/src/flow/SheetMaterial.d.ts.map +1 -1
  90. package/dist/src/flow/depositFlowConfig.d.ts +3 -0
  91. package/dist/src/flow/depositFlowConfig.d.ts.map +1 -1
  92. package/dist/src/flow/isLockedDeposit.d.ts +6 -0
  93. package/dist/src/flow/isLockedDeposit.d.ts.map +1 -0
  94. package/dist/src/flow/pageMotion.d.ts +37 -0
  95. package/dist/src/flow/pageMotion.d.ts.map +1 -0
  96. package/dist/src/flow/pageTurn.d.ts +28 -0
  97. package/dist/src/flow/pageTurn.d.ts.map +1 -0
  98. package/dist/src/flow/sheetSizing.d.ts +6 -5
  99. package/dist/src/flow/sheetSizing.d.ts.map +1 -1
  100. package/dist/src/flow/useCopiedToast.d.ts +1 -1
  101. package/dist/src/flow/useCopiedToast.d.ts.map +1 -1
  102. package/dist/src/flow/withdrawalFlowConfig.d.ts +18 -5
  103. package/dist/src/flow/withdrawalFlowConfig.d.ts.map +1 -1
  104. package/dist/src/hooks/useNestedSheetHeight.d.ts +10 -3
  105. package/dist/src/hooks/useNestedSheetHeight.d.ts.map +1 -1
  106. package/dist/src/hooks/useSheetFade.d.ts.map +1 -1
  107. package/dist/src/screens/DepositAmountScreen.d.ts +6 -1
  108. package/dist/src/screens/DepositAmountScreen.d.ts.map +1 -1
  109. package/dist/src/screens/LockedTransferCryptoScreen.d.ts +19 -0
  110. package/dist/src/screens/LockedTransferCryptoScreen.d.ts.map +1 -0
  111. package/dist/src/screens/SelectChainScreen.d.ts +1 -0
  112. package/dist/src/screens/SelectChainScreen.d.ts.map +1 -1
  113. package/dist/src/screens/SelectReceiveTokenAndChainScreen.d.ts +0 -8
  114. package/dist/src/screens/SelectReceiveTokenAndChainScreen.d.ts.map +1 -1
  115. package/dist/src/screens/TokenAndChainPickerScreen.d.ts +16 -0
  116. package/dist/src/screens/TokenAndChainPickerScreen.d.ts.map +1 -0
  117. package/dist/src/screens/WithdrawAddressScreen.d.ts +4 -1
  118. package/dist/src/screens/WithdrawAddressScreen.d.ts.map +1 -1
  119. package/dist/src/screens/WithdrawAmountScreen.d.ts +16 -8
  120. package/dist/src/screens/WithdrawAmountScreen.d.ts.map +1 -1
  121. package/dist/src/screens/WithdrawCryptoSteps.d.ts.map +1 -1
  122. package/dist/src/swapped/SwappedScreenShell.d.ts.map +1 -1
  123. package/dist/src/theme/buildFunkitTheme.d.ts +1 -0
  124. package/dist/src/theme/buildFunkitTheme.d.ts.map +1 -1
  125. package/dist/src/theme/restyle.d.ts +33 -0
  126. package/dist/src/theme/restyle.d.ts.map +1 -1
  127. package/dist/src/theme/toRestyleTheme.d.ts +3 -0
  128. package/dist/src/theme/toRestyleTheme.d.ts.map +1 -1
  129. package/dist/src/theme/tokens.d.ts +6 -0
  130. package/dist/src/theme/tokens.d.ts.map +1 -1
  131. package/dist/src/transfer/clipboard.d.ts +2 -0
  132. package/dist/src/transfer/clipboard.d.ts.map +1 -1
  133. package/dist/src/transfer/depositAssets.d.ts +35 -0
  134. package/dist/src/transfer/depositAssets.d.ts.map +1 -0
  135. package/dist/src/transfer/hooks/useCopyDepositAddress.d.ts +7 -6
  136. package/dist/src/transfer/hooks/useCopyDepositAddress.d.ts.map +1 -1
  137. package/dist/src/transfer/hooks/useDepositAssets.d.ts +14 -0
  138. package/dist/src/transfer/hooks/useDepositAssets.d.ts.map +1 -0
  139. package/dist/src/transfer/hooks/useFiatExchangeRates.d.ts +5 -8
  140. package/dist/src/transfer/hooks/useFiatExchangeRates.d.ts.map +1 -1
  141. package/dist/src/transfer/hooks/useLockedTokenAmount.d.ts +10 -0
  142. package/dist/src/transfer/hooks/useLockedTokenAmount.d.ts.map +1 -0
  143. package/dist/src/transfer/lockedTokenAmount.d.ts +9 -0
  144. package/dist/src/transfer/lockedTokenAmount.d.ts.map +1 -0
  145. package/dist/src/transfer/supportedTokens.d.ts +5 -0
  146. package/dist/src/transfer/supportedTokens.d.ts.map +1 -1
  147. package/dist/src/utils/assetGrid.d.ts +5 -0
  148. package/dist/src/utils/assetGrid.d.ts.map +1 -1
  149. package/dist/src/utils/motion.d.ts +0 -15
  150. package/dist/src/utils/motion.d.ts.map +1 -1
  151. package/dist/src/utils/tokenAndChainPicker.d.ts +15 -0
  152. package/dist/src/utils/tokenAndChainPicker.d.ts.map +1 -0
  153. package/dist/src/withdrawal/maxWithdrawAmount.d.ts +43 -0
  154. package/dist/src/withdrawal/maxWithdrawAmount.d.ts.map +1 -0
  155. package/dist/src/withdrawal/receiveDestination.d.ts +0 -7
  156. package/dist/src/withdrawal/receiveDestination.d.ts.map +1 -1
  157. package/dist/src/withdrawal/useCryptoWithdrawalForm.d.ts +6 -1
  158. package/dist/src/withdrawal/useCryptoWithdrawalForm.d.ts.map +1 -1
  159. package/dist/src/withdrawal/useCryptoWithdrawalValidation.d.ts +6 -1
  160. package/dist/src/withdrawal/useCryptoWithdrawalValidation.d.ts.map +1 -1
  161. package/dist/src/withdrawal/useSourceTokenUsdPrice.d.ts +17 -3
  162. package/dist/src/withdrawal/useSourceTokenUsdPrice.d.ts.map +1 -1
  163. package/dist/src/withdrawal/useWithdrawalAmountInput.d.ts +8 -5
  164. package/dist/src/withdrawal/useWithdrawalAmountInput.d.ts.map +1 -1
  165. package/dist/src/withdrawal/useWithdrawalFiatPrice.d.ts +6 -0
  166. package/dist/src/withdrawal/useWithdrawalFiatPrice.d.ts.map +1 -0
  167. package/dist/src/withdrawal/useWithdrawalMaximum.d.ts +19 -0
  168. package/dist/src/withdrawal/useWithdrawalMaximum.d.ts.map +1 -0
  169. package/dist/src/withdrawal/validation.d.ts +6 -2
  170. package/dist/src/withdrawal/validation.d.ts.map +1 -1
  171. package/package.json +8 -5
  172. package/dist/chunk-KZOSYNGV.js.map +0 -7
  173. package/dist/chunk-SRVRWQO6.js.map +0 -7
  174. package/dist/src/fiat/kycFormPosition.d.ts +0 -28
  175. package/dist/src/fiat/kycFormPosition.d.ts.map +0 -1
  176. package/dist/src/flow/StepPage.d.ts +0 -16
  177. package/dist/src/flow/StepPage.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @funkit/connect-rn
2
2
 
3
+ ## 8.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - df17726: Add fiat withdrawal ceilings while preserving token-limit priority and balance checks without asset prices.
8
+ - cc8b722: Country, state and KYC option drawers open on a plain white or black panel instead of glass, themeable through the new `background.drawer` token.
9
+ - cc8b722: V2 deposit screens slide in from the right, KYC pages show a scrolling three-dot indicator, and the address form picks the state from a searchable drawer.
10
+ - e8dd054: Allow crypto withdrawal entry in euros with switching between EUR and token units.
11
+
12
+ ### Patch Changes
13
+
14
+ - d308c78: MoonPay and Coinbase Apple Pay deposits reveal the fee, terms and a ready Apple Pay button together, and MoonPay skips the Continue tap for connected buyers.
15
+ - cc8b722: Country and state pickers read like a contacts list: every entry in its letter with the chosen one checked, an index rail, a blurred title bar the list scrolls under, a Liquid Glass search floating over its foot, and the drawer dismissible by dragging the bar; the sheet material follows the theme's light or dark modal fill.
16
+ - cc8b722: The date-of-birth wheel sits centred on the page instead of against its left edge.
17
+ - cc8b722: The country picker's title bar and search foot blur the list along a gradient instead of in four visible steps.
18
+ - f096d39: Show withdrawal limit errors and let users correct amounts without losing their recipient.
19
+ - 4267e0a: Explain unavailable withdrawal limits and allow retrying failed exchange-rate requests.
20
+ - 4aa16c2: Show the provider's correction reason before reopening document verification.
21
+ - Updated dependencies [4aa16c2]
22
+ - @funkit/connect-core@8.4.1
23
+
24
+ ## 8.1.0
25
+
26
+ ### Minor Changes
27
+
28
+ - a4a1e23: Add locked crypto deposits with asset selection, refreshed amount estimates, explicit copying, and unavailable states.
29
+ - 544a0ce: Support loading and retry states for token price estimates.
30
+
31
+ ### Patch Changes
32
+
33
+ - a4a1e23: Choose a locked crypto deposit’s token and network together before confirming, and prevent confirming unavailable withdrawal token/network pairs.
34
+ - 665dd8d: Preserve deposit token precision and prepare asset selection with network-specific address availability checks.
35
+ - a4a1e23: Expand a locked crypto deposit address to reveal its complete value.
36
+ - a4a1e23: Explain the send amount for locked crypto deposits in a dismissible tooltip.
37
+ - e52bd63: Keep the amount screen in place while an existing MoonPay connection advances to Apple Pay.
38
+ - 059edbe: Keep cancelled and declined MoonPay Apple Pay attempts retryable in every environment, without dismissing the deposit flow.
39
+ - aac8adf: Keep the deposit sheet from closing on a backdrop tap while the Swapped embed is taking a card payment, so a stray tap can no longer interrupt the 3DS / biometric challenge.
40
+ - Updated dependencies [bd9d5e8]
41
+ - Updated dependencies [e06ae58]
42
+ - Updated dependencies [48aae63]
43
+ - @funkit/api-base@8.5.1
44
+ - @funkit/connect-core@8.4.0
45
+ - @funkit/chains@2.4.1
46
+ - @funkit/utils@5.0.1
47
+
3
48
  ## 8.0.0
4
49
 
5
50
  ### Major Changes
package/README.md CHANGED
@@ -39,6 +39,26 @@ log transports, identity context, and transfer hooks are **internal** (mirroring
39
39
  `@funkit/connect`, which exports none of them). When adding a public export, wire
40
40
  it explicitly in `index.ts`.
41
41
 
42
+ ## Withdrawal display currency
43
+
44
+ Set `WithdrawalFlowConfig.displayCurrency` to `'EUR'` to enter crypto withdrawal
45
+ amounts in euros. Users can switch between EUR and source-token units. The
46
+ conversion uses the token's USD price and the shared USD-to-EUR rate, without
47
+ assuming that EURC trades at exactly one euro. For example, at $2 per token and
48
+ 0.8 EUR per USD, entering €8 stages 5 tokens for withdrawal.
49
+
50
+ Token amounts round down to the token's precision; the typed fiat value is
51
+ preserved through denomination switches and navigation. Use Max still stages
52
+ the exact allowed token amount. Rate refreshes do not rewrite an existing entry.
53
+ Until usable rates are available, entry stays in clearly labelled token units;
54
+ a rate arriving later does not reinterpret an amount already typed. Cached
55
+ rates remain usable if a background refresh fails.
56
+
57
+ Omitting the option, or setting `'USD'`, preserves existing USD entry behavior.
58
+ Limits, quotes, confirmation screens, and settlement retain their existing
59
+ denominations. Configure withdrawal ceilings separately using the maximum
60
+ callbacks; a EUR ceiling does not implicitly select an entry currency.
61
+
42
62
  ## Payment deposit metadata
43
63
 
44
64
  `clientMetadata.authorizedAmountBaseUnit` is an explicit maximum gross deposit
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useFunkitIdentity
3
- } from "./chunk-KZOSYNGV.js";
3
+ } from "./chunk-J5K2FSAI.js";
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-D64EJ57D.js";
@@ -52,20 +52,28 @@ function useIsStablecoin() {
52
52
  var SOURCE_TOKEN_PRICE_QUERY_KEY = "sourceTokenUsdPrice";
53
53
  var PRICE_STALE_TIME_MS = 6e4;
54
54
  var STABLECOIN_USD_PRICE = 1;
55
- function useSourceTokenUsdPrice(sourceToken) {
55
+ function useSourceTokenUsdPrice(sourceToken, {
56
+ enabled = true,
57
+ refetchInterval = false
58
+ } = {}) {
56
59
  const { apiKey } = useFunkitIdentity();
57
60
  const isStablecoin = useIsStablecoin();
58
- const isStable = isStablecoin(sourceToken.symbol);
59
- const { data } = useQuery({
61
+ const chainId = sourceToken ? String(sourceToken.chainId) : void 0;
62
+ const isStable = !!sourceToken && isStablecoin(sourceToken.symbol);
63
+ const unavailable = enabled && !!sourceToken && !isStable && !apiKey;
64
+ const query = useQuery({
60
65
  queryKey: [
61
66
  SOURCE_TOKEN_PRICE_QUERY_KEY,
62
67
  apiKey,
63
- sourceToken.chainId,
64
- sourceToken.address
68
+ chainId,
69
+ sourceToken?.address
65
70
  ],
66
71
  queryFn: async () => {
72
+ if (!sourceToken || !chainId) {
73
+ throw new Error("Missing price inputs");
74
+ }
67
75
  const info = await getAssetPriceInfoWithFallback({
68
- chainId: sourceToken.chainId,
76
+ chainId,
69
77
  assetTokenAddress: sourceToken.address,
70
78
  apiKey,
71
79
  logger
@@ -81,11 +89,19 @@ function useSourceTokenUsdPrice(sourceToken) {
81
89
  }
82
90
  return unitPrice;
83
91
  },
84
- enabled: !!apiKey && !isStable,
92
+ enabled: enabled && !!sourceToken && !isStable && !unavailable,
85
93
  staleTime: PRICE_STALE_TIME_MS,
94
+ refetchInterval: isStable ? false : refetchInterval,
86
95
  retry: false
87
96
  });
88
- return isStable ? STABLECOIN_USD_PRICE : data ?? 0;
97
+ return {
98
+ refetch: query.refetch,
99
+ data: isStable ? STABLECOIN_USD_PRICE : query.data ?? 0,
100
+ isUnavailable: unavailable,
101
+ isPending: !isStable && !unavailable && query.isPending,
102
+ isError: !isStable && (unavailable || query.isError),
103
+ isFetching: !isStable && query.isFetching
104
+ };
89
105
  }
90
106
 
91
107
  export {
@@ -94,4 +110,4 @@ export {
94
110
  useIsStablecoin,
95
111
  useSourceTokenUsdPrice
96
112
  };
97
- //# sourceMappingURL=chunk-SRVRWQO6.js.map
113
+ //# sourceMappingURL=chunk-GG2WCQ6N.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/statsig/useDynamicConfig.ts", "../src/geo/useUserIpInfo.ts", "../src/withdrawal/useSourceTokenUsdPrice.ts", "../src/hooks/useIsStablecoin.ts"],
4
+ "sourcesContent": ["import {\n type DynamicConfigName,\n type DynamicConfigValue,\n useDynamicConfig as useCoreDynamicConfig,\n} from '@funkit/connect-core'\n\nimport { useUserIpInfo } from '../geo/useUserIpInfo'\n\n// RN counterpart of `@funkit/connect`'s `hooks/statsig/useDynamicConfig`. The\n// core hook takes `countryCode` as a parameter so it stays platform-agnostic;\n// this wrapper threads the user's IP-derived `alpha2` (Moonpay/ipapi) so\n// country-conditional variant configs (e.g. `enableswappeddeposit`) resolve\n// against the real region instead of falling to their default branch.\nexport type { DynamicConfigName, DynamicConfigValue }\n\nexport const useDynamicConfig = <Name extends DynamicConfigName>(\n name: Name,\n options?: {\n bypassCountryCode?: boolean\n },\n): DynamicConfigValue<Name> => {\n const { userIpInfo } = useUserIpInfo()\n return useCoreDynamicConfig(name, {\n bypassCountryCode: options?.bypassCountryCode,\n countryCode: userIpInfo?.alpha2,\n })\n}\n", "import { useUserIpInfo as useCoreUserIpInfo } from '@funkit/connect-core'\n\nimport { useFunkitIdentity } from '../identity/IdentityContext'\nimport { logger } from '../logging/logger'\n\n// Re-exported so existing RN importers (isCountryBlocked, the flow hooks, tests)\n// keep their type source unchanged after the fetch logic moved to core.\nexport type {\n FunkitUserIpInfo,\n UseUserIpInfoResult,\n} from '@funkit/connect-core'\n\n// Thin RN wrapper over the shared core `useUserIpInfo` (V1 PR13 moved the\n// Moonpay\u2192ipapi fetch logic there so web and RN don't duplicate it). RN is\n// login-agnostic, so the lookup always runs (`enabled: true`); web's wrapper\n// gates on `isUserLoggedIn` instead. `apiKey` lets the core hook reach the\n// first-party geo endpoint; the chain it picks is Statsig-driven.\nexport function useUserIpInfo() {\n const { apiKey } = useFunkitIdentity()\n\n // Login-agnostic + session-stable: always run, never go stale. The fiat\n // rail prices a US buyer by state, so a stateless answer is worth a second\n // provider here; web reads only the country and leaves this off.\n return useCoreUserIpInfo({\n logger,\n apiKey,\n enabled: true,\n staleTime: Number.POSITIVE_INFINITY,\n requireState: true,\n })\n}\n", "import { getAssetPriceInfoWithFallback } from '@funkit/connect-core'\nimport { useQuery } from '@tanstack/react-query'\n\nimport { useIsStablecoin } from '../hooks/useIsStablecoin'\nimport { useFunkitIdentity } from '../identity/IdentityContext'\nimport { logger } from '../logging/logger'\n\nconst SOURCE_TOKEN_PRICE_QUERY_KEY = 'sourceTokenUsdPrice'\n\n/** Long enough that typing doesn't refetch, short enough to stay honest. */\nconst PRICE_STALE_TIME_MS = 60_000\n\n/** What a dollar stablecoin is worth, without asking anyone. */\nconst STABLECOIN_USD_PRICE = 1\n\n/**\n * Spot USD price of the source token, for the USD floor and ceiling the host\n * configures (`getMinWithdrawalUSD`, `getMaxWithdrawalFiat`, or\n * `getMaxWithdrawalUSD`).\n *\n * A dollar stablecoin is priced from its symbol and never fetched, as web's\n * `useAssetAddressPrice` does \u2014 it is the common withdrawal source, and the\n * amount screen was waiting on a round trip to be told a dollar is a dollar.\n *\n * `0` means \"unknown\", which is what the core validator reads as \"no price\" \u2014\n * so a failed or in-flight lookup leaves the USD limits inert rather than\n * judging an amount against a made-up rate. Per-token limits and the balance\n * check are unaffected either way.\n *\n * Not every source has a price: Lighter's L2 assets are addressed by index, not\n * by an ERC-20 funkit's price API knows, so that lookup 404s and core's Relay\n * fallback is what prices them.\n */\nexport function useSourceTokenUsdPrice(\n sourceToken:\n | { chainId: string | number; address: string; symbol: string }\n | undefined,\n {\n enabled = true,\n refetchInterval = false,\n }: {\n enabled?: boolean\n refetchInterval?: number | false\n } = {},\n) {\n const { apiKey } = useFunkitIdentity()\n const isStablecoin = useIsStablecoin()\n const chainId = sourceToken ? String(sourceToken.chainId) : undefined\n const isStable = !!sourceToken && isStablecoin(sourceToken.symbol)\n const unavailable = enabled && !!sourceToken && !isStable && !apiKey\n\n const query = useQuery({\n queryKey: [\n SOURCE_TOKEN_PRICE_QUERY_KEY,\n apiKey,\n chainId,\n sourceToken?.address,\n ],\n queryFn: async () => {\n if (!sourceToken || !chainId) {\n throw new Error('Missing price inputs')\n }\n const info = await getAssetPriceInfoWithFallback({\n chainId,\n assetTokenAddress: sourceToken.address as `0x${string}`,\n apiKey,\n logger,\n })\n const unitPrice = info.unitPrice\n if (!Number.isFinite(unitPrice) || unitPrice <= 0) {\n // Reported here, not on read: a cached bad price would otherwise warn\n // on every render. A non-positive price would silently scale every USD\n // limit to nothing.\n logger.warn('connect-rn:withdrawal:unusable_source_price', {\n chainId: sourceToken.chainId,\n address: sourceToken.address,\n unitPrice,\n })\n return 0\n }\n return unitPrice\n },\n enabled: enabled && !!sourceToken && !isStable && !unavailable,\n staleTime: PRICE_STALE_TIME_MS,\n refetchInterval: isStable ? false : refetchInterval,\n retry: false,\n })\n\n return {\n refetch: query.refetch,\n data: isStable ? STABLECOIN_USD_PRICE : (query.data ?? 0),\n isUnavailable: unavailable,\n isPending: !isStable && !unavailable && query.isPending,\n isError: !isStable && (unavailable || query.isError),\n isFetching: !isStable && query.isFetching,\n }\n}\n", "import { useCallback } from 'react'\nimport { useDynamicConfig } from '../statsig/useDynamicConfig'\n\nexport type IsStablecoinFn = (symbol: string) => boolean\n\nexport function useIsStablecoin(): IsStablecoinFn {\n const stablecoinSymbols = useDynamicConfig('stablecoinsymbols')\n return useCallback(\n (symbol: string) =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