@dynamic-labs/sdk-react-core 0.17.0-RC.18 → 0.17.0-RC.19

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.cjs +9 -9
  3. package/package.js +9 -9
  4. package/package.json +16 -16
  5. package/src/lib/components/ErrorContainer/ErrorContainer.cjs +2 -2
  6. package/src/lib/components/ErrorContainer/ErrorContainer.d.ts +3 -1
  7. package/src/lib/components/ErrorContainer/ErrorContainer.js +2 -2
  8. package/src/lib/components/Input/Input.cjs +6 -3
  9. package/src/lib/components/Input/Input.js +7 -4
  10. package/src/lib/components/Input/Input.types.d.ts +4 -0
  11. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +56 -19
  12. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.d.ts +3 -1
  13. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +57 -20
  14. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  15. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +11 -3
  16. package/src/lib/layout/DynamicAuthLayout/Header/header.js +11 -3
  17. package/src/lib/styles/index.shadow.cjs +1 -1
  18. package/src/lib/styles/index.shadow.js +1 -1
  19. package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.cjs +29 -0
  20. package/src/lib/utils/functions/getReferencedAccount/getReferencedAccount.js +25 -0
  21. package/src/lib/utils/hooks/useWalletConnectors/reconnectSocialWallet.cjs +37 -0
  22. package/src/lib/utils/hooks/useWalletConnectors/reconnectSocialWallet.js +33 -0
  23. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +7 -0
  24. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +8 -1
  25. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +1 -1
  26. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +1 -1
  27. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +3 -8
  28. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +3 -8
  29. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +58 -0
  30. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.d.ts +2 -0
  31. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +54 -0
  32. package/src/lib/views/SocialWrongAccountView/index.d.ts +1 -0
  33. package/src/lib/views/viewToComponentMap.cjs +2 -0
  34. package/src/lib/views/viewToComponentMap.js +2 -0
  35. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +9 -5
  36. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +9 -5
@@ -14,6 +14,7 @@ import { useInternalDynamicContext } from '../../context/DynamicContext/useInter
14
14
  import '@dynamic-labs/multi-wallet';
15
15
  import '../../components/ShadowDOM/ShadowDOM.js';
16
16
  import '../../context/ThemeContext/ThemeContext.js';
17
+ import { classNames } from '../../utils/functions/classNames/classNames.js';
17
18
  import 'react-dom';
18
19
  import 'react-focus-lock';
19
20
  import '../../components/Transition/ZoomTransition/ZoomTransition.js';
@@ -39,17 +40,11 @@ import { getSocialIcon } from '../../utils/functions/getSocialIcon/getSocialIcon
39
40
  const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
