@dynamic-labs/sdk-react-core 0.18.100-viem.3 → 0.18.100-viem.30
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 +233 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +10 -10
- package/src/index.cjs +1 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
- package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.cjs +6 -2
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.d.ts +2 -1
- package/src/lib/components/ModalHeaderBanner/ModalHeaderBanner.js +6 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +2 -2
- package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
- package/src/lib/components/OTPVerificationView/OTPVerificationView.js +2 -2
- package/src/lib/components/SignMessagePreview/SignMessagePreview.cjs +27 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.d.ts +6 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.js +23 -0
- package/src/lib/components/SignMessagePreview/SignMessagePreview.types.d.ts +8 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.cjs +44 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.d.ts +8 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/SignTypedDataPreview.js +40 -0
- package/src/lib/components/SignMessagePreview/components/SignTypedDataPreview/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/components/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/index.d.ts +1 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.cjs +17 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.d.ts +2 -0
- package/src/lib/components/SignMessagePreview/utils/isSignTypedData/isSignTypedData.js +13 -0
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -6
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +11 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +21 -7
- package/src/lib/context/DynamicContext/helpers.cjs +42 -3
- package/src/lib/context/DynamicContext/helpers.d.ts +7 -1
- package/src/lib/context/DynamicContext/helpers.js +38 -4
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.cjs +5 -2
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.d.ts +4 -2
- package/src/lib/context/DynamicContext/hooks/useSetShowAuthFlowWithInit/useSetShowAuthFlowWithInit.js +5 -2
- package/src/lib/context/DynamicContext/internalEvents/index.d.ts +2 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.cjs +14 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.d.ts +8 -0
- package/src/lib/context/DynamicContext/internalEvents/internalEvents.js +6 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +7 -1
- package/src/lib/context/DynamicContext/useDynamicContext.cjs +2 -1
- package/src/lib/context/DynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext.js +2 -1
- package/src/lib/context/ErrorContext/ErrorContext.cjs +1 -0
- package/src/lib/context/ErrorContext/ErrorContext.js +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +33 -7
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +33 -7
- package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
- package/src/lib/context/WalletContext/WalletContext.cjs +2 -16
- package/src/lib/context/WalletContext/WalletContext.js +2 -16
- package/src/lib/data/api.cjs +20 -12
- package/src/lib/data/api.d.ts +3 -2
- package/src/lib/data/api.js +20 -12
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +2 -1
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +2 -1
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +2 -1
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +2 -1
- package/src/lib/shared/types/index.d.ts +4 -0
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs +28 -2
- package/src/lib/shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js +28 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/localStorage.cjs +4 -0
- package/src/lib/utils/constants/localStorage.d.ts +2 -0
- package/src/lib/utils/constants/localStorage.js +3 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.cjs +6 -1
- package/src/lib/utils/functions/getDynamicLayoutData/getDynamicLayoutData.js +6 -1
- package/src/lib/utils/functions/getProviderByType/getProviderByType.cjs +7 -0
- package/src/lib/utils/functions/getProviderByType/getProviderByType.d.ts +2 -0
- package/src/lib/utils/functions/getProviderByType/getProviderByType.js +3 -0
- package/src/lib/utils/functions/getProviderByType/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/index.d.ts +1 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.cjs +48 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.d.ts +18 -0
- package/src/lib/utils/functions/sendTransactionWithAutoNonce/sendTransactionWithAutoNonce.js +43 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +10 -5
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +10 -5
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +6 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +6 -2
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +13 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.d.ts +1 -19
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +13 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +22 -32
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.d.ts +1 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +23 -33
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +7 -6
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +7 -6
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +10 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +10 -1
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +15 -1
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +15 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +2 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +94 -16
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +5 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +94 -16
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +5 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +5 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +13 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +13 -3
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +20 -26
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +3 -2
- package/src/lib/utils/hooks/useWallets/useWallets.js +21 -27
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +1 -1
- package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +1 -1
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +3 -2
- package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +3 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +3 -2
- package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +3 -2
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +19 -3
- package/src/lib/views/SendBalanceView/SendBalanceView.js +19 -3
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +4 -16
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +2 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +5 -17
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.cjs +1 -0
- package/src/lib/views/WalletGroupView/components/WalletGroupItem/WalletGroupItem.js +1 -0
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +1 -1
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +1 -1
- package/src/lib/views/WalletList/data.cjs +2 -14
- package/src/lib/views/WalletList/data.d.ts +4 -2
- package/src/lib/views/WalletList/data.js +2 -13
- package/src/lib/views/viewToComponentMap.cjs +1 -0
- package/src/lib/views/viewToComponentMap.js +1 -0
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/DynamicWidget.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +36 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +36 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicUserProfile/DynamicUserProfile.js +2 -2
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +7 -10
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +8 -11
- package/src/lib/widgets/DynamicWidget/hooks/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.cjs +17 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.d.ts +6 -0
- package/src/lib/widgets/DynamicWidget/hooks/useViewController/useViewController.js +13 -0
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.cjs +2 -3
- package/src/lib/widgets/DynamicWidget/views/SendBalanceWidgetView/SendBalanceWidgetView.js +2 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
|
|
3
|
+
const MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE = -32603;
|
|
4
|
+
/**
|
|
5
|
+
* Sends a transaction with an automatically determined nonce, if not provided.
|
|
6
|
+
*
|
|
7
|
+
* In Ethereum, each transaction sent from a particular address must have a unique nonce.
|
|
8
|
+
* If the transaction does not already have a nonce, this function helps to automatically set it.
|
|
9
|
+
* If a transaction with a particular nonce fails due to a "could not replace transaction" error,
|
|
10
|
+
* this function will automatically retry with the next nonce.
|
|
11
|
+
*
|
|
12
|
+
* @param connector - A Dynamic connector to interact with the Ethereum network.
|
|
13
|
+
* @param transaction - The transaction details.
|
|
14
|
+
* @param sendTransactionHandler - A handler function to send the transaction.
|
|
15
|
+
*
|
|
16
|
+
* @returns A promise that resolves to the transaction response.
|
|
17
|
+
*/
|
|
18
|
+
const sendTransactionWithAutoNonce = (connector, transaction, sendTransactionHandler) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
if (transaction.nonce !== undefined) {
|
|
20
|
+
return sendTransactionHandler(transaction);
|
|
21
|
+
}
|
|
22
|
+
const publicClient = yield connector.getRpcProvider();
|
|
23
|
+
const walletClient = yield connector.getSigner();
|
|
24
|
+
const [address] = yield walletClient.getAddresses();
|
|
25
|
+
const nonce = yield publicClient.getTransactionCount({
|
|
26
|
+
address,
|
|
27
|
+
});
|
|
28
|
+
const transactionWithNonce = Object.assign(Object.assign({}, transaction), { nonce });
|
|
29
|
+
try {
|
|
30
|
+
const response = yield sendTransactionHandler(transactionWithNonce);
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err.code ===
|
|
35
|
+
MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE) {
|
|
36
|
+
const transactionWithNextNonce = Object.assign(Object.assign({}, transaction), { nonce: nonce + 1 });
|
|
37
|
+
return sendTransactionHandler(transactionWithNextNonce);
|
|
38
|
+
}
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { MAGIC_COULD_NOT_REPLACE_TRANSACTION_ERROR_CODE, sendTransactionWithAutoNonce };
|
|
@@ -32,7 +32,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
32
32
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
33
33
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
34
34
|
const { captchaToken } = CaptchaContext.useCaptchaContext();
|
|
35
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
35
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain = [], } = useInternalDynamicContext.useInternalDynamicContext();
|
|
36
36
|
const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
|
|
37
37
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
38
38
|
consumeNonce,
|
|
@@ -75,7 +75,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
75
75
|
if (shouldUpdateWallets) {
|
|
76
76
|
handleWalletsToConnect();
|
|
77
77
|
}
|
|
78
|
-
if (!isFullyConnected ||
|
|
78
|
+
if (!isFullyConnected || walletsToConnectByChain.length) {
|
|
79
79
|
setCallback('connectSuccess');
|
|
80
80
|
}
|
|
81
81
|
return;
|
|
@@ -99,11 +99,16 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
catch (err) {
|
|
102
|
-
|
|
102
|
+
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) === 'user-cancelled';
|
|
103
|
+
if (!userCancelled)
|
|
104
|
+
logger.logger.debug(err);
|
|
103
105
|
setErrorMessage((_b = err === null || err === void 0 ? void 0 : err.code) === null || _b === void 0 ? void 0 : _b.toString());
|
|
104
106
|
goToInitialView();
|
|
105
|
-
// Since auth failed,
|
|
106
|
-
|
|
107
|
+
// Since auth failed, clear verification flag
|
|
108
|
+
// But if user cancelled, clearStatesOnBackClick will have already cleared it. So avoid
|
|
109
|
+
// clearing again since that would trigger a warning
|
|
110
|
+
if (!userCancelled)
|
|
111
|
+
setIsVerificationInProgress(false);
|
|
107
112
|
return;
|
|
108
113
|
}
|
|
109
114
|
});
|
|
@@ -28,7 +28,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
28
28
|
const { setView, goToInitialView } = useViewContext();
|
|
29
29
|
const { setErrorMessage } = useErrorContext();
|
|
30
30
|
const { captchaToken } = useCaptchaContext();
|
|
31
|
-
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain, } = useInternalDynamicContext();
|
|
31
|
+
const { authMode, connectWallet, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, setIsVerificationInProgress, isFullyConnected, walletsToConnectByChain = [], } = useInternalDynamicContext();
|
|
32
32
|
const { handleWalletsToConnect } = useHandleWalletsToConnect();
|
|
33
33
|
const verifyWallet = useVerifyWallet({
|
|
34
34
|
consumeNonce,
|
|
@@ -71,7 +71,7 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
71
71
|
if (shouldUpdateWallets) {
|
|
72
72
|
handleWalletsToConnect();
|
|
73
73
|
}
|
|
74
|
-
if (!isFullyConnected ||
|
|
74
|
+
if (!isFullyConnected || walletsToConnectByChain.length) {
|
|
75
75
|
setCallback('connectSuccess');
|
|
76
76
|
}
|
|
77
77
|
return;
|
|
@@ -95,11 +95,16 @@ const useConnectAndSign = ({ shouldUpdateWallets = true, shouldCallCallback = tr
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
catch (err) {
|
|
98
|
-
|
|
98
|
+
const userCancelled = (err === null || err === void 0 ? void 0 : err.code) === 'user-cancelled';
|
|
99
|
+
if (!userCancelled)
|
|
100
|
+
logger.debug(err);
|
|
99
101
|
setErrorMessage((_b = err === null || err === void 0 ? void 0 : err.code) === null || _b === void 0 ? void 0 : _b.toString());
|
|
100
102
|
goToInitialView();
|
|
101
|
-
// Since auth failed,
|
|
102
|
-
|
|
103
|
+
// Since auth failed, clear verification flag
|
|
104
|
+
// But if user cancelled, clearStatesOnBackClick will have already cleared it. So avoid
|
|
105
|
+
// clearing again since that would trigger a warning
|
|
106
|
+
if (!userCancelled)
|
|
107
|
+
setIsVerificationInProgress(false);
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
110
|
});
|
package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
7
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
7
8
|
var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
8
9
|
var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
|
|
@@ -10,7 +11,6 @@ var useVerifyWallet = require('../../useVerifyWallet/useVerifyWallet.cjs');
|
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
11
12
|
var logger = require('../../../../shared/logger.cjs');
|
|
12
13
|
require('@dynamic-labs/iconic');
|
|
13
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
14
14
|
require('react/jsx-runtime');
|
|
15
15
|
require('react');
|
|
16
16
|
require('@dynamic-labs/wallet-book');
|
|
@@ -23,7 +23,7 @@ require('../../../../shared/consts/index.cjs');
|
|
|
23
23
|
const useSignConnectOnlyUser = () => {
|
|
24
24
|
const { setView } = ViewContext.useViewContext();
|
|
25
25
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
26
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
26
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, walletUiUtils, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
27
27
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
28
28
|
consumeNonce,
|
|
29
29
|
displaySiweStatement,
|
|
@@ -33,6 +33,10 @@ const useSignConnectOnlyUser = () => {
|
|
|
33
33
|
});
|
|
34
34
|
return ({ walletConnector, fetchPublicAddressOpts = undefined, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
try {
|
|
36
|
+
if (walletConnectorCore.isEmbeddedConnector(walletConnector) &&
|
|
37
|
+
!walletConnectorCore.isBloctoConnector(walletConnector)) {
|
|
38
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
39
|
+
}
|
|
36
40
|
// Prepare states to show the pending signature view (without back button)
|
|
37
41
|
// We need this because in connect-only we don't want to show wallet-list
|
|
38
42
|
// We don't want to show the back button in the pending signature view
|
package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { isEmbeddedConnector, isBloctoConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
3
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
3
4
|
import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
|
|
4
5
|
import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
|
|
@@ -6,7 +7,6 @@ import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
|
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
7
8
|
import { logger } from '../../../../shared/logger.js';
|
|
8
9
|
import '@dynamic-labs/iconic';
|
|
9
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import 'react/jsx-runtime';
|
|
11
11
|
import 'react';
|
|
12
12
|
import '@dynamic-labs/wallet-book';
|
|
@@ -19,7 +19,7 @@ import '../../../../shared/consts/index.js';
|
|
|
19
19
|
const useSignConnectOnlyUser = () => {
|
|
20
20
|
const { setView } = useViewContext();
|
|
21
21
|
const { setErrorMessage } = useErrorContext();
|
|
22
|
-
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, } = useInternalDynamicContext();
|
|
22
|
+
const { connectWallet, consumeNonce, displaySiweStatement, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, setSelectedWalletConnector, walletUiUtils, } = useInternalDynamicContext();
|
|
23
23
|
const verifyWallet = useVerifyWallet({
|
|
24
24
|
consumeNonce,
|
|
25
25
|
displaySiweStatement,
|
|
@@ -29,6 +29,10 @@ const useSignConnectOnlyUser = () => {
|
|
|
29
29
|
});
|
|
30
30
|
return ({ walletConnector, fetchPublicAddressOpts = undefined, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
try {
|
|
32
|
+
if (isEmbeddedConnector(walletConnector) &&
|
|
33
|
+
!isBloctoConnector(walletConnector)) {
|
|
34
|
+
walletUiUtils.disabledConfirmationOnce();
|
|
35
|
+
}
|
|
32
36
|
// Prepare states to show the pending signature view (without back button)
|
|
33
37
|
// We need this because in connect-only we don't want to show wallet-list
|
|
34
38
|
// We don't want to show the back button in the pending signature view
|
|
@@ -10,8 +10,8 @@ var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
|
10
10
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
11
11
|
var errors = require('../../../constants/errors.cjs');
|
|
12
12
|
|
|
13
|
-
const useSyncPrimaryWallet = (
|
|
14
|
-
const { setShowAuthFlow, isAuthenticated } = useInternalDynamicContext.useInternalDynamicContext();
|
|
13
|
+
const useSyncPrimaryWallet = (canSync = true) => {
|
|
14
|
+
const { setShowAuthFlow, isAuthenticated, authMode, computeConnectedStateForWallets, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showLockedWalletView, showWidgetStatePopup, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
15
15
|
const { setView } = ViewContext.useViewContext();
|
|
16
16
|
const handlePrimaryWalletNotActive = React.useCallback((connectedAddress) => {
|
|
17
17
|
if (!primaryWallet)
|
|
@@ -93,8 +93,16 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
93
93
|
}
|
|
94
94
|
// user is logged in (has valid jwt), but no wallet is connected
|
|
95
95
|
if (isAuthenticated && e.code === errors.MISSING_ADDRESS_ERROR) {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
97
|
+
handleLogOut();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (showLockedWalletView) {
|
|
101
|
+
setShowAuthFlow(true);
|
|
102
|
+
setView('wallet-locked-view');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
handleLogOut();
|
|
98
106
|
}
|
|
99
107
|
});
|
|
100
108
|
}, [
|
|
@@ -111,6 +119,7 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
111
119
|
setShowAuthFlow,
|
|
112
120
|
authMode,
|
|
113
121
|
isAuthenticated,
|
|
122
|
+
showLockedWalletView,
|
|
114
123
|
]);
|
|
115
124
|
};
|
|
116
125
|
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { AuthModeType, MultiWalletWidgetState, Wallet } from '../../../../shared/types';
|
|
4
|
-
import { MultiWalletWidgetStateSetter } from '../useMultiWalletWidgetState';
|
|
5
|
-
export type UseSyncPrimaryWalletArgs = {
|
|
6
|
-
canSync?: boolean;
|
|
7
|
-
connectWallet: (walletConnector: WalletConnector, fetchPublicAddressOpts?: FetchPublicAddressOpts, shouldCallCallback?: boolean) => Promise<string | undefined>;
|
|
8
|
-
computeConnectedStateForWallets: () => Promise<void>;
|
|
9
|
-
handleLogOut: () => Promise<void>;
|
|
10
|
-
multiWalletWidgetState: MultiWalletWidgetState;
|
|
11
|
-
primaryWallet: Wallet | null;
|
|
12
|
-
secondaryWallets: Wallet[];
|
|
13
|
-
setMultiWalletWidgetState: MultiWalletWidgetStateSetter;
|
|
14
|
-
setPrimaryWallet: (walletId: string) => Promise<void>;
|
|
15
|
-
setShowWidgetStatePopup: Dispatch<SetStateAction<boolean>>;
|
|
16
|
-
showWidgetStatePopup: boolean;
|
|
17
|
-
authMode: AuthModeType;
|
|
18
|
-
};
|
|
19
|
-
export declare const useSyncPrimaryWallet: ({ connectWallet, computeConnectedStateForWallets, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showWidgetStatePopup, canSync, authMode, }: UseSyncPrimaryWalletArgs) => void;
|
|
1
|
+
export declare const useSyncPrimaryWallet: (canSync?: boolean) => void;
|
|
@@ -6,8 +6,8 @@ import { useViewContext } from '../../../../context/ViewContext/ViewContext.js';
|
|
|
6
6
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
7
7
|
import { MISSING_ADDRESS_ERROR } from '../../../constants/errors.js';
|
|
8
8
|
|
|
9
|
-
const useSyncPrimaryWallet = (
|
|
10
|
-
const { setShowAuthFlow, isAuthenticated } = useInternalDynamicContext();
|
|
9
|
+
const useSyncPrimaryWallet = (canSync = true) => {
|
|
10
|
+
const { setShowAuthFlow, isAuthenticated, authMode, computeConnectedStateForWallets, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, secondaryWallets, setMultiWalletWidgetState, setPrimaryWallet, setShowWidgetStatePopup, showLockedWalletView, showWidgetStatePopup, } = useInternalDynamicContext();
|
|
11
11
|
const { setView } = useViewContext();
|
|
12
12
|
const handlePrimaryWalletNotActive = useCallback((connectedAddress) => {
|
|
13
13
|
if (!primaryWallet)
|
|
@@ -89,8 +89,16 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
89
89
|
}
|
|
90
90
|
// user is logged in (has valid jwt), but no wallet is connected
|
|
91
91
|
if (isAuthenticated && e.code === MISSING_ADDRESS_ERROR) {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
93
|
+
handleLogOut();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (showLockedWalletView) {
|
|
97
|
+
setShowAuthFlow(true);
|
|
98
|
+
setView('wallet-locked-view');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
handleLogOut();
|
|
94
102
|
}
|
|
95
103
|
});
|
|
96
104
|
}, [
|
|
@@ -107,6 +115,7 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
107
115
|
setShowAuthFlow,
|
|
108
116
|
authMode,
|
|
109
117
|
isAuthenticated,
|
|
118
|
+
showLockedWalletView,
|
|
110
119
|
]);
|
|
111
120
|
};
|
|
112
121
|
|
|
@@ -47,12 +47,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
47
47
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
48
48
|
const walletChain = walletConnector.connectedChain;
|
|
49
49
|
const walletObject = {
|
|
50
|
-
address:
|
|
51
|
-
// We use `storedConnectedWalletInfo.lastWalletAddress` as a workaround to Braavos issue
|
|
52
|
-
// Braavos during initialization returns an empty string as a wallet address
|
|
53
|
-
walletAddress ||
|
|
54
|
-
storedConnectedWalletInfo.lastWalletAddress ||
|
|
55
|
-
'',
|
|
50
|
+
address: walletAddress || '',
|
|
56
51
|
chain: walletChain || '',
|
|
57
52
|
connected: true,
|
|
58
53
|
connector: walletConnector,
|
|
@@ -89,11 +84,10 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
89
84
|
}, [connectedWallets]);
|
|
90
85
|
const connectedWallet = connectedWallets[0] || null;
|
|
91
86
|
// Keeps connected wallet data inside localStorage
|
|
92
|
-
const applyConnectedWalletToStore = ({ walletId,
|
|
87
|
+
const applyConnectedWalletToStore = ({ walletId, walletConnectorKey, walletChain, provider, }) => {
|
|
93
88
|
const nextConnectedWalletsInfo = [...connectedWalletsInfo];
|
|
94
89
|
nextConnectedWalletsInfo.push({
|
|
95
90
|
id: walletId,
|
|
96
|
-
lastWalletAddress: walletAddress,
|
|
97
91
|
provider,
|
|
98
92
|
walletChain,
|
|
99
93
|
walletConnectorKey,
|
|
@@ -120,18 +114,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
120
114
|
return;
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
|
-
|
|
124
|
-
walletConnectorCore.logger.error('Could not refresh the wallet. The wallet address is not available');
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const currentWalletConnectoNetwork = yield walletConnector.getNetwork();
|
|
117
|
+
const currentWalletConnectorNetwork = yield walletConnector.getNetwork();
|
|
128
118
|
updateConnectedWalletById(walletId, {
|
|
129
119
|
address: currentWalletConnectorAddress,
|
|
130
|
-
network:
|
|
120
|
+
network: currentWalletConnectorNetwork,
|
|
131
121
|
});
|
|
132
122
|
});
|
|
133
|
-
const shouldSkipCreatingVisit =
|
|
134
|
-
connectedWallet, [authMode, connectedWallet, enableVisitTrackingOnConnectOnly]);
|
|
123
|
+
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
135
124
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
136
125
|
const publicWalletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
137
126
|
if (!publicWalletAddress) {
|
|
@@ -168,31 +157,32 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
168
157
|
walletConnectorKey: walletConnector.name,
|
|
169
158
|
walletId,
|
|
170
159
|
});
|
|
160
|
+
if (!shouldSkipCreatingVisit) {
|
|
161
|
+
// send information to backend to kick off background jobs
|
|
162
|
+
// so verify/sign on the next step could go by more quickly
|
|
163
|
+
// this is async work, but DO NOT AWAIT
|
|
164
|
+
api.createVisit({
|
|
165
|
+
authMode,
|
|
166
|
+
chain: walletChain || '',
|
|
167
|
+
environmentId,
|
|
168
|
+
publicWalletAddress,
|
|
169
|
+
walletName: walletConnector.name,
|
|
170
|
+
walletProvider: getWalletProvider.getWalletProvider(walletConnector),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
171
173
|
}
|
|
172
|
-
if (shouldSkipCreatingVisit) {
|
|
173
|
-
return Promise.resolve(publicWalletAddress);
|
|
174
|
-
}
|
|
175
|
-
// send information to backend to kick off background jobs
|
|
176
|
-
// so verify/sign on the next step could go by more quickly
|
|
177
|
-
// this is async work, but DO NOT AWAIT
|
|
178
|
-
api.createVisit({
|
|
179
|
-
authMode,
|
|
180
|
-
chain: walletChain || '',
|
|
181
|
-
environmentId,
|
|
182
|
-
publicWalletAddress,
|
|
183
|
-
walletName: walletConnector.name,
|
|
184
|
-
walletProvider: getWalletProvider.getWalletProvider(walletConnector),
|
|
185
|
-
});
|
|
186
174
|
return Promise.resolve(publicWalletAddress);
|
|
187
175
|
});
|
|
188
|
-
const unlinkConnectedWallet = (walletId) => {
|
|
176
|
+
const unlinkConnectedWallet = (walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
const connectedWalletToUnlink = connectedWallets.find((wallet) => wallet.id === walletId);
|
|
178
|
+
yield (connectedWalletToUnlink === null || connectedWalletToUnlink === void 0 ? void 0 : connectedWalletToUnlink.connector.endSession());
|
|
189
179
|
const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
|
|
190
180
|
if (walletId === primaryWalletId) {
|
|
191
181
|
clearPrimaryWalletId();
|
|
192
182
|
}
|
|
193
183
|
setConnectedWalletsInfo(filteredWallets);
|
|
194
184
|
onUnlink === null || onUnlink === void 0 ? void 0 : onUnlink(walletId, filteredWallets);
|
|
195
|
-
};
|
|
185
|
+
});
|
|
196
186
|
const getConnectedWalletById = React.useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
|
|
197
187
|
return {
|
|
198
188
|
connectWallet,
|
|
@@ -6,7 +6,6 @@ export type ConnectedWalletConnectorType = {
|
|
|
6
6
|
walletChain?: Chain;
|
|
7
7
|
walletConnectorKey: string;
|
|
8
8
|
provider: string;
|
|
9
|
-
lastWalletAddress?: string;
|
|
10
9
|
};
|
|
11
10
|
type Props = {
|
|
12
11
|
authMode: AuthModeType;
|
|
@@ -28,6 +27,6 @@ export declare const useConnectWallet: ({ authMode, clearPrimaryWalletId, enable
|
|
|
28
27
|
getConnectedWalletById: (walletId: string) => Wallet | undefined;
|
|
29
28
|
refreshConnectedWallet: (walletId: string, walletConnector: WalletConnector) => Promise<void>;
|
|
30
29
|
removeConnectedWalletsInfo: () => void;
|
|
31
|
-
unlinkConnectedWallet: (walletId: string) => void
|
|
30
|
+
unlinkConnectedWallet: (walletId: string) => Promise<void>;
|
|
32
31
|
};
|
|
33
32
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useCallback, useEffect
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getWalletConnectorByName, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../../shared/logger.js';
|
|
@@ -43,12 +43,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
43
43
|
const walletNetwork = yield walletConnector.getNetwork();
|
|
44
44
|
const walletChain = walletConnector.connectedChain;
|
|
45
45
|
const walletObject = {
|
|
46
|
-
address:
|
|
47
|
-
// We use `storedConnectedWalletInfo.lastWalletAddress` as a workaround to Braavos issue
|
|
48
|
-
// Braavos during initialization returns an empty string as a wallet address
|
|
49
|
-
walletAddress ||
|
|
50
|
-
storedConnectedWalletInfo.lastWalletAddress ||
|
|
51
|
-
'',
|
|
46
|
+
address: walletAddress || '',
|
|
52
47
|
chain: walletChain || '',
|
|
53
48
|
connected: true,
|
|
54
49
|
connector: walletConnector,
|
|
@@ -85,11 +80,10 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
85
80
|
}, [connectedWallets]);
|
|
86
81
|
const connectedWallet = connectedWallets[0] || null;
|
|
87
82
|
// Keeps connected wallet data inside localStorage
|
|
88
|
-
const applyConnectedWalletToStore = ({ walletId,
|
|
83
|
+
const applyConnectedWalletToStore = ({ walletId, walletConnectorKey, walletChain, provider, }) => {
|
|
89
84
|
const nextConnectedWalletsInfo = [...connectedWalletsInfo];
|
|
90
85
|
nextConnectedWalletsInfo.push({
|
|
91
86
|
id: walletId,
|
|
92
|
-
lastWalletAddress: walletAddress,
|
|
93
87
|
provider,
|
|
94
88
|
walletChain,
|
|
95
89
|
walletConnectorKey,
|
|
@@ -116,18 +110,13 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
116
110
|
return;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
|
-
|
|
120
|
-
logger.error('Could not refresh the wallet. The wallet address is not available');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const currentWalletConnectoNetwork = yield walletConnector.getNetwork();
|
|
113
|
+
const currentWalletConnectorNetwork = yield walletConnector.getNetwork();
|
|
124
114
|
updateConnectedWalletById(walletId, {
|
|
125
115
|
address: currentWalletConnectorAddress,
|
|
126
|
-
network:
|
|
116
|
+
network: currentWalletConnectorNetwork,
|
|
127
117
|
});
|
|
128
118
|
});
|
|
129
|
-
const shouldSkipCreatingVisit =
|
|
130
|
-
connectedWallet, [authMode, connectedWallet, enableVisitTrackingOnConnectOnly]);
|
|
119
|
+
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
131
120
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
121
|
const publicWalletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
133
122
|
if (!publicWalletAddress) {
|
|
@@ -164,31 +153,32 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
164
153
|
walletConnectorKey: walletConnector.name,
|
|
165
154
|
walletId,
|
|
166
155
|
});
|
|
156
|
+
if (!shouldSkipCreatingVisit) {
|
|
157
|
+
// send information to backend to kick off background jobs
|
|
158
|
+
// so verify/sign on the next step could go by more quickly
|
|
159
|
+
// this is async work, but DO NOT AWAIT
|
|
160
|
+
createVisit({
|
|
161
|
+
authMode,
|
|
162
|
+
chain: walletChain || '',
|
|
163
|
+
environmentId,
|
|
164
|
+
publicWalletAddress,
|
|
165
|
+
walletName: walletConnector.name,
|
|
166
|
+
walletProvider: getWalletProvider(walletConnector),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
167
169
|
}
|
|
168
|
-
if (shouldSkipCreatingVisit) {
|
|
169
|
-
return Promise.resolve(publicWalletAddress);
|
|
170
|
-
}
|
|
171
|
-
// send information to backend to kick off background jobs
|
|
172
|
-
// so verify/sign on the next step could go by more quickly
|
|
173
|
-
// this is async work, but DO NOT AWAIT
|
|
174
|
-
createVisit({
|
|
175
|
-
authMode,
|
|
176
|
-
chain: walletChain || '',
|
|
177
|
-
environmentId,
|
|
178
|
-
publicWalletAddress,
|
|
179
|
-
walletName: walletConnector.name,
|
|
180
|
-
walletProvider: getWalletProvider(walletConnector),
|
|
181
|
-
});
|
|
182
170
|
return Promise.resolve(publicWalletAddress);
|
|
183
171
|
});
|
|
184
|
-
const unlinkConnectedWallet = (walletId) => {
|
|
172
|
+
const unlinkConnectedWallet = (walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
const connectedWalletToUnlink = connectedWallets.find((wallet) => wallet.id === walletId);
|
|
174
|
+
yield (connectedWalletToUnlink === null || connectedWalletToUnlink === void 0 ? void 0 : connectedWalletToUnlink.connector.endSession());
|
|
185
175
|
const filteredWallets = connectedWalletsInfo.filter((wallet) => wallet.id !== walletId);
|
|
186
176
|
if (walletId === primaryWalletId) {
|
|
187
177
|
clearPrimaryWalletId();
|
|
188
178
|
}
|
|
189
179
|
setConnectedWalletsInfo(filteredWallets);
|
|
190
180
|
onUnlink === null || onUnlink === void 0 ? void 0 : onUnlink(walletId, filteredWallets);
|
|
191
|
-
};
|
|
181
|
+
});
|
|
192
182
|
const getConnectedWalletById = useCallback((walletId) => connectedWallets.find((wallet) => wallet.id === walletId), [connectedWallets]);
|
|
193
183
|
return {
|
|
194
184
|
connectWallet,
|
|
@@ -22,7 +22,7 @@ var isProgrammableNetworkSwitchSupported = require('../../functions/isProgrammab
|
|
|
22
22
|
|
|
23
23
|
const useConnectedWalletsNetworkValidation = () => {
|
|
24
24
|
const { connectedWallets, selectedWalletConnector, setSelectedWalletConnector, setShowAuthFlow, showAuthFlow, walletsToConnectByChain, isBridgeFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
25
|
-
const {
|
|
25
|
+
const { setView } = ViewContext.useViewContext();
|
|
26
26
|
React.useEffect(() => {
|
|
27
27
|
if (!isBridgeFlow) {
|
|
28
28
|
return;
|
|
@@ -53,16 +53,17 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
53
53
|
}
|
|
54
54
|
setView(networkNotSupportedView);
|
|
55
55
|
}
|
|
56
|
+
// we need it to remove 'showAuthFlow' property. we don't want to react to it,
|
|
57
|
+
// because closing modal on network switch causes it to re-open
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
59
|
}, [
|
|
57
|
-
isBridgeFlow,
|
|
58
60
|
connectedWallets,
|
|
59
|
-
|
|
61
|
+
isBridgeFlow,
|
|
60
62
|
selectedWalletConnector,
|
|
61
|
-
walletsToConnectByChain,
|
|
62
|
-
showAuthFlow,
|
|
63
|
-
setView,
|
|
64
63
|
setSelectedWalletConnector,
|
|
65
64
|
setShowAuthFlow,
|
|
65
|
+
setView,
|
|
66
|
+
walletsToConnectByChain,
|
|
66
67
|
]);
|
|
67
68
|
};
|
|
68
69
|
|
|
@@ -18,7 +18,7 @@ import { isProgrammableNetworkSwitchSupported } from '../../functions/isProgramm
|
|
|
18
18
|
|
|
19
19
|
const useConnectedWalletsNetworkValidation = () => {
|
|
20
20
|
const { connectedWallets, selectedWalletConnector, setSelectedWalletConnector, setShowAuthFlow, showAuthFlow, walletsToConnectByChain, isBridgeFlow, } = useInternalDynamicContext();
|
|
21
|
-
const {
|
|
21
|
+
const { setView } = useViewContext();
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
if (!isBridgeFlow) {
|
|
24
24
|
return;
|
|
@@ -49,16 +49,17 @@ const useConnectedWalletsNetworkValidation = () => {
|
|
|
49
49
|
}
|
|
50
50
|
setView(networkNotSupportedView);
|
|
51
51
|
}
|
|
52
|
+
// we need it to remove 'showAuthFlow' property. we don't want to react to it,
|
|
53
|
+
// because closing modal on network switch causes it to re-open
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
55
|
}, [
|
|
53
|
-
isBridgeFlow,
|
|
54
56
|
connectedWallets,
|
|
55
|
-
|
|
57
|
+
isBridgeFlow,
|
|
56
58
|
selectedWalletConnector,
|
|
57
|
-
walletsToConnectByChain,
|
|
58
|
-
showAuthFlow,
|
|
59
|
-
setView,
|
|
60
59
|
setSelectedWalletConnector,
|
|
61
60
|
setShowAuthFlow,
|
|
61
|
+
setView,
|
|
62
|
+
walletsToConnectByChain,
|
|
62
63
|
]);
|
|
63
64
|
};
|
|
64
65
|
|
|
@@ -44,7 +44,16 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
44
44
|
environmentId &&
|
|
45
45
|
retries < maxRetries) {
|
|
46
46
|
setLoading(true);
|
|
47
|
-
|
|
47
|
+
// we ReactNode components are not being serialized properly
|
|
48
|
+
// remove them for now and deal with them later
|
|
49
|
+
// context: https://linear.app/dynamic-labs/issue/GVTY-328/[starknet]-sdk-api-is-not-serializing-react-components
|
|
50
|
+
// future work: https://linear.app/dynamic-labs/issue/GVTY-330/bug-figure-out-why-react-components-are-not
|
|
51
|
+
const updatedDynamicProps = {
|
|
52
|
+
settings: Object.assign(Object.assign({}, dynamicContextProps.settings), { customPrivacyPolicy: Boolean(dynamicContextProps.settings.customPrivacyPolicy), customTermsOfServices: Boolean(dynamicContextProps.settings.customTermsOfServices), policiesConsentInnerComponent: Boolean(dynamicContextProps.settings.policiesConsentInnerComponent) }),
|
|
53
|
+
};
|
|
54
|
+
api.sendDynamicProps(environmentId, {
|
|
55
|
+
dynamicContextProps: updatedDynamicProps,
|
|
56
|
+
});
|
|
48
57
|
api.fetchProjectSettings(environmentId)
|
|
49
58
|
.then((response) => {
|
|
50
59
|
if (!response)
|
|
@@ -40,7 +40,16 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
40
40
|
environmentId &&
|
|
41
41
|
retries < maxRetries) {
|
|
42
42
|
setLoading(true);
|
|
43
|
-
|
|
43
|
+
// we ReactNode components are not being serialized properly
|
|
44
|
+
// remove them for now and deal with them later
|
|
45
|
+
// context: https://linear.app/dynamic-labs/issue/GVTY-328/[starknet]-sdk-api-is-not-serializing-react-components
|
|
46
|
+
// future work: https://linear.app/dynamic-labs/issue/GVTY-330/bug-figure-out-why-react-components-are-not
|
|
47
|
+
const updatedDynamicProps = {
|
|
48
|
+
settings: Object.assign(Object.assign({}, dynamicContextProps.settings), { customPrivacyPolicy: Boolean(dynamicContextProps.settings.customPrivacyPolicy), customTermsOfServices: Boolean(dynamicContextProps.settings.customTermsOfServices), policiesConsentInnerComponent: Boolean(dynamicContextProps.settings.policiesConsentInnerComponent) }),
|
|
49
|
+
};
|
|
50
|
+
sendDynamicProps(environmentId, {
|
|
51
|
+
dynamicContextProps: updatedDynamicProps,
|
|
52
|
+
});
|
|
44
53
|
fetchProjectSettings(environmentId)
|
|
45
54
|
.then((response) => {
|
|
46
55
|
if (!response)
|
|
@@ -6,7 +6,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useInte
|
|
|
6
6
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
7
7
|
|
|
8
8
|
const useHandleWalletsToConnect = () => {
|
|
9
|
-
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setIsFullyConnected, isFullyConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
9
|
+
const { walletsToConnectByChain, setWalletsToConnectByChain, setShowAuthFlow, setIsFullyConnected, selectedWalletConnector, isFullyConnected, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
10
10
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
11
11
|
const handleWalletsToConnect = () => {
|
|
12
12
|
if (!walletsToConnectByChain) {
|
|
@@ -19,6 +19,20 @@ const useHandleWalletsToConnect = () => {
|
|
|
19
19
|
setShowAuthFlow(false);
|
|
20
20
|
return goToInitialView();
|
|
21
21
|
}
|
|
22
|
+
if (!selectedWalletConnector || !selectedWalletConnector.connectedChain) {
|
|
23
|
+
setShowAuthFlow(false);
|
|
24
|
+
return goToInitialView();
|
|
25
|
+
}
|
|
26
|
+
// Assuming based on the logic above that we have at least one more chain/wallet to connect
|
|
27
|
+
// If the current connected wallet is already connected to the bridge,
|
|
28
|
+
// we can go directly to bridge-next-wallet-connection since we know there is a different chain to connect
|
|
29
|
+
const walletChainsToConnect = walletsToConnectByChain
|
|
30
|
+
.filter((wallet) => wallet.numberOfWallets > 0)
|
|
31
|
+
.map((wallet) => wallet.chain.toString());
|
|
32
|
+
if (!walletChainsToConnect.includes(selectedWalletConnector.connectedChain)) {
|
|
33
|
+
setView('bridge-next-wallet-connection');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
22
36
|
const [firstWallet, ...restOfTheWallets] = walletsToConnectByChain;
|
|
23
37
|
if (firstWallet.numberOfWallets > 1) {
|
|
24
38
|
const updatedWallets = [
|