@dynamic-labs/sdk-react-core 0.18.100-viem.0 → 0.18.100-viem.10

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 (220) hide show
  1. package/CHANGELOG.md +111 -1
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +10 -10
  5. package/src/index.cjs +4 -0
  6. package/src/index.js +2 -0
  7. package/src/lib/Main.cjs +5 -0
  8. package/src/lib/Main.js +5 -0
  9. package/src/lib/components/Button/Button.cjs +10 -7
  10. package/src/lib/components/Button/Button.js +10 -7
  11. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  12. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  13. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  14. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  15. package/src/lib/components/ListTile/ListTile.js +1 -1
  16. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  17. package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
  18. package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
  19. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +6 -2
  20. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
  21. package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +6 -2
  22. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
  23. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +2 -0
  24. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
  25. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  26. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  27. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
  28. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
  29. package/src/lib/components/Typography/Typography.cjs +1 -0
  30. package/src/lib/components/Typography/Typography.js +1 -0
  31. package/src/lib/components/Typography/Typography.types.d.ts +1 -1
  32. package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
  33. package/src/lib/components/UserProfile/UserProfile.js +1 -1
  34. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
  35. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
  36. package/src/lib/context/DynamicContext/DynamicContext.cjs +15 -4
  37. package/src/lib/context/DynamicContext/DynamicContext.js +17 -6
  38. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  39. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  40. package/src/lib/context/DynamicContext/internalEvents/index.d.ts +2 -0
  41. package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
  42. package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
  43. package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
  44. package/src/lib/context/DynamicContext/types/index.d.ts +6 -3
  45. package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
  46. package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
  47. package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
  48. package/src/lib/context/SendBalanceContext/SendBalanceContext.types.d.ts +2 -2
  49. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +2 -1
  50. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +2 -1
  51. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  52. package/src/lib/data/api.cjs +33 -1
  53. package/src/lib/data/api.d.ts +3 -1
  54. package/src/lib/data/api.js +34 -4
  55. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
  56. package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
  57. package/src/lib/main.global.cjs +1 -1
  58. package/src/lib/main.global.js +1 -1
  59. package/src/lib/modals/SendBalanceModal/SendBalanceModal.d.ts +2 -2
  60. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +11 -2
  61. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +11 -2
  62. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +6 -3
  63. package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
  64. package/src/lib/shared/assets/double-arrow-right.js +29 -0
  65. package/src/lib/shared/assets/index.d.ts +1 -0
  66. package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +28 -2
  67. package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +28 -2
  68. package/src/lib/styles/index.shadow.cjs +1 -1
  69. package/src/lib/styles/index.shadow.js +1 -1
  70. package/src/lib/utils/constants/errors.cjs +7 -0
  71. package/src/lib/utils/constants/errors.d.ts +1 -0
  72. package/src/lib/utils/constants/errors.js +3 -0
  73. package/src/lib/utils/constants/index.d.ts +1 -1
  74. package/src/lib/utils/constants/localStorage.cjs +2 -0
  75. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  76. package/src/lib/utils/constants/localStorage.js +2 -1
  77. package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
  78. package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
  79. package/src/lib/utils/functions/digestSHA256/digestSHA256.cjs +11 -0
  80. package/src/lib/utils/functions/digestSHA256/digestSHA256.d.ts +1 -0
  81. package/src/lib/utils/functions/digestSHA256/digestSHA256.js +7 -0
  82. package/src/lib/utils/functions/digestSHA256/index.d.ts +1 -0
  83. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.cjs +14 -0
  84. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.d.ts +1 -0
  85. package/src/lib/utils/functions/encodeBase64URL/encodeBase64URL.js +10 -0
  86. package/src/lib/utils/functions/encodeBase64URL/index.d.ts +1 -0
  87. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.cjs +33 -0
  88. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.d.ts +1 -0
  89. package/src/lib/utils/functions/getRedirectURIOrigin/getRedirectURIOrigin.js +29 -0
  90. package/src/lib/utils/functions/getRedirectURIOrigin/index.d.ts +1 -0
  91. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  92. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  93. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  94. package/src/lib/utils/functions/index.d.ts +7 -0
  95. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  96. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  97. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  98. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  99. package/src/lib/utils/functions/randomString/index.d.ts +1 -0
  100. package/src/lib/utils/functions/randomString/randomString.cjs +14 -0
  101. package/src/lib/utils/functions/randomString/randomString.d.ts +1 -0
  102. package/src/lib/utils/functions/randomString/randomString.js +10 -0
  103. package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
  104. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +48 -0
  105. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +18 -0
  106. package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +43 -0
  107. package/src/lib/utils/functions/stringifyURIQuery/index.d.ts +1 -0
  108. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.cjs +13 -0
  109. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.d.ts +1 -0
  110. package/src/lib/utils/functions/stringifyURIQuery/stringifyURIQuery.js +9 -0
  111. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +10 -4
  112. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
  113. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +11 -5
  114. package/src/lib/utils/hooks/index.d.ts +2 -0
  115. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  116. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  117. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  118. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +15 -9
  119. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  120. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +15 -9
  121. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
  122. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
  123. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +16 -18
  124. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  125. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +17 -19
  126. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
  127. package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
  128. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  129. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  130. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  131. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  132. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  133. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  134. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  135. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
  136. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
  137. package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
  138. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +149 -26
  139. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
  140. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +151 -28
  141. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  142. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +31 -0
  143. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  144. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +27 -0
  145. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  146. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +56 -0
  147. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  148. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +52 -0
  149. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
  150. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
  151. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  152. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
  153. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  154. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
  155. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  156. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +9 -3
  157. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +9 -3
  158. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  159. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  160. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
  161. package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
  162. package/src/lib/views/EmailVerification/EmailVerification.cjs +12 -1
  163. package/src/lib/views/EmailVerification/EmailVerification.js +14 -3
  164. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
  165. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
  166. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  167. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  168. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
  169. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
  170. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +111 -0
  171. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
  172. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +107 -0
  173. package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
  174. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +4 -2
  175. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +4 -2
  176. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +4 -2
  177. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +4 -2
  178. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -35
  179. package/src/lib/views/SendBalanceView/SendBalanceView.d.ts +2 -2
  180. package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -36
  181. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +67 -0
  182. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  183. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +63 -0
  184. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  185. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  186. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
  187. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
  188. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +31 -8
  189. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +4 -3
  190. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +32 -9
  191. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  192. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  193. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.cjs +69 -0
  194. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  195. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +65 -0
  196. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  197. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  198. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +6 -0
  199. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  200. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -0
  201. package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +1 -0
  202. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  203. package/src/lib/views/WalletList/WalletList.js +4 -1
  204. package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -1
  205. package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -1
  206. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
  207. package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
  208. package/src/lib/views/viewToComponentMap.cjs +2 -0
  209. package/src/lib/views/viewToComponentMap.js +2 -0
  210. package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs +4 -1
  211. package/src/lib/widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js +4 -1
  212. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.cjs +13 -0
  213. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.d.ts +2 -0
  214. package/src/lib/widgets/OAuthIFrameContainer/OAuthIFrameContainer.js +9 -0
  215. package/src/lib/widgets/OAuthIFrameContainer/index.d.ts +1 -0
  216. package/src/lib/widgets/index.d.ts +1 -0
  217. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  218. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +0 -104
  219. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -17
  220. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -100
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var sdkApi = require('@dynamic-labs/sdk-api');
5
6
  var index = require('../getEnabledKYC/index.cjs');
