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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/index.cjs +2 -0
  6. package/src/index.js +1 -0
  7. package/src/lib/Main.cjs +5 -0
  8. package/src/lib/Main.js +5 -0
  9. package/src/lib/components/Button/Button.cjs +10 -7
  10. package/src/lib/components/Button/Button.js +10 -7
  11. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  12. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  13. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  14. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  15. package/src/lib/components/ListTile/ListTile.js +1 -1
  16. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  17. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
  18. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  19. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
  20. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  21. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  22. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
  23. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
  24. package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
  25. package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
  26. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  27. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  28. package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
  29. package/src/lib/context/SendBalanceContext/SendBalanceContext.types.d.ts +2 -2
  30. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  31. package/src/lib/data/api.cjs +16 -0
  32. package/src/lib/data/api.d.ts +1 -0
  33. package/src/lib/data/api.js +18 -3
  34. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
  35. package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
  36. package/src/lib/modals/SendBalanceModal/SendBalanceModal.d.ts +2 -2
  37. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
  38. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
  39. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +6 -3
  40. package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
  41. package/src/lib/shared/assets/double-arrow-right.js +29 -0
  42. package/src/lib/shared/assets/index.d.ts +1 -0
  43. package/src/lib/styles/index.shadow.cjs +1 -1
  44. package/src/lib/styles/index.shadow.js +1 -1
  45. package/src/lib/utils/constants/errors.cjs +7 -0
  46. package/src/lib/utils/constants/errors.d.ts +1 -0
  47. package/src/lib/utils/constants/errors.js +3 -0
  48. package/src/lib/utils/constants/index.d.ts +1 -1
  49. package/src/lib/utils/constants/localStorage.cjs +2 -0
  50. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  51. package/src/lib/utils/constants/localStorage.js +2 -1
  52. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  53. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  54. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  55. package/src/lib/utils/functions/index.d.ts +1 -0
  56. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  57. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  58. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  59. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  60. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
  61. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
  62. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
  63. package/src/lib/utils/hooks/index.d.ts +2 -0
  64. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  65. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  66. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  67. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
  68. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  69. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
  70. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
  71. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
  72. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
  73. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  74. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
  75. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  76. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  77. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  78. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  79. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  80. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  81. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  82. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
  83. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
  84. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  85. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +31 -0
  86. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  87. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +27 -0
  88. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  89. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +56 -0
  90. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  91. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +52 -0
  92. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
  93. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
  94. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  95. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
  96. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  97. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
  98. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  99. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.cjs +9 -3
  100. package/src/lib/views/CaptchaVerifyUser/CaptchaVerifyUser.js +9 -3
  101. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  102. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  103. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
  104. package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
  105. package/src/lib/views/EmailVerification/EmailVerification.cjs +12 -1
  106. package/src/lib/views/EmailVerification/EmailVerification.js +14 -3
  107. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
  108. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
  109. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  110. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  111. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
  112. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
  113. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +111 -0
  114. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
  115. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +107 -0
  116. package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
  117. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
  118. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
  119. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
  120. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
  121. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +14 -35
  122. package/src/lib/views/SendBalanceView/SendBalanceView.d.ts +2 -2
  123. package/src/lib/views/SendBalanceView/SendBalanceView.js +15 -36
  124. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +73 -0
  125. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  126. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +69 -0
  127. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  128. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  129. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
  130. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
  131. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +31 -8
  132. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.d.ts +4 -3
  133. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +32 -9
  134. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  135. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  136. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.cjs +69 -0
  137. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  138. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.js +65 -0
  139. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  140. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  141. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +6 -0
  142. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  143. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  144. package/src/lib/views/WalletList/WalletList.js +4 -1
  145. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
  146. package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
  147. package/src/lib/views/viewToComponentMap.cjs +2 -0
  148. package/src/lib/views/viewToComponentMap.js +2 -0
  149. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  150. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +0 -104
  151. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -17
  152. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +0 -100
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
+ import { TransactionConfirmationViewProps } from '../../../TransactionConfirmationView';
4
+ type TransactionStageProps = Omit<TransactionConfirmationViewProps, 'mutation'> & {
5
+ walletConnector: WalletConnector;
6
+ };
7
+ export declare const TransactionStage: FC<TransactionStageProps>;
8
+ export {};
@@ -0,0 +1,69 @@
1
+ import { __rest, __awaiter } from '../../../../../../_virtual/_tslib.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import 'react';
4
+ import '@dynamic-labs/utils';
5
+ import '@dynamic-labs/sdk-api';
6
+ import '../../../../config/ApiEndpoint.js';
7
+ import '../../../../shared/logger.js';
8
+ import '@dynamic-labs/iconic';
9
+ import '@dynamic-labs/wallet-connector-core';
10
+ import '../../../../context/ViewContext/ViewContext.js';
11
+ import '@dynamic-labs/wallet-book';
12
+ import '../../../../utils/constants/colors.js';
13
+ import '../../../../shared/utils/classes/storage/localStorage.js';
14
+ import 'viem';
15
+ import '../../../../shared/consts/index.js';
16
+ import '@dynamic-labs/multi-wallet';
17
+ import { isMagicConnector } from '../../../../utils/functions/isMagicConnector/isMagicConnector.js';
18
+ import '@dynamic-labs/rpc-providers';
19
+ import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
20
+ import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
21
+ import '../../../../context/ErrorContext/ErrorContext.js';
22
+ import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
23
+ import '../../../../context/AccountExistsContext/AccountExistsContext.js';
24
+ import 'react-dom';
25
+ import '../../../../components/ShadowDOM/ShadowDOM.js';
26
+ import '../../../../context/ThemeContext/ThemeContext.js';
27
+ import 'react-focus-lock';
28
+ import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
29
+ import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
30
+ import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
31
+ import '../../../../components/IconButton/IconButton.js';
32
+ import '../../../../components/Alert/Alert.js';
33
+ import '../../../../components/Popper/Popper/Popper.js';
34
+ import '../../../../components/Popper/PopperContext/PopperContext.js';
35
+ import 'formik';
36
+ import 'yup';
37
+ import '../../../../components/InlineWidget/InlineWidget.js';
38
+ import '../../../../components/MenuList/Dropdown/Dropdown.js';
39
+ import { TransactionConfirmationView } from '../../../TransactionConfirmationView/TransactionConfirmationView.js';
40
+ import '../../../../context/MockContext/MockContext.js';
41
+ import '../../../../context/CaptchaContext/CaptchaContext.js';
42
+ import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
43
+ import { useTransactionWithGasPrice } from '../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js';
44
+
45
+ const TransactionStage = (_a) => {
46
+ var { transaction, provider, walletConnector } = _a, rest = __rest(_a, ["transaction", "provider", "walletConnector"]);
47
+ const { walletUiUtils } = useInternalDynamicContext();
48
+ const transactionWithGasPrice = useTransactionWithGasPrice({
49
+ enabled: isMagicConnector(walletConnector),
50
+ increasePercentage: 5,
51
+ provider,
52
+ transaction,
53
+ });
54
+ return (jsx(TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => __awaiter(void 0, void 0, void 0, function* () {
55
+ walletUiUtils.disabledConfirmationOnce();
56
+ const signer = yield walletConnector.getSigner();
57
+ const sentTransaction = yield signer.sendTransaction({
58
+ account: transactionWithGasPrice.from,
59
+ chain: null,
60
+ gasPrice: transactionWithGasPrice.gasPrice,
61
+ to: transactionWithGasPrice.to,
62
+ type: 'eip2930',
63
+ value: transactionWithGasPrice.value,
64
+ });
65
+ return sentTransaction;
66
+ }) }, rest)));
67
+ };
68
+
69
+ export { TransactionStage };
@@ -0,0 +1 @@
1
+ export { TransactionStage } from './TransactionStage';
@@ -0,0 +1 @@
1
+ export * from './TransactionStage';
@@ -47,14 +47,13 @@ require('../../components/InlineWidget/InlineWidget.cjs');
47
47
  require('../../components/MenuList/Dropdown/Dropdown.cjs');
