@dynamic-labs/sdk-react-core 4.47.1 → 4.47.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 (135) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +14 -14
  5. package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
  6. package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.cjs +17 -0
  7. package/src/lib/client/extension/hooks/useInitializeSdkClient/useInitializeSdkClient.js +17 -0
  8. package/src/lib/client/extension/user/raiseUserProfileEvent/raiseUserProfileEvent.cjs +6 -6
  9. package/src/lib/client/extension/user/raiseUserProfileEvent/raiseUserProfileEvent.js +6 -6
  10. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.cjs +6 -6
  11. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.js +6 -6
  12. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +5 -5
  13. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +5 -5
  14. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +5 -5
  15. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +5 -5
  16. package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +4 -4
  17. package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +4 -4
  18. package/src/lib/context/ViewContext/ViewContext.cjs +6 -1
  19. package/src/lib/context/ViewContext/ViewContext.js +6 -1
  20. package/src/lib/data/api/api.cjs +9 -9
  21. package/src/lib/data/api/api.js +9 -9
  22. package/src/lib/data/api/externalAuth/externalAuth.cjs +4 -4
  23. package/src/lib/data/api/externalAuth/externalAuth.js +4 -4
  24. package/src/lib/data/api/oauth/oauth.cjs +4 -4
  25. package/src/lib/data/api/oauth/oauth.js +4 -4
  26. package/src/lib/data/api/user/user.cjs +4 -4
  27. package/src/lib/data/api/user/user.js +4 -4
  28. package/src/lib/data/api/wallets/wallets.cjs +4 -4
  29. package/src/lib/data/api/wallets/wallets.js +4 -4
  30. package/src/lib/shared/assets/index.d.ts +1 -0
  31. package/src/lib/shared/assets/reload-icon.cjs +54 -0
  32. package/src/lib/shared/assets/reload-icon.js +30 -0
  33. package/src/lib/store/state/connectedWalletsInfo/connectedWalletsInfo.cjs +6 -6
  34. package/src/lib/store/state/connectedWalletsInfo/connectedWalletsInfo.js +6 -6
  35. package/src/lib/store/state/nonce/nonce.cjs +4 -4
  36. package/src/lib/store/state/nonce/nonce.js +4 -4
  37. package/src/lib/store/utils/settingsUtils/settingsUtils.cjs +6 -6
  38. package/src/lib/store/utils/settingsUtils/settingsUtils.js +6 -6
  39. package/src/lib/styles/index.shadow.cjs +1 -1
  40. package/src/lib/styles/index.shadow.js +1 -1
  41. package/src/lib/utils/functions/isMfaMethodEnabled/isMfaMethodEnabled.cjs +6 -6
  42. package/src/lib/utils/functions/isMfaMethodEnabled/isMfaMethodEnabled.js +6 -6
  43. package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs +5 -5
  44. package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.js +5 -5
  45. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs +6 -6
  46. package/src/lib/utils/hooks/authenticationHooks/helpers/isConnectOnly.js +6 -6
  47. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +6 -6
  48. package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +6 -6
  49. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +6 -6
  50. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +6 -6
  51. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.cjs +5 -5
  52. package/src/lib/utils/hooks/useClientSessionKeys/useClientSessionKeys.js +5 -5
  53. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +4 -4
  54. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +4 -4
  55. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs +4 -4
  56. package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js +4 -4
  57. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -4
  58. package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -4
  59. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +16 -16
  60. package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +16 -16
  61. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +5 -5
  62. package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +5 -5
  63. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +4 -4
  64. package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +4 -4
  65. package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.cjs +2 -1
  66. package/src/lib/utils/hooks/useFundingHelpers/useFundingHelpers.js +2 -1
  67. package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.cjs +5 -5
  68. package/src/lib/utils/hooks/useGlobalLoading/useGlobalLoading.js +5 -5
  69. package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.cjs +6 -6
  70. package/src/lib/utils/hooks/useIsLoadingEmbeddedWallet/useIsLoadingEmbeddedWallet.js +6 -6
  71. package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.cjs +6 -6
  72. package/src/lib/utils/hooks/useIsPasskeysMfaEnabled/useIsPasskeysMfaEnabled.js +6 -6
  73. package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.cjs +6 -6
  74. package/src/lib/utils/hooks/useIsTotpMfaEnabled/useIsTotpMfaEnabled.js +6 -6
  75. package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +4 -4
  76. package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +4 -4
  77. package/src/lib/utils/hooks/useMfa/useMfa.cjs +5 -5
  78. package/src/lib/utils/hooks/useMfa/useMfa.js +5 -5
  79. package/src/lib/utils/hooks/useMultichainTokenBalances/useMultichainTokenBalances.cjs +6 -6
  80. package/src/lib/utils/hooks/useMultichainTokenBalances/useMultichainTokenBalances.js +6 -6
  81. package/src/lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.cjs +5 -5
  82. package/src/lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.js +5 -5
  83. package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.cjs +25 -27
  84. package/src/lib/utils/hooks/usePromptMfaAuth/usePromptMfaAuth.js +25 -27
  85. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.cjs +4 -4
  86. package/src/lib/utils/hooks/useRefreshUser/useRefreshUser.js +4 -4
  87. package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +4 -4
  88. package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +4 -4
  89. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +3 -3
  90. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
  91. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +5 -5
  92. package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +5 -5
  93. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +6 -6
  94. package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +6 -6
  95. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +5 -5
  96. package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +5 -5
  97. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.cjs +6 -6
  98. package/src/lib/utils/hooks/useUpgradeEmbeddedWallet/useUpgradeEmbeddedWallet.js +6 -6
  99. package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +4 -4
  100. package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +4 -4
  101. package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +5 -5
  102. package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +5 -5
  103. package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +5 -5
  104. package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +5 -5
  105. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +4 -3
  106. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.d.ts +3 -20
  107. package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +4 -3
  108. package/src/lib/views/EmailVerification/EmailVerification.cjs +7 -7
  109. package/src/lib/views/EmailVerification/EmailVerification.js +7 -7
  110. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +9 -9
  111. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +9 -9
  112. package/src/lib/views/ExchangeList/ExchangeList.cjs +6 -6
  113. package/src/lib/views/ExchangeList/ExchangeList.js +6 -6
  114. package/src/lib/views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs +5 -5
  115. package/src/lib/views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js +5 -5
  116. package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +4 -4
  117. package/src/lib/views/MfaVerificationView/MfaVerificationView.js +4 -4
  118. package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +5 -5
  119. package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +5 -5
  120. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +25 -25
  121. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +25 -25
  122. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +42 -2
  123. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +42 -2
  124. package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.cjs +6 -6
  125. package/src/lib/widgets/DynamicWidget/hooks/useFetchNameService/useFetchNameService.js +6 -6
  126. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/ZKSyncSessionsSection/ZKSyncSessionsSection.cjs +6 -6
  127. package/src/lib/widgets/DynamicWidget/views/AccountAndSecuritySettingsView/ZKSyncSessionsSection/ZKSyncSessionsSection.js +6 -6
  128. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.cjs +5 -5
  129. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/getPromptAmountParams/getPromptAmountParams.js +5 -5
  130. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.cjs +5 -5
  131. package/src/lib/widgets/DynamicWidget/views/ChooseWalletFundingMethod/useFundingMethods/useStartExchangeFunding/useStartExchangeFunding.js +5 -5
  132. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.cjs +6 -6
  133. package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.js +6 -6
  134. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.cjs +5 -5
  135. package/src/lib/widgets/DynamicWidget/views/WaasBackupView/WaasBackupView.js +5 -5
