@dynamic-labs/sdk-react-core 4.5.0 → 4.5.2

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 (314) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +12 -12
  5. package/src/index.cjs +7 -7
  6. package/src/index.js +2 -2
  7. package/src/lib/components/Alert/Alert.cjs +6 -3
  8. package/src/lib/components/Alert/Alert.d.ts +1 -0
  9. package/src/lib/components/Alert/Alert.js +6 -4
  10. package/src/lib/components/Alert/AlertText/AlertText.cjs +16 -0
  11. package/src/lib/components/Alert/AlertText/AlertText.d.ts +7 -0
  12. package/src/lib/components/Alert/AlertText/AlertText.js +12 -0
  13. package/src/lib/components/Alert/AlertText/index.d.ts +1 -0
  14. package/src/lib/components/NetworkPicker/NetworkPicker.cjs +11 -40
  15. package/src/lib/components/NetworkPicker/NetworkPicker.d.ts +2 -6
  16. package/src/lib/components/NetworkPicker/NetworkPicker.js +12 -41
  17. package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.cjs +6 -8
  18. package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.d.ts +2 -4
  19. package/src/lib/components/NetworkPicker/components/NetworkControl/NetworkControl.js +6 -8
  20. package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.cjs +67 -0
  21. package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.d.ts +14 -0
  22. package/src/lib/components/NetworkPicker/components/NetworkDropdown/NetworkDropdown.js +63 -0
  23. package/src/lib/components/NetworkPicker/components/NetworkDropdown/index.d.ts +1 -0
  24. package/src/lib/components/NetworkPicker/components/{EvmNetworkControl/EvmNetworkControl.cjs → NetworkSwitchControl/NetworkSwitchControl.cjs} +27 -36
  25. package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/NetworkSwitchControl.d.ts +16 -0
  26. package/src/lib/components/NetworkPicker/components/{EvmNetworkControl/EvmNetworkControl.js → NetworkSwitchControl/NetworkSwitchControl.js} +27 -35
  27. package/src/lib/components/NetworkPicker/components/NetworkSwitchControl/index.d.ts +1 -0
  28. package/src/lib/components/Portal/Portal.cjs +3 -2
  29. package/src/lib/components/Portal/Portal.js +3 -2
  30. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +1 -1
  31. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +1 -1
  32. package/src/lib/components/ShadowDOM/ShadowDOM.cjs +0 -2
  33. package/src/lib/components/ShadowDOM/ShadowDOM.js +1 -2
  34. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +1 -1
  35. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +1 -1
  36. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -1
  37. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -1
  38. package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
  39. package/src/lib/components/UserProfile/UserProfile.js +1 -1
  40. package/src/lib/context/DynamicContext/DynamicContext.cjs +15 -12
  41. package/src/lib/context/DynamicContext/DynamicContext.js +15 -12
  42. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.cjs +2 -2
  43. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.js +3 -3
  44. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -4
  45. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +0 -4
  46. package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +7 -2
  47. package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +7 -2
  48. package/src/lib/context/DynamicContext/hooks/usePasskeySuccessPopup/usePasskeySuccessPopup.cjs +2 -2
  49. package/src/lib/context/DynamicContext/hooks/usePasskeySuccessPopup/usePasskeySuccessPopup.js +3 -3
  50. package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +5 -2
  51. package/src/lib/context/ErrorContext/ErrorContext.cjs +7 -6
  52. package/src/lib/context/ErrorContext/ErrorContext.js +8 -7
  53. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +3 -3
  54. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +3 -3
  55. package/src/lib/context/ViewContext/ViewContext.cjs +7 -2
  56. package/src/lib/context/ViewContext/ViewContext.js +7 -2
  57. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  58. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +5 -64
  59. package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +2 -18
  60. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +6 -61
  61. package/src/lib/data/api/wallets/wallets.cjs +1 -3
  62. package/src/lib/data/api/wallets/wallets.d.ts +1 -1
  63. package/src/lib/data/api/wallets/wallets.js +2 -4
  64. package/src/lib/events/embeddedWallet.d.ts +0 -4
  65. package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.cjs +2 -6
  66. package/src/lib/layout/DynamicAuthLayout/ToSFooter/ToSFooter.js +2 -6
  67. package/src/lib/locale/en/translation.cjs +13 -32
  68. package/src/lib/locale/en/translation.d.ts +12 -31
  69. package/src/lib/locale/en/translation.js +13 -32
  70. package/src/lib/main.global.cjs +1 -1
  71. package/src/lib/main.global.js +1 -1
  72. package/src/lib/modals/SyncWalletPromptModal/SyncWalletPromptModal.cjs +8 -8
  73. package/src/lib/modals/SyncWalletPromptModal/SyncWalletPromptModal.js +8 -8
  74. package/src/lib/modals/index.d.ts +0 -2
  75. package/src/lib/shared/assets/index.d.ts +1 -0
  76. package/src/lib/shared/assets/{currency.cjs → wallet-with-sunglasses.cjs} +14 -26
  77. package/src/lib/shared/assets/wallet-with-sunglasses.js +34 -0
  78. package/src/lib/shared/utils/functions/index.d.ts +0 -2
  79. package/src/lib/shared/utils/hooks/useLocalStorage/useLocalStorage.cjs +7 -5
  80. package/src/lib/shared/utils/hooks/useLocalStorage/useLocalStorage.js +8 -6
  81. package/src/lib/styles/index.shadow.cjs +1 -1
  82. package/src/lib/styles/index.shadow.js +1 -1
  83. package/src/lib/utils/functions/index.d.ts +0 -5
  84. package/src/lib/utils/functions/isAllowedToLinkWallet/isAllowedToLinkWallet.cjs +1 -1
  85. package/src/lib/utils/functions/isAllowedToLinkWallet/isAllowedToLinkWallet.js +1 -1
  86. package/src/lib/utils/functions/isNetworkUnsupported/isNetworkUnsupported.cjs +2 -4
  87. package/src/lib/utils/functions/isNetworkUnsupported/isNetworkUnsupported.d.ts +2 -2
  88. package/src/lib/utils/functions/isNetworkUnsupported/isNetworkUnsupported.js +2 -4
  89. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.cjs +1 -1
  90. package/src/lib/utils/functions/onrampConfigurationToOnrampOption/onrampConfigurationToOnrampOption.js +1 -1
  91. package/src/lib/utils/hooks/index.d.ts +0 -1
  92. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +0 -2
  93. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +0 -2
  94. package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.cjs +2 -2
  95. package/src/lib/utils/hooks/useClearWalletConnectSessions/useClearWalletConnectSessions.js +3 -3
  96. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +16 -4
  97. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +16 -4
  98. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +3 -3
  99. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +3 -3
  100. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.cjs +1 -1
  101. package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.js +1 -1
  102. package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +1 -6
  103. package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +1 -6
  104. package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.cjs +1 -1
  105. package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.js +1 -1
  106. package/src/lib/utils/hooks/useElementById/useElementById.cjs +2 -2
  107. package/src/lib/utils/hooks/useElementById/useElementById.js +3 -3
  108. package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +1 -13
  109. package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +1 -13
  110. package/src/lib/utils/hooks/useEmbeddedWallet/index.d.ts +0 -1
  111. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +7 -23
  112. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +0 -2
  113. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +7 -23
  114. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +4 -4
  115. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +4 -4
  116. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +3 -3
  117. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +3 -3
  118. package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.cjs +1 -0
  119. package/src/lib/utils/hooks/useFundWithWallet/useConnectWalletForFunding/useConnectWalletForFunding.js +1 -0
  120. package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs +1 -1
  121. package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js +1 -1
  122. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +2 -2
  123. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +2 -2
  124. package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +1 -1
  125. package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +1 -1
  126. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +11 -18
  127. package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +12 -19
  128. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +4 -4
  129. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +4 -4
  130. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.cjs +4 -4
  131. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.js +4 -4
  132. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +4 -4
  133. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +4 -4
  134. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +0 -3
  135. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +0 -3
  136. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +0 -3
  137. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +0 -3
  138. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +0 -1
  139. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +0 -1
  140. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -24
  141. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -24
  142. package/src/lib/utils/validations/index.d.ts +0 -1
  143. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +2 -4
  144. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +2 -4
  145. package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.cjs +2 -2
  146. package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.js +2 -2
  147. package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
  148. package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
  149. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +12 -34
  150. package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +13 -35
  151. package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs +2 -2
  152. package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js +2 -2
  153. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
  154. package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
  155. package/src/lib/views/MfaRecoveryView/MfaRecoveryView.cjs +1 -1
  156. package/src/lib/views/MfaRecoveryView/MfaRecoveryView.js +1 -1
  157. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -4
  158. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -4
  159. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +1 -1
  160. package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +1 -1
  161. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +1 -1
  162. package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -1
  163. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +11 -11
  164. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +11 -11
  165. package/src/lib/views/viewToComponentMap.cjs +0 -4
  166. package/src/lib/views/viewToComponentMap.d.ts +0 -2
  167. package/src/lib/views/viewToComponentMap.js +0 -4
  168. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +10 -15
  169. package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +11 -16
  170. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +1 -1
  171. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +1 -1
  172. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +2 -6
  173. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +2 -6
  174. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +3 -3
  175. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +3 -3
  176. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +1 -1
  177. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +1 -1
  178. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
  179. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
  180. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
  181. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +1 -1
  182. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +1 -1
  183. package/src/lib/widgets/DynamicWidget/views/ChooseOnrampProviderView/ChooseOnrampProviderView.cjs +4 -1
  184. package/src/lib/widgets/DynamicWidget/views/ChooseOnrampProviderView/ChooseOnrampProviderView.js +4 -1
  185. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/ChooseWalletFundingMethod.cjs +1 -1
  186. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/ChooseWalletFundingMethod.js +1 -1
  187. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useFundingMethods.cjs +19 -11
  188. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useFundingMethods.js +19 -11
  189. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +2 -2
  190. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +2 -2
  191. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/ReceiveExternalWalletFunds.cjs +103 -50
  192. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/ReceiveExternalWalletFunds.js +99 -46
  193. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenOption/TokenOption.cjs +21 -10
  194. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenOption/TokenOption.d.ts +2 -0
  195. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenOption/TokenOption.js +21 -10
  196. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenSelectScreen.cjs +3 -3
  197. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenSelectScreen.d.ts +2 -0
  198. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/TokenSelectScreen/TokenSelectScreen.js +3 -3
  199. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/types.d.ts +2 -0
  200. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/calculateFiatBalance/calculateFiatBalance.cjs +27 -0
  201. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/calculateFiatBalance/calculateFiatBalance.d.ts +2 -0
  202. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/calculateFiatBalance/calculateFiatBalance.js +23 -0
  203. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/calculateFiatBalance/index.d.ts +1 -0
  204. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/convert/convert.cjs +4 -0
  205. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/convert/convert.js +4 -0
  206. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/convertScientificToDecimal/convertScientificToDecimal.cjs +33 -0
  207. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/convertScientificToDecimal/convertScientificToDecimal.d.ts +8 -0
  208. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/convertScientificToDecimal/convertScientificToDecimal.js +29 -0
  209. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/convertScientificToDecimal/index.d.ts +1 -0
  210. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/formatValue.cjs +27 -22
  211. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/formatValue.d.ts +6 -0
  212. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/formatValue/formatValue.js +27 -22
  213. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/isFiatToken/isFiatToken.cjs +2 -0
  214. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/isFiatToken/isFiatToken.d.ts +1 -0
  215. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/isFiatToken/isFiatToken.js +2 -1
  216. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useExchangeRatesForFunding/index.d.ts +1 -0
  217. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useExchangeRatesForFunding/useExchangeRatesForFunding.cjs +32 -0
  218. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useExchangeRatesForFunding/useExchangeRatesForFunding.d.ts +9 -0
  219. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useExchangeRatesForFunding/useExchangeRatesForFunding.js +28 -0
  220. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useSubmitExternalWalletFunding/useSubmitExternalWalletFunding.cjs +14 -2
  221. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useSubmitExternalWalletFunding/useSubmitExternalWalletFunding.js +14 -2
  222. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useTokensForFunding/useTokensForFunding.cjs +27 -15
  223. package/src/lib/widgets/DynamicWidget/views/ReceiveExternalWalletFunds/utils/useTokensForFunding/useTokensForFunding.js +27 -15
  224. package/src/lib/widgets/DynamicWidget/views/SettingsView/EmptyScreen/EmptyScreen.cjs +20 -0
  225. package/src/lib/widgets/DynamicWidget/views/SettingsView/EmptyScreen/EmptyScreen.d.ts +2 -0
  226. package/src/lib/widgets/DynamicWidget/views/SettingsView/EmptyScreen/EmptyScreen.js +16 -0
  227. package/src/lib/widgets/DynamicWidget/views/SettingsView/EmptyScreen/index.d.ts +1 -0
  228. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +10 -23
  229. package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +11 -24
  230. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.d.ts +0 -23
  231. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/index.d.ts +0 -1
  232. package/src/lib/components/ToggleVisibilityButton/ToggleVisibilityButton.cjs +0 -113
  233. package/src/lib/components/ToggleVisibilityButton/ToggleVisibilityButton.js +0 -109
  234. package/src/lib/modals/CreatePasswordModal/CreatePasswordModal.cjs +0 -106
  235. package/src/lib/modals/CreatePasswordModal/CreatePasswordModal.d.ts +0 -3
  236. package/src/lib/modals/CreatePasswordModal/CreatePasswordModal.js +0 -102
  237. package/src/lib/modals/CreatePasswordModal/CreatePasswordModal.types.d.ts +0 -5
  238. package/src/lib/modals/CreatePasswordModal/index.d.ts +0 -1
  239. package/src/lib/modals/EnterPasswordModal/EnterPasswordModal.cjs +0 -106
  240. package/src/lib/modals/EnterPasswordModal/EnterPasswordModal.d.ts +0 -3
  241. package/src/lib/modals/EnterPasswordModal/EnterPasswordModal.js +0 -102
  242. package/src/lib/modals/EnterPasswordModal/EnterPasswordModal.types.d.ts +0 -6
  243. package/src/lib/modals/EnterPasswordModal/index.d.ts +0 -1
  244. package/src/lib/shared/assets/alt-key.cjs +0 -55
  245. package/src/lib/shared/assets/alt-key.js +0 -31
  246. package/src/lib/shared/assets/currency.js +0 -46
  247. package/src/lib/shared/assets/lock.cjs +0 -55
  248. package/src/lib/shared/assets/lock.js +0 -31
  249. package/src/lib/shared/assets/save-password-hero.cjs +0 -128
  250. package/src/lib/shared/assets/save-password-hero.js +0 -104
  251. package/src/lib/shared/assets/wallet-claim-hero.cjs +0 -128
  252. package/src/lib/shared/assets/wallet-claim-hero.js +0 -104
  253. package/src/lib/shared/utils/functions/generateRandomPassword/generateRandomPassword.cjs +0 -15
  254. package/src/lib/shared/utils/functions/generateRandomPassword/generateRandomPassword.d.ts +0 -1
  255. package/src/lib/shared/utils/functions/generateRandomPassword/generateRandomPassword.js +0 -11
  256. package/src/lib/shared/utils/functions/generateRandomPassword/index.d.ts +0 -1
  257. package/src/lib/shared/utils/functions/validatePassword/index.d.ts +0 -1
  258. package/src/lib/shared/utils/functions/validatePassword/validatePassword.cjs +0 -60
  259. package/src/lib/shared/utils/functions/validatePassword/validatePassword.d.ts +0 -13
  260. package/src/lib/shared/utils/functions/validatePassword/validatePassword.js +0 -56
  261. package/src/lib/utils/functions/findCoinbaseMPCWallet/findCoinbaseMPCWallet.cjs +0 -8
  262. package/src/lib/utils/functions/findCoinbaseMPCWallet/findCoinbaseMPCWallet.d.ts +0 -2
  263. package/src/lib/utils/functions/findCoinbaseMPCWallet/findCoinbaseMPCWallet.js +0 -4
  264. package/src/lib/utils/functions/findCoinbaseMPCWallet/index.d.ts +0 -1
  265. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +0 -53
  266. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.d.ts +0 -9
  267. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +0 -49
  268. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/index.d.ts +0 -1
  269. package/src/lib/utils/functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.cjs +0 -14
  270. package/src/lib/utils/functions/isCoinbaseWaasEnabled/isCoinbaseWaasEnabled.js +0 -10
  271. package/src/lib/utils/functions/requiresPasswordForEmbeddedWallet/index.d.ts +0 -1
  272. package/src/lib/utils/functions/requiresPasswordForEmbeddedWallet/requiresPasswordForEmbeddedWallet.cjs +0 -16
  273. package/src/lib/utils/functions/requiresPasswordForEmbeddedWallet/requiresPasswordForEmbeddedWallet.d.ts +0 -2
  274. package/src/lib/utils/functions/requiresPasswordForEmbeddedWallet/requiresPasswordForEmbeddedWallet.js +0 -12
  275. package/src/lib/utils/functions/requiresPasswordForEmbeddedWalletOnSignup/index.d.ts +0 -1
  276. package/src/lib/utils/functions/requiresPasswordForEmbeddedWalletOnSignup/requiresPasswordForEmbeddedWalletOnSignup.cjs +0 -39
  277. package/src/lib/utils/functions/requiresPasswordForEmbeddedWalletOnSignup/requiresPasswordForEmbeddedWalletOnSignup.d.ts +0 -2
  278. package/src/lib/utils/functions/requiresPasswordForEmbeddedWalletOnSignup/requiresPasswordForEmbeddedWalletOnSignup.js +0 -35
  279. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/index.d.ts +0 -2
  280. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/index.d.ts +0 -1
  281. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +0 -229
  282. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.d.ts +0 -5
  283. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +0 -225
  284. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.cjs +0 -191
  285. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.d.ts +0 -18
  286. package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.js +0 -187
  287. package/src/lib/utils/hooks/useEmbeddedWalletPassword/index.d.ts +0 -1
  288. package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +0 -141
  289. package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.d.ts +0 -4
  290. package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +0 -137
  291. package/src/lib/utils/validations/validateMPCProviderEnabled/index.d.ts +0 -1
  292. package/src/lib/utils/validations/validateMPCProviderEnabled/validateMPCProviderEnabled.cjs +0 -18
  293. package/src/lib/utils/validations/validateMPCProviderEnabled/validateMPCProviderEnabled.d.ts +0 -2
  294. package/src/lib/utils/validations/validateMPCProviderEnabled/validateMPCProviderEnabled.js +0 -14
  295. package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.cjs +0 -116
  296. package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.d.ts +0 -2
  297. package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.js +0 -112
  298. package/src/lib/views/CoinbaseMPCClaimIntro/index.d.ts +0 -1
  299. package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.cjs +0 -197
  300. package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.d.ts +0 -12
  301. package/src/lib/views/CreatePasswordView/CreatePasswordStep/CreatePasswordStep.js +0 -193
  302. package/src/lib/views/CreatePasswordView/CreatePasswordStep/index.d.ts +0 -1
  303. package/src/lib/views/CreatePasswordView/CreatePasswordView.cjs +0 -169
  304. package/src/lib/views/CreatePasswordView/CreatePasswordView.d.ts +0 -9
  305. package/src/lib/views/CreatePasswordView/CreatePasswordView.js +0 -165
  306. package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.cjs +0 -141
  307. package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.d.ts +0 -12
  308. package/src/lib/views/CreatePasswordView/SavePasswordStep/SavePasswordStep.js +0 -137
  309. package/src/lib/views/CreatePasswordView/SavePasswordStep/index.d.ts +0 -1
  310. package/src/lib/views/CreatePasswordView/index.d.ts +0 -1
  311. package/src/lib/views/EnterPasswordView/EnterPasswordView.cjs +0 -141
  312. package/src/lib/views/EnterPasswordView/EnterPasswordView.d.ts +0 -8
  313. package/src/lib/views/EnterPasswordView/EnterPasswordView.js +0 -137
  314. package/src/lib/views/EnterPasswordView/index.d.ts +0 -1
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useState } from 'react';
3
+ import { useState, useCallback } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { WalletIcon } from '@dynamic-labs/wallet-book';
6
6
  import { classNames } from '../../../../utils/functions/classNames/classNames.js';
