@dynamic-labs/sdk-react-core 1.0.3 → 1.0.4
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 +10 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +16 -9
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +16 -9
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -4
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +65 -21
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +66 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.0.4](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.3...v1.0.4) (2024-01-04)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* edge case with unlinking wallet ([#4285](https://github.com/dynamic-labs/DynamicAuth/issues/4285)) ([#4293](https://github.com/dynamic-labs/DynamicAuth/issues/4293)) ([85eb4ea](https://github.com/dynamic-labs/DynamicAuth/commit/85eb4ea0fa4521d37ee3901dbb1fa6d88a8cf8f7))
|
|
8
|
+
* phantom solana not connecting on mobile ([#4287](https://github.com/dynamic-labs/DynamicAuth/issues/4287)) ([0d85e24](https://github.com/dynamic-labs/DynamicAuth/commit/0d85e2429f2dc0a92c293cf57dc0e241c4b948be))
|
|
9
|
+
* prevent error message when mobile wallet app is open ([#4301](https://github.com/dynamic-labs/DynamicAuth/issues/4301)) ([#4303](https://github.com/dynamic-labs/DynamicAuth/issues/4303)) ([0ba145e](https://github.com/dynamic-labs/DynamicAuth/commit/0ba145e6d1145fecc3e7bc2e60d127106be9aa54))
|
|
10
|
+
* **useFetchBalance:** ensure the latest wallet balance is fetched ([#4288](https://github.com/dynamic-labs/DynamicAuth/issues/4288)) ([#4294](https://github.com/dynamic-labs/DynamicAuth/issues/4294)) ([3fa0d60](https://github.com/dynamic-labs/DynamicAuth/commit/3fa0d60552082dffd032317368d20b87cdab9c6d))
|
|
11
|
+
|
|
2
12
|
### [1.0.3](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.2...v1.0.3) (2023-12-28)
|
|
3
13
|
|
|
4
14
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"react-focus-lock": "2.9.2",
|
|
18
18
|
"react-i18next": "^13.2.0",
|
|
19
19
|
"yup": "0.32.11",
|
|
20
|
-
"@dynamic-labs/ethereum": "1.0.
|
|
21
|
-
"@dynamic-labs/logger": "1.0.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "1.0.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "1.0.
|
|
24
|
-
"@dynamic-labs/types": "1.0.
|
|
25
|
-
"@dynamic-labs/utils": "1.0.
|
|
26
|
-
"@dynamic-labs/viem-utils": "1.0.
|
|
27
|
-
"@dynamic-labs/wallet-book": "1.0.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "1.0.
|
|
20
|
+
"@dynamic-labs/ethereum": "1.0.4",
|
|
21
|
+
"@dynamic-labs/logger": "1.0.4",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "1.0.4",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "1.0.4",
|
|
24
|
+
"@dynamic-labs/types": "1.0.4",
|
|
25
|
+
"@dynamic-labs/utils": "1.0.4",
|
|
26
|
+
"@dynamic-labs/viem-utils": "1.0.4",
|
|
27
|
+
"@dynamic-labs/wallet-book": "1.0.4",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "1.0.4",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
6
7
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
7
8
|
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
8
9
|
var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
@@ -20,7 +21,6 @@ var localStorage$1 = require('../../../constants/localStorage.cjs');
|
|
|
20
21
|
require('../../../constants/colors.cjs');
|
|
21
22
|
var localStorage = require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
22
23
|
require('viem');
|
|
23
|
-
require('@dynamic-labs/utils');
|
|
24
24
|
require('../../../../shared/consts/index.cjs');
|
|
25
25
|
var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
26
26
|
var useHandleWalletsToConnect = require('../../useHandleWalletsToConnect/useHandleWalletsToConnect.cjs');
|
|
@@ -38,6 +38,19 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
38
38
|
projectSettings,
|
|
39
39
|
setIsSingleWalletAccount,
|
|
40
40
|
});
|
|
41
|
+
const onErrorHandler = (err) => {
|
|
42
|
+
logger.logger.debug(err);
|
|
43
|
+
goToInitialView();
|
|
44
|
+
setIsVerificationInProgress(false);
|
|
45
|
+
/**
|
|
46
|
+
* On mobile we don't want to show error message because the user
|
|
47
|
+
* is redirected to the wallet mobile app
|
|
48
|
+
*/
|
|
49
|
+
const isMissingPublicAddressErrorExpected = err instanceof utils.MissingPublicAddressError && utils.isMobile();
|
|
50
|
+
if (!isMissingPublicAddressErrorExpected) {
|
|
51
|
+
setErrorMessage(err.toString());
|
|
52
|
+
}
|
|
53
|
+
};
|
|
41
54
|
// This method is similar to useConnectAndSign, but it skips signing for now
|
|
42
55
|
// It's used when we want to connect and sign in two separate steps
|
|
43
56
|
// For example on mobile when we want to sign on button click
|
|
@@ -71,10 +84,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
71
84
|
setView('pending-signature');
|
|
72
85
|
}
|
|
73
86
|
catch (err) {
|
|
74
|
-
|
|
75
|
-
setErrorMessage(err.toString());
|
|
76
|
-
goToInitialView();
|
|
77
|
-
setIsVerificationInProgress(false);
|
|
87
|
+
onErrorHandler(err);
|
|
78
88
|
return;
|
|
79
89
|
}
|
|
80
90
|
});
|
|
@@ -95,10 +105,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
95
105
|
});
|
|
96
106
|
}
|
|
97
107
|
catch (err) {
|
|
98
|
-
|
|
99
|
-
setErrorMessage(err.toString());
|
|
100
|
-
goToInitialView();
|
|
101
|
-
setIsVerificationInProgress(false);
|
|
108
|
+
onErrorHandler(err);
|
|
102
109
|
return;
|
|
103
110
|
}
|
|
104
111
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { MissingPublicAddressError, isMobile } from '@dynamic-labs/utils';
|
|
2
3
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
3
4
|
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
4
5
|
import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
|
|
@@ -16,7 +17,6 @@ import { LAST_USED_WALLET } from '../../../constants/localStorage.js';
|
|
|
16
17
|
import '../../../constants/colors.js';
|
|
17
18
|
import { LocalStorage } from '../../../../shared/utils/classes/storage/localStorage.js';
|
|
18
19
|
import 'viem';
|
|
19
|
-
import '@dynamic-labs/utils';
|
|
20
20
|
import '../../../../shared/consts/index.js';
|
|
21
21
|
import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
22
22
|
import { useHandleWalletsToConnect } from '../../useHandleWalletsToConnect/useHandleWalletsToConnect.js';
|
|
@@ -34,6 +34,19 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
34
34
|
projectSettings,
|
|
35
35
|
setIsSingleWalletAccount,
|
|
36
36
|
});
|
|
37
|
+
const onErrorHandler = (err) => {
|
|
38
|
+
logger.debug(err);
|
|
39
|
+
goToInitialView();
|
|
40
|
+
setIsVerificationInProgress(false);
|
|
41
|
+
/**
|
|
42
|
+
* On mobile we don't want to show error message because the user
|
|
43
|
+
* is redirected to the wallet mobile app
|
|
44
|
+
*/
|
|
45
|
+
const isMissingPublicAddressErrorExpected = err instanceof MissingPublicAddressError && isMobile();
|
|
46
|
+
if (!isMissingPublicAddressErrorExpected) {
|
|
47
|
+
setErrorMessage(err.toString());
|
|
48
|
+
}
|
|
49
|
+
};
|
|
37
50
|
// This method is similar to useConnectAndSign, but it skips signing for now
|
|
38
51
|
// It's used when we want to connect and sign in two separate steps
|
|
39
52
|
// For example on mobile when we want to sign on button click
|
|
@@ -67,10 +80,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
67
80
|
setView('pending-signature');
|
|
68
81
|
}
|
|
69
82
|
catch (err) {
|
|
70
|
-
|
|
71
|
-
setErrorMessage(err.toString());
|
|
72
|
-
goToInitialView();
|
|
73
|
-
setIsVerificationInProgress(false);
|
|
83
|
+
onErrorHandler(err);
|
|
74
84
|
return;
|
|
75
85
|
}
|
|
76
86
|
});
|
|
@@ -91,10 +101,7 @@ const useConnectAndSignSplitSteps = () => {
|
|
|
91
101
|
});
|
|
92
102
|
}
|
|
93
103
|
catch (err) {
|
|
94
|
-
|
|
95
|
-
setErrorMessage(err.toString());
|
|
96
|
-
goToInitialView();
|
|
97
|
-
setIsVerificationInProgress(false);
|
|
104
|
+
onErrorHandler(err);
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
9
|
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
9
10
|
var api = require('../../../data/api.cjs');
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
@@ -18,7 +19,6 @@ require('../../constants/colors.cjs');
|
|
|
18
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
20
|
require('viem');
|
|
20
21
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
21
|
-
require('@dynamic-labs/utils');
|
|
22
22
|
require('../../../shared/consts/index.cjs');
|
|
23
23
|
require('@dynamic-labs/multi-wallet');
|
|
24
24
|
var shouldManuallyReconnectOnRefresh = require('../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
@@ -166,9 +166,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
166
166
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
167
167
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
168
168
|
if (!walletAddress) {
|
|
169
|
-
|
|
170
|
-
error.code = 'missing-public-address';
|
|
171
|
-
throw error;
|
|
169
|
+
throw new utils.MissingPublicAddressError();
|
|
172
170
|
}
|
|
173
171
|
if (onBeforeConnectSuccessConfirmation && shouldCallCallback) {
|
|
174
172
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { MissingPublicAddressError } from '@dynamic-labs/utils';
|
|
4
5
|
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
5
6
|
import { createVisit } from '../../../data/api.js';
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
@@ -14,7 +15,6 @@ import '../../constants/colors.js';
|
|
|
14
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
16
|
import 'viem';
|
|
16
17
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
17
|
-
import '@dynamic-labs/utils';
|
|
18
18
|
import '../../../shared/consts/index.js';
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
20
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
@@ -162,9 +162,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
162
162
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
163
163
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
164
164
|
if (!walletAddress) {
|
|
165
|
-
|
|
166
|
-
error.code = 'missing-public-address';
|
|
167
|
-
throw error;
|
|
165
|
+
throw new MissingPublicAddressError();
|
|
168
166
|
}
|
|
169
167
|
if (onBeforeConnectSuccessConfirmation && shouldCallCallback) {
|
|
170
168
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -80,7 +80,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
80
80
|
if (newSelectedCredentialWallet) {
|
|
81
81
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
82
82
|
if (verifyOnly ||
|
|
83
|
-
|
|
83
|
+
!primaryWallet ||
|
|
84
84
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
85
85
|
newSelectedCredentialWallet.walletName ===
|
|
86
86
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|
|
@@ -34,7 +34,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
34
34
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
35
35
|
const { setView, goToInitialView } = useViewContext();
|
|
36
36
|
const { setErrorMessage, setError } = useErrorContext();
|
|
37
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext();
|
|
37
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext();
|
|
38
38
|
// If the user is not already logged it means that we only need to verify
|
|
39
39
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
40
40
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -76,7 +76,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
76
76
|
if (newSelectedCredentialWallet) {
|
|
77
77
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
78
78
|
if (verifyOnly ||
|
|
79
|
-
|
|
79
|
+
!primaryWallet ||
|
|
80
80
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
81
81
|
newSelectedCredentialWallet.walletName ===
|
|
82
82
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|
|
@@ -4,42 +4,86 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
|
+
require('@dynamic-labs/utils');
|
|
8
|
+
require('../../../../context/DynamicContext/DynamicContext.cjs');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
11
|
+
require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
12
|
+
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
7
13
|
require('@dynamic-labs/sdk-api');
|
|
8
14
|
require('../../../../shared/logger.cjs');
|
|
9
15
|
require('@dynamic-labs/iconic');
|
|
10
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
11
16
|
require('react/jsx-runtime');
|
|
12
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
13
17
|
require('@dynamic-labs/wallet-book');
|
|
14
18
|
require('../../../../utils/constants/colors.cjs');
|
|
15
19
|
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
16
20
|
require('viem');
|
|
17
|
-
require('@dynamic-labs/utils');
|
|
18
21
|
require('../../../../shared/consts/index.cjs');
|
|
19
22
|
require('@dynamic-labs/multi-wallet');
|
|
20
23
|
var isWalletConnected = require('../../../../utils/functions/isWalletConnected/isWalletConnected.cjs');
|
|
24
|
+
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
25
|
+
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
26
|
+
require('../../../../config/ApiEndpoint.cjs');
|
|
27
|
+
require('../../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
28
|
+
require('react-dom');
|
|
29
|
+
require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
30
|
+
var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
|
|
31
|
+
require('@dynamic-labs/types');
|
|
32
|
+
require('yup');
|
|
33
|
+
require('react-i18next');
|
|
34
|
+
require('../../../../context/MockContext/MockContext.cjs');
|
|
35
|
+
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
36
|
+
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
37
|
+
var useWalletConnectorEvent = require('../../../../utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.cjs');
|
|
38
|
+
require('@dynamic-labs/rpc-providers');
|
|
39
|
+
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
40
|
+
require('../../../../components/Alert/Alert.cjs');
|
|
41
|
+
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
42
|
+
require('../../../../components/IconButton/IconButton.cjs');
|
|
43
|
+
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
44
|
+
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
45
|
+
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
46
|
+
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
47
|
+
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
48
|
+
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
49
|
+
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
50
|
+
require('react-focus-lock');
|
|
51
|
+
require('formik');
|
|
52
|
+
require('i18next');
|
|
53
|
+
require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
54
|
+
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
55
|
+
require('../../../../context/QrCodeContext/QrCodeContext.cjs');
|
|
56
|
+
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
57
|
+
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
58
|
+
require('qrcode');
|
|
59
|
+
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
60
|
+
require('../../context/DynamicWidgetContext.cjs');
|
|
61
|
+
require('../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
62
|
+
require('@dynamic-labs/viem-utils');
|
|
63
|
+
require('../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
21
64
|
|
|
22
65
|
const useFetchBalance = ({ connector, chain, address, network, }) => {
|
|
23
66
|
const [balance, setBalance] = React.useState('0.0');
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
chain,
|
|
33
|
-
connector,
|
|
34
|
-
});
|
|
35
|
-
/* istanbul ignore else */
|
|
36
|
-
if (isConnected) {
|
|
37
|
-
const value = yield connector.getBalance();
|
|
38
|
-
setBalance(value);
|
|
39
|
-
}
|
|
67
|
+
const isFetchBalanceDisabled = !chain || !address || (connector.supportsNetworkSwitching() && !network);
|
|
68
|
+
const fetchBalance = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
if (isFetchBalanceDisabled)
|
|
70
|
+
return;
|
|
71
|
+
const isConnected = yield isWalletConnected.isWalletConnected({
|
|
72
|
+
address,
|
|
73
|
+
chain,
|
|
74
|
+
connector,
|
|
40
75
|
});
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
/* istanbul ignore else */
|
|
77
|
+
if (isConnected) {
|
|
78
|
+
const value = yield connector.getBalance();
|
|
79
|
+
setBalance(value);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
usePromise.usePromise(fetchBalance, {
|
|
83
|
+
deps: [address, network === null || network === void 0 ? void 0 : network.toString(), chain],
|
|
84
|
+
enabled: !isFetchBalanceDisabled,
|
|
85
|
+
});
|
|
86
|
+
useWalletConnectorEvent.useWalletConnectorEvent(connector, 'accountChange', fetchBalance);
|
|
43
87
|
return [balance];
|
|
44
88
|
};
|
|
45
89
|
|
|
@@ -1,41 +1,85 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import '@dynamic-labs/utils';
|
|
4
|
+
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import '../../../../context/CaptchaContext/CaptchaContext.js';
|
|
7
|
+
import '../../../../context/ErrorContext/ErrorContext.js';
|
|
8
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
3
9
|
import '@dynamic-labs/sdk-api';
|
|
4
10
|
import '../../../../shared/logger.js';
|
|
5
11
|
import '@dynamic-labs/iconic';
|
|
6
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
7
12
|
import 'react/jsx-runtime';
|
|
8
|
-
import '../../../../context/ViewContext/ViewContext.js';
|
|
9
13
|
import '@dynamic-labs/wallet-book';
|
|
10
14
|
import '../../../../utils/constants/colors.js';
|
|
11
15
|
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
12
16
|
import 'viem';
|
|
13
|
-
import '@dynamic-labs/utils';
|
|
14
17
|
import '../../../../shared/consts/index.js';
|
|
15
18
|
import '@dynamic-labs/multi-wallet';
|
|
16
19
|
import { isWalletConnected } from '../../../../utils/functions/isWalletConnected/isWalletConnected.js';
|
|
20
|
+
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
21
|
+
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
22
|
+
import '../../../../config/ApiEndpoint.js';
|
|
23
|
+
import '../../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
24
|
+
import 'react-dom';
|
|
25
|
+
import '../../../../context/ThemeContext/ThemeContext.js';
|
|
26
|
+
import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
|
|
27
|
+
import '@dynamic-labs/types';
|
|
28
|
+
import 'yup';
|
|
29
|
+
import 'react-i18next';
|
|
30
|
+
import '../../../../context/MockContext/MockContext.js';
|
|
31
|
+
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
32
|
+
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
33
|
+
import { useWalletConnectorEvent } from '../../../../utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.js';
|
|
34
|
+
import '@dynamic-labs/rpc-providers';
|
|
35
|
+
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
36
|
+
import '../../../../components/Alert/Alert.js';
|
|
37
|
+
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
38
|
+
import '../../../../components/IconButton/IconButton.js';
|
|
39
|
+
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
40
|
+
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
41
|
+
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
42
|
+
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
43
|
+
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
44
|
+
import '../../../../components/Popper/Popper/Popper.js';
|
|
45
|
+
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
46
|
+
import 'react-focus-lock';
|
|
47
|
+
import 'formik';
|
|
48
|
+
import 'i18next';
|
|
49
|
+
import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
50
|
+
import '../../../../context/FooterAnimationContext/index.js';
|
|
51
|
+
import '../../../../context/QrCodeContext/QrCodeContext.js';
|
|
52
|
+
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
53
|
+
import '../../components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
54
|
+
import 'qrcode';
|
|
55
|
+
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
56
|
+
import '../../context/DynamicWidgetContext.js';
|
|
57
|
+
import '../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
58
|
+
import '@dynamic-labs/viem-utils';
|
|
59
|
+
import '../../views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
17
60
|
|
|
18
61
|
const useFetchBalance = ({ connector, chain, address, network, }) => {
|
|
19
62
|
const [balance, setBalance] = useState('0.0');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
chain,
|
|
29
|
-
connector,
|
|
30
|
-
});
|
|
31
|
-
/* istanbul ignore else */
|
|
32
|
-
if (isConnected) {
|
|
33
|
-
const value = yield connector.getBalance();
|
|
34
|
-
setBalance(value);
|
|
35
|
-
}
|
|
63
|
+
const isFetchBalanceDisabled = !chain || !address || (connector.supportsNetworkSwitching() && !network);
|
|
64
|
+
const fetchBalance = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
if (isFetchBalanceDisabled)
|
|
66
|
+
return;
|
|
67
|
+
const isConnected = yield isWalletConnected({
|
|
68
|
+
address,
|
|
69
|
+
chain,
|
|
70
|
+
connector,
|
|
36
71
|
});
|
|
37
|
-
|
|
38
|
-
|
|
72
|
+
/* istanbul ignore else */
|
|
73
|
+
if (isConnected) {
|
|
74
|
+
const value = yield connector.getBalance();
|
|
75
|
+
setBalance(value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
usePromise(fetchBalance, {
|
|
79
|
+
deps: [address, network === null || network === void 0 ? void 0 : network.toString(), chain],
|
|
80
|
+
enabled: !isFetchBalanceDisabled,
|
|
81
|
+
});
|
|
82
|
+
useWalletConnectorEvent(connector, 'accountChange', fetchBalance);
|
|
39
83
|
return [balance];
|
|
40
84
|
};
|
|
41
85
|
|