48
48
  var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
49
49
 
50
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
51
50
  const SocialRedirectView = () => {
52
51
  const { socialProvider, socialWalletConnector } = SocialRedirectContext.useSocialRedirectContext();
53
52
  const getSocialIcon = useGetSocialIcon.useGetSocialIcon();
54
53
  if (!socialWalletConnector || !socialProvider) {
55
54
  return null;
56
55
  }
57
- return (jsxRuntime.jsxs("div", { className: classNames.classNames('social-redirect-view__container'), children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsxs(Typography.Typography, { weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title'), children: ["Connecting to ", capitalize(socialProvider), "..."] })] }));
56
+ return (jsxRuntime.jsxs("div", { className: classNames.classNames('social-redirect-view__container'), children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title'), children: "Logging you in" })] }));
58
57
  };
59
58
 
60
59
  exports.SocialRedirectView = SocialRedirectView;
@@ -43,14 +43,13 @@ import '../../components/InlineWidget/InlineWidget.js';
43
43
  import '../../components/MenuList/Dropdown/Dropdown.js';
44
44
  import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
45
45
 
46
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
47
46
  const SocialRedirectView = () => {
48
47
  const { socialProvider, socialWalletConnector } = useSocialRedirectContext();
49
48
  const getSocialIcon = useGetSocialIcon();
50
49
  if (!socialWalletConnector || !socialProvider) {
51
50
  return null;
52
51
  }
53
- return (jsxs("div", { className: classNames('social-redirect-view__container'), children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxs(Typography, { weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title'), children: ["Connecting to ", capitalize(socialProvider), "..."] })] }));
52
+ return (jsxs("div", { className: classNames('social-redirect-view__container'), children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsx(Typography, { weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title'), children: "Logging you in" })] }));
54
53
  };
55
54
 
56
55
  export { SocialRedirectView };
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
5
6
  var jsxRuntime = require('react/jsx-runtime');
6
7
  var React = require('react');
7
8
  var viem = require('viem');
@@ -46,7 +47,8 @@ require('yup');
46
47
  require('../../components/InlineWidget/InlineWidget.cjs');
47
48
  require('../../components/MenuList/Dropdown/Dropdown.cjs');
48
49
  var useFetchCurrency = require('../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.cjs');
49
- var useTransactionData = require('./hooks/useTransactionData/useTransactionData.cjs');
50
+ var useTransactionGas = require('./hooks/useTransactionGas/useTransactionGas.cjs');
51
+ var useTransactionTotal = require('./hooks/useTransactionTotal/useTransactionTotal.cjs');
50
52
  var transactionErrorMessage = require('./helpers/transactionErrorMessage.cjs');
51
53
  require('../../context/MockContext/MockContext.cjs');
52
54
  require('../../context/CaptchaContext/CaptchaContext.cjs');
@@ -54,23 +56,42 @@ var usePromise = require('../../utils/hooks/usePromise/usePromise.cjs');
54
56
  var useMutation = require('../../utils/hooks/useMutation/useMutation.cjs');
55
57
  require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
56
58
 
57
- const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess, onClickBack, onClickClose, title, displayPoweredByDynamicFooter = false, }) => {
59
+ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess, onClickBack, onClickClose, title, displayPoweredByDynamicFooter = false, provider, }) => {
58
60
  const { appName, appLogoUrl, primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
59
61
  const appOrigin = getAppOrigin.getAppOrigin();
60
62
  if (!primaryWallet) {
61
63
  throw new utils.DynamicError('Primary wallet is not available, transaction cannot be displayed');
62
64
  }
63
65
  const [currencySymbol] = useFetchCurrency.useFetchCurrency(primaryWallet.connector);
64
- const { data: balance } = usePromise.usePromise(() => primaryWallet.connector
65
- .getBalance()
66
- .then((balanceText) => balanceText ? viem.parseEther(balanceText) : undefined));
66
+ const { data: balance } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
67
+ const balanceText = yield primaryWallet.connector.getBalance();
68
+ return balanceText ? viem.parseEther(balanceText) : undefined;
69
+ }));
67
70
  const { mutate: send, isLoading, error: transactionError, } = useMutation.useMutation(mutation, {
68
71
  onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
69
72
  onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
70
73
  });
71
- const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData.useTransactionData({
74
+ const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas.useTransactionGas({
75
+ provider,
72
76
  transaction,
73
77
  });
78
+ const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise.usePromise(() => transaction.to);
79
+ const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise.usePromise(() => transaction.from);
80
+ const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
81
+ const val = yield transaction.value;
82
+ if (viem.isHex(val)) {
83
+ return viem.hexToBigInt(val);
84
+ }
85
+ return val ? val : undefined;
86
+ }));
87
+ const total = useTransactionTotal.useTransactionTotal({
88
+ gasTotalPrice,
89
+ transactionValue,
90
+ });
91
+ const isTransactionLoading = isTransactionValueLoading ||
92
+ isGasPriceLoading ||
93
+ isTransactionToAddressLoading ||
94
+ isTransactionFromAddressLoading;
74
95
  const ChainIconComponent = getChainIcon.getChainIcon(primaryWallet.chain);
75
96
  const chainIcon = (jsxRuntime.jsx(Icon.Icon, { size: 'small', children: jsxRuntime.jsx(ChainIconComponent, {}) }));
76
97
  const errorMessage = transactionError && transactionErrorMessage.transactionErrorMessage(transactionError);
@@ -91,8 +112,10 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
91
112
  const amountLeft = formatBigNumber.formatBigNumber(missingFunds, 5);
92
113
  return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
93
114
  }, [currencySymbol, hasInsufficientFunds, missingFunds]);
94
- return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, { onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isLoadingTransaction || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage, children: [jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress, children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress, children: transactionToAddress &&
95
- shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue ? formatBigNumber.formatBigNumber(transactionValue) : undefined, suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount', children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'Gas (estimated)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate ? formatBigNumber.formatBigNumber(gasEstimate) : undefined, suffix: gasEstimate ? currencySymbol : undefined, icon: gasEstimate ? chainIcon : undefined, dataTestId: 'transaction-gas-free', children: gasEstimate ? formatBigNumber.formatBigNumber(gasEstimate, 10) : 'N/A' }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'Total', isEmpty: !total, title: total ? formatBigNumber.formatBigNumber(total) : undefined, suffix: total ? currencySymbol : undefined, icon: total ? chainIcon : undefined, dataTestId: 'transaction-total', children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' })] }));
115
+ return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, { onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isTransactionLoading || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage, children: [jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress, children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress, children: transactionToAddress &&
116
+ shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue ? formatBigNumber.formatBigNumber(transactionValue) : undefined, suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount', children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice ? formatBigNumber.formatBigNumber(gasTotalPrice) : undefined, suffix: gasTotalPrice ? currencySymbol : undefined, icon: gasTotalPrice ? chainIcon : undefined, dataTestId: isGasEstimated
117
+ ? 'transaction-estimated-gas-fee'
118
+ : 'transaction-gas-fee', children: gasTotalPrice ? formatBigNumber.formatBigNumber(gasTotalPrice, 10) : 'N/A' }), jsxRuntime.jsx(TransactionRow.TransactionRow, { label: 'Total', isEmpty: !total, title: total ? formatBigNumber.formatBigNumber(total) : undefined, suffix: total ? currencySymbol : undefined, icon: total ? chainIcon : undefined, dataTestId: 'transaction-total', children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' })] }));
96
119
  };
97
120
 
98
121
  exports.TransactionConfirmationView = TransactionConfirmationView;
@@ -1,13 +1,14 @@
1
1
  import { FC, MouseEventHandler, ReactNode } from 'react';
2
- import { TransactionReceipt, TransactionRequest } from 'viem';
2
+ import { Address, PublicClient, TransactionRequest } from 'viem';
3
3
  export type TransactionConfirmationViewProps = {
4
4
  displayPoweredByDynamicFooter?: boolean;
5
- mutation: () => Promise<TransactionReceipt>;
5
+ mutation: () => Promise<Address>;
6
6
  onClickBack?: MouseEventHandler<HTMLButtonElement>;
7
7
  onClickClose?: MouseEventHandler<HTMLButtonElement>;
8
8
  onError?: (error: unknown) => void;
9
- onSuccess?: (transaction: TransactionReceipt) => void;
9
+ onSuccess?: (transactionAddress: Address) => void;
10
10
  title: ReactNode;
11
11
  transaction: TransactionRequest;
12
+ provider: PublicClient;
12
13
  };
13
14
  export declare const TransactionConfirmationView: FC<TransactionConfirmationViewProps>;
@@ -1,6 +1,7 @@
1
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
1
2
  import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import { useMemo } from 'react';
3
- import { parseEther } from 'viem';
4
+ import { parseEther, isHex, hexToBigInt } from 'viem';
4
5
  import { DynamicError } from '@dynamic-labs/utils';
5
6
  import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
6
7
  import '@dynamic-labs/sdk-api';
@@ -42,7 +43,8 @@ import 'yup';
42
43
  import '../../components/InlineWidget/InlineWidget.js';
43
44
  import '../../components/MenuList/Dropdown/Dropdown.js';
44
45
  import { useFetchCurrency } from '../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js';
45
- import { useTransactionData } from './hooks/useTransactionData/useTransactionData.js';
46
+ import { useTransactionGas } from './hooks/useTransactionGas/useTransactionGas.js';
47
+ import { useTransactionTotal } from './hooks/useTransactionTotal/useTransactionTotal.js';
46
48
  import { transactionErrorMessage } from './helpers/transactionErrorMessage.js';
47
49
  import '../../context/MockContext/MockContext.js';
48
50
  import '../../context/CaptchaContext/CaptchaContext.js';
@@ -50,23 +52,42 @@ import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
50
52
  import { useMutation } from '../../utils/hooks/useMutation/useMutation.js';
51
53
  import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
52
54
 
53
- const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess, onClickBack, onClickClose, title, displayPoweredByDynamicFooter = false, }) => {
55
+ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess, onClickBack, onClickClose, title, displayPoweredByDynamicFooter = false, provider, }) => {
54
56
  const { appName, appLogoUrl, primaryWallet } = useInternalDynamicContext();
55
57
  const appOrigin = getAppOrigin();
56
58
  if (!primaryWallet) {
57
59
  throw new DynamicError('Primary wallet is not available, transaction cannot be displayed');
58
60
  }
59
61
  const [currencySymbol] = useFetchCurrency(primaryWallet.connector);
60
- const { data: balance } = usePromise(() => primaryWallet.connector
61
- .getBalance()
62
- .then((balanceText) => balanceText ? parseEther(balanceText) : undefined));
62
+ const { data: balance } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
63
+ const balanceText = yield primaryWallet.connector.getBalance();
64
+ return balanceText ? parseEther(balanceText) : undefined;
65
+ }));
63
66
  const { mutate: send, isLoading, error: transactionError, } = useMutation(mutation, {
64
67
  onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
65
68
  onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
66
69
  });
67
- const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData({
70
+ const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas({
71
+ provider,
68
72
  transaction,
69
73
  });
74
+ const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise(() => transaction.to);
75
+ const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise(() => transaction.from);
76
+ const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
77
+ const val = yield transaction.value;
78
+ if (isHex(val)) {
79
+ return hexToBigInt(val);
80
+ }
81
+ return val ? val : undefined;
82
+ }));
83
+ const total = useTransactionTotal({
84
+ gasTotalPrice,
85
+ transactionValue,
86
+ });
87
+ const isTransactionLoading = isTransactionValueLoading ||
88
+ isGasPriceLoading ||
89
+ isTransactionToAddressLoading ||
90
+ isTransactionFromAddressLoading;
70
91
  const ChainIconComponent = getChainIcon(primaryWallet.chain);
71
92
  const chainIcon = (jsx(Icon, { size: 'small', children: jsx(ChainIconComponent, {}) }));
72
93
  const errorMessage = transactionError && transactionErrorMessage(transactionError);
@@ -87,8 +108,10 @@ const TransactionConfirmationView = ({ transaction, mutation, onError, onSuccess
87
108
  const amountLeft = formatBigNumber(missingFunds, 5);
88
109
  return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
89
110
  }, [currencySymbol, hasInsufficientFunds, missingFunds]);
90
- return (jsxs(TransactionConfirmationPageLayout, { onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isLoadingTransaction || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage, children: [jsx(TransactionRow, { label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress, children: shortenWalletAddress(transactionFromAddress, 4, 4) }), jsx(TransactionRow, { label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress, children: transactionToAddress &&
91
- shortenWalletAddress(transactionToAddress, 4, 4) }), jsx(TransactionRow, { label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue ? formatBigNumber(transactionValue) : undefined, suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount', children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 }), jsx(TransactionRow, { label: 'Gas (estimated)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate ? formatBigNumber(gasEstimate) : undefined, suffix: gasEstimate ? currencySymbol : undefined, icon: gasEstimate ? chainIcon : undefined, dataTestId: 'transaction-gas-free', children: gasEstimate ? formatBigNumber(gasEstimate, 10) : 'N/A' }), jsx(TransactionRow, { label: 'Total', isEmpty: !total, title: total ? formatBigNumber(total) : undefined, suffix: total ? currencySymbol : undefined, icon: total ? chainIcon : undefined, dataTestId: 'transaction-total', children: total ? formatBigNumber(total, 10) : 'N/A' })] }));
111
+ return (jsxs(TransactionConfirmationPageLayout, { onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isTransactionLoading || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage, children: [jsx(TransactionRow, { label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress, children: shortenWalletAddress(transactionFromAddress, 4, 4) }), jsx(TransactionRow, { label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress, children: transactionToAddress &&
112
+ shortenWalletAddress(transactionToAddress, 4, 4) }), jsx(TransactionRow, { label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue ? formatBigNumber(transactionValue) : undefined, suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount', children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 }), jsx(TransactionRow, { label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice ? formatBigNumber(gasTotalPrice) : undefined, suffix: gasTotalPrice ? currencySymbol : undefined, icon: gasTotalPrice ? chainIcon : undefined, dataTestId: isGasEstimated
113
+ ? 'transaction-estimated-gas-fee'
114
+ : 'transaction-gas-fee', children: gasTotalPrice ? formatBigNumber(gasTotalPrice, 10) : 'N/A' }), jsx(TransactionRow, { label: 'Total', isEmpty: !total, title: total ? formatBigNumber(total) : undefined, suffix: total ? currencySymbol : undefined, icon: total ? chainIcon : undefined, dataTestId: 'transaction-total', children: total ? formatBigNumber(total, 10) : 'N/A' })] }));
92
115
  };
93
116
 
94
117
  export { TransactionConfirmationView };
@@ -1 +1,2 @@
1
- export * from './useTransactionData';
1
+ export * from './useTransactionGas';
2
+ export * from './useTransactionTotal';
@@ -0,0 +1 @@
1
+ export { useTransactionGas } from './useTransactionGas';
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../../_virtual/_tslib.cjs');
6
+ var React = require('react');
7
+ require('@dynamic-labs/utils');
8
+ require('@dynamic-labs/sdk-api');
9
+ require('../../../../config/ApiEndpoint.cjs');
10
+ require('../../../../shared/logger.cjs');
11
+ require('@dynamic-labs/iconic');
12
+ require('@dynamic-labs/wallet-connector-core');
13
+ require('react/jsx-runtime');
14
+ require('../../../../context/ViewContext/ViewContext.cjs');
15
+ require('@dynamic-labs/wallet-book');
16
+ require('../../../../utils/constants/colors.cjs');
17
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
18
+ require('viem');
19
+ require('../../../../shared/consts/index.cjs');
20
+ require('@dynamic-labs/multi-wallet');
21
+ require('@dynamic-labs/rpc-providers');
22
+ require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
23
+ require('../../../../context/DynamicContext/DynamicContext.cjs');
24
+ require('../../../../context/ErrorContext/ErrorContext.cjs');
25
+ require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
26
+ require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
27
+ require('react-dom');
28
+ require('../../../../components/ShadowDOM/ShadowDOM.cjs');
29
+ require('../../../../context/ThemeContext/ThemeContext.cjs');
30
+ require('react-focus-lock');
31
+ require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
32
+ require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
33
+ require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
34
+ require('../../../../components/IconButton/IconButton.cjs');
35
+ require('../../../../components/Alert/Alert.cjs');
36
+ require('../../../../components/Popper/Popper/Popper.cjs');
37
+ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
38
+ require('formik');
39
+ require('yup');
40
+ require('../../../../components/InlineWidget/InlineWidget.cjs');
41
+ require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
42
+ require('../../../../context/MockContext/MockContext.cjs');
43
+ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
44
+ var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
45
+ require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
46
+ var useTransactionEstimatedGas = require('../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs');
47
+
48
+ const useTransactionGas = ({ provider, transaction, }) => {
49
+ const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas.useTransactionEstimatedGas(provider, transaction);
50
+ const { data: gasPrice, isLoading: isLoadingGasPrice } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
51
+ if (transaction.gasPrice) {
52
+ const { gasPrice } = transaction;
53
+ return gasPrice;
54
+ }
55
+ return provider.getGasPrice();
56
+ }), {
57
+ deps: [transaction.gasPrice],
58
+ });
59
+ const gasTotalPrice = React.useMemo(() => (gasPrice && estimatedGas ? gasPrice * estimatedGas : undefined), [gasPrice, estimatedGas]);
60
+ const isLoading = isEstimatedGasLoading || isLoadingGasPrice;
61
+ const isGasEstimated = Boolean(estimatedGas) && !transaction.gasPrice;
62
+ return {
63
+ gasTotalPrice,
64
+ isGasEstimated,
65
+ isLoading,
66
+ };
67
+ };
68
+
69
+ exports.useTransactionGas = useTransactionGas;
@@ -0,0 +1,11 @@
1
+ import { PublicClient, TransactionRequest } from 'viem';
2
+ type UseTransactionGasProps = {
3
+ provider: PublicClient;
4
+ transaction: TransactionRequest;
5
+ };
6
+ export declare const useTransactionGas: ({ provider, transaction, }: UseTransactionGasProps) => {
7
+ gasTotalPrice: bigint | undefined;
8
+ isGasEstimated: boolean;
9
+ isLoading: boolean;
10
+ };
11
+ export {};
@@ -0,0 +1,65 @@
1
+ import { __awaiter } from '../../../../../../_virtual/_tslib.js';
2
+ import { useMemo } from 'react';
3
+ import '@dynamic-labs/utils';
4
+ import '@dynamic-labs/sdk-api';
5
+ import '../../../../config/ApiEndpoint.js';
6
+ import '../../../../shared/logger.js';
7
+ import '@dynamic-labs/iconic';
8
+ import '@dynamic-labs/wallet-connector-core';
9
+ import 'react/jsx-runtime';
10
+ import '../../../../context/ViewContext/ViewContext.js';
11
+ import '@dynamic-labs/wallet-book';
12
+ import '../../../../utils/constants/colors.js';
13
+ import '../../../../shared/utils/classes/storage/localStorage.js';
14
+ import 'viem';
15
+ import '../../../../shared/consts/index.js';
16
+ import '@dynamic-labs/multi-wallet';
17
+ import '@dynamic-labs/rpc-providers';
18
+ import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
19
+ import '../../../../context/DynamicContext/DynamicContext.js';
20
+ import '../../../../context/ErrorContext/ErrorContext.js';
21
+ import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
22
+ import '../../../../context/AccountExistsContext/AccountExistsContext.js';
23
+ import 'react-dom';
24
+ import '../../../../components/ShadowDOM/ShadowDOM.js';
25
+ import '../../../../context/ThemeContext/ThemeContext.js';
26
+ import 'react-focus-lock';
27
+ import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
28
+ import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
29
+ import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
30
+ import '../../../../components/IconButton/IconButton.js';
31
+ import '../../../../components/Alert/Alert.js';
32
+ import '../../../../components/Popper/Popper/Popper.js';
33
+ import '../../../../components/Popper/PopperContext/PopperContext.js';
34
+ import 'formik';
35
+ import 'yup';
36
+ import '../../../../components/InlineWidget/InlineWidget.js';
37
+ import '../../../../components/MenuList/Dropdown/Dropdown.js';
38
+ import '../../../../context/MockContext/MockContext.js';
39
+ import '../../../../context/CaptchaContext/CaptchaContext.js';
40
+ import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
41
+ import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
42
+ import { useTransactionEstimatedGas } from '../../../../utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js';
43
+
44
+ const useTransactionGas = ({ provider, transaction, }) => {
45
+ const { data: estimatedGas, isLoading: isEstimatedGasLoading } = useTransactionEstimatedGas(provider, transaction);
46
+ const { data: gasPrice, isLoading: isLoadingGasPrice } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
47
+ if (transaction.gasPrice) {
48
+ const { gasPrice } = transaction;
49
+ return gasPrice;
50
+ }
51
+ return provider.getGasPrice();
52
+ }), {
53
+ deps: [transaction.gasPrice],
54
+ });
55
+ const gasTotalPrice = useMemo(() => (gasPrice && estimatedGas ? gasPrice * estimatedGas : undefined), [gasPrice, estimatedGas]);
56
+ const isLoading = isEstimatedGasLoading || isLoadingGasPrice;
57
+ const isGasEstimated = Boolean(estimatedGas) && !transaction.gasPrice;
58
+ return {
59
+ gasTotalPrice,
60
+ isGasEstimated,
61
+ isLoading,
62
+ };
63
+ };
64
+
65
+ export { useTransactionGas };
@@ -0,0 +1 @@
1
+ export { useTransactionTotal } from './useTransactionTotal';
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ const useTransactionTotal = ({ transactionValue, gasTotalPrice, }) => React.useMemo(() => {
8
+ if (gasTotalPrice !== undefined && transactionValue !== undefined) {
9
+ return gasTotalPrice + transactionValue;
10
+ }
11
+ return transactionValue || gasTotalPrice;
12
+ }, [gasTotalPrice, transactionValue]);
13
+
14
+ exports.useTransactionTotal = useTransactionTotal;
@@ -0,0 +1,6 @@
1
+ type UseTransactionTotalProps = {
2
+ transactionValue?: bigint;
3
+ gasTotalPrice?: bigint;
4
+ };
5
+ export declare const useTransactionTotal: ({ transactionValue, gasTotalPrice, }: UseTransactionTotalProps) => bigint | undefined;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ import { useMemo } from 'react';
2
+
3
+ const useTransactionTotal = ({ transactionValue, gasTotalPrice, }) => useMemo(() => {
4
+ if (gasTotalPrice !== undefined && transactionValue !== undefined) {
5
+ return gasTotalPrice + transactionValue;
6
+ }
7
+ return transactionValue || gasTotalPrice;
8
+ }, [gasTotalPrice, transactionValue]);
9
+
10
+ export { useTransactionTotal };
@@ -78,7 +78,10 @@ const WalletList = ({ isWalletConnectList = false, }) => {
78
78
  };
