@dynamic-labs/waas-evm 4.12.2 → 4.12.4

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,14 @@
1
1
 
2
+ ### [4.12.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.3...v4.12.4) (2025-04-18)
3
+
4
+ ### [4.12.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.2...v4.12.3) (2025-04-17)
5
+
6
+
7
+ ### Features
8
+
9
+ * default waas sui connector network based on enabled chains ([#8570](https://github.com/dynamic-labs/dynamic-auth/issues/8570)) ([9a11b01](https://github.com/dynamic-labs/dynamic-auth/commit/9a11b019bc8ed51873de9d24c93bcc3c1ed6406b))
10
+ * dynamic waas can sign smart account transactiosn ([#8551](https://github.com/dynamic-labs/dynamic-auth/issues/8551)) ([f4882eb](https://github.com/dynamic-labs/dynamic-auth/commit/f4882ebc869b5af72c3beb187bd1a98b83c06e04))
11
+
2
12
  ### [4.12.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.12.1...v4.12.2) (2025-04-16)
3
13
 
4
14
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.12.2";
6
+ var version = "4.12.4";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.12.2";
2
+ var version = "4.12.4";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/waas-evm",
3
- "version": "4.12.2",
3
+ "version": "4.12.4",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -18,14 +18,15 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs-wallet/evm": "0.0.60",
22
- "viem": "2.21.55",
23
- "@dynamic-labs/assert-package-version": "4.12.2",
24
- "@dynamic-labs/ethereum-core": "4.12.2",
25
- "@dynamic-labs/logger": "4.12.2",
26
- "@dynamic-labs/types": "4.12.2",
27
- "@dynamic-labs/utils": "4.12.2",
28
- "@dynamic-labs/wallet-connector-core": "4.12.2"
21
+ "@dynamic-labs-wallet/evm": "0.0.63",
22
+ "@dynamic-labs/sdk-api-core": "0.0.658",
23
+ "viem": "2.21.60",
24
+ "@dynamic-labs/assert-package-version": "4.12.4",
25
+ "@dynamic-labs/ethereum-core": "4.12.4",
26
+ "@dynamic-labs/logger": "4.12.4",
27
+ "@dynamic-labs/types": "4.12.4",
28
+ "@dynamic-labs/utils": "4.12.4",
29
+ "@dynamic-labs/wallet-connector-core": "4.12.4"
29
30
  },
30
31
  "peerDependencies": {}
31
32
  }
@@ -20,6 +20,37 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
20
20
  this.overrideKey = 'dynamicwaas';
21
21
  this.isEmbeddedWallet = true;
22
22
  }
23
+ set verifiedCredentials(verifiedCredentials) {
24
+ this._verifiedCredentials = verifiedCredentials;
25
+ }
26
+ get verifiedCredentials() {
27
+ return this._verifiedCredentials;
28
+ }
29
+ set verifiedCredential(verifiedCredential) {
30
+ this._verifiedCredential = verifiedCredential;
31
+ }
32
+ get verifiedCredential() {
33
+ return this._verifiedCredential;
34
+ }
35
+ setVerifiedCredentials(verifiedCredentials) {
36
+ const dynamicWaasVerifiedCredentials = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.reduce((acc, vc) => {
37
+ if (vc.walletName === 'dynamicwaas' && vc.chain === 'eip155') {
38
+ const smartWallet = verifiedCredentials.find((v) => v.signerRefId === vc.id);
39
+ const smartWalletRefId = smartWallet === null || smartWallet === void 0 ? void 0 : smartWallet.id;
40
+ const smartWalletRefAddress = smartWallet === null || smartWallet === void 0 ? void 0 : smartWallet.address;
41
+ acc.push(Object.assign(Object.assign({}, vc), { smartWalletRefAddress, smartWalletRefId }));
42
+ }
43
+ return acc;
44
+ }, []);
45
+ const [dynamicWaasVerifiedCredential] = dynamicWaasVerifiedCredentials;
46
+ const didDynamicWaasVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredentials) !==
47
+ JSON.stringify(dynamicWaasVerifiedCredentials);
48
+ if (!didDynamicWaasVerifiedCredentialsChanged) {
49
+ return;
50
+ }
51
+ this.verifiedCredential = dynamicWaasVerifiedCredential;
52
+ this.verifiedCredentials = dynamicWaasVerifiedCredentials;
53
+ }
23
54
  setGetAuthTokenFunction(getAuthToken) {
24
55
  this.getAuthToken = getAuthToken;
25
56
  }
@@ -167,21 +198,25 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
167
198
  return this.getPublicClient();
168
199
  }
169
200
  const rpcUrl = this.getRpcUrl();
170
- const viemAccount = this.getViemAccount({
171
- accountAddress: targetAccountAddress,
172
- });
173
201
  const evmNetwork = chainId
174
202
  ? this.getEvmNetworkByChainId(parseInt(chainId))
175
203
  : this.currentEvmNetwork();
176
204
  if (!evmNetwork) {
177
205
  throw new Error('EVM network not found');
178
206
  }
179
- const walletClient = viem.createWalletClient({
180
- account: viemAccount,
207
+ return ethereumCore.createWalletClientWithUiConfirmation({
208
+ account: () => _tslib.__awaiter(this, void 0, void 0, function* () {
209
+ return this.getViemAccount({
210
+ accountAddress: targetAccountAddress,
211
+ });
212
+ }),
213
+ address: targetAccountAddress,
181
214
  chain: ethereumCore.getOrMapViemChain(evmNetwork),
182
215
  transport: viem.http(rpcUrl, this.providersConfig.httpTransportConfig),
216
+ // TODO: remove this. We should not be passing references to wallet connectors
217
+ walletConnector: this,
218
+ walletUiUtils: this.walletUiUtils,
183
219
  });
184
- return walletClient;
185
220
  }
186
221
  createWalletAccount() {
187
222
  return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
@@ -282,6 +317,19 @@ class DynamicWaasEVMConnector extends ethereumCore.EthereumWalletConnector {
282
317
  });
283
318
  });
284
319
  }
320
+ getConnectedAccounts() {
321
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
322
+ var _a;
323
+ const verifiedCredentials = this.verifiedCredentials || [];
324
+ const addresses = verifiedCredentials
325
+ .map((vc) => vc === null || vc === void 0 ? void 0 : vc.address)
326
+ .filter((a) => typeof a === 'string');
327
+ if (addresses.length > 0 && ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address)) {
328
+ this.setActiveAccount(this.verifiedCredential.address);
329
+ }
330
+ return addresses;
331
+ });
332
+ }
285
333
  }
286
334
  DynamicWaasEVMConnector.lastUsedChainIdStorageKey = 'dynamic-waas-evm-last-used-chain-id';
287
335
 
@@ -4,8 +4,12 @@ import { DynamicEvmWalletClient } from '@dynamic-labs-wallet/evm';
4
4
  import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import { EthereumWalletConnector, SwitchNetworkOps, EthereumWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
6
6
  import { IUITransaction } from '@dynamic-labs/types';
7
+ import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
8
+ interface JwtVerifiedCredentialWithSmartWalletRef extends JwtVerifiedCredential {
9
+ smartWalletRefId?: string;
10
+ smartWalletRefAddress?: string;
11
+ }
7
12
  export declare class DynamicWaasEVMConnector extends EthereumWalletConnector implements IDynamicWaasConnector {
8
- static lastUsedChainIdStorageKey: string;
9
13
  name: string;
10
14
  overrideKey: string;
11
15
  isEmbeddedWallet: boolean;
@@ -14,7 +18,22 @@ export declare class DynamicWaasEVMConnector extends EthereumWalletConnector imp
14
18
  private dynamicWaasClient;
15
19
  private baseApiUrl?;
16
20
  private relayUrl?;
21
+ /**
22
+ * Relationship between verifiedCredential and verifiedCredentials:
23
+ * - verifiedCredential: The first/primary credential from the array (used for active account)
24
+ * - verifiedCredentials: The full array of all credentials
25
+ * When setVerifiedCredentials is called, it processes the input array and sets both properties
26
+ * The first credential (verifiedCredential) is specifically filtered to be a "dynamicwaas"
27
+ */
28
+ private _verifiedCredential;
29
+ private _verifiedCredentials;
30
+ static lastUsedChainIdStorageKey: string;
17
31
  constructor(props: EthereumWalletConnectorOpts);
32
+ set verifiedCredentials(verifiedCredentials: JwtVerifiedCredentialWithSmartWalletRef[] | undefined);
33
+ get verifiedCredentials(): JwtVerifiedCredentialWithSmartWalletRef[] | undefined;
34
+ set verifiedCredential(verifiedCredential: JwtVerifiedCredentialWithSmartWalletRef | undefined);
35
+ get verifiedCredential(): JwtVerifiedCredentialWithSmartWalletRef | undefined;
36
+ setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
18
37
  setGetAuthTokenFunction(getAuthToken: () => string): void;
19
38
  setEnvironmentId(environmentId: string): void;
20
39
  setBaseApiUrl(baseApiUrl: string): void;
@@ -60,4 +79,6 @@ export declare class DynamicWaasEVMConnector extends EthereumWalletConnector imp
60
79
  accountAddress: string;
61
80
  }): Promise<void>;
62
81
  createUiTransaction(from: string): Promise<IUITransaction>;
82
+ getConnectedAccounts(): Promise<string[]>;
63
83
  }
84
+ export {};
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../_virtual/_tslib.js';
3
- import { createWalletClient, http, erc20Abi } from 'viem';
3
+ import { http, erc20Abi } from 'viem';
4
4
  import { toAccount } from 'viem/accounts';
5
5
  import { DynamicEvmWalletClient } from '@dynamic-labs-wallet/evm';
6
6
  import { Logger } from '@dynamic-labs/logger';
7
7
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
8
- import { EthereumWalletConnector, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
8
+ import { EthereumWalletConnector, createWalletClientWithUiConfirmation, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
9
9
  import { DynamicError } from '@dynamic-labs/utils';
10
10
 
11
11
  const logger = new Logger('DynamicWaasConnector');
@@ -16,6 +16,37 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
16
16
  this.overrideKey = 'dynamicwaas';
17
17
  this.isEmbeddedWallet = true;
18
18
  }
19
+ set verifiedCredentials(verifiedCredentials) {
20
+ this._verifiedCredentials = verifiedCredentials;
21
+ }
22
+ get verifiedCredentials() {
23
+ return this._verifiedCredentials;
24
+ }
25
+ set verifiedCredential(verifiedCredential) {
26
+ this._verifiedCredential = verifiedCredential;
27
+ }
28
+ get verifiedCredential() {
29
+ return this._verifiedCredential;
30
+ }
31
+ setVerifiedCredentials(verifiedCredentials) {
32
+ const dynamicWaasVerifiedCredentials = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.reduce((acc, vc) => {
33
+ if (vc.walletName === 'dynamicwaas' && vc.chain === 'eip155') {
34
+ const smartWallet = verifiedCredentials.find((v) => v.signerRefId === vc.id);
35
+ const smartWalletRefId = smartWallet === null || smartWallet === void 0 ? void 0 : smartWallet.id;
36
+ const smartWalletRefAddress = smartWallet === null || smartWallet === void 0 ? void 0 : smartWallet.address;
37
+ acc.push(Object.assign(Object.assign({}, vc), { smartWalletRefAddress, smartWalletRefId }));
38
+ }
39
+ return acc;
40
+ }, []);
41
+ const [dynamicWaasVerifiedCredential] = dynamicWaasVerifiedCredentials;
42
+ const didDynamicWaasVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredentials) !==
43
+ JSON.stringify(dynamicWaasVerifiedCredentials);
44
+ if (!didDynamicWaasVerifiedCredentialsChanged) {
45
+ return;
46
+ }
47
+ this.verifiedCredential = dynamicWaasVerifiedCredential;
48
+ this.verifiedCredentials = dynamicWaasVerifiedCredentials;
49
+ }
19
50
  setGetAuthTokenFunction(getAuthToken) {
20
51
  this.getAuthToken = getAuthToken;
21
52
  }
@@ -163,21 +194,25 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
163
194
  return this.getPublicClient();
164
195
  }
165
196
  const rpcUrl = this.getRpcUrl();
166
- const viemAccount = this.getViemAccount({
167
- accountAddress: targetAccountAddress,
168
- });
169
197
  const evmNetwork = chainId
170
198
  ? this.getEvmNetworkByChainId(parseInt(chainId))
171
199
  : this.currentEvmNetwork();
172
200
  if (!evmNetwork) {
173
201
  throw new Error('EVM network not found');
174
202
  }
175
- const walletClient = createWalletClient({
176
- account: viemAccount,
203
+ return createWalletClientWithUiConfirmation({
204
+ account: () => __awaiter(this, void 0, void 0, function* () {
205
+ return this.getViemAccount({
206
+ accountAddress: targetAccountAddress,
207
+ });
208
+ }),
209
+ address: targetAccountAddress,
177
210
  chain: getOrMapViemChain(evmNetwork),
178
211
  transport: http(rpcUrl, this.providersConfig.httpTransportConfig),
212
+ // TODO: remove this. We should not be passing references to wallet connectors
213
+ walletConnector: this,
214
+ walletUiUtils: this.walletUiUtils,
179
215
  });
180
- return walletClient;
181
216
  }
182
217
  createWalletAccount() {
183
218
  return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
@@ -278,6 +313,19 @@ class DynamicWaasEVMConnector extends EthereumWalletConnector {
278
313
  });
279
314
  });
280
315
  }
316
+ getConnectedAccounts() {
317
+ return __awaiter(this, void 0, void 0, function* () {
318
+ var _a;
319
+ const verifiedCredentials = this.verifiedCredentials || [];
320
+ const addresses = verifiedCredentials
321
+ .map((vc) => vc === null || vc === void 0 ? void 0 : vc.address)
322
+ .filter((a) => typeof a === 'string');
323
+ if (addresses.length > 0 && ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address)) {
324
+ this.setActiveAccount(this.verifiedCredential.address);
325
+ }
326
+ return addresses;
327
+ });
328
+ }
281
329
  }
282
330
  DynamicWaasEVMConnector.lastUsedChainIdStorageKey = 'dynamic-waas-evm-last-used-chain-id';
283
331