@@ -43,7 +43,6 @@ import '../../../../utils/functions/compareChains/compareChains.js';
43
43
  import '../../../../context/ThemeContext/ThemeContext.js';
44
44
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
45
45
  import 'bs58';
46
- import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
47
46
  import '@dynamic-labs/types';
48
47
  import '../../../../context/SocialRedirectContext/SocialRedirectContext.js';
49
48
  import '../../../../context/LoadingContext/LoadingContext.js';
@@ -73,6 +72,7 @@ import { Icon } from '../../../../components/Icon/Icon.js';
73
72
  import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
74
73
  import { IconButton } from '../../../../components/IconButton/IconButton.js';
75
74
  import '../../../../components/MenuList/Dropdown/Dropdown.js';
75
+ import { Image } from '../../../../components/Image/Image.js';
76
76
  import { TypographyButton } from '../../../../components/TypographyButton/TypographyButton.js';
77
77
  import 'formik';
78
78
  import '../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
@@ -98,18 +98,19 @@ import '../../../../components/InlineWidget/InlineWidget.js';
98
98
  import '../../../../components/IsBrowser/IsBrowser.js';
99
99
  import '../../../../components/Popper/Popper/Popper.js';
100
100
  import '../../../../components/Popper/PopperContext/PopperContext.js';