79
79
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'wallet-list__container', children: [error && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: error }), !projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'wallet-list__search-skeleton' })) : (isSearchEnabled && (jsxRuntime.jsx(Search.Search, { label: `Search through ${numberOfWallets} wallets...`, value: filterValue, onChange: ({ target: { value } }) => handleFilterValueChange(value), onClickClear: () => handleFilterValueChange('') }))), jsxRuntime.jsxs("div", { className: classNames.classNames('wallet-list__scroll-container', {
80
80
  'wallet-list__scroll-container--full-height': isSearchEnabled,
81
- }), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll, children: [!projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wallets.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsxRuntime.jsx(noWalletFound.ReactComponent, {}) })) : (walletsList.map((wallet) => (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, onResetSearchValue: () => handleFilterValueChange('') }, wallet.key))))] })), isSearchEnabled && !filterValue && projectSettings && (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, {}))] })] }), noDefaultFooter && (jsxRuntime.jsx("div", { className: classNames.classNames('wallet-list__tiny-footer', {
81
+ }), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll, children: [!projectSettings ? (jsxRuntime.jsx(Skeleton.Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [wallets.length === 0 && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsxRuntime.jsx(noWalletFound.ReactComponent, {}) })) : (walletsList.map((wallet) => {
82
+ var _a;
83
+ return (jsxRuntime.jsx(WalletListItem.WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, onResetSearchValue: () => handleFilterValueChange('') }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
84
+ }))] })), isSearchEnabled && !filterValue && projectSettings && (jsxRuntime.jsx(SearchNotFoundMessage.SearchNotFoundMessage, {}))] })] }), noDefaultFooter && (jsxRuntime.jsx("div", { className: classNames.classNames('wallet-list__tiny-footer', {
82
85
  'wallet-list__tiny-footer--hidden': footerIsVisible,
83
86
  }), "data-testid": 'wallet-list-tiny-footer' }))] }));