@@ -12,19 +12,19 @@ require('../../../../client/client.cjs');
12
12
  require('react');
13
13
  require('@dynamic-labs-sdk/client');
14
14
  require('../../../../config/ApiEndpoint.cjs');
15
- var findEmbeddedWalletFromVerifiedCredentials = require('../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
16
- require('../../../../utils/constants/values.cjs');
17
- var errors = require('../../../../utils/constants/errors.cjs');
18
- require('@dynamic-labs/multi-wallet');
19
- require('react-international-phone');
20
- var localStorage = require('../../../../utils/constants/localStorage.cjs');
21
- require('../../../../utils/constants/colors.cjs');
22
15
  require('@dynamic-labs/iconic');
23
16
  require('react/jsx-runtime');
24
17
  require('../../../../context/ViewContext/ViewContext.cjs');
25
18
  require('../../../../shared/logger.cjs');
26
19
  require('@dynamic-labs/wallet-book');
20
+ var localStorage = require('../../../../utils/constants/localStorage.cjs');
21
+ require('../../../../utils/constants/colors.cjs');
22
+ require('../../../../utils/constants/values.cjs');
27
23
  require('../../../../shared/consts/index.cjs');
24
+ var findEmbeddedWalletFromVerifiedCredentials = require('../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.cjs');
25
+ var errors = require('../../../../utils/constants/errors.cjs');
26
+ require('@dynamic-labs/multi-wallet');
27
+ require('react-international-phone');
28
28
  require('../../../../store/state/nonce/nonce.cjs');
29
29
  var removeElementById = require('../../../../utils/functions/removeElementById/removeElementById.cjs');
30
30
  require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
@@ -72,7 +72,7 @@ const initEmbeddedWalletSession = (_a) => _tslib.__awaiter(void 0, [_a], void 0,
72
72
  return;
73
73
  });