101
- import { getExchangeRates } from '../../../../data/api/exchangeRates/exchangeRates.js';
102
101
  import { FormattedInput } from './FormattedInput/FormattedInput.js';
103
102
  import { createFormattedInputEmitter } from './FormattedInput/formattedInputEmitter.js';
104
103
  import { TokenSelectScreen } from './TokenSelectScreen/TokenSelectScreen.js';
105
104
  import { UNAVAILABLE_VALUE } from './consts.js';
106
105
  import { convertFromFiat, convertToFiat } from './utils/convert/convert.js';
107
106
  import { formatValue } from './utils/formatValue/formatValue.js';
108
- import { isFiatToken } from './utils/isFiatToken/isFiatToken.js';
107
+ import { isFiatOrStablecoin, isFiatToken } from './utils/isFiatToken/isFiatToken.js';
109
108
  import { isNonZero } from './utils/isNonZero/isNonZero.js';
110
109
  import { respectsMinimum } from './utils/respectsMinimum/respectsMinimum.js';
110
+ import { useExchangeRatesForFunding } from './utils/useExchangeRatesForFunding/useExchangeRatesForFunding.js';
111
111
  import { useSubmitExternalWalletFunding } from './utils/useSubmitExternalWalletFunding/useSubmitExternalWalletFunding.js';
112
112
  import { useTokensForFunding } from './utils/useTokensForFunding/useTokensForFunding.js';
113
+ import { calculateFiatBalance } from './utils/calculateFiatBalance/calculateFiatBalance.js';
113
114
 