6
7
 
7
8
  /**
@@ -53,19 +54,30 @@ const getNonEditableUserProfileFields = ({ projectSettingsKyc = [], user, }) =>
53
54
  * Get all user profile fields that exist in the user profile and are defined in the project
54
55
  * @param {Object} options - The function options object.
55
56
  * @param {ProjectSettingsKyc[]} options.projectSettingsKyc - The project settings KYC object array.
56
- * @param {UserFields} options.user - The user profile object.
57
+ * @param {UserProfile} options.user - The user profile object.
57
58
  * @returns {ProjectSettingsKyc[]} - The list of all user profile fields based on project settings.
58
59
  */
59
60
  const getUserProfileFields = ({ projectSettingsKyc = [], user, }) => {
61
+ var _a;
60
62
  const editableUserProfileFields = getEditableUserProfileFields(projectSettingsKyc);
61
63
  const nonEditableUserProfileFields = getNonEditableUserProfileFields({
62
64
  projectSettingsKyc,
63
65
  user,
64
66
  });
65
- const concatedList = [
67
+ let concatedList = [
66
68
  ...editableUserProfileFields,
67
69
  ...nonEditableUserProfileFields,
68
70
  ];
71
+ const hasEmbeddedWalletLinkedToEmail = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((credential) => credential.format === sdkApi.JwtVerifiedCredentialFormatEnum.Email &&
72
+ Boolean(credential.embeddedWalletId));
73
+ if (hasEmbeddedWalletLinkedToEmail) {
74
+ concatedList = concatedList.map((field) => {
75
+ if (field.name !== 'email') {
76
+ return field;
77
+ }
78
+ return Object.assign(Object.assign({}, field), { enabled: false });
79
+ });
80
+ }
69
81
  return concatedList.sort((a, b) => {
70
82
  const indexA = projectSettingsKyc.findIndex((field) => field.name === a.name);
71
83
  const indexB = projectSettingsKyc.findIndex((field) => field.name === b.name);
@@ -1,4 +1,5 @@
1
1
  import { ProjectSettingsKyc, UserFields } from '@dynamic-labs/sdk-api';
2
+ import { UserProfile } from '../../../shared';
2
3
  /**
3
4
  * Get editable user profile fields based on the project settings.
4
5
  * @param {ProjectSettingsKyc[]} projectSettings - The project settings KYC object array.
@@ -20,10 +21,10 @@ export declare const getNonEditableUserProfileFields: ({ projectSettingsKyc, use
20
21
  * Get all user profile fields that exist in the user profile and are defined in the project
21
22
  * @param {Object} options - The function options object.
22
23
  * @param {ProjectSettingsKyc[]} options.projectSettingsKyc - The project settings KYC object array.
23
- * @param {UserFields} options.user - The user profile object.
24
+ * @param {UserProfile} options.user - The user profile object.
24
25
  * @returns {ProjectSettingsKyc[]} - The list of all user profile fields based on project settings.
25
26
  */
26
27
  export declare const getUserProfileFields: ({ projectSettingsKyc, user, }: {
27
28
  projectSettingsKyc?: ProjectSettingsKyc[] | undefined;
28
- user?: UserFields | undefined;
29
+ user?: UserProfile | undefined;
29
30
  }) => ProjectSettingsKyc[];
@@ -1,3 +1,4 @@
1
+ import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api';
1
2
  import { getEnabledKYC } from '../getEnabledKYC/index.js';
2
3
 
3
4
  /**
@@ -49,19 +50,30 @@ const getNonEditableUserProfileFields = ({ projectSettingsKyc = [], user, }) =>
49
50
  * Get all user profile fields that exist in the user profile and are defined in the project
50
51
  * @param {Object} options - The function options object.
51
52
  * @param {ProjectSettingsKyc[]} options.projectSettingsKyc - The project settings KYC object array.
52
- * @param {UserFields} options.user - The user profile object.
53
+ * @param {UserProfile} options.user - The user profile object.
53
54
  * @returns {ProjectSettingsKyc[]} - The list of all user profile fields based on project settings.
54
55
  */
55
56
  const getUserProfileFields = ({ projectSettingsKyc = [], user, }) => {
57
+ var _a;
56
58
  const editableUserProfileFields = getEditableUserProfileFields(projectSettingsKyc);
57
59
  const nonEditableUserProfileFields = getNonEditableUserProfileFields({
58
60
  projectSettingsKyc,
59
61
  user,
60
62
  });
61
- const concatedList = [
63
+ let concatedList = [
62
64
  ...editableUserProfileFields,
63
65
  ...nonEditableUserProfileFields,
64
66
  ];
67
+ const hasEmbeddedWalletLinkedToEmail = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find((credential) => credential.format === JwtVerifiedCredentialFormatEnum.Email &&
68
+ Boolean(credential.embeddedWalletId));
69
+ if (hasEmbeddedWalletLinkedToEmail) {
70
+ concatedList = concatedList.map((field) => {
71
+ if (field.name !== 'email') {
72
+ return field;
73
+ }
74
+ return Object.assign(Object.assign({}, field), { enabled: false });
75
+ });
76
+ }
65
77
  return concatedList.sort((a, b) => {
66
78
  const indexA = projectSettingsKyc.findIndex((field) => field.name === a.name);
67
79
  const indexB = projectSettingsKyc.findIndex((field) => field.name === b.name);
@@ -21,3 +21,10 @@ export * from './isProviderEnabled';
21
21
  export * from './isOnrampProvider';
22
22
  export * from './getWalletConnectorNetworks/getWalletConnectorNetworks';
23
23
  export * from './isSocialKycEnabled';
24
+ export * from './isMagicConnector';
25
+ export * from './randomString';
26
+ export * from './stringifyURIQuery';
27
+ export * from './digestSHA256';
28
+ export * from './encodeBase64URL';
29
+ export * from './getRedirectURIOrigin';
30
+ export * from './sendTransactionWithAutoNonce';
@@ -0,0 +1 @@
1
+ export { isMagicConnector } from './isMagicConnector';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const magicEmailOtpWalletConnectorKey = 'magicemailotp';
6
+ const magicSocialWalletConnectorKey = 'magicsocial';
7
+ const isMagicConnector = (connector) => connector.key === magicEmailOtpWalletConnectorKey ||
8
+ connector.key === magicSocialWalletConnectorKey;
9
+
10
+ exports.isMagicConnector = isMagicConnector;
@@ -0,0 +1,2 @@
1
+ import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const isMagicConnector: (connector: WalletConnectorBase) => boolean;
@@ -0,0 +1,6 @@
1
+ const magicEmailOtpWalletConnectorKey = 'magicemailotp';
2
+ const magicSocialWalletConnectorKey = 'magicsocial';
3
+ const isMagicConnector = (connector) => connector.key === magicEmailOtpWalletConnectorKey ||
4
+ connector.key === magicSocialWalletConnectorKey;
5
+
6
+ export { isMagicConnector };
@@ -0,0 +1 @@
1
+ export { randomString } from './randomString';
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const randomString = (length) => {
6
+ const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
7
+ let result = '';
8
+ for (let i = length; i > 0; --i) {
9
+ result += CHARS[Math.floor(Math.random() * CHARS.length)];
10
+ }
11
+ return result;
12
+ };
13
+
14
+ exports.randomString = randomString;
@@ -0,0 +1 @@
1
+ export declare const randomString: (length: number) => string;
@@ -0,0 +1,10 @@
1
+ const randomString = (length) => {
2
+ const CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
3
+ let result = '';
4
+ for (let i = length; i > 0; --i) {
5
+ result += CHARS[Math.floor(Math.random() * CHARS.length)];
6
+ }
7
+ return result;
8
+ };
9
+
10
+ export { randomString };
@@ -0,0 +1 @@
1
+ export { sendTransactionWithAutoNonce } from './sendTransactionWithAutoNonce';
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+
7
+ const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
8
+ /**
9
+ * Sends a transaction with an automatically determined nonce, if not provided.
10
+ *
11
+ * In Ethereum, each transaction sent from a particular address must have a unique nonce.
12
+ * If the transaction does not already have a nonce, this function helps to automatically set it.
13
+ * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
14
+ * this function will automatically retry with the next nonce.
15
+ *
16
+ * @param connector - A Dynamic connector to interact with the Ethereum network.
17
+ * @param transaction - The transaction details.
18
+ * @param sendTransactionHandler - A handler function to send the transaction.
19
+ *
20
+ * @returns A promise that resolves to the transaction response.
21
+ */
22
+ const sendTransactionWithAutoNonce = (connector, transaction, sendTransactionHandler) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
23
+ if (transaction.nonce !== undefined) {
24
+ return sendTransactionHandler(transaction);
25
+ }
26
+ const publicClient = yield connector.getRpcProvider();
27
+ const walletClient = yield connector.getSigner();
28
+ const [address] = yield walletClient.getAddresses();
29
+ const nonce = yield publicClient.getTransactionCount({
30
+ address,
31
+ });
32
+ const transactionWithNonce = Object.assign(Object.assign({}, transaction), { nonce });
33
+ try {
34
+ const response = yield sendTransactionHandler(transactionWithNonce);
35
+ return response;
36
+ }
37
+ catch (err) {
38
+ if (err.code ===
39
+ MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE) {
40
+ const transactionWithNextNonce = Object.assign(Object.assign({}, transaction), { nonce: nonce + 1 });
41
+ return sendTransactionHandler(transactionWithNextNonce);
42
+ }
43
+ throw err;
44
+ }
45
+ });
46
+
47
+ exports.MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE;
48
+ exports.sendTransactionWithAutoNonce = sendTransactionWithAutoNonce;
@@ -0,0 +1,18 @@
1
+ import { TransactionRequest, Address } from 'viem';
2
+ import { WalletConnector } from '../../../..';
3
+ export declare const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
4
+ /**
5
+ * Sends a transaction with an automatically determined nonce, if not provided.
6
+ *
7
+ * In Ethereum, each transaction sent from a particular address must have a unique nonce.
8
+ * If the transaction does not already have a nonce, this function helps to automatically set it.
9
+ * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
10
+ * this function will automatically retry with the next nonce.
11
+ *
12
+ * @param connector - A Dynamic connector to interact with the Ethereum network.
13
+ * @param transaction - The transaction details.
14
+ * @param sendTransactionHandler - A handler function to send the transaction.
15
+ *
16
+ * @returns A promise that resolves to the transaction response.
17
+ */
18
+ export declare const sendTransactionWithAutoNonce: (connector: WalletConnector, transaction: TransactionRequest, sendTransactionHandler: (transaction: TransactionRequest) => Promise<Address>) => Promise<`0x${string}`>;
@@ -0,0 +1,43 @@
1
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
+
3
+ const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
4
+ /**
5
+ * Sends a transaction with an automatically determined nonce, if not provided.
6
+ *
7
+ * In Ethereum, each transaction sent from a particular address must have a unique nonce.
8
+ * If the transaction does not already have a nonce, this function helps to automatically set it.
9
+ * If a transaction with a particular nonce fails due to a "could not replace transaction" error,
10
+ * this function will automatically retry with the next nonce.
11
+ *
12
+ * @param connector - A Dynamic connector to interact with the Ethereum network.
13
+ * @param transaction - The transaction details.
14
+ * @param sendTransactionHandler - A handler function to send the transaction.
15
+ *
16
+ * @returns A promise that resolves to the transaction response.
17
+ */
18
+ const sendTransactionWithAutoNonce = (connector, transaction, sendTransactionHandler) => __awaiter(void 0, void 0, void 0, function* () {
19
+ if (transaction.nonce !== undefined) {
20
+ return sendTransactionHandler(transaction);
21
+ }
22
+ const publicClient = yield connector.getRpcProvider();
23
+ const walletClient = yield connector.getSigner();
24
+ const [address] = yield walletClient.getAddresses();
25
+ const nonce = yield publicClient.getTransactionCount({
26
+ address,
27
+ });
28
+ const transactionWithNonce = Object.assign(Object.assign({}, transaction), { nonce });
29
+ try {
30
+ const response = yield sendTransactionHandler(transactionWithNonce);
31
+ return response;
32
+ }
33
+ catch (err) {
34
+ if (err.code ===
35
+ MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE) {
36
+ const transactionWithNextNonce = Object.assign(Object.assign({}, transaction), { nonce: nonce + 1 });
37
+ return sendTransactionHandler(transactionWithNextNonce);
38
+ }
39
+ throw err;
40
+ }
41
+ });
42
+
43
+ export { MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE, sendTransactionWithAutoNonce };
@@ -0,0 +1 @@
1
+ export { stringifyURIQuery } from './stringifyURIQuery';
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const stringifyURIQuery = (obj) => {
6
+ const str = [];
7
+ for (const prop in obj) {
8
+ str.push(encodeURIComponent(prop) + '=' + encodeURIComponent(obj[prop]));
9
+ }
10
+ return str.join('&');
11
+ };
12
+
13
+ exports.stringifyURIQuery = stringifyURIQuery;
@@ -0,0 +1 @@
1
+ export declare const stringifyURIQuery: (obj: any) => string;
@@ -0,0 +1,9 @@
1
+ const stringifyURIQuery = (obj) => {
2
+ const str = [];
3
+ for (const prop in obj) {
4
+ str.push(encodeURIComponent(prop) + '=' + encodeURIComponent(obj[prop]));
5
+ }
6
+ return str.join('&');
7
+ };
8
+
9
+ export { stringifyURIQuery };
@@ -28,11 +28,11 @@ require('@dynamic-labs/multi-wallet');
28
28
  var isSupportedNetwork = require('../../../functions/isSupportedNetwork/isSupportedNetwork.cjs');
29
29
  var isProgrammableNetworkSwitchSupported = require('../../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.cjs');
30
30
 
31
- const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
31
+ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = true, } = {}) => {
32
32
  const { setView, goToInitialView } = ViewContext.useViewContext();
33
33
  const { setErrorMessage } = ErrorContext.useErrorContext();
34
34
  const { captchaToken } = CaptchaContext.useCaptchaContext();
35
- const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, } = useInternalDynamicContext.useInternalDynamicContext();
35
+ const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
36
36
  const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
37
37
  const verifyWallet = useVerifyWallet.useVerifyWallet({
38
38
  consumeNonce,
@@ -55,7 +55,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
55
55
  setView('wait-for-email-confirmation-view');
56
56
  }
57
57
  }
58
- const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
58
+ const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts, shouldCallCallback);
59
59
  if (!publicWalletAddress) {
60
60
  return;
61
61
  }
@@ -72,9 +72,15 @@ const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
72
72
  }
73
73
  if (isConnectOnly.isConnectOnly(user, authMode)) {
74
74
  localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.name);
75
- if (shouldUpdateWallets) {
75
+ // we don't want to re-calculate wallets to connect state if wallet is already connected.
76
+ // it may happen when user switch network in connect flow on already connected wallet
77
+ const isAlreadyConnected = connectedWallets.find((wallet) => walletConnectorCore.isSameAddress(publicWalletAddress, wallet.address, wallet.chain));
78
+ if (shouldUpdateWallets && !isAlreadyConnected) {
76
79
  handleWalletsToConnect();
77
80
  }
81
+ if (isAlreadyConnected) {
82
+ setView('bridge-next-wallet-connection');
83
+ }
78
84
  if (!isFullyConnected || (walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)) {
79
85
  setCallback('connectSuccess');
80
86
  }
@@ -3,7 +3,8 @@ type Props = {
3
3
  fetchPublicAddressOpts?: FetchPublicAddressOpts;
4
4
  walletConnector: WalletConnector;
5
5
  };
6
- export declare const useConnectAndSign: ({ shouldUpdateWallets }?: {
6
+ export declare const useConnectAndSign: ({ shouldUpdateWallets, shouldCallCallback, }?: {
7
7
  shouldUpdateWallets?: boolean | undefined;
8
+ shouldCallCallback?: boolean | undefined;
8
9
  }) => ({ walletConnector, fetchPublicAddressOpts, }: Props) => Promise<void>;
9
10
  export {};
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
2
- import { isEmailWalletConnector, isEmailOTPWalletConnector, isBloctoConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { isEmailWalletConnector, isEmailOTPWalletConnector, isBloctoConnector, isSameAddress } from '@dynamic-labs/wallet-connector-core';
3
3
  import { showPendingConnectView } from '../helpers/showPendingConnectView.js';
4
4
  import { isConnectOnly } from '../helpers/isConnectOnly.js';
5
5
  import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
@@ -24,11 +24,11 @@ import '@dynamic-labs/multi-wallet';
24
24
  import { isSupportedNetwork } from '../../../functions/isSupportedNetwork/isSupportedNetwork.js';
25
25
  import { isProgrammableNetworkSwitchSupported } from '../../../functions/isProgrammableNetworkSwitchSupported/isProgrammableNetworkSwitchSupported.js';
26
26
 
27
- const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
27
+ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = true, } = {}) => {
28
28
  const { setView, goToInitialView } = useViewContext();
29
29
  const { setErrorMessage } = useErrorContext();
30
30
  const { captchaToken } = useCaptchaContext();
31
- const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, } = useInternalDynamicContext();
31
+ const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, connectedWallets, } = useInternalDynamicContext();
32
32
  const { handleWalletsToConnect } = useHandleWalletsToConnect();
33
33
  const verifyWallet = useVerifyWallet({
34
34
  consumeNonce,
@@ -51,7 +51,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
51
51
  setView('wait-for-email-confirmation-view');
52
52
  }
53
53
  }
54
- const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
54
+ const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts, shouldCallCallback);
55
55
  if (!publicWalletAddress) {
56
56
  return;
57
57
  }
@@ -68,9 +68,15 @@ const useConnectAndSign = ({ shouldUpdateWallets = true } = {}) => {
68
68
  }
69
69
  if (isConnectOnly(user, authMode)) {
70
70
  LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.name);
71
- if (shouldUpdateWallets) {
71
+ // we don't want to re-calculate wallets to connect state if wallet is already connected.
72
+ // it may happen when user switch network in connect flow on already connected wallet
73
+ const isAlreadyConnected = connectedWallets.find((wallet) => isSameAddress(publicWalletAddress, wallet.address, wallet.chain));
74
+ if (shouldUpdateWallets && !isAlreadyConnected) {
72
75
  handleWalletsToConnect();
73
76
  }
77
+ if (isAlreadyConnected) {
78
+ setView('bridge-next-wallet-connection');
79
+ }
74
80
  if (!isFullyConnected || (walletsToConnectByChain === null || walletsToConnectByChain === void 0 ? void 0 : walletsToConnectByChain.length)) {
75
81
  setCallback('connectSuccess');
76
82
  }
@@ -31,3 +31,5 @@ export { useCountdown } from './useCountdown/useCountdown';
31
31
  export { useValidateSession } from './useValidateSession';
32
32
  export { useEventListener } from './useEventListener';
33
33
  export { useWalletConnectorEvent } from './useWalletConnectorEvent';
34
+ export { useTransactionWithGasPrice } from './useTransactionWithGasPrice';
35
+ export { useTransactionEstimatedGas } from './useTransactionEstimatedGas';
@@ -3,13 +3,29 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
+ require('@dynamic-labs/sdk-api');
7
+ require('../../../../shared/logger.cjs');
8
+ require('@dynamic-labs/iconic');
9
+ require('@dynamic-labs/wallet-connector-core');
10
+ require('react/jsx-runtime');
11
+ require('../../../../context/ViewContext/ViewContext.cjs');
12
+ require('@dynamic-labs/wallet-book');
13
+ require('@dynamic-labs/utils');
14
+ var localStorage = require('../../../constants/localStorage.cjs');
15
+ require('../../../constants/colors.cjs');
16
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
17
+ require('viem');
18
+ var useLocalStorage = require('../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
19
+ require('../../../../shared/consts/index.cjs');
6
20
 
7
21
  const useMultiWallet = (multiWalletSettings) => {
8
22
  const isMultiWalletEnabled = multiWalletSettings !== null && multiWalletSettings !== void 0 ? multiWalletSettings : false;
9
- const [multiWallet, setMultiWallet] = React.useState(isMultiWalletEnabled);
23
+ const [multiWallet, setMultiWallet] = useLocalStorage.useLocalStorage(localStorage.IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
10
24
  React.useEffect(() => {
11
- setMultiWallet(isMultiWalletEnabled);
12
- }, [isMultiWalletEnabled]);
25
+ if (multiWalletSettings) {
26
+ setMultiWallet(multiWalletSettings);
27
+ }
28
+ }, [multiWalletSettings]);
13
29
  return { multiWallet, setMultiWallet };
14
30
  };
15
31
 
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  export declare const useMultiWallet: (multiWalletSettings?: boolean) => {
3
2
  multiWallet: boolean;
4
- setMultiWallet: import("react").Dispatch<import("react").SetStateAction<boolean>>;
3
+ setMultiWallet: (value: boolean | ((val: boolean) => boolean)) => void;
5
4
  };
@@ -1,11 +1,27 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
+ import '@dynamic-labs/sdk-api';
3
+ import '../../../../shared/logger.js';
4
+ import '@dynamic-labs/iconic';
5
+ import '@dynamic-labs/wallet-connector-core';
6
+ import 'react/jsx-runtime';
7
+ import '../../../../context/ViewContext/ViewContext.js';
8
+ import '@dynamic-labs/wallet-book';
9
+ import '@dynamic-labs/utils';
10
+ import { IS_MULTI_WALLET_ENABLED } from '../../../constants/localStorage.js';
11
+ import '../../../constants/colors.js';
12
+ import '../../../../shared/utils/classes/storage/localStorage.js';
13
+ import 'viem';
14
+ import { useLocalStorage } from '../../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
15
+ import '../../../../shared/consts/index.js';
2
16
 
3
17
  const useMultiWallet = (multiWalletSettings) => {
4
18
  const isMultiWalletEnabled = multiWalletSettings !== null && multiWalletSettings !== void 0 ? multiWalletSettings : false;
5
- const [multiWallet, setMultiWallet] = useState(isMultiWalletEnabled);
19
+ const [multiWallet, setMultiWallet] = useLocalStorage(IS_MULTI_WALLET_ENABLED, isMultiWalletEnabled);
6
20
  useEffect(() => {
7
- setMultiWallet(isMultiWalletEnabled);
8
- }, [isMultiWalletEnabled]);
21
+ if (multiWalletSettings) {
22
+ setMultiWallet(multiWalletSettings);
23
+ }
24
+ }, [multiWalletSettings]);
9
25
  return { multiWallet, setMultiWallet };
10
26
  };
11
27
 
@@ -4,15 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
+ var utils = require('@dynamic-labs/utils');
7
8
  var isWalletLinked = require('../../../functions/isWalletLinked/isWalletLinked.cjs');
8
9
  var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
9
- var AccountExistsContext = require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
10
10
  var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
11
+ var errors = require('../../../constants/errors.cjs');
11
12
 
12
13
  const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showWidgetStatePopup, canSync = true, authMode, }) => {
13
- const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
14
+ const { setShowAuthFlow, isAuthenticated } = useInternalDynamicContext.useInternalDynamicContext();
14
15
  const { setView } = ViewContext.useViewContext();
15
- const { existentAccountData } = AccountExistsContext.useAccountExistsContext();
16
16
  const handlePrimaryWalletNotActive = React.useCallback((connectedAddress) => {
17
17
  if (!primaryWallet)
18
18
  return;
@@ -76,23 +76,28 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
76
76
  .getConnectedAccounts()
77
77
  .then((accounts) => {
78
78
  const [connectedAddress] = accounts;
79
+ if (!connectedAddress) {
80
+ throw new utils.DynamicError('Missing wallet address', errors.MISSING_ADDRESS_ERROR);
81
+ }
79
82
  if (walletConnectorCore.isSameAddress(connectedAddress, primaryWallet.address, primaryWallet.chain)) {
80
83
  return;
81
84
  }
82
85
  handlePrimaryWalletNotActive(connectedAddress);
83
86
  })
84
- .catch(() => {
87
+ .catch((e) => {
85
88
  const connectedSecondaryWallet = secondaryWallets.find((wallet) => wallet.connected);
86
89
  if (connectedSecondaryWallet) {
87
90
  setPrimaryWallet(connectedSecondaryWallet.id);
88
91
  computeConnectedStateForWallets();
89
92
  return;
90
93
  }
91
- // no wallet is connected
92
- setShowAuthFlow(true);
93
- // check needed so 'wallet-locked-view'
94
- // doesn't overwrite 'account-exists' view
95
- if (!existentAccountData) {
94
+ // user is logged in (has valid jwt), but no wallet is connected
95
+ if (isAuthenticated && e.code === errors.MISSING_ADDRESS_ERROR) {
96
+ if (!primaryWallet.connector.isInstalledOnBrowser()) {
97
+ handleLogOut();
98
+ return;
99
+ }
100
+ setShowAuthFlow(true);
96
101
  setView('wallet-locked-view');
97
102
  }
98
103
  });
@@ -109,6 +114,7 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
109
114
  setView,
110
115
  setShowAuthFlow,
111
116
  authMode,
117
+ isAuthenticated,
112
118
  ]);
113
119
  };
114
120
 
@@ -4,7 +4,7 @@ import { AuthModeType, MultiWalletWidgetState, Wallet } from '../../../../shared
4
4
  import { MultiWalletWidgetStateSetter } from '../useMultiWalletWidgetState';
5
5
  export type UseSyncPrimaryWalletArgs = {
6
6
  canSync?: boolean;
7
- connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts) => Promise<string | undefined>;
7
+ connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, shouldCallCallback?: boolean) => Promise<string | undefined>;
8
8
  computeConnectedStateForWallets: () => Promise<void>;
9
9
  handleLogOut: () => Promise<void>;
10
10
  multiWalletWidgetState: MultiWalletWidgetState;
@@ -1,14 +1,14 @@
1
1
  import { useCallback, useEffect } from 'react';
2
2
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
3
+ import { DynamicError } from '@dynamic-labs/utils';
3
4
  import { isWalletLinked } from '../../../functions/isWalletLinked/isWalletLinked.js';
4
5
  import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
5
- import { useAccountExistsContext } from '../../../../context/AccountExistsContext/AccountExistsContext.js';
6
6
  import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
7
+ import { MISSING_ADDRESS_ERROR } from '../../../constants/errors.js';
7
8
 
8
9
  const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showWidgetStatePopup, canSync = true, authMode, }) => {
9
- const { setShowAuthFlow } = useInternalDynamicContext();
10
+ const { setShowAuthFlow, isAuthenticated } = useInternalDynamicContext();
10
11
  const { setView } = useViewContext();
11
- const { existentAccountData } = useAccountExistsContext();
12
12
  const handlePrimaryWalletNotActive = useCallback((connectedAddress) => {
13
13
  if (!primaryWallet)
14
14
  return;
@@ -72,23 +72,28 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
72
72
  .getConnectedAccounts()
73
73
  .then((accounts) => {
74
74
  const [connectedAddress] = accounts;
75
+ if (!connectedAddress) {
76
+ throw new DynamicError('Missing wallet address', MISSING_ADDRESS_ERROR);
77
+ }
75
78
  if (isSameAddress(connectedAddress, primaryWallet.address, primaryWallet.chain)) {
76
79
  return;
77
80
  }
78
81
  handlePrimaryWalletNotActive(connectedAddress);
79
82
  })
80
- .catch(() => {
83
+ .catch((e) => {
81
84
  const connectedSecondaryWallet = secondaryWallets.find((wallet) => wallet.connected);
82
85
  if (connectedSecondaryWallet) {
83
86
  setPrimaryWallet(connectedSecondaryWallet.id);
84
87
  computeConnectedStateForWallets();
85
88
  return;
86
89
  }
87
- // no wallet is connected
88
- setShowAuthFlow(true);
89
- // check needed so 'wallet-locked-view'
90
- // doesn't overwrite 'account-exists' view
91
- if (!existentAccountData) {
90
+ // user is logged in (has valid jwt), but no wallet is connected
91
+ if (isAuthenticated && e.code === MISSING_ADDRESS_ERROR) {
92
+ if (!primaryWallet.connector.isInstalledOnBrowser()) {
93
+ handleLogOut();
94
+ return;
95
+ }
96
+ setShowAuthFlow(true);
92
97
  setView('wallet-locked-view');
93
98
  }
94
99
  });
@@ -105,6 +110,7 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
105
110
  setView,
106
111
  setShowAuthFlow,
107
112
  authMode,
113
+ isAuthenticated,
108
114
  ]);
109
115
  };
110
116