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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/lib/Main.cjs +5 -0
  6. package/src/lib/Main.js +5 -0
  7. package/src/lib/components/Button/Button.cjs +10 -7
  8. package/src/lib/components/Button/Button.js +10 -7
  9. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  10. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  11. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +1 -1
  12. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  13. package/src/lib/components/ListTile/ListTile.js +1 -1
  14. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  15. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
  16. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  17. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
  18. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +3 -1
  19. package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +3 -1
  20. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +2 -2
  21. package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +2 -2
  22. package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -2
  23. package/src/lib/context/DynamicContext/DynamicContext.js +8 -3
  24. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.cjs +13 -3
  25. package/src/lib/context/DynamicContext/hooks/useVerificationInProgress/useVerificationInProgress.js +13 -3
  26. package/src/lib/context/DynamicContext/types/index.d.ts +2 -2
  27. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
  28. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
  29. package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
  30. package/src/lib/styles/index.shadow.cjs +1 -1
  31. package/src/lib/styles/index.shadow.js +1 -1
  32. package/src/lib/utils/constants/errors.cjs +7 -0
  33. package/src/lib/utils/constants/errors.d.ts +1 -0
  34. package/src/lib/utils/constants/errors.js +3 -0
  35. package/src/lib/utils/constants/index.d.ts +1 -1
  36. package/src/lib/utils/constants/localStorage.cjs +3 -1
  37. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  38. package/src/lib/utils/constants/localStorage.js +3 -2
  39. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  40. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  41. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  42. package/src/lib/utils/functions/index.d.ts +1 -0
  43. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  44. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
  45. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  46. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
  47. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
  48. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +2 -1
  49. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
  50. package/src/lib/utils/hooks/index.d.ts +2 -0
  51. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  52. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  53. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  54. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +11 -9
  55. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -1
  56. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +11 -9
  57. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +1 -1
  58. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +1 -1
  59. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
  60. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -1
  61. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
  62. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.cjs +2 -7
  63. package/src/lib/utils/hooks/useFetchNetworkConfigurations/useFetchNetworkConfigurations.js +2 -7
  64. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/index.d.ts +1 -0
  65. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/index.d.ts +1 -0
  66. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.cjs +16 -0
  67. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.d.ts +2 -0
  68. package/src/lib/utils/hooks/useFetchNetworkConfigurations/utils/mergeCustomerEvmNetworksWithServerNetworks/mergeCustomerEvmNetworksWithServerNetworks.js +12 -0
  69. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +22 -4
  70. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +22 -4
  71. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  72. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
  73. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  74. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
  75. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  76. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +47 -0
  77. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  78. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +43 -0
  79. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -0
  80. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -0
  81. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +1 -1
  82. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +2 -2
  83. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +5 -1
  84. package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +2 -2
  85. package/src/lib/utils/hooks/useWallets/useWallets.d.ts +2 -2
  86. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  87. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  88. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +13 -4
  89. package/src/lib/views/EmailUpdate/EmailUpdate.js +13 -4
  90. package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -1
  91. package/src/lib/views/EmailVerification/EmailVerification.js +7 -2
  92. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
  93. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
  94. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.cjs +4 -1
  95. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailWalletList/LoginWithEmailWalletList.js +4 -1
  96. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
  97. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
  98. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +9 -1
  99. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +9 -1
  100. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -0
  101. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -0
  102. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +1 -0
  103. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +1 -0
  104. package/src/lib/views/SendBalanceView/SendBalanceView.cjs +11 -16
  105. package/src/lib/views/SendBalanceView/SendBalanceView.js +11 -16
  106. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +66 -0
  107. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
  108. package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +62 -0
  109. package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
  110. package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
  111. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +1 -2
  112. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +1 -2
  113. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +22 -4
  114. package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +22 -4
  115. package/src/lib/views/TransactionConfirmationView/hooks/index.d.ts +2 -1
  116. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/index.d.ts +1 -0
  117. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.cjs → useTransactionGas/useTransactionGas.cjs} +17 -42
  118. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionGas/useTransactionGas.d.ts +11 -0
  119. package/src/lib/views/TransactionConfirmationView/hooks/{useTransactionData/useTransactionData.js → useTransactionGas/useTransactionGas.js} +18 -43
  120. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/index.d.ts +1 -0
  121. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.cjs +14 -0
  122. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.d.ts +7 -0
  123. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionTotal/useTransactionTotal.js +10 -0
  124. package/src/lib/views/WalletList/WalletList.cjs +4 -1
  125. package/src/lib/views/WalletList/WalletList.js +4 -1
  126. package/src/lib/views/WalletLockedView/WalletLockedView.cjs +20 -4
  127. package/src/lib/views/WalletLockedView/WalletLockedView.js +20 -4
  128. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/index.d.ts +0 -1
  129. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +0 -18
