@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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Typography } from '../../../Typography/Typography.js';
|
|
3
|
+
import { capitalize } from '../../../../shared/utils/functions/capitalize/capitalize.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api';
|
|
5
|
+
import '../../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import '../../../../context/ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import { shortenWalletAddress } from '../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
|
|
12
|
+
import '@dynamic-labs/utils';
|
|
13
|
+
import '../../../../utils/constants/colors.js';
|
|
14
|
+
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
15
|
+
import 'viem';
|
|
16
|
+
import '../../../../shared/consts/index.js';
|
|
17
|
+
|
|
18
|
+
const TypeTitle = ({ children }) => (jsx(Typography, { color: 'secondary', weight: 'medium', children: children }));
|
|
19
|
+
const AttributeName = TypeTitle;
|
|
20
|
+
const AttributeValue = ({ children, title, }) => (jsx(Typography, { as: 'span', weight: 'regular', color: 'primary', title: title, children: children }));
|
|
21
|
+
const SignTypedDataPreview = ({ currentType, types, showTypeName = false, data }) => {
|
|
22
|
+
const fields = types[currentType].map((field) => {
|
|
23
|
+
const { type } = field;
|
|
24
|
+
const isKnownType = type in types;
|
|
25
|
+
if (isKnownType) {
|
|
26
|
+
return (jsxs("div", { children: [jsx(TypeTitle, { children: capitalize(field.name) }), jsx("div", { className: 'sign-typed-data-preview--type-container', children: jsx(SignTypedDataPreview, { currentType: type, types: types, data: data === null || data === void 0 ? void 0 : data[field.name] }) })] }, field.name));
|
|
27
|
+
}
|
|
28
|
+
const fieldData = data === null || data === void 0 ? void 0 : data[field.name];
|
|
29
|
+
const fieldType = field.type;
|
|
30
|
+
return (jsxs("div", { className: 'sign-typed-data-preview--attribute-row', children: [jsxs(AttributeName, { children: [capitalize(field.name), ": "] }), jsx(AttributeValue, { title: fieldData, children: fieldType === 'address'
|
|
31
|
+
? shortenWalletAddress(fieldData, 4, 4)
|
|
32
|
+
: fieldData })] }, field.name));
|
|
33
|
+
});
|
|
34
|
+
if (showTypeName) {
|
|
35
|
+
return (jsxs(Fragment, { children: [jsx(TypeTitle, { children: currentType }), jsx("div", { className: 'sign-typed-data-preview--type-container', children: fields })] }));
|
|
36
|
+
}
|
|
37
|
+
return jsx("div", { className: 'sign-typed-data-preview--fields-list', children: fields });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { SignTypedDataPreview };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SignTypedDataPreview } from './SignTypedDataPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SignTypedDataPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SignMessagePreview } from './SignMessagePreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isSignTypedData';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isSignTypedData } from './isSignTypedData';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const isSignTypedData = (data) => {
|
|
6
|
+
if (typeof data !== 'object' || data === null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const { types, message, primaryType } = data;
|
|
10
|
+
return (typeof types === 'object' &&
|
|
11
|
+
types !== null &&
|
|
12
|
+
typeof message === 'object' &&
|
|
13
|
+
message !== null &&
|
|
14
|
+
typeof primaryType === 'string');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.isSignTypedData = isSignTypedData;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const isSignTypedData = (data) => {
|
|
2
|
+
if (typeof data !== 'object' || data === null) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const { types, message, primaryType } = data;
|
|
6
|
+
return (typeof types === 'object' &&
|
|
7
|
+
types !== null &&
|
|
8
|
+
typeof message === 'object' &&
|
|
9
|
+
message !== null &&
|
|
10
|
+
typeof primaryType === 'string');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { isSignTypedData };
|
|
@@ -29,6 +29,7 @@ const Typography = (_a) => {
|
|
|
29
29
|
'brand-primary': 'typography--brand-primary',
|
|
30
30
|
'error-1': 'typography--dynamic-error-1',
|
|
31
31
|
'error-2': 'typography--dynamic-error-2',
|
|
32
|
+
'green-1': 'typography--connection-green-1',
|
|
32
33
|
link: 'typography--link',
|
|
33
34
|
primary: 'typography--primary',
|
|
34
35
|
secondary: 'typography--secondary',
|
|
@@ -25,6 +25,7 @@ const Typography = (_a) => {
|
|
|
25
25
|
'brand-primary': 'typography--brand-primary',
|
|
26
26
|
'error-1': 'typography--dynamic-error-1',
|
|
27
27
|
'error-2': 'typography--dynamic-error-2',
|
|
28
|
+
'green-1': 'typography--connection-green-1',
|
|
28
29
|
link: 'typography--link',
|
|
29
30
|
primary: 'typography--primary',
|
|
30
31
|
secondary: 'typography--secondary',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
|
|
2
2
|
export type TypographyTag = ElementType;
|
|
3
3
|
export type TypographyVariant = 'title' | 'body_normal' | 'body_small' | 'body_mini' | 'button_primary' | 'button_secondary' | 'button_tertiary' | 'numbers_big' | 'numbers_medium' | 'numbers_small';
|
|
4
|
-
export type TypographyColor = 'primary' | 'secondary' | 'brand-primary' | 'tertiary' | 'link' | 'error-1' | 'error-2' | 'tooltip';
|
|
4
|
+
export type TypographyColor = 'primary' | 'secondary' | 'brand-primary' | 'tertiary' | 'link' | 'error-1' | 'error-2' | 'tooltip' | 'green-1';
|
|
5
5
|
export type TypographyWeight = 'regular' | 'medium' | 'bold';
|
|
6
6
|
export type TypographyTransform = 'uppercase';
|
|
7
7
|
export type TypographyProps<TAG extends ElementType = 'p'> = {
|
|
@@ -43,7 +43,7 @@ const UserProfile = ({ rootClassName }) => {
|
|
|
43
43
|
const { label } = index$1.getValueByKey(fieldsConfig.fieldsConfig, name);
|
|
44
44
|
const value = mapFieldKeyToValue(name);
|
|
45
45
|
return (jsxRuntime.jsx(UserProfileField.UserProfileField, { name: name, label: label, value: value }, name));
|
|
46
|
-
}) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: 'Social accounts', children: jsxRuntime.jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({
|
|
46
|
+
}) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, { title: 'Social accounts', children: jsxRuntime.jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({ provider }) => (jsxRuntime.jsx(UserProfileSocialAccount.UserProfileSocialAccount, { provider: provider }, provider))) }) }))] }));
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
exports.UserProfile = UserProfile;
|
|
@@ -39,7 +39,7 @@ const UserProfile = ({ rootClassName }) => {
|
|
|
39
39
|
const { label } = getValueByKey(fieldsConfig, name);
|
|
40
40
|
const value = mapFieldKeyToValue(name);
|
|
41
41
|
return (jsx(UserProfileField, { name: name, label: label, value: value }, name));
|
|
42
|
-
}) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsx(UserProfileSection, { title: 'Social accounts', children: jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({
|
|
42
|
+
}) }) })), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsx(UserProfileSection, { title: 'Social accounts', children: jsx("div", { className: 'user-profile__social-accounts', children: providers.map(({ provider }) => (jsx(UserProfileSocialAccount, { provider: provider }, provider))) }) }))] }));
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export { UserProfile };
|
package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs
CHANGED
|
@@ -57,7 +57,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
|
|
|
57
57
|
const isProviderLinked = isLinked(provider);
|
|
58
58
|
const connectedAccountInfo = getLinkedAccountInformation(provider);
|
|
59
59
|
const iconThemeVariant = useIconThemeVariant.useIconThemeVariant();
|
|
60
|
-
return (jsxRuntime.jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsxRuntime.jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar
|
|
60
|
+
return (jsxRuntime.jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsxRuntime.jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsxRuntime.jsx(iconic.SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsxRuntime.jsx("div", { className: 'user-profile-social-account__label', children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : helpers.capitalize(provider) }) }), isProviderLinked ? (jsxRuntime.jsx(Button.Button, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonRounded: 'small', buttonPadding: 'none', onClick: () => unlinkSocialAccount(provider), loading: isProcessing, dataTestId: 'social-account-disconnect-button', typographyProps: {
|
|
61
61
|
color: 'secondary',
|
|
62
62
|
variant: 'button_tertiary',
|
|
63
63
|
}, startSlot:
|
package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js
CHANGED
|
@@ -53,7 +53,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
|
|
|
53
53
|
const isProviderLinked = isLinked(provider);
|
|
54
54
|
const connectedAccountInfo = getLinkedAccountInformation(provider);
|
|
55
55
|
const iconThemeVariant = useIconThemeVariant();
|
|
56
|
-
return (jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar
|
|
56
|
+
return (jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsx(SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsx("div", { className: 'user-profile-social-account__label', children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : capitalize(provider) }) }), isProviderLinked ? (jsx(Button, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonRounded: 'small', buttonPadding: 'none', onClick: () => unlinkSocialAccount(provider), loading: isProcessing, dataTestId: 'social-account-disconnect-button', typographyProps: {
|
|
57
57
|
color: 'secondary',
|
|
58
58
|
variant: 'button_tertiary',
|
|
59
59
|
}, startSlot:
|
|
@@ -94,13 +94,17 @@ var useVerificationInProgress = require('./hooks/useVerificationInProgress/useVe
|
|
|
94
94
|
var useCustomerCallbacks = require('./useCustomerCallbacks/useCustomerCallbacks.cjs');
|
|
95
95
|
var useCustomerAuthFlowCallbacks = require('./useCustomerCallbacks/useCustomerAuthFlowCallbacks.cjs');
|
|
96
96
|
var validators = require('./validators.cjs');
|
|
97
|
+
var internalEvents = require('./internalEvents/internalEvents.cjs');
|
|
97
98
|
|
|
98
99
|
const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9';
|
|
99
100
|
const EMPTY_INITIAL_USER = undefined;
|
|
100
101
|
const DynamicContext = React.createContext(undefined);
|
|
101
102
|
const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
102
103
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
103
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
|
|
104
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, deepLinkPreference = 'native', walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = true, } = settings;
|
|
105
|
+
// The following event related methods are temporary and should be removed after QNTM-180 is done
|
|
106
|
+
// ============ START REMOVE AFTER QNTM-180 ============
|
|
107
|
+
const internalEventsRef = React.useRef(internalEvents.getInternalEvents());
|
|
104
108
|
let { walletConnectV1Bridge, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
|
|
105
109
|
if (!environmentId) {
|
|
106
110
|
throw new utils.MissingEnvironmentIdError();
|
|
@@ -170,6 +174,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
170
174
|
const { wallets } = useWallets.useWallets({
|
|
171
175
|
appLogoUrl,
|
|
172
176
|
appName,
|
|
177
|
+
deepLinkPreference,
|
|
173
178
|
flowNetwork,
|
|
174
179
|
networkConfigurations: serverNetworkConfigurations,
|
|
175
180
|
projectSettings,
|
|
@@ -179,7 +184,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
179
184
|
walletUiUtils,
|
|
180
185
|
});
|
|
181
186
|
const [authMode, setAuthMode] = useLocalStorage.useLocalStorage(localStorage$1.AUTH_MODE, initialAuthenticationMode);
|
|
182
|
-
const { clearPrimaryWalletId, primaryWalletId, setPrimaryWalletId } = usePrimaryWalletId.usePrimaryWalletId();
|
|
187
|
+
const { clearPrimaryWalletId, primaryWalletId, setPrimaryWalletId } = usePrimaryWalletId.usePrimaryWalletId(internalEventsRef.current);
|
|
183
188
|
const { connectWallet, removeConnectedWalletsInfo, connectedWalletsInfo, connectedWallet, getConnectedWalletById, connectedWallets, unlinkConnectedWallet, refreshConnectedWallet, } = useConnectWallet.useConnectWallet({
|
|
184
189
|
authMode,
|
|
185
190
|
clearPrimaryWalletId,
|
|
@@ -230,7 +235,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
230
235
|
walletBook: walletBook$1,
|
|
231
236
|
});
|
|
232
237
|
const setShowAuthFlowWithInit = useSetShowAuthFlowWithInit.useSetShowAuthFlowWithInit({
|
|
238
|
+
isMultiWalletEnabled: multiWallet,
|
|
233
239
|
setShowAuthFlow,
|
|
240
|
+
user,
|
|
234
241
|
wallets,
|
|
235
242
|
});
|
|
236
243
|
// until user completes onboarding, jwt is only stored in onboardingOnlyJwt
|
|
@@ -446,6 +453,8 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
446
453
|
handleUnlinkWallet: authMode === 'connect-only'
|
|
447
454
|
? unlinkConnectedWallet
|
|
448
455
|
: handleUnlinkWallet,
|
|
456
|
+
internalEvents: internalEventsRef,
|
|
457
|
+
internalSetShowAuthFlow: setShowAuthFlow,
|
|
449
458
|
isAuthenticated,
|
|
450
459
|
isBridgeFlow,
|
|
451
460
|
isFullyConnected,
|
|
@@ -508,6 +517,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
508
517
|
showAuthFlow,
|
|
509
518
|
showBridgeWidget,
|
|
510
519
|
showDynamicUserProfile,
|
|
520
|
+
showLockedWalletView,
|
|
511
521
|
showQrcodeModal,
|
|
512
522
|
showWidgetStatePopup,
|
|
513
523
|
signWithEmailWalletName,
|
|
@@ -562,13 +572,12 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
562
572
|
handleUnlinkWallet,
|
|
563
573
|
isAuthenticated,
|
|
564
574
|
isBridgeFlow,
|
|
575
|
+
isFullyConnected,
|
|
565
576
|
isProjectSettingsLoading,
|
|
566
577
|
isSingleWalletAccount,
|
|
567
|
-
isFullyConnected,
|
|
568
578
|
isVerificationInProgress,
|
|
569
|
-
primaryWallet,
|
|
570
|
-
secondaryWallets,
|
|
571
579
|
legacyIsVerifying,
|
|
580
|
+
linkedWallets,
|
|
572
581
|
loadingNetwork,
|
|
573
582
|
loginWithEmail,
|
|
574
583
|
multiWallet,
|
|
@@ -581,6 +590,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
581
590
|
imageUserInAccessList,
|
|
582
591
|
onboardingImageUrl,
|
|
583
592
|
policiesConsentInnerComponent,
|
|
593
|
+
primaryWallet,
|
|
584
594
|
primaryWalletId,
|
|
585
595
|
privacyPolicyUrl,
|
|
586
596
|
projectSettings,
|
|
@@ -588,12 +598,15 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
588
598
|
removeConnectedWalletsInfo,
|
|
589
599
|
rpcProviders,
|
|
590
600
|
sdkHasLoaded,
|
|
601
|
+
secondaryWallets,
|
|
591
602
|
selectedWalletConnector,
|
|
592
603
|
selectedWalletWithAction,
|
|
604
|
+
sendWagmiSettings,
|
|
593
605
|
setAuthMode,
|
|
594
606
|
setAuthorizationViewDisplayOrder,
|
|
595
607
|
setCallback,
|
|
596
608
|
setIsFullyConnected,
|
|
609
|
+
setIsVerificationInProgress,
|
|
597
610
|
setLogInWithEmail,
|
|
598
611
|
setMultiWallet,
|
|
599
612
|
setMultiWalletWidgetState,
|
|
@@ -608,6 +621,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
608
621
|
showAuthFlow,
|
|
609
622
|
showBridgeWidget,
|
|
610
623
|
showDynamicUserProfile,
|
|
624
|
+
showLockedWalletView,
|
|
611
625
|
showQrcodeModal,
|
|
612
626
|
showWidgetStatePopup,
|
|
613
627
|
signWithEmailWalletName,
|
|
@@ -625,7 +639,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
625
639
|
walletsByChain,
|
|
626
640
|
walletsFilter,
|
|
627
641
|
walletsToConnectByChain,
|
|
628
|
-
linkedWallets,
|
|
629
642
|
]);
|
|
630
643
|
React.useEffect(() => {
|
|
631
644
|
const addPrefetch = (attr) => {
|
|
@@ -673,6 +686,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
673
686
|
connectedWallets,
|
|
674
687
|
isBridgeFlow,
|
|
675
688
|
isFullyConnected,
|
|
689
|
+
isMultiWalletEnabled: multiWallet,
|
|
676
690
|
loginWithEmail,
|
|
677
691
|
}), children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(QrCodeContext.QrCodeContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsxs(WalletGroupContext.WalletGroupContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(OAuthIFrameContainer.OAuthIFrameContainer, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
678
692
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { LogLevel } from '@dynamic-labs/logger';
|
|
3
3
|
import { EvmNetwork, SocialProviderFilter } from '@dynamic-labs/types';
|
|
4
|
-
import { WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { DeepLinkVariant, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { AccessDeniedCustomButton, AuthModeType, ChainToWalletMap, DynamicEventsCallbacks, WalletOption } from '../../shared';
|
|
6
6
|
import { SocialNetworkIconType } from '../../utils/functions/getSocialNetworkIcon';
|
|
7
7
|
import { ThemeData, ThemeSetting } from '../ThemeContext';
|
|
@@ -19,6 +19,15 @@ export interface DynamicContextProps {
|
|
|
19
19
|
appName?: string;
|
|
20
20
|
cssOverrides?: string | JSX.Element;
|
|
21
21
|
debugError?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Used to control the type of deep link used when connecting
|
|
24
|
+
* a mobile wallet. Defaults to 'native'. This is useful for
|
|
25
|
+
* example if your app is running in a webview of a native
|
|
26
|
+
* mobile app, and you want to be able to link out to any
|
|
27
|
+
* wallet without having to modify your iOS build config.
|
|
28
|
+
* In this case, you can set this to 'universal'.
|
|
29
|
+
*/
|
|
30
|
+
deepLinkPreference?: DeepLinkVariant;
|
|
22
31
|
defaultNumberOfWalletsToShow?: number;
|
|
23
32
|
displaySiweStatement?: boolean;
|
|
24
33
|
enableVisitTrackingOnConnectOnly?: boolean;
|
|
@@ -36,6 +45,7 @@ export interface DynamicContextProps {
|
|
|
36
45
|
* @default WARN
|
|
37
46
|
*/
|
|
38
47
|
logLevel?: keyof typeof LogLevel;
|
|
48
|
+
showLockedWalletView?: boolean;
|
|
39
49
|
newToWeb3WalletChainMap?: ChainToWalletMap;
|
|
40
50
|
notInTheListImageUrl?: string;
|
|
41
51
|
onboardingImageUrl?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
3
|
+
import { createContext, useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
4
4
|
import { ICONIC_SPRITE_URL } from '@dynamic-labs/iconic';
|
|
5
5
|
import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
|
|
6
6
|
import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
|
|
@@ -90,13 +90,17 @@ import { useVerificationInProgress } from './hooks/useVerificationInProgress/use
|
|
|
90
90
|
import { useCustomerCallbacks } from './useCustomerCallbacks/useCustomerCallbacks.js';
|
|
91
91
|
import { useCustomerAuthFlowCallbacks } from './useCustomerCallbacks/useCustomerAuthFlowCallbacks.js';
|
|
92
92
|
import { validateAuthUser } from './validators.js';
|
|
93
|
+
import { getInternalEvents } from './internalEvents/internalEvents.js';
|
|
93
94
|
|
|
94
95
|
const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = '2762a57b-faa4-41ce-9f16-abff9300e2c9';
|
|
95
96
|
const EMPTY_INITIAL_USER = undefined;
|
|
96
97
|
const DynamicContext = createContext(undefined);
|
|
97
98
|
const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
98
99
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
99
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, } = settings;
|
|
100
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, deepLinkPreference = 'native', walletsByChain, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = true, } = settings;
|
|
101
|
+
// The following event related methods are temporary and should be removed after QNTM-180 is done
|
|
102
|
+
// ============ START REMOVE AFTER QNTM-180 ============
|
|
103
|
+
const internalEventsRef = useRef(getInternalEvents());
|
|
100
104
|
let { walletConnectV1Bridge, appLogoUrl = 'https://demo.dynamic.xyz/assets/dynamic-logo.svg', appName = 'Dynamic Example', } = settings;
|
|
101
105
|
if (!environmentId) {
|
|
102
106
|
throw new MissingEnvironmentIdError();
|
|
@@ -166,6 +170,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
166
170
|
const { wallets } = useWallets({
|
|
167
171
|
appLogoUrl,
|
|
168
172
|
appName,
|
|
173
|
+
deepLinkPreference,
|
|
169
174
|
flowNetwork,
|
|
170
175
|
networkConfigurations: serverNetworkConfigurations,
|
|
171
176
|
projectSettings,
|
|
@@ -175,7 +180,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
175
180
|
walletUiUtils,
|
|
176
181
|
});
|
|
177
182
|
const [authMode, setAuthMode] = useLocalStorage(AUTH_MODE, initialAuthenticationMode);
|
|
178
|
-
const { clearPrimaryWalletId, primaryWalletId, setPrimaryWalletId } = usePrimaryWalletId();
|
|
183
|
+
const { clearPrimaryWalletId, primaryWalletId, setPrimaryWalletId } = usePrimaryWalletId(internalEventsRef.current);
|
|
179
184
|
const { connectWallet, removeConnectedWalletsInfo, connectedWalletsInfo, connectedWallet, getConnectedWalletById, connectedWallets, unlinkConnectedWallet, refreshConnectedWallet, } = useConnectWallet({
|
|
180
185
|
authMode,
|
|
181
186
|
clearPrimaryWalletId,
|
|
@@ -226,7 +231,9 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
226
231
|
walletBook,
|
|
227
232
|
});
|
|
228
233
|
const setShowAuthFlowWithInit = useSetShowAuthFlowWithInit({
|
|
234
|
+
isMultiWalletEnabled: multiWallet,
|
|
229
235
|
setShowAuthFlow,
|
|
236
|
+
user,
|
|
230
237
|
wallets,
|
|
231
238
|
});
|
|
232
239
|
// until user completes onboarding, jwt is only stored in onboardingOnlyJwt
|
|
@@ -442,6 +449,8 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
442
449
|
handleUnlinkWallet: authMode === 'connect-only'
|
|
443
450
|
? unlinkConnectedWallet
|
|
444
451
|
: handleUnlinkWallet,
|
|
452
|
+
internalEvents: internalEventsRef,
|
|
453
|
+
internalSetShowAuthFlow: setShowAuthFlow,
|
|
445
454
|
isAuthenticated,
|
|
446
455
|
isBridgeFlow,
|
|
447
456
|
isFullyConnected,
|
|
@@ -504,6 +513,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
504
513
|
showAuthFlow,
|
|
505
514
|
showBridgeWidget,
|
|
506
515
|
showDynamicUserProfile,
|
|
516
|
+
showLockedWalletView,
|
|
507
517
|
showQrcodeModal,
|
|
508
518
|
showWidgetStatePopup,
|
|
509
519
|
signWithEmailWalletName,
|
|
@@ -558,13 +568,12 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
558
568
|
handleUnlinkWallet,
|
|
559
569
|
isAuthenticated,
|
|
560
570
|
isBridgeFlow,
|
|
571
|
+
isFullyConnected,
|
|
561
572
|
isProjectSettingsLoading,
|
|
562
573
|
isSingleWalletAccount,
|
|
563
|
-
isFullyConnected,
|
|
564
574
|
isVerificationInProgress,
|
|
565
|
-
primaryWallet,
|
|
566
|
-
secondaryWallets,
|
|
567
575
|
legacyIsVerifying,
|
|
576
|
+
linkedWallets,
|
|
568
577
|
loadingNetwork,
|
|
569
578
|
loginWithEmail,
|
|
570
579
|
multiWallet,
|
|
@@ -577,6 +586,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
577
586
|
imageUserInAccessList,
|
|
578
587
|
onboardingImageUrl,
|
|
579
588
|
policiesConsentInnerComponent,
|
|
589
|
+
primaryWallet,
|
|
580
590
|
primaryWalletId,
|
|
581
591
|
privacyPolicyUrl,
|
|
582
592
|
projectSettings,
|
|
@@ -584,12 +594,15 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
584
594
|
removeConnectedWalletsInfo,
|
|
585
595
|
rpcProviders,
|
|
586
596
|
sdkHasLoaded,
|
|
597
|
+
secondaryWallets,
|
|
587
598
|
selectedWalletConnector,
|
|
588
599
|
selectedWalletWithAction,
|
|
600
|
+
sendWagmiSettings,
|
|
589
601
|
setAuthMode,
|
|
590
602
|
setAuthorizationViewDisplayOrder,
|
|
591
603
|
setCallback,
|
|
592
604
|
setIsFullyConnected,
|
|
605
|
+
setIsVerificationInProgress,
|
|
593
606
|
setLogInWithEmail,
|
|
594
607
|
setMultiWallet,
|
|
595
608
|
setMultiWalletWidgetState,
|
|
@@ -604,6 +617,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
604
617
|
showAuthFlow,
|
|
605
618
|
showBridgeWidget,
|
|
606
619
|
showDynamicUserProfile,
|
|
620
|
+
showLockedWalletView,
|
|
607
621
|
showQrcodeModal,
|
|
608
622
|
showWidgetStatePopup,
|
|
609
623
|
signWithEmailWalletName,
|
|
@@ -621,7 +635,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
621
635
|
walletsByChain,
|
|
622
636
|
walletsFilter,
|
|
623
637
|
walletsToConnectByChain,
|
|
624
|
-
linkedWallets,
|
|
625
638
|
]);
|
|
626
639
|
useEffect(() => {
|
|
627
640
|
const addPrefetch = (attr) => {
|
|
@@ -669,6 +682,7 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
|
|
|
669
682
|
connectedWallets,
|
|
670
683
|
isBridgeFlow,
|
|
671
684
|
isFullyConnected,
|
|
685
|
+
isMultiWalletEnabled: multiWallet,
|
|
672
686
|
loginWithEmail,
|
|
673
687
|
}), children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(QrCodeContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(ErrorContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(CaptchaContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsxs(WalletGroupContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(OAuthIFrameContainer, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
674
688
|
};
|
|
@@ -11,12 +11,16 @@ require('react');
|
|
|
11
11
|
require('../../shared/logger.cjs');
|
|
12
12
|
require('@dynamic-labs/wallet-book');
|
|
13
13
|
require('@dynamic-labs/utils');
|
|
14
|
+
var localStorage$1 = require('../../utils/constants/localStorage.cjs');
|
|
14
15
|
require('../../utils/constants/colors.cjs');
|
|
15
|
-
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
16
|
+
var localStorage = require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
16
17
|
require('viem');
|
|
17
18
|
var getAuthToken = require('../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
18
19
|
|
|
19
20
|
let logoutTimer;
|
|
21
|
+
let dynamicContextSettingsTimer;
|
|
22
|
+
let wagmiSettingsTimer;
|
|
23
|
+
const sdkSettingsTimeout = 24 * 60 * 60 * 1000; // 24 hours
|
|
20
24
|
const isAuthTokenExpired = (token) => {
|
|
21
25
|
const decoded = decodeJwt.decodeJwt(token);
|
|
22
26
|
if (!decoded) {
|
|
@@ -54,19 +58,54 @@ const initExpirationTime = (logout) => {
|
|
|
54
58
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
55
59
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
56
60
|
};
|
|
57
|
-
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }) => {
|
|
61
|
+
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, isMultiWalletEnabled, }) => {
|
|
58
62
|
if (loginWithEmail) {
|
|
59
63
|
return 'login-with-email-or-wallet';
|
|
60
64
|
}
|
|
61
65
|
if (isFullyConnected) {
|
|
62
|
-
return 'wallet-list';
|
|
66
|
+
return isMultiWalletEnabled ? 'multi-wallet-wallet-list' : 'wallet-list';
|
|
63
67
|
}
|
|
64
68
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
65
69
|
return 'bridge-welcome';
|
|
66
70
|
}
|
|
67
71
|
return 'wallet-list';
|
|
68
72
|
};
|
|
73
|
+
const setDynamicContextSessionSettings = () => {
|
|
74
|
+
setSessionSettings(localStorage$1.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS);
|
|
75
|
+
dynamicContextSettingsTimer = setTimeout(isDynamicContextSessionSettingExpired, sdkSettingsTimeout);
|
|
76
|
+
};
|
|
77
|
+
const setWagmiSessionSettings = () => {
|
|
78
|
+
setSessionSettings(localStorage$1.WAGMI_LAST_SESSION_SETTINGS);
|
|
79
|
+
wagmiSettingsTimer = setTimeout(isWagmiSessionSettingExpired, sdkSettingsTimeout);
|
|
80
|
+
};
|
|
81
|
+
const setSessionSettings = (lsKey) => {
|
|
82
|
+
const timestamp = new Date().getTime();
|
|
83
|
+
localStorage.LocalStorage.setToLS(lsKey, timestamp.toString());
|
|
84
|
+
};
|
|
85
|
+
const isDynamicContextSessionSettingExpired = () => isSettingExpired(localStorage$1.DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, dynamicContextSettingsTimer);
|
|
86
|
+
const isWagmiSessionSettingExpired = () => isSettingExpired(localStorage$1.WAGMI_LAST_SESSION_SETTINGS, wagmiSettingsTimer);
|
|
87
|
+
const isSettingExpired = (lsKey, timer) => {
|
|
88
|
+
const lastSentTime = localStorage.LocalStorage.getFromLS(lsKey);
|
|
89
|
+
// should set new time
|
|
90
|
+
if (!lastSentTime) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
const lastSentTimestamp = parseInt(lastSentTime);
|
|
94
|
+
const currentTime = new Date().getTime();
|
|
95
|
+
if (currentTime - lastSentTimestamp > sdkSettingsTimeout) {
|
|
96
|
+
// Reset session-related data here
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
localStorage.LocalStorage.removeFromLS(lsKey);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
};
|
|
69
103
|
|
|
70
104
|
exports.getInitialView = getInitialView;
|
|
71
105
|
exports.initExpirationTime = initExpirationTime;
|
|
72
106
|
exports.isAuthTokenExpired = isAuthTokenExpired;
|
|
107
|
+
exports.isDynamicContextSessionSettingExpired = isDynamicContextSessionSettingExpired;
|
|
108
|
+
exports.isWagmiSessionSettingExpired = isWagmiSessionSettingExpired;
|
|
109
|
+
exports.sdkSettingsTimeout = sdkSettingsTimeout;
|
|
110
|
+
exports.setDynamicContextSessionSettings = setDynamicContextSessionSettings;
|
|
111
|
+
exports.setWagmiSessionSettings = setWagmiSessionSettings;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { Wallet } from '../../shared';
|
|
2
2
|
import { ViewType } from '../ViewContext';
|
|
3
|
+
export declare const sdkSettingsTimeout: number;
|
|
3
4
|
export declare const isAuthTokenExpired: (token: string) => boolean;
|
|
4
5
|
export declare const initExpirationTime: (logout: VoidFunction) => void;
|
|
5
|
-
export declare const getInitialView: ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }: {
|
|
6
|
+
export declare const getInitialView: ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, isMultiWalletEnabled, }: {
|
|
6
7
|
connectedWallets: Wallet[];
|
|
7
8
|
loginWithEmail: boolean;
|
|
8
9
|
isBridgeFlow: boolean;
|
|
9
10
|
isFullyConnected: boolean;
|
|
11
|
+
isMultiWalletEnabled: boolean;
|
|
10
12
|
}) => ViewType;
|
|
13
|
+
export declare const setDynamicContextSessionSettings: () => void;
|
|
14
|
+
export declare const setWagmiSessionSettings: () => void;
|
|
15
|
+
export declare const isDynamicContextSessionSettingExpired: () => boolean;
|
|
16
|
+
export declare const isWagmiSessionSettingExpired: () => boolean;
|
|
@@ -7,12 +7,16 @@ import 'react';
|
|
|
7
7
|
import '../../shared/logger.js';
|
|
8
8
|
import '@dynamic-labs/wallet-book';
|
|
9
9
|
import '@dynamic-labs/utils';
|
|
10
|
+
import { DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, WAGMI_LAST_SESSION_SETTINGS } from '../../utils/constants/localStorage.js';
|
|
10
11
|
import '../../utils/constants/colors.js';
|
|
11
|
-
import '../../shared/utils/classes/storage/localStorage.js';
|
|
12
|
+
import { LocalStorage } from '../../shared/utils/classes/storage/localStorage.js';
|
|
12
13
|
import 'viem';
|
|
13
14
|
import { getAuthToken } from '../../utils/functions/getAuthToken/getAuthToken.js';
|
|
14
15
|
|
|
15
16
|
let logoutTimer;
|
|
17
|
+
let dynamicContextSettingsTimer;
|
|
18
|
+
let wagmiSettingsTimer;
|
|
19
|
+
const sdkSettingsTimeout = 24 * 60 * 60 * 1000; // 24 hours
|
|
16
20
|
const isAuthTokenExpired = (token) => {
|
|
17
21
|
const decoded = decodeJwt(token);
|
|
18
22
|
if (!decoded) {
|
|
@@ -50,17 +54,47 @@ const initExpirationTime = (logout) => {
|
|
|
50
54
|
const expiryTimeout = Math.min(expirationTimeInMs, 2147483647);
|
|
51
55
|
logoutTimer = setTimeout(logout, expiryTimeout);
|
|
52
56
|
};
|
|
53
|
-
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, }) => {
|
|
57
|
+
const getInitialView = ({ connectedWallets, loginWithEmail, isBridgeFlow, isFullyConnected, isMultiWalletEnabled, }) => {
|
|
54
58
|
if (loginWithEmail) {
|
|
55
59
|
return 'login-with-email-or-wallet';
|
|
56
60
|
}
|
|
57
61
|
if (isFullyConnected) {
|
|
58
|
-
return 'wallet-list';
|
|
62
|
+
return isMultiWalletEnabled ? 'multi-wallet-wallet-list' : 'wallet-list';
|
|
59
63
|
}
|
|
60
64
|
if (isBridgeFlow && !connectedWallets.length) {
|
|
61
65
|
return 'bridge-welcome';
|
|
62
66
|
}
|
|
63
67
|
return 'wallet-list';
|
|
64
68
|
};
|
|
69
|
+
const setDynamicContextSessionSettings = () => {
|
|
70
|
+
setSessionSettings(DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS);
|
|
71
|
+
dynamicContextSettingsTimer = setTimeout(isDynamicContextSessionSettingExpired, sdkSettingsTimeout);
|
|
72
|
+
};
|
|
73
|
+
const setWagmiSessionSettings = () => {
|
|
74
|
+
setSessionSettings(WAGMI_LAST_SESSION_SETTINGS);
|
|
75
|
+
wagmiSettingsTimer = setTimeout(isWagmiSessionSettingExpired, sdkSettingsTimeout);
|
|
76
|
+
};
|
|
77
|
+
const setSessionSettings = (lsKey) => {
|
|
78
|
+
const timestamp = new Date().getTime();
|
|
79
|
+
LocalStorage.setToLS(lsKey, timestamp.toString());
|
|
80
|
+
};
|
|
81
|
+
const isDynamicContextSessionSettingExpired = () => isSettingExpired(DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, dynamicContextSettingsTimer);
|
|
82
|
+
const isWagmiSessionSettingExpired = () => isSettingExpired(WAGMI_LAST_SESSION_SETTINGS, wagmiSettingsTimer);
|
|
83
|
+
const isSettingExpired = (lsKey, timer) => {
|
|
84
|
+
const lastSentTime = LocalStorage.getFromLS(lsKey);
|
|
85
|
+
// should set new time
|
|
86
|
+
if (!lastSentTime) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const lastSentTimestamp = parseInt(lastSentTime);
|
|
90
|
+
const currentTime = new Date().getTime();
|
|
91
|
+
if (currentTime - lastSentTimestamp > sdkSettingsTimeout) {
|
|
92
|
+
// Reset session-related data here
|
|
93
|
+
clearTimeout(timer);
|
|
94
|
+
LocalStorage.removeFromLS(lsKey);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
};
|
|
65
99
|
|
|
66
|
-
export { getInitialView, initExpirationTime, isAuthTokenExpired };
|
|
100
|
+
export { getInitialView, initExpirationTime, isAuthTokenExpired, isDynamicContextSessionSettingExpired, isWagmiSessionSettingExpired, sdkSettingsTimeout, setDynamicContextSessionSettings, setWagmiSessionSettings };
|