@dynamic-labs/sdk-react-core 0.18.0-beta.31 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/lib/Main.cjs +5 -0
  6. package/src/lib/Main.js +5 -0
  7. package/src/lib/components/Button/Button.cjs +10 -7
  8. package/src/lib/components/Button/Button.js +10 -7
  9. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  10. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  11. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  12. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  13. package/src/lib/components/ListTile/ListTile.js +1 -1
  14. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  15. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
  16. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  17. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
  18. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  19. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  20. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
  21. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
  22. package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
  23. package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
  24. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  25. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  26. package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
  27. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
  28. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
  29. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
  30. package/src/lib/styles/index.shadow.cjs +1 -1
  31. package/src/lib/styles/index.shadow.js +1 -1
  32. package/src/lib/utils/constants/errors.cjs +7 -0
  33. package/src/lib/utils/constants/errors.d.ts +1 -0
  34. package/src/lib/utils/constants/errors.js +3 -0
  35. package/src/lib/utils/constants/index.d.ts +1 -1
  36. package/src/lib/utils/constants/localStorage.cjs +3 -1
  37. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  38. package/src/lib/utils/constants/localStorage.js +3 -2
  39. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  40. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  41. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  42. package/src/lib/utils/functions/index.d.ts +1 -0
  43. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  44. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  45. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  46. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  47. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
  48. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
  49. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
  50. package/src/lib/utils/hooks/index.d.ts +2 -0
  51. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  52. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  53. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  54. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
  55. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  56. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
  57. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
  58. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
  59. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
  60. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  61. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
  62. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  63. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  64. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  65. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  66. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  67. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  68. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  69. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
  70. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
  71. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  72. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
  73. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  74. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
  75. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  76. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
  77. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  78. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -0
  79. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
  80. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
  81. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  82. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
  83. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  84. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
  85. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  86. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  87. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  88. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
  89. package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
  90. package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -1
  91. package/src/lib/views/EmailVerification/EmailVerification.js +7 -2
  92. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
  93. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
  94. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  95. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  96. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
  97. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
  98. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +9 -1
  99. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +9 -1
  100. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
  101. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
  102. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
  103. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
  104. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +11 -16
  105. package/src/lib/views/SendBalanceView/SendBalanceView.js +11 -16
  106. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +66 -0
  107. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  108. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +62 -0
  109. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  110. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  111. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
  112. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
  113. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +22 -4
  114. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +22 -4
  115. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  116. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  117. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +17 -42
  118. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  119. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.js → useTransactionGas/useTransactionGas.js} +18 -43
  120. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  121. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  122. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +7 -0
  123. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  124. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  125. package/src/lib/views/WalletList/WalletList.js +4 -1
  126. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
  127. package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
  128. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  129. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -18
@@ -0,0 +1,57 @@
1
+ import { __awaiter, __rest } from '../../../../../_virtual/_tslib.js';
2
+ import { usePromise } from '../usePromise/usePromise.js';
3
+ import '@dynamic-labs/sdk-api';
4
+ import { logger } from '../../../shared/logger.js';
5
+ import '@dynamic-labs/iconic';
6
+ import '@dynamic-labs/wallet-connector-core';
7
+ import 'react/jsx-runtime';
8
+ import '../../../context/ViewContext/ViewContext.js';
9
+ import 'react';
10
+ import '@dynamic-labs/wallet-book';
11
+ import '@dynamic-labs/utils';
12
+ import '../../constants/colors.js';
13
+ import '../../../shared/utils/classes/storage/localStorage.js';
14
+ import 'ethers';
15
+ import '../../../shared/consts/index.js';
16
+
17
+ /**
18
+ * Hook to estimate the gas required for a transaction.
19
+ *
20
+ * This hook uses the `usePromise` hook to asynchronously estimate the gas required for a transaction.
21
+ * It first tries to estimate the gas without the 'from' field in the transaction, as the Alchemy API
22
+ * checks the origin address funds and can return an error if the origin wallet has no funds for the transaction.
23
+ * If the error 'UNPREDICTABLE_GAS_LIMIT' is encountered, it tries to estimate the gas again with the
24
+ * original transaction.
25
+ *
26
+ * @see {@link https://docs.alchemy.com/reference/eth-estimategas}
27
+ * @see {@link https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT}
28
+ *
29
+ * @param {ethers.providers.Web3Provider} provider - The Web3 provider to use for estimating the gas.
30
+ * @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} transaction - The transaction for
31
+ * which to estimate the gas.
32
+ *
33
+ * @returns {PromiseState<ethers.BigNumber>} A promise that resolves to the estimated gas for the transaction.
34
+ */
35
+ const useTransactionEstimatedGas = (provider, transaction) => usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
36
+ // To safely run estimateGas using alchemy, we need to remove the from address
37
+ // because alchemy checks the origin address funds and can return an error if
38
+ // origin wallet has no funds for the transaction
39
+ // https://docs.alchemy.com/reference/eth-estimategas
40
+ const transactionWithNoOrigin = __rest(transaction, ["from"]);
41
+ try {
42
+ return yield provider.estimateGas(transactionWithNoOrigin);
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ }
45
+ catch (err) {
46
+ logger.error(err);
47
+ // If the error is UNPREDICTABLE_GAS_LIMIT, we try to estimate gas again
48
+ // with original transaction
49
+ // https://docs.ethers.org/v5/troubleshooting/errors/#help-UNPREDICTABLE_GAS_LIMIT
50
+ if (err.code === 'UNPREDICTABLE_GAS_LIMIT') {
51
+ return provider.estimateGas(transaction);
52
+ }
53
+ throw err;
54
+ }
55
+ }), { deps: [transaction, provider] });
56
+
57
+ export { useTransactionEstimatedGas };
@@ -0,0 +1 @@
1
+ export { useTransactionWithGasPrice } from './useTransactionWithGasPrice';
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var usePromise = require('../usePromise/usePromise.cjs');
6
+
7
+ const increaseGasPrice = (gasPrice, increasePercentage) => {
8
+ const increaseFactor = 100 + increasePercentage;
9
+ return gasPrice.mul(increaseFactor).div(100);
10
+ };
11
+ /**
12
+ * A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
13
+ * The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
14
+ * or disable this functionality.
15
+ *
16
+ * @param {Object} props - The properties for the hook.
17
+ * @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
18
+ * @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
19
+ * @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
20
+ * @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
21
+ *
22
+ * @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
23
+ * If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
24
+ * gas price set, the original transaction object is returned.
25
+ *
26
+ * @example
27
+ * const updatedTransaction = useTransactionWithGasPrice({
28
+ * provider: myProvider,
29
+ * transaction: myTransaction,
30
+ * increasePercentage: 10,
31
+ * enabled: true,
32
+ * });
33
+ */
34
+ const useTransactionWithGasPrice = ({ increasePercentage = 0, provider, transaction, enabled = true, }) => {
35
+ const isGasPriceDefinedInTransaction = Boolean(transaction.gasPrice);
36
+ const shouldLoadGasPrice = enabled && increasePercentage > 0 && !isGasPriceDefinedInTransaction;
37
+ const { data: gasPrice } = usePromise.usePromise(() => provider.getGasPrice(), {
38
+ deps: [transaction, provider],
39
+ enabled: shouldLoadGasPrice,
40
+ });
41
+ if (!gasPrice) {
42
+ return transaction;
43
+ }
44
+ return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
45
+ };
46
+
47
+ exports.useTransactionWithGasPrice = useTransactionWithGasPrice;
@@ -0,0 +1,32 @@
1
+ import { ethers } from 'ethers';
2
+ type UseTransactionWithGasPriceProps = {
3
+ provider: ethers.providers.Provider;
4
+ transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
5
+ increasePercentage?: number;
6
+ enabled?: boolean;
7
+ };
8
+ /**
9
+ * A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
10
+ * The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
11
+ * or disable this functionality.
12
+ *
13
+ * @param {Object} props - The properties for the hook.
14
+ * @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
15
+ * @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
16
+ * @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
17
+ * @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
18
+ *
19
+ * @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
20
+ * If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
21
+ * gas price set, the original transaction object is returned.
22
+ *
23
+ * @example
24
+ * const updatedTransaction = useTransactionWithGasPrice({
25
+ * provider: myProvider,
26
+ * transaction: myTransaction,
27
+ * increasePercentage: 10,
28
+ * enabled: true,
29
+ * });
30
+ */
31
+ export declare const useTransactionWithGasPrice: ({ increasePercentage, provider, transaction, enabled, }: UseTransactionWithGasPriceProps) => ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
32
+ export {};
@@ -0,0 +1,43 @@
1
+ import { usePromise } from '../usePromise/usePromise.js';
2
+
3
+ const increaseGasPrice = (gasPrice, increasePercentage) => {
4
+ const increaseFactor = 100 + increasePercentage;
5
+ return gasPrice.mul(increaseFactor).div(100);
6
+ };
7
+ /**
8
+ * A React Hook that returns a transaction object with the gas price set to the current gas price from the provider.
9
+ * The gas price is increased by a certain percentage specified by the user. The hook also allows the user to enable
10
+ * or disable this functionality.
11
+ *
12
+ * @param {Object} props - The properties for the hook.
13
+ * @param {ethers.providers.Provider} props.provider - The provider to use for getting the current gas price.
14
+ * @param {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} props.transaction - The transaction object.
15
+ * @param {number} props.increasePercentage - The percentage by which to increase the current gas price.
16
+ * @param {boolean} [props.enabled=true] - A flag to enable or disable the gas price increase functionality.
17
+ *
18
+ * @returns {ethers.utils.Deferrable<ethers.providers.TransactionRequest>} A new transaction object with the gas price.
19
+ * If the `enabled` flag is set to false, or if the gas price is not available, or if the transaction already has a
20
+ * gas price set, the original transaction object is returned.
21
+ *
22
+ * @example
23
+ * const updatedTransaction = useTransactionWithGasPrice({
24
+ * provider: myProvider,
25
+ * transaction: myTransaction,
26
+ * increasePercentage: 10,
27
+ * enabled: true,
28
+ * });
29
+ */
30
+ const useTransactionWithGasPrice = ({ increasePercentage = 0, provider, transaction, enabled = true, }) => {
31
+ const isGasPriceDefinedInTransaction = Boolean(transaction.gasPrice);
32
+ const shouldLoadGasPrice = enabled && increasePercentage > 0 && !isGasPriceDefinedInTransaction;
33
+ const { data: gasPrice } = usePromise(() => provider.getGasPrice(), {
34
+ deps: [transaction, provider],
35
+ enabled: shouldLoadGasPrice,
36
+ });
37
+ if (!gasPrice) {
38
+ return transaction;
39
+ }
40
+ return Object.assign(Object.assign({}, transaction), { gasPrice: increaseGasPrice(gasPrice, increasePercentage) });
41
+ };
42
+
43
+ export { useTransactionWithGasPrice };
@@ -145,6 +145,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
145
145
  return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
146
146
  const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
147
147
  try {
148
+ setIsVerificationInProgress(true);
148
149
  const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
149
150
  const decodedJwt = decodeJwt.decodeJwt(Jwt);
150
151
  if (decodedJwt === undefined)
@@ -141,6 +141,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
141
141
  return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => __awaiter(void 0, void 0, void 0, function* () {
142
142
  const walletProvider = getWalletProvider(walletConnector);
143
143
  try {
144
+ setIsVerificationInProgress(true);
144
145
  const Jwt = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
145
146
  const decodedJwt = decodeJwt(Jwt);
146
147
  if (decodedJwt === undefined)
@@ -17,7 +17,7 @@ export type UseWalletEventListenersArgs = {
17
17
  setSelectedWalletWithAction(walletWithAction: WalletWithAction | null): void;
18
18
  user: UserProfile | undefined;
19
19
  authMode: AuthModeType;
20
- refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector) => Promise<void>;
20
+ refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector, shouldCallCallback?: boolean) => Promise<void>;
21
21
  };
22
22
  export declare const useWalletEventListeners: ({ computeConnectedStateForWallets, handleLogOut, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnector, setSelectedWalletWithAction, setMultiWalletWidgetState, user, setPrimaryWalletId, authMode, refreshConnectedWallet, }: UseWalletEventListenersArgs) => {
23
23
  loadingNetwork: boolean;
@@ -67,11 +67,11 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
67
67
  }
68
68
  return openSignMessage((resolve, reject) => (jsxRuntime.jsx(SignMessageConfirmationModal.SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
69
69
  }, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
70
- const sendTransaction = React.useCallback(({ transaction, handler, provider }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
70
+ const sendTransaction = React.useCallback(({ transaction, handler, provider, connector }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
71
71
  if (!shouldConfirmAction()) {
72
72
  return handler(transaction);
73
73
  }
74
- return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
74
+ return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { walletConnector: connector, title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
75
75
  }), [openSendTransaction, shouldConfirmAction]);
76
76
  const disabledConfirmationOnce = React.useCallback(() => {
77
77
  confirmationStateRef.current = 'disabled';
@@ -1,4 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { WalletUiUtils } from '@dynamic-labs/types';
3
+ import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
4
  import { WalletUiUtilsHookProps } from './useWalletUiUtils.types';
4
- export declare const useWalletUiUtils: ({ appLogoUrl, appName, getAppOrigin, }: WalletUiUtilsHookProps) => [ReactNode | undefined, WalletUiUtils];
5
+ export declare const useWalletUiUtils: ({ appLogoUrl, appName, getAppOrigin, }: WalletUiUtilsHookProps) => [
6
+ ReactNode | undefined,
7
+ WalletUiUtils<WalletConnector>
8
+ ];
@@ -63,11 +63,11 @@ const useWalletUiUtils = ({ appLogoUrl, appName, getAppOrigin, }) => {
63
63
  }
64
64
  return openSignMessage((resolve, reject) => (jsx(SignMessageConfirmationModal, { appLogoUrl: appLogoUrl, appName: appName, appOrigin: getAppOrigin(), message: message, handler: handler, onSignMessage: resolve, onReject: reject })));
65
65
  }, [appLogoUrl, appName, getAppOrigin, openSignMessage, shouldConfirmAction]);
66
- const sendTransaction = useCallback(({ transaction, handler, provider }) => __awaiter(void 0, void 0, void 0, function* () {
66
+ const sendTransaction = useCallback(({ transaction, handler, provider, connector }) => __awaiter(void 0, void 0, void 0, function* () {
67
67
  if (!shouldConfirmAction()) {
68
68
  return handler(transaction);
69
69
  }
70
- return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
70
+ return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { walletConnector: connector, title: 'Send Transaction', transaction: transaction, handler: handler, onTransactionResponseSuccess: resolve, onReject: reject, provider: provider })));
71
71
  }), [openSendTransaction, shouldConfirmAction]);
72
72
  const disabledConfirmationOnce = useCallback(() => {
73
73
  confirmationStateRef.current = 'disabled';
@@ -1,6 +1,6 @@
1
1
  import { ProjectSettings } from '@dynamic-labs/sdk-api';
2
2
  import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
3
- import { WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
3
+ import { WalletConnector, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
4
4
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
5
  type Props = {
6
6
  appLogoUrl?: string;
@@ -11,7 +11,7 @@ type Props = {
11
11
  walletBook: WalletBookSchema;
12
12
  walletConnectV1Bridge?: string;
13
13
  walletConnectorsProp?: WalletConnectorsMethod[];
14
- walletUiUtils: WalletUiUtils;
14
+ walletUiUtils: WalletUiUtils<WalletConnector>;
15
15
  };
16
16
  export declare const useWallets: ({ projectSettings, appLogoUrl, appName, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, }: Props) => {
17
17
  wallets: import("../../../shared").WalletOption[];
@@ -41,6 +41,7 @@ require('../../../components/Alert/Alert.cjs');
41
41
  require('../../../context/MockContext/MockContext.cjs');
42
42
  require('../../../context/CaptchaContext/CaptchaContext.cjs');
43
43
  require('../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
44
+ var Tooltip = require('../../../components/Tooltip/Tooltip.cjs');
44
45
  require('../../../components/Popper/Popper/Popper.cjs');
45
46
  require('../../../components/Popper/PopperContext/PopperContext.cjs');
46
47
  require('yup');
@@ -63,6 +64,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
63
64
  else if (name === 'policiesConsent') {
64
65
  return (jsxRuntime.jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxRuntime.jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsxRuntime.jsx(formik.Field, { as: Checkbox.Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsxRuntime.jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
65
66
  }
67
+ else if (name === 'email' && !enabled) {
68
+ return (jsxRuntime.jsx(Tooltip.Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsxRuntime.jsx(formik.Field, { disabled: true, as: Input.Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
69
+ }
66
70
  else {
67
71
  return (jsxRuntime.jsx(formik.Field, { disabled: !enabled, as: Input.Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage.getDisplayErrorMessage(label, errors[name]) }, name));
68
72
  }
@@ -37,6 +37,7 @@ import '../../../components/Alert/Alert.js';
37
37
  import '../../../context/MockContext/MockContext.js';
38
38
  import '../../../context/CaptchaContext/CaptchaContext.js';
39
39
  import '../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
40
+ import { Tooltip } from '../../../components/Tooltip/Tooltip.js';
40
41
  import '../../../components/Popper/Popper/Popper.js';
41
42
  import '../../../components/Popper/PopperContext/PopperContext.js';
42
43
  import 'yup';
@@ -59,6 +60,9 @@ const UserDataFields = ({ errors, policiesConsentInnerComponentArray, fields, to
59
60
  else if (name === 'policiesConsent') {
60
61
  return (jsx("div", Object.assign({ role: 'group', "aria-labelledby": 'checkbox-group', className: 'user-data-fields__checkbox-container' }, { children: policiesConsentInnerComponentArray === null || policiesConsentInnerComponentArray === void 0 ? void 0 : policiesConsentInnerComponentArray.map((component, index) => (jsxs("div", Object.assign({ className: 'user-data-fields__consent-checkbox' }, { children: [jsx(Field, { as: Checkbox, id: `policiesConsent_${index}`, name: 'policiesConsentArray', type: 'checkbox', value: `${index}` }, `policiesConsent_${index}`), jsx("label", Object.assign({ htmlFor: `policiesConsent_${index}`, className: 'user-data-fields__checkbox-label' }, { children: jsx(Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: component })) }))] }), `policiesConsent_${index}`))) }), 'policiesConsentGroup'));
61
62
  }
63
+ else if (name === 'email' && !enabled) {
64
+ return (jsx(Tooltip, Object.assign({ content: 'This email is tied to your wallet so cannot be updated', className: 'user-data-fields__tooltip' }, { children: jsx(Field, { disabled: true, as: Input, type: type, id: name, name: name, label: label }, name) }), 'disabled-email-tooltip'));
65
+ }
62
66
  else {
63
67
  return (jsx(Field, { disabled: !enabled, as: Input, type: type, id: name, name: name, label: label, optional: enabled && !required, error: errors[name] && touched[name], message: touched[name] && getDisplayErrorMessage(label, errors[name]) }, name));
64
68
  }
@@ -6,6 +6,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
8
  var iconic = require('@dynamic-labs/iconic');
9
+ var utils = require('@dynamic-labs/utils');
9
10
  var Typography = require('../../components/Typography/Typography.cjs');
10
11
  require('@dynamic-labs/sdk-api');
11
12
  var logger = require('../../shared/logger.cjs');
@@ -13,7 +14,6 @@ require('@dynamic-labs/wallet-connector-core');
13
14
  var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
14
15
  var chevronLeft = require('../../shared/assets/chevron-left.cjs');
15
16
  require('@dynamic-labs/wallet-book');
16
- require('@dynamic-labs/utils');
17
17
  require('../../utils/constants/colors.cjs');
18
18
  require('../../shared/utils/classes/storage/localStorage.cjs');
19
19
  require('ethers');
@@ -55,18 +55,23 @@ const EmailUpdate = () => {
55
55
  const { loading, setLoading } = LoadingContext.useLoadingContext();
56
56
  const { setView, goToInitialView } = ViewContext.useViewContext();
57
57
  const { email, setEmail, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
58
- const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
58
+ const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext.useInternalDynamicContext();
59
+ const [emailError, setEmailError] = React.useState(undefined);
59
60
  const handleBackClick = () => {
60
61
  setView('verify-email');
61
62
  setError(undefined);
62
63
  };
64
+ // If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
65
+ // If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
66
+ const jwtToken = authToken || onboardingOnlyJwt;
63
67
  const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
64
68
  try {
65
69
  if (!updatedEmail) {
66
70
  return;
67
71
  }
72
+ setEmailError(undefined);
68
73
  setLoading(true);
69
- const { emailVerification } = yield api.updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
74
+ const { emailVerification } = yield api.updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
70
75
  if (!emailVerification) {
71
76
  yield handleLogOut();
72
77
  goToInitialView();
@@ -79,6 +84,10 @@ const EmailUpdate = () => {
79
84
  }
80
85
  catch (error) {
81
86
  logger.logger.debug(error);
87
+ if (error instanceof utils.EmailAlreadyExistsError) {
88
+ setEmailError('Email already exists');
89
+ return;
90
+ }
82
91
  setErrorMessage(error.code);
83
92
  }
84
93
  finally {
@@ -90,7 +99,7 @@ const EmailUpdate = () => {
90
99
  width: '3.125rem',
91
100
  }, className: 'email-update__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-update__title' }, { children: "Update Email" })), jsxRuntime.jsxs("div", Object.assign({ className: 'email-update__copy-text-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your current email address is" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: email }))] })), jsxRuntime.jsx(Input.Input, { id: 'email_field', onChange: (e) => {
92
101
  setUpdatedEmail(e.target.value);
93
- }, type: 'email', label: 'Email address', className: 'email-update__input' }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
102
+ }, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
94
103
  };
95
104
 
96
105
  exports.EmailUpdate = EmailUpdate;
@@ -2,6 +2,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
4
  import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
5
+ import { EmailAlreadyExistsError } from '@dynamic-labs/utils';
5
6
  import { Typography } from '../../components/Typography/Typography.js';
6
7
  import '@dynamic-labs/sdk-api';
7
8
  import { logger } from '../../shared/logger.js';
@@ -9,7 +10,6 @@ import '@dynamic-labs/wallet-connector-core';
9
10
  import { useViewContext } from '../../context/ViewContext/ViewContext.js';
10
11
  import { ReactComponent as SvgChevronLeft } from '../../shared/assets/chevron-left.js';
11
12
  import '@dynamic-labs/wallet-book';
12
- import '@dynamic-labs/utils';
13
13
  import '../../utils/constants/colors.js';
14
14
  import '../../shared/utils/classes/storage/localStorage.js';
15
15
  import 'ethers';
@@ -51,18 +51,23 @@ const EmailUpdate = () => {
51
51
  const { loading, setLoading } = useLoadingContext();
52
52
  const { setView, goToInitialView } = useViewContext();
53
53
  const { email, setEmail, setVerificationUUID } = useEmailVerificationContext();
54
- const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
54
+ const { environmentId, handleLogOut, onboardingOnlyJwt, authToken } = useInternalDynamicContext();
55
+ const [emailError, setEmailError] = useState(undefined);
55
56
  const handleBackClick = () => {
56
57
  setView('verify-email');
57
58
  setError(undefined);
58
59
  };
60
+ // If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
61
+ // If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
62
+ const jwtToken = authToken || onboardingOnlyJwt;
59
63
  const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
60
64
  try {
61
65
  if (!updatedEmail) {
62
66
  return;
63
67
  }
68
+ setEmailError(undefined);
64
69
  setLoading(true);
65
- const { emailVerification } = yield updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
70
+ const { emailVerification } = yield updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
66
71
  if (!emailVerification) {
67
72
  yield handleLogOut();
68
73
  goToInitialView();
@@ -75,6 +80,10 @@ const EmailUpdate = () => {
75
80
  }
76
81
  catch (error) {
77
82
  logger.debug(error);
83
+ if (error instanceof EmailAlreadyExistsError) {
84
+ setEmailError('Email already exists');
85
+ return;
86
+ }
78
87
  setErrorMessage(error.code);
79
88
  }
80
89
  finally {
@@ -86,7 +95,7 @@ const EmailUpdate = () => {
86
95
  width: '3.125rem',
87
96
  }, className: 'email-update__icon' }), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-update__title' }, { children: "Update Email" })), jsxs("div", Object.assign({ className: 'email-update__copy-text-container' }, { children: [jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your current email address is" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: email }))] })), jsx(Input, { id: 'email_field', onChange: (e) => {
88
97
  setUpdatedEmail(e.target.value);
89
- }, type: 'email', label: 'Email address', className: 'email-update__input' }), jsx(Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
98
+ }, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsx(Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
90
99
  };
91
100
 
92
101
  export { EmailUpdate };
@@ -69,7 +69,7 @@ const EmailVerification = () => {
69
69
  const { view, setView, goToInitialView } = ViewContext.useViewContext();
70
70
  const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
71
71
  const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
72
- const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
72
+ const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext.useInternalDynamicContext();
73
73
  const { email, verificationUUID, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
74
74
  const { loading, setLoading } = LoadingContext.useLoadingContext();
75
75
  const { remainingSeconds, startCountdown } = useCountdown.useCountdown({
@@ -79,6 +79,11 @@ const EmailVerification = () => {
79
79
  const isLoginView = view === 'login-with-email-verification';
80
80
  const { verifyEmail } = useEmailVerificationRequest.useEmailVerificationRequest();
81
81
  const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
82
+ // Set verification in progress
83
+ // It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
84
+ React.useEffect(() => {
85
+ setIsVerificationInProgress(true);
86
+ }, []);
82
87
  const handleComplete = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
83
88
  setError(undefined);
84
89
  setLoading(true);
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from '../../../../_virtual/_tslib.js';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
- import { useState, useCallback } from 'react';
3
+ import { useState, useEffect, useCallback } from 'react';
4
4
  import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
5
5
  import { UserHasAccountWithEmailError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
6
6
  import { Typography } from '../../components/Typography/Typography.js';
@@ -65,7 +65,7 @@ const EmailVerification = () => {
65
65
  const { view, setView, goToInitialView } = useViewContext();
66
66
  const { error, setError, setErrorMessage } = useErrorContext();
67
67
  const { setExistentAccountData } = useAccountExistsContext();
68
- const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
68
+ const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, } = useInternalDynamicContext();
69
69
  const { email, verificationUUID, setVerificationUUID } = useEmailVerificationContext();
70
70
  const { loading, setLoading } = useLoadingContext();
71
71
  const { remainingSeconds, startCountdown } = useCountdown({
@@ -75,6 +75,11 @@ const EmailVerification = () => {
75
75
  const isLoginView = view === 'login-with-email-verification';
76
76
  const { verifyEmail } = useEmailVerificationRequest();
77
77
  const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
78
+ // Set verification in progress
79
+ // It should be disabled by either clearStatesOnBackClick, the close button, or onAuthSuccess
80
+ useEffect(() => {
81
+ setIsVerificationInProgress(true);
82
+ }, []);
78
83
  const handleComplete = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
79
84
  setError(undefined);
80
85
  setLoading(true);
@@ -47,7 +47,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
47
47
  const EmailWalletOTPVerificationView = () => {
48
48
  const { setView } = ViewContext.useViewContext();
49
49
  const [error, setError] = React.useState();
50
- const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext.useInternalDynamicContext();
50
+ const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
51
51
  if (!emailWalletConnector ||
52
52
  !walletConnectorCore.isEmailOTPWalletConnector(emailWalletConnector)) {
53
53
  throw new Error('Current wallet is not EmailWalletConnector');
@@ -61,10 +61,11 @@ const EmailWalletOTPVerificationView = () => {
61
61
  clearStatesOnBackClick();
62
62
  setView('login-with-email-or-wallet');
63
63
  };
64
+ const handleOnClickClose = () => setShowAuthFlow(false);
64
65
  const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
65
66
  onFailure: (error) => setError(error),
66
67
  });
67
- return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
68
+ return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
68
69
  };
69
70
 
70
71
  exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
@@ -43,7 +43,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
43
43
  const EmailWalletOTPVerificationView = () => {
44
44
  const { setView } = useViewContext();
45
45
  const [error, setError] = useState();
46
- const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext();
46
+ const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext();
47
47
  if (!emailWalletConnector ||
48
48
  !isEmailOTPWalletConnector(emailWalletConnector)) {
49
49
  throw new Error('Current wallet is not EmailWalletConnector');
@@ -57,10 +57,11 @@ const EmailWalletOTPVerificationView = () => {
57
57
  clearStatesOnBackClick();
58
58
  setView('login-with-email-or-wallet');
59
59
  };
60
+ const handleOnClickClose = () => setShowAuthFlow(false);
60
61
  const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
61
62
  onFailure: (error) => setError(error),
62
63
  });
63
- return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
64
+ return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
64
65
  };
65
66
 
66
67
  export { EmailWalletOTPVerificationView };
@@ -26,7 +26,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
26
26
  const { setView } = ViewContext.useViewContext();
27
27
  const { projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
28
28
  const isUsingMultiWallet = Boolean(localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_USER));
29
- return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key))), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
29
+ return !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxRuntime.jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
30
+ var _a;
31
+ return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
32
+ }), jsxRuntime.jsx(ListItemButton.ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
30
33
  };
31
34
 
32
35
  exports.LoginWithEmailWalletList = LoginWithEmailWalletList;
@@ -22,7 +22,10 @@ const LoginWithEmailWalletList = ({ walletsList, numberOfWallets, }) => {
22
22
  const { setView } = useViewContext();
23
23
  const { projectSettings } = useInternalDynamicContext();
24
24
  const isUsingMultiWallet = Boolean(LocalStorage.getFromLS(AUTH_USER));
25
- return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key))), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
25
+ return !projectSettings ? (jsx(Skeleton, { count: NUMBER_OF_WALLETS + 1, className: 'login-with-email-wallet-list__skeleton' })) : (jsxs("div", Object.assign({ className: 'login-with-email-wallet-list__container' }, { children: [walletsList.map((wallet) => {
26
+ var _a;
27
+ return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
28
+ }), jsx(ListItemButton, { text: 'View all wallets', onClick: () => setView('login-with-email-or-wallet-full-wallet-list'), numberOfWallets: numberOfWallets })] })));
26
29
  };
27
30
 
28
31
  export { LoginWithEmailWalletList, NUMBER_OF_WALLETS };
@@ -78,7 +78,7 @@ const SocialSignIn = () => {
78
78
  const closeButton = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })));
79
79
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in', style: {
80
80
  '--number-of-social-grid-items': numberOfSocialGridItems,
81
- } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
81
+ } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
82
82
  };
83
83
 
84
84
  exports.SocialSignIn = SocialSignIn;
@@ -74,7 +74,7 @@ const SocialSignIn = () => {
74
74
  const closeButton = (jsx(IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsx(SvgClose, {}) })));
75
75
  return (jsxs(Fragment, { children: [jsxs("div", Object.assign({ className: 'social-sign-in', style: {
76
76
  '--number-of-social-grid-items': numberOfSocialGridItems,
77
- } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsx(IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
77
+ } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsx(IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile' }, { children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
78
78
  };
79
79
 
80
80
  export { SocialSignIn };