@@ -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
  });
@@ -97,7 +101,11 @@ const MergeUserAccountsView = () => {
97
101
  };
98
102
  return (jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__container' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenWalletAddress.shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) }))] })), jsxRuntime.jsx("div", Object.assign({ className: 'merge-user-accounts__accounts__divider' }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-secondary', size: 'small' }, { children: jsxRuntime.jsx(doubleArrowRight.ReactComponent, {}) })) })), jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenEmail.shortenEmail(email, {
99
103
  breakpoint: 4,
100
- }) }))] }))] })), jsxRuntime.jsxs(Typography.Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text' }, { children: ["An account already exists that uses", ' ', jsxRuntime.jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: email })), "."] })), jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Link wallet to existing account" })), jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Use different email" }))] }))] })));
104
+ cutEnd: 1,
105
+ cutStart: 2,
106
+ }) }))] }))] })), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header' }, { children: "Would you like to link this wallet to this existing account?" })), jsxRuntime.jsxs(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body' }, { children: ["An account already exists that uses", ' ', jsxRuntime.jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: shortenEmail.shortenEmail(email, {
107
+ breakpoint: 14,
108
+ }) })), ' ', "email."] })), jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Yes, link to existing account" })), jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "No, I'll use a different email" }))] }))] })));
101
109
  };
102
110
 
103
111
  exports.MergeUserAccountsView = MergeUserAccountsView;
@@ -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
  });
@@ -93,7 +97,11 @@ const MergeUserAccountsView = () => {
93
97
  };
94
98
  return (jsxs("div", Object.assign({ className: 'merge-user-accounts__container' }, { children: [jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts' }, { children: [jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsx(WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) }))] })), jsx("div", Object.assign({ className: 'merge-user-accounts__accounts__divider' }, { children: jsx(Icon, Object.assign({ color: 'text-secondary', size: 'small' }, { children: jsx(SvgDoubleArrowRight, {}) })) })), jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsx(UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenEmail(email, {
95
99
  breakpoint: 4,
96
- }) }))] }))] })), jsxs(Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text' }, { children: ["An account already exists that uses", ' ', jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: email })), "."] })), jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Link wallet to existing account" })), jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Use different email" }))] }))] })));
100
+ cutEnd: 1,
101
+ cutStart: 2,
102
+ }) }))] }))] })), jsx(Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header' }, { children: "Would you like to link this wallet to this existing account?" })), jsxs(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body' }, { children: ["An account already exists that uses", ' ', jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: shortenEmail(email, {
103
+ breakpoint: 14,
104
+ }) })), ' ', "email."] })), jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Yes, link to existing account" })), jsx(Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "No, I'll use a different email" }))] }))] })));
97
105
  };
98
106
 
99
107
  export { MergeUserAccountsView };
@@ -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;
@@ -1,4 +1,3 @@
1
- import { __awaiter } from '../../../../_virtual/_tslib.js';
2
1
  import { jsx } from 'react/jsx-runtime';
3
2
  import { useState, useRef } from 'react';
4
3
  import { utils } from 'ethers';
@@ -38,9 +37,9 @@ import '../../components/Popper/PopperContext/PopperContext.js';
38
37
  import { SendBalancePageLayout } from '../../components/SendBalancePageLayout/SendBalancePageLayout.js';
39
38
  import '../../components/InlineWidget/InlineWidget.js';
40
39
  import '../../components/MenuList/Dropdown/Dropdown.js';
41
- import { TransactionConfirmationView } from '../TransactionConfirmationView/TransactionConfirmationView.js';
42
- import { TransactionStatusLayout } from '../../components/TransactionStatusLayout/TransactionStatusLayout.js';
43
40
  import { useFetchCurrency } from '../../widgets/DynamicWidget/hooks/useFetchCurrency/useFetchCurrency.js';