114
115
  const defaultQuickSuggestions = {
115
116
  token: 'USD',
@@ -119,7 +120,7 @@ const rulesThatHideQuickSuggestions = ['exact', 'minimum'];
119
120
  const rulesThatDisableTokenSelect = ['exact', 'exact-with-amount'];
120
121
  const inputEmitter = createFormattedInputEmitter();
121
122
  const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialTokenRaw, externalWallet, quickSuggestions = defaultQuickSuggestions, }) => {
122
- var _a, _b, _c, _d, _e, _f;
123
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
123
124
  // For now we hardcode the default value, soon we will fetch this from project settings
124
125
  const initialToken = initialTokenRaw !== null && initialTokenRaw !== void 0 ? initialTokenRaw : {
125
126
  rule: 'recommended',
@@ -142,10 +143,9 @@ const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialToken
142
143
  const { isLoading: tokenBalancesLoading, tokens: tokenBalances } = useTokensForFunding({
143
144
  wallet: externalWallet,
144
145
  });
145
- const { data: exchangeRates } = usePromise(getExchangeRates, {
146
- initialData: {},
146
+ const exchangeRates = useExchangeRatesForFunding({
147
147
  // Initialize amounts after exchange rates are fetched
148
- onResolve: (exchangeRates) => {
148
+ onFetch: (exchangeRates) => {
149
149
  if (tokenAmount === undefined && fiatAmount !== undefined) {
150
150
  setTokenAmount(convertFromFiat(fiatAmount, tokenSymbol, exchangeRates));
151
151
  }
@@ -153,37 +153,44 @@ const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialToken
153
153
  setFiatAmount(convertToFiat(tokenAmount, tokenSymbol, exchangeRates));
154
154
  }
155
155
  },
156
+ tokenBalances,
156
157
  });
157
158
  const [tokenAmount, setTokenAmount] = useState(isInitialAmountValueForToken
158
159
  ? (_a = initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.value.toString()) !== null && _a !== void 0 ? _a : ''
159
160
  : convertFromFiat((_b = initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.value.toString()) !== null && _b !== void 0 ? _b : '', initialToken.value, exchangeRates));
160
161
  const [tokenSymbol, _setTokenSymbol] = useState(initialToken.value);
161
- const setTokenSymbol = (symbol) => {
162
+ const [fiatAmount, setFiatAmount] = useState(isInitialAmountValueForToken
163
+ ? convertToFiat(tokenAmount !== null && tokenAmount !== void 0 ? tokenAmount : '', tokenSymbol, exchangeRates)
164
+ : (_c = initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.value.toString()) !== null && _c !== void 0 ? _c : '');
165
+ const setTokenSymbol = useCallback((symbol) => {
162
166
  setHasUserInteracted(true);
163
167
  _setTokenSymbol(symbol);
164
168
  if (fiatAmount)
165
169
  setTokenAmount(convertFromFiat(fiatAmount, symbol, exchangeRates));
166
- };
167
- const [fiatAmount, setFiatAmount] = useState(isInitialAmountValueForToken
168
- ? convertToFiat(tokenAmount !== null && tokenAmount !== void 0 ? tokenAmount : '', tokenSymbol, exchangeRates)
169
- : (_c = initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.value.toString()) !== null && _c !== void 0 ? _c : '');
170
+ }, [fiatAmount, exchangeRates]);
170
171
  // When we eventually allow changing this, add setter as _setFiatSymbol
171
172
  // And then create a setFiatSymbol function similar to how we have setTokenSymbol
172
173
  const [fiatSymbol] = useState('USD');
173
- const setAmountsByTokenValue = (amount) => {
174
+ const setAmountsByTokenValue = useCallback((amount) => {
174
175
  setTokenAmount(amount);
175
176
  setFiatAmount(convertToFiat(amount, tokenSymbol, exchangeRates));
176
- };
177
- const setAmountsByFiatValue = (amount) => {
177
+ }, [tokenSymbol, exchangeRates]);
178
+ const setAmountsByFiatValue = useCallback((amount) => {
178
179
  setFiatAmount(amount);
179
180
  setTokenAmount(convertFromFiat(amount, tokenSymbol, exchangeRates));
180
- };
181
+ }, [tokenSymbol, exchangeRates]);
181
182
  const [showTokenAsPrimary, setShowTokenAsPrimary] = useState(false);
182
- const switchPrimaryAndSecondary = () => {
183
+ const switchPrimaryAndSecondary = useCallback(() => {
183
184
  setHasUserInteracted(true);
184
185
  setShowTokenAsPrimary(!showTokenAsPrimary);
186
+ if (tokenAmount && isNaN(parseFloat(tokenAmount))) {
187
+ setTokenAmount('');
188
+ }
189
+ if (fiatAmount && isNaN(parseFloat(fiatAmount))) {
190
+ setFiatAmount('');
191
+ }
185
192
  inputEmitter.emit('focus');
186
- };
193
+ }, [fiatAmount, showTokenAsPrimary, tokenAmount]);
187
194
  const isMinimumRespected = minimum
188
195
  ? respectsMinimum({ token: fiatSymbol, value: fiatAmount !== null && fiatAmount !== void 0 ? fiatAmount : '' }, minimum, exchangeRates)
189
196
  : true;
@@ -205,9 +212,10 @@ const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialToken
205
212
  { amount: tokenAmount, symbol: tokenSymbol },
206
213
  ];
207
214
  const secondaryDisplay = formatValue({
215
+ maxDecimals: isFiatOrStablecoin(secondaryData.symbol) ? 2 : undefined,
208
216
  symbol: secondaryData.symbol,
209
217
  value: secondaryData.amount,
210
- withFixedZeros: isFiatToken(secondaryData.symbol) || secondaryData.symbol === 'USDC',
218
+ withFixedZeros: isFiatOrStablecoin(secondaryData.symbol),
211
219
  });
212
220
  const quickSuggestionsWithToken = Array.isArray(quickSuggestions)
213
221
  ? { token: 'USD', values: quickSuggestions }
@@ -222,10 +230,33 @@ const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialToken
222
230
  value,
223
231
  }))
224
232
  .filter(({ display }) => display !== undefined);