74
74
  const passkeyRecoveryBundleValidation = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ user, bundleInput, wallet, }) {
75
- var _d, _e, _f, _g;
75
+ var _d, _e, _f, _g, _h;
76
76
  if (!bundleInput) {
77
77
  throw new utils.DynamicError('Code must be informed');
78
78
  }
@@ -84,8 +84,8 @@ const passkeyRecoveryBundleValidation = (_c) => _tslib.__awaiter(void 0, [_c], v
84
84
  if (!user) {
85
85
  throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
86
86
  }
87
- const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
88
- const turnkeyRecoveryHandler = (_g = wallet.connector) === null || _g === void 0 ? void 0 : _g.getAuthenticatorHandler();
87
+ const organizationId = (_g = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId) !== null && _g !== void 0 ? _g : undefined;
88
+ const turnkeyRecoveryHandler = (_h = wallet.connector) === null || _h === void 0 ? void 0 : _h.getAuthenticatorHandler();
89
89
  yield turnkeyRecoveryHandler.verifyRecoveryCode(bundleInput, organizationId);
90
90
  const sessionSettings = {
91
91
  createdAt: new Date().getTime(),
@@ -94,8 +94,8 @@ const passkeyRecoveryBundleValidation = (_c) => _tslib.__awaiter(void 0, [_c], v
94
94
  };
95
95
  utils.StorageService.setItem(localStorage.EMBEDDED_WALLET_SESSION_SETTINGS, sessionSettings);
96
96
  });
97
- const resentRecoveryEmail = (_h) => _tslib.__awaiter(void 0, [_h], void 0, function* ({ authenticatorType, user, environmentId, wallet, }) {
98
- var _j;
97
+ const resentRecoveryEmail = (_j) => _tslib.__awaiter(void 0, [_j], void 0, function* ({ authenticatorType, user, environmentId, wallet, }) {
98
+ var _k;
99
99
  if (!user) {
100
100
  throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
101
101
  }
@@ -104,7 +104,7 @@ const resentRecoveryEmail = (_h) => _tslib.__awaiter(void 0, [_h], void 0, funct
104
104
  !walletConnectorCore.isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
105
105
  throw new utils.InvalidPrimaryWalletOrConnectorError();
106
106
  }
107
- const publicKey = (_j = wallet.connector) === null || _j === void 0 ? void 0 : _j.getAuthenticatorHandler().publicKey;
107
+ const publicKey = (_k = wallet.connector) === null || _k === void 0 ? void 0 : _k.getAuthenticatorHandler().publicKey;
108
108
  if (!publicKey) {
109
109
  throw new utils.DynamicError('Could not proceed with your request. Please restart the process.');
110
110
  }
@@ -115,7 +115,7 @@ const resentRecoveryEmail = (_h) => _tslib.__awaiter(void 0, [_h], void 0, funct
115
115
  walletId: wallet === null || wallet === void 0 ? void 0 : wallet.id,
116
116
  });
117
117
  });
118
- const completePasskeyRecovery = (_k) => _tslib.__awaiter(void 0, [_k], void 0, function* ({ user, environmentId, wallet, }) {
118
+ const completePasskeyRecovery = (_l) => _tslib.__awaiter(void 0, [_l], void 0, function* ({ user, environmentId, wallet, }) {
119
119
  const { connector, user: updatedUser } = yield recoverTurnkeyWallet({
120
120
  addPasskeyAuthenticator: false,
121
121
  environmentId,
@@ -128,7 +128,7 @@ const completePasskeyRecovery = (_k) => _tslib.__awaiter(void 0, [_k], void 0, f
128
128
  removeElementById.removeElementById(constants.iframeElementId);
129
129
  return updatedUser;
130
130
  });
131
- const addNewPasskeyAuthenticator = (_l) => _tslib.__awaiter(void 0, [_l], void 0, function* ({ user, environmentId, wallet, }) {
131
+ const addNewPasskeyAuthenticator = (_m) => _tslib.__awaiter(void 0, [_m], void 0, function* ({ user, environmentId, wallet, }) {
132
132
  const { user: updatedUser } = yield recoverTurnkeyWallet({
133
133
  addPasskeyAuthenticator: true,
134
134
  environmentId,
@@ -137,8 +137,8 @@ const addNewPasskeyAuthenticator = (_l) => _tslib.__awaiter(void 0, [_l], void 0
137
137
  });
138
138
  return updatedUser;
139
139
  });
140
- const recoverTurnkeyWallet = (_m) => _tslib.__awaiter(void 0, [_m], void 0, function* ({ wallet, user, environmentId, addPasskeyAuthenticator, }) {
141
- var _o, _p, _q;
140
+ const recoverTurnkeyWallet = (_o) => _tslib.__awaiter(void 0, [_o], void 0, function* ({ wallet, user, environmentId, addPasskeyAuthenticator, }) {
141
+ var _p, _q, _r;
142
142
  if (!user) {
143
143
  throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
144
144
  }
@@ -150,7 +150,7 @@ const recoverTurnkeyWallet = (_m) => _tslib.__awaiter(void 0, [_m], void 0, func
150
150
  }
151
151
  const connector = wallet.connector;
152
152
  connector.setEmail(user.email);
153
- const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
153
+ const turnkeySubOrganizationId = (_r = (_q = (_p = user.verifiedCredentials) === null || _p === void 0 ? void 0 : _p.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _q === void 0 ? void 0 : _q.walletProperties) === null || _r === void 0 ? void 0 : _r.turnkeySubOrganizationId;
154
154
  if (!turnkeySubOrganizationId) {
155
155
  throw new utils.DynamicError('The authentication token is invalid - turnkeySubOrganizationId is missing');
156
156
  }
@@ -208,8 +208,8 @@ const canRestoreEmbeddedWalletSession = (sessionExpirationTime) => {
208
208
  }
209
209
  return true;
210
210
  };
211
- const restoreEmbeddedWalletSession = (_r) => _tslib.__awaiter(void 0, [_r], void 0, function* ({ user, iframeContainer, iframeElementId, wallet, sessionExpiration, }) {
212
- var _s, _t, _u, _v;
211
+ const restoreEmbeddedWalletSession = (_s) => _tslib.__awaiter(void 0, [_s], void 0, function* ({ user, iframeContainer, iframeElementId, wallet, sessionExpiration, }) {
212
+ var _t, _u, _v, _w, _x;
213
213
  if (!user) {
214
214
  throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
215
215
  }
@@ -219,7 +219,7 @@ const restoreEmbeddedWalletSession = (_r) => _tslib.__awaiter(void 0, [_r], void
219
219
  throw new utils.InvalidPrimaryWalletOrConnectorError();
220
220
  }
221
221
  const sessionSettings = utils.StorageService.getItem(localStorage.EMBEDDED_WALLET_SESSION_SETTINGS);
222
- const turnkeyRecoveryHandler = (_s = wallet.connector) === null || _s === void 0 ? void 0 : _s.getAuthenticatorHandler();
222
+ const turnkeyRecoveryHandler = (_t = wallet.connector) === null || _t === void 0 ? void 0 : _t.getAuthenticatorHandler();
223
223
  if (!sessionSettings || Boolean(turnkeyRecoveryHandler.recoveryUserId)) {
224
224
  return false;
225
225
  }
@@ -228,12 +228,12 @@ const restoreEmbeddedWalletSession = (_r) => _tslib.__awaiter(void 0, [_r], void
228
228
  throw new utils.DynamicError('Could not open embedded wallet connection communication');
229
229
  }
230
230
  turnkeyRecoveryHandler.recoveryUserId = sessionSettings.userId;
231
- const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
231
+ const organizationId = (_x = (_w = (_v = (_u = user.verifiedCredentials) === null || _u === void 0 ? void 0 : _u.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _v === void 0 ? void 0 : _v.walletProperties) === null || _w === void 0 ? void 0 : _w.turnkeySubOrganizationId) !== null && _x !== void 0 ? _x : undefined;
232
232
  yield turnkeyRecoveryHandler.verifyRecoveryCode(sessionSettings.emailCode, organizationId);
233
233
  return true;
234
234
  });
235
- const addEmailRecovery = (_w) => _tslib.__awaiter(void 0, [_w], void 0, function* ({ user: user$1, environmentId, wallet, }) {
236
- var _x, _y;
235
+ const addEmailRecovery = (_y) => _tslib.__awaiter(void 0, [_y], void 0, function* ({ user: user$1, environmentId, wallet, }) {
236
+ var _z, _0;
237
237
  if (!(user$1 === null || user$1 === void 0 ? void 0 : user$1.email)) {
238
238
  throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
239
239
  }
@@ -243,7 +243,7 @@ const addEmailRecovery = (_w) => _tslib.__awaiter(void 0, [_w], void 0, function
243
243
  !walletConnectorCore.isEmailWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
244
244
  throw new utils.InvalidPrimaryWalletOrConnectorError();
245
245
  }
246
- const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user$1.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _y === void 0 ? void 0 : _y.walletProperties;
246
+ const { turnkeySubOrganizationId, turnkeyUserId } = (_0 = (_z = user$1.verifiedCredentials) === null || _z === void 0 ? void 0 : _z.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _0 === void 0 ? void 0 : _0.walletProperties;
247
247
  if (!turnkeySubOrganizationId || !turnkeyUserId) {
248
248
  throw new utils.DynamicError('The authentication token is invalid - turnkeySubOrganizationId or turnkeyUserID is missing');
249
249
  }
@@ -8,19 +8,19 @@ import '../../../../client/client.js';
8
8
  import 'react';
9
9
  import '@dynamic-labs-sdk/client';
10
10
  import '../../../../config/ApiEndpoint.js';
11
- import { findEmbeddedWalletFromVerifiedCredentials } from '../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
12
- import '../../../../utils/constants/values.js';
13
- import { USER_NOT_LOGGED_IN } from '../../../../utils/constants/errors.js';
14
- import '@dynamic-labs/multi-wallet';
15
- import 'react-international-phone';
16
- import { EMBEDDED_WALLET_SESSION_SETTINGS } from '../../../../utils/constants/localStorage.js';
17
- import '../../../../utils/constants/colors.js';
18
11
  import '@dynamic-labs/iconic';
19
12
  import 'react/jsx-runtime';
20
13
  import '../../../../context/ViewContext/ViewContext.js';
21
14
  import '../../../../shared/logger.js';
22
15
  import '@dynamic-labs/wallet-book';
16
+ import { EMBEDDED_WALLET_SESSION_SETTINGS } from '../../../../utils/constants/localStorage.js';
17
+ import '../../../../utils/constants/colors.js';
18
+ import '../../../../utils/constants/values.js';
23
19
  import '../../../../shared/consts/index.js';
20
+ import { findEmbeddedWalletFromVerifiedCredentials } from '../../../../utils/functions/findEmbeddedWalletFromVerifiedCredentials/findEmbeddedWalletFromVerifiedCredentials.js';
21
+ import { USER_NOT_LOGGED_IN } from '../../../../utils/constants/errors.js';
22
+ import '@dynamic-labs/multi-wallet';
23
+ import 'react-international-phone';
24
24
  import '../../../../store/state/nonce/nonce.js';
25
25
  import { removeElementById } from '../../../../utils/functions/removeElementById/removeElementById.js';
26
26
  import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
@@ -68,7 +68,7 @@ const initEmbeddedWalletSession = (_a) => __awaiter(void 0, [_a], void 0, functi
68
68
  return;
69
69
  });
70
70
  const passkeyRecoveryBundleValidation = (_c) => __awaiter(void 0, [_c], void 0, function* ({ user, bundleInput, wallet, }) {
71
- var _d, _e, _f, _g;
71
+ var _d, _e, _f, _g, _h;
72
72
  if (!bundleInput) {
73
73
  throw new DynamicError('Code must be informed');
74
74
  }
@@ -80,8 +80,8 @@ const passkeyRecoveryBundleValidation = (_c) => __awaiter(void 0, [_c], void 0,
80
80
  if (!user) {
81
81
  throw new DynamicError(USER_NOT_LOGGED_IN);
82
82
  }
83
- const organizationId = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId;
84
- const turnkeyRecoveryHandler = (_g = wallet.connector) === null || _g === void 0 ? void 0 : _g.getAuthenticatorHandler();
83
+ const organizationId = (_g = (_f = (_e = (_d = user.verifiedCredentials) === null || _d === void 0 ? void 0 : _d.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _e === void 0 ? void 0 : _e.walletProperties) === null || _f === void 0 ? void 0 : _f.turnkeySubOrganizationId) !== null && _g !== void 0 ? _g : undefined;
84
+ const turnkeyRecoveryHandler = (_h = wallet.connector) === null || _h === void 0 ? void 0 : _h.getAuthenticatorHandler();
85
85
  yield turnkeyRecoveryHandler.verifyRecoveryCode(bundleInput, organizationId);
86
86
  const sessionSettings = {
87
87
  createdAt: new Date().getTime(),
@@ -90,8 +90,8 @@ const passkeyRecoveryBundleValidation = (_c) => __awaiter(void 0, [_c], void 0,
90
90
  };
91
91
  StorageService.setItem(EMBEDDED_WALLET_SESSION_SETTINGS, sessionSettings);
92
92
  });
93
- const resentRecoveryEmail = (_h) => __awaiter(void 0, [_h], void 0, function* ({ authenticatorType, user, environmentId, wallet, }) {
94
- var _j;
93
+ const resentRecoveryEmail = (_j) => __awaiter(void 0, [_j], void 0, function* ({ authenticatorType, user, environmentId, wallet, }) {
94
+ var _k;
95
95
  if (!user) {
96
96
  throw new DynamicError(USER_NOT_LOGGED_IN);
97
97
  }
@@ -100,7 +100,7 @@ const resentRecoveryEmail = (_h) => __awaiter(void 0, [_h], void 0, function* ({
100
100
  !isPasskeyWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
101
101
  throw new InvalidPrimaryWalletOrConnectorError();
102
102
  }
103
- const publicKey = (_j = wallet.connector) === null || _j === void 0 ? void 0 : _j.getAuthenticatorHandler().publicKey;
103
+ const publicKey = (_k = wallet.connector) === null || _k === void 0 ? void 0 : _k.getAuthenticatorHandler().publicKey;
104
104
  if (!publicKey) {
105
105
  throw new DynamicError('Could not proceed with your request. Please restart the process.');
106
106
  }
@@ -111,7 +111,7 @@ const resentRecoveryEmail = (_h) => __awaiter(void 0, [_h], void 0, function* ({
111
111
  walletId: wallet === null || wallet === void 0 ? void 0 : wallet.id,
112
112
  });
113
113
  });
114
- const completePasskeyRecovery = (_k) => __awaiter(void 0, [_k], void 0, function* ({ user, environmentId, wallet, }) {
114
+ const completePasskeyRecovery = (_l) => __awaiter(void 0, [_l], void 0, function* ({ user, environmentId, wallet, }) {
115
115
  const { connector, user: updatedUser } = yield recoverTurnkeyWallet({
116
116
  addPasskeyAuthenticator: false,
117
117
  environmentId,
@@ -124,7 +124,7 @@ const completePasskeyRecovery = (_k) => __awaiter(void 0, [_k], void 0, function
124
124
  removeElementById(iframeElementId);
125
125
  return updatedUser;
126
126
  });
127
- const addNewPasskeyAuthenticator = (_l) => __awaiter(void 0, [_l], void 0, function* ({ user, environmentId, wallet, }) {
127
+ const addNewPasskeyAuthenticator = (_m) => __awaiter(void 0, [_m], void 0, function* ({ user, environmentId, wallet, }) {
128
128
  const { user: updatedUser } = yield recoverTurnkeyWallet({
129
129
  addPasskeyAuthenticator: true,
130
130
  environmentId,
@@ -133,8 +133,8 @@ const addNewPasskeyAuthenticator = (_l) => __awaiter(void 0, [_l], void 0, funct
133
133
  });
134
134
  return updatedUser;
135
135
  });
136
- const recoverTurnkeyWallet = (_m) => __awaiter(void 0, [_m], void 0, function* ({ wallet, user, environmentId, addPasskeyAuthenticator, }) {
137
- var _o, _p, _q;
136
+ const recoverTurnkeyWallet = (_o) => __awaiter(void 0, [_o], void 0, function* ({ wallet, user, environmentId, addPasskeyAuthenticator, }) {
137
+ var _p, _q, _r;
138
138
  if (!user) {
139
139
  throw new DynamicError(USER_NOT_LOGGED_IN);
140
140
  }
@@ -146,7 +146,7 @@ const recoverTurnkeyWallet = (_m) => __awaiter(void 0, [_m], void 0, function* (
146
146
  }
147
147
  const connector = wallet.connector;
148
148
  connector.setEmail(user.email);
149
- const turnkeySubOrganizationId = (_q = (_p = (_o = user.verifiedCredentials) === null || _o === void 0 ? void 0 : _o.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _p === void 0 ? void 0 : _p.walletProperties) === null || _q === void 0 ? void 0 : _q.turnkeySubOrganizationId;
149
+ const turnkeySubOrganizationId = (_r = (_q = (_p = user.verifiedCredentials) === null || _p === void 0 ? void 0 : _p.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _q === void 0 ? void 0 : _q.walletProperties) === null || _r === void 0 ? void 0 : _r.turnkeySubOrganizationId;
150
150
  if (!turnkeySubOrganizationId) {
151
151
  throw new DynamicError('The authentication token is invalid - turnkeySubOrganizationId is missing');
152
152
  }
@@ -204,8 +204,8 @@ const canRestoreEmbeddedWalletSession = (sessionExpirationTime) => {
204
204
  }
205
205
  return true;
206
206
  };
207
- const restoreEmbeddedWalletSession = (_r) => __awaiter(void 0, [_r], void 0, function* ({ user, iframeContainer, iframeElementId, wallet, sessionExpiration, }) {
208
- var _s, _t, _u, _v;
207
+ const restoreEmbeddedWalletSession = (_s) => __awaiter(void 0, [_s], void 0, function* ({ user, iframeContainer, iframeElementId, wallet, sessionExpiration, }) {
208
+ var _t, _u, _v, _w, _x;
209
209
  if (!user) {
210
210
  throw new DynamicError(USER_NOT_LOGGED_IN);
211
211
  }
@@ -215,7 +215,7 @@ const restoreEmbeddedWalletSession = (_r) => __awaiter(void 0, [_r], void 0, fun
215
215
  throw new InvalidPrimaryWalletOrConnectorError();
216
216
  }
217
217
  const sessionSettings = StorageService.getItem(EMBEDDED_WALLET_SESSION_SETTINGS);
218
- const turnkeyRecoveryHandler = (_s = wallet.connector) === null || _s === void 0 ? void 0 : _s.getAuthenticatorHandler();
218
+ const turnkeyRecoveryHandler = (_t = wallet.connector) === null || _t === void 0 ? void 0 : _t.getAuthenticatorHandler();
219
219
  if (!sessionSettings || Boolean(turnkeyRecoveryHandler.recoveryUserId)) {
220
220
  return false;
221
221
  }
@@ -224,12 +224,12 @@ const restoreEmbeddedWalletSession = (_r) => __awaiter(void 0, [_r], void 0, fun
224
224
  throw new DynamicError('Could not open embedded wallet connection communication');
225
225
  }
226
226
  turnkeyRecoveryHandler.recoveryUserId = sessionSettings.userId;
227
- const organizationId = (_v = (_u = (_t = user.verifiedCredentials) === null || _t === void 0 ? void 0 : _t.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _u === void 0 ? void 0 : _u.walletProperties) === null || _v === void 0 ? void 0 : _v.turnkeySubOrganizationId;
227
+ const organizationId = (_x = (_w = (_v = (_u = user.verifiedCredentials) === null || _u === void 0 ? void 0 : _u.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _v === void 0 ? void 0 : _v.walletProperties) === null || _w === void 0 ? void 0 : _w.turnkeySubOrganizationId) !== null && _x !== void 0 ? _x : undefined;
228
228
  yield turnkeyRecoveryHandler.verifyRecoveryCode(sessionSettings.emailCode, organizationId);
229
229
  return true;
230
230
  });
231
- const addEmailRecovery = (_w) => __awaiter(void 0, [_w], void 0, function* ({ user, environmentId, wallet, }) {
232
- var _x, _y;
231
+ const addEmailRecovery = (_y) => __awaiter(void 0, [_y], void 0, function* ({ user, environmentId, wallet, }) {
232
+ var _z, _0;
233
233
  if (!(user === null || user === void 0 ? void 0 : user.email)) {
234
234
  throw new DynamicError(USER_NOT_LOGGED_IN);
235
235
  }
@@ -239,7 +239,7 @@ const addEmailRecovery = (_w) => __awaiter(void 0, [_w], void 0, function* ({ us
239
239
  !isEmailWalletConnector(wallet === null || wallet === void 0 ? void 0 : wallet.connector)) {
240
240
  throw new InvalidPrimaryWalletOrConnectorError();
241
241
  }
242
- const { turnkeySubOrganizationId, turnkeyUserId } = (_y = (_x = user.verifiedCredentials) === null || _x === void 0 ? void 0 : _x.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _y === void 0 ? void 0 : _y.walletProperties;
242
+ const { turnkeySubOrganizationId, turnkeyUserId } = (_0 = (_z = user.verifiedCredentials) === null || _z === void 0 ? void 0 : _z.find(({ walletName, id }) => (walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey')) && id === wallet.id)) === null || _0 === void 0 ? void 0 : _0.walletProperties;
243
243
  if (!turnkeySubOrganizationId || !turnkeyUserId) {
244
244
  throw new DynamicError('The authentication token is invalid - turnkeySubOrganizationId or turnkeyUserID is missing');
245
245
  }
@@ -11,8 +11,10 @@ require('../../../../context/DynamicContext/DynamicContext.cjs');
11
11
  require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
12
12
  require('@dynamic-labs/iconic');
13
13
  require('@dynamic-labs/wallet-connector-core');
14
+ var check = require('../../../../shared/assets/check.cjs');
14
15
  var chevronDown = require('../../../../shared/assets/chevron-down.cjs');
15
16
  require('../../../../context/ViewContext/ViewContext.cjs');
17
+ var reloadIcon = require('../../../../shared/assets/reload-icon.cjs');
16
18
  require('../../../../shared/logger.cjs');
17
19
  require('@dynamic-labs/wallet-book');
18
20
  require('@dynamic-labs/utils');
@@ -117,12 +119,16 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
117
119
  const [balanceIsExpanded, setBalanceIsExpanded] = React.useState(false);
118
120
  /** Controls for the shadow on scroll of the multi asset balance section */
119
121
  const [hasShadow, setHasShadow] = React.useState(false);
122
+ const [isRefreshing, setIsRefreshing] = React.useState(false);
123
+ const [isSuccess, setIsSuccess] = React.useState(false);
120
124
  const contentRef = React.useRef(null);
125
+ const successTimeoutRef = React.useRef(null);
126
+ const refreshTimeoutRef = React.useRef(null);
121
127
  const { primaryWallet, network, showFiat, multiAsset } = useInternalDynamicContext.useInternalDynamicContext();
122
128
  const authMode$1 = authMode.useAuthMode();
123
129
  const projectSettings = useProjectSettings.useProjectSettings();
124
130
  const { data: testnet } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () { return Boolean(yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isTestnet())); }), { deps: [network], initialData: false });
125
- const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances.useTokenBalances({
131
+ const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances.useTokenBalances({
126
132
  chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
127
133
  includeFiat: showFiat,
128
134
  includeNativeBalance: true,
@@ -152,6 +158,37 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
152
158
  setHasShadow(contentRef.current.scrollTop > 0);
153
159
  }
154
160
  };
161
+ const handleRefresh = React.useCallback((event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
162
+ event.stopPropagation();
163
+ if (isRefreshing || isSuccess)
164
+ return;
165
+ // Clear any existing timeouts
166
+ if (successTimeoutRef.current) {
167
+ clearTimeout(successTimeoutRef.current);
168
+ successTimeoutRef.current = null;
169
+ }
170
+ if (refreshTimeoutRef.current) {
171
+ clearTimeout(refreshTimeoutRef.current);
172
+ refreshTimeoutRef.current = null;
173
+ }
174
+ setIsRefreshing(true);
175
+ setIsSuccess(false);
176
+ try {
177
+ yield fetchAccountBalances(true);
178
+ setIsRefreshing(false);
179
+ setIsSuccess(true);
180
+ successTimeoutRef.current = setTimeout(() => {
181
+ setIsSuccess(false);
182
+ successTimeoutRef.current = null;
183
+ }, 5000);
184
+ }
185
+ catch (error) {
186
+ refreshTimeoutRef.current = setTimeout(() => {
187
+ setIsRefreshing(false);
188
+ refreshTimeoutRef.current = null;
189
+ }, 1000);
190
+ }
191
+ }), [isRefreshing, isSuccess, fetchAccountBalances]);
155
192
  const primaryWalletNativeBalance = () => {
156
193
  if (!primaryWallet || isLoadingTokenBalances || isLoading) {
157
194
  return jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-container__skeleton' });
@@ -160,7 +197,10 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
160
197
  ? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
161
198
  : '<$0.01' })) : (jsxRuntime.jsx(Balance.Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
162
199
  };
163
- const balanceHeaderTitle = () => (jsxRuntime.jsxs("div", { className: 'balance-header__title', children: [isLoadingTokenBalances || isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-header__title-skeleton' })) : (jsxRuntime.jsx(Typography.Typography, { color: 'secondary', variant: 'body_normal', copykey: 'dyn_active_wallet_info.balance', children: t('dyn_active_wallet_info.balance') })), jsxRuntime.jsx("div", { className: 'balance-header__balance', children: primaryWalletNativeBalance() })] }));
200
+ const balanceHeaderTitle = () => (jsxRuntime.jsxs("div", { className: 'balance-header__title', children: [isLoadingTokenBalances || isLoading ? (jsxRuntime.jsx(Skeleton.Skeleton, { className: 'balance-header__title-skeleton' })) : (jsxRuntime.jsx(Typography.Typography, { color: 'secondary', variant: 'body_normal', copykey: 'dyn_active_wallet_info.balance', children: t('dyn_active_wallet_info.balance') })), jsxRuntime.jsxs("div", { className: 'balance-header__balance', children: [primaryWalletNativeBalance(), isSuccess ? (jsxRuntime.jsx("div", { className: 'balance-header__success-icon', children: jsxRuntime.jsx(check.ReactComponent, { "data-testid": 'success-icon' }) })) : (jsxRuntime.jsx(reloadIcon.ReactComponent, { "data-testid": 'refresh-balances', className: `balance-header__refresh-icon ${isRefreshing ? 'balance-header__refresh-icon--spinning' : ''}`, onClick: handleRefresh, style: {
201
+ cursor: isRefreshing ? 'not-allowed' : 'pointer',
202
+ opacity: isRefreshing ? 0.5 : 1,
203
+ }, title: 'Refresh balances' }))] })] }));
164
204
  const toggleBalanceAccordion = React.useCallback(() => {
165
205
  if (!isLoadingTokenBalances) {
166
206
  setBalanceIsExpanded(!balanceIsExpanded);
@@ -7,8 +7,10 @@ import '../../../../context/DynamicContext/DynamicContext.js';
7
7
  import '../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
8
8
  import '@dynamic-labs/iconic';
9
9
  import '@dynamic-labs/wallet-connector-core';
10
+ import { ReactComponent as SvgCheck } from '../../../../shared/assets/check.js';
10
11
  import { ReactComponent as SvgChevronDown } from '../../../../shared/assets/chevron-down.js';
11
12
  import '../../../../context/ViewContext/ViewContext.js';
13
+ import { ReactComponent as SvgReloadIcon } from '../../../../shared/assets/reload-icon.js';
12
14
  import '../../../../shared/logger.js';
13
15
  import '@dynamic-labs/wallet-book';
14
16
  import '@dynamic-labs/utils';
@@ -113,12 +115,16 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
113
115
  const [balanceIsExpanded, setBalanceIsExpanded] = useState(false);
114
116
  /** Controls for the shadow on scroll of the multi asset balance section */
115
117
  const [hasShadow, setHasShadow] = useState(false);
118
+ const [isRefreshing, setIsRefreshing] = useState(false);
119
+ const [isSuccess, setIsSuccess] = useState(false);
116
120
  const contentRef = useRef(null);
121
+ const successTimeoutRef = useRef(null);
122
+ const refreshTimeoutRef = useRef(null);
117
123
  const { primaryWallet, network, showFiat, multiAsset } = useInternalDynamicContext();
118
124
  const authMode = useAuthMode();
119
125
  const projectSettings = useProjectSettings();
120
126
  const { data: testnet } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () { return Boolean(yield (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.isTestnet())); }), { deps: [network], initialData: false });
121
- const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, } = useTokenBalances({
127
+ const { isLoading: isLoadingTokenBalances, tokenBalances, error: errorTokenBalances, fetchAccountBalances, } = useTokenBalances({
122
128
  chainName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain,
123
129
  includeFiat: showFiat,
124
130
  includeNativeBalance: true,
@@ -148,6 +154,37 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
148
154
  setHasShadow(contentRef.current.scrollTop > 0);
149
155
  }
150
156
  };
157
+ const handleRefresh = useCallback((event) => __awaiter(void 0, void 0, void 0, function* () {
158
+ event.stopPropagation();
159
+ if (isRefreshing || isSuccess)
160
+ return;
161
+ // Clear any existing timeouts
162
+ if (successTimeoutRef.current) {
163
+ clearTimeout(successTimeoutRef.current);
164
+ successTimeoutRef.current = null;
165
+ }
166
+ if (refreshTimeoutRef.current) {
167
+ clearTimeout(refreshTimeoutRef.current);
168
+ refreshTimeoutRef.current = null;
169
+ }
170
+ setIsRefreshing(true);
171
+ setIsSuccess(false);
172
+ try {
173
+ yield fetchAccountBalances(true);
174
+ setIsRefreshing(false);
175
+ setIsSuccess(true);
176
+ successTimeoutRef.current = setTimeout(() => {
177
+ setIsSuccess(false);
178
+ successTimeoutRef.current = null;
179
+ }, 5000);
180
+ }
181
+ catch (error) {
182
+ refreshTimeoutRef.current = setTimeout(() => {
183
+ setIsRefreshing(false);
184
+ refreshTimeoutRef.current = null;
185
+ }, 1000);
186
+ }
187
+ }), [isRefreshing, isSuccess, fetchAccountBalances]);
151
188
  const primaryWalletNativeBalance = () => {
152
189
  if (!primaryWallet || isLoadingTokenBalances || isLoading) {
153
190
  return jsx(Skeleton, { className: 'balance-container__skeleton' });
@@ -156,7 +193,10 @@ const ActiveWalletBalance = ({ isLoading = false, }) => {
156
193
  ? currencyFormatter.format(parseFloat(totalValue.toFixed(2)))
157
194
  : '<$0.01' })) : (jsx(Balance, { className: 'balance-header__balance', wallet: primaryWallet, network: network, variant: 'numbers_display' }));
158
195
  };
159
- const balanceHeaderTitle = () => (jsxs("div", { className: 'balance-header__title', children: [isLoadingTokenBalances || isLoading ? (jsx(Skeleton, { className: 'balance-header__title-skeleton' })) : (jsx(Typography, { color: 'secondary', variant: 'body_normal', copykey: 'dyn_active_wallet_info.balance', children: t('dyn_active_wallet_info.balance') })), jsx("div", { className: 'balance-header__balance', children: primaryWalletNativeBalance() })] }));
196
+ const balanceHeaderTitle = () => (jsxs("div", { className: 'balance-header__title', children: [isLoadingTokenBalances || isLoading ? (jsx(Skeleton, { className: 'balance-header__title-skeleton' })) : (jsx(Typography, { color: 'secondary', variant: 'body_normal', copykey: 'dyn_active_wallet_info.balance', children: t('dyn_active_wallet_info.balance') })), jsxs("div", { className: 'balance-header__balance', children: [primaryWalletNativeBalance(), isSuccess ? (jsx("div", { className: 'balance-header__success-icon', children: jsx(SvgCheck, { "data-testid": 'success-icon' }) })) : (jsx(SvgReloadIcon, { "data-testid": 'refresh-balances', className: `balance-header__refresh-icon ${isRefreshing ? 'balance-header__refresh-icon--spinning' : ''}`, onClick: handleRefresh, style: {
197
+ cursor: isRefreshing ? 'not-allowed' : 'pointer',
198
+ opacity: isRefreshing ? 0.5 : 1,
199
+ }, title: 'Refresh balances' }))] })] }));
160
200
  const toggleBalanceAccordion = useCallback(() => {
161
201
  if (!isLoadingTokenBalances) {
162
202
  setBalanceIsExpanded(!balanceIsExpanded);
@@ -9,19 +9,19 @@ require('@dynamic-labs/sdk-api-core');
9
9
  require('../../../../client/client.cjs');
10
10
  require('@dynamic-labs-sdk/client');
11
11
  require('../../../../config/ApiEndpoint.cjs');
12
- require('../../../../utils/constants/values.cjs');
13
- require('@dynamic-labs/utils');
14
- require('../../../../../../_virtual/_tslib.cjs');
15
- require('@dynamic-labs/multi-wallet');
16
- require('react-international-phone');
17
- require('../../../../utils/constants/colors.cjs');
18
12
  require('@dynamic-labs/iconic');
19
13
  require('@dynamic-labs/wallet-connector-core');
20
14
  require('react/jsx-runtime');
21
15
  require('../../../../context/ViewContext/ViewContext.cjs');
22
16
  require('../../../../shared/logger.cjs');
23
17
  require('@dynamic-labs/wallet-book');
18
+ require('@dynamic-labs/utils');
19
+ require('../../../../utils/constants/colors.cjs');
20
+ require('../../../../utils/constants/values.cjs');
24
21
  require('../../../../shared/consts/index.cjs');
22
+ require('../../../../../../_virtual/_tslib.cjs');
23
+ require('@dynamic-labs/multi-wallet');
24
+ require('react-international-phone');
25
25
  require('../../../../store/state/nonce/nonce.cjs');
26
26
  require('@dynamic-labs/locale');
27
27
  require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
@@ -5,19 +5,19 @@ import '@dynamic-labs/sdk-api-core';
5
5
  import '../../../../client/client.js';
6
6
  import '@dynamic-labs-sdk/client';
7
7
  import '../../../../config/ApiEndpoint.js';
8
- import '../../../../utils/constants/values.js';
9
- import '@dynamic-labs/utils';
10
- import '../../../../../../_virtual/_tslib.js';
11
- import '@dynamic-labs/multi-wallet';
12
- import 'react-international-phone';
13
- import '../../../../utils/constants/colors.js';
14
8
  import '@dynamic-labs/iconic';
15
9
  import '@dynamic-labs/wallet-connector-core';
16
10
  import 'react/jsx-runtime';
17
11
  import '../../../../context/ViewContext/ViewContext.js';
18
12
  import '../../../../shared/logger.js';
19
13
  import '@dynamic-labs/wallet-book';
14
+ import '@dynamic-labs/utils';
15
+ import '../../../../utils/constants/colors.js';
16
+ import '../../../../utils/constants/values.js';
20
17
  import '../../../../shared/consts/index.js';
18
+ import '../../../../../../_virtual/_tslib.js';
19
+ import '@dynamic-labs/multi-wallet';
20
+ import 'react-international-phone';
21
21
  import '../../../../store/state/nonce/nonce.js';
22
22
  import '@dynamic-labs/locale';
23
23
  import '../../../../store/state/dynamicContextProps/dynamicContextProps.js';
@@ -17,16 +17,16 @@ require('@dynamic-labs/sdk-api-core');
17
17
  require('../../../../../client/client.cjs');
18
18
  require('@dynamic-labs-sdk/client');
19
19
  require('../../../../../config/ApiEndpoint.cjs');
20
- require('../../../../../utils/constants/values.cjs');
21
- require('@dynamic-labs/utils');
22
- require('../../../../../../../_virtual/_tslib.cjs');
23
- require('@dynamic-labs/multi-wallet');
24
- require('react-international-phone');
25
- require('../../../../../utils/constants/colors.cjs');
26
20
  require('@dynamic-labs/wallet-connector-core');
27
21
  require('../../../../../shared/logger.cjs');
28
22
  require('@dynamic-labs/wallet-book');
23
+ require('@dynamic-labs/utils');
24
+ require('../../../../../utils/constants/colors.cjs');
25
+ require('../../../../../utils/constants/values.cjs');
29
26
  require('../../../../../shared/consts/index.cjs');
27
+ require('../../../../../../../_virtual/_tslib.cjs');
28
+ require('@dynamic-labs/multi-wallet');
29
+ require('react-international-phone');
30
30
  require('../../../../../store/state/nonce/nonce.cjs');
31
31
  require('@dynamic-labs/locale');
32
32
  require('../../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
@@ -13,16 +13,16 @@ import '@dynamic-labs/sdk-api-core';
13
13
  import '../../../../../client/client.js';
14
14
  import '@dynamic-labs-sdk/client';
15
15
  import '../../../../../config/ApiEndpoint.js';
16
- import '../../../../../utils/constants/values.js';
17
- import '@dynamic-labs/utils';
18
- import '../../../../../../../_virtual/_tslib.js';
19
- import '@dynamic-labs/multi-wallet';
20
- import 'react-international-phone';
21
- import '../../../../../utils/constants/colors.js';
22
16
  import '@dynamic-labs/wallet-connector-core';
23
17
  import '../../../../../shared/logger.js';
24
18
  import '@dynamic-labs/wallet-book';
19
+ import '@dynamic-labs/utils';
20
+ import '../../../../../utils/constants/colors.js';
21
+ import '../../../../../utils/constants/values.js';
25
22
  import '../../../../../shared/consts/index.js';
23
+ import '../../../../../../../_virtual/_tslib.js';
24
+ import '@dynamic-labs/multi-wallet';
25
+ import 'react-international-phone';
26
26
  import '../../../../../store/state/nonce/nonce.js';
27
27
  import '@dynamic-labs/locale';
28
28
  import '../../../../../store/state/dynamicContextProps/dynamicContextProps.js';
@@ -10,18 +10,18 @@ require('../../../../../../client/client.cjs');
10
10
  require('react');
11
11
  require('@dynamic-labs-sdk/client');
12
12
  require('../../../../../../config/ApiEndpoint.cjs');
13
- require('../../../../../../utils/constants/values.cjs');
14
- require('../../../../../../../../_virtual/_tslib.cjs');
15
- require('@dynamic-labs/multi-wallet');
16
- require('react-international-phone');
17
- require('../../../../../../utils/constants/colors.cjs');
18
13
  require('@dynamic-labs/iconic');
19
14
  require('@dynamic-labs/wallet-connector-core');
20
15
  require('react/jsx-runtime');
21
16
  require('../../../../../../context/ViewContext/ViewContext.cjs');
22
17
  require('../../../../../../shared/logger.cjs');
23
18
  require('@dynamic-labs/wallet-book');
19
+ require('../../../../../../utils/constants/colors.cjs');
20
+ require('../../../../../../utils/constants/values.cjs');
24
21
  require('../../../../../../shared/consts/index.cjs');
22
+ require('../../../../../../../../_virtual/_tslib.cjs');
23
+ require('@dynamic-labs/multi-wallet');
24
+ require('react-international-phone');
25
25
  require('../../../../../../store/state/nonce/nonce.cjs');
26
26
  require('@dynamic-labs/locale');
27
27
  require('../../../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
@@ -6,18 +6,18 @@ import '../../../../../../client/client.js';
6
6
  import 'react';
7
7
  import '@dynamic-labs-sdk/client';
8
8
  import '../../../../../../config/ApiEndpoint.js';
9
- import '../../../../../../utils/constants/values.js';
10
- import '../../../../../../../../_virtual/_tslib.js';
11
- import '@dynamic-labs/multi-wallet';
12
- import 'react-international-phone';
13
- import '../../../../../../utils/constants/colors.js';
14
9
  import '@dynamic-labs/iconic';
15
10
  import '@dynamic-labs/wallet-connector-core';
16
11
  import 'react/jsx-runtime';
17
12
  import '../../../../../../context/ViewContext/ViewContext.js';
18
13
  import '../../../../../../shared/logger.js';
19
14
  import '@dynamic-labs/wallet-book';
15
+ import '../../../../../../utils/constants/colors.js';
16
+ import '../../../../../../utils/constants/values.js';
20
17
  import '../../../../../../shared/consts/index.js';
18
+ import '../../../../../../../../_virtual/_tslib.js';
19
+ import '@dynamic-labs/multi-wallet';
20
+ import 'react-international-phone';
21
21
  import '../../../../../../store/state/nonce/nonce.js';
22
22
  import '@dynamic-labs/locale';
23
23
  import '../../../../../../store/state/dynamicContextProps/dynamicContextProps.js';