41
+ import { TransactionStatusLayout } from '../../components/TransactionStatusLayout/TransactionStatusLayout.js';
42
+ import { TransactionStage } from './components/TransactionStage/TransactionStage.js';
44
43
  import '../../context/MockContext/MockContext.js';
45
44
  import '../../context/CaptchaContext/CaptchaContext.js';
46
45
  import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
@@ -48,18 +47,19 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
48
47
 
49
48
  const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBack, onClickClose, onError, onSuccess, onDone, displayPoweredByDynamicFooter = false, }) => {
50
49
  const [stage, setStage] = useState('form');
51
- const { primaryWallet, walletUiUtils, network } = useInternalDynamicContext();
50
+ const { primaryWallet, network } = useInternalDynamicContext();
52
51
  const [value, setValue] = useState(initialValue !== null && initialValue !== void 0 ? initialValue : null);
53
52
  const [recipientAddress, setRecipientAddress] = useState(initialRecipientAddress);
54
53
  const transactionRef = useRef(null);
55
54
  if (!primaryWallet) {
56
55
  throw new DynamicError('Primary wallet is not available, send balance cannot be displayed');
57
56
  }
58
- const { data: balance } = usePromise(() => primaryWallet.connector.getBalance());
59
- const { data: provider } = usePromise(() => primaryWallet.connector.getWeb3Provider());
60
- const evmNetworks = ((primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) &&
61
- primaryWallet.connector.evmNetworks) ||
62
- [];
57
+ const walletConnector = primaryWallet.connector;
58
+ const { data: balance } = usePromise(() => walletConnector.getBalance(), {
59
+ deps: [walletConnector],
60
+ });
61
+ const { data: provider } = usePromise(() => walletConnector.getWeb3Provider(), { deps: [walletConnector] });
62
+ const evmNetworks = (walletConnector && walletConnector.evmNetworks) || [];
63
63
  const evmNetwork = evmNetworks.find((evmNetwork) => evmNetwork.chainId === network);
64
64
  const networkIcon = evmNetwork && (jsx("img", { src: evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.iconUrls[0], alt: `${evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name} icon` }));
65
65
  const networkName = (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.vanityName) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.name);
@@ -84,16 +84,11 @@ const SendBalanceView = ({ initialRecipientAddress = '', initialValue, onClickBa
84
84
  to: recipientAddress,
85
85
  value,
86
86
  };
87
- return (jsx(TransactionConfirmationView, { provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
87
+ return (jsx(TransactionStage, { walletConnector: walletConnector, provider: provider, transaction: transaction, title: 'Confirm transaction', onClickBack: () => setStage('form'), onError: onError, displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, onSuccess: (transaction) => {
88
88
  transactionRef.current = transaction;
89
89
  setStage('success');
90
90
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionRef.current);
91
- }, mutation: () => __awaiter(void 0, void 0, void 0, function* () {
92
- walletUiUtils.disabledConfirmationOnce();
93
- const signer = provider.getSigner();
94
- const sentTransaction = yield signer.sendTransaction(transaction);
95
- return sentTransaction;
96
- }) }));
91
+ } }));
97
92
  };