225
- const balanceNumber = (_e = (_d = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find(({ symbol }) => symbol === tokenSymbol)) === null || _d === void 0 ? void 0 : _d.balance) !== null && _e !== void 0 ? _e : 0;
226
- const showNotEnoughBalance = Boolean(isNonZero(tokenAmount) &&
227
- tokenAmount !== undefined &&
228
- balanceNumber < parseFloat(tokenAmount));
233
+ const currentToken = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find(({ symbol }) => symbol === tokenSymbol);
234
+ const fiatBalance = calculateFiatBalance(currentToken, exchangeRates);
235
+ const [primaryBalance, secondaryBalance] = showTokenAsPrimary
236
+ ? [
237
+ {
238
+ symbol: tokenSymbol,
239
+ value: (_d = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _d !== void 0 ? _d : 0,
240
+ },
241
+ {
242
+ symbol: fiatSymbol,
243
+ value: fiatBalance,
244
+ },
245
+ ]
246
+ : [
247
+ {
248
+ symbol: fiatSymbol,
249
+ value: fiatBalance,
250
+ },
251
+ {
252
+ symbol: tokenSymbol,
253
+ value: (_e = currentToken === null || currentToken === void 0 ? void 0 : currentToken.balance) !== null && _e !== void 0 ? _e : 0,
254
+ },
255
+ ];
256
+ const showNotEnoughBalance = Boolean(!currentToken ||
257
+ (isNonZero(tokenAmount) &&
258
+ tokenAmount !== undefined &&
259
+ currentToken.balance < parseFloat(tokenAmount)));
229
260
  const showMinimumRequired = Boolean(!isMinimumRespected && !showNotEnoughBalance);
230
261
  const showQuickSuggestions = quickSuggestionsParsed.length > 0 &&
231
262
  !hasUserInteracted &&
@@ -234,59 +265,81 @@ const ReceiveExternalWalletFunds = ({ amount: initialAmount, token: initialToken
234
265
  isFiatToken(quickSuggestionsWithToken.token));
235
266
  const disableTokenSelect = rulesThatDisableTokenSelect.includes(initialToken.rule);
236
267
  const [showTokenSelect, setShowTokenSelect] = useState(false);
237
- const handleSelectToken = (token) => {
268
+ const handleSelectToken = useCallback((token) => {
238
269
  setTokenSymbol(token);
239
270
  setShowTokenSelect(false);
240
- };
241
- const handleQuickSuggestion = (value) => {
271
+ }, [setTokenSymbol]);
272
+ const handleQuickSuggestion = useCallback((value) => {
242
273
  setHasUserInteracted(true);
243
274
  if (isFiatToken(quickSuggestionsWithToken.token))
244
275
  setAmountsByFiatValue(value.toString());
245
276
  else
246
277
  setAmountsByTokenValue(value.toString());
247
278
  inputEmitter.emit('focus');
248
- };
279
+ }, [
280
+ quickSuggestionsWithToken.token,
281
+ setAmountsByFiatValue,
282
+ setAmountsByTokenValue,
283
+ ]);
249
284
  const handleSubmit = useSubmitExternalWalletFunding();
285
+ const disableSubmit = !isMinimumRespected || showNotEnoughBalance || !isNonZero(tokenAmount);
286
+ const closeTokenSelect = useCallback(() => {
287
+ setShowTokenSelect(false);
288
+ inputEmitter.emit('focus');
289
+ }, []);
290
+ const grayOutSecondaryDisplay = !isNonZero(secondaryData.amount) ||
291
+ (isFiatOrStablecoin(secondaryData.symbol) &&
292
+ parseFloat((_f = secondaryData.amount) !== null && _f !== void 0 ? _f : '0') < 0.0099);
250
293
  const inputSymbolProp = primaryData.symbol === 'USD'
251
294
  ? { leading: '$' }
252
295
  : { trailing: primaryData.symbol };
253
296
  const backButton = (jsx(IconButton, { type: 'button', id: 'back-button', "data-testid": 'back-button', onClick: () => setDynamicWidgetView('choose-wallet-funding-method'), children: jsx(SvgArrowLeft, {}) }));
254
- return (jsxs("div", { className: 'fund-from-wallet', children: [!disableTokenSelect && (jsx(TokenSelectScreen, { onClose: () => setShowTokenSelect(false), onSelectToken: handleSelectToken, tokens: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : [], currentToken: tokenSymbol, className: classNames('fund-from-wallet__token-select', {
297
+ return (jsxs("div", { className: 'fund-from-wallet', children: [!disableTokenSelect && (jsx(TokenSelectScreen, { onClose: closeTokenSelect, onSelectToken: handleSelectToken, tokens: tokenBalances !== null && tokenBalances !== void 0 ? tokenBalances : [], currentToken: tokenSymbol, className: classNames('fund-from-wallet__token-select', {
255
298
  'fund-from-wallet__token-select--open': showTokenSelect,
256
- }) })), jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', children: t('dyn_wallet_funding.from_external_wallet.funding_view.title') }) }), jsxs("div", { className: 'fund-from-wallet__content', children: [jsxs("div", { className: 'fund-from-wallet__content__amount-container', children: [minimum && (jsx(Typography, { color: 'error-1', className: classNames('fund-from-wallet__content__amount-container__minimum-error', {
299
+ }), showTokenAsPrimary: showTokenAsPrimary, exchangeRates: exchangeRates })), jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', children: t('dyn_wallet_funding.from_external_wallet.funding_view.title') }) }), jsxs("div", { className: 'fund-from-wallet__content', children: [jsxs("div", { className: 'fund-from-wallet__content__amount-container', children: [minimum && (jsx(Typography, { color: 'error-1', className: classNames('fund-from-wallet__content__amount-container__minimum-error', {
257
300
  'fund-from-wallet__content__amount-container__minimum-error--visible': showMinimumRequired,
258
- }), variant: 'body_normal', children: t('dyn_wallet_funding.from_external_wallet.funding_view.minimum_error', {
301
+ }), variant: 'body_normal', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.funding_view.minimum_error', {
259
302
  minimum: formatValue({
260
303
  symbol: minimum.token,
261
304
  value: minimum.value,
262
305
  }),
263
306
  }) })), primaryData.amount !== undefined && (jsx(FormattedInput, Object.assign({ className: 'fund-from-wallet__content__amount-container__amount', value: (initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.rule) === 'exact'
264
- ? (_f = formatValue({
265
- maxDecimals: 8,
307
+ ? (_g = formatValue({
308
+ maxDecimals: isFiatOrStablecoin(primaryData.symbol)
309
+ ? 2
310
+ : 8,
266
311
  symbol: undefined,
267
312
  value: primaryData.amount,
268
- withFixedZeros: isFiatToken(primaryData.symbol) ||
269
- primaryData.symbol === 'USDC',
270
- })) !== null && _f !== void 0 ? _f : primaryData.amount
313
+ withFixedZeros: isFiatOrStablecoin(primaryData.symbol),
314
+ })) !== null && _g !== void 0 ? _g : primaryData.amount
271
315
  : primaryData.amount, onChange: primaryData.setAmount, emitter: inputEmitter, onInteraction: () => setHasUserInteracted(true), locked: (initialAmount === null || initialAmount === void 0 ? void 0 : initialAmount.rule) === 'exact' }, inputSymbolProp))), primaryData.amount === undefined && (jsx(Skeleton, { dataTestId: 'primary-amount-skeleton', container: {
272
316
  className: 'fund-from-wallet__content__amount-container__skeleton',
273
- } })), showQuickSuggestions && (jsx("div", { className: 'fund-from-wallet__content__amount-container__quick-suggestions', children: quickSuggestionsParsed.map(({ display, value }) => (jsx(Typography, { variant: 'body_small', color: 'secondary', onClick: () => handleQuickSuggestion(value), children: display }, value))) })), !showQuickSuggestions && secondaryDisplay && (jsxs("div", { className: 'fund-from-wallet__content__amount-container__secondary-amount-container', children: [jsx(Typography, { weight: 'medium', className: classNames('fund-from-wallet__content__amount-container__secondary-amount-container__amount', {
274
- 'fund-from-wallet__content__amount-container__secondary-amount-container__amount--zero': !isNonZero(secondaryData.amount),
317
+ } })), showQuickSuggestions && (jsx("div", { className: 'fund-from-wallet__content__amount-container__quick-suggestions', children: quickSuggestionsParsed.map(({ display, value }) => (jsx(Typography, { variant: 'body_small', color: 'secondary', onClick: () => handleQuickSuggestion(value), weight: 'medium', children: display }, value))) })), !showQuickSuggestions && secondaryDisplay && (jsxs("div", { className: 'fund-from-wallet__content__amount-container__secondary-amount-container', children: [(currentToken === null || currentToken === void 0 ? void 0 : currentToken.logoURI) ? (jsx(Image, { dataTestId: 'token-icon', alt: tokenSymbol, src: currentToken.logoURI, className: 'fund-from-wallet__content__token-icon' })) : null, jsx(Typography, { weight: 'medium', className: classNames('fund-from-wallet__content__amount-container__secondary-amount-container__amount', {
318
+ 'fund-from-wallet__content__amount-container__secondary-amount-container__amount--grayed-out': grayOutSecondaryDisplay,
275
319
  }), children: secondaryDisplay }), jsx(Icon, { size: 'small', color: 'text-secondary', className: 'fund-from-wallet__content__amount-container__secondary-amount-container__switch', children: jsx(SvgSwitchToggle, { "data-testid": 'switch-primary-and-secondary', onClick: switchPrimaryAndSecondary }) })] })), !showQuickSuggestions && !secondaryDisplay && (jsxs("div", { className: 'fund-from-wallet__content__amount-container__secondary-missing', children: [jsx(Typography, { weight: 'medium', children: formatValue({
276
320
  symbol: secondaryData.symbol,
277
321
  value: UNAVAILABLE_VALUE,
278
- }) }), jsx("div", { ref: setConversionErrorIconRef, children: jsx(Icon, { size: 'medium', color: 'text-tertiary', children: jsx(SvgFooterInfoIcon, {}) }) }), jsx(Tooltip, { content: t('dyn_wallet_funding.from_external_wallet.funding_view.network_conversion_error'), targetRef: conversionErrorIconRef, className: 'fund-from-wallet__content__amount-container__secondary-missing__tooltip' })] })), jsx(Typography, { color: 'error-1', className: classNames('fund-from-wallet__content__amount-container__balance-error', {
322
+ }) }), jsx("div", { ref: setConversionErrorIconRef, children: jsx(Icon, { size: 'medium', color: 'text-tertiary', children: jsx(SvgFooterInfoIcon, {}) }) }), jsx(Tooltip, { content: t('dyn_wallet_funding.from_external_wallet.funding_view.pricing_unavailable'), targetRef: conversionErrorIconRef, className: 'fund-from-wallet__content__amount-container__secondary-missing__tooltip' })] })), jsx(Typography, { color: 'error-1', className: classNames('fund-from-wallet__content__amount-container__balance-error', {
279
323
  'fund-from-wallet__content__amount-container__balance-error--visible': showNotEnoughBalance,
280
- }), variant: 'body_normal', children: t('dyn_wallet_funding.from_external_wallet.funding_view.balance_error') })] }), jsxs("div", { className: 'fund-from-wallet__content__wallet-card', children: [jsxs("div", { className: 'fund-from-wallet__content__wallet-card__wallet-details', children: [jsx(WalletIcon, { icon: externalWallet.connector.metadata.icon, walletKey: externalWallet.connector.key, className: 'fund-from-wallet__content__wallet-card__wallet-details__icon' }), jsxs("div", { className: 'fund-from-wallet__content__wallet-card__wallet-details__rows', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', children: t('dyn_wallet_funding.from_external_wallet.funding_view.wallet_detail_from') }), jsx(Typography, { variant: 'body_small', children: shortenWalletAddress(externalWallet.address) })] })] }), tokenBalancesLoading && (jsx(Skeleton, { dataTestId: 'balance-skeleton', container: {
324
+ }), variant: 'body_normal', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.funding_view.balance_error') })] }), jsxs("div", { className: 'fund-from-wallet__content__wallet-card', children: [jsxs("div", { className: 'fund-from-wallet__content__wallet-card__wallet-details', children: [jsx(WalletIcon, { icon: externalWallet.connector.metadata.icon, walletKey: externalWallet.connector.key, className: 'fund-from-wallet__content__wallet-card__wallet-details__icon' }), jsxs("div", { className: 'fund-from-wallet__content__wallet-card__wallet-details__rows', children: [jsx(Typography, { variant: 'body_small', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.funding_view.wallet_detail_from') }), jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'medium', children: shortenWalletAddress(externalWallet.address) })] })] }), tokenBalancesLoading && (jsx(Skeleton, { dataTestId: 'balance-skeleton', container: {
281
325
  className: 'fund-from-wallet__content__wallet-card__balance-skeleton',
282
326
  } })), !tokenBalancesLoading && (jsxs("div", { className: classNames('fund-from-wallet__content__wallet-card__balance', {
283
327
  'fund-from-wallet__content__wallet-card__balance--disable-select': disableTokenSelect,
284
- }), onClick: () => !disableTokenSelect && setShowTokenSelect(true), children: [jsxs("div", { className: 'fund-from-wallet__content__wallet-card__balance__rows', children: [jsx(Typography, { variant: 'body_small', color: 'secondary', weight: 'bold', children: t('dyn_wallet_funding.from_external_wallet.funding_view.balance') }), jsx(Typography, { variant: 'body_small', weight: 'bold', "data-testid": `balance-amount-${tokenSymbol}`, children: formatValue({
285
- maxDecimals: 8,
286
- symbol: tokenSymbol,
287
- value: balanceNumber,
288
- withFixedZeros: isFiatToken(tokenSymbol) || tokenSymbol === 'USDC',
289
- }) })] }), !disableTokenSelect && (jsx(Icon, { color: 'text-tertiary', size: 'small', className: 'fund-from-wallet__content__wallet-card__balance__icon', children: jsx(SvgChevronDown, {}) }))] }))] })] }), jsx(TypographyButton, { dataTestId: 'confirm-button', buttonVariant: 'brand-primary', buttonPadding: 'large', typographyProps: { color: 'white' }, className: 'fund-from-wallet__confirm-button', disabled: !isMinimumRespected || showNotEnoughBalance || !isNonZero(tokenAmount), onClick: () => handleSubmit({
328
+ }), onClick: () => !disableTokenSelect && setShowTokenSelect(true), children: [jsxs("div", { className: 'fund-from-wallet__content__wallet-card__balance__rows', children: [jsx(Typography, { variant: 'body_small', "data-testid": `primary-balance-amount-${primaryBalance.symbol}`, weight: 'medium', children: formatValue({
329
+ maxDecimals: isFiatOrStablecoin(primaryBalance.symbol)
330
+ ? 2
331
+ : 6,
332
+ symbol: primaryBalance.symbol,
333
+ value: (_h = primaryBalance.value) !== null && _h !== void 0 ? _h : UNAVAILABLE_VALUE,
334
+ withFixedZeros: isFiatOrStablecoin(primaryBalance.symbol),
335
+ }) }), jsx(Typography, { variant: 'body_small', "data-testid": `secondary-balance-amount-${secondaryBalance.symbol}`, color: 'secondary', weight: 'medium', children: formatValue({
336
+ maxDecimals: isFiatOrStablecoin(secondaryBalance.symbol)
337
+ ? 2
338
+ : 6,
339
+ symbol: secondaryBalance.symbol,
340
+ value: (_j = secondaryBalance.value) !== null && _j !== void 0 ? _j : UNAVAILABLE_VALUE,
341
+ withFixedZeros: isFiatOrStablecoin(secondaryBalance.symbol),
342
+ }) })] }), !disableTokenSelect && (jsx(Icon, { color: 'text-tertiary', size: 'small', className: 'fund-from-wallet__content__wallet-card__balance__icon', children: jsx(SvgChevronDown, { "data-testid": 'token-select-dropdown' }) }))] }))] })] }), jsx(TypographyButton, { dataTestId: 'confirm-button', buttonVariant: 'brand-primary', buttonPadding: 'large', typographyProps: { color: 'white' }, className: 'fund-from-wallet__confirm-button', disabled: disableSubmit, onClick: () => handleSubmit({
290
343
  externalWallet,
291
344
  tokenAmount,
292
345
  tokenBalances,
@@ -4,8 +4,6 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var reactI18next = require('react-i18next');
8
- var Image = require('../../../../../../components/Image/Image.cjs');
9
7
  var classNames = require('../../../../../../utils/functions/classNames/classNames.cjs');
10
8
  require('../../../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
11
9
  require('../../../../../../components/Alert/Alert.cjs');
@@ -56,6 +54,7 @@ require('../../../../../../context/UserFieldEditorContext/UserFieldEditorContext
56
54
  require('@dynamic-labs/rpc-providers');
57
55
  require('../../../../../../store/state/loadingAndLifecycle.cjs');
58
56
  require('../../../../../../store/state/walletOptions/walletOptions.cjs');
57
+ require('react-i18next');
59
58
  var Typography = require('../../../../../../components/Typography/Typography.cjs');
60
59
  require('../../../../../../context/FooterAnimationContext/index.cjs');
61
60
  require('../../../../../../components/ShadowDOM/ShadowDOM.cjs');
@@ -69,6 +68,7 @@ require('react-focus-lock');
69
68
  require('../../../../context/DynamicWidgetContext.cjs');
70
69
  require('../../../../../../components/IconButton/IconButton.cjs');
71
70
  require('../../../../../../components/MenuList/Dropdown/Dropdown.cjs');
71
+ var Image = require('../../../../../../components/Image/Image.cjs');
72
72
  require('formik');
73
73
  require('../../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
74
74
  require('../../../../../../store/state/sendBalances.cjs');
@@ -93,18 +93,29 @@ require('../../../../../../components/InlineWidget/InlineWidget.cjs');
93
93
  require('../../../../../../components/IsBrowser/IsBrowser.cjs');
94
94
  require('../../../../../../components/Popper/Popper/Popper.cjs');
95
95
  require('../../../../../../components/Popper/PopperContext/PopperContext.cjs');
96
+ var calculateFiatBalance = require('../../utils/calculateFiatBalance/calculateFiatBalance.cjs');
96
97
  var formatValue = require('../../utils/formatValue/formatValue.cjs');
98
+ var isFiatToken = require('../../utils/isFiatToken/isFiatToken.cjs');
97
99
 
98
- const TokenOption = ({ token, isSelected, onSelect, }) => {
99
- const { t } = reactI18next.useTranslation();
100
+ const TokenOption = ({ token, isSelected, onSelect, showTokenAsPrimary, exchangeRates, }) => {
101
+ const fiatBalance = formatValue.formatValue({
102
+ maxDecimals: 2,
103
+ symbol: 'USD',
104
+ value: calculateFiatBalance.calculateFiatBalance(token, exchangeRates),
105
+ withFixedZeros: true,
106
+ });
107
+ const tokenBalance = formatValue.formatValue({
108
+ maxDecimals: isFiatToken.isFiatOrStablecoin(token.symbol) ? 2 : 6,
109
+ symbol: token.symbol,
110
+ value: token.balance,
111
+ withFixedZeros: isFiatToken.isFiatOrStablecoin(token.symbol),
112
+ });
113
+ const [primaryBalance, secondaryBalance] = showTokenAsPrimary
114
+ ? [tokenBalance, fiatBalance]
115
+ : [fiatBalance, tokenBalance];
100
116
  return (jsxRuntime.jsxs("div", { className: classNames.classNames('token-option', {
101
117
  'token-option--selected': isSelected,
102
- }), onClick: onSelect, "data-testid": `token-option-${token.symbol}`, children: [token.logoURI ? (jsxRuntime.jsx(Image.Image, { src: token.logoURI, alt: token.symbol, className: 'token-option__icon', dataTestId: 'token-option-icon' })) : (jsxRuntime.jsx("div", { className: 'token-option__icon--skeleton', "data-testid": 'token-option__icon--skeleton' })), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', className: 'token-option__name', children: token.name }), jsxRuntime.jsxs("div", { className: 'token-option__balance-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', className: 'token-option__balance-label', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.token_option.balance_label') }), jsxRuntime.jsx("div", { className: 'token-option__balance-container__balance-value-container', children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', children: formatValue.formatValue({
103
- maxDecimals: 8,
104
- symbol: token.symbol,
105
- value: token.balance,
106
- withFixedZeros: token.symbol === 'USDC',
107
- }) }) })] })] }));
118
+ }), onClick: onSelect, "data-testid": `token-option-${token.symbol}`, children: [token.logoURI ? (jsxRuntime.jsx(Image.Image, { src: token.logoURI, alt: token.symbol, className: 'token-option__icon', dataTestId: 'token-option-icon' })) : (jsxRuntime.jsx("div", { className: 'token-option__icon--skeleton', "data-testid": 'token-option__icon--skeleton' })), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', className: 'token-option__name', children: token.name }), jsxRuntime.jsxs("div", { className: 'token-option__balance-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'medium', "data-testid": 'token-option__primary-balance', children: primaryBalance }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'token-option__secondary-balance', children: secondaryBalance })] })] }));
108
119
  };
109
120
 
110
121
  exports.TokenOption = TokenOption;
@@ -4,6 +4,8 @@ type TokenOptionProps = {
4
4
  token: FundingTokenData;
5
5
  isSelected: boolean;
6
6
  onSelect: () => void;
7
+ showTokenAsPrimary: boolean;
8
+ exchangeRates: Record<string, number>;
7
9
  };
8
10
  export declare const TokenOption: FC<TokenOptionProps>;
9
11
  export {};
@@ -1,7 +1,5 @@
1
1
  'use client'
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useTranslation } from 'react-i18next';
4
- import { Image } from '../../../../../../components/Image/Image.js';
5
3
  import { classNames } from '../../../../../../utils/functions/classNames/classNames.js';
6
4
  import '../../../../../../components/Accordion/components/AccordionItem/AccordionItem.js';
7
5
  import '../../../../../../components/Alert/Alert.js';
@@ -52,6 +50,7 @@ import '../../../../../../context/UserFieldEditorContext/UserFieldEditorContext.
52
50
  import '@dynamic-labs/rpc-providers';
53
51
  import '../../../../../../store/state/loadingAndLifecycle.js';
54
52
  import '../../../../../../store/state/walletOptions/walletOptions.js';
53
+ import 'react-i18next';
55
54
  import { Typography } from '../../../../../../components/Typography/Typography.js';
56
55
  import '../../../../../../context/FooterAnimationContext/index.js';
57
56
  import '../../../../../../components/ShadowDOM/ShadowDOM.js';
@@ -65,6 +64,7 @@ import 'react-focus-lock';
65
64
  import '../../../../context/DynamicWidgetContext.js';
66
65
  import '../../../../../../components/IconButton/IconButton.js';
67
66
  import '../../../../../../components/MenuList/Dropdown/Dropdown.js';
67
+ import { Image } from '../../../../../../components/Image/Image.js';
68
68
  import 'formik';
69
69
  import '../../../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
70
70
  import '../../../../../../store/state/sendBalances.js';
@@ -89,18 +89,29 @@ import '../../../../../../components/InlineWidget/InlineWidget.js';
89
89
  import '../../../../../../components/IsBrowser/IsBrowser.js';
90
90
  import '../../../../../../components/Popper/Popper/Popper.js';
91
91
  import '../../../../../../components/Popper/PopperContext/PopperContext.js';
92
+ import { calculateFiatBalance } from '../../utils/calculateFiatBalance/calculateFiatBalance.js';
92
93
  import { formatValue } from '../../utils/formatValue/formatValue.js';
94
+ import { isFiatOrStablecoin } from '../../utils/isFiatToken/isFiatToken.js';
93
95
 
94
- const TokenOption = ({ token, isSelected, onSelect, }) => {
95
- const { t } = useTranslation();
96
+ const TokenOption = ({ token, isSelected, onSelect, showTokenAsPrimary, exchangeRates, }) => {
97
+ const fiatBalance = formatValue({
98
+ maxDecimals: 2,
99
+ symbol: 'USD',
100
+ value: calculateFiatBalance(token, exchangeRates),
101
+ withFixedZeros: true,
102
+ });
103
+ const tokenBalance = formatValue({
104
+ maxDecimals: isFiatOrStablecoin(token.symbol) ? 2 : 6,
105
+ symbol: token.symbol,
106
+ value: token.balance,
107
+ withFixedZeros: isFiatOrStablecoin(token.symbol),
108
+ });
109
+ const [primaryBalance, secondaryBalance] = showTokenAsPrimary
110
+ ? [tokenBalance, fiatBalance]
111
+ : [fiatBalance, tokenBalance];
96
112
  return (jsxs("div", { className: classNames('token-option', {
97
113
  'token-option--selected': isSelected,
98
- }), onClick: onSelect, "data-testid": `token-option-${token.symbol}`, children: [token.logoURI ? (jsx(Image, { src: token.logoURI, alt: token.symbol, className: 'token-option__icon', dataTestId: 'token-option-icon' })) : (jsx("div", { className: 'token-option__icon--skeleton', "data-testid": 'token-option__icon--skeleton' })), jsx(Typography, { variant: 'body_normal', className: 'token-option__name', children: token.name }), jsxs("div", { className: 'token-option__balance-container', children: [jsx(Typography, { variant: 'body_small', className: 'token-option__balance-label', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.token_option.balance_label') }), jsx("div", { className: 'token-option__balance-container__balance-value-container', children: jsx(Typography, { weight: 'medium', variant: 'body_small', children: formatValue({
99
- maxDecimals: 8,
100
- symbol: token.symbol,
101
- value: token.balance,
102
- withFixedZeros: token.symbol === 'USDC',
103
- }) }) })] })] }));
114
+ }), onClick: onSelect, "data-testid": `token-option-${token.symbol}`, children: [token.logoURI ? (jsx(Image, { src: token.logoURI, alt: token.symbol, className: 'token-option__icon', dataTestId: 'token-option-icon' })) : (jsx("div", { className: 'token-option__icon--skeleton', "data-testid": 'token-option__icon--skeleton' })), jsx(Typography, { variant: 'body_normal', className: 'token-option__name', children: token.name }), jsxs("div", { className: 'token-option__balance-container', children: [jsx(Typography, { variant: 'body_small', weight: 'medium', "data-testid": 'token-option__primary-balance', children: primaryBalance }), jsx(Typography, { weight: 'medium', variant: 'body_small', color: 'secondary', "data-testid": 'token-option__secondary-balance', children: secondaryBalance })] })] }));
104
115
  };
105
116
 
106
117
  export { TokenOption };
@@ -81,6 +81,7 @@ require('../../../../../components/OverlayCard/OverlayCard.cjs');
81
81
  require('../../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
82
82
  require('../../../../../context/PasskeyContext/PasskeyContext.cjs');
83
83
  require('../../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
84
+ var LinearGradientFrame = require('../../../../../components/LinearGradientFrame/LinearGradientFrame.cjs');
84
85
  require('../../../../../context/OnrampContext/OnrampContext.cjs');
85
86
  require('qrcode');
86
87
  require('../ReceiveExternalWalletFunds.cjs');
@@ -97,10 +98,9 @@ require('../../../../../components/InlineWidget/InlineWidget.cjs');
97
98
  require('../../../../../components/IsBrowser/IsBrowser.cjs');
98
99
  require('../../../../../components/Popper/Popper/Popper.cjs');
99
100
  require('../../../../../components/Popper/PopperContext/PopperContext.cjs');
100
- var LinearGradientFrame = require('../../../../../components/LinearGradientFrame/LinearGradientFrame.cjs');
101
101
  var TokenOption = require('./TokenOption/TokenOption.cjs');
102
102
 
103
- const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, className, style, }) => {
103
+ const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, className, style, showTokenAsPrimary, exchangeRates, }) => {
104
104
  const { t } = reactI18next.useTranslation();
105
105
  const [search$1, setSearch] = React.useState('');
106
106
  const filteredTokens = tokens.filter((token) => {
@@ -114,7 +114,7 @@ const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, class
114
114
  const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', id: 'close-button', "data-testid": 'close-button', onClick: onClose, children: jsxRuntime.jsx(close.ReactComponent, {}) }));
115
115
  return (jsxRuntime.jsxs("div", { className: classNames.classNames('token-select', className), style: style, "data-testid": 'token-select', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', children: t(noAssets
116
116
  ? 'dyn_wallet_funding.from_external_wallet.token_select.no_assets_title'
117
- : 'dyn_wallet_funding.from_external_wallet.token_select.title') }) }), noAssets && (jsxRuntime.jsxs("div", { className: 'token-select__no-assets', children: [jsxRuntime.jsx(LinearGradientFrame.LinearGradientFrame, { Icon: jsxRuntime.jsx(walletIllustration.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.no_assets_description') })] })), !noAssets && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("label", { htmlFor: 'token-select-search', className: 'token-select__search', children: [jsxRuntime.jsx(Icon.Icon, { color: 'text-tertiary', size: 'small', children: jsxRuntime.jsx(search.ReactComponent, {}) }), jsxRuntime.jsx("input", { id: 'token-select-search', placeholder: t('dyn_wallet_funding.from_external_wallet.token_select.search_placeholder'), className: 'token-select__search__input', value: search$1, onChange: (e) => setSearch(e.target.value) })] }), jsxRuntime.jsx("div", { className: 'token-select__tokens', children: filteredTokens.map((token) => (jsxRuntime.jsx(TokenOption.TokenOption, { token: token, isSelected: token.symbol === currentToken, onSelect: () => onSelectToken(token.symbol) }, token.symbol))) })] }))] }));
117
+ : 'dyn_wallet_funding.from_external_wallet.token_select.title') }) }), noAssets && (jsxRuntime.jsxs("div", { className: 'token-select__no-assets', children: [jsxRuntime.jsx(LinearGradientFrame.LinearGradientFrame, { Icon: jsxRuntime.jsx(walletIllustration.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.no_assets_description') })] })), !noAssets && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("label", { htmlFor: 'token-select-search', className: 'token-select__search', children: [jsxRuntime.jsx(Icon.Icon, { color: 'text-tertiary', size: 'small', children: jsxRuntime.jsx(search.ReactComponent, {}) }), jsxRuntime.jsx("input", { id: 'token-select-search', placeholder: t('dyn_wallet_funding.from_external_wallet.token_select.search_placeholder'), className: 'token-select__search__input', value: search$1, onChange: (e) => setSearch(e.target.value) })] }), jsxRuntime.jsx("div", { className: 'token-select__tokens', children: filteredTokens.map((token) => (jsxRuntime.jsx(TokenOption.TokenOption, { token: token, isSelected: token.symbol === currentToken, onSelect: () => onSelectToken(token.symbol), showTokenAsPrimary: showTokenAsPrimary, exchangeRates: exchangeRates }, token.symbol))) })] }))] }));
118
118
  };
119
119
 
120
120
  exports.TokenSelectScreen = TokenSelectScreen;
@@ -6,6 +6,8 @@ type TokenSelectScreenProps = ClassStyleProps & {
6
6
  onSelectToken: (token: FundingTokenData['symbol']) => void;
7
7
  tokens: FundingTokenData[];
8
8
  currentToken: FundingTokenData['symbol'];
9
+ showTokenAsPrimary: boolean;
10
+ exchangeRates: Record<string, number>;
9
11
  };
10
12
  export declare const TokenSelectScreen: FC<TokenSelectScreenProps>;
11
13
  export {};
@@ -77,6 +77,7 @@ import '../../../../../components/OverlayCard/OverlayCard.js';
77
77
  import '../../../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
78
78
  import '../../../../../context/PasskeyContext/PasskeyContext.js';
79
79
  import '../../ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
80
+ import { LinearGradientFrame } from '../../../../../components/LinearGradientFrame/LinearGradientFrame.js';
80
81
  import '../../../../../context/OnrampContext/OnrampContext.js';
81
82
  import 'qrcode';
82
83
  import '../ReceiveExternalWalletFunds.js';
@@ -93,10 +94,9 @@ import '../../../../../components/InlineWidget/InlineWidget.js';
93
94
  import '../../../../../components/IsBrowser/IsBrowser.js';
94
95
  import '../../../../../components/Popper/Popper/Popper.js';
95
96
  import '../../../../../components/Popper/PopperContext/PopperContext.js';
96
- import { LinearGradientFrame } from '../../../../../components/LinearGradientFrame/LinearGradientFrame.js';
97
97
  import { TokenOption } from './TokenOption/TokenOption.js';
98
98
 
99
- const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, className, style, }) => {
99
+ const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, className, style, showTokenAsPrimary, exchangeRates, }) => {
100
100
  const { t } = useTranslation();
101
101
  const [search, setSearch] = useState('');
102
102
  const filteredTokens = tokens.filter((token) => {
@@ -110,7 +110,7 @@ const TokenSelectScreen = ({ onClose, onSelectToken, currentToken, tokens, class
110
110
  const closeButton = (jsx(IconButton, { type: 'button', id: 'close-button', "data-testid": 'close-button', onClick: onClose, children: jsx(SvgClose, {}) }));
111
111
  return (jsxs("div", { className: classNames('token-select', className), style: style, "data-testid": 'token-select', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { variant: 'title', children: t(noAssets
112
112
  ? 'dyn_wallet_funding.from_external_wallet.token_select.no_assets_title'
113
- : 'dyn_wallet_funding.from_external_wallet.token_select.title') }) }), noAssets && (jsxs("div", { className: 'token-select__no-assets', children: [jsx(LinearGradientFrame, { Icon: jsx(SvgWalletIllustration, {}) }), jsx(Typography, { variant: 'title', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.no_assets_description') })] })), !noAssets && (jsxs(Fragment, { children: [jsxs("label", { htmlFor: 'token-select-search', className: 'token-select__search', children: [jsx(Icon, { color: 'text-tertiary', size: 'small', children: jsx(SvgSearch, {}) }), jsx("input", { id: 'token-select-search', placeholder: t('dyn_wallet_funding.from_external_wallet.token_select.search_placeholder'), className: 'token-select__search__input', value: search, onChange: (e) => setSearch(e.target.value) })] }), jsx("div", { className: 'token-select__tokens', children: filteredTokens.map((token) => (jsx(TokenOption, { token: token, isSelected: token.symbol === currentToken, onSelect: () => onSelectToken(token.symbol) }, token.symbol))) })] }))] }));
113
+ : 'dyn_wallet_funding.from_external_wallet.token_select.title') }) }), noAssets && (jsxs("div", { className: 'token-select__no-assets', children: [jsx(LinearGradientFrame, { Icon: jsx(SvgWalletIllustration, {}) }), jsx(Typography, { variant: 'title', color: 'secondary', weight: 'medium', children: t('dyn_wallet_funding.from_external_wallet.token_select.no_assets_description') })] })), !noAssets && (jsxs(Fragment, { children: [jsxs("label", { htmlFor: 'token-select-search', className: 'token-select__search', children: [jsx(Icon, { color: 'text-tertiary', size: 'small', children: jsx(SvgSearch, {}) }), jsx("input", { id: 'token-select-search', placeholder: t('dyn_wallet_funding.from_external_wallet.token_select.search_placeholder'), className: 'token-select__search__input', value: search, onChange: (e) => setSearch(e.target.value) })] }), jsx("div", { className: 'token-select__tokens', children: filteredTokens.map((token) => (jsx(TokenOption, { token: token, isSelected: token.symbol === currentToken, onSelect: () => onSelectToken(token.symbol), showTokenAsPrimary: showTokenAsPrimary, exchangeRates: exchangeRates }, token.symbol))) })] }))] }));
114
114
  };
115
115
 
116
116
  export { TokenSelectScreen };
@@ -3,7 +3,9 @@ export type FundingTokenData = {
3
3
  name: string;
4
4
  symbol: string;
5
5
  balance: number;
6
+ fiatBalance: number | undefined;
6
7
  logoURI: string | undefined;
8
+ price?: number;
7
9
  token: 'native' | {
8
10
  address: string;
9
11
  decimals?: number;
@@ -0,0 +1,27 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var isFiatToken = require('../isFiatToken/isFiatToken.cjs');
7
+
8
+ const calculateFiatBalance = (token, exchangeRates) => {
9
+ // If there is no token, return 0 instead of undefined because token is only undefined
10
+ // when and only when user has no balance for it.
11
+ if (!token)
12
+ return 0;
13
+ if (token.fiatBalance)
14
+ return token.fiatBalance;
15
+ // Fixing price to 1 for stablecoins to match user expectation
16
+ if (isFiatToken.isFiatOrStablecoin(token.symbol))
17
+ return token.balance;
18
+ if (token.price)
19
+ return token.balance * token.price;
20
+ if (exchangeRates[token.symbol])
21
+ return token.balance * exchangeRates[token.symbol];
22
+ // Here we return undefined instead of 0 because we know user HAS balance for this token,
23
+ // but we cannot calculate the fiat balance, so show as unavailable.
24
+ return undefined;
25
+ };
26
+
27
+ exports.calculateFiatBalance = calculateFiatBalance;
@@ -0,0 +1,2 @@
1
+ import { FundingTokenData } from '../../types';
2
+ export declare const calculateFiatBalance: (token: FundingTokenData | undefined, exchangeRates: Record<string, number>) => number | undefined;
@@ -0,0 +1,23 @@
1
+ 'use client'
2
+ import { isFiatOrStablecoin } from '../isFiatToken/isFiatToken.js';
3
+
4
+ const calculateFiatBalance = (token, exchangeRates) => {
5
+ // If there is no token, return 0 instead of undefined because token is only undefined
6
+ // when and only when user has no balance for it.
7
+ if (!token)
8
+ return 0;
9
+ if (token.fiatBalance)
10
+ return token.fiatBalance;
11
+ // Fixing price to 1 for stablecoins to match user expectation
12
+ if (isFiatOrStablecoin(token.symbol))
13
+ return token.balance;
14
+ if (token.price)
15
+ return token.balance * token.price;
16
+ if (exchangeRates[token.symbol])
17
+ return token.balance * exchangeRates[token.symbol];
18
+ // Here we return undefined instead of 0 because we know user HAS balance for this token,
19
+ // but we cannot calculate the fiat balance, so show as unavailable.
20
+ return undefined;
21
+ };
22
+
23
+ export { calculateFiatBalance };
@@ -10,6 +10,8 @@ const convertToFiat = (amount, token, exchangeRates) => {
10
10
  if (amount === '')
11
11
  return '';
12
12
  const value = parseFloat(amount);
13
+ if (isNaN(value))
14
+ return '';
13
15
  return exchangeRates[token] !== undefined
14
16
  ? roundToMaxDisplayLength(value * exchangeRates[token])
15
17
  : undefined;
@@ -18,6 +20,8 @@ const convertFromFiat = (amount, token, exchangeRates) => {
18
20
  if (amount === '')
19
21
  return '';
20
22
  const value = parseFloat(amount);
23
+ if (isNaN(value))
24
+ return '';
21
25
  return exchangeRates[token] !== undefined
22
26
  ? roundToMaxDisplayLength(value / exchangeRates[token])
23
27
  : undefined;