@dynamic-labs/sdk-react-core 4.79.2 → 4.81.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.
- package/CHANGELOG.md +25 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/Main.cjs +2 -2
- package/src/lib/Main.js +2 -2
- package/src/lib/client/extension/deprecated/mfa/verifyTotpMfaDevice/verifyTotpMfaDevice.d.ts +1 -1
- package/src/lib/components/LogoutButton/LogoutButton.cjs +2 -2
- package/src/lib/components/LogoutButton/LogoutButton.js +2 -2
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +63 -3
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +63 -3
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.cjs +40 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.d.ts +16 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.js +36 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.cjs +17 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.d.ts +8 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.js +12 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +6 -4
- package/src/lib/context/DynamicContext/DynamicContext.js +6 -4
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +9 -0
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +25 -12
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.d.ts +5 -3
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +24 -11
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.cjs +3 -3
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.d.ts +3 -2
- package/src/lib/context/DynamicContext/hooks/useRemoveWallet/useRemoveWallet.js +3 -3
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +2 -0
- package/src/lib/context/DynamicContext/types/IInternalDynamicContext.d.ts +8 -1
- package/src/lib/events/auth.d.ts +2 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useAleoShieldedBalances/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.cjs +372 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.d.ts +24 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.js +368 -0
- package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs +2 -2
- package/src/lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +1 -0
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWalletSessionKeys/useEmbeddedWalletSessionKeys.js +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +3 -3
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +3 -3
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.d.ts +2 -1
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js +1 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +3 -1
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.d.ts +2 -2
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +3 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +3 -3
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.d.ts +3 -3
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +3 -3
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +2 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.d.ts +3 -2
- package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +2 -2
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.cjs +5 -5
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.js +5 -5
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +2 -2
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +2 -2
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +2 -2
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +2 -2
- package/src/lib/views/DeviceRegistrationView/DeviceRegistrationView.cjs +2 -2
- package/src/lib/views/DeviceRegistrationView/DeviceRegistrationView.js +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -2
- package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.cjs +2 -2
- package/src/lib/views/EmbeddedDeleteView/EmbeddedDeleteView.js +2 -2
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +7 -7
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +7 -7
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +7 -7
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +7 -7
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +5 -5
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +5 -5
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +53 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +53 -0
- package/src/lib/views/SmsVerification/SmsVerification.cjs +2 -2
- package/src/lib/views/SmsVerification/SmsVerification.js +2 -2
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.cjs +2 -2
- package/src/lib/views/WalletDelegation/WalletDelegationView/WalletDelegationView.js +2 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.cjs +2 -2
- package/src/lib/views/WalletLockedView/WalletLockedView.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +191 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +191 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.d.ts +10 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +5 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.d.ts +3 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/SingleWalletButtons/SingleWalletButtons.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SettingsView/SettingsView.js +2 -2
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
|
+
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
6
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
7
|
+
import '@dynamic-labs/iconic';
|
|
8
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import '../../../shared/logger.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../constants/colors.js';
|
|
15
|
+
import '../../constants/values.js';
|
|
16
|
+
import '../../../shared/consts/index.js';
|
|
17
|
+
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import 'react-international-phone';
|
|
22
|
+
import '../../../store/state/nonce/nonce.js';
|
|
23
|
+
import '@dynamic-labs-sdk/client/core';
|
|
24
|
+
import 'eventemitter3';
|
|
25
|
+
import '@dynamic-labs-sdk/client';
|
|
26
|
+
import '../../../config/ApiEndpoint.js';
|
|
27
|
+
import '@dynamic-labs/locale';
|
|
28
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
29
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
30
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
31
|
+
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
32
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
35
|
+
import '../../../store/state/authMode/authMode.js';
|
|
36
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
37
|
+
import 'react-dom';
|
|
38
|
+
import '../../functions/compareChains/compareChains.js';
|
|
39
|
+
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
40
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
41
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
42
|
+
import 'bs58';
|
|
43
|
+
import '@dynamic-labs/types';
|
|
44
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
45
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
46
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
47
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
48
|
+
import 'yup';
|
|
49
|
+
import '../../../context/MockContext/MockContext.js';
|
|
50
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
51
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
52
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
53
|
+
import '@dynamic-labs/rpc-providers';
|
|
54
|
+
import '../../../store/state/walletOptions/walletOptions.js';
|
|
55
|
+
import 'react-i18next';
|
|
56
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
57
|
+
import '../../../components/Alert/Alert.js';
|
|
58
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
59
|
+
import '../../../components/IconButton/IconButton.js';
|
|
60
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
61
|
+
import '../../../components/Input/Input.js';
|
|
62
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
63
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
64
|
+
import '../../../components/OverlayCard/OverlayCard.js';
|
|
65
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
66
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
67
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
68
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
69
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
70
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
71
|
+
import 'react-focus-lock';
|
|
72
|
+
import 'qrcode';
|
|
73
|
+
import 'formik';
|
|
74
|
+
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
75
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
76
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
77
|
+
import '../useGetMfaToken/useGetMfaToken.js';
|
|
78
|
+
import '../useWalletBackup/useWalletBackup.js';
|
|
79
|
+
import '../useWalletBackup/types.js';
|
|
80
|
+
import '../useWalletBackup/cloudProviders.js';
|
|
81
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
82
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
83
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
84
|
+
import '@hcaptcha/react-hcaptcha';
|
|
85
|
+
import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
|
|
86
|
+
import '../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
87
|
+
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
88
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
89
|
+
import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
90
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
91
|
+
import '../../../context/OnrampContext/OnrampContext.js';
|
|
92
|
+
import '../../../store/state/sendBalances.js';
|
|
93
|
+
import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
94
|
+
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
95
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
96
|
+
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
97
|
+
import '../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
|
|
98
|
+
import '../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
|
|
99
|
+
import '../../../../index.js';
|
|
100
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js';
|
|
101
|
+
import '../../../widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js';
|
|
102
|
+
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
103
|
+
import '../../../store/state/tokenBalances.js';
|
|
104
|
+
import '../../../store/state/multichainBalances.js';
|
|
105
|
+
import '@dynamic-labs/store';
|
|
106
|
+
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
107
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
108
|
+
|
|
109
|
+
const MICROCREDITS_PER_CREDIT = 1000000;
|
|
110
|
+
const ALEO_CREDITS_LOGO = 'https://app.dynamic.xyz/assets/networks/aleo.svg';
|
|
111
|
+
// Generic dark "?" token icon — matches redcoast's `DEFAULT_TOKEN_LOGO_URI`
|
|
112
|
+
// used by the multichain endpoint when an unshielded token has no curated
|
|
113
|
+
// logo. Reusing it here keeps the Shielded tab visually consistent with
|
|
114
|
+
// the Unshielded tab for the same token.
|
|
115
|
+
const UNKNOWN_TOKEN_LOGO = 'https://app.dynamic.xyz/assets/tokens/unknown.svg';
|
|
116
|
+
const TOKEN_REGISTRY_PROGRAM = 'token_registry.aleo';
|
|
117
|
+
const TOKEN_REGISTRY_RECORD = 'Token';
|
|
118
|
+
// Non-credits tokens deliberately omit `logoURI` — Aleo doesn't have a
|
|
119
|
+
// curated icon list yet, so leaving it undefined surfaces the widget's
|
|
120
|
+
// generic placeholder (`?` skeleton) consistent with the unshielded feed.
|
|
121
|
+
const KNOWN_SHIELDED_TOKENS = [
|
|
122
|
+
{
|
|
123
|
+
contractAddress: 'usad_stablecoin.aleo',
|
|
124
|
+
decimals: 6,
|
|
125
|
+
name: 'USAD',
|
|
126
|
+
programName: 'usad_stablecoin.aleo',
|
|
127
|
+
recordName: 'Token',
|
|
128
|
+
symbol: 'USAD',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
contractAddress: 'test_usad_stablecoin.aleo',
|
|
132
|
+
decimals: 6,
|
|
133
|
+
name: 'USAD',
|
|
134
|
+
programName: 'test_usad_stablecoin.aleo',
|
|
135
|
+
recordName: 'Token',
|
|
136
|
+
symbol: 'USAD',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
contractAddress: 'usdcx_stablecoin.aleo',
|
|
140
|
+
decimals: 6,
|
|
141
|
+
name: 'USDCx',
|
|
142
|
+
programName: 'usdcx_stablecoin.aleo',
|
|
143
|
+
recordName: 'Token',
|
|
144
|
+
symbol: 'USDCx',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
contractAddress: 'test_usdcx_stablecoin.aleo',
|
|
148
|
+
decimals: 6,
|
|
149
|
+
name: 'USDCx',
|
|
150
|
+
programName: 'test_usdcx_stablecoin.aleo',
|
|
151
|
+
recordName: 'Token',
|
|
152
|
+
symbol: 'USDCx',
|
|
153
|
+
},
|
|
154
|
+
// ARC-21 (Hyperlane warp routes) — mainnet only. Token IDs match the
|
|
155
|
+
// values pinned in `packages/aleo/src/utils/aleoSendableTokens` and the
|
|
156
|
+
// redcoast `aleoArc21Tokens` registry. Decimals match each token's
|
|
157
|
+
// `token_info` metadata on-chain.
|
|
158
|
+
{
|
|
159
|
+
contractAddress: 'hyp_warp_token_sol.aleo',
|
|
160
|
+
decimals: 9,
|
|
161
|
+
name: 'Wrapped SOL',
|
|
162
|
+
programName: TOKEN_REGISTRY_PROGRAM,
|
|
163
|
+
recordName: TOKEN_REGISTRY_RECORD,
|
|
164
|
+
symbol: 'wSOL',
|
|
165
|
+
tokenId: '2045969100091121326225168054634646230244820821909676777152465722877810201564field',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
contractAddress: 'hyp_warp_token_eth.aleo',
|
|
169
|
+
decimals: 18,
|
|
170
|
+
name: 'Wrapped ETH',
|
|
171
|
+
programName: TOKEN_REGISTRY_PROGRAM,
|
|
172
|
+
recordName: TOKEN_REGISTRY_RECORD,
|
|
173
|
+
symbol: 'wETH',
|
|
174
|
+
tokenId: '8189585964265444162798552221009403350643900573290534096996249214099143169251field',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
contractAddress: 'hyp_warp_token_wbtc.aleo',
|
|
178
|
+
decimals: 8,
|
|
179
|
+
name: 'Wrapped BTC',
|
|
180
|
+
programName: TOKEN_REGISTRY_PROGRAM,
|
|
181
|
+
recordName: TOKEN_REGISTRY_RECORD,
|
|
182
|
+
symbol: 'wBTC',
|
|
183
|
+
tokenId: '3491859903473482085250871387962132231204352466326026409883548131580582527809field',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
contractAddress: 'hyp_warp_token_usdt.aleo',
|
|
187
|
+
decimals: 6,
|
|
188
|
+
name: 'Tether USD',
|
|
189
|
+
programName: TOKEN_REGISTRY_PROGRAM,
|
|
190
|
+
recordName: TOKEN_REGISTRY_RECORD,
|
|
191
|
+
symbol: 'USDT',
|
|
192
|
+
tokenId: '7881654794448182580124231856035865816599796419758925654292946277940935117913field',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
contractAddress: 'hyp_warp_token_usdc.aleo',
|
|
196
|
+
decimals: 6,
|
|
197
|
+
name: 'USD Coin',
|
|
198
|
+
programName: TOKEN_REGISTRY_PROGRAM,
|
|
199
|
+
recordName: TOKEN_REGISTRY_RECORD,
|
|
200
|
+
symbol: 'USDC',
|
|
201
|
+
tokenId: '4697275201844475848710842677807162058146139844643350200269139278887318953049field',
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
/**
|
|
205
|
+
* Match a record to a shielded-token spec. Stablecoins match on
|
|
206
|
+
* (program, record); ARC-21 entries additionally require the spec's
|
|
207
|
+
* `tokenId` to appear inside `record_plaintext` (since every ARC-21 token
|
|
208
|
+
* shares `token_registry.aleo / Token`).
|
|
209
|
+
*/
|
|
210
|
+
const findTokenSpec = (record) => {
|
|
211
|
+
for (const spec of KNOWN_SHIELDED_TOKENS) {
|
|
212
|
+
if (record.program_name !== spec.programName)
|
|
213
|
+
continue;
|
|
214
|
+
if (record.record_name !== spec.recordName)
|
|
215
|
+
continue;
|
|
216
|
+
if (spec.tokenId) {
|
|
217
|
+
if (typeof record.record_plaintext !== 'string' ||
|
|
218
|
+
!record.record_plaintext.includes(`token_id: ${spec.tokenId}`)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return spec;
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Hook that returns the active wallet's shielded (private) Aleo token
|
|
228
|
+
* balances as a `TokenBalance[]` so the widget can render them through the
|
|
229
|
+
* same TokenBalanceList path it uses for unshielded balances.
|
|
230
|
+
*
|
|
231
|
+
* - Records come from the iframe via `connector.listOwnedRecords()` (the
|
|
232
|
+
* Provable RecordScanner; view key never leaves the iframe).
|
|
233
|
+
* - Aggregates `credits.aleo/credits` (sum `microcredits` → ALEO) plus any
|
|
234
|
+
* tier-3 stablecoin Token records (sum `amount` per program → USAD/USDCx).
|
|
235
|
+
* ARC-21 multi-token grouped-by-`token_id` is Phase 2B.
|
|
236
|
+
*
|
|
237
|
+
* Returns an empty list when:
|
|
238
|
+
* - The wallet isn't Aleo
|
|
239
|
+
* - The connector doesn't expose `listOwnedRecords` (e.g. external Aleo wallet)
|
|
240
|
+
* - The user owns no records that match a known program/record pair
|
|
241
|
+
*/
|
|
242
|
+
const useAleoShieldedBalances = () => {
|
|
243
|
+
const { primaryWallet, network } = useInternalDynamicContext();
|
|
244
|
+
const [tokenBalances, setTokenBalances] = useState([]);
|
|
245
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
246
|
+
const [error, setError] = useState();
|
|
247
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
248
|
+
const isAleo = (connector === null || connector === void 0 ? void 0 : connector.connectedChain) === ChainEnum.Aleo;
|
|
249
|
+
const supportsShielded = isAleo &&
|
|
250
|
+
typeof (connector === null || connector === void 0 ? void 0 : connector.listOwnedRecords) === 'function';
|
|
251
|
+
// Mirror the live connector into a ref so `fetchShielded` can read it
|
|
252
|
+
// without depending on the (often unstable) object reference. Some test
|
|
253
|
+
// setups mock context with a factory that returns a fresh `primaryWallet`
|
|
254
|
+
// every render — depending on that ref directly turned this into an
|
|
255
|
+
// infinite render loop.
|
|
256
|
+
const connectorRef = useRef(connector);
|
|
257
|
+
connectorRef.current = connector;
|
|
258
|
+
const connectorKey = connector === null || connector === void 0 ? void 0 : connector.key;
|
|
259
|
+
const networkKey = network !== undefined && network !== null ? String(network) : undefined;
|
|
260
|
+
const fetchShielded = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
|
+
var _a, _b, _c;
|
|
262
|
+
const liveConnector = connectorRef.current;
|
|
263
|
+
if (!supportsShielded || !liveConnector) {
|
|
264
|
+
setTokenBalances((prev) => (prev.length === 0 ? prev : []));
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
setIsLoading(true);
|
|
268
|
+
setError(undefined);
|
|
269
|
+
try {
|
|
270
|
+
const result = yield liveConnector.listOwnedRecords();
|
|
271
|
+
const records = (_a = result === null || result === void 0 ? void 0 : result.records) !== null && _a !== void 0 ? _a : [];
|
|
272
|
+
const networkIdNumeric = Number(networkKey);
|
|
273
|
+
const safeNetworkId = Number.isFinite(networkIdNumeric)
|
|
274
|
+
? networkIdNumeric
|
|
275
|
+
: undefined;
|
|
276
|
+
const balances = [];
|
|
277
|
+
// Tier 1: native credits — sum microcredits across credits.aleo records.
|
|
278
|
+
const creditsRecords = records.filter((r) => (r === null || r === void 0 ? void 0 : r.program_name) === 'credits.aleo' &&
|
|
279
|
+
(r === null || r === void 0 ? void 0 : r.record_name) === 'credits' &&
|
|
280
|
+
typeof (r === null || r === void 0 ? void 0 : r.microcredits) === 'string');
|
|
281
|
+
if (creditsRecords.length > 0) {
|
|
282
|
+
const totalMicrocredits = creditsRecords.reduce((sum, r) => sum + BigInt(r.microcredits), BigInt(0));
|
|
283
|
+
// BigInt → number for the TokenBalance shape. Aleo balances stay well
|
|
284
|
+
// below Number.MAX_SAFE_INTEGER for a single wallet (max u64 supply is
|
|
285
|
+
// 1.5B credits = 1.5e15 microcredits; Number can hold up to ~9e15).
|
|
286
|
+
const rawBalance = Number(totalMicrocredits);
|
|
287
|
+
balances.push({
|
|
288
|
+
address: '0x0',
|
|
289
|
+
balance: rawBalance / MICROCREDITS_PER_CREDIT,
|
|
290
|
+
decimals: 6,
|
|
291
|
+
isNative: true,
|
|
292
|
+
logoURI: ALEO_CREDITS_LOGO,
|
|
293
|
+
name: 'Aleo Credits',
|
|
294
|
+
networkId: safeNetworkId,
|
|
295
|
+
rawBalance,
|
|
296
|
+
symbol: 'ALEO',
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
// Tier 3 + ARC-21: Token records. Each record matches at most one
|
|
300
|
+
// spec (stablecoin programs disambiguate by program; ARC-21 records
|
|
301
|
+
// share `token_registry.aleo / Token` and disambiguate by tokenId
|
|
302
|
+
// inside the plaintext). Sum the `amount` field per spec.
|
|
303
|
+
const sumsByContract = new Map();
|
|
304
|
+
const specsByContract = new Map();
|
|
305
|
+
for (const r of records) {
|
|
306
|
+
const spec = findTokenSpec(r);
|
|
307
|
+
if (!spec || typeof r.amount !== 'string')
|
|
308
|
+
continue;
|
|
309
|
+
try {
|
|
310
|
+
const prev = (_b = sumsByContract.get(spec.contractAddress)) !== null && _b !== void 0 ? _b : BigInt(0);
|
|
311
|
+
sumsByContract.set(spec.contractAddress, prev + BigInt(r.amount));
|
|
312
|
+
specsByContract.set(spec.contractAddress, spec);
|
|
313
|
+
}
|
|
314
|
+
catch (_d) {
|
|
315
|
+
/* ignore — malformed amount string */
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
for (const [contractAddress, total] of sumsByContract.entries()) {
|
|
319
|
+
const spec = specsByContract.get(contractAddress);
|
|
320
|
+
if (!spec)
|
|
321
|
+
continue;
|
|
322
|
+
const rawBalance = Number(total);
|
|
323
|
+
balances.push({
|
|
324
|
+
address: spec.contractAddress,
|
|
325
|
+
balance: rawBalance / Math.pow(10, spec.decimals),
|
|
326
|
+
decimals: spec.decimals,
|
|
327
|
+
// Use redcoast's `DEFAULT_TOKEN_LOGO_URI` for stablecoins + ARC-21
|
|
328
|
+
// so they render the same dark "?" icon the Unshielded tab shows
|
|
329
|
+
// for these tokens (the multichain endpoint applies that fallback
|
|
330
|
+
// itself; we mirror it here for visual parity).
|
|
331
|
+
logoURI: (_c = spec.logoURI) !== null && _c !== void 0 ? _c : UNKNOWN_TOKEN_LOGO,
|
|
332
|
+
name: spec.name,
|
|
333
|
+
networkId: safeNetworkId,
|
|
334
|
+
rawBalance,
|
|
335
|
+
symbol: spec.symbol,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
setTokenBalances(balances);
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
342
|
+
setError(msg);
|
|
343
|
+
setTokenBalances((prev) => (prev.length === 0 ? prev : []));
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
setIsLoading(false);
|
|
347
|
+
}
|
|
348
|
+
}), [connectorKey, networkKey, supportsShielded]);
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
if (!supportsShielded) {
|
|
351
|
+
setTokenBalances((prev) => (prev.length === 0 ? prev : []));
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
fetchShielded().catch(() => {
|
|
355
|
+
// fetchShielded already records the error in component state;
|
|
356
|
+
// the .catch keeps the fire-and-forget shape lint-clean.
|
|
357
|
+
});
|
|
358
|
+
}, [supportsShielded, fetchShielded]);
|
|
359
|
+
return {
|
|
360
|
+
error,
|
|
361
|
+
isLoading,
|
|
362
|
+
refetch: fetchShielded,
|
|
363
|
+
supportsShielded,
|
|
364
|
+
tokenBalances,
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export { useAleoShieldedBalances };
|
|
@@ -113,7 +113,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
113
113
|
|
|
114
114
|
const useDeleteUserAccount = () => {
|
|
115
115
|
const environmentId = dynamicContextProps.useEnvironmentId();
|
|
116
|
-
const {
|
|
116
|
+
const { handleLogOutWithReason } = useInternalDynamicContext.useInternalDynamicContext();
|
|
117
117
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
118
118
|
const [error, setError] = React.useState(null);
|
|
119
119
|
const deleteUser = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -121,7 +121,7 @@ const useDeleteUserAccount = () => {
|
|
|
121
121
|
setIsLoading(true);
|
|
122
122
|
setError(null);
|
|
123
123
|
yield user.hardDeleteUser(environmentId);
|
|
124
|
-
yield
|
|
124
|
+
yield handleLogOutWithReason('user-deleted');
|
|
125
125
|
}
|
|
126
126
|
catch (err) {
|
|
127
127
|
setError(err);
|
|
@@ -109,7 +109,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
109
109
|
|
|
110
110
|
const useDeleteUserAccount = () => {
|
|
111
111
|
const environmentId = useEnvironmentId();
|
|
112
|
-
const {
|
|
112
|
+
const { handleLogOutWithReason } = useInternalDynamicContext();
|
|
113
113
|
const [isLoading, setIsLoading] = useState(false);
|
|
114
114
|
const [error, setError] = useState(null);
|
|
115
115
|
const deleteUser = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -117,7 +117,7 @@ const useDeleteUserAccount = () => {
|
|
|
117
117
|
setIsLoading(true);
|
|
118
118
|
setError(null);
|
|
119
119
|
yield hardDeleteUser(environmentId);
|
|
120
|
-
yield
|
|
120
|
+
yield handleLogOutWithReason('user-deleted');
|
|
121
121
|
}
|
|
122
122
|
catch (err) {
|
|
123
123
|
setError(err);
|
|
@@ -119,6 +119,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
119
119
|
|
|
120
120
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
121
121
|
/**
|
|
122
|
+
* @deprecated This hook is deprecated and will be removed in a future release. Use `useDynamicWaas` instead.
|
|
122
123
|
* @returns {
|
|
123
124
|
* createEmbeddedWallet, - creates Dynamic embedded wallet according to the settings
|
|
124
125
|
* createOrRestoreSession, - creates or restores session for the embedded wallet
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EmbeddedWalletChainEnum, EmbeddedWalletVersionEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { Wallet } from '../../../shared';
|
|
3
3
|
/**
|
|
4
|
+
* @deprecated This hook is deprecated and will be removed in a future release. Use `useDynamicWaas` instead.
|
|
4
5
|
* @returns {
|
|
5
6
|
* createEmbeddedWallet, - creates Dynamic embedded wallet according to the settings
|
|
6
7
|
* createOrRestoreSession, - creates or restores session for the embedded wallet
|
|
@@ -115,6 +115,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
115
115
|
|
|
116
116
|
// Hook exposed to customers and used internally to trigger embedded wallet creation
|
|
117
117
|
/**
|
|
118
|
+
* @deprecated This hook is deprecated and will be removed in a future release. Use `useDynamicWaas` instead.
|
|
118
119
|
* @returns {
|
|
119
120
|
* createEmbeddedWallet, - creates Dynamic embedded wallet according to the settings
|
|
120
121
|
* createOrRestoreSession, - creates or restores session for the embedded wallet
|
|
@@ -60,7 +60,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
60
60
|
// this can happen if the public key passed during initial registration
|
|
61
61
|
// does not match the root session public key that the backend expects
|
|
62
62
|
walletConnectorCore.logger.warn('Invalid embedded wallet session key. Re-authentication is required to create new session keys.');
|
|
63
|
-
dynamicEvents.dynamicEvents.emit('triggerLogout');
|
|
63
|
+
dynamicEvents.dynamicEvents.emit('triggerLogout', 'embedded-wallet-session-key-invalid');
|
|
64
64
|
}
|
|
65
65
|
walletConnectorCore.logger.error('Error registering session key', { error });
|
|
66
66
|
throw error;
|
|
@@ -56,7 +56,7 @@ const useEmbeddedWalletSessionKeys = ({ environmentId, projectSettings, }) => {
|
|
|
56
56
|
// this can happen if the public key passed during initial registration
|
|
57
57
|
// does not match the root session public key that the backend expects
|
|
58
58
|
logger.warn('Invalid embedded wallet session key. Re-authentication is required to create new session keys.');
|
|
59
|
-
dynamicEvents.emit('triggerLogout');
|
|
59
|
+
dynamicEvents.emit('triggerLogout', 'embedded-wallet-session-key-invalid');
|
|
60
60
|
}
|
|
61
61
|
logger.error('Error registering session key', { error });
|
|
62
62
|
throw error;
|
|
@@ -118,7 +118,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
118
118
|
|
|
119
119
|
const sleepToShowSuccessMessage = () => utils.sleep(1500);
|
|
120
120
|
const useUserAuth = ({ authMethod, }) => {
|
|
121
|
-
const {
|
|
121
|
+
const { handleLogOutWithReason, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
122
122
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
123
123
|
const { view, pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
|
|
124
124
|
const { setLoading } = LoadingContext.useLoadingContext();
|
|
@@ -130,9 +130,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
130
130
|
const isVerifyResponse = (response) => response.user;
|
|
131
131
|
const cancelAuth = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
132
132
|
logger.logger.debug('cancelAuth', { authMethod });
|
|
133
|
-
yield
|
|
133
|
+
yield handleLogOutWithReason('auth-cancelled');
|
|
134
134
|
clearStackAndPushInitialView();
|
|
135
|
-
}), [authMethod, clearStackAndPushInitialView,
|
|
135
|
+
}), [authMethod, clearStackAndPushInitialView, handleLogOutWithReason]);
|
|
136
136
|
const handleAuthError = React.useCallback((error, { options = {}, onError, }) => {
|
|
137
137
|
var _a, _b;
|
|
138
138
|
instrumentAuthLoginFailed.instrumentAuthLoginFailed(error, {
|
|
@@ -114,7 +114,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
114
114
|
|
|
115
115
|
const sleepToShowSuccessMessage = () => sleep(1500);
|
|
116
116
|
const useUserAuth = ({ authMethod, }) => {
|
|
117
|
-
const {
|
|
117
|
+
const { handleLogOutWithReason, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext();
|
|
118
118
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
119
119
|
const { view, pushView, clearStackAndPushInitialView } = useViewContext();
|
|
120
120
|
const { setLoading } = useLoadingContext();
|
|
@@ -126,9 +126,9 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
126
126
|
const isVerifyResponse = (response) => response.user;
|
|
127
127
|
const cancelAuth = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
128
|
logger.debug('cancelAuth', { authMethod });
|
|
129
|
-
yield
|
|
129
|
+
yield handleLogOutWithReason('auth-cancelled');
|
|
130
130
|
clearStackAndPushInitialView();
|
|
131
|
-
}), [authMethod, clearStackAndPushInitialView,
|
|
131
|
+
}), [authMethod, clearStackAndPushInitialView, handleLogOutWithReason]);
|
|
132
132
|
const handleAuthError = useCallback((error, { options = {}, onError, }) => {
|
|
133
133
|
var _a, _b;
|
|
134
134
|
instrumentAuthLoginFailed(error, {
|
|
@@ -17,7 +17,7 @@ const handleStoreAndEnvironmentMismatch = (_a) => _tslib.__awaiter(void 0, [_a],
|
|
|
17
17
|
yield logout('store and environment are out of sync', {
|
|
18
18
|
currentEnvId: environmentId,
|
|
19
19
|
storedEnvId: storeEnvId,
|
|
20
|
-
});
|
|
20
|
+
}, 'store-environment-mismatch');
|
|
21
21
|
dynamicContextProps.setEnvironmentId(environmentId);
|
|
22
22
|
});
|
|
23
23
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { SdkLogoutReason } from '../../../../context/DynamicContext/hooks/useHandleLogout';
|
|
1
2
|
export type HandleStoreAndEnvironmentMismatchParams = {
|
|
2
3
|
environmentId: string;
|
|
3
|
-
logout: (reason: string, params: any) => Promise<void>;
|
|
4
|
+
logout: (reason: string, params: any, logoutReason: SdkLogoutReason) => Promise<void>;
|
|
4
5
|
};
|
|
5
6
|
/**
|
|
6
7
|
* Detects envId mismtach with store.
|
|
@@ -13,7 +13,7 @@ const handleStoreAndEnvironmentMismatch = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
13
13
|
yield logout('store and environment are out of sync', {
|
|
14
14
|
currentEnvId: environmentId,
|
|
15
15
|
storedEnvId: storeEnvId,
|
|
16
|
-
});
|
|
16
|
+
}, 'store-environment-mismatch');
|
|
17
17
|
setEnvironmentId(environmentId);
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -63,7 +63,9 @@ const handleWalletInfoOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0,
|
|
|
63
63
|
connectedWallets,
|
|
64
64
|
primaryWalletId: primaryWalletId$1,
|
|
65
65
|
user,
|
|
66
|
-
}, isTokenExpired
|
|
66
|
+
}, isTokenExpired
|
|
67
|
+
? 'token-expired-validate-session'
|
|
68
|
+
: 'wallet-info-out-of-sync');
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
exports.handleWalletInfoOutOfSync = handleWalletInfoOutOfSync;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SdkLogoutReason } from '../../../../context/DynamicContext/hooks/useHandleLogout';
|
|
2
2
|
export type HandleWalletInfoOutOfSyncParams = {
|
|
3
|
-
logout: (reason: string, params: any, logoutReason
|
|
3
|
+
logout: (reason: string, params: any, logoutReason: SdkLogoutReason) => Promise<void>;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
6
|
* Detects mismatch between wallet info.
|
|
@@ -59,7 +59,9 @@ const handleWalletInfoOutOfSync = (_a) => __awaiter(void 0, [_a], void 0, functi
|
|
|
59
59
|
connectedWallets,
|
|
60
60
|
primaryWalletId,
|
|
61
61
|
user,
|
|
62
|
-
}, isTokenExpired
|
|
62
|
+
}, isTokenExpired
|
|
63
|
+
? 'token-expired-validate-session'
|
|
64
|
+
: 'wallet-info-out-of-sync');
|
|
63
65
|
});
|
|
64
66
|
|
|
65
67
|
export { handleWalletInfoOutOfSync };
|
|
@@ -35,7 +35,7 @@ var useProjectSettings = require('../../../client/extension/projectSettings/useP
|
|
|
35
35
|
var handleStoreAndEnvironmentMismatch = require('./handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs');
|
|
36
36
|
var handleWalletInfoOutOfSync = require('./handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs');
|
|
37
37
|
|
|
38
|
-
const useValidateSession = ({ environmentId,
|
|
38
|
+
const useValidateSession = ({ environmentId, handleLogOutWithReason, }) => {
|
|
39
39
|
const didRunRef = React.useRef(false);
|
|
40
40
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
41
41
|
const initStatus = useInitStatus.useClientInitStatus();
|
|
@@ -43,8 +43,8 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
44
|
(reason, params, logoutReason) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
45
|
logger.logger.info(`Logging out due to invalid session - Reason: ${reason}`, Object.assign({}, params));
|
|
46
|
-
return
|
|
47
|
-
}), [
|
|
46
|
+
return handleLogOutWithReason(logoutReason);
|
|
47
|
+
}), [handleLogOutWithReason]);
|
|
48
48
|
const validateSession = React.useCallback((projectSettings) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
49
|
const params = {
|
|
50
50
|
environmentId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SdkLogoutReason } from '../../../context/DynamicContext/hooks/useHandleLogout';
|
|
2
2
|
type Props = {
|
|
3
3
|
environmentId: string;
|
|
4
|
-
|
|
4
|
+
handleLogOutWithReason: (reason: SdkLogoutReason) => Promise<void>;
|
|
5
5
|
};
|
|
6
|
-
export declare const useValidateSession: ({ environmentId,
|
|
6
|
+
export declare const useValidateSession: ({ environmentId, handleLogOutWithReason, }: Props) => void;
|
|
7
7
|
export {};
|
|
@@ -31,7 +31,7 @@ import { useProjectSettings } from '../../../client/extension/projectSettings/us
|
|
|
31
31
|
import { handleStoreAndEnvironmentMismatch } from './handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js';
|
|
32
32
|
import { handleWalletInfoOutOfSync } from './handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js';
|
|
33
33
|
|
|
34
|
-
const useValidateSession = ({ environmentId,
|
|
34
|
+
const useValidateSession = ({ environmentId, handleLogOutWithReason, }) => {
|
|
35
35
|
const didRunRef = useRef(false);
|
|
36
36
|
const projectSettings = useProjectSettings();
|
|
37
37
|
const initStatus = useClientInitStatus();
|
|
@@ -39,8 +39,8 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
40
|
(reason, params, logoutReason) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
logger.info(`Logging out due to invalid session - Reason: ${reason}`, Object.assign({}, params));
|
|
42
|
-
return
|
|
43
|
-
}), [
|
|
42
|
+
return handleLogOutWithReason(logoutReason);
|
|
43
|
+
}), [handleLogOutWithReason]);
|
|
44
44
|
const validateSession = useCallback((projectSettings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
45
|
const params = {
|
|
46
46
|
environmentId,
|
|
@@ -34,7 +34,7 @@ require('@dynamic-labs/locale');
|
|
|
34
34
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
35
35
|
var authMode = require('../../../store/state/authMode/authMode.cjs');
|
|
36
36
|
|
|
37
|
-
const useWalletEventListeners = ({ disconnectWallet,
|
|
37
|
+
const useWalletEventListeners = ({ disconnectWallet, handleLogOutWithReason, multiWallet, multiWalletWidgetState, primaryWallet, secondaryWallets, selectedWalletConnector, selectedWalletWithAction, setSelectedWalletConnectorKey, setSelectedWalletWithAction, setMultiWalletWidgetState, user, refreshConnectedWallet, detectNewWalletsForLinking, }) => {
|
|
38
38
|
const handleAccountChangeWhenAwaitingAccountSwitch = React.useCallback((isPrimaryWallet, newAddress) => {
|
|
39
39
|
logger.logger.debug('handleAccountChangeWhenAwaitingAccountSwitch', {
|
|
40
40
|
isPrimaryWallet,
|
|
@@ -163,7 +163,7 @@ const useWalletEventListeners = ({ disconnectWallet, handleLogOut, multiWallet,
|
|
|
163
163
|
logger.logger.debug('primary wallet disconnect');
|
|
164
164
|
const authMode$1 = authMode.getAuthMode();
|
|
165
165
|
if (authMode$1 === 'connect-only') {
|
|
166
|
-
|
|
166
|
+
handleLogOutWithReason('primary-wallet-disconnected');
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
useWalletConnectorEvent.useWalletConnectorEvent(uniqueNonPrimaryWallets, 'disconnect', (affectedConnector) => {
|