@dynamic-labs/sdk-react-core 1.0.6 → 1.0.8

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 (57) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +12 -12
  5. package/src/index.cjs +10 -8
  6. package/src/index.js +5 -4
  7. package/src/lib/Main.cjs +1 -1
  8. package/src/lib/Main.js +1 -1
  9. package/src/lib/components/InlineWidget/components/InlineWidgetButton/InlineWidgetButton.d.ts +2 -1
  10. package/src/lib/components/MenuList/Dropdown/Dropdown.cjs +1 -1
  11. package/src/lib/components/MenuList/Dropdown/Dropdown.js +1 -1
  12. package/src/lib/components/SyncPasskeyFlow/SyncPasskeyFlow.cjs +2 -2
  13. package/src/lib/components/SyncPasskeyFlow/SyncPasskeyFlow.js +2 -2
  14. package/src/lib/components/WalletInformationCard/WalletInformationCard.cjs +3 -1
  15. package/src/lib/components/WalletInformationCard/WalletInformationCard.d.ts +2 -1
  16. package/src/lib/components/WalletInformationCard/WalletInformationCard.js +3 -1
  17. package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -2
  18. package/src/lib/context/DynamicContext/DynamicContext.js +2 -2
  19. package/src/lib/data/api.cjs +2 -2
  20. package/src/lib/data/api.d.ts +1 -0
  21. package/src/lib/data/api.js +2 -2
  22. package/src/lib/locale/en/translation.cjs +34 -0
  23. package/src/lib/locale/en/translation.d.ts +34 -0
  24. package/src/lib/locale/en/translation.js +34 -0
  25. package/src/lib/shared/utils/hooks/index.d.ts +5 -4
  26. package/src/lib/shared/utils/hooks/useThrottle/index.d.ts +1 -0
  27. package/src/lib/shared/utils/hooks/useThrottle/useThrottle.cjs +29 -0
  28. package/src/lib/shared/utils/hooks/useThrottle/useThrottle.d.ts +8 -0
  29. package/src/lib/shared/utils/hooks/useThrottle/useThrottle.js +25 -0
  30. package/src/lib/utils/functions/getWalletIdentifier/getWalletIdentifier.cjs +1 -1
  31. package/src/lib/utils/functions/getWalletIdentifier/getWalletIdentifier.d.ts +1 -1
  32. package/src/lib/utils/functions/getWalletIdentifier/getWalletIdentifier.js +1 -1
  33. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +13 -2
  34. package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +13 -2
  35. package/src/lib/utils/hooks/useColorSchemePreference/useColorSchemePreference.cjs +1 -1
  36. package/src/lib/utils/hooks/useColorSchemePreference/useColorSchemePreference.js +1 -1
  37. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +14 -6
  38. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +14 -6
  39. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +15 -1
  40. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +16 -2
  41. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +8 -8
  42. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +8 -8
  43. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +4 -3
  44. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +4 -3
  45. package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.cjs +65 -45
  46. package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.d.ts +5 -7
  47. package/src/lib/utils/hooks/useWalletsConnectionState/useWalletsConnectionState.js +66 -46
  48. package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.cjs +3 -2
  49. package/src/lib/widgets/DynamicBridgeWidget/DynamicBridgeWidget.js +3 -2
  50. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.cjs +10 -5
  51. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCard/DynamicBridgeWalletCard.js +11 -6
  52. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.cjs +6 -5
  53. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWalletCardBody/DynamicBridgeWalletCardBody.js +6 -5
  54. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.cjs +5 -2
  55. package/src/lib/widgets/DynamicBridgeWidget/components/DynamicBridgeWidgetEmptyCard/DynamicBridgeWidgetEmptyCard.js +5 -2
  56. package/src/lib/widgets/DynamicBridgeWidget/views/ProfileView/ProfileView.cjs +3 -1
  57. package/src/lib/widgets/DynamicBridgeWidget/views/ProfileView/ProfileView.js +3 -1
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
6
  var React = require('react');
7
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
8
  require('@dynamic-labs/sdk-api');
8
- var logger = require('../../../shared/logger.cjs');
9
+ require('../../../shared/logger.cjs');
9
10
  require('@dynamic-labs/iconic');
10
- require('@dynamic-labs/wallet-connector-core');
11
11
  require('react/jsx-runtime');
12
12
  require('../../../context/ViewContext/ViewContext.cjs');
13
13
  require('@dynamic-labs/wallet-book');
@@ -15,6 +15,7 @@ require('../../constants/colors.cjs');
15
15
  require('../../../shared/utils/classes/storage/localStorage.cjs');
16
16
  require('viem');
17
17
  require('@dynamic-labs/utils');
18
+ var useThrottle = require('../../../shared/utils/hooks/useThrottle/useThrottle.cjs');
18
19
  require('../../../shared/consts/index.cjs');
19
20
  require('@dynamic-labs/multi-wallet');
20
21
  var getWalletIdentifier = require('../../functions/getWalletIdentifier/getWalletIdentifier.cjs');
@@ -22,65 +23,84 @@ var isWalletConnected = require('../../functions/isWalletConnected/isWalletConne
22
23
  var useEventListener = require('../useEventListener/useEventListener.cjs');
23
24
  var useWalletConnectorEvent = require('../useWalletConnectorEvent/useWalletConnectorEvent.cjs');
24
25
 
25
- const connectedWalletStateReducer = (state, connectedWalletsMap) => {
26
- // When setting to empty, unset load flag
27
- if (Object.values(connectedWalletsMap).length === 0) {
28
- if (state.didLoad === false)
29
- return state;
30
- return Object.assign(Object.assign({}, state), { connectedWalletsMap, didLoad: false });
31
- }
32
- return Object.assign(Object.assign({}, state), { connectedWalletsMap, didLoad: true });
33
- };
26
+ /**
27
+ * For the given wallet array, this returns an object mapping from each wallet's
28
+ * identifier to whether its connector recognizes it as currently connected or not.
29
+ */
30
+ const getConnectedWalletsMap = (wallets) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
31
+ const newMap = {};
32
+ yield Promise.all(wallets.map((wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
33
+ newMap[getWalletIdentifier.getWalletIdentifier(wallet)] = yield isWalletConnected.isWalletConnected(wallet);
34
+ })));
35
+ return newMap;
36
+ });
34
37
  const useWalletsConnectionState = (wallets) => {
35
- const [state, setState] = React.useReducer(connectedWalletStateReducer, {
36
- connectedWalletsMap: {},
37
- didLoad: false,
38
- });
39
- const connectors = wallets.map(({ connector }) => connector);
40
- const lastCallTimestamp = React.useRef(0);
38
+ const [connectedWalletsMap, setConnectedWalletsMap] = React.useState({});
39
+ /**
40
+ * Whether the connection map has been loaded off of the current wallet array.
41
+ * Always false for empty wallet arrays.
42
+ */
43
+ const didConnectedStateLoad = React.useRef(false);
44
+ /**
45
+ * When an accountChanged event is raised, we store the incoming wallet here
46
+ * until it is finally reflected in the wallets prop.
47
+ * During this time we do not update the connectedWalletsMap.
48
+ * This way, we avoid setting the connected state of the primary wallet
49
+ * to false due to a state transition delay.
50
+ */
51
+ const incomingWalletSwitchAddress = React.useRef(undefined);
41
52
  const computeConnectedStateForWallets = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
42
- const connectedWalletsMap = {};
43
- yield Promise.all(wallets.map((wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
44
- connectedWalletsMap[getWalletIdentifier.getWalletIdentifier(wallet)] =
45
- yield isWalletConnected.isWalletConnected(wallet);
46
- })));
47
- setState(connectedWalletsMap);
48
- }), [wallets]);
49
- const handleOnEventUpdate = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
50
- if (!wallets.length)
51
- return;
52
- const callTimestamp = new Date().getTime();
53
- const diffFromLastCall = callTimestamp - lastCallTimestamp.current;
54
- lastCallTimestamp.current = callTimestamp;
55
- // getConnectedAccounts trigger accountChanged event for Phantom EVM wallets
56
- // which causes a loop of calls to this function
57
- if (diffFromLastCall < 1000) {
58
- logger.logger.warn('computeConnectedStateForWallets: skipping due too many calls.');
53
+ didConnectedStateLoad.current = false;
54
+ const newMap = yield getConnectedWalletsMap(wallets);
55
+ if (Object.values(newMap).length === 0) {
56
+ setConnectedWalletsMap({});
59
57
  return;
60
58
  }
61
- computeConnectedStateForWallets();
62
- }), [computeConnectedStateForWallets, wallets.length]);
63
- useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'accountChange', handleOnEventUpdate);
64
- useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'disconnect', handleOnEventUpdate);
65
- useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'chainChange', handleOnEventUpdate);
66
- const refreshKey = wallets.map(getWalletIdentifier.getWalletIdentifier).join('-');
59
+ didConnectedStateLoad.current = true;
60
+ // If there is an incoming account switch and it isn't yet finished,
61
+ // we don't change the map to avoid setting it to a misleading state
62
+ if (incomingWalletSwitchAddress.current) {
63
+ const accountSwitchIsComplete = wallets.some((wallet) => walletConnectorCore.isSameAddress(incomingWalletSwitchAddress.current, wallet.address, wallet.chain));
64
+ if (accountSwitchIsComplete)
65
+ incomingWalletSwitchAddress.current = undefined;
66
+ else
67
+ return;
68
+ }
69
+ setConnectedWalletsMap(newMap);
70
+ }), [wallets]);
71
+ /** A string that is unique for each possible value of the wallets prop */
72
+ const walletsHash = wallets.map(getWalletIdentifier.getWalletIdentifier).join('-');
73
+ const connectors = wallets.map(({ connector }) => connector);
74
+ // getConnectedAccounts trigger accountChanged event for Phantom EVM wallets
75
+ // which causes a loop of calls to this function, so we throttle it
76
+ const handleEvent = useThrottle.useThrottle(() => {
77
+ if (walletsHash)
78
+ computeConnectedStateForWallets();
79
+ }, 1000);
80
+ const onAccountChange = ({ accounts }) => {
81
+ incomingWalletSwitchAddress.current = accounts[0];
82
+ handleEvent();
83
+ };
84
+ useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'accountChange', onAccountChange);
85
+ useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'disconnect', handleEvent);
86
+ useWalletConnectorEvent.useWalletConnectorEvent(connectors, 'chainChange', handleEvent);
67
87
  React.useEffect(() => {
68
88
  computeConnectedStateForWallets();
69
89
  },
70
90
  /**
71
- * This is using a custom key to force the useEffect to run only when a connector is
72
- * added or removed from the connectors list.
91
+ * This is using a custom key to force the useEffect to run only when the ids of the
92
+ * wallets change.
73
93
  */
74
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
- [refreshKey]);
95
+ [walletsHash]);
76
96
  /**
77
97
  * This is a workaround to detect when the user switches to another tab/extension
78
98
  * and then comes back to the dapp.
79
99
  */
80
100
  useEventListener.useEventListener('focus', computeConnectedStateForWallets);
81
101
  return {
82
- connectedWalletMap: state.connectedWalletsMap,
83
- didConnectedStateLoad: state.didLoad,
102
+ connectedWalletsMap,
103
+ didConnectedStateLoad,
84
104
  };
85
105
  };
86
106
 
@@ -1,13 +1,11 @@
1
+ import { MutableRefObject } from 'react';
1
2
  import { Wallet } from '../../../shared';
2
- type ConnectedState = {
3
- didLoad: boolean;
4
- connectedWalletsMap: {
5
- [address: string]: boolean;
6
- };
3
+ type ConnectedWalletsMap = {
4
+ [address: string]: boolean;
7
5
  };
8
6
  type WalletsConnectionStateHook = (wallets: Wallet[]) => {
9
- connectedWalletMap: ConnectedState['connectedWalletsMap'];
10
- didConnectedStateLoad: ConnectedState['didLoad'];
7
+ connectedWalletsMap: ConnectedWalletsMap;
8
+ didConnectedStateLoad: MutableRefObject<boolean>;
11
9
  };
12
10
  export declare const useWalletsConnectionState: WalletsConnectionStateHook;
13
11
  export {};
@@ -1,9 +1,9 @@
1
1
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
- import { useReducer, useRef, useCallback, useEffect } from 'react';
2
+ import { useState, useRef, useCallback, useEffect } from 'react';
3
+ import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
3
4
  import '@dynamic-labs/sdk-api';
4
- import { logger } from '../../../shared/logger.js';
5
+ import '../../../shared/logger.js';
5
6
  import '@dynamic-labs/iconic';
6
- import '@dynamic-labs/wallet-connector-core';
7
7
  import 'react/jsx-runtime';
8
8
  import '../../../context/ViewContext/ViewContext.js';
9
9
  import '@dynamic-labs/wallet-book';
@@ -11,6 +11,7 @@ import '../../constants/colors.js';
11
11
  import '../../../shared/utils/classes/storage/localStorage.js';
12
12
  import 'viem';
13
13
  import '@dynamic-labs/utils';
14
+ import { useThrottle } from '../../../shared/utils/hooks/useThrottle/useThrottle.js';
14
15
  import '../../../shared/consts/index.js';
15
16
  import '@dynamic-labs/multi-wallet';
16
17
  import { getWalletIdentifier } from '../../functions/getWalletIdentifier/getWalletIdentifier.js';
@@ -18,65 +19,84 @@ import { isWalletConnected } from '../../functions/isWalletConnected/isWalletCon
18
19
  import { useEventListener } from '../useEventListener/useEventListener.js';
19
20
  import { useWalletConnectorEvent } from '../useWalletConnectorEvent/useWalletConnectorEvent.js';
20
21
 
21
- const connectedWalletStateReducer = (state, connectedWalletsMap) => {
22
- // When setting to empty, unset load flag
23
- if (Object.values(connectedWalletsMap).length === 0) {
24
- if (state.didLoad === false)
25
- return state;
26
- return Object.assign(Object.assign({}, state), { connectedWalletsMap, didLoad: false });
27
- }
28
- return Object.assign(Object.assign({}, state), { connectedWalletsMap, didLoad: true });
29
- };
22
+ /**
23
+ * For the given wallet array, this returns an object mapping from each wallet's
24
+ * identifier to whether its connector recognizes it as currently connected or not.
25
+ */
26
+ const getConnectedWalletsMap = (wallets) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const newMap = {};
28
+ yield Promise.all(wallets.map((wallet) => __awaiter(void 0, void 0, void 0, function* () {
29
+ newMap[getWalletIdentifier(wallet)] = yield isWalletConnected(wallet);
30
+ })));
31
+ return newMap;
32
+ });
30
33
  const useWalletsConnectionState = (wallets) => {
31
- const [state, setState] = useReducer(connectedWalletStateReducer, {
32
- connectedWalletsMap: {},
33
- didLoad: false,
34
- });
35
- const connectors = wallets.map(({ connector }) => connector);
36
- const lastCallTimestamp = useRef(0);
34
+ const [connectedWalletsMap, setConnectedWalletsMap] = useState({});
35
+ /**
36
+ * Whether the connection map has been loaded off of the current wallet array.
37
+ * Always false for empty wallet arrays.
38
+ */
39
+ const didConnectedStateLoad = useRef(false);
40
+ /**
41
+ * When an accountChanged event is raised, we store the incoming wallet here
42
+ * until it is finally reflected in the wallets prop.
43
+ * During this time we do not update the connectedWalletsMap.
44
+ * This way, we avoid setting the connected state of the primary wallet
45
+ * to false due to a state transition delay.
46
+ */
47
+ const incomingWalletSwitchAddress = useRef(undefined);
37
48
  const computeConnectedStateForWallets = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
38
- const connectedWalletsMap = {};
39
- yield Promise.all(wallets.map((wallet) => __awaiter(void 0, void 0, void 0, function* () {
40
- connectedWalletsMap[getWalletIdentifier(wallet)] =
41
- yield isWalletConnected(wallet);
42
- })));
43
- setState(connectedWalletsMap);
44
- }), [wallets]);
45
- const handleOnEventUpdate = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
46
- if (!wallets.length)
47
- return;
48
- const callTimestamp = new Date().getTime();
49
- const diffFromLastCall = callTimestamp - lastCallTimestamp.current;
50
- lastCallTimestamp.current = callTimestamp;
51
- // getConnectedAccounts trigger accountChanged event for Phantom EVM wallets
52
- // which causes a loop of calls to this function
53
- if (diffFromLastCall < 1000) {
54
- logger.warn('computeConnectedStateForWallets: skipping due too many calls.');
49
+ didConnectedStateLoad.current = false;
50
+ const newMap = yield getConnectedWalletsMap(wallets);
51
+ if (Object.values(newMap).length === 0) {
52
+ setConnectedWalletsMap({});
55
53
  return;
56
54
  }
57
- computeConnectedStateForWallets();
58
- }), [computeConnectedStateForWallets, wallets.length]);
59
- useWalletConnectorEvent(connectors, 'accountChange', handleOnEventUpdate);
60
- useWalletConnectorEvent(connectors, 'disconnect', handleOnEventUpdate);
61
- useWalletConnectorEvent(connectors, 'chainChange', handleOnEventUpdate);
62
- const refreshKey = wallets.map(getWalletIdentifier).join('-');
55
+ didConnectedStateLoad.current = true;
56
+ // If there is an incoming account switch and it isn't yet finished,
57
+ // we don't change the map to avoid setting it to a misleading state
58
+ if (incomingWalletSwitchAddress.current) {
59
+ const accountSwitchIsComplete = wallets.some((wallet) => isSameAddress(incomingWalletSwitchAddress.current, wallet.address, wallet.chain));
60
+ if (accountSwitchIsComplete)
61
+ incomingWalletSwitchAddress.current = undefined;
62
+ else
63
+ return;
64
+ }
65
+ setConnectedWalletsMap(newMap);
66
+ }), [wallets]);
67
+ /** A string that is unique for each possible value of the wallets prop */
68
+ const walletsHash = wallets.map(getWalletIdentifier).join('-');
69
+ const connectors = wallets.map(({ connector }) => connector);
70
+ // getConnectedAccounts trigger accountChanged event for Phantom EVM wallets
71
+ // which causes a loop of calls to this function, so we throttle it
72
+ const handleEvent = useThrottle(() => {
73
+ if (walletsHash)
74
+ computeConnectedStateForWallets();
75
+ }, 1000);
76
+ const onAccountChange = ({ accounts }) => {
77
+ incomingWalletSwitchAddress.current = accounts[0];
78
+ handleEvent();
79
+ };
80
+ useWalletConnectorEvent(connectors, 'accountChange', onAccountChange);
81
+ useWalletConnectorEvent(connectors, 'disconnect', handleEvent);
82
+ useWalletConnectorEvent(connectors, 'chainChange', handleEvent);
63
83
  useEffect(() => {
64
84
  computeConnectedStateForWallets();
65
85
  },
66
86
  /**
67
- * This is using a custom key to force the useEffect to run only when a connector is
68
- * added or removed from the connectors list.
87
+ * This is using a custom key to force the useEffect to run only when the ids of the
88
+ * wallets change.
69
89
  */
70
90
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
- [refreshKey]);
91
+ [walletsHash]);
72
92
  /**
73
93
  * This is a workaround to detect when the user switches to another tab/extension
74
94
  * and then comes back to the dapp.
75
95
  */
76
96
  useEventListener('focus', computeConnectedStateForWallets);
77
97
  return {
78
- connectedWalletMap: state.connectedWalletsMap,
79
- didConnectedStateLoad: state.didLoad,
98
+ connectedWalletsMap,
99
+ didConnectedStateLoad,
80
100
  };
81
101
  };
82
102
 
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
+ var reactI18next = require('react-i18next');
7
8
  var IsBrowser = require('../../components/IsBrowser/IsBrowser.cjs');
8
9
  require('@dynamic-labs/utils');
9
10
  var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
@@ -31,7 +32,6 @@ require('react-dom');
31
32
  require('../../context/ThemeContext/ThemeContext.cjs');
32
33
  require('@dynamic-labs/types');
33
34
  require('yup');
34
- require('react-i18next');
35
35
  require('../../context/MockContext/MockContext.cjs');
36
36
  require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
37
37
  require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
@@ -68,6 +68,7 @@ var DynamicBridgeWidgetContext = require('./context/DynamicBridgeWidgetContext/D
68
68
  const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
69
69
  const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext.useInternalDynamicContext();
70
70
  const { widgetRef, inlineControlsRef } = DynamicBridgeWidgetContext.useDynamicBridgeWidgetContext();
71
+ const { t } = reactI18next.useTranslation();
71
72
  const closeOnOutsideClick = React.useCallback((e) => {
72
73
  var _a;
73
74
  const target = e.composedPath().shift();
@@ -84,7 +85,7 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
84
85
  if (connectedChainWallets.length > 0) {
85
86
  return connectedChainWallets.map((wallet) => (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress.shortenWalletAddress(wallet.address, 3, 3) }, wallet.id)));
86
87
  }
87
- return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), children: "Connect wallet" }, chain));
88
+ return (jsxRuntime.jsx(InlineWidgetButton.InlineWidgetButton, { icon: jsxRuntime.jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), copykey: 'dyn_bridge.widget.connect', children: t('dyn_bridge.widget.connect') }, chain));
88
89
  }) }), jsxRuntime.jsx(DynamicBridgeUserProfile.DynamicBridgeUserProfile, { variant: variant })] }) }));
89
90
  };
90
91
 
@@ -1,5 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useCallback } from 'react';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { IsBrowser } from '../../components/IsBrowser/IsBrowser.js';
4
5
  import '@dynamic-labs/utils';
5
6
  import { useInternalDynamicContext } from '../../context/DynamicContext/useInternalDynamicContext.js';
@@ -27,7 +28,6 @@ import 'react-dom';
27
28
  import '../../context/ThemeContext/ThemeContext.js';
28
29
  import '@dynamic-labs/types';
29
30
  import 'yup';
30
- import 'react-i18next';
31
31
  import '../../context/MockContext/MockContext.js';
32
32
  import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
33
33
  import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
@@ -64,6 +64,7 @@ import { useDynamicBridgeWidgetContext } from './context/DynamicBridgeWidgetCont
64
64
  const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
65
65
  const { showAuthFlow, setShowBridgeWidget, bridgeChains, setShowAuthFlow, connectedWallets, } = useInternalDynamicContext();
66
66
  const { widgetRef, inlineControlsRef } = useDynamicBridgeWidgetContext();
67
+ const { t } = useTranslation();
67
68
  const closeOnOutsideClick = useCallback((e) => {
68
69
  var _a;
69
70
  const target = e.composedPath().shift();
@@ -80,7 +81,7 @@ const DynamicBridgeWidget = ({ className, variant = 'modal', }) => {
80
81
  if (connectedChainWallets.length > 0) {
81
82
  return connectedChainWallets.map((wallet) => (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), onClick: () => setShowBridgeWidget(true), children: shortenWalletAddress(wallet.address, 3, 3) }, wallet.id)));
82
83
  }
83
- return (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), children: "Connect wallet" }, chain));
84
+ return (jsx(InlineWidgetButton, { icon: jsx(ChainIcon, {}), onClick: () => setShowAuthFlow(true), copykey: 'dyn_bridge.widget.connect', children: t('dyn_bridge.widget.connect') }, chain));
84
85
  }) }), jsx(DynamicBridgeUserProfile, { variant: variant })] }) }));
85
86
  };
86
87
 
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
+ var reactI18next = require('react-i18next');
7
8
  var classNames = require('../../../../utils/functions/classNames/classNames.cjs');
8
9
  require('@dynamic-labs/utils');
9
10
  require('../../../../context/DynamicContext/DynamicContext.cjs');
@@ -28,7 +29,6 @@ require('react-dom');
28
29
  require('../../../../context/ThemeContext/ThemeContext.cjs');
29
30
  require('@dynamic-labs/types');
30
31
  require('yup');
31
- require('react-i18next');
32
32
  require('../../../../context/MockContext/MockContext.cjs');
33
33
  require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
34
34
  require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
@@ -64,9 +64,14 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
64
64
 
65
65
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
66
66
 
67
- const DynamicBridgeWalletCard = ({ className, networkIcon, networkName, children }) => (jsxRuntime.jsxs("div", { className: classNames.classNames('dynamic-bridge-wallet-card', className), children: [jsxRuntime.jsxs("div", { className: 'dynamic-bridge-wallet-card__network', children: [networkIcon &&
68
- React__default["default"].cloneElement(networkIcon, {
69
- className: 'dynamic-bridge-wallet-card__network-icon',
70
- }), networkName && (jsxRuntime.jsxs(Typography.Typography, { className: 'dynamic-bridge-wallet-card__network-name', variant: 'body_small', color: 'primary', weight: 'medium', as: 'span', children: [networkName, " wallet"] }))] }), children] }));
67
+ const DynamicBridgeWalletCard = ({ className, networkIcon, networkName, children }) => {
68
+ const { t } = reactI18next.useTranslation();
69
+ return (jsxRuntime.jsxs("div", { className: classNames.classNames('dynamic-bridge-wallet-card', className), children: [jsxRuntime.jsxs("div", { className: 'dynamic-bridge-wallet-card__network', children: [networkIcon &&
70
+ React__default["default"].cloneElement(networkIcon, {
71
+ className: 'dynamic-bridge-wallet-card__network-icon',
72
+ }), networkName && (jsxRuntime.jsx(Typography.Typography, { className: 'dynamic-bridge-wallet-card__network-name', variant: 'body_small', color: 'primary', weight: 'medium', as: 'span', copykey: 'dyn_bridge.widget.wallet_network', children: t('dyn_bridge.widget.wallet_network', {
73
+ networkName,
74
+ }) }))] }), children] }));
75
+ };
71
76
 
72
77
  exports.DynamicBridgeWalletCard = DynamicBridgeWalletCard;
@@ -1,5 +1,6 @@
1
- import { jsxs } from 'react/jsx-runtime';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import React__default from 'react';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { classNames } from '../../../../utils/functions/classNames/classNames.js';
4
5
  import '@dynamic-labs/utils';
5
6
  import '../../../../context/DynamicContext/DynamicContext.js';
@@ -24,7 +25,6 @@ import 'react-dom';
24
25
  import '../../../../context/ThemeContext/ThemeContext.js';
25
26
  import '@dynamic-labs/types';
26
27
  import 'yup';
27
- import 'react-i18next';
28
28
  import '../../../../context/MockContext/MockContext.js';
29
29
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
30
30
  import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
@@ -56,9 +56,14 @@ import '../../../../components/Popper/Popper/Popper.js';
56
56
  import '../../../../components/Popper/PopperContext/PopperContext.js';
57
57
  import 'react-focus-lock';
58
58
 
59
- const DynamicBridgeWalletCard = ({ className, networkIcon, networkName, children }) => (jsxs("div", { className: classNames('dynamic-bridge-wallet-card', className), children: [jsxs("div", { className: 'dynamic-bridge-wallet-card__network', children: [networkIcon &&
60
- React__default.cloneElement(networkIcon, {
61
- className: 'dynamic-bridge-wallet-card__network-icon',
62
- }), networkName && (jsxs(Typography, { className: 'dynamic-bridge-wallet-card__network-name', variant: 'body_small', color: 'primary', weight: 'medium', as: 'span', children: [networkName, " wallet"] }))] }), children] }));
59
+ const DynamicBridgeWalletCard = ({ className, networkIcon, networkName, children }) => {
60
+ const { t } = useTranslation();
61
+ return (jsxs("div", { className: classNames('dynamic-bridge-wallet-card', className), children: [jsxs("div", { className: 'dynamic-bridge-wallet-card__network', children: [networkIcon &&
62
+ React__default.cloneElement(networkIcon, {
63
+ className: 'dynamic-bridge-wallet-card__network-icon',
64
+ }), networkName && (jsx(Typography, { className: 'dynamic-bridge-wallet-card__network-name', variant: 'body_small', color: 'primary', weight: 'medium', as: 'span', copykey: 'dyn_bridge.widget.wallet_network', children: t('dyn_bridge.widget.wallet_network', {
65
+ networkName,
66
+ }) }))] }), children] }));
67
+ };
63
68
 
64
69
  export { DynamicBridgeWalletCard };
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactI18next = require('react-i18next');
6
7
  var walletBook = require('@dynamic-labs/wallet-book');
7
8
  require('react');
8
9
  require('@dynamic-labs/utils');
@@ -27,7 +28,6 @@ require('react-dom');
27
28
  require('../../../../context/ThemeContext/ThemeContext.cjs');
28
29
  require('@dynamic-labs/types');
29
30
  require('yup');
30
- require('react-i18next');
31
31
  require('../../../../context/MockContext/MockContext.cjs');
32
32
  require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
33
33
  require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
@@ -62,28 +62,29 @@ var WalletInformationCard = require('../../../../components/WalletInformationCar
62
62
  var useFetchNameService = require('../../../DynamicWidget/hooks/useFetchNameService/useFetchNameService.cjs');
63
63
 
64
64
  const DynamicBridgeWalletCardBody = ({ walletAddress, walletBalance, walletKey, onDisconnectClick }) => {
65
+ const { t } = reactI18next.useTranslation();
65
66
  const nameService = useFetchNameService.useFetchNameService(walletAddress);
66
67
  const options = [
67
68
  {
68
69
  Icon: null,
69
70
  callback: () => (nameService === null || nameService === void 0 ? void 0 : nameService.name) && navigator.clipboard.writeText(nameService === null || nameService === void 0 ? void 0 : nameService.name),
70
71
  hide: !(nameService === null || nameService === void 0 ? void 0 : nameService.name),
71
- text: 'Copy ENS',
72
+ text: t('dyn_bridge.widget.copy.ens'),
72
73
  },
73
74
  {
74
75
  Icon: null,
75
76
  callback: () => walletAddress && navigator.clipboard.writeText(walletAddress),
76
77
  hide: !walletAddress,
77
- text: 'Copy wallet address',
78
+ text: t('dyn_bridge.widget.copy.address'),
78
79
  },
79
80
  {
80
81
  Icon: null,
81
82
  callback: () => onDisconnectClick === null || onDisconnectClick === void 0 ? void 0 : onDisconnectClick(),
82
83
  hide: !onDisconnectClick,
83
- text: 'Disconnect',
84
+ text: t('dyn_bridge.widget.disconnect'),
84
85
  },
85
86
  ];
86
- return (jsxRuntime.jsx(WalletInformationCard.WalletInformationCard, { ens: nameService === null || nameService === void 0 ? void 0 : nameService.name, address: walletAddress, icon: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletKey }), balance: walletBalance, menu: jsxRuntime.jsx(DotsMenu.DotsMenu, { options: options }) }));
87
+ return (jsxRuntime.jsx(WalletInformationCard.WalletInformationCard, { ens: nameService === null || nameService === void 0 ? void 0 : nameService.name, address: walletAddress, icon: jsxRuntime.jsx(walletBook.WalletIcon, { walletKey: walletKey }), balance: walletBalance, menu: jsxRuntime.jsx(DotsMenu.DotsMenu, { options: options }), copykey: 'dyn_bridge.widget' }));
87
88
  };
88
89
 
89
90
  exports.DynamicBridgeWalletCardBody = DynamicBridgeWalletCardBody;
@@ -1,4 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
+ import { useTranslation } from 'react-i18next';
2
3
  import { WalletIcon } from '@dynamic-labs/wallet-book';
3
4
  import 'react';
4
5
  import '@dynamic-labs/utils';
@@ -23,7 +24,6 @@ import 'react-dom';
23
24
  import '../../../../context/ThemeContext/ThemeContext.js';
24
25
  import '@dynamic-labs/types';
25
26
  import 'yup';
26
- import 'react-i18next';
27
27
  import '../../../../context/MockContext/MockContext.js';
28
28
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
29
29
  import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
@@ -58,28 +58,29 @@ import { WalletInformationCard } from '../../../../components/WalletInformationC
58
58
  import { useFetchNameService } from '../../../DynamicWidget/hooks/useFetchNameService/useFetchNameService.js';
59
59
 
60
60
  const DynamicBridgeWalletCardBody = ({ walletAddress, walletBalance, walletKey, onDisconnectClick }) => {
61
+ const { t } = useTranslation();
61
62
  const nameService = useFetchNameService(walletAddress);
62
63
  const options = [
63
64
  {
64
65
  Icon: null,
65
66
  callback: () => (nameService === null || nameService === void 0 ? void 0 : nameService.name) && navigator.clipboard.writeText(nameService === null || nameService === void 0 ? void 0 : nameService.name),
66
67
  hide: !(nameService === null || nameService === void 0 ? void 0 : nameService.name),
67
- text: 'Copy ENS',
68
+ text: t('dyn_bridge.widget.copy.ens'),
68
69
  },
69
70
  {
70
71
  Icon: null,
71
72
  callback: () => walletAddress && navigator.clipboard.writeText(walletAddress),
72
73
  hide: !walletAddress,
73
- text: 'Copy wallet address',
74
+ text: t('dyn_bridge.widget.copy.address'),
74
75
  },
75
76
  {
76
77
  Icon: null,
77
78
  callback: () => onDisconnectClick === null || onDisconnectClick === void 0 ? void 0 : onDisconnectClick(),
78
79
  hide: !onDisconnectClick,
79
- text: 'Disconnect',
80
+ text: t('dyn_bridge.widget.disconnect'),
80
81
  },
81
82
  ];
82
- return (jsx(WalletInformationCard, { ens: nameService === null || nameService === void 0 ? void 0 : nameService.name, address: walletAddress, icon: jsx(WalletIcon, { walletKey: walletKey }), balance: walletBalance, menu: jsx(DotsMenu, { options: options }) }));
83
+ return (jsx(WalletInformationCard, { ens: nameService === null || nameService === void 0 ? void 0 : nameService.name, address: walletAddress, icon: jsx(WalletIcon, { walletKey: walletKey }), balance: walletBalance, menu: jsx(DotsMenu, { options: options }), copykey: 'dyn_bridge.widget' }));
83
84
  };
84
85
 
85
86
  export { DynamicBridgeWalletCardBody };
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactI18next = require('react-i18next');
6
7
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
8
  var useInternalDynamicContext = require('../../../../context/DynamicContext/useInternalDynamicContext.cjs');
8
9
  require('@dynamic-labs/sdk-api');
@@ -28,7 +29,6 @@ require('react-dom');
28
29
  require('../../../../context/ThemeContext/ThemeContext.cjs');
29
30
  require('@dynamic-labs/types');
30
31
  require('yup');
31
- require('react-i18next');
32
32
  require('../../../../context/MockContext/MockContext.cjs');
33
33
  require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
34
34
  require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
@@ -61,6 +61,7 @@ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
61
61
  require('react-focus-lock');
62
62
 
63
63
  const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
64
+ const { t } = reactI18next.useTranslation();
64
65
  const { bridgeChainsToConnect, setShowAuthFlow, setShowBridgeWidget } = useInternalDynamicContext.useInternalDynamicContext();
65
66
  if (!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) || !chain) {
66
67
  return null;
@@ -70,7 +71,9 @@ const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
70
71
  return (jsxRuntime.jsxs("div", { role: 'button', className: 'dynamic-bridge-widget-empty-card', onClick: () => {
71
72
  setShowBridgeWidget(false);
72
73
  setShowAuthFlow(true);
73
- }, children: [jsxRuntime.jsx(ChainIcon, { className: 'dynamic-bridge-widget-empty-card__icon' }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', weight: 'medium', as: 'span', color: 'primary', className: 'dynamic-bridge-widget-empty-card__text', children: ["Connect ", chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName, " wallet"] })] }));
74
+ }, children: [jsxRuntime.jsx(ChainIcon, { className: 'dynamic-bridge-widget-empty-card__icon' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'medium', as: 'span', color: 'primary', className: 'dynamic-bridge-widget-empty-card__text', copykey: 'dyn_bridge.widget.connect_with_network', children: t('dyn_bridge.widget.connect_with_network', {
75
+ blockchainName: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName,
76
+ }) })] }));
74
77
  };
75
78
 
76
79
  exports.DynamicBridgeWidgetEmptyCard = DynamicBridgeWidgetEmptyCard;
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useTranslation } from 'react-i18next';
2
3
  import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
3
4
  import { useInternalDynamicContext } from '../../../../context/DynamicContext/useInternalDynamicContext.js';
4
5
  import '@dynamic-labs/sdk-api';
@@ -24,7 +25,6 @@ import 'react-dom';
24
25
  import '../../../../context/ThemeContext/ThemeContext.js';
25
26
  import '@dynamic-labs/types';
26
27
  import 'yup';
27
- import 'react-i18next';
28
28
  import '../../../../context/MockContext/MockContext.js';
29
29
  import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
30
30
  import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
@@ -57,6 +57,7 @@ import '../../../../components/Popper/PopperContext/PopperContext.js';
57
57
  import 'react-focus-lock';
58
58
 
59
59
  const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
60
+ const { t } = useTranslation();
60
61
  const { bridgeChainsToConnect, setShowAuthFlow, setShowBridgeWidget } = useInternalDynamicContext();
61
62
  if (!(bridgeChainsToConnect === null || bridgeChainsToConnect === void 0 ? void 0 : bridgeChainsToConnect.length) || !chain) {
62
63
  return null;
@@ -66,7 +67,9 @@ const DynamicBridgeWidgetEmptyCard = ({ chain }) => {
66
67
  return (jsxs("div", { role: 'button', className: 'dynamic-bridge-widget-empty-card', onClick: () => {
67
68
  setShowBridgeWidget(false);
68
69
  setShowAuthFlow(true);
69
- }, children: [jsx(ChainIcon, { className: 'dynamic-bridge-widget-empty-card__icon' }), jsxs(Typography, { variant: 'body_normal', weight: 'medium', as: 'span', color: 'primary', className: 'dynamic-bridge-widget-empty-card__text', children: ["Connect ", chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName, " wallet"] })] }));
70
+ }, children: [jsx(ChainIcon, { className: 'dynamic-bridge-widget-empty-card__icon' }), jsx(Typography, { variant: 'body_normal', weight: 'medium', as: 'span', color: 'primary', className: 'dynamic-bridge-widget-empty-card__text', copykey: 'dyn_bridge.widget.connect_with_network', children: t('dyn_bridge.widget.connect_with_network', {
71
+ blockchainName: chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo.blockchainName,
72
+ }) })] }));
70
73
  };
71
74
 
72
75
  export { DynamicBridgeWidgetEmptyCard };