84
87
  };
@@ -74,7 +74,10 @@ const WalletList = ({ isWalletConnectList = false, }) => {
74
74
  };
75
75
  return (jsxs(Fragment, { children: [jsxs("div", { className: 'wallet-list__container', children: [error && jsx(ErrorContainer, { children: error }), !projectSettings ? (jsx(Skeleton, { className: 'wallet-list__search-skeleton' })) : (isSearchEnabled && (jsx(Search, { label: `Search through ${numberOfWallets} wallets...`, value: filterValue, onChange: ({ target: { value } }) => handleFilterValueChange(value), onClickClear: () => handleFilterValueChange('') }))), jsxs("div", { className: classNames('wallet-list__scroll-container', {
76
76
  'wallet-list__scroll-container--full-height': isSearchEnabled,
77
- }), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll, children: [!projectSettings ? (jsx(Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxs(Fragment, { children: [wallets.length === 0 && (jsx(ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsx(SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsx(SvgNoWalletFound, {}) })) : (walletsList.map((wallet) => (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, onResetSearchValue: () => handleFilterValueChange('') }, wallet.key))))] })), isSearchEnabled && !filterValue && projectSettings && (jsx(SearchNotFoundMessage, {}))] })] }), noDefaultFooter && (jsx("div", { className: classNames('wallet-list__tiny-footer', {
77
+ }), "data-testid": 'wallet-list-scroll-container', ref: walletListScrollRef, onScroll: handleScroll, children: [!projectSettings ? (jsx(Skeleton, { count: 10, className: 'wallet-list__tile-skeleton' })) : (jsxs(Fragment, { children: [wallets.length === 0 && (jsx(ErrorContainer, { children: "Oops, no login methods have been configured." })), wallets.length && walletsList.length === 0 ? (jsx(SearchNotFoundMessage, { title: 'No wallet found.', subtitle: 'Try searching for a different wallet', image: jsx(SvgNoWalletFound, {}) })) : (walletsList.map((wallet) => {
78
+ var _a;
79
+ return (jsx(WalletListItem, { wallet: wallet, usingMultiWallet: isUsingMultiWallet, onResetSearchValue: () => handleFilterValueChange('') }, wallet.key + ((_a = wallet.groupedWallets) === null || _a === void 0 ? void 0 : _a.length)));
80
+ }))] })), isSearchEnabled && !filterValue && projectSettings && (jsx(SearchNotFoundMessage, {}))] })] }), noDefaultFooter && (jsx("div", { className: classNames('wallet-list__tiny-footer', {
78
81
  'wallet-list__tiny-footer--hidden': footerIsVisible,
79
82
  }), "data-testid": 'wallet-list-tiny-footer' }))] }));