98
93
  const buildSuccessState = () => {
99
94
  var _a;
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../../_virtual/_tslib.cjs');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ require('react');
8
+ require('@dynamic-labs/utils');
9
+ require('@dynamic-labs/sdk-api');
10
+ require('../../../../config/ApiEndpoint.cjs');
11
+ require('../../../../shared/logger.cjs');
12
+ require('@dynamic-labs/iconic');
13
+ require('@dynamic-labs/wallet-connector-core');
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('ethers');
19
+ require('../../../../shared/consts/index.cjs');
20
+ require('@dynamic-labs/multi-wallet');
21
+ var isMagicConnector = require('../../../../utils/functions/isMagicConnector/isMagicConnector.cjs');
22
+ require('@dynamic-labs/rpc-providers');
23
+ require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
24
+ var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
25
+ require('../../../../context/ErrorContext/ErrorContext.cjs');
26
+ require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
27
+ require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
28
+ require('react-dom');
29
+ require('../../../../components/ShadowDOM/ShadowDOM.cjs');
30
+ require('../../../../context/ThemeContext/ThemeContext.cjs');
31
+ require('react-focus-lock');
32
+ require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
33
+ require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
34
+ require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
35
+ require('../../../../components/IconButton/IconButton.cjs');
36
+ require('../../../../components/Alert/Alert.cjs');
37
+ require('../../../../components/Popper/Popper/Popper.cjs');
38
+ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
39
+ require('formik');
40
+ require('yup');
41
+ require('../../../../components/InlineWidget/InlineWidget.cjs');
42
+ require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
43
+ var TransactionConfirmationView = require('../../../TransactionConfirmationView/TransactionConfirmationView.cjs');
44
+ require('../../../../context/MockContext/MockContext.cjs');
45
+ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
46
+ require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
47
+ var useTransactionWithGasPrice = require('../../../../utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs');
48
+
49
+ const TransactionStage = (_a) => {
50
+ var { transaction, provider, walletConnector } = _a, rest = _tslib.__rest(_a, ["transaction", "provider", "walletConnector"]);
51
+ const { walletUiUtils } = useInternalDynamicContext.useInternalDynamicContext();
52
+ const transactionWithGasPrice = useTransactionWithGasPrice.useTransactionWithGasPrice({
53
+ enabled: isMagicConnector.isMagicConnector(walletConnector),
54
+ increasePercentage: 5,
55
+ provider,
56
+ transaction,
57
+ });
58
+ return (jsxRuntime.jsx(TransactionConfirmationView.TransactionConfirmationView, Object.assign({ provider: provider, transaction: transactionWithGasPrice, mutation: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
59
+ walletUiUtils.disabledConfirmationOnce();
60
+ const signer = provider.getSigner();
61
+ const sentTransaction = yield signer.sendTransaction(transactionWithGasPrice);
62
+ return sentTransaction;
63
+ }) }, rest)));
64
+ };
65
+
66
+ exports.TransactionStage = TransactionStage;
@@ -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,62 @@
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 'ethers';
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 = provider.getSigner();
57
+ const sentTransaction = yield signer.sendTransaction(transactionWithGasPrice);
58
+ return sentTransaction;
59
+ }) }, rest)));
60
+ };
61
+
62
+ 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", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsxs(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames.classNames('social-redirect-view__title') }, { children: ["Connecting to ", capitalize(socialProvider), "..."] }))] })));
56
+ return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-redirect-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxRuntime.jsx(Typography.Typography, Object.assign({ 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", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxs(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title') }, { children: ["Connecting to ", capitalize(socialProvider), "..."] }))] })));
52
+ return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsx(Typography, Object.assign({ 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 ethers = require('ethers');
@@ -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');
@@ -68,10 +70,24 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
68
70
  onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
69
71
  onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
70
72
  });
71
- const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData.useTransactionData({
73
+ const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas.useTransactionGas({
72
74
  provider,
73
75
  transaction,
74
76
  });
77
+ const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise.usePromise(() => transaction.to);
78
+ const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise.usePromise(() => transaction.from);
79
+ const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
80
+ const val = yield transaction.value;
81
+ return val ? ethers.ethers.BigNumber.from(val) : undefined;
82
+ }));
83
+ const total = useTransactionTotal.useTransactionTotal({
84
+ gasTotalPrice,
85
+ transactionValue,
86
+ });
87
+ const isTransactionLoading = isTransactionValueLoading ||
88
+ isGasPriceLoading ||
89
+ isTransactionToAddressLoading ||
90
+ isTransactionFromAddressLoading;
75
91
  const ChainIconComponent = getChainIcon.getChainIcon(primaryWallet.chain);
76
92
  const chainIcon = (jsxRuntime.jsx(Icon.Icon, Object.assign({ size: 'small' }, { children: jsxRuntime.jsx(ChainIconComponent, {}) })));
77
93
  const errorMessage = transactionError && transactionErrorMessage.transactionErrorMessage(transactionError);
@@ -92,8 +108,10 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
92
108
  const amountLeft = formatBigNumber.formatBigNumber(missingFunds, 5);
93
109
  return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
94
110
  }, [currencySymbol, hasInsufficientFunds, missingFunds]);
95
- return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({ 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, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
96
- shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber.formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Gas (estimated)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate && formatBigNumber.formatBigNumber(gasEstimate), suffix: gasEstimate && currencySymbol, icon: gasEstimate && chainIcon, dataTestId: 'transaction-gas-free' }, { children: gasEstimate ? formatBigNumber.formatBigNumber(gasEstimate, 10) : 'N/A' })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber.formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' }))] })));
111
+ return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({ 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, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
112
+ shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber.formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice && formatBigNumber.formatBigNumber(gasTotalPrice), suffix: gasTotalPrice && currencySymbol, icon: gasTotalPrice && chainIcon, dataTestId: isGasEstimated
113
+ ? 'transaction-estimated-gas-fee'
114
+ : 'transaction-gas-fee' }, { children: gasTotalPrice ? formatBigNumber.formatBigNumber(gasTotalPrice, 10) : 'N/A' })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber.formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' }))] })));
97
115
  };