40
41
  const SocialRedirectView = () => {
41
42
  const { socialProvider, socialWalletConnector } = useSocialRedirectContext();
42
- const { termsOfServiceUrl, privacyPolicyUrl } = useInternalDynamicContext();
43
+ const { termsOfServiceUrl, privacyPolicyUrl, isAuthenticated } = useInternalDynamicContext();
43
44
  if (!socialWalletConnector || !socialProvider) {
44
45
  return null;
45
46
  }
46
- return (jsxs("div", Object.assign({ style: {
47
- alignItems: 'center',
48
- display: 'flex',
49
- flexDirection: 'column',
50
- justifyContent: 'center',
51
- paddingBottom: '3rem',
52
- } }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxs(Typography, { children: ["Connecting to ", capitalize(socialProvider), "..."] }), jsx(TosAndPp, { mode: 'logging in', privacyPolicyUrl: privacyPolicyUrl, termsOfServiceUrl: termsOfServiceUrl })] })));
47
+ return (jsxs("div", Object.assign({ className: classNames('social-redirect-view__container') }, { children: [jsx(IconWithSpinner, { iconSize: 64, Icon: getSocialIcon(socialProvider), isSpinning: true }), jsxs(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-redirect-view__title') }, { children: ["Connecting to ", capitalize(socialProvider), "..."] })), jsx(TosAndPp, { mode: isAuthenticated ? 'connecting' : 'logging in', privacyPolicyUrl: privacyPolicyUrl, termsOfServiceUrl: termsOfServiceUrl })] })));
53
48
  };
54
49
 
55
50
  export { SocialRedirectView };
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+ var Typography = require('../../components/Typography/Typography.cjs');
8
+ require('@dynamic-labs/sdk-api');
9
+ require('../../shared/logger.cjs');
10
+ require('@dynamic-labs/iconic');
11
+ require('@dynamic-labs/wallet-connector-core');
12
+ require('../../context/ViewContext/ViewContext.cjs');
13
+ require('@dynamic-labs/utils');
14
+ require('../../utils/constants/colors.cjs');
15
+ require('ethers');
16
+ require('../../shared/consts/index.cjs');
17
+ require('../../context/DynamicContext/DynamicContext.cjs');
18
+ require('@dynamic-labs/multi-wallet');
19
+ require('../../components/ShadowDOM/ShadowDOM.cjs');
20
+ require('../../context/ThemeContext/ThemeContext.cjs');
21
+ var classNames = require('../../utils/functions/classNames/classNames.cjs');
22
+ require('react-dom');
23
+ require('react-focus-lock');
24
+ require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
25
+ require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
26
+ require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
27
+ require('../../config/ApiEndpoint.cjs');
28
+ require('@dynamic-labs/rpc-providers');
29
+ require('../../context/ErrorContext/ErrorContext.cjs');
30
+ require('../../context/MockContext/MockContext.cjs');
31
+ require('../../context/CaptchaContext/CaptchaContext.cjs');
32
+ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
33
+ var Button = require('../../components/Button/Button.cjs');
34
+ require('../../components/IconButton/IconButton.cjs');
35
+ require('../../components/Alert/Alert.cjs');
36
+ var IconWithSpinner = require('../../components/IconWithSpinner/IconWithSpinner.cjs');
37
+ require('../../components/Popper/Popper/Popper.cjs');
38
+ require('../../components/Popper/PopperContext/PopperContext.cjs');
39
+ require('@dynamic-labs/wallet-book');
40
+ require('../../components/SendBalanceForm/SendBalanceForm.cjs');
41
+ var SocialRedirectContext = require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
42
+ var getSocialIcon = require('../../utils/functions/getSocialIcon/getSocialIcon.cjs');
43
+
44
+ const SocialWrongAccountView = () => {
45
+ const [tryAgainClicked, setTryAgainClicked] = React.useState(false);
46
+ const { socialWalletConnector, socialAccount } = SocialRedirectContext.useSocialRedirectContext();
47
+ if (!socialAccount || !socialWalletConnector)
48
+ return null;
49
+ return (jsxRuntime.jsxs("div", Object.assign({ className: classNames.classNames('social-wrong-account-view__container') }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon.getSocialIcon(socialAccount.oauthProvider), isSpinning: tryAgainClicked, iconSize: 64 }), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames.classNames('social-wrong-account-view__title') }, { children: "Whoops. Wrong Account" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames.classNames('social-wrong-account-view__copy') }, { children: "You must connect with the same account you originally signed in with." })), jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames.classNames('social-wrong-account-view__copy') }, { children: ["Please connect with: ", jsxRuntime.jsx("b", { children: socialAccount.oauthUsername })] })), jsxRuntime.jsx(Button.Button, Object.assign({ buttonClassName: 'social-wrong-account-view__button', buttonRounded: 'medium', buttonVariant: 'primary', buttonPadding: 'large', expanded: true, typographyProps: {
50
+ variant: 'button_primary',
51
+ weight: 'medium',
52
+ }, disabled: tryAgainClicked, onClick: () => {
53
+ setTryAgainClicked(true);
54
+ socialWalletConnector.connect(socialAccount.oauthProvider);
55
+ } }, { children: "Try again" }))] })));
56
+ };
57
+
58
+ exports.SocialWrongAccountView = SocialWrongAccountView;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const SocialWrongAccountView: () => JSX.Element | null;
@@ -0,0 +1,54 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { Typography } from '../../components/Typography/Typography.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 '@dynamic-labs/utils';
10
+ import '../../utils/constants/colors.js';
11
+ import 'ethers';
12
+ import '../../shared/consts/index.js';
13
+ import '../../context/DynamicContext/DynamicContext.js';
14
+ import '@dynamic-labs/multi-wallet';
15
+ import '../../components/ShadowDOM/ShadowDOM.js';
16
+ import '../../context/ThemeContext/ThemeContext.js';
17
+ import { classNames } from '../../utils/functions/classNames/classNames.js';
18
+ import 'react-dom';
19
+ import 'react-focus-lock';
20
+ import '../../components/Transition/ZoomTransition/ZoomTransition.js';
21
+ import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
22
+ import '../../components/Transition/OpacityTransition/OpacityTransition.js';
23
+ import '../../config/ApiEndpoint.js';
24
+ import '@dynamic-labs/rpc-providers';
25
+ import '../../context/ErrorContext/ErrorContext.js';
26
+ import '../../context/MockContext/MockContext.js';
27
+ import '../../context/CaptchaContext/CaptchaContext.js';
28
+ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
29
+ import { Button } from '../../components/Button/Button.js';
30
+ import '../../components/IconButton/IconButton.js';
31
+ import '../../components/Alert/Alert.js';
32
+ import { IconWithSpinner } from '../../components/IconWithSpinner/IconWithSpinner.js';
33
+ import '../../components/Popper/Popper/Popper.js';
34
+ import '../../components/Popper/PopperContext/PopperContext.js';
35
+ import '@dynamic-labs/wallet-book';
36
+ import '../../components/SendBalanceForm/SendBalanceForm.js';
37
+ import { useSocialRedirectContext } from '../../context/SocialRedirectContext/SocialRedirectContext.js';
38
+ import { getSocialIcon } from '../../utils/functions/getSocialIcon/getSocialIcon.js';
39
+
40
+ const SocialWrongAccountView = () => {
41
+ const [tryAgainClicked, setTryAgainClicked] = useState(false);
42
+ const { socialWalletConnector, socialAccount } = useSocialRedirectContext();
43
+ if (!socialAccount || !socialWalletConnector)
44
+ return null;
45
+ return (jsxs("div", Object.assign({ className: classNames('social-wrong-account-view__container') }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(socialAccount.oauthProvider), isSpinning: tryAgainClicked, iconSize: 64 }), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: classNames('social-wrong-account-view__title') }, { children: "Whoops. Wrong Account" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames('social-wrong-account-view__copy') }, { children: "You must connect with the same account you originally signed in with." })), jsxs(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', className: classNames('social-wrong-account-view__copy') }, { children: ["Please connect with: ", jsx("b", { children: socialAccount.oauthUsername })] })), jsx(Button, Object.assign({ buttonClassName: 'social-wrong-account-view__button', buttonRounded: 'medium', buttonVariant: 'primary', buttonPadding: 'large', expanded: true, typographyProps: {
46
+ variant: 'button_primary',
47
+ weight: 'medium',
48
+ }, disabled: tryAgainClicked, onClick: () => {
49
+ setTryAgainClicked(true);
50
+ socialWalletConnector.connect(socialAccount.oauthProvider);
51
+ } }, { children: "Try again" }))] })));
52
+ };
53
+
54
+ export { SocialWrongAccountView };
@@ -0,0 +1 @@
1
+ export * from './SocialWrongAccountView';
@@ -22,6 +22,7 @@ var WalletList = require('./WalletList/WalletList.cjs');
22
22
  var NoAccess = require('./NoAccess/NoAccess.cjs');
23
23
  var WalletSignSpinnerView = require('./WalletSignSpinnerView/WalletSignSpinnerView.cjs');
24
24
  var WalletUsedView = require('./WalletUsedView/WalletUsedView.cjs');
25
+ var SocialWrongAccountView = require('./SocialWrongAccountView/SocialWrongAccountView.cjs');
25
26
 
26
27
  const viewToComponentMap = {
27
28
  captcha: jsxRuntime.jsx(CaptchaVerifyUser.CaptchaVerifyUser, {}),
@@ -41,6 +42,7 @@ const viewToComponentMap = {
41
42
  'pending-signature-without-back-button': jsxRuntime.jsx(PendingSignatureView.PendingSignatureView, {}),
42
43
  'qr-code': jsxRuntime.jsx(QrCodeView.QrCodeView, {}),
43
44
  'social-redirect-view': jsxRuntime.jsx(SocialRedirectView.SocialRedirectView, {}),
45
+ 'social-wrong-account': jsxRuntime.jsx(SocialWrongAccountView.SocialWrongAccountView, {}),
44
46
  'update-email': jsxRuntime.jsx(EmailUpdate.EmailUpdate, {}),
45
47
  'verify-email': jsxRuntime.jsx(EmailVerification.EmailVerification, {}),
46
48
  'wait-for-email-confirmation-view': jsxRuntime.jsx(EmailConfirmationWaitingView.EmailConfirmationWaitingView, {}),
@@ -18,6 +18,7 @@ import { WalletList } from './WalletList/WalletList.js';
18
18
  import { NoAccess } from './NoAccess/NoAccess.js';
19
19
  import { WalletSignSpinnerView } from './WalletSignSpinnerView/WalletSignSpinnerView.js';
20
20
  import { WalletUsedView } from './WalletUsedView/WalletUsedView.js';
21
+ import { SocialWrongAccountView } from './SocialWrongAccountView/SocialWrongAccountView.js';
21
22
 
22
23
  const viewToComponentMap = {
23
24
  captcha: jsx(CaptchaVerifyUser, {}),
@@ -37,6 +38,7 @@ const viewToComponentMap = {
37
38
  'pending-signature-without-back-button': jsx(PendingSignatureView, {}),
38
39
  'qr-code': jsx(QrCodeView, {}),
39
40
  'social-redirect-view': jsx(SocialRedirectView, {}),
41
+ 'social-wrong-account': jsx(SocialWrongAccountView, {}),
40
42
  'update-email': jsx(EmailUpdate, {}),
41
43
  'verify-email': jsx(EmailVerification, {}),
42
44
  'wait-for-email-confirmation-view': jsx(EmailConfirmationWaitingView, {}),
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../../../../../../_virtual/_tslib.cjs');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
8
  require('@dynamic-labs/iconic');
8
9
  require('../../../../context/ViewContext/ViewContext.cjs');
9
10
  require('react');
@@ -12,7 +13,6 @@ var unlink = require('../../../../shared/assets/unlink.cjs');
12
13
  var switchHorizontal = require('../../../../shared/assets/switch-horizontal.cjs');
13
14
  require('@dynamic-labs/sdk-api');
14
15
  require('../../../../shared/logger.cjs');
15
- require('@dynamic-labs/wallet-connector-core');
16
16
  var shortenWalletAddress = require('../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
17
17
  require('@dynamic-labs/utils');
18
18
  require('../../../../utils/constants/colors.cjs');
@@ -44,6 +44,7 @@ var DotsMenu = require('../DotsMenu/DotsMenu.cjs');
44
44
  var helpers = require('../../helpers/helpers.cjs');
45
45
  var WalletIconWithStatus = require('../WalletIconWithStatus/WalletIconWithStatus.cjs');
46
46
 
47
+ const isEmbeddedConnector = (connector) => walletConnectorCore.isSocialWalletConnector(connector) || walletConnectorCore.isEmailOTPWalletConnector(connector);
47
48
  const Wallet = ({ wallet, ens }) => {
48
49
  const { id: walletId, connector, address, connected } = wallet;
49
50
  const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setShowWidgetStatePopup, setSelectedWalletWithAction, } = useInternalDynamicContext.useInternalDynamicContext();
@@ -66,11 +67,14 @@ const Wallet = ({ wallet, ens }) => {
66
67
  Icon: jsxRuntime.jsx(copy.ReactComponent, {}),
67
68
  callback: () => helpers.copyToClipboard(address || ''),
68
69
  text: 'Copy address',
69
- }, {
70
- Icon: jsxRuntime.jsx(unlink.ReactComponent, {}),
71
- callback: () => setSelectedWalletWithAction({ action: 'unlink', wallet }),
72
- text: 'Unlink from my account',
73
70
  });
71
+ if (!isEmbeddedConnector(connector)) {
72
+ options.push({
73
+ Icon: jsxRuntime.jsx(unlink.ReactComponent, {}),
74
+ callback: () => setSelectedWalletWithAction({ action: 'unlink', wallet }),
75
+ text: 'Unlink from my account',
76
+ });
77
+ }
74
78
  const onSelectWalletClick = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
75
79
  var _a;
76
80
  if (connector.connectedChain === 'FLOW') {
@@ -1,5 +1,6 @@
1
1
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
+ import { isSocialWalletConnector, isEmailOTPWalletConnector } from '@dynamic-labs/wallet-connector-core';
3
4
  import '@dynamic-labs/iconic';
4
5
  import '../../../../context/ViewContext/ViewContext.js';
5
6
  import 'react';
@@ -8,7 +9,6 @@ import { ReactComponent as SvgUnlink } from '../../../../shared/assets/unlink.js
8
9
  import { ReactComponent as SvgSwitchHorizontal } from '../../../../shared/assets/switch-horizontal.js';
9
10
  import '@dynamic-labs/sdk-api';
10
11
  import '../../../../shared/logger.js';
11
- import '@dynamic-labs/wallet-connector-core';
12
12
  import { shortenWalletAddress } from '../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
13
13
  import '@dynamic-labs/utils';
14
14
  import '../../../../utils/constants/colors.js';
@@ -40,6 +40,7 @@ import { DotsMenu } from '../DotsMenu/DotsMenu.js';
40
40
  import { copyToClipboard } from '../../helpers/helpers.js';
41
41
  import { WalletIconWithStatus } from '../WalletIconWithStatus/WalletIconWithStatus.js';
42
42
 
43
+ const isEmbeddedConnector = (connector) => isSocialWalletConnector(connector) || isEmailOTPWalletConnector(connector);
43
44
  const Wallet = ({ wallet, ens }) => {
44
45
  const { id: walletId, connector, address, connected } = wallet;
45
46
  const { computeConnectedStateForWallets, setPrimaryWallet, setSelectedWalletConnector, setShowWidgetStatePopup, setSelectedWalletWithAction, } = useInternalDynamicContext();
@@ -62,11 +63,14 @@ const Wallet = ({ wallet, ens }) => {
62
63
  Icon: jsx(SvgCopy, {}),
63
64
  callback: () => copyToClipboard(address || ''),
64
65
  text: 'Copy address',
65
- }, {
66
- Icon: jsx(SvgUnlink, {}),
67
- callback: () => setSelectedWalletWithAction({ action: 'unlink', wallet }),
68
- text: 'Unlink from my account',
69
66
  });
67
+ if (!isEmbeddedConnector(connector)) {
68
+ options.push({
69
+ Icon: jsx(SvgUnlink, {}),
70
+ callback: () => setSelectedWalletWithAction({ action: 'unlink', wallet }),
71
+ text: 'Unlink from my account',
72
+ });
73
+ }
70
74
  const onSelectWalletClick = () => __awaiter(void 0, void 0, void 0, function* () {
71
75
  var _a;
72
76
  if (connector.connectedChain === 'FLOW') {