@dynamic-labs/sdk-react-core 4.91.0 → 4.91.1

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.
@@ -84,7 +84,10 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
84
84
  React.useEffect(() => {
85
85
  if (!dustSyncing)
86
86
  return undefined;
87
- const id = setInterval(() => setDustPollTick((tick) => tick + 1), 15000);
87
+ // Poll frequently while syncing so the gauge appears within a couple
88
+ // seconds of dust completing (sync now finishes in ~4s). The effect stops
89
+ // the moment `dustSyncing` flips false, so this adds no steady-state load.
90
+ const id = setInterval(() => setDustPollTick((tick) => tick + 1), 2500);
88
91
  return () => clearInterval(id);
89
92
  }, [dustSyncing]);
90
93
  // `registerDust` is a WaaS-only connector method (external/injected Midnight
@@ -134,7 +137,7 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
134
137
  .join(' ') }, segmentKey))) })] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
135
138
  }
136
139
  if (isWaasWallet) {
137
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_generating', children: t('dyn_active_wallet_info.midnight_dust_generating') })] }) }), jsxRuntime.jsx(Button.Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
140
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust', children: [jsxRuntime.jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxRuntime.jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsxRuntime.jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsxRuntime.jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsxRuntime.jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_not_registered', children: t('dyn_active_wallet_info.midnight_dust_not_registered') })] }) }), jsxRuntime.jsx(Button.Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsxRuntime.jsx("div", { className: 'active-midnight-balance__divider' })] }));
138
141
  }
139
142
  return null;
140
143
  };
@@ -80,7 +80,10 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
80
80
  useEffect(() => {
81
81
  if (!dustSyncing)
82
82
  return undefined;
83
- const id = setInterval(() => setDustPollTick((tick) => tick + 1), 15000);
83
+ // Poll frequently while syncing so the gauge appears within a couple
84
+ // seconds of dust completing (sync now finishes in ~4s). The effect stops
85
+ // the moment `dustSyncing` flips false, so this adds no steady-state load.
86
+ const id = setInterval(() => setDustPollTick((tick) => tick + 1), 2500);
84
87
  return () => clearInterval(id);
85
88
  }, [dustSyncing]);
86
89
  // `registerDust` is a WaaS-only connector method (external/injected Midnight
@@ -130,7 +133,7 @@ const ActiveMidnightWalletBalance = ({ isLoading = false, }) => {
130
133
  .join(' ') }, segmentKey))) })] }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
131
134
  }
132
135
  if (isWaasWallet) {
133
- return (jsxs(Fragment, { children: [jsxs("div", { className: 'active-midnight-balance__dust', children: [jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_generating', children: t('dyn_active_wallet_info.midnight_dust_generating') })] }) }), jsx(Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
136
+ return (jsxs(Fragment, { children: [jsxs("div", { className: 'active-midnight-balance__dust', children: [jsx("div", { className: 'active-midnight-balance__dust-header', children: jsxs("div", { className: 'active-midnight-balance__dust-title', children: [jsx("svg", { className: 'active-midnight-balance__dust-icon', width: '12', height: '12', viewBox: '0 0 24 24', children: jsx("path", { d: 'M13 2L3 14h9l-1 8 10-12h-9l1-8z' }) }), jsx("span", { className: 'active-midnight-balance__dust-label', "data-copykey": 'dyn_active_wallet_info.midnight_dust_not_registered', children: t('dyn_active_wallet_info.midnight_dust_not_registered') })] }) }), jsx(Button, { buttonPadding: 'small', buttonVariant: 'secondary', buttonClassName: 'active-midnight-balance__register-dust-button', onClick: handleRegisterDust, "data-copykey": 'dyn_active_wallet_info.midnight_register_dust', children: t('dyn_active_wallet_info.midnight_register_dust') })] }), jsx("div", { className: 'active-midnight-balance__divider' })] }));
134
137
  }
135
138
  return null;
136
139
  };
@@ -4,7 +4,10 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
7
8
  var reactI18next = require('react-i18next');
9
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
10
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
11
  var CopyButton = require('../../../../components/CopyButton/CopyButton.cjs');
9
12
  var IconButton = require('../../../../components/IconButton/IconButton.cjs');
10
13
  var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
@@ -12,13 +15,14 @@ var QRCode = require('../../../../components/QRCode/QRCode.cjs');
12
15
  var Typography = require('../../../../components/Typography/Typography.cjs');
13
16
  require('../../../../context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
14
17
  var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
15
- require('react');
16
18
  var arrowLeft = require('../../../../shared/assets/arrow-left.cjs');
17
19
  var copy = require('../../../../shared/assets/copy.cjs');
18
20
  var embeddedWalletIcon = require('../../../../shared/assets/embedded-wallet-icon.cjs');
19
21
  require('@dynamic-labs/iconic');
20
22
  require('../../../../context/ViewContext/ViewContext.cjs');
21
23
  var shortenWalletAddress = require('../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
24
+ var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
25
+ var getWalletAdditionalAddressByType = require('../../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.cjs');
22
26
  var usePromise = require('../../../../utils/hooks/usePromise/usePromise.cjs');
23
27
  var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
24
28
  var useFetchChain = require('../../hooks/useFetchChain/useFetchChain.cjs');
@@ -30,13 +34,25 @@ const DepositView = () => {
30
34
  const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
31
35
  const { chain } = useFetchChain.useFetchChain(walletConnector);
32
36
  const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
37
+ const [midnightAddressType, setMidnightAddressType] = React.useState('unshielded');
33
38
  const { data: ens } = usePromise.usePromise(() => getNameService(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address), { deps: [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address], initialData: undefined });
34
39
  const ensName = (_a = ens === null || ens === void 0 ? void 0 : ens.name) !== null && _a !== void 0 ? _a : null;
35
40
  if (!primaryWallet) {
36
41
  return null;
37
42
  }
43
+ const shieldedAddress = walletConnectorCore.isMidnightWallet(primaryWallet)
44
+ ? getWalletAdditionalAddressByType.getWalletAdditionalAddressByType(sdkApiCore.WalletAddressType.MidnightShielded, primaryWallet)
45
+ : undefined;
46
+ const showMidnightToggle = Boolean(shieldedAddress);
47
+ const depositAddress = showMidnightToggle && midnightAddressType === 'shielded' && shieldedAddress
48
+ ? shieldedAddress
49
+ : primaryWallet.address;
38
50
  const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', id: 'back-button', "data-testid": 'back-button', onClick: () => setDynamicWidgetView('choose-wallet-funding-method'), children: jsxRuntime.jsx(arrowLeft.ReactComponent, {}) }));
39
- return (jsxRuntime.jsxs("div", { className: 'deposit-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxRuntime.jsxs("div", { className: 'deposit-view__content', children: [jsxRuntime.jsx(QRCode.QRCode, { className: 'deposit-view__content__qr-code', value: primaryWallet.address, Icon: jsxRuntime.jsx(embeddedWalletIcon.ReactComponent, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsxRuntime.jsx(Typography.Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsxRuntime.jsx(Typography.Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress.shortenWalletAddress(primaryWallet.address) }), jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'text', textToCopy: primaryWallet.address, className: 'deposit-view__content__address__wrapper__copy', children: jsxRuntime.jsx(copy.ReactComponent, { "data-testid": 'copy-address' }) })] })] }), jsxRuntime.jsxs(Typography.Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
51
+ return (jsxRuntime.jsxs("div", { className: 'deposit-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxRuntime.jsxs("div", { className: 'deposit-view__content', children: [showMidnightToggle && (jsxRuntime.jsxs("div", { className: 'deposit-view__content__toggle', children: [jsxRuntime.jsx("button", { type: 'button', "data-testid": 'deposit-toggle-unshielded', className: classNames.classNames('deposit-view__content__toggle__option', {
52
+ 'deposit-view__content__toggle__option--active': midnightAddressType === 'unshielded',
53
+ }), "data-copykey": 'dyn_active_wallet_info.midnight_unshielded_address', onClick: () => setMidnightAddressType('unshielded'), children: t('dyn_active_wallet_info.midnight_unshielded_address') }), jsxRuntime.jsx("button", { type: 'button', "data-testid": 'deposit-toggle-shielded', className: classNames.classNames('deposit-view__content__toggle__option', {
54
+ 'deposit-view__content__toggle__option--active': midnightAddressType === 'shielded',
55
+ }), "data-copykey": 'dyn_active_wallet_info.midnight_shielded_address', onClick: () => setMidnightAddressType('shielded'), children: t('dyn_active_wallet_info.midnight_shielded_address') })] })), jsxRuntime.jsx(QRCode.QRCode, { className: 'deposit-view__content__qr-code', value: depositAddress, Icon: jsxRuntime.jsx(embeddedWalletIcon.ReactComponent, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsxRuntime.jsx(Typography.Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxRuntime.jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsxRuntime.jsx(Typography.Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress.shortenWalletAddress(depositAddress) }), jsxRuntime.jsx(CopyButton.CopyButton, { variant: 'text', textToCopy: depositAddress, className: 'deposit-view__content__address__wrapper__copy', children: jsxRuntime.jsx(copy.ReactComponent, { "data-testid": 'copy-address' }) })] })] }), jsxRuntime.jsxs(Typography.Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
40
56
  };
41
57
 
42
58
  exports.DepositView = DepositView;
@@ -1,6 +1,9 @@
1
1
  'use client'
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
5
+ import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
6
+ import { isMidnightWallet } from '@dynamic-labs/wallet-connector-core';
4
7
  import { CopyButton } from '../../../../components/CopyButton/CopyButton.js';
5
8
  import { IconButton } from '../../../../components/IconButton/IconButton.js';
6
9
  import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
@@ -8,13 +11,14 @@ import { QRCode } from '../../../../components/QRCode/QRCode.js';
8
11
  import { Typography } from '../../../../components/Typography/Typography.js';
9
12
  import '../../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
10
13
  import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
11
- import 'react';
12
14
  import { ReactComponent as SvgArrowLeft } from '../../../../shared/assets/arrow-left.js';
13
15
  import { ReactComponent as SvgCopy } from '../../../../shared/assets/copy.js';
14
16
  import { ReactComponent as SvgEmbeddedWalletIcon } from '../../../../shared/assets/embedded-wallet-icon.js';
15
17
  import '@dynamic-labs/iconic';
16
18
  import '../../../../context/ViewContext/ViewContext.js';
17
19
  import { shortenWalletAddress } from '../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
20
+ import { classNames } from '../../../../utils/functions/classNames/classNames.js';
21
+ import { getWalletAdditionalAddressByType } from '../../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.js';
18
22
  import { usePromise } from '../../../../utils/hooks/usePromise/usePromise.js';
19
23
  import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
20
24
  import { useFetchChain } from '../../hooks/useFetchChain/useFetchChain.js';
@@ -26,13 +30,25 @@ const DepositView = () => {
26
30
  const walletConnector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
27
31
  const { chain } = useFetchChain(walletConnector);
28
32
  const { setDynamicWidgetView } = useWidgetContext();
33
+ const [midnightAddressType, setMidnightAddressType] = useState('unshielded');
29
34
  const { data: ens } = usePromise(() => getNameService(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address), { deps: [primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address], initialData: undefined });
30
35
  const ensName = (_a = ens === null || ens === void 0 ? void 0 : ens.name) !== null && _a !== void 0 ? _a : null;
31
36
  if (!primaryWallet) {
32
37
  return null;
33
38
  }
39
+ const shieldedAddress = isMidnightWallet(primaryWallet)
40
+ ? getWalletAdditionalAddressByType(WalletAddressType.MidnightShielded, primaryWallet)
41
+ : undefined;
42
+ const showMidnightToggle = Boolean(shieldedAddress);
43
+ const depositAddress = showMidnightToggle && midnightAddressType === 'shielded' && shieldedAddress
44
+ ? shieldedAddress
45
+ : primaryWallet.address;
34
46
  const backButton = (jsx(IconButton, { type: 'button', id: 'back-button', "data-testid": 'back-button', onClick: () => setDynamicWidgetView('choose-wallet-funding-method'), children: jsx(SvgArrowLeft, {}) }));
35
- return (jsxs("div", { className: 'deposit-view', children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxs("div", { className: 'deposit-view__content', children: [jsx(QRCode, { className: 'deposit-view__content__qr-code', value: primaryWallet.address, Icon: jsx(SvgEmbeddedWalletIcon, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsx(Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsx(Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress(primaryWallet.address) }), jsx(CopyButton, { variant: 'text', textToCopy: primaryWallet.address, className: 'deposit-view__content__address__wrapper__copy', children: jsx(SvgCopy, { "data-testid": 'copy-address' }) })] })] }), jsxs(Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
47
+ return (jsxs("div", { className: 'deposit-view', children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', copykey: 'dyn_deposit.title', children: t('dyn_deposit.title') }) }), jsxs("div", { className: 'deposit-view__content', children: [showMidnightToggle && (jsxs("div", { className: 'deposit-view__content__toggle', children: [jsx("button", { type: 'button', "data-testid": 'deposit-toggle-unshielded', className: classNames('deposit-view__content__toggle__option', {
48
+ 'deposit-view__content__toggle__option--active': midnightAddressType === 'unshielded',
49
+ }), "data-copykey": 'dyn_active_wallet_info.midnight_unshielded_address', onClick: () => setMidnightAddressType('unshielded'), children: t('dyn_active_wallet_info.midnight_unshielded_address') }), jsx("button", { type: 'button', "data-testid": 'deposit-toggle-shielded', className: classNames('deposit-view__content__toggle__option', {
50
+ 'deposit-view__content__toggle__option--active': midnightAddressType === 'shielded',
51
+ }), "data-copykey": 'dyn_active_wallet_info.midnight_shielded_address', onClick: () => setMidnightAddressType('shielded'), children: t('dyn_active_wallet_info.midnight_shielded_address') })] })), jsx(QRCode, { className: 'deposit-view__content__qr-code', value: depositAddress, Icon: jsx(SvgEmbeddedWalletIcon, {}), logoSize: 40, logoMargin: 64, size: 215 }), jsxs("div", { className: 'deposit-view__content__address', children: [ensName && (jsx(Typography, { className: 'deposit-view__content__address__ens', variant: 'title', children: ensName })), jsxs("div", { className: 'deposit-view__content__address__wrapper', children: [jsx(Typography, { "data-testid": 'deposit-view-address', variant: 'title', weight: 'medium', className: 'deposit-view__content__address__wrapper__text', children: shortenWalletAddress(depositAddress) }), jsx(CopyButton, { variant: 'text', textToCopy: depositAddress, className: 'deposit-view__content__address__wrapper__copy', children: jsx(SvgCopy, { "data-testid": 'copy-address' }) })] })] }), jsxs(Typography, { className: 'deposit-view__content__network', variant: 'body_small', color: 'secondary', copykey: 'dyn_deposit.receive_funds_on', children: [t('dyn_deposit.receive_funds_on'), chain === null || chain === void 0 ? void 0 : chain.name] })] })] }));
36
52
  };
37
53
 
38
54
  export { DepositView };