80
83
  };
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
5
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
6
8
  var walletBook = require('@dynamic-labs/wallet-book');
7
- require('react');
8
9
  var Typography = require('../../components/Typography/Typography.cjs');
9
10
  require('@dynamic-labs/sdk-api');
10
- require('../../shared/logger.cjs');
11
+ var logger = require('../../shared/logger.cjs');
11
12
  require('@dynamic-labs/iconic');
12
13
  require('@dynamic-labs/wallet-connector-core');
13
14
  require('../../context/ViewContext/ViewContext.cjs');
@@ -51,15 +52,30 @@ require('../../components/MenuList/Dropdown/Dropdown.cjs');
51
52
 
52
53
  const iconSize = 64;
53
54
  const WalletLockedView = () => {
54
- const { handleLogOut, primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
55
+ const { handleLogOut, primaryWallet, setShowAuthFlow, appName, authToken } = useInternalDynamicContext.useInternalDynamicContext();
56
+ React.useEffect(() => {
57
+ // when there is no valid session, we want to log user out
58
+ if (!authToken) {
59
+ handleLogOut();
60
+ }
61
+ }, [authToken, handleLogOut]);
55
62
  if (!primaryWallet) {
56
63
  return null;
57
64
  }
65
+ const handleConnectWallet = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
66
+ try {
67
+ yield primaryWallet.connector.connect();
68
+ setShowAuthFlow(false);
69
+ }
70
+ catch (_a) {
71
+ logger.logger.info('could not connect wallet');
72
+ }
73
+ });
58
74
  const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet.connector.name, style: {
59
75
  height: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
60
76
  width: pixelToRem.pixelToRem(iconSize * IconWithSpinner.iconRatio),
61
77
  } }));
62
- return (jsxRuntime.jsxs("div", { "data-testid": 'wallet-locked-view', children: [jsxRuntime.jsx(ErrorContainer.ErrorContainer, { withIcon: false, className: 'wallet-locked-view__error-container', children: "We cannot connect to your wallet" }), jsxRuntime.jsxs("div", { className: 'wallet-locked-view__content', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: icon, iconSize: iconSize, className: 'wallet-locked-view__icon', isSpinning: true }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', weight: 'medium', className: 'wallet-locked-view__title', children: "Unlock your Wallet extension" }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', weight: 'regular', children: "Your wallet extension is locked. To continue, open your extension and unlock your wallet." }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', weight: 'regular', className: 'wallet-locked-view__button-header', children: "Once unlocked, click here" }), jsxRuntime.jsx(Button.Button, { buttonRounded: 'default', onClick: () => setShowAuthFlow(false), buttonClassName: 'wallet-locked-view__button', children: "I unlocked the wallet" }), jsxRuntime.jsx(Divider.Divider, { text: 'Or' }), jsxRuntime.jsx(TextButton.TextButton, { className: 'wallet-locked-view__log-out', onClick: handleLogOut, children: "Log out" })] })] }));
78
+ return (jsxRuntime.jsxs("div", { "data-testid": 'wallet-locked-view', children: [jsxRuntime.jsx(ErrorContainer.ErrorContainer, { withIcon: false, variant: 'success', className: 'wallet-locked-view__error-container', children: "Connect your wallet to continue" }), jsxRuntime.jsxs("div", { className: 'wallet-locked-view__content', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: icon, iconSize: iconSize, className: 'wallet-locked-view__icon', isSpinning: true }), jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', weight: 'medium', className: 'wallet-locked-view__title', children: "Welcome back." }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', color: 'secondary', weight: 'regular', children: ["We couldn't connect to your wallet. Click connect to retry the connection ", appName, "."] }), jsxRuntime.jsx(Button.Button, { buttonRounded: 'default', onClick: () => handleConnectWallet(), buttonClassName: 'wallet-locked-view__button', children: "Connect wallet" }), jsxRuntime.jsx(Divider.Divider, { text: 'Or' }), jsxRuntime.jsx(TextButton.TextButton, { className: 'wallet-locked-view__log-out', onClick: handleLogOut, children: "Log out" })] })] }));
63
79
  };
64
80
 
65
81
  exports.WalletLockedView = WalletLockedView;