98
116
 
99
117
  exports.TransactionConfirmationView = TransactionConfirmationView;
@@ -1,3 +1,4 @@
1
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
1
2
  import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import { useMemo } from 'react';
3
4
  import { ethers } from 'ethers';
@@ -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';
@@ -64,10 +66,24 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
64
66
  onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
65
67
  onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
66
68
  });
67
- const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData({
69
+ const { isLoading: isGasPriceLoading, gasTotalPrice, isGasEstimated, } = useTransactionGas({
68
70
  provider,
69
71
  transaction,
70
72
  });
73
+ const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise(() => transaction.to);
74
+ const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise(() => transaction.from);
75
+ const { data: transactionValue, isLoading: isTransactionValueLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
76
+ const val = yield transaction.value;
77
+ return val ? ethers.BigNumber.from(val) : undefined;
78
+ }));
79
+ const total = useTransactionTotal({
80
+ gasTotalPrice,
81
+ transactionValue,
82
+ });
83
+ const isTransactionLoading = isTransactionValueLoading ||
84
+ isGasPriceLoading ||
85
+ isTransactionToAddressLoading ||
86
+ isTransactionFromAddressLoading;
71
87
  const ChainIconComponent = getChainIcon(primaryWallet.chain);
72
88
  const chainIcon = (jsx(Icon, Object.assign({ size: 'small' }, { children: jsx(ChainIconComponent, {}) })));
73
89
  const errorMessage = transactionError && transactionErrorMessage(transactionError);
@@ -88,8 +104,10 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
88
104
  const amountLeft = formatBigNumber(missingFunds, 5);
89
105
  return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
90
106
  }, [currencySymbol, hasInsufficientFunds, missingFunds]);
91
- return (jsxs(TransactionConfirmationPageLayout, Object.assign({ 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, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress(transactionFromAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
92
- shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 })), jsx(TransactionRow, Object.assign({ label: 'Gas (estimated)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate && formatBigNumber(gasEstimate), suffix: gasEstimate && currencySymbol, icon: gasEstimate && chainIcon, dataTestId: 'transaction-gas-free' }, { children: gasEstimate ? formatBigNumber(gasEstimate, 10) : 'N/A' })), jsx(TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber(total, 10) : 'N/A' }))] })));
107
+ return (jsxs(TransactionConfirmationPageLayout, Object.assign({ 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, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress(transactionFromAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
108
+ shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading: isTransactionValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 })), jsx(TransactionRow, Object.assign({ label: isGasEstimated ? 'Gas (estimate)' : 'Gas', isEmpty: !gasTotalPrice, isLoading: isGasPriceLoading, title: gasTotalPrice && formatBigNumber(gasTotalPrice), suffix: gasTotalPrice && currencySymbol, icon: gasTotalPrice && chainIcon, dataTestId: isGasEstimated
109
+ ? 'transaction-estimated-gas-fee'
110
+ : 'transaction-gas-fee' }, { children: gasTotalPrice ? formatBigNumber(gasTotalPrice, 10) : 'N/A' })), jsx(TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber(total, 10) : 'N/A' }))] })));
93
111
  };
94
112
 
95
113
  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';