@dynamic-labs/sdk-react-core 0.18.100-viem.3 → 0.18.100-viem.31
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 +240 -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
|
@@ -12,15 +12,18 @@ var React = require('react');
|
|
|
12
12
|
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
13
13
|
* to immediately trigger the deep link on mobile
|
|
14
14
|
*/
|
|
15
|
-
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, }) => {
|
|
15
|
+
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, user, isMultiWalletEnabled, }) => {
|
|
16
16
|
const setShowAuthFlowWithInit = React.useCallback((value) => {
|
|
17
17
|
var _a;
|
|
18
18
|
if (value) {
|
|
19
|
+
// if the uer is already signed in but multiwallet is not enabled, do not change state
|
|
20
|
+
if (user && !isMultiWalletEnabled)
|
|
21
|
+
return;
|
|
19
22
|
(_a = wallets
|
|
20
23
|
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
21
24
|
}
|
|
22
25
|
setShowAuthFlow(value);
|
|
23
|
-
}, [setShowAuthFlow, wallets]);
|
|
26
|
+
}, [setShowAuthFlow, wallets, user, isMultiWalletEnabled]);
|
|
24
27
|
return setShowAuthFlowWithInit;
|
|
25
28
|
};
|
|
26
29
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { WalletOption } from '../../../../shared';
|
|
2
|
+
import { UserProfile, WalletOption } from '../../../../shared';
|
|
3
3
|
/**
|
|
4
4
|
* this hook wraps `setShowAuthFlow`. WalletConnect requires initialization
|
|
5
5
|
* before we can connect a wallet. The goal here is that when a user clicks
|
|
@@ -8,7 +8,9 @@ import { WalletOption } from '../../../../shared';
|
|
|
8
8
|
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
9
9
|
* to immediately trigger the deep link on mobile
|
|
10
10
|
*/
|
|
11
|
-
export declare const useSetShowAuthFlowWithInit: ({ setShowAuthFlow, wallets, }: {
|
|
11
|
+
export declare const useSetShowAuthFlowWithInit: ({ setShowAuthFlow, wallets, user, isMultiWalletEnabled, }: {
|
|
12
12
|
setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
13
13
|
wallets: WalletOption[];
|
|
14
|
+
user?: UserProfile | undefined;
|
|
15
|
+
isMultiWalletEnabled?: boolean | undefined;
|
|
14
16
|
}) => Dispatch<SetStateAction<boolean>>;
|
|
@@ -8,15 +8,18 @@ import { useCallback } from 'react';
|
|
|
8
8
|
* "Connect" button in the WalletConnect modal, there is a uri ready to go
|
|
9
9
|
* to immediately trigger the deep link on mobile
|
|
10
10
|
*/
|
|
11
|
-
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, }) => {
|
|
11
|
+
const useSetShowAuthFlowWithInit = ({ setShowAuthFlow, wallets, user, isMultiWalletEnabled, }) => {
|
|
12
12
|
const setShowAuthFlowWithInit = useCallback((value) => {
|
|
13
13
|
var _a;
|
|
14
14
|
if (value) {
|
|
15
|
+
// if the uer is already signed in but multiwallet is not enabled, do not change state
|
|
16
|
+
if (user && !isMultiWalletEnabled)
|
|
17
|
+
return;
|
|
15
18
|
(_a = wallets
|
|
16
19
|
.find((wallet) => wallet.walletConnector.key === 'walletconnect')) === null || _a === void 0 ? void 0 : _a.walletConnector.init();
|
|
17
20
|
}
|
|
18
21
|
setShowAuthFlow(value);
|
|
19
|
-
}, [setShowAuthFlow, wallets]);
|
|
22
|
+
}, [setShowAuthFlow, wallets, user, isMultiWalletEnabled]);
|
|
20
23
|
return setShowAuthFlowWithInit;
|
|
21
24
|
};
|
|
22
25
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var EventEmitter = require('eventemitter3');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
10
|
+
|
|
11
|
+
// This file is temporary and should be removed after QNTM-180 is done
|
|
12
|
+
const getInternalEvents = () => new EventEmitter__default["default"]();
|
|
13
|
+
|
|
14
|
+
exports.getInternalEvents = getInternalEvents;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
/** Maps internal event names to their listeners */
|
|
3
|
+
export type InternalEventMap = {
|
|
4
|
+
emailVerificationResult: (param: boolean) => void;
|
|
5
|
+
clearPrimaryWallet: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type InternalEventEmitter = EventEmitter<InternalEventMap>;
|
|
8
|
+
export declare const getInternalEvents: () => InternalEventEmitter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
1
|
+
import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import { DynamicJwt, NameServiceData, ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
3
3
|
import { NetworkConfigurationMap, SocialProviderFilter, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
4
|
import { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -8,6 +8,7 @@ import { MultiWalletWidgetStateSetter } from '../../../utils/hooks/multiWallet';
|
|
|
8
8
|
import { ThemeData, ThemeSetting } from '../../ThemeContext';
|
|
9
9
|
import { DisplayOrder, SetDisplayOrderPriority } from '../hooks';
|
|
10
10
|
import { Callback } from '../useCustomerCallbacks';
|
|
11
|
+
import { InternalEventEmitter } from '../internalEvents';
|
|
11
12
|
export type ChainsToConnect = {
|
|
12
13
|
chain: Chain;
|
|
13
14
|
numberOfWallets: number;
|
|
@@ -97,6 +98,8 @@ export interface IDynamicContext {
|
|
|
97
98
|
setSelectedWalletConnector: (connector: WalletConnector | null) => void;
|
|
98
99
|
setSelectedWalletWithAction: (walletWithAction: WalletWithAction | null) => void;
|
|
99
100
|
setShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
101
|
+
/** The unwrapped version of setShowAuthFlow. See useSetShowAuthFlowWithInit.ts for context */
|
|
102
|
+
internalSetShowAuthFlow: Dispatch<SetStateAction<boolean>>;
|
|
100
103
|
setShowDynamicUserProfile: Dispatch<SetStateAction<boolean>>;
|
|
101
104
|
setShowQrcodeModal: Dispatch<SetStateAction<boolean>>;
|
|
102
105
|
setShowWidgetStatePopup: Dispatch<SetStateAction<boolean>>;
|
|
@@ -112,6 +115,7 @@ export interface IDynamicContext {
|
|
|
112
115
|
* The boolean value representing the state of displaying the bridge widget
|
|
113
116
|
*/
|
|
114
117
|
showBridgeWidget: boolean;
|
|
118
|
+
showLockedWalletView?: boolean;
|
|
115
119
|
showQrcodeModal: boolean;
|
|
116
120
|
showWidgetStatePopup: boolean;
|
|
117
121
|
signWithEmailWalletName?: string;
|
|
@@ -143,4 +147,6 @@ export interface IDynamicContext {
|
|
|
143
147
|
legacyIsVerifying: boolean;
|
|
144
148
|
/** Legacy setter for legacyIsVerifying */
|
|
145
149
|
setLegacyIsVerifying: Dispatch<SetStateAction<boolean>>;
|
|
150
|
+
/** Temporary workaround, until QNTM-180 is complete */
|
|
151
|
+
internalEvents: MutableRefObject<InternalEventEmitter>;
|
|
146
152
|
}
|
|
@@ -11,7 +11,7 @@ const useDynamicContext = () => {
|
|
|
11
11
|
if (context === undefined) {
|
|
12
12
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
13
13
|
}
|
|
14
|
-
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, setShowBridgeWidget, sendWagmiSettings, } = context;
|
|
14
|
+
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, setShowBridgeWidget, sendWagmiSettings, internalEvents, } = context;
|
|
15
15
|
return {
|
|
16
16
|
accountSwitchState,
|
|
17
17
|
authMode,
|
|
@@ -21,6 +21,7 @@ const useDynamicContext = () => {
|
|
|
21
21
|
getNameService,
|
|
22
22
|
handleLogOut,
|
|
23
23
|
handleUnlinkWallet,
|
|
24
|
+
internalEvents,
|
|
24
25
|
isAuthenticated,
|
|
25
26
|
isFullyConnected,
|
|
26
27
|
isVerificationInProgress,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IDynamicContext } from './types';
|
|
2
|
-
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'isFullyConnected' | 'isVerificationInProgress' | 'linkedWallets' | 'loadingNetwork' | 'loginWithEmail' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'rpcProviders' | 'sdkHasLoaded' | 'secondaryWallets' | 'setLogInWithEmail' | 'setMultiWalletWidgetState' | 'setNetwork' | 'setPrimaryWallet' | 'setShowAuthFlow' | 'setShowDynamicUserProfile' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'user' | 'walletConnector' | 'wallets' | 'walletsByChain' | 'walletsToConnectByChain' | 'setShowBridgeWidget' | 'sendWagmiSettings'>;
|
|
2
|
+
export type UseDynamicContext = Pick<IDynamicContext, 'accountSwitchState' | 'authMode' | 'authToken' | 'awaitingSignatureState' | 'connectedWallets' | 'getNameService' | 'handleLogOut' | 'handleUnlinkWallet' | 'isAuthenticated' | 'isFullyConnected' | 'isVerificationInProgress' | 'linkedWallets' | 'loadingNetwork' | 'loginWithEmail' | 'multiWalletWidgetState' | 'network' | 'networkConfigurations' | 'primaryWallet' | 'qrcodeUri' | 'rpcProviders' | 'sdkHasLoaded' | 'secondaryWallets' | 'setLogInWithEmail' | 'setMultiWalletWidgetState' | 'setNetwork' | 'setPrimaryWallet' | 'setShowAuthFlow' | 'setShowDynamicUserProfile' | 'setShowQrcodeModal' | 'shadowDOMEnabled' | 'showAuthFlow' | 'showQrcodeModal' | 'user' | 'walletConnector' | 'wallets' | 'walletsByChain' | 'walletsToConnectByChain' | 'setShowBridgeWidget' | 'sendWagmiSettings' | 'internalEvents'>;
|
|
3
3
|
export declare const useDynamicContext: () => UseDynamicContext;
|
|
@@ -7,7 +7,7 @@ const useDynamicContext = () => {
|
|
|
7
7
|
if (context === undefined) {
|
|
8
8
|
throw new Error('useDynamicContext must be used within a DynamicContextProvider');
|
|
9
9
|
}
|
|
10
|
-
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, setShowBridgeWidget, sendWagmiSettings, } = context;
|
|
10
|
+
const { accountSwitchState, authMode, authToken, awaitingSignatureState, connectedWallets, getNameService, handleLogOut, handleUnlinkWallet, isAuthenticated, isFullyConnected, isVerificationInProgress, linkedWallets, loadingNetwork, loginWithEmail, multiWalletWidgetState, network, networkConfigurations, qrcodeUri, rpcProviders, sdkHasLoaded, secondaryWallets, setLogInWithEmail, setMultiWalletWidgetState, setNetwork, setPrimaryWallet, setShowAuthFlow, setShowDynamicUserProfile, setShowQrcodeModal, shadowDOMEnabled, showAuthFlow, showQrcodeModal, user, walletConnector, wallets, walletsByChain, walletsToConnectByChain, primaryWallet, setShowBridgeWidget, sendWagmiSettings, internalEvents, } = context;
|
|
11
11
|
return {
|
|
12
12
|
accountSwitchState,
|
|
13
13
|
authMode,
|
|
@@ -17,6 +17,7 @@ const useDynamicContext = () => {
|
|
|
17
17
|
getNameService,
|
|
18
18
|
handleLogOut,
|
|
19
19
|
handleUnlinkWallet,
|
|
20
|
+
internalEvents,
|
|
20
21
|
isAuthenticated,
|
|
21
22
|
isFullyConnected,
|
|
22
23
|
isVerificationInProgress,
|
|
@@ -20,6 +20,7 @@ const errorMessageMap = {
|
|
|
20
20
|
'missing-nonce': 'Something went wrong. Please try again.',
|
|
21
21
|
'missing-public-address': 'Connection cancelled. Please try again',
|
|
22
22
|
too_many_email_verification_attempts: 'Too many email verification attempts, please try again later',
|
|
23
|
+
'user-cancelled': '',
|
|
23
24
|
wallet_not_deployed: 'Your smart wallet has not been deployed.',
|
|
24
25
|
wrong_email_verification_token: 'The code you entered is incorrect. Please try again.',
|
|
25
26
|
};
|
|
@@ -16,6 +16,7 @@ const errorMessageMap = {
|
|
|
16
16
|
'missing-nonce': 'Something went wrong. Please try again.',
|
|
17
17
|
'missing-public-address': 'Connection cancelled. Please try again',
|
|
18
18
|
too_many_email_verification_attempts: 'Too many email verification attempts, please try again later',
|
|
19
|
+
'user-cancelled': '',
|
|
19
20
|
wallet_not_deployed: 'Your smart wallet has not been deployed.',
|
|
20
21
|
wrong_email_verification_token: 'The code you entered is incorrect. Please try again.',
|
|
21
22
|
};
|
|
@@ -46,7 +46,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
|
|
|
46
46
|
const SocialRedirectContext = React.createContext(undefined);
|
|
47
47
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
48
48
|
var _a, _b;
|
|
49
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
49
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
50
50
|
const { setErrorMessage } = ErrorContext.useErrorContext();
|
|
51
51
|
const { setView } = ViewContext.useViewContext();
|
|
52
52
|
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
@@ -65,7 +65,10 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
65
65
|
.find(walletConnectorCore.isSocialWalletConnector);
|
|
66
66
|
const [redirectStatus, setRedirectStatus] = React.useState('idle');
|
|
67
67
|
const [socialProvider, setSocialProvider] = React.useState();
|
|
68
|
-
const
|
|
68
|
+
const userWallets = primaryWallet
|
|
69
|
+
? [primaryWallet, ...secondaryWallets]
|
|
70
|
+
: secondaryWallets;
|
|
71
|
+
const wallet = userWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
|
|
69
72
|
const socialAccount = React.useMemo(() => (wallet ? getReferencedAccount.getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
|
|
70
73
|
const handleError = React.useCallback((message) => {
|
|
71
74
|
logger.logger.error(message);
|
|
@@ -126,12 +129,32 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
126
129
|
if (!socialAccount) {
|
|
127
130
|
throw new Error('Social account not found');
|
|
128
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* consider google: a user may have multiple google accounts.
|
|
134
|
+
* we need to make sure they connected with the same google account
|
|
135
|
+
* that they originally used to authenticate
|
|
136
|
+
*
|
|
137
|
+
* there are two known scenarios that we enter this branch:
|
|
138
|
+
* 1. the user is reconnected a social wallet:
|
|
139
|
+
* a. the user signed in with social
|
|
140
|
+
* b. the user then linked another wallet (for ex: metamask)
|
|
141
|
+
* c. the user signed out
|
|
142
|
+
* d. the user signed in with metamask
|
|
143
|
+
* e. the user selects their social wallet as their primary wallet
|
|
144
|
+
* f. we need to reconnect the social wallet and put the user in the social oauth redirect flow
|
|
145
|
+
*
|
|
146
|
+
* 2. for an unknown reason, the magic search params get put back into the url and this component rerenders,
|
|
147
|
+
* causing us to think the user is reconnecting.
|
|
148
|
+
* see: https://dynamiclabsgroup.slack.com/archives/C0473MNEP0T/p1697503460754999
|
|
149
|
+
*/
|
|
129
150
|
if (socialAccount.oauthAccountId === session.oauthId) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.id) !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id)) {
|
|
152
|
+
// justification: socialAccount is defined if and only if wallet is also defined
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
154
|
+
setPrimaryWalletId(wallet.id);
|
|
155
|
+
setShowAuthFlow(false);
|
|
156
|
+
setShowDynamicUserProfile(true);
|
|
157
|
+
}
|
|
135
158
|
}
|
|
136
159
|
else {
|
|
137
160
|
yield socialWalletConnector.endSession();
|
|
@@ -139,6 +162,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
139
162
|
}
|
|
140
163
|
}
|
|
141
164
|
else {
|
|
165
|
+
yield connectWallet(socialWalletConnector);
|
|
142
166
|
const address = yield socialWalletConnector.fetchPublicAddress();
|
|
143
167
|
walletUiUtils.disabledConfirmationOnce();
|
|
144
168
|
yield verifyWallet({
|
|
@@ -181,6 +205,8 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
181
205
|
walletUiUtils,
|
|
182
206
|
wallet,
|
|
183
207
|
handleError,
|
|
208
|
+
connectWallet,
|
|
209
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
184
210
|
]);
|
|
185
211
|
return (jsxRuntime.jsx(SocialRedirectContext.Provider, { value: {
|
|
186
212
|
enabledSocialProviders,
|
|
@@ -42,7 +42,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
|
|
|
42
42
|
const SocialRedirectContext = createContext(undefined);
|
|
43
43
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
44
44
|
var _a, _b;
|
|
45
|
-
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, } = useInternalDynamicContext();
|
|
45
|
+
const { setShowAuthFlow, wallets, setSelectedWalletConnector, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, isAuthenticated, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, authToken, connectWallet, primaryWallet, } = useInternalDynamicContext();
|
|
46
46
|
const { setErrorMessage } = useErrorContext();
|
|
47
47
|
const { setView } = useViewContext();
|
|
48
48
|
const verifyWallet = useVerifyWallet({
|
|
@@ -61,7 +61,10 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
61
61
|
.find(isSocialWalletConnector);
|
|
62
62
|
const [redirectStatus, setRedirectStatus] = useState('idle');
|
|
63
63
|
const [socialProvider, setSocialProvider] = useState();
|
|
64
|
-
const
|
|
64
|
+
const userWallets = primaryWallet
|
|
65
|
+
? [primaryWallet, ...secondaryWallets]
|
|
66
|
+
: secondaryWallets;
|
|
67
|
+
const wallet = userWallets.find((wallet) => wallet.connector.key === (socialWalletConnector === null || socialWalletConnector === void 0 ? void 0 : socialWalletConnector.key));
|
|
65
68
|
const socialAccount = useMemo(() => (wallet ? getReferencedAccount(authToken, wallet.id) : undefined), [authToken, wallet]);
|
|
66
69
|
const handleError = useCallback((message) => {
|
|
67
70
|
logger.error(message);
|
|
@@ -122,12 +125,32 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
122
125
|
if (!socialAccount) {
|
|
123
126
|
throw new Error('Social account not found');
|
|
124
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* consider google: a user may have multiple google accounts.
|
|
130
|
+
* we need to make sure they connected with the same google account
|
|
131
|
+
* that they originally used to authenticate
|
|
132
|
+
*
|
|
133
|
+
* there are two known scenarios that we enter this branch:
|
|
134
|
+
* 1. the user is reconnected a social wallet:
|
|
135
|
+
* a. the user signed in with social
|
|
136
|
+
* b. the user then linked another wallet (for ex: metamask)
|
|
137
|
+
* c. the user signed out
|
|
138
|
+
* d. the user signed in with metamask
|
|
139
|
+
* e. the user selects their social wallet as their primary wallet
|
|
140
|
+
* f. we need to reconnect the social wallet and put the user in the social oauth redirect flow
|
|
141
|
+
*
|
|
142
|
+
* 2. for an unknown reason, the magic search params get put back into the url and this component rerenders,
|
|
143
|
+
* causing us to think the user is reconnecting.
|
|
144
|
+
* see: https://dynamiclabsgroup.slack.com/archives/C0473MNEP0T/p1697503460754999
|
|
145
|
+
*/
|
|
125
146
|
if (socialAccount.oauthAccountId === session.oauthId) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
147
|
+
if ((wallet === null || wallet === void 0 ? void 0 : wallet.id) !== (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id)) {
|
|
148
|
+
// justification: socialAccount is defined if and only if wallet is also defined
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
150
|
+
setPrimaryWalletId(wallet.id);
|
|
151
|
+
setShowAuthFlow(false);
|
|
152
|
+
setShowDynamicUserProfile(true);
|
|
153
|
+
}
|
|
131
154
|
}
|
|
132
155
|
else {
|
|
133
156
|
yield socialWalletConnector.endSession();
|
|
@@ -135,6 +158,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
135
158
|
}
|
|
136
159
|
}
|
|
137
160
|
else {
|
|
161
|
+
yield connectWallet(socialWalletConnector);
|
|
138
162
|
const address = yield socialWalletConnector.fetchPublicAddress();
|
|
139
163
|
walletUiUtils.disabledConfirmationOnce();
|
|
140
164
|
yield verifyWallet({
|
|
@@ -177,6 +201,8 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
177
201
|
walletUiUtils,
|
|
178
202
|
wallet,
|
|
179
203
|
handleError,
|
|
204
|
+
connectWallet,
|
|
205
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
|
|
180
206
|
]);
|
|
181
207
|
return (jsx(SocialRedirectContext.Provider, { value: {
|
|
182
208
|
enabledSocialProviders,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SetStateAction, Dispatch, PropsWithChildren, FC } from 'react';
|
|
2
|
-
export type ViewType = 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-with-email' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-email-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'update-email' | 'verify-email' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts';
|
|
2
|
+
export type ViewType = 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-with-email' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-email-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'update-email' | 'verify-email' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'multi-wallet-wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts';
|
|
3
3
|
export type ViewContextProps = {
|
|
4
4
|
setView: Dispatch<SetStateAction<ViewType>>;
|
|
5
5
|
view: ViewType;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
|
|
7
|
+
require('../DynamicContext/DynamicContext.cjs');
|
|
8
8
|
require('@dynamic-labs/sdk-api');
|
|
9
9
|
require('../../shared/logger.cjs');
|
|
10
10
|
require('@dynamic-labs/iconic');
|
|
@@ -26,21 +26,7 @@ var useSyncPrimaryWallet = require('../../utils/hooks/multiWallet/useSyncPrimary
|
|
|
26
26
|
|
|
27
27
|
const WalletContext = React.createContext(undefined);
|
|
28
28
|
const WalletContextProvider = ({ children, canSync, }) => {
|
|
29
|
-
|
|
30
|
-
useSyncPrimaryWallet.useSyncPrimaryWallet({
|
|
31
|
-
authMode,
|
|
32
|
-
canSync,
|
|
33
|
-
computeConnectedStateForWallets,
|
|
34
|
-
connectWallet,
|
|
35
|
-
handleLogOut,
|
|
36
|
-
multiWalletWidgetState,
|
|
37
|
-
primaryWallet,
|
|
38
|
-
secondaryWallets,
|
|
39
|
-
setMultiWalletWidgetState,
|
|
40
|
-
setPrimaryWallet,
|
|
41
|
-
setShowWidgetStatePopup,
|
|
42
|
-
showWidgetStatePopup,
|
|
43
|
-
});
|
|
29
|
+
useSyncPrimaryWallet.useSyncPrimaryWallet(canSync);
|
|
44
30
|
const value = undefined;
|
|
45
31
|
return (jsxRuntime.jsx(WalletContext.Provider, { value: value, children: children }));
|
|
46
32
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import '../DynamicContext/DynamicContext.js';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -22,21 +22,7 @@ import { useSyncPrimaryWallet } from '../../utils/hooks/multiWallet/useSyncPrima
|
|
|
22
22
|
|
|
23
23
|
const WalletContext = createContext(undefined);
|
|
24
24
|
const WalletContextProvider = ({ children, canSync, }) => {
|
|
25
|
-
|
|
26
|
-
useSyncPrimaryWallet({
|
|
27
|
-
authMode,
|
|
28
|
-
canSync,
|
|
29
|
-
computeConnectedStateForWallets,
|
|
30
|
-
connectWallet,
|
|
31
|
-
handleLogOut,
|
|
32
|
-
multiWalletWidgetState,
|
|
33
|
-
primaryWallet,
|
|
34
|
-
secondaryWallets,
|
|
35
|
-
setMultiWalletWidgetState,
|
|
36
|
-
setPrimaryWallet,
|
|
37
|
-
setShowWidgetStatePopup,
|
|
38
|
-
showWidgetStatePopup,
|
|
39
|
-
});
|
|
25
|
+
useSyncPrimaryWallet(canSync);
|
|
40
26
|
const value = undefined;
|
|
41
27
|
return (jsx(WalletContext.Provider, { value: value, children: children }));
|
|
42
28
|
};
|
package/src/lib/data/api.cjs
CHANGED
|
@@ -18,6 +18,7 @@ require('../utils/constants/colors.cjs');
|
|
|
18
18
|
require('../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('viem');
|
|
20
20
|
require('../shared/consts/index.cjs');
|
|
21
|
+
var helpers = require('../context/DynamicContext/helpers.cjs');
|
|
21
22
|
|
|
22
23
|
const sdkApi = (jwt) => {
|
|
23
24
|
const settings = {
|
|
@@ -187,11 +188,12 @@ const unlinkWallet = ({ environmentId, primaryWalletId, walletId, }, userJwt) =>
|
|
|
187
188
|
return undefined;
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
|
-
const transferWallet = (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
const transferWallet = (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
191
192
|
// We should find a better way to do this than force type casting
|
|
192
193
|
const verifyRequest = {
|
|
193
194
|
chain,
|
|
194
195
|
messageToSign,
|
|
196
|
+
network,
|
|
195
197
|
publicWalletAddress,
|
|
196
198
|
signedMessage,
|
|
197
199
|
skipEmptyAccountCheck,
|
|
@@ -371,11 +373,12 @@ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state },
|
|
|
371
373
|
return undefined;
|
|
372
374
|
}
|
|
373
375
|
});
|
|
374
|
-
const unlinkOAuth = ({ environmentId, verifiedCrentialId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
376
|
+
const unlinkOAuth = ({ environmentId, primaryWalletId, verifiedCrentialId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
375
377
|
try {
|
|
376
378
|
const { jwt } = yield sdkApi(userJwt).verifyUnlink({
|
|
377
379
|
environmentId,
|
|
378
380
|
verifyUnlinkRequest: {
|
|
381
|
+
primaryWalletId,
|
|
379
382
|
verifiedCrentialId,
|
|
380
383
|
},
|
|
381
384
|
});
|
|
@@ -401,19 +404,24 @@ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddr
|
|
|
401
404
|
const sendDynamicProps = (environmentId, settingsToSend) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
402
405
|
try {
|
|
403
406
|
const { dynamicContextProps, dynamicWagmiSettings } = settingsToSend;
|
|
404
|
-
if (dynamicContextProps
|
|
405
|
-
yield
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
dynamicWagmiSettings,
|
|
410
|
-
},
|
|
411
|
-
});
|
|
407
|
+
if (dynamicContextProps) {
|
|
408
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps }, helpers.isDynamicContextSessionSettingExpired, helpers.setDynamicContextSessionSettings);
|
|
409
|
+
}
|
|
410
|
+
if (dynamicWagmiSettings) {
|
|
411
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, helpers.isWagmiSessionSettingExpired, helpers.setWagmiSessionSettings);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
catch (
|
|
415
|
-
logger.logger.error
|
|
414
|
+
catch (error) {
|
|
415
|
+
logger.logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
419
|
+
// sent once. no need to send again
|
|
420
|
+
if (!isSdkSettingExpired()) {
|
|
421
|
+
return;
|
|
416
422
|
}
|
|
423
|
+
yield sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
424
|
+
setSDKSessionSettings();
|
|
417
425
|
});
|
|
418
426
|
const mergeUserAccounts = (userJwt, environmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
419
427
|
try {
|
package/src/lib/data/api.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId,
|
|
|
34
34
|
primaryWalletId: string | undefined;
|
|
35
35
|
walletId: string;
|
|
36
36
|
}, userJwt: string) => Promise<string | undefined>;
|
|
37
|
-
export declare const transferWallet: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet, userJwt: string) => Promise<string | undefined>;
|
|
37
|
+
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet, userJwt: string) => Promise<string | undefined>;
|
|
38
38
|
export declare const mapChainToChainEnum: (chain: string) => ChainEnum;
|
|
39
39
|
export declare const mapProviderToProviderEnum: (provider: string) => WalletProviderEnum;
|
|
40
40
|
export declare const mapAuthModeTypeToEnum: (authMode: string) => AuthModeEnum;
|
|
@@ -52,8 +52,9 @@ export declare const fetchProjectSettings: (environmentId: string) => Promise<Pr
|
|
|
52
52
|
export declare const updateUserProfileFields: (jwt: string | undefined, environmentId: string, fields: UserFields) => Promise<UpdateSelfResponse>;
|
|
53
53
|
export declare const getOauthLoginUrl: (environmentId: string, providerType: ProviderEnum, userJwt: string) => Promise<string | undefined>;
|
|
54
54
|
export declare const verifyOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state }: OauthRequest, userJwt: string) => Promise<string | undefined>;
|
|
55
|
-
export declare const unlinkOAuth: ({ environmentId, verifiedCrentialId, }: {
|
|
55
|
+
export declare const unlinkOAuth: ({ environmentId, primaryWalletId, verifiedCrentialId, }: {
|
|
56
56
|
environmentId: string;
|
|
57
|
+
primaryWalletId: string | undefined;
|
|
57
58
|
verifiedCrentialId: string;
|
|
58
59
|
}, userJwt: string) => Promise<string | undefined>;
|
|
59
60
|
export declare const getOnrampProviders: ({ chain, environmentId, networkId, token, walletAddress, }: {
|
package/src/lib/data/api.js
CHANGED
|
@@ -14,6 +14,7 @@ import '../utils/constants/colors.js';
|
|
|
14
14
|
import '../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import 'viem';
|
|
16
16
|
import '../shared/consts/index.js';
|
|
17
|
+
import { isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings, isWagmiSessionSettingExpired, setWagmiSessionSettings } from '../context/DynamicContext/helpers.js';
|
|
17
18
|
|
|
18
19
|
const sdkApi = (jwt) => {
|
|
19
20
|
const settings = {
|
|
@@ -183,11 +184,12 @@ const unlinkWallet = ({ environmentId, primaryWalletId, walletId, }, userJwt) =>
|
|
|
183
184
|
return undefined;
|
|
184
185
|
}
|
|
185
186
|
});
|
|
186
|
-
const transferWallet = (environmentId, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
187
|
+
const transferWallet = (environmentId, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck = false, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
187
188
|
// We should find a better way to do this than force type casting
|
|
188
189
|
const verifyRequest = {
|
|
189
190
|
chain,
|
|
190
191
|
messageToSign,
|
|
192
|
+
network,
|
|
191
193
|
publicWalletAddress,
|
|
192
194
|
signedMessage,
|
|
193
195
|
skipEmptyAccountCheck,
|
|
@@ -367,11 +369,12 @@ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state },
|
|
|
367
369
|
return undefined;
|
|
368
370
|
}
|
|
369
371
|
});
|
|
370
|
-
const unlinkOAuth = ({ environmentId, verifiedCrentialId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
372
|
+
const unlinkOAuth = ({ environmentId, primaryWalletId, verifiedCrentialId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
371
373
|
try {
|
|
372
374
|
const { jwt } = yield sdkApi(userJwt).verifyUnlink({
|
|
373
375
|
environmentId,
|
|
374
376
|
verifyUnlinkRequest: {
|
|
377
|
+
primaryWalletId,
|
|
375
378
|
verifiedCrentialId,
|
|
376
379
|
},
|
|
377
380
|
});
|
|
@@ -397,19 +400,24 @@ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddr
|
|
|
397
400
|
const sendDynamicProps = (environmentId, settingsToSend) => __awaiter(void 0, void 0, void 0, function* () {
|
|
398
401
|
try {
|
|
399
402
|
const { dynamicContextProps, dynamicWagmiSettings } = settingsToSend;
|
|
400
|
-
if (dynamicContextProps
|
|
401
|
-
yield
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
dynamicWagmiSettings,
|
|
406
|
-
},
|
|
407
|
-
});
|
|
403
|
+
if (dynamicContextProps) {
|
|
404
|
+
yield sendDynamicContextSettings(environmentId, { dynamicContextProps }, isDynamicContextSessionSettingExpired, setDynamicContextSessionSettings);
|
|
405
|
+
}
|
|
406
|
+
if (dynamicWagmiSettings) {
|
|
407
|
+
yield sendDynamicContextSettings(environmentId, { dynamicWagmiSettings }, isWagmiSessionSettingExpired, setWagmiSessionSettings);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
catch (
|
|
411
|
-
logger.error
|
|
410
|
+
catch (error) {
|
|
411
|
+
logger.warn('Error caught when sending sdkSettings to api. Please notify Dynamic, and send the DynamicContextProvider settings you currently have configured', { error });
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
const sendDynamicContextSettings = (environmentId, sdkSettingsRequest, isSdkSettingExpired, setSDKSessionSettings) => __awaiter(void 0, void 0, void 0, function* () {
|
|
415
|
+
// sent once. no need to send again
|
|
416
|
+
if (!isSdkSettingExpired()) {
|
|
417
|
+
return;
|
|
412
418
|
}
|
|
419
|
+
yield sdkApi().logDynamicSdkSettings({ environmentId, sdkSettingsRequest });
|
|
420
|
+
setSDKSessionSettings();
|
|
413
421
|
});
|
|
414
422
|
const mergeUserAccounts = (userJwt, environmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
415
423
|
try {
|