@dynamic-labs/sdk-react-core 4.20.5 → 4.20.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [4.20.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.5...v4.20.6) (2025-06-18)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * parse input to eth_signTypedData_v4 with global wallets ([#8964](https://github.com/dynamic-labs/dynamic-auth/issues/8964)) ([6035b5a](https://github.com/dynamic-labs/dynamic-auth/commit/6035b5afcb3af44833e5f9dd9f423b865c06e729))
8
+ * utilize wallet zerodev properties when available in react native ([#8974](https://github.com/dynamic-labs/dynamic-auth/issues/8974)) ([a2390b3](https://github.com/dynamic-labs/dynamic-auth/commit/a2390b367999fd7bfc4e142c1b4ea8d5fab0eece))
9
+
2
10
  ### [4.20.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.20.4...v4.20.5) (2025-06-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 = "4.20.5";
6
+ var version = "4.20.6";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.688",
9
9
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.20.5";
2
+ var version = "4.20.6";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.688",
5
5
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.20.5",
3
+ "version": "4.20.6",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.688",
6
6
  "@dynamic-labs-sdk/client": "0.0.1-alpha.5",
@@ -15,16 +15,16 @@
15
15
  "yup": "0.32.11",
16
16
  "react-international-phone": "4.2.5",
17
17
  "bs58": "5.0.0",
18
- "@dynamic-labs/assert-package-version": "4.20.5",
19
- "@dynamic-labs/iconic": "4.20.5",
20
- "@dynamic-labs/logger": "4.20.5",
21
- "@dynamic-labs/multi-wallet": "4.20.5",
22
- "@dynamic-labs/rpc-providers": "4.20.5",
23
- "@dynamic-labs/store": "4.20.5",
24
- "@dynamic-labs/types": "4.20.5",
25
- "@dynamic-labs/utils": "4.20.5",
26
- "@dynamic-labs/wallet-book": "4.20.5",
27
- "@dynamic-labs/wallet-connector-core": "4.20.5",
18
+ "@dynamic-labs/assert-package-version": "4.20.6",
19
+ "@dynamic-labs/iconic": "4.20.6",
20
+ "@dynamic-labs/logger": "4.20.6",
21
+ "@dynamic-labs/multi-wallet": "4.20.6",
22
+ "@dynamic-labs/rpc-providers": "4.20.6",
23
+ "@dynamic-labs/store": "4.20.6",
24
+ "@dynamic-labs/types": "4.20.6",
25
+ "@dynamic-labs/utils": "4.20.6",
26
+ "@dynamic-labs/wallet-book": "4.20.6",
27
+ "@dynamic-labs/wallet-connector-core": "4.20.6",
28
28
  "eventemitter3": "5.0.1"
29
29
  },
30
30
  "devDependencies": {
@@ -103,11 +103,17 @@ const useHandleLogout = (params) => {
103
103
  const paramsRef = React.useRef(params);
104
104
  paramsRef.current = params;
105
105
  const logout = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
106
+ const p = paramsRef.current;
107
+ // We store which wallet connectors were active before logout
108
+ // to not have to worry about having the array change midway through
109
+ const activeConnectors = [
110
+ ...p.walletConnectors,
111
+ ...p.connectedWallets.map((connectedWallet) => connectedWallet.connector),
112
+ ];
106
113
  logger.logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
107
114
  params: paramsRef.current,
108
115
  });
109
116
  utils.tracing.logEvent('logout', 'useHandleLogout called');
110
- const p = paramsRef.current;
111
117
  p.setSelectedWalletConnectorKey(null);
112
118
  p.clearAllWalletConnectSessions();
113
119
  p.setShowDynamicUserProfile(false);
@@ -150,8 +156,7 @@ const useHandleLogout = (params) => {
150
156
  p.removeSessionStorageSessionKeys();
151
157
  dynamicEvents.dynamicEvents.emit('logout');
152
158
  user.setUser(undefined);
153
- yield Promise.all(p.walletConnectors.map((connector) => connector.endSession()));
154
- yield Promise.all(p.connectedWallets.map((connectedWallet) => connectedWallet.connector.endSession()));
159
+ yield Promise.all(activeConnectors.map((connector) => connector.endSession()));
155
160
  }), []);
156
161
  /** Trigger a logout when the SDK failed to load data from storage */
157
162
  React.useEffect(() => {
@@ -99,11 +99,17 @@ const useHandleLogout = (params) => {
99
99
  const paramsRef = useRef(params);
100
100
  paramsRef.current = params;
101
101
  const logout = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
102
+ const p = paramsRef.current;
103
+ // We store which wallet connectors were active before logout
104
+ // to not have to worry about having the array change midway through
105
+ const activeConnectors = [
106
+ ...p.walletConnectors,
107
+ ...p.connectedWallets.map((connectedWallet) => connectedWallet.connector),
108
+ ];
102
109
  logger.logVerboseTroubleshootingMessage('useHandleLogout called', {
103
110
  params: paramsRef.current,
104
111
  });
105
112
  tracing.logEvent('logout', 'useHandleLogout called');
106
- const p = paramsRef.current;
107
113
  p.setSelectedWalletConnectorKey(null);
108
114
  p.clearAllWalletConnectSessions();
109
115
  p.setShowDynamicUserProfile(false);
@@ -146,8 +152,7 @@ const useHandleLogout = (params) => {
146
152
  p.removeSessionStorageSessionKeys();
147
153
  dynamicEvents.emit('logout');
148
154
  setUser(undefined);
149
- yield Promise.all(p.walletConnectors.map((connector) => connector.endSession()));
150
- yield Promise.all(p.connectedWallets.map((connectedWallet) => connectedWallet.connector.endSession()));
155
+ yield Promise.all(activeConnectors.map((connector) => connector.endSession()));
151
156
  }), []);
152
157
  /** Trigger a logout when the SDK failed to load data from storage */
153
158
  useEffect(() => {
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains';
6
+ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to the Dynamic Dashboard, select Embedded Wallets, and then click the gear icon on the top row to enable a new chain.';
7
7
  const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
8
8
  const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
9
9
  const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
@@ -1,4 +1,4 @@
1
- export declare const NO_ENABLED_CHAINS_ERROR = "No enabled embedded wallet chains";
1
+ export declare const NO_ENABLED_CHAINS_ERROR = "No enabled embedded wallet chains. Please go to the Dynamic Dashboard, select Embedded Wallets, and then click the gear icon on the top row to enable a new chain.";
2
2
  export declare const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = "Dynamic Waas connector not found";
3
3
  export declare const INVALID_CHAINS_ERROR = "The following chains are not enabled for embedded wallets";
4
4
  export declare const WALLET_CREATION_FAILED_ERROR = "Failed to create wallet account for the following chains";
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains';
2
+ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to the Dynamic Dashboard, select Embedded Wallets, and then click the gear icon on the top row to enable a new chain.';
3
3
  const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
4
4
  const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
5
5
  const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
@@ -185,10 +185,21 @@ const useDynamicWaas = () => {
185
185
  const account = yield walletConnector.createWalletAccount();
186
186
  return Object.assign(Object.assign({}, account), { chainName: chain });
187
187
  })));
188
- const failedChains = chainNames.filter((_, i) => results[i].status === 'rejected');
188
+ const failedChains = [];
189
+ const errors = [];
190
+ results.forEach((result, i) => {
191
+ if (result.status === 'rejected') {
192
+ const chainName = chainNames[i];
193
+ failedChains.push(chainName);
194
+ const errorMessage = result.reason instanceof Error
195
+ ? result.reason.message
196
+ : String(result.reason);
197
+ errors.push(`${chainName}: ${errorMessage}`);
198
+ }
199
+ });
189
200
  if (failedChains.length > 0) {
190
201
  refresh();
191
- throw new utils.DynamicError(`${constants.WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}`);
202
+ throw new utils.DynamicError(`${constants.WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}`);
192
203
  }
193
204
  const createdWalletAccounts = results.map((r) => r.status === 'fulfilled' ? r.value : undefined);
194
205
  const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
@@ -225,29 +236,21 @@ const useDynamicWaas = () => {
225
236
  addedWalletsIds,
226
237
  ]);
227
238
  const needsAutoCreateWalletChains = React.useMemo(() => {
228
- const hasDynamicWaasWalletForChain = (chain) => {
229
- var _a;
230
- return (_a = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => {
231
- var _a;
232
- return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas')) &&
233
- wallet.chain &&
234
- compareChains.compareChains(wallet.chain, chain);
235
- })) !== null && _a !== void 0 ? _a : false;
236
- };
237
- const hasDynamicWaasWalletForAllEnabledChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.every(hasDynamicWaasWalletForChain);
238
- const missingChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.filter((chain) => !hasDynamicWaasWalletForChain(chain));
239
- const hasExistingV1orV2Wallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => {
240
- var _a, _b;
241
- return ((_a = wallet.walletProperties) === null || _a === void 0 ? void 0 : _a.version) === sdkApiCore.EmbeddedWalletVersionEnum.V1 || // V1 wallet
242
- ((_b = wallet.walletProperties) === null || _b === void 0 ? void 0 : _b.version) === sdkApiCore.EmbeddedWalletVersionEnum.V2;
243
- });
244
239
  if (!user$1 ||
245
- hasDynamicWaasWalletForAllEnabledChains || // already has a dynamic waas wallet for all enabled chains
246
- !dynamicWaasIsEnabled || // dynamic waas is not enabled
247
- !automaticEmbeddedWalletCreationEnabled || // automatic embedded wallet creation is not enabled
248
- hasExistingV1orV2Wallet // already has a v2 or v1 wallet
249
- )
240
+ !dynamicWaasIsEnabled ||
241
+ !automaticEmbeddedWalletCreationEnabled) {
250
242
  return [];
243
+ }
244
+ // check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
245
+ const hasEmbeddedWalletForChain = (chain) => {
246
+ var _a;
247
+ return (_a = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((wallet) => wallet.chain &&
248
+ compareChains.compareChains(wallet.chain, chain) &&
249
+ wallet.walletProvider === sdkApiCore.WalletProviderEnum.EmbeddedWallet)) !== null && _a !== void 0 ? _a : false;
250
+ };
251
+ // For each enabled chain, if user does NOT have a V3 wallet and does NOT have a V1/V2 wallet, add to missing
252
+ const missingChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.filter((chain) => !hasEmbeddedWalletForChain(chain));
253
+ // If user has an external wallet, only create if automaticEmbeddedWalletCreationForExternalEnabled is true
251
254
  const hasExternalWallet = user$1 === null || user$1 === void 0 ? void 0 : user$1.verifiedCredentials.some((vc) => vc.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain &&
252
255
  vc.walletProvider !== sdkApiCore.WalletProviderEnum.EmbeddedWallet);
253
256
  const shouldCreateDynamicWaasWallet = hasExternalWallet
@@ -181,10 +181,21 @@ const useDynamicWaas = () => {
181
181
  const account = yield walletConnector.createWalletAccount();
182
182
  return Object.assign(Object.assign({}, account), { chainName: chain });
183
183
  })));
184
- const failedChains = chainNames.filter((_, i) => results[i].status === 'rejected');
184
+ const failedChains = [];
185
+ const errors = [];
186
+ results.forEach((result, i) => {
187
+ if (result.status === 'rejected') {
188
+ const chainName = chainNames[i];
189
+ failedChains.push(chainName);
190
+ const errorMessage = result.reason instanceof Error
191
+ ? result.reason.message
192
+ : String(result.reason);
193
+ errors.push(`${chainName}: ${errorMessage}`);
194
+ }
195
+ });
185
196
  if (failedChains.length > 0) {
186
197
  refresh();
187
- throw new DynamicError(`${WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}`);
198
+ throw new DynamicError(`${WALLET_CREATION_FAILED_ERROR}: ${failedChains.join(', ')}. Errors: ${errors.join('; ')}`);
188
199
  }
189
200
  const createdWalletAccounts = results.map((r) => r.status === 'fulfilled' ? r.value : undefined);
190
201
  const primaryWalletAccount = createdWalletAccounts === null || createdWalletAccounts === void 0 ? void 0 : createdWalletAccounts.find((wallet) => (wallet === null || wallet === void 0 ? void 0 : wallet.chainName) === (primaryChain === null || primaryChain === void 0 ? void 0 : primaryChain.name));
@@ -221,29 +232,21 @@ const useDynamicWaas = () => {
221
232
  addedWalletsIds,
222
233
  ]);
223
234
  const needsAutoCreateWalletChains = useMemo(() => {
224
- const hasDynamicWaasWalletForChain = (chain) => {
225
- var _a;
226
- return (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => {
227
- var _a;
228
- return ((_a = wallet.walletName) === null || _a === void 0 ? void 0 : _a.includes('dynamicwaas')) &&
229
- wallet.chain &&
230
- compareChains(wallet.chain, chain);
231
- })) !== null && _a !== void 0 ? _a : false;
232
- };
233
- const hasDynamicWaasWalletForAllEnabledChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.every(hasDynamicWaasWalletForChain);
234
- const missingChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.filter((chain) => !hasDynamicWaasWalletForChain(chain));
235
- const hasExistingV1orV2Wallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => {
236
- var _a, _b;
237
- return ((_a = wallet.walletProperties) === null || _a === void 0 ? void 0 : _a.version) === EmbeddedWalletVersionEnum.V1 || // V1 wallet
238
- ((_b = wallet.walletProperties) === null || _b === void 0 ? void 0 : _b.version) === EmbeddedWalletVersionEnum.V2;
239
- });
240
235
  if (!user ||
241
- hasDynamicWaasWalletForAllEnabledChains || // already has a dynamic waas wallet for all enabled chains
242
- !dynamicWaasIsEnabled || // dynamic waas is not enabled
243
- !automaticEmbeddedWalletCreationEnabled || // automatic embedded wallet creation is not enabled
244
- hasExistingV1orV2Wallet // already has a v2 or v1 wallet
245
- )
236
+ !dynamicWaasIsEnabled ||
237
+ !automaticEmbeddedWalletCreationEnabled) {
246
238
  return [];
239
+ }
240
+ // check if user have any wallet (V1, V2, or V3/dynamicwaas) for this chain
241
+ const hasEmbeddedWalletForChain = (chain) => {
242
+ var _a;
243
+ return (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((wallet) => wallet.chain &&
244
+ compareChains(wallet.chain, chain) &&
245
+ wallet.walletProvider === WalletProviderEnum.EmbeddedWallet)) !== null && _a !== void 0 ? _a : false;
246
+ };
247
+ // For each enabled chain, if user does NOT have a V3 wallet and does NOT have a V1/V2 wallet, add to missing
248
+ const missingChains = enabledChainNames === null || enabledChainNames === void 0 ? void 0 : enabledChainNames.filter((chain) => !hasEmbeddedWalletForChain(chain));
249
+ // If user has an external wallet, only create if automaticEmbeddedWalletCreationForExternalEnabled is true
247
250
  const hasExternalWallet = user === null || user === void 0 ? void 0 : user.verifiedCredentials.some((vc) => vc.format === JwtVerifiedCredentialFormatEnum.Blockchain &&
248
251
  vc.walletProvider !== WalletProviderEnum.EmbeddedWallet);
249
252
  const shouldCreateDynamicWaasWallet = hasExternalWallet