@dynamic-labs/sdk-react-core 3.9.10 → 3.9.11

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 (30) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +11 -11
  5. package/src/lib/context/UserWalletsContext/UserWalletsContext.cjs +19 -14
  6. package/src/lib/context/UserWalletsContext/UserWalletsContext.js +20 -15
  7. package/src/lib/context/ViewContext/types/index.d.ts +1 -1
  8. package/src/lib/data/api/wallets/wallets.cjs +3 -0
  9. package/src/lib/data/api/wallets/wallets.js +4 -1
  10. package/src/lib/locale/en/translation.cjs +4 -0
  11. package/src/lib/locale/en/translation.d.ts +4 -0
  12. package/src/lib/locale/en/translation.js +4 -0
  13. package/src/lib/styles/index.shadow.cjs +1 -1
  14. package/src/lib/styles/index.shadow.js +1 -1
  15. package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +4 -0
  16. package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +4 -0
  17. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -0
  18. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +6 -1
  19. package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.cjs +101 -0
  20. package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.d.ts +2 -0
  21. package/src/lib/views/WalletAlreadyExistsView/WalletAlreadyExistsView.js +97 -0
  22. package/src/lib/views/WalletAlreadyExistsView/index.d.ts +1 -0
  23. package/src/lib/views/viewToComponentMap.cjs +2 -0
  24. package/src/lib/views/viewToComponentMap.d.ts +1 -0
  25. package/src/lib/views/viewToComponentMap.js +2 -0
  26. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +1 -1
  27. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +1 -1
  28. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.cjs +10 -4
  29. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.d.ts +3 -1
  30. package/src/lib/widgets/DynamicWidget/components/Wallet/Wallet.js +10 -4
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [3.9.11](https://github.com/dynamic-labs/DynamicAuth/compare/v3.9.10...v3.9.11) (2025-02-08)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * ensure correct dependencies are listed in packages ([#7958](https://github.com/dynamic-labs/DynamicAuth/issues/7958)) ([0ba0035](https://github.com/dynamic-labs/DynamicAuth/commit/0ba003520136336ea69a6ac163d36acec2b67970))
8
+ * ensure user wallets state has been updated before emitting walletAdded/walletRemoved events ([#7870](https://github.com/dynamic-labs/DynamicAuth/issues/7870)) ([5d89ad0](https://github.com/dynamic-labs/DynamicAuth/commit/5d89ad02a278ccb1b47bc46a8e36c15180ed7965)), closes [#7863](https://github.com/dynamic-labs/DynamicAuth/issues/7863)
9
+
2
10
  ### [3.9.10](https://github.com/dynamic-labs/DynamicAuth/compare/v3.9.9...v3.9.10) (2025-01-16)
3
11
 
4
12
 
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "3.9.10";
6
+ var version = "3.9.11";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.586",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "3.9.10";
2
+ var version = "3.9.11";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.586",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "3.9.10",
3
+ "version": "3.9.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -17,16 +17,16 @@
17
17
  "react-i18next": "13.5.0",
18
18
  "yup": "0.32.11",
19
19
  "react-international-phone": "4.2.5",
20
- "@dynamic-labs/assert-package-version": "3.9.10",
21
- "@dynamic-labs/iconic": "3.9.10",
22
- "@dynamic-labs/logger": "3.9.10",
23
- "@dynamic-labs/multi-wallet": "3.9.10",
24
- "@dynamic-labs/rpc-providers": "3.9.10",
25
- "@dynamic-labs/store": "3.9.10",
26
- "@dynamic-labs/types": "3.9.10",
27
- "@dynamic-labs/utils": "3.9.10",
28
- "@dynamic-labs/wallet-book": "3.9.10",
29
- "@dynamic-labs/wallet-connector-core": "3.9.10",
20
+ "@dynamic-labs/assert-package-version": "3.9.11",
21
+ "@dynamic-labs/iconic": "3.9.11",
22
+ "@dynamic-labs/logger": "3.9.11",
23
+ "@dynamic-labs/multi-wallet": "3.9.11",
24
+ "@dynamic-labs/rpc-providers": "3.9.11",
25
+ "@dynamic-labs/store": "3.9.11",
26
+ "@dynamic-labs/types": "3.9.11",
27
+ "@dynamic-labs/utils": "3.9.11",
28
+ "@dynamic-labs/wallet-book": "3.9.11",
29
+ "@dynamic-labs/wallet-connector-core": "3.9.11",
30
30
  "bs58": "5.0.0",
31
31
  "eventemitter3": "5.0.1"
32
32
  },
@@ -11,28 +11,33 @@ var dynamicEvents = require('../../events/dynamicEvents.cjs');
11
11
  const UserWalletsContext = React.createContext(undefined);
12
12
  const UserWalletsProvider = ({ children }) => {
13
13
  const [userWallets, _setUserWallets] = React.useState([]);
14
+ const prevUserWallets = React.useRef([]);
14
15
  const addedWalletsIds = React.useRef([]);
15
16
  const removedWalletsIds = React.useRef([]);
16
17
  const setUserWallets = React.useCallback((returnUpdatedWallets) => {
17
18
  _setUserWallets((prevWallets) => {
19
+ prevUserWallets.current = prevWallets;
18
20
  const updatedWallets = returnUpdatedWallets(prevWallets);
19
- addedWalletsIds.current.forEach((walletId) => {
20
- const wallet = updatedWallets.find(({ id }) => id === walletId);
21
- if (!wallet)
22
- return;
23
- dynamicEvents.dynamicEvents.emit('walletAdded', wallet, updatedWallets);
24
- });
25
- removedWalletsIds.current.forEach((walletId) => {
26
- const wallet = prevWallets.find(({ id }) => id === walletId);
27
- if (!wallet)
28
- return;
29
- dynamicEvents.dynamicEvents.emit('walletRemoved', wallet, updatedWallets);
30
- });
31
- addedWalletsIds.current = [];
32
- removedWalletsIds.current = [];
33
21
  return updatedWallets;
34
22
  });
35
23
  }, []);
24
+ // it's an useEffect because it needs to be called after the userWallets state is updated
25
+ React.useEffect(() => {
26
+ addedWalletsIds.current.forEach((walletId) => {
27
+ const wallet = userWallets.find(({ id }) => id === walletId);
28
+ if (!wallet)
29
+ return;
30
+ dynamicEvents.dynamicEvents.emit('walletAdded', wallet, userWallets);
31
+ });
32
+ removedWalletsIds.current.forEach((walletId) => {
33
+ const wallet = prevUserWallets.current.find(({ id }) => id === walletId);
34
+ if (!wallet)
35
+ return;
36
+ dynamicEvents.dynamicEvents.emit('walletRemoved', wallet, userWallets);
37
+ });
38
+ addedWalletsIds.current = [];
39
+ removedWalletsIds.current = [];
40
+ }, [userWallets]);
36
41
  return (jsxRuntime.jsx(UserWalletsContext.Provider, { value: {
37
42
  addedWalletsIds,
38
43
  registerUserWallet: (newWallet) => setUserWallets((userWallets) => [...userWallets, newWallet]),
@@ -1,34 +1,39 @@
1
1
  'use client'
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { createContext, useContext, useState, useRef, useCallback } from 'react';
3
+ import { createContext, useContext, useState, useRef, useCallback, useEffect } from 'react';
4
4
  import { dynamicEvents } from '../../events/dynamicEvents.js';
5
5
 
6
6
  /** Context for accessing the current user/session's wallets */
7
7
  const UserWalletsContext = createContext(undefined);
8
8
  const UserWalletsProvider = ({ children }) => {
9
9
  const [userWallets, _setUserWallets] = useState([]);
10
+ const prevUserWallets = useRef([]);
10
11
  const addedWalletsIds = useRef([]);
11
12
  const removedWalletsIds = useRef([]);
12
13
  const setUserWallets = useCallback((returnUpdatedWallets) => {
13
14
  _setUserWallets((prevWallets) => {
15
+ prevUserWallets.current = prevWallets;
14
16
  const updatedWallets = returnUpdatedWallets(prevWallets);
15
- addedWalletsIds.current.forEach((walletId) => {
16
- const wallet = updatedWallets.find(({ id }) => id === walletId);
17
- if (!wallet)
18
- return;
19
- dynamicEvents.emit('walletAdded', wallet, updatedWallets);
20
- });
21
- removedWalletsIds.current.forEach((walletId) => {
22
- const wallet = prevWallets.find(({ id }) => id === walletId);
23
- if (!wallet)
24
- return;
25
- dynamicEvents.emit('walletRemoved', wallet, updatedWallets);
26
- });
27
- addedWalletsIds.current = [];
28
- removedWalletsIds.current = [];
29
17
  return updatedWallets;
30
18
  });
31
19
  }, []);
20
+ // it's an useEffect because it needs to be called after the userWallets state is updated
21
+ useEffect(() => {
22
+ addedWalletsIds.current.forEach((walletId) => {
23
+ const wallet = userWallets.find(({ id }) => id === walletId);
24
+ if (!wallet)
25
+ return;
26
+ dynamicEvents.emit('walletAdded', wallet, userWallets);
27
+ });
28
+ removedWalletsIds.current.forEach((walletId) => {
29
+ const wallet = prevUserWallets.current.find(({ id }) => id === walletId);
30
+ if (!wallet)
31
+ return;
32
+ dynamicEvents.emit('walletRemoved', wallet, userWallets);
33
+ });
34
+ addedWalletsIds.current = [];
35
+ removedWalletsIds.current = [];
36
+ }, [userWallets]);
32
37
  return (jsx(UserWalletsContext.Provider, { value: {
33
38
  addedWalletsIds,
34
39
  registerUserWallet: (newWallet) => setUserWallets((userWallets) => [...userWallets, newWallet]),
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { viewToComponentMap } from '../../../views/viewToComponentMap';
3
- export type ViewType = 'access-blocked' | 'select-hardware-wallet' | 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-no-wallet' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-wallet-only' | 'login-with-email-verification' | 'login-with-sms-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'verify-email' | 'verify-sms' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'sandbox-maximum-threshold-reached' | 'multi-wallet-wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'select-wallet-in-wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts' | 'merge-user-accounts-conflicts' | 'merge-user-accounts-with-same-email' | 'mfa-choose-device' | 'mfa-recovery' | 'mfa-secure-device' | 'mfa-secure-device-help' | 'mfa-verification' | 'mfa-display-backup-codes' | 'wallet-cannot-be-transferred' | 'passkey-intro' | 'passkey-recovery-add-email' | 'global-wallet-confirm' | 'global-wallet-malicious' | 'global-wallet-info' | 'passkey-recovery-start' | 'passkey-recovery-bundle' | 'passkey-recovery-complete' | 'passkey-new-domain-detected' | 'embedded-reveal-view' | 'embedded-reveal-account-view' | 'embedded-wallet-auth-choice' | 'rename-passkey' | 'wallet-redirect-view' | 'create-password-view' | 'wallet-claim-intro' | 'mobile-wallet-redirect-view' | 'farcaster-connect-view';
3
+ export type ViewType = 'access-blocked' | 'select-hardware-wallet' | 'captcha' | 'chainalysis-blocked-wallet' | 'collect-user-data' | 'collect-user-data-login-no-wallet' | 'login-with-email-or-wallet-full-wallet-list' | 'login-with-email-or-wallet' | 'login-with-wallet-only' | 'login-with-email-verification' | 'login-with-sms-verification' | 'network-not-supported' | 'network-not-supported-manual' | 'no-access' | 'no-qr-not-installed' | 'pending-connect' | 'pending-signature-without-back-button' | 'pending-signature' | 'qr-code' | 'verify-email' | 'verify-sms' | 'wallet-connect-mobile-wallets-list' | 'wallet-list' | 'sandbox-maximum-threshold-reached' | 'multi-wallet-wallet-list' | 'wallet-sign' | 'wallet-used' | 'wallet-group' | 'select-wallet-in-wallet-group' | 'wait-for-email-confirmation-view' | 'email-wallet-otp-verification-view' | 'social-redirect-view' | 'wallet-locked-view' | 'social-wrong-account' | 'gate-blocked-wallet' | 'bridge-welcome' | 'bridge-summary' | 'bridge-next-wallet-connection' | 'account-exists' | 'merge-user-accounts' | 'merge-user-accounts-conflicts' | 'merge-user-accounts-with-same-email' | 'mfa-choose-device' | 'mfa-recovery' | 'mfa-secure-device' | 'mfa-secure-device-help' | 'mfa-verification' | 'mfa-display-backup-codes' | 'wallet-cannot-be-transferred' | 'passkey-intro' | 'passkey-recovery-add-email' | 'global-wallet-confirm' | 'global-wallet-malicious' | 'global-wallet-info' | 'passkey-recovery-start' | 'passkey-recovery-bundle' | 'passkey-recovery-complete' | 'passkey-new-domain-detected' | 'embedded-reveal-view' | 'embedded-reveal-account-view' | 'embedded-wallet-auth-choice' | 'rename-passkey' | 'wallet-redirect-view' | 'create-password-view' | 'wallet-claim-intro' | 'mobile-wallet-redirect-view' | 'farcaster-connect-view' | 'embedded-wallet-exists';
4
4
  export type ViewMapConstraint = Record<ViewType, FC<any>>;
5
5
  type ComponentProps<T extends FC<any>> = T extends FC<infer P> ? P : never;
6
6
  export type ViewMap = typeof viewToComponentMap;
@@ -51,6 +51,9 @@ const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmen
51
51
  }
52
52
  catch (e) {
53
53
  const data = yield utils.logResponseError(e, 'Error linkWallet');
54
+ if (data.code === 'embedded_wallet_address_already_linked') {
55
+ throw new utils$1.EmbeddedWalletExistsError(data.code);
56
+ }
54
57
  if (data.code === 'reassign_wallet_confirm' ||
55
58
  data.code === 'reassign_wallet_error') {
56
59
  throw new utils$1.WalletUsedError(data.code);
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../../../../_virtual/_tslib.js';
3
3
  import { VerifyRequestFromJSON } from '@dynamic-labs/sdk-api-core';
4
- import { WalletUsedError, MergeAccountsConfirmationError, SandboxMaximumThresholdReachedError, DynamicError, WalletNotDeployedError, ChainalysisError, GateBlockedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
4
+ import { EmbeddedWalletExistsError, WalletUsedError, MergeAccountsConfirmationError, SandboxMaximumThresholdReachedError, DynamicError, WalletNotDeployedError, ChainalysisError, GateBlockedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
5
5
  import { sdkApi } from '../api.js';
6
6
  import { storeAuthTokenAndUser } from '../../../store/state/user/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
7
7
  import '../../../store/state/user/user.js';
@@ -47,6 +47,9 @@ const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1,
47
47
  }
48
48
  catch (e) {
49
49
  const data = yield logResponseError(e, 'Error linkWallet');
50
+ if (data.code === 'embedded_wallet_address_already_linked') {
51
+ throw new EmbeddedWalletExistsError(data.code);
52
+ }
50
53
  if (data.code === 'reassign_wallet_confirm' ||
51
54
  data.code === 'reassign_wallet_error') {
52
55
  throw new WalletUsedError(data.code);
@@ -2008,6 +2008,10 @@ const translation = {
2008
2008
  },
2009
2009
  log_out_button: 'Log out',
2010
2010
  title: 'Transfer this wallet?',
2011
+ already_exists: {
2012
+ title: 'Wallet Already Linked',
2013
+ description: 'This wallet is already used as an embedded wallet. You cannot link it unless you delete the existing embedded wallet.',
2014
+ },
2011
2015
  },
2012
2016
  /**
2013
2017
  * @description copy keys for connecting wallets list view
@@ -2004,6 +2004,10 @@ export declare const translation: {
2004
2004
  };
2005
2005
  log_out_button: string;
2006
2006
  title: string;
2007
+ already_exists: {
2008
+ title: string;
2009
+ description: string;
2010
+ };
2007
2011
  };
2008
2012
  /**
2009
2013
  * @description copy keys for connecting wallets list view
@@ -2004,6 +2004,10 @@ const translation = {
2004
2004
  },
2005
2005
  log_out_button: 'Log out',
2006
2006
  title: 'Transfer this wallet?',
2007
+ already_exists: {
2008
+ title: 'Wallet Already Linked',
2009
+ description: 'This wallet is already used as an embedded wallet. You cannot link it unless you delete the existing embedded wallet.',
2010
+ },
2007
2011
  },
2008
2012
  /**
2009
2013
  * @description copy keys for connecting wallets list view