@dynamic-labs/waas-svm 4.57.2 → 4.58.0

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,18 @@
1
1
 
2
+ ## [4.58.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.57.2...v4.58.0) (2026-01-28)
3
+
4
+
5
+ ### Features
6
+
7
+ * add password setup flow for WaaS wallets ([#10308](https://github.com/dynamic-labs/dynamic-auth/issues/10308)) ([aad892d](https://github.com/dynamic-labs/dynamic-auth/commit/aad892d0359df589753b141c1099a03c72b799d9))
8
+ * add useRefreshAuth ([#10280](https://github.com/dynamic-labs/dynamic-auth/issues/10280)) ([bff850a](https://github.com/dynamic-labs/dynamic-auth/commit/bff850afc4167d47d3a38c5e9845d35b754ea573))
9
+ * **waas:** add unlockWallet and getWalletRecoveryState methods ([#10286](https://github.com/dynamic-labs/dynamic-auth/issues/10286)) ([4c2f26b](https://github.com/dynamic-labs/dynamic-auth/commit/4c2f26b1cd6483406288513d73be66554cd3c66a))
10
+
11
+ ### Bug Fixes
12
+
13
+ * ensure refresh user not update the jwt ([#10278](https://github.com/dynamic-labs/dynamic-auth/issues/10278)) ([c8cdbe6](https://github.com/dynamic-labs/dynamic-auth/commit/c8cdbe6e10636b39985f299a219fa362c25b4cd0))
14
+ * use isVersionedTransaction for reliable Solana transaction type detection ([#10319](https://github.com/dynamic-labs/dynamic-auth/issues/10319)) ([472aa15](https://github.com/dynamic-labs/dynamic-auth/commit/472aa15a94cfe541b22b96c5c63483e6a5971781))
15
+
2
16
  ### [4.57.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.57.1...v4.57.2) (2026-01-23)
3
17
 
4
18
  ### [4.57.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.57.0...v4.57.1) (2026-01-22)
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.57.2";
6
+ var version = "4.58.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.57.2";
2
+ var version = "4.58.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/waas-svm",
3
- "version": "4.57.2",
3
+ "version": "4.58.0",
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",
@@ -19,17 +19,18 @@
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
21
  "@dynamic-labs/sdk-api-core": "0.0.860",
22
+ "@dynamic-labs/embedded-wallet-solana": "4.58.0",
22
23
  "@solana/web3.js": "1.98.1",
23
24
  "eventemitter3": "5.0.1",
24
25
  "bs58": "5.0.0",
25
- "@dynamic-labs/assert-package-version": "4.57.2",
26
- "@dynamic-labs/logger": "4.57.2",
27
- "@dynamic-labs/rpc-providers": "4.57.2",
28
- "@dynamic-labs/solana-core": "4.57.2",
29
- "@dynamic-labs/types": "4.57.2",
30
- "@dynamic-labs/utils": "4.57.2",
31
- "@dynamic-labs/waas": "4.57.2",
32
- "@dynamic-labs/wallet-connector-core": "4.57.2"
26
+ "@dynamic-labs/assert-package-version": "4.58.0",
27
+ "@dynamic-labs/logger": "4.58.0",
28
+ "@dynamic-labs/rpc-providers": "4.58.0",
29
+ "@dynamic-labs/solana-core": "4.58.0",
30
+ "@dynamic-labs/types": "4.58.0",
31
+ "@dynamic-labs/utils": "4.58.0",
32
+ "@dynamic-labs/waas": "4.58.0",
33
+ "@dynamic-labs/wallet-connector-core": "4.58.0"
33
34
  },
34
35
  "peerDependencies": {}
35
36
  }
@@ -10,6 +10,7 @@ var solanaCore = require('@dynamic-labs/solana-core');
10
10
  var utils = require('@dynamic-labs/utils');
11
11
  var waas = require('@dynamic-labs/waas');
12
12
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
13
+ var embeddedWalletSolana = require('@dynamic-labs/embedded-wallet-solana');
13
14
  var logger = require('../../utils/logger.cjs');
14
15
  var DynamicWaasSVMSigner = require('../signer/DynamicWaasSVMSigner.cjs');
15
16
  var logger$1 = require('@dynamic-labs/logger');
@@ -23,9 +24,53 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
23
24
  this.name = 'Dynamic Waas';
24
25
  this.overrideKey = 'dynamicwaas';
25
26
  this.isEmbeddedWallet = true;
27
+ this.svmGasSponsorshipEnabled = false;
26
28
  this.logger = logger.logger;
27
29
  this.walletUiUtils = props.walletUiUtils;
28
30
  }
31
+ /**
32
+ * Enable or disable SVM gas sponsorship for this connector.
33
+ */
34
+ setSvmGasSponsorshipEnabled(enabled) {
35
+ this.svmGasSponsorshipEnabled = enabled;
36
+ }
37
+ /**
38
+ * Check if a transaction is already signed (has non-zero signatures).
39
+ */
40
+ isTxAlreadySigned(transaction) {
41
+ if ('version' in transaction) {
42
+ return transaction.signatures.some((sig) => !sig.every((byte) => byte === 0));
43
+ }
44
+ return transaction.signatures.some((sig) => sig.signature && !sig.signature.every((byte) => byte === 0));
45
+ }
46
+ /**
47
+ * Sponsor a transaction if gas sponsorship is enabled and the tx is unsigned.
48
+ * Falls back to original transaction on error.
49
+ */
50
+ maybeSponsorTransaction(transaction) {
51
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
52
+ if (!this.svmGasSponsorshipEnabled) {
53
+ return transaction;
54
+ }
55
+ if (this.isTxAlreadySigned(transaction)) {
56
+ logger.logger.debug('[maybeSponsorTransaction] Skipping sponsorship - transaction already signed');
57
+ return transaction;
58
+ }
59
+ if (!this.environmentId) {
60
+ logger.logger.warn('[maybeSponsorTransaction] Missing environmentId, skipping sponsorship');
61
+ return transaction;
62
+ }
63
+ try {
64
+ const sponsoredTransaction = yield embeddedWalletSolana.sponsorSolanaTransaction(this.environmentId, transaction);
65
+ logger.logger.info('[maybeSponsorTransaction] Transaction sponsored successfully');
66
+ return sponsoredTransaction;
67
+ }
68
+ catch (error) {
69
+ logger.logger.warn('[maybeSponsorTransaction] Failed to sponsor transaction, using original', { error });
70
+ return transaction;
71
+ }
72
+ });
73
+ }
29
74
  /**
30
75
  * Override setEnvironmentId to ensure it's set on the global logger
31
76
  */
@@ -144,6 +189,8 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
144
189
  var _a, _b;
145
190
  const traceId = parentTraceId || this.generateTraceId();
146
191
  const effectiveStartTime = startTime || Date.now();
192
+ // Attempt to sponsor the transaction before signing
193
+ const txToSign = yield this.maybeSponsorTransaction(transaction);
147
194
  const walletClient = yield this.instrumentAsync({
148
195
  context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
149
196
  fn: () => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getWaasWalletClient(); }),
@@ -160,9 +207,10 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
160
207
  const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this, {
161
208
  mfaAction: sdkApiCore.MFAAction.WalletWaasSign,
162
209
  }));
163
- const messageBytes = transaction instanceof web3_js.Transaction
164
- ? transaction.serializeMessage()
165
- : transaction.message.serialize();
210
+ const isVersionedSolanaTransaction = solanaCore.isVersionedTransaction(txToSign);
211
+ const messageBytes = isVersionedSolanaTransaction
212
+ ? txToSign.message.serialize()
213
+ : txToSign.serializeMessage();
166
214
  const messageToSign = Buffer.from(messageBytes).toString('hex');
167
215
  const chainId = yield this.getNetwork(true);
168
216
  const senderAddress = this.activeAccountAddress;
@@ -186,17 +234,21 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
186
234
  operation: 'internalSignTransaction',
187
235
  resource: 'signTransaction',
188
236
  });
189
- transaction.addSignature(new web3_js.PublicKey(this.activeAccountAddress), Buffer.from(signature, 'hex'));
190
- try {
191
- transaction.serialize({
192
- requireAllSignatures: false,
193
- verifySignatures: true,
194
- });
195
- }
196
- catch (err) {
197
- logger.logger.warn('[internalSignTransaction] Error signing transaction', err);
237
+ txToSign.addSignature(new web3_js.PublicKey(this.activeAccountAddress), Buffer.from(signature, 'hex'));
238
+ // Optional signature verification (legacy Transaction only)
239
+ // VersionedTransaction.serialize() doesn't support signature verification
240
+ if (!isVersionedSolanaTransaction) {
241
+ try {
242
+ txToSign.serialize({
243
+ requireAllSignatures: false,
244
+ verifySignatures: true,
245
+ });
246
+ }
247
+ catch (err) {
248
+ logger.logger.warn('[internalSignTransaction] Signature verification failed for legacy Transaction', err);
249
+ }
198
250
  }
199
- return transaction;
251
+ return txToSign;
200
252
  });
201
253
  }
202
254
  signTransaction(transaction) {
@@ -294,6 +346,15 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
294
346
  operation: 'internalSignAndSendTransaction',
295
347
  resource: 'internalSignTransaction',
296
348
  });
349
+ // Serialize the transaction for sending
350
+ // VersionedTransaction.serialize() doesn't accept options, only legacy Transaction does
351
+ const isVersionedSolanaTransaction = solanaCore.isVersionedTransaction(signedTransaction);
352
+ const serializedTransaction = !isVersionedSolanaTransaction
353
+ ? signedTransaction.serialize({
354
+ requireAllSignatures: false,
355
+ verifySignatures: true,
356
+ })
357
+ : signedTransaction.serialize();
297
358
  const signature = yield this.instrumentAsync({
298
359
  context: {
299
360
  chainName: 'SVM',
@@ -301,12 +362,7 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
301
362
  startTime: effectiveStartTime,
302
363
  traceId,
303
364
  },
304
- fn: () => _tslib.__awaiter(this, void 0, void 0, function* () {
305
- return connection.sendRawTransaction(signedTransaction.serialize({
306
- requireAllSignatures: false,
307
- verifySignatures: true,
308
- }), options);
309
- }),
365
+ fn: () => _tslib.__awaiter(this, void 0, void 0, function* () { return connection.sendRawTransaction(serializedTransaction, options); }),
310
366
  operation: 'internalSignAndSendTransaction',
311
367
  resource: 'sendRawTransaction',
312
368
  });
@@ -112,6 +112,13 @@ declare const DynamicWaasSVMConnector_base: (abstract new (...args: any[]) => {
112
112
  message: string;
113
113
  password?: string | undefined;
114
114
  }): Promise<string>;
115
+ unlockWallet({ accountAddress, password, }: {
116
+ accountAddress: string;
117
+ password: string;
118
+ }): Promise<import("@dynamic-labs-wallet/core").GetWalletResponse>;
119
+ getWalletRecoveryState({ accountAddress, }: {
120
+ accountAddress: string;
121
+ }): Promise<import("@dynamic-labs-wallet/core").WalletRecoveryState>;
115
122
  endSession(): Promise<void>;
116
123
  getActiveAccountAddress(): Promise<string | undefined>;
117
124
  getConnectedAccounts(): Promise<string[]>;
@@ -131,7 +138,21 @@ export declare class DynamicWaasSVMConnector extends DynamicWaasSVMConnector_bas
131
138
  isEmbeddedWallet: boolean;
132
139
  activeAccountAddress: string | undefined;
133
140
  protected walletUiUtils: WalletUiUtils<InternalWalletConnector>;
141
+ private svmGasSponsorshipEnabled;
134
142
  constructor(props: DynamicWaasSVMConnectorProps);
143
+ /**
144
+ * Enable or disable SVM gas sponsorship for this connector.
145
+ */
146
+ setSvmGasSponsorshipEnabled(enabled: boolean): void;
147
+ /**
148
+ * Check if a transaction is already signed (has non-zero signatures).
149
+ */
150
+ private isTxAlreadySigned;
151
+ /**
152
+ * Sponsor a transaction if gas sponsorship is enabled and the tx is unsigned.
153
+ * Falls back to original transaction on error.
154
+ */
155
+ private maybeSponsorTransaction;
135
156
  /**
136
157
  * Override setEnvironmentId to ensure it's set on the global logger
137
158
  */
@@ -1,11 +1,12 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { Transaction, PublicKey } from '@solana/web3.js';
3
+ import { PublicKey } from '@solana/web3.js';
4
4
  import { MFAAction } from '@dynamic-labs/sdk-api-core';
5
- import { SolanaWalletConnector, SolanaUiTransaction } from '@dynamic-labs/solana-core';
5
+ import { SolanaWalletConnector, isVersionedTransaction, SolanaUiTransaction } from '@dynamic-labs/solana-core';
6
6
  import { DynamicError } from '@dynamic-labs/utils';
7
7
  import { withDynamicWaas } from '@dynamic-labs/waas';
8
8
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
9
+ import { sponsorSolanaTransaction } from '@dynamic-labs/embedded-wallet-solana';
9
10
  import { logger } from '../../utils/logger.js';
10
11
  import { DynamicWaasSVMSigner } from '../signer/DynamicWaasSVMSigner.js';
11
12
  import { Logger } from '@dynamic-labs/logger';
@@ -19,9 +20,53 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
19
20
  this.name = 'Dynamic Waas';
20
21
  this.overrideKey = 'dynamicwaas';
21
22
  this.isEmbeddedWallet = true;
23
+ this.svmGasSponsorshipEnabled = false;
22
24
  this.logger = logger;
23
25
  this.walletUiUtils = props.walletUiUtils;
24
26
  }
27
+ /**
28
+ * Enable or disable SVM gas sponsorship for this connector.
29
+ */
30
+ setSvmGasSponsorshipEnabled(enabled) {
31
+ this.svmGasSponsorshipEnabled = enabled;
32
+ }
33
+ /**
34
+ * Check if a transaction is already signed (has non-zero signatures).
35
+ */
36
+ isTxAlreadySigned(transaction) {
37
+ if ('version' in transaction) {
38
+ return transaction.signatures.some((sig) => !sig.every((byte) => byte === 0));
39
+ }
40
+ return transaction.signatures.some((sig) => sig.signature && !sig.signature.every((byte) => byte === 0));
41
+ }
42
+ /**
43
+ * Sponsor a transaction if gas sponsorship is enabled and the tx is unsigned.
44
+ * Falls back to original transaction on error.
45
+ */
46
+ maybeSponsorTransaction(transaction) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ if (!this.svmGasSponsorshipEnabled) {
49
+ return transaction;
50
+ }
51
+ if (this.isTxAlreadySigned(transaction)) {
52
+ logger.debug('[maybeSponsorTransaction] Skipping sponsorship - transaction already signed');
53
+ return transaction;
54
+ }
55
+ if (!this.environmentId) {
56
+ logger.warn('[maybeSponsorTransaction] Missing environmentId, skipping sponsorship');
57
+ return transaction;
58
+ }
59
+ try {
60
+ const sponsoredTransaction = yield sponsorSolanaTransaction(this.environmentId, transaction);
61
+ logger.info('[maybeSponsorTransaction] Transaction sponsored successfully');
62
+ return sponsoredTransaction;
63
+ }
64
+ catch (error) {
65
+ logger.warn('[maybeSponsorTransaction] Failed to sponsor transaction, using original', { error });
66
+ return transaction;
67
+ }
68
+ });
69
+ }
25
70
  /**
26
71
  * Override setEnvironmentId to ensure it's set on the global logger
27
72
  */
@@ -140,6 +185,8 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
140
185
  var _a, _b;
141
186
  const traceId = parentTraceId || this.generateTraceId();
142
187
  const effectiveStartTime = startTime || Date.now();
188
+ // Attempt to sponsor the transaction before signing
189
+ const txToSign = yield this.maybeSponsorTransaction(transaction);
143
190
  const walletClient = yield this.instrumentAsync({
144
191
  context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
145
192
  fn: () => __awaiter(this, void 0, void 0, function* () { return this.getWaasWalletClient(); }),
@@ -156,9 +203,10 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
156
203
  const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this, {
157
204
  mfaAction: MFAAction.WalletWaasSign,
158
205
  }));
159
- const messageBytes = transaction instanceof Transaction
160
- ? transaction.serializeMessage()
161
- : transaction.message.serialize();
206
+ const isVersionedSolanaTransaction = isVersionedTransaction(txToSign);
207
+ const messageBytes = isVersionedSolanaTransaction
208
+ ? txToSign.message.serialize()
209
+ : txToSign.serializeMessage();
162
210
  const messageToSign = Buffer.from(messageBytes).toString('hex');
163
211
  const chainId = yield this.getNetwork(true);
164
212
  const senderAddress = this.activeAccountAddress;
@@ -182,17 +230,21 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
182
230
  operation: 'internalSignTransaction',
183
231
  resource: 'signTransaction',
184
232
  });
185
- transaction.addSignature(new PublicKey(this.activeAccountAddress), Buffer.from(signature, 'hex'));
186
- try {
187
- transaction.serialize({
188
- requireAllSignatures: false,
189
- verifySignatures: true,
190
- });
191
- }
192
- catch (err) {
193
- logger.warn('[internalSignTransaction] Error signing transaction', err);
233
+ txToSign.addSignature(new PublicKey(this.activeAccountAddress), Buffer.from(signature, 'hex'));
234
+ // Optional signature verification (legacy Transaction only)
235
+ // VersionedTransaction.serialize() doesn't support signature verification
236
+ if (!isVersionedSolanaTransaction) {
237
+ try {
238
+ txToSign.serialize({
239
+ requireAllSignatures: false,
240
+ verifySignatures: true,
241
+ });
242
+ }
243
+ catch (err) {
244
+ logger.warn('[internalSignTransaction] Signature verification failed for legacy Transaction', err);
245
+ }
194
246
  }
195
- return transaction;
247
+ return txToSign;
196
248
  });
197
249
  }
198
250
  signTransaction(transaction) {
@@ -290,6 +342,15 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
290
342
  operation: 'internalSignAndSendTransaction',
291
343
  resource: 'internalSignTransaction',
292
344
  });
345
+ // Serialize the transaction for sending
346
+ // VersionedTransaction.serialize() doesn't accept options, only legacy Transaction does
347
+ const isVersionedSolanaTransaction = isVersionedTransaction(signedTransaction);
348
+ const serializedTransaction = !isVersionedSolanaTransaction
349
+ ? signedTransaction.serialize({
350
+ requireAllSignatures: false,
351
+ verifySignatures: true,
352
+ })
353
+ : signedTransaction.serialize();
293
354
  const signature = yield this.instrumentAsync({
294
355
  context: {
295
356
  chainName: 'SVM',
@@ -297,12 +358,7 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
297
358
  startTime: effectiveStartTime,
298
359
  traceId,
299
360
  },
300
- fn: () => __awaiter(this, void 0, void 0, function* () {
301
- return connection.sendRawTransaction(signedTransaction.serialize({
302
- requireAllSignatures: false,
303
- verifySignatures: true,
304
- }), options);
305
- }),
361
+ fn: () => __awaiter(this, void 0, void 0, function* () { return connection.sendRawTransaction(serializedTransaction, options); }),
306
362
  operation: 'internalSignAndSendTransaction',
307
363
  resource: 'sendRawTransaction',
308
364
  });