@dynamic-labs/sdk-react-core 0.18.0-beta.32 → 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 (115) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/lib/components/Button/Button.cjs +10 -7
  6. package/src/lib/components/Button/Button.js +10 -7
  7. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  8. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  9. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  10. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
  11. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
  12. package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
  13. package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
  14. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  15. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  16. package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
  17. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
  18. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
  19. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
  20. package/src/lib/styles/index.shadow.cjs +1 -1
  21. package/src/lib/styles/index.shadow.js +1 -1
  22. package/src/lib/utils/constants/errors.cjs +7 -0
  23. package/src/lib/utils/constants/errors.d.ts +1 -0
  24. package/src/lib/utils/constants/errors.js +3 -0
  25. package/src/lib/utils/constants/index.d.ts +1 -1
  26. package/src/lib/utils/constants/localStorage.cjs +3 -1
  27. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  28. package/src/lib/utils/constants/localStorage.js +3 -2
  29. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  30. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  31. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  32. package/src/lib/utils/functions/index.d.ts +1 -0
  33. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  34. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  35. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  36. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  37. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
  38. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
  39. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
  40. package/src/lib/utils/hooks/index.d.ts +2 -0
  41. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  42. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  43. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  44. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
  45. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  46. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
  47. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
  48. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
  49. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
  50. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  51. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
  52. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  53. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  54. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  55. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  56. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  57. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  58. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  59. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
  60. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
  61. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  62. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
  63. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  64. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
  65. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  66. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
  67. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  68. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -0
  69. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
  70. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
  71. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  72. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
  73. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  74. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
  75. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  76. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  77. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  78. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +5 -2
  79. package/src/lib/views/EmailUpdate/EmailUpdate.js +5 -2
  80. package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -1
  81. package/src/lib/views/EmailVerification/EmailVerification.js +7 -2
  82. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  83. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  84. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +4 -0
  85. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +4 -0
  86. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
  87. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
  88. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
  89. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
  90. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +11 -16
  91. package/src/lib/views/SendBalanceView/SendBalanceView.js +11 -16
  92. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +66 -0
  93. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  94. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +62 -0
  95. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  96. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  97. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
  98. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
  99. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +22 -4
  100. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +22 -4
  101. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  102. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  103. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +17 -42
  104. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  105. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.js → useTransactionGas/useTransactionGas.js} +18 -43
  106. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  107. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  108. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +7 -0
  109. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  110. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  111. package/src/lib/views/WalletList/WalletList.js +4 -1
  112. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
  113. package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
  114. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  115. 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
  }
@@ -55,12 +55,15 @@ 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
59
  const [emailError, setEmailError] = React.useState(undefined);
60
60
  const handleBackClick = () => {
61
61
  setView('verify-email');
62
62
  setError(undefined);
63
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;
64
67
  const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
65
68
  try {
66
69
  if (!updatedEmail) {
@@ -68,7 +71,7 @@ const EmailUpdate = () => {
68
71
  }
69
72
  setEmailError(undefined);
70
73
  setLoading(true);
71
- const { emailVerification } = yield api.updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
74
+ const { emailVerification } = yield api.updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
72
75
  if (!emailVerification) {
73
76
  yield handleLogOut();
74
77
  goToInitialView();
@@ -51,12 +51,15 @@ 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
55
  const [emailError, setEmailError] = useState(undefined);
56
56
  const handleBackClick = () => {
57
57
  setView('verify-email');
58
58
  setError(undefined);
59
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;
60
63
  const handleEmailUpdate = () => __awaiter(void 0, void 0, void 0, function* () {
61
64
  try {
62
65
  if (!updatedEmail) {
@@ -64,7 +67,7 @@ const EmailUpdate = () => {
64
67
  }
65
68
  setEmailError(undefined);
66
69
  setLoading(true);
67
- const { emailVerification } = yield updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
70
+ const { emailVerification } = yield updateUserProfileFields(jwtToken, environmentId, { email: updatedEmail });
68
71
  if (!emailVerification) {
69
72
  yield handleLogOut();
70
73
  goToInitialView();
@@ -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);
@@ -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 };
@@ -84,6 +84,10 @@ const MergeUserAccountsView = () => {
84
84
  }
85
85
  catch (e) {
86
86
  setError('Something went wrong, please try again.');
87
+ if (user) {
88
+ setShowAuthFlow(false);
89
+ return;
90
+ }
87
91
  goToInitialView();
88
92
  }
89
93
  });
@@ -80,6 +80,10 @@ const MergeUserAccountsView = () => {
80
80
  }
81
81
  catch (e) {
82
82
  setError('Something went wrong, please try again.');
83
+ if (user) {
84
+ setShowAuthFlow(false);
85
+ return;
86
+ }
83
87
  goToInitialView();
84
88
  }
85
89
  });
@@ -57,6 +57,7 @@ const NetworkNotSupported = () => {
57
57
  // Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
58
58
  const { data: walletConnectorNetwork } = usePromise.usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
59
59
  const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
60
+ shouldCallCallback: false,
60
61
  shouldUpdateWallets: !isFullyConnected,
61
62
  });
62
63
  const [isNetworkPickerOpen, setIsNetworkPickerOpen] = React.useState(false);
@@ -53,6 +53,7 @@ const NetworkNotSupported = () => {
53
53
  // Refresh selectedWalletConnector network when primaryWallet or connectedWallets updates
54
54
  const { data: walletConnectorNetwork } = usePromise(() => walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.getNetwork(), { deps: [primaryWallet, walletConnector, connectedWallets] });
55
55
  const finishConnectAndSign = useConnectAndSign({
56
+ shouldCallCallback: false,
56
57
  shouldUpdateWallets: !isFullyConnected,
57
58
  });
58
59
  const [isNetworkPickerOpen, setIsNetworkPickerOpen] = useState(false);
@@ -60,6 +60,7 @@ const NetworkNotSupportedSwitchManual = () => {
60
60
  deps: [walletConnector, connectedWallets],
61
61
  });
62
62
  const finishConnectAndSign = useConnectAndSign.useConnectAndSign({
63
+ shouldCallCallback: false,
63
64
  shouldUpdateWallets: !isFullyConnected,
64
65
  });
65
66
  // Finishes auth flow when wallet switches to proper network
@@ -56,6 +56,7 @@ const NetworkNotSupportedSwitchManual = () => {
56
56
  deps: [walletConnector, connectedWallets],
57
57
  });
58
58
  const finishConnectAndSign = useConnectAndSign({
59
+ shouldCallCallback: false,
59
60
  shouldUpdateWallets: !isFullyConnected,
60
61
  });
61
62
  // Finishes auth flow when wallet switches to proper network
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _tslib = require('../../../../_virtual/_tslib.cjs');
6
5
  var jsxRuntime = require('react/jsx-runtime');
7
6
  var React = require('react');
8
7
  var ethers = require('ethers');
@@ -42,9 +41,9 @@ require('../../components/Popper/PopperContext/PopperContext.cjs');
42
41
  var SendBalancePageLayout = require('../../components/SendBalancePageLayout/SendBalancePageLayout.cjs');
43
42
  require('../../components/InlineWidget/InlineWidget.cjs');
44
43
  require('../../components/MenuList/Dropdown/Dropdown.cjs');
45
- var TransactionConfirmationView = require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
46
- var TransactionStatusLayout = require('../../components/TransactionStatusLayout/TransactionStatusLayout.cjs');
47
44
  var useFetchCurrency = require('../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs');
45
+ var TransactionStatusLayout = require('../../components/TransactionStatusLayout/TransactionStatusLayout.cjs');
46
+ var TransactionStage = require('./components/TransactionStage/TransactionStage.cjs');
48
47
  require('../../context/MockContext/MockContext.cjs');
49
48
  require('../../context/CaptchaContext/CaptchaContext.cjs');
50
49
  var usePromise = require('../../utils/hooks/usePromise/usePromise.cjs');
@@ -52,18 +51,19 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
52
51
 
53
52
  const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
54
53
  const [stage, setStage] = React.useState('form');
55
- const { primaryWallet, walletUiUtils, network } = useInternalDynamicContext.useInternalDynamicContext();
54
+ const { primaryWallet, network } = useInternalDynamicContext.useInternalDynamicContext();
56
55
  const [value, setValue] = React.useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
57
56
  const [recipientAddress, setRecipientAddress] = React.useState(initialRecipientAddress);
58
57
  const transactionRef = React.useRef(null);
59
58
  if (!primaryWallet) {
60
59
  throw new utils.DynamicError('Primary wallet is not available, send balance cannot be displayed');
61
60
  }
62
- const { data: balance } = usePromise.usePromise(() => primaryWallet.connector.getBalance());
63
- const { data: provider } = usePromise.usePromise(() => primaryWallet.connector.getWeb3Provider());
64
- const evmNetworks = ((primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) &&
65
- primaryWallet.connector.evmNetworks) ||
66
- [];
61
+ const walletConnector = primaryWallet.connector;
62
+ const { data: balance } = usePromise.usePromise(() => walletConnector.getBalance(), {
63
+ deps: [walletConnector],
64
+ });
65
+ const { data: provider } = usePromise.usePromise(() => walletConnector.getWeb3Provider(), { deps: [walletConnector] });
66
+ const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
67
67
  const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
68
68
  const networkIcon = evmNetwork && (jsxRuntime.jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
69
69
  const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
@@ -88,16 +88,11 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
88
88
  to: recipientAddress,
89
89
  value,
90
90
  };
91
- return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, { provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
91
+ return (jsxRuntime.jsx(TransactionStage.TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
92
92
  transactionRef.current = transaction;
93
93
  setStage('success');
94
94
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
95
- }, mutation: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
96
- walletUiUtils.disabledConfirmationOnce();
97
- const signer = provider.getSigner();
98
- const sentTransaction = yield signer.sendTransaction(transaction);
99
- return sentTransaction;
100
- }) }));
95
+ } }));
101
96
  };
102
97
  const buildSuccessState = () => {
103
98
  var _a;