@dynamic-labs/sdk-react-core 0.17.0-RC.16 → 0.17.0-RC.18

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 (315) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +8 -8
  5. package/src/index.cjs +8 -0
  6. package/src/index.js +5 -0
  7. package/src/lib/Main.cjs +2 -0
  8. package/src/lib/Main.js +2 -0
  9. package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.cjs +2 -0
  10. package/src/lib/components/Accordion/components/AccordionItem/AccordionItem.js +2 -0
  11. package/src/lib/components/AnimatePresence/AnimatePresence.cjs +2 -0
  12. package/src/lib/components/AnimatePresence/AnimatePresence.js +2 -0
  13. package/src/lib/components/AppOriginTile/AppOriginTile.types.d.ts +1 -1
  14. package/src/lib/components/Divider/Divider.cjs +6 -1
  15. package/src/lib/components/Divider/Divider.d.ts +6 -2
  16. package/src/lib/components/Divider/Divider.js +6 -1
  17. package/src/lib/components/IconWithSpinner/IconWithSpinner.cjs +1 -0
  18. package/src/lib/components/IconWithSpinner/IconWithSpinner.js +1 -0
  19. package/src/lib/components/IconWithSpinner/Spinner/Spinner.cjs +1 -0
  20. package/src/lib/components/IconWithSpinner/Spinner/Spinner.js +1 -0
  21. package/src/lib/components/IconWithStatus/IconWithStatus.cjs +1 -0
  22. package/src/lib/components/IconWithStatus/IconWithStatus.js +1 -0
  23. package/src/lib/components/Input/Input.cjs +10 -6
  24. package/src/lib/components/Input/Input.js +10 -6
  25. package/src/lib/components/NetworkPicker/components/ActionList/ActionList.cjs +2 -0
  26. package/src/lib/components/NetworkPicker/components/ActionList/ActionList.js +2 -0
  27. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.cjs +2 -0
  28. package/src/lib/components/NetworkPicker/components/EvmNetworkControl/EvmNetworkControl.js +2 -0
  29. package/src/lib/components/NetworkPicker/components/Network/Network.cjs +2 -0
  30. package/src/lib/components/NetworkPicker/components/Network/Network.js +2 -0
  31. package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.cjs +2 -0
  32. package/src/lib/components/NetworkPicker/components/NonNetworkSwitchingSupportedControl/NonNetworkSwitchingSupportedControl.js +2 -0
  33. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +2 -0
  34. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -0
  35. package/src/lib/components/OverlayCard/OverlayCard.cjs +2 -0
  36. package/src/lib/components/OverlayCard/OverlayCard.js +2 -0
  37. package/src/lib/components/Portal/Portal.cjs +2 -0
  38. package/src/lib/components/Portal/Portal.js +2 -0
  39. package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +24 -0
  40. package/src/lib/components/SendBalanceForm/SendBalanceForm.d.ts +10 -0
  41. package/src/lib/components/SendBalanceForm/SendBalanceForm.js +22 -0
  42. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.d.ts +16 -0
  43. package/src/lib/components/SendBalancePageLayout/components/TokenBalanceCard/TokenBalanceCard.d.ts +8 -0
  44. package/src/lib/components/SendBalancePageLayout/components/TokenBalanceCard/index.d.ts +1 -0
  45. package/src/lib/components/SendBalancePageLayout/components/index.d.ts +1 -0
  46. package/src/lib/components/SendBalancePageLayout/index.d.ts +2 -0
  47. package/src/lib/components/Tooltip/Tooltip.cjs +2 -0
  48. package/src/lib/components/Tooltip/Tooltip.js +2 -0
  49. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +40 -0
  50. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.d.ts +17 -0
  51. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +36 -0
  52. package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.cjs +11 -0
  53. package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.d.ts +12 -0
  54. package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/TransactionRow.js +7 -0
  55. package/src/lib/components/TransactionConfirmationPageLayout/components/TransactionRow/index.d.ts +1 -0
  56. package/src/lib/components/TransactionConfirmationPageLayout/components/index.d.ts +1 -0
  57. package/src/lib/components/TransactionConfirmationPageLayout/index.d.ts +2 -0
  58. package/src/lib/components/TransactionOriginDestination/TransactionOriginDestination.d.ts +11 -0
  59. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.d.ts +11 -0
  60. package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.cjs +2 -0
  61. package/src/lib/components/Transition/VerticalDrawerTransition/VerticalDrawerTransition.js +2 -0
  62. package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.cjs +2 -0
  63. package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.js +2 -0
  64. package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.cjs +2 -0
  65. package/src/lib/components/UserProfile/parts/UserProfileSection/UserProfileSection.js +2 -0
  66. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +2 -0
  67. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +2 -0
  68. package/src/lib/components/index.d.ts +2 -0
  69. package/src/lib/context/DynamicContext/DynamicContext.cjs +22 -9
  70. package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -0
  71. package/src/lib/context/DynamicContext/DynamicContext.js +22 -9
  72. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.cjs +1 -0
  73. package/src/lib/context/DynamicContext/hooks/useEmailLoginState/useEmailLoginState.js +1 -0
  74. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.cjs +2 -0
  75. package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerAuthFlowCallbacks.js +2 -0
  76. package/src/lib/context/QrCodeContext/QrCodeContext.cjs +2 -0
  77. package/src/lib/context/QrCodeContext/QrCodeContext.js +2 -0
  78. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +5 -2
  79. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +5 -2
  80. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +2 -0
  81. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +2 -0
  82. package/src/lib/layout/DynamicAuthLayout/Footer/Footer.cjs +2 -0
  83. package/src/lib/layout/DynamicAuthLayout/Footer/Footer.js +2 -0
  84. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/Item/Item.cjs +2 -0
  85. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/Item/Item.js +2 -0
  86. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.cjs +2 -0
  87. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/WalletExtensionOrAppContinueButton/WalletExtensionOrAppContinueButton.js +2 -0
  88. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/WalletListFooterContent.cjs +1 -0
  89. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletListFooterContent/WalletListFooterContent.js +1 -0
  90. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletMoreInfoContent/WalletMoreInfoContent.cjs +2 -0
  91. package/src/lib/layout/DynamicAuthLayout/FooterContent/WalletMoreInfoContent/WalletMoreInfoContent.js +2 -0
  92. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +2 -0
  93. package/src/lib/layout/DynamicAuthLayout/Header/header.js +2 -0
  94. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +2 -0
  95. package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +2 -0
  96. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +25 -80
  97. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +27 -82
  98. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +0 -4
  99. package/src/lib/shared/types/index.d.ts +1 -1
  100. package/src/lib/shared/utils/functions/formatBigNumber/formatBigNumber.cjs +2 -1
  101. package/src/lib/shared/utils/functions/formatBigNumber/formatBigNumber.js +2 -1
  102. package/src/lib/shared/utils/functions/index.d.ts +1 -0
  103. package/src/lib/shared/utils/functions/trimEnd/index.d.ts +1 -0
  104. package/src/lib/shared/utils/functions/trimEnd/trimEnd.cjs +13 -0
  105. package/src/lib/shared/utils/functions/trimEnd/trimEnd.d.ts +1 -0
  106. package/src/lib/shared/utils/functions/trimEnd/trimEnd.js +9 -0
  107. package/src/lib/shared/utils/hooks/index.d.ts +2 -0
  108. package/src/lib/shared/utils/hooks/useIsMounted/index.d.ts +1 -0
  109. package/src/lib/shared/utils/hooks/useIsMounted/useIsMounted.cjs +18 -0
  110. package/src/lib/shared/utils/hooks/useIsMounted/useIsMounted.d.ts +1 -0
  111. package/src/lib/shared/utils/hooks/useIsMounted/useIsMounted.js +14 -0
  112. package/src/lib/styles/index.shadow.cjs +1 -1
  113. package/src/lib/styles/index.shadow.js +1 -1
  114. package/src/lib/utils/functions/getAppOrigin/getAppOrigin.cjs +12 -0
  115. package/src/lib/utils/functions/getAppOrigin/getAppOrigin.d.ts +1 -0
  116. package/src/lib/utils/functions/getAppOrigin/getAppOrigin.js +8 -0
  117. package/src/lib/utils/functions/getAppOrigin/index.d.ts +1 -0
  118. package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.d.ts +7 -0
  119. package/src/lib/utils/functions/getReferencedAccount/index.d.ts +1 -0
  120. package/src/lib/utils/functions/index.d.ts +2 -0
  121. package/src/lib/utils/functions/isWalletLinked/index.d.ts +1 -0
  122. package/src/lib/utils/functions/isWalletLinked/isWalletLinked.cjs +15 -0
  123. package/src/lib/utils/functions/isWalletLinked/isWalletLinked.d.ts +2 -0
  124. package/src/lib/utils/functions/isWalletLinked/isWalletLinked.js +11 -0
  125. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
  126. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
  127. package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +1 -0
  128. package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +1 -0
  129. package/src/lib/utils/hooks/multiWallet/index.d.ts +1 -0
  130. package/src/lib/utils/hooks/multiWallet/useMultiWalletWidgetState/useMultiWalletWidgetState.cjs +0 -2
  131. package/src/lib/utils/hooks/multiWallet/useMultiWalletWidgetState/useMultiWalletWidgetState.js +0 -2
  132. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +63 -7
  133. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +8 -1
  134. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +64 -8
  135. package/src/lib/utils/hooks/useConnectedAccountWallet/index.d.ts +1 -0
  136. package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.cjs +30 -0
  137. package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.d.ts +2 -0
  138. package/src/lib/utils/hooks/useConnectedAccountWallet/useConnectedAccountWallet.js +26 -0
  139. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
  140. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
  141. package/src/lib/utils/hooks/useWalletConnectors/reconnectSocialWallet.d.ts +8 -0
  142. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +18 -6
  143. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +18 -6
  144. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +8 -8
  145. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +8 -8
  146. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +3 -2
  147. package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +3 -2
  148. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +19 -17
  149. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +19 -17
  150. package/src/lib/utils/hooks/useWallets/useWallets.cjs +26 -36
  151. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +1 -2
  152. package/src/lib/utils/hooks/useWallets/useWallets.js +27 -37
  153. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +2 -0
  154. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +2 -0
  155. package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +1 -0
  156. package/src/lib/views/CollectUserDataView/CollectUserDataView.js +1 -0
  157. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +2 -0
  158. package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +2 -0
  159. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +2 -0
  160. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +2 -0
  161. package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.cjs +2 -0
  162. package/src/lib/views/CollectUserDataViewLoginWithEmail/CollectUserDataViewLoginWithEmail.js +2 -0
  163. package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +2 -0
  164. package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +2 -0
  165. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -0
  166. package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -0
  167. package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -0
  168. package/src/lib/views/EmailVerification/EmailVerification.js +2 -0
  169. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -0
  170. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -0
  171. package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.cjs +2 -0
  172. package/src/lib/views/LoginWithEmailView/components/ListItemButton/ListItemButton.js +2 -0
  173. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +2 -0
  174. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +2 -0
  175. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +2 -0
  176. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +2 -0
  177. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
  178. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
  179. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
  180. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
  181. package/src/lib/views/NoAccess/NoAccess.cjs +1 -0
  182. package/src/lib/views/NoAccess/NoAccess.js +1 -0
  183. package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.cjs +1 -0
  184. package/src/lib/views/NoQrNotInstalledView/NoQrNotInstalledView.js +1 -0
  185. package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.cjs +2 -0
  186. package/src/lib/views/NoQrNotInstalledView/WalletHelpLink.js +2 -0
  187. package/src/lib/views/PendingConnectView/PendingConnectView.cjs +1 -0
  188. package/src/lib/views/PendingConnectView/PendingConnectView.js +1 -0
  189. package/src/lib/views/PendingSignatureView/PendingSignatureView.cjs +1 -0
  190. package/src/lib/views/PendingSignatureView/PendingSignatureView.js +1 -0
  191. package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.cjs +2 -0
  192. package/src/lib/views/QrCodeView/QrCodeContainer/QrCodeContainer.js +2 -0
  193. package/src/lib/views/QrCodeView/QrCodeView.cjs +1 -0
  194. package/src/lib/views/QrCodeView/QrCodeView.js +1 -0
  195. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +2 -0
  196. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +2 -0
  197. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +92 -0
  198. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +13 -0
  199. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +88 -0
  200. package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/helpers/transactionErrorMessage.cjs +6 -1
  201. package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/helpers/transactionErrorMessage.d.ts +1 -0
  202. package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/helpers/transactionErrorMessage.js +6 -1
  203. package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/hooks/useTransactionData/useTransactionData.cjs +2 -0
  204. package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/hooks/useTransactionData/useTransactionData.js +2 -0
  205. package/src/lib/views/TransactionConfirmationView/index.d.ts +2 -0
  206. package/src/lib/views/WalletList/SearchInstead/SearchInstead.cjs +2 -0
  207. package/src/lib/views/WalletList/SearchInstead/SearchInstead.js +2 -0
  208. package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -0
  209. package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -0
  210. package/src/lib/views/WalletList/data.cjs +4 -5
  211. package/src/lib/views/WalletList/data.d.ts +2 -2
  212. package/src/lib/views/WalletList/data.js +4 -5
  213. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +1 -0
  214. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +1 -0
  215. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +1 -0
  216. package/src/lib/views/WalletUsedView/WalletUsedView.js +1 -0
  217. package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +2 -0
  218. package/src/lib/widgets/DynamicWidget/DynamicWidget.js +2 -0
  219. package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.cjs +1 -0
  220. package/src/lib/widgets/DynamicWidget/components/AccountControl/AccountControl.js +1 -0
  221. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -0
  222. package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -0
  223. package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +2 -0
  224. package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +2 -0
  225. package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.cjs +2 -0
  226. package/src/lib/widgets/DynamicWidget/components/DotsMenuDropdown/DotsMenuDropdown.js +2 -0
  227. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +2 -0
  228. package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +2 -0
  229. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs +2 -0
  230. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js +2 -0
  231. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +1 -0
  232. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +1 -0
  233. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.cjs +15 -5
  234. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetPrompts/DynamicWidgetPrompts.js +15 -5
  235. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetSwitcher/DynamicWidgetSwitcher.cjs +2 -0
  236. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetSwitcher/DynamicWidgetSwitcher.js +2 -0
  237. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.cjs +2 -0
  238. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetDropdown/DynamicWidgetDropdown.js +2 -0
  239. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.cjs +2 -0
  240. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetVariants/variants/DynamicWidgetModal/DynamicWidgetModal.js +2 -0
  241. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +2 -0
  242. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +2 -0
  243. package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.cjs +2 -0
  244. package/src/lib/widgets/DynamicWidget/components/EmailConnectorPendingSignModalContent/EmailConnectorPendingSignModalContent.js +2 -0
  245. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +2 -0
  246. package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +2 -0
  247. package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +2 -0
  248. package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +2 -0
  249. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +2 -0
  250. package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +2 -0
  251. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +4 -1
  252. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +4 -1
  253. package/src/lib/widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.cjs +1 -0
  254. package/src/lib/widgets/DynamicWidget/components/WalletIconWithStatus/WalletIconWithStatus.js +1 -0
  255. package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.cjs +40 -6
  256. package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.d.ts +2 -1
  257. package/src/lib/widgets/DynamicWidget/components/WidgetPortal/WidgetPortal.js +41 -7
  258. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +2 -0
  259. package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +2 -0
  260. package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +1 -0
  261. package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +1 -0
  262. package/src/lib/widgets/DynamicWidget/{components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs → prompts/DefaultPromptModal/DefaultPromptModal.cjs} +8 -13
  263. package/src/lib/widgets/DynamicWidget/prompts/DefaultPromptModal/DefaultPromptModal.d.ts +13 -0
  264. package/src/lib/widgets/DynamicWidget/{components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js → prompts/DefaultPromptModal/DefaultPromptModal.js} +8 -13
  265. package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.cjs +2 -0
  266. package/src/lib/widgets/DynamicWidget/prompts/DetectedNewWalletModal/DetectedNewWalletModal.js +2 -0
  267. package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.cjs +2 -1
  268. package/src/lib/widgets/DynamicWidget/prompts/NoQrNotInstalledModalView/NoQrNotInstalledModalView.js +2 -1
  269. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.cjs +17 -42
  270. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/PendingAccountSwitchModal.js +18 -43
  271. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.cjs +42 -0
  272. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.d.ts +7 -0
  273. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/SwitchAccountView.js +38 -0
  274. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchAccountView/index.d.ts +1 -0
  275. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.cjs +68 -0
  276. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.d.ts +8 -0
  277. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/SwitchOrUseActiveAccountView.js +64 -0
  278. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchModal/SwitchOrUseActiveAccountView/index.d.ts +1 -0
  279. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.cjs +58 -0
  280. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.d.ts +2 -0
  281. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/PendingAccountSwitchToLinkModal.js +54 -0
  282. package/src/lib/widgets/DynamicWidget/prompts/PendingAccountSwitchToLinkModal/index.d.ts +1 -0
  283. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +45 -0
  284. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.d.ts +2 -0
  285. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +41 -0
  286. package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/index.d.ts +1 -0
  287. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.cjs +65 -0
  288. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.d.ts +2 -0
  289. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/DefaultPendingSignModalContent/DefaultPendingSignModalContent.js +61 -0
  290. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/PendingSignModal.cjs +2 -33
  291. package/src/lib/widgets/DynamicWidget/prompts/PendingSignModal/PendingSignModal.js +2 -33
  292. package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.cjs +5 -6
  293. package/src/lib/widgets/DynamicWidget/prompts/PrimaryNotConnectedModal/PrimaryNotConnectedModal.js +6 -7
  294. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.cjs +2 -1
  295. package/src/lib/widgets/DynamicWidget/prompts/QrCodeModalView/QrCodeModalView.js +2 -1
  296. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.cjs +2 -0
  297. package/src/lib/widgets/DynamicWidget/prompts/UnlinkWalletPopUp/UnlinkWalletPopUp.js +2 -0
  298. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +2 -0
  299. package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +2 -0
  300. package/src/lib/widgets/DynamicWidget/views/IndexView/IndexView.cjs +2 -0
  301. package/src/lib/widgets/DynamicWidget/views/IndexView/IndexView.js +2 -0
  302. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +2 -0
  303. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +2 -0
  304. package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.cjs +2 -0
  305. package/src/lib/widgets/FundingWidget/views/FundWalletView/FundWalletView.js +2 -0
  306. package/src/lib/widgets/DynamicWidget/components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.d.ts +0 -2
  307. package/src/lib/widgets/DynamicWidget/components/DefaultPendingSignModalContent/DefaultPendingSignModalContent.types.d.ts +0 -7
  308. package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.cjs +0 -61
  309. package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.d.ts +0 -7
  310. package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/DetectedKnownSecondaryWalletModal.js +0 -57
  311. package/src/lib/widgets/DynamicWidget/prompts/DetectedKnownSecondaryWalletModal/index.d.ts +0 -1
  312. /package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/hooks/index.d.ts +0 -0
  313. /package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/hooks/useTransactionData/index.d.ts +0 -0
  314. /package/src/lib/{modals/TransactionConfirmationModal → views/TransactionConfirmationView}/hooks/useTransactionData/useTransactionData.d.ts +0 -0
  315. /package/src/lib/widgets/DynamicWidget/{components → prompts/PendingSignModal}/DefaultPendingSignModalContent/index.d.ts +0 -0
@@ -1,7 +1,49 @@
1
- import { useEffect } from 'react';
1
+ import { useCallback, useEffect } from 'react';
2
2
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
3
+ import { isWalletLinked } from '../../../functions/isWalletLinked/isWalletLinked.js';
3
4
 
4
- const useSyncPrimaryWallet = ({ primaryWallet, setMultiWalletWidgetState, multiWalletWidgetState, }) => {
5
+ const useSyncPrimaryWallet = ({ computeConnectedStateForWallets, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showWidgetStatePopup, }) => {
6
+ const handlePrimaryWalletNotActive = useCallback((connectedAddress) => {
7
+ if (!primaryWallet)
8
+ return;
9
+ const connectedWalletIsLinked = isWalletLinked(connectedAddress, [
10
+ primaryWallet,
11
+ ...secondaryWallets,
12
+ ]);
13
+ if (!connectedWalletIsLinked) {
14
+ const connectedSecondaryWallet = secondaryWallets.find((wallet) => wallet.connected);
15
+ if (!connectedSecondaryWallet) {
16
+ setMultiWalletWidgetState('awaiting_account_switch', 'primary_not_connected');
17
+ return;
18
+ }
19
+ setPrimaryWallet(connectedSecondaryWallet.id);
20
+ computeConnectedStateForWallets();
21
+ return;
22
+ }
23
+ if (showWidgetStatePopup) {
24
+ // user updates wallet address in the widget
25
+ setShowWidgetStatePopup(false);
26
+ setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
27
+ return;
28
+ }
29
+ // !showWidgetStatePopup - user comes back to site with different wallet address
30
+ const connectedWallet = secondaryWallets.find((wallet) => wallet.connected &&
31
+ isSameAddress(wallet.address, connectedAddress, wallet.chain));
32
+ if (connectedWallet) {
33
+ setPrimaryWallet(connectedWallet.id);
34
+ computeConnectedStateForWallets();
35
+ return;
36
+ }
37
+ setMultiWalletWidgetState('awaiting_account_switch', 'primary_not_connected');
38
+ }, [
39
+ primaryWallet,
40
+ secondaryWallets,
41
+ showWidgetStatePopup,
42
+ setShowWidgetStatePopup,
43
+ setMultiWalletWidgetState,
44
+ setPrimaryWallet,
45
+ computeConnectedStateForWallets,
46
+ ]);
5
47
  useEffect(() => {
6
48
  if (!primaryWallet || multiWalletWidgetState !== 'idle')
7
49
  return;
@@ -11,17 +53,31 @@ const useSyncPrimaryWallet = ({ primaryWallet, setMultiWalletWidgetState, multiW
11
53
  return;
12
54
  primaryWallet.connector
13
55
  .getConnectedAccounts()
14
- .then(([selectedAddress]) => {
15
- if (!selectedAddress)
56
+ .then(([connectedAddress]) => {
57
+ if (isSameAddress(connectedAddress, primaryWallet.address, primaryWallet.chain)) {
16
58
  return;
17
- if (!isSameAddress(selectedAddress, primaryWallet.address, primaryWallet.chain)) {
18
- setMultiWalletWidgetState('awaiting_account_switch', 'primary_not_connected');
19
59
  }
60
+ handlePrimaryWalletNotActive(connectedAddress);
20
61
  })
21
62
  .catch(() => {
22
- setMultiWalletWidgetState('awaiting_account_switch', 'primary_not_connected');
63
+ const connectedSecondaryWallet = secondaryWallets.find((wallet) => wallet.connected);
64
+ if (connectedSecondaryWallet) {
65
+ setPrimaryWallet(connectedSecondaryWallet.id);
66
+ computeConnectedStateForWallets();
67
+ return;
68
+ }
69
+ handleLogOut();
23
70
  });
24
- }, [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id, setMultiWalletWidgetState, multiWalletWidgetState]);
71
+ }, [
72
+ primaryWallet,
73
+ secondaryWallets,
74
+ multiWalletWidgetState,
75
+ setMultiWalletWidgetState,
76
+ computeConnectedStateForWallets,
77
+ handlePrimaryWalletNotActive,
78
+ handleLogOut,
79
+ setPrimaryWallet,
80
+ ]);
25
81
  };
26
82
 
27
83
  export { useSyncPrimaryWallet };
@@ -0,0 +1 @@
1
+ export { useConnectedAccountWallet } from './useConnectedAccountWallet';
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+ var React = require('react');
7
+
8
+ const useConnectedAccountWallet = (connector, secondaryWallets) => {
9
+ const [wallet, setWallet] = React.useState();
10
+ React.useEffect(() => {
11
+ const getConnectedAccounts = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
12
+ var _a;
13
+ if (!connector) {
14
+ setWallet(undefined);
15
+ return;
16
+ }
17
+ const connectedAccounts = (_a = (yield connector.getConnectedAccounts())) !== null && _a !== void 0 ? _a : [];
18
+ const connectedWallet = secondaryWallets.find((secondaryWallet) => {
19
+ var _a;
20
+ return secondaryWallet.address.toLowerCase() ===
21
+ ((_a = connectedAccounts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase());
22
+ });
23
+ setWallet(connectedWallet);
24
+ });
25
+ getConnectedAccounts();
26
+ }, [connector, secondaryWallets]);
27
+ return wallet;
28
+ };
29
+
30
+ exports.useConnectedAccountWallet = useConnectedAccountWallet;
@@ -0,0 +1,2 @@
1
+ import { Wallet, WalletConnector } from '../../../..';
2
+ export declare const useConnectedAccountWallet: (connector: WalletConnector | undefined, secondaryWallets: Wallet[]) => Wallet | undefined;
@@ -0,0 +1,26 @@
1
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
+ import { useState, useEffect } from 'react';
3
+
4
+ const useConnectedAccountWallet = (connector, secondaryWallets) => {
5
+ const [wallet, setWallet] = useState();
6
+ useEffect(() => {
7
+ const getConnectedAccounts = () => __awaiter(void 0, void 0, void 0, function* () {
8
+ var _a;
9
+ if (!connector) {
10
+ setWallet(undefined);
11
+ return;
12
+ }
13
+ const connectedAccounts = (_a = (yield connector.getConnectedAccounts())) !== null && _a !== void 0 ? _a : [];
14
+ const connectedWallet = secondaryWallets.find((secondaryWallet) => {
15
+ var _a;
16
+ return secondaryWallet.address.toLowerCase() ===
17
+ ((_a = connectedAccounts[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase());
18
+ });
19
+ setWallet(connectedWallet);
20
+ });
21
+ getConnectedAccounts();
22
+ }, [connector, secondaryWallets]);
23
+ return wallet;
24
+ };
25
+
26
+ export { useConnectedAccountWallet };
@@ -23,11 +23,11 @@ var createUserProfile = require('../../functions/createUserProfile/createUserPro
23
23
  var isSupportedNetwork = require('../../functions/isSupportedNetwork/isSupportedNetwork.cjs');
24
24
  require('@dynamic-labs/sdk-api');
25
25
  var isProgrammableNetworkSwitchSupported = require('../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.cjs');
26
+ require('../../../shared/consts/index.cjs');
26
27
  var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
27
28
  var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
28
29
  var getSiweStatement = require('../../functions/getSiweStatement/getSiweStatement.cjs');
29
30
  var getWalletProvider = require('../../functions/getWalletProvider/getWalletProvider.cjs');
30
- require('../../../shared/consts/index.cjs');
31
31
 
32
32
  // This logic is used to both verify or link a wallet
33
33
  // Since we are re-using the different screens to authenticate or link the wallet.
@@ -19,11 +19,11 @@ import { createUserProfile } from '../../functions/createUserProfile/createUserP
19
19
  import { isSupportedNetwork } from '../../functions/isSupportedNetwork/isSupportedNetwork.js';
20
20
  import '@dynamic-labs/sdk-api';
21
21
  import { isProgrammableNetworkSwitchSupported } from '../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.js';
22
+ import '../../../shared/consts/index.js';
22
23
  import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
23
24
  import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
24
25
  import { getSiweStatement } from '../../functions/getSiweStatement/getSiweStatement.js';
25
26
  import { getWalletProvider } from '../../functions/getWalletProvider/getWalletProvider.js';
26
- import '../../../shared/consts/index.js';
27
27
 
28
28
  // This logic is used to both verify or link a wallet
29
29
  // Since we are re-using the different screens to authenticate or link the wallet.
@@ -0,0 +1,8 @@
1
+ import { Wallet } from '../../../shared';
2
+ /**
3
+ * This function will use a referenced account to kick off the social wallet
4
+ * authentication. This is useful in the multiwallet scenario where the user
5
+ * wants to set their disconnected social wallet as their primary wallet, in
6
+ * which case the wallet needs to be reconnected
7
+ */
8
+ export declare const reconnectSocialWallet: (jwt: string | undefined, wallet: Wallet) => Promise<void>;
@@ -97,9 +97,7 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
97
97
  const connectedAccounts = yield newWallet.connector.getConnectedAccounts();
98
98
  return { connectedAccounts, newWallet };
99
99
  }), [wallets]);
100
- const checkIfAccountChangeIsRequired = React.useCallback((primaryWallet, newPrimaryWallet) => {
101
- if (!primaryWallet)
102
- return;
100
+ const checkIfAccountChangeIsRequired = React.useCallback((primaryWallet, newPrimaryWallet, connectedAccounts) => {
103
101
  /**
104
102
  * we need to check multiWalletWidgetState here because `setPrimaryWallet` currently gets
105
103
  * called twice: once when the user clicks "make active" and once when the user performs
@@ -107,8 +105,12 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
107
105
  * (https://github.com/dynamic-labs/DynamicAuth/pull/550) is merged, since setting the
108
106
  * primary wallet will be simpler, so we won't need to call `setPrimaryWallet` twice.
109
107
  */
110
- return (multiWalletWidgetState === 'idle' &&
111
- isSameWalletName.isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name));
108
+ if (!primaryWallet || multiWalletWidgetState !== 'idle')
109
+ return;
110
+ const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
111
+ !connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
112
+ newPrimaryWallet.address.toLowerCase());
113
+ return (isSameWalletName.isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name) || accountIsNotConnectedInSecondaryWallet);
112
114
  }, [multiWalletWidgetState]);
113
115
  const checkIfShowQrCodeModal = React.useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
114
116
  !wallet.connector.canConnectViaCustodialService, []);
@@ -123,7 +125,8 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
123
125
  return;
124
126
  const primaryWallet = getPrimaryWallet();
125
127
  if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet)) {
126
- setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
128
+ yield newPrimaryWallet.connector.connect();
129
+ setPrimaryWalletId(walletId);
127
130
  return;
128
131
  }
129
132
  if (!connectedAccounts.length) {
@@ -146,6 +149,15 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
146
149
  setQrcodeUri(uri);
147
150
  }),
148
151
  });
152
+ /**
153
+ * need to check for connected account again for wallets that disconnect on refresh
154
+ * and only reconnect upon fetching public address above
155
+ */
156
+ const updatedConnectedAccounts = yield newPrimaryWallet.connector.getConnectedAccounts();
157
+ if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet, updatedConnectedAccounts)) {
158
+ setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
159
+ return;
160
+ }
149
161
  if (publicAddress) {
150
162
  setPrimaryWalletId(walletId);
151
163
  setMultiWalletWidgetState('idle');
@@ -93,9 +93,7 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
93
93
  const connectedAccounts = yield newWallet.connector.getConnectedAccounts();
94
94
  return { connectedAccounts, newWallet };
95
95
  }), [wallets]);
96
- const checkIfAccountChangeIsRequired = useCallback((primaryWallet, newPrimaryWallet) => {
97
- if (!primaryWallet)
98
- return;
96
+ const checkIfAccountChangeIsRequired = useCallback((primaryWallet, newPrimaryWallet, connectedAccounts) => {
99
97
  /**
100
98
  * we need to check multiWalletWidgetState here because `setPrimaryWallet` currently gets
101
99
  * called twice: once when the user clicks "make active" and once when the user performs
@@ -103,8 +101,12 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
103
101
  * (https://github.com/dynamic-labs/DynamicAuth/pull/550) is merged, since setting the
104
102
  * primary wallet will be simpler, so we won't need to call `setPrimaryWallet` twice.
105
103
  */
106
- return (multiWalletWidgetState === 'idle' &&
107
- isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name));
104
+ if (!primaryWallet || multiWalletWidgetState !== 'idle')
105
+ return;
106
+ const accountIsNotConnectedInSecondaryWallet = connectedAccounts &&
107
+ !connectedAccounts.find((connectedAccount) => connectedAccount.toLowerCase() ===
108
+ newPrimaryWallet.address.toLowerCase());
109
+ return (isSameWalletName(newPrimaryWallet.connector.name, primaryWallet.connector.name) || accountIsNotConnectedInSecondaryWallet);
108
110
  }, [multiWalletWidgetState]);
109
111
  const checkIfShowQrCodeModal = useCallback((wallet) => !wallet.connector.isInstalledOnBrowser() &&
110
112
  !wallet.connector.canConnectViaCustodialService, []);
@@ -119,7 +121,8 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
119
121
  return;
120
122
  const primaryWallet = getPrimaryWallet();
121
123
  if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet)) {
122
- setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
124
+ yield newPrimaryWallet.connector.connect();
125
+ setPrimaryWalletId(walletId);
123
126
  return;
124
127
  }
125
128
  if (!connectedAccounts.length) {
@@ -142,6 +145,15 @@ const useWalletConnectors = ({ authToken, wallets: availableWallets, multiWallet
142
145
  setQrcodeUri(uri);
143
146
  }),
144
147
  });
148
+ /**
149
+ * need to check for connected account again for wallets that disconnect on refresh
150
+ * and only reconnect upon fetching public address above
151
+ */
152
+ const updatedConnectedAccounts = yield newPrimaryWallet.connector.getConnectedAccounts();
153
+ if (checkIfAccountChangeIsRequired(primaryWallet, newPrimaryWallet, updatedConnectedAccounts)) {
154
+ setMultiWalletWidgetState('awaiting_account_switch', 'switching_primary');
155
+ return;
156
+ }
145
157
  if (publicAddress) {
146
158
  setPrimaryWalletId(walletId);
147
159
  setMultiWalletWidgetState('idle');
@@ -91,26 +91,25 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
91
91
  primaryWallet.connector.setupEventListeners({
92
92
  onAccountChange: (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
93
93
  const [newAddress] = accounts;
94
- yield computeConnectedStateForWallets();
94
+ const newWallet = secondaryWallets.find((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain));
95
95
  if (walletConnectorCore.isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
96
96
  setMultiWalletWidgetState('idle');
97
97
  }
98
98
  else if (!multiWallet) {
99
99
  yield handleLogOut();
100
+ return;
100
101
  }
101
102
  else if (multiWalletWidgetState === 'awaiting_account_switch') {
102
103
  handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
103
- yield computeConnectedStateForWallets();
104
104
  }
105
- else if (multiWalletWidgetState === 'idle' &&
106
- secondaryWallets.some((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain))) {
107
- setMultiWalletWidgetState('detected_known_secondary_wallet');
105
+ else if (multiWalletWidgetState === 'idle' && newWallet) {
106
+ setPrimaryWalletId(newWallet.id);
108
107
  }
109
- else if (multiWalletWidgetState === 'idle' &&
110
- !secondaryWallets.some((wallet) => walletConnectorCore.isSameAddress(wallet.address, newAddress, wallet.chain))) {
108
+ else if (multiWalletWidgetState === 'idle' && !newWallet) {
111
109
  if (user) {
112
110
  setMultiWalletWidgetState('detected_new_wallet');
113
111
  setSelectedWalletConnector(primaryWallet.connector);
112
+ yield computeConnectedStateForWallets();
114
113
  return;
115
114
  }
116
115
  connectWalletByAddressAndChain(primaryWallet.connector.name, newAddress, primaryWallet.chain);
@@ -119,9 +118,9 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
119
118
  logger.logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
120
119
  setMultiWalletWidgetState('idle');
121
120
  }
121
+ yield computeConnectedStateForWallets();
122
122
  }),
123
123
  onChainChange: (chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
124
- /* istanbul ignore next */
125
124
  setNetwork(parseInt(chain));
126
125
  }),
127
126
  onDisconnect: handleLogOut,
@@ -138,6 +137,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
138
137
  secondaryWallets,
139
138
  setSelectedWalletConnector,
140
139
  handleAccountChangeWhenAwaitingAccountSwitch,
140
+ setPrimaryWalletId,
141
141
  ]);
142
142
  const addSecondaryWalletEventListeners = React.useCallback((seen) => {
143
143
  const secondaryListeners = {
@@ -87,26 +87,25 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
87
87
  primaryWallet.connector.setupEventListeners({
88
88
  onAccountChange: (accounts) => __awaiter(void 0, void 0, void 0, function* () {
89
89
  const [newAddress] = accounts;
90
- yield computeConnectedStateForWallets();
90
+ const newWallet = secondaryWallets.find((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain));
91
91
  if (isSameAddress(newAddress, primaryWallet.address, primaryWallet.chain)) {
92
92
  setMultiWalletWidgetState('idle');
93
93
  }
94
94
  else if (!multiWallet) {
95
95
  yield handleLogOut();
96
+ return;
96
97
  }
97
98
  else if (multiWalletWidgetState === 'awaiting_account_switch') {
98
99
  handleAccountChangeWhenAwaitingAccountSwitch(true, newAddress);
99
- yield computeConnectedStateForWallets();
100
100
  }
101
- else if (multiWalletWidgetState === 'idle' &&
102
- secondaryWallets.some((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain))) {
103
- setMultiWalletWidgetState('detected_known_secondary_wallet');
101
+ else if (multiWalletWidgetState === 'idle' && newWallet) {
102
+ setPrimaryWalletId(newWallet.id);
104
103
  }
105
- else if (multiWalletWidgetState === 'idle' &&
106
- !secondaryWallets.some((wallet) => isSameAddress(wallet.address, newAddress, wallet.chain))) {
104
+ else if (multiWalletWidgetState === 'idle' && !newWallet) {
107
105
  if (user) {
108
106
  setMultiWalletWidgetState('detected_new_wallet');
109
107
  setSelectedWalletConnector(primaryWallet.connector);
108
+ yield computeConnectedStateForWallets();
110
109
  return;
111
110
  }
112
111
  connectWalletByAddressAndChain(primaryWallet.connector.name, newAddress, primaryWallet.chain);
@@ -115,9 +114,9 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
115
114
  logger.error(`Unexpected multiWalletWidgetState (${multiWalletWidgetState}) and onAccountChange combination. Resetting state to idle.`);
116
115
  setMultiWalletWidgetState('idle');
117
116
  }
117
+ yield computeConnectedStateForWallets();
118
118
  }),
119
119
  onChainChange: (chain) => __awaiter(void 0, void 0, void 0, function* () {
120
- /* istanbul ignore next */
121
120
  setNetwork(parseInt(chain));
122
121
  }),
123
122
  onDisconnect: handleLogOut,
@@ -134,6 +133,7 @@ const useWalletEventListeners = ({ computeConnectedStateForWallets, handleLogOut
134
133
  secondaryWallets,
135
134
  setSelectedWalletConnector,
136
135
  handleAccountChangeWhenAwaitingAccountSwitch,
136
+ setPrimaryWalletId,
137
137
  ]);
138
138
  const addSecondaryWalletEventListeners = useCallback((seen) => {
139
139
  const secondaryListeners = {
@@ -18,14 +18,14 @@ require('react/jsx-runtime');
18
18
  require('react');
19
19
  require('ethers');
20
20
  var requiresTwoStepAuthentication = require('../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.cjs');
21
+ require('../../../shared/consts/index.cjs');
21
22
  var useConnectAndSign = require('../authenticationHooks/useConnectAndSign/useConnectAndSign.cjs');
22
23
  require('../../../config/ApiEndpoint.cjs');
23
- require('../../../shared/consts/index.cjs');
24
24
  var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
25
25
  var isSelectedWalletAlreadyConnected = require('../../functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.cjs');
26
26
 
27
27
  const useWalletItemActions = () => {
28
- const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
28
+ const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, setIsVerifying, } = useInternalDynamicContext.useInternalDynamicContext();
29
29
  const { mockedSDK } = MockContext.useMockContext();
30
30
  const { setError } = ErrorContext.useErrorContext();
31
31
  const { setView } = ViewContext.useViewContext();
@@ -108,6 +108,7 @@ const useWalletItemActions = () => {
108
108
  if (walletConnector.connectedChain === 'FLOW') {
109
109
  yield walletConnector.endSession();
110
110
  }
111
+ setIsVerifying(false);
111
112
  if (isSelectedWalletAlreadyConnected.isSelectedWalletAlreadyConnected(connectedWallets, walletConnector, user) &&
112
113
  walletConnector.connectedChain !== 'FLOW') {
113
114
  // wallet is already connected
@@ -14,14 +14,14 @@ import 'react/jsx-runtime';
14
14
  import 'react';
15
15
  import 'ethers';
16
16
  import { requiresTwoStepAuthentication } from '../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.js';
17
+ import '../../../shared/consts/index.js';
17
18
  import { useConnectAndSign } from '../authenticationHooks/useConnectAndSign/useConnectAndSign.js';
18
19
  import '../../../config/ApiEndpoint.js';
19
- import '../../../shared/consts/index.js';
20
20
  import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
21
21
  import { isSelectedWalletAlreadyConnected } from '../../functions/isSelectedWalletAlreadyConnected/isSelectedWalletAlreadyConnected.js';
22
22
 
23
23
  const useWalletItemActions = () => {
24
- const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, } = useInternalDynamicContext();
24
+ const { setMultiWalletWidgetState, setShowAuthFlow, setSelectedWalletConnector, wallets, setQrcodeUri, setDesktopUri, user, connectedWallets, setIsVerifying, } = useInternalDynamicContext();
25
25
  const { mockedSDK } = useMockContext();
26
26
  const { setError } = useErrorContext();
27
27
  const { setView } = useViewContext();
@@ -104,6 +104,7 @@ const useWalletItemActions = () => {
104
104
  if (walletConnector.connectedChain === 'FLOW') {
105
105
  yield walletConnector.endSession();
106
106
  }
107
+ setIsVerifying(false);
107
108
  if (isSelectedWalletAlreadyConnected(connectedWallets, walletConnector, user) &&
108
109
  walletConnector.connectedChain !== 'FLOW') {
109
110
  // wallet is already connected
@@ -8,40 +8,42 @@ var React = require('react');
8
8
  var SignMessageConfirmationModal = require('../../../modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs');
9
9
  var TransactionConfirmationModal = require('../../../modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs');
10
10
  var useConfirmationModal = require('../useConfirmationModal/useConfirmationModal.cjs');
11
- require('../../constants/colors.cjs');
12
- require('@dynamic-labs/multi-wallet');
13
- require('@dynamic-labs/utils');
14
- var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
15
- require('@dynamic-labs/wallet-connector-core');
16
- require('@dynamic-labs/sdk-api');
17
11
 
18
12
  const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
19
- const fakeSignerRef = React.useRef('disabled');
13
+ const confirmationStateRef = React.useRef('enabled');
20
14
  const { modal: sendTransactionModal, open: openSendTransaction } = useConfirmationModal.useConfirmationModal({
21
15
  elementId: 'dynamic-send-transaction',
22
16
  });
23
17
  const { modal, open: openSignMessage } = useConfirmationModal.useConfirmationModal({
24
18
  elementId: 'dynamic-sign-message',
25
19
  });
20
+ const shouldConfirmAction = React.useCallback(() => {
21
+ if (confirmationStateRef.current === 'disabled') {
22
+ confirmationStateRef.current = 'enabled';
23
+ return false;
24
+ }
25
+ return true;
26
+ }, [confirmationStateRef]);
26
27
  const signMessage = React.useCallback(({ message, handler }) => {
27
- const jwt = getAuthToken.getAuthToken();
28
- if (!jwt && fakeSignerRef.current === 'enabled') {
29
- fakeSignerRef.current = 'disabled';
28
+ if (!shouldConfirmAction()) {
30
29
  return handler(message);
31
30
  }
32
31
  return openSignMessage((resolve, reject) => (jsxRuntime.jsx(SignMessageConfirmationModal.SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
33
- }, [appLogoUrl, appName, getAppOrigin, openSignMessage]);
32
+ }, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
34
33
  const sendTransaction = React.useCallback(({ transaction, handler, provider }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
35
- return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { title: 'Send Transaction', appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
36
- }), [appLogoUrl, appName, getAppOrigin, openSendTransaction]);
37
- const enableInternalSign = React.useCallback(() => {
38
- fakeSignerRef.current = 'enabled';
34
+ if (!shouldConfirmAction()) {
35
+ return handler(transaction);
36
+ }
37
+ return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
38
+ }), [openSendTransaction, shouldConfirmAction]);
39
+ const disabledConfirmationOnce = React.useCallback(() => {
40
+ confirmationStateRef.current = 'disabled';
39
41
  }, []);
40
42
  const walletUiUtils = React.useMemo(() => ({
41
- enableInternalSign,
43
+ disabledConfirmationOnce,
42
44
  sendTransaction,
43
45
  signMessage,
44
- }), [signMessage, enableInternalSign, sendTransaction]);
46
+ }), [signMessage, disabledConfirmationOnce, sendTransaction]);
45
47
  return React.useMemo(() => [modal || sendTransactionModal, walletUiUtils], [modal, sendTransactionModal, walletUiUtils]);
46
48
  };
47
49
 
@@ -4,40 +4,42 @@ import { useRef, useCallback, useMemo } from 'react';
4
4
  import { SignMessageConfirmationModal } from '../../../modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js';
5
5
  import { TransactionConfirmationModal } from '../../../modals/TransactionConfirmationModal/TransactionConfirmationModal.js';
6
6
  import { useConfirmationModal } from '../useConfirmationModal/useConfirmationModal.js';
7
- import '../../constants/colors.js';
8
- import '@dynamic-labs/multi-wallet';
9
- import '@dynamic-labs/utils';
10
- import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
11
- import '@dynamic-labs/wallet-connector-core';
12
- import '@dynamic-labs/sdk-api';
13
7
 
14
8
  const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
15
- const fakeSignerRef = useRef('disabled');
9
+ const confirmationStateRef = useRef('enabled');
16
10
  const { modal: sendTransactionModal, open: openSendTransaction } = useConfirmationModal({
17
11
  elementId: 'dynamic-send-transaction',
18
12
  });
19
13
  const { modal, open: openSignMessage } = useConfirmationModal({
20
14
  elementId: 'dynamic-sign-message',
21
15
  });
16
+ const shouldConfirmAction = useCallback(() => {
17
+ if (confirmationStateRef.current === 'disabled') {
18
+ confirmationStateRef.current = 'enabled';
19
+ return false;
20
+ }
21
+ return true;
22
+ }, [confirmationStateRef]);
22
23
  const signMessage = useCallback(({ message, handler }) => {
23
- const jwt = getAuthToken();
24
- if (!jwt && fakeSignerRef.current === 'enabled') {
25
- fakeSignerRef.current = 'disabled';
24
+ if (!shouldConfirmAction()) {
26
25
  return handler(message);
27
26
  }
28
27
  return openSignMessage((resolve, reject) => (jsx(SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
29
- }, [appLogoUrl, appName, getAppOrigin, openSignMessage]);
28
+ }, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
30
29
  const sendTransaction = useCallback(({ transaction, handler, provider }) => __awaiter(void 0, void 0, void 0, function* () {
31
- return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { title: 'Send Transaction', appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
32
- }), [appLogoUrl, appName, getAppOrigin, openSendTransaction]);
33
- const enableInternalSign = useCallback(() => {
34
- fakeSignerRef.current = 'enabled';
30
+ if (!shouldConfirmAction()) {
31
+ return handler(transaction);
32
+ }
33
+ return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
34
+ }), [openSendTransaction, shouldConfirmAction]);
35
+ const disabledConfirmationOnce = useCallback(() => {
36
+ confirmationStateRef.current = 'disabled';
35
37
  }, []);
36
38
  const walletUiUtils = useMemo(() => ({
37
- enableInternalSign,
39
+ disabledConfirmationOnce,
38
40
  sendTransaction,
39
41
  signMessage,
40
- }), [signMessage, enableInternalSign, sendTransaction]);
42
+ }), [signMessage, disabledConfirmationOnce, sendTransaction]);
41
43
  return useMemo(() => [modal || sendTransactionModal, walletUiUtils], [modal, sendTransactionModal, walletUiUtils]);
42
44
  };
43
45