@dynamic-labs/aptos 4.41.1 → 4.43.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,29 @@
1
1
 
2
+ ## [4.43.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.42.0...v4.43.0) (2025-11-04)
3
+
4
+
5
+ ### Features
6
+
7
+ * add getOnrampQrCode ([#9794](https://github.com/dynamic-labs/dynamic-auth/issues/9794)) ([08a3dc9](https://github.com/dynamic-labs/dynamic-auth/commit/08a3dc944c0391f279f836f15255e6c16da18931))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * aptos wallet event listeners ([#9818](https://github.com/dynamic-labs/dynamic-auth/issues/9818)) ([5aa28c1](https://github.com/dynamic-labs/dynamic-auth/commit/5aa28c109909d4a81362f181be7be0df29d6a257))
13
+ * issue with adding totp mfa device after adding passkey ([#9822](https://github.com/dynamic-labs/dynamic-auth/issues/9822)) ([a372ea4](https://github.com/dynamic-labs/dynamic-auth/commit/a372ea4254b771d62044d53f82481b89630e7613))
14
+
15
+ ## [4.42.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.41.1...v4.42.0) (2025-11-04)
16
+
17
+
18
+ ### Features
19
+
20
+ * add support for send balance in React Native ([#9807](https://github.com/dynamic-labs/dynamic-auth/issues/9807)) ([40cab11](https://github.com/dynamic-labs/dynamic-auth/commit/40cab119f23d0b2efa5d6b161294bc682f1c0031))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * don't override mfa token on non-mfa related state updates ([#9817](https://github.com/dynamic-labs/dynamic-auth/issues/9817)) ([76dfbb9](https://github.com/dynamic-labs/dynamic-auth/commit/76dfbb9f5012709c6c400c1d51b8a20b2b99c3db))
26
+
2
27
  ### [4.41.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.41.0...v4.41.1) (2025-10-30)
3
28
 
4
29
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.41.1";
6
+ var version = "4.43.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.41.1";
2
+ var version = "4.43.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/aptos",
3
- "version": "4.41.1",
3
+ "version": "4.43.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",
@@ -20,13 +20,13 @@
20
20
  "dependencies": {
21
21
  "@aptos-labs/ts-sdk": "5.1.1",
22
22
  "@aptos-labs/wallet-standard": "0.5.2",
23
- "@dynamic-labs/assert-package-version": "4.41.1",
23
+ "@dynamic-labs/assert-package-version": "4.43.0",
24
24
  "@wallet-standard/core": "1.1.1",
25
25
  "@wallet-standard/features": "1.0.3",
26
- "@dynamic-labs/logger": "4.41.1",
27
- "@dynamic-labs/utils": "4.41.1",
28
- "@dynamic-labs/wallet-book": "4.41.1",
29
- "@dynamic-labs/wallet-connector-core": "4.41.1"
26
+ "@dynamic-labs/logger": "4.43.0",
27
+ "@dynamic-labs/utils": "4.43.0",
28
+ "@dynamic-labs/wallet-book": "4.43.0",
29
+ "@dynamic-labs/wallet-connector-core": "4.43.0"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
@@ -294,37 +294,99 @@ class AptosProviderHelper {
294
294
  });
295
295
  return;
296
296
  }
297
+ // Clean up any existing listeners first
298
+ this._teardownEventListeners();
297
299
  const onAccountChangeMethod = provider === null || provider === void 0 ? void 0 : provider.onAccountChange;
298
300
  const onNetworkChangeMethod = provider === null || provider === void 0 ? void 0 : provider.onNetworkChange;
299
301
  if (onAccountChangeMethod) {
300
- onAccountChangeMethod((account) => {
302
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Setting up account change listener', {
303
+ connector: this.connector.name,
304
+ });
305
+ const unsubscribe = onAccountChangeMethod((account) => {
306
+ var _a;
307
+ const newAddress = (_a = account === null || account === void 0 ? void 0 : account.address) === null || _a === void 0 ? void 0 : _a.toString();
308
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Account change event received', {
309
+ address: newAddress,
310
+ connector: this.connector.name,
311
+ hasAccount: Boolean(account),
312
+ lastAddress: this.lastAccountAddress,
313
+ });
314
+ // Skip if account hasn't actually changed
315
+ if (account && newAddress === this.lastAccountAddress) {
316
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Account address unchanged, skipping', {
317
+ address: newAddress,
318
+ connector: this.connector.name,
319
+ });
320
+ return;
321
+ }
301
322
  if (account) {
323
+ this.lastAccountAddress = newAddress;
302
324
  this.handleAccountChange(this.connector, provider, account.address.toString());
303
325
  }
304
326
  else {
327
+ this.lastAccountAddress = undefined;
328
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Account is null, emitting disconnect', {
329
+ connector: this.connector.name,
330
+ });
305
331
  this.connector.emit('disconnect');
306
332
  }
307
333
  });
334
+ this.unsubscribeAccountChange =
335
+ typeof unsubscribe === 'function' ? unsubscribe : undefined;
336
+ if (!this.unsubscribeAccountChange) {
337
+ walletConnectorCore.logger.warn('[AptosProviderHelper] onAccountChange did not return unsubscribe function', {
338
+ connector: this.connector.name,
339
+ });
340
+ }
341
+ }
342
+ else {
343
+ walletConnectorCore.logger.debug('[AptosProviderHelper] onAccountChange method not available', {
344
+ connector: this.connector.name,
345
+ hasProvider: Boolean(provider),
346
+ });
308
347
  }
309
348
  if (onNetworkChangeMethod) {
310
- onNetworkChangeMethod((network) => {
349
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Setting up network change listener', {
350
+ connector: this.connector.name,
351
+ });
352
+ const unsubscribe = onNetworkChangeMethod((network) => {
353
+ walletConnectorCore.logger.debug('[AptosProviderHelper] Network change event received', {
354
+ chainId: network.chainId,
355
+ connector: this.connector.name,
356
+ });
311
357
  if (network.chainId) {
312
358
  this.connector.emit('chainChange', {
313
359
  chain: network.chainId.toString(),
314
360
  });
315
361
  }
316
362
  });
363
+ this.unsubscribeNetworkChange =
364
+ typeof unsubscribe === 'function' ? unsubscribe : undefined;
365
+ if (!this.unsubscribeNetworkChange) {
366
+ walletConnectorCore.logger.warn('[AptosProviderHelper] onNetworkChange did not return unsubscribe function', {
367
+ connector: this.connector.name,
368
+ });
369
+ }
370
+ }
371
+ else {
372
+ walletConnectorCore.logger.debug('[AptosProviderHelper] onNetworkChange method not available', {
373
+ connector: this.connector.name,
374
+ });
317
375
  }
318
376
  }
319
377
  /**
320
378
  * Tears down event listeners.
321
379
  */
322
380
  _teardownEventListeners() {
323
- const provider = this.findProvider();
324
- if (!provider)
325
- return;
326
- // Aptos providers don't have removeAllListeners like Solana
327
- // Event listeners are automatically cleaned up when the provider is destroyed
381
+ // Call unsubscribe functions if they exist
382
+ if (this.unsubscribeAccountChange) {
383
+ this.unsubscribeAccountChange();
384
+ this.unsubscribeAccountChange = undefined;
385
+ }
386
+ if (this.unsubscribeNetworkChange) {
387
+ this.unsubscribeNetworkChange();
388
+ this.unsubscribeNetworkChange = undefined;
389
+ }
328
390
  }
329
391
  }
330
392
 
@@ -13,6 +13,9 @@ import type { InjectedWalletBase } from './InjectedWalletBase';
13
13
  export declare class AptosProviderHelper {
14
14
  private walletBookWallet;
15
15
  private connector;
16
+ private unsubscribeAccountChange?;
17
+ private unsubscribeNetworkChange?;
18
+ private lastAccountAddress?;
16
19
  constructor(connector: InjectedWalletBase);
17
20
  /**
18
21
  * Gets the installed Aptos provider using legacy injection.
@@ -290,37 +290,99 @@ class AptosProviderHelper {
290
290
  });
291
291
  return;
292
292
  }
293
+ // Clean up any existing listeners first
294
+ this._teardownEventListeners();
293
295
  const onAccountChangeMethod = provider === null || provider === void 0 ? void 0 : provider.onAccountChange;
294
296
  const onNetworkChangeMethod = provider === null || provider === void 0 ? void 0 : provider.onNetworkChange;
295
297
  if (onAccountChangeMethod) {
296
- onAccountChangeMethod((account) => {
298
+ logger.debug('[AptosProviderHelper] Setting up account change listener', {
299
+ connector: this.connector.name,
300
+ });
301
+ const unsubscribe = onAccountChangeMethod((account) => {
302
+ var _a;
303
+ const newAddress = (_a = account === null || account === void 0 ? void 0 : account.address) === null || _a === void 0 ? void 0 : _a.toString();
304
+ logger.debug('[AptosProviderHelper] Account change event received', {
305
+ address: newAddress,
306
+ connector: this.connector.name,
307
+ hasAccount: Boolean(account),
308
+ lastAddress: this.lastAccountAddress,
309
+ });
310
+ // Skip if account hasn't actually changed
311
+ if (account && newAddress === this.lastAccountAddress) {
312
+ logger.debug('[AptosProviderHelper] Account address unchanged, skipping', {
313
+ address: newAddress,
314
+ connector: this.connector.name,
315
+ });
316
+ return;
317
+ }
297
318
  if (account) {
319
+ this.lastAccountAddress = newAddress;
298
320
  this.handleAccountChange(this.connector, provider, account.address.toString());
299
321
  }
300
322
  else {
323
+ this.lastAccountAddress = undefined;
324
+ logger.debug('[AptosProviderHelper] Account is null, emitting disconnect', {
325
+ connector: this.connector.name,
326
+ });
301
327
  this.connector.emit('disconnect');
302
328
  }
303
329
  });
330
+ this.unsubscribeAccountChange =
331
+ typeof unsubscribe === 'function' ? unsubscribe : undefined;
332
+ if (!this.unsubscribeAccountChange) {
333
+ logger.warn('[AptosProviderHelper] onAccountChange did not return unsubscribe function', {
334
+ connector: this.connector.name,
335
+ });
336
+ }
337
+ }
338
+ else {
339
+ logger.debug('[AptosProviderHelper] onAccountChange method not available', {
340
+ connector: this.connector.name,
341
+ hasProvider: Boolean(provider),
342
+ });
304
343
  }
305
344
  if (onNetworkChangeMethod) {
306
- onNetworkChangeMethod((network) => {
345
+ logger.debug('[AptosProviderHelper] Setting up network change listener', {
346
+ connector: this.connector.name,
347
+ });
348
+ const unsubscribe = onNetworkChangeMethod((network) => {
349
+ logger.debug('[AptosProviderHelper] Network change event received', {
350
+ chainId: network.chainId,
351
+ connector: this.connector.name,
352
+ });
307
353
  if (network.chainId) {
308
354
  this.connector.emit('chainChange', {
309
355
  chain: network.chainId.toString(),
310
356
  });
311
357
  }
312
358
  });
359
+ this.unsubscribeNetworkChange =
360
+ typeof unsubscribe === 'function' ? unsubscribe : undefined;
361
+ if (!this.unsubscribeNetworkChange) {
362
+ logger.warn('[AptosProviderHelper] onNetworkChange did not return unsubscribe function', {
363
+ connector: this.connector.name,
364
+ });
365
+ }
366
+ }
367
+ else {
368
+ logger.debug('[AptosProviderHelper] onNetworkChange method not available', {
369
+ connector: this.connector.name,
370
+ });
313
371
  }
314
372
  }
315
373
  /**
316
374
  * Tears down event listeners.
317
375
  */
318
376
  _teardownEventListeners() {
319
- const provider = this.findProvider();
320
- if (!provider)
321
- return;
322
- // Aptos providers don't have removeAllListeners like Solana
323
- // Event listeners are automatically cleaned up when the provider is destroyed
377
+ // Call unsubscribe functions if they exist
378
+ if (this.unsubscribeAccountChange) {
379
+ this.unsubscribeAccountChange();
380
+ this.unsubscribeAccountChange = undefined;
381
+ }
382
+ if (this.unsubscribeNetworkChange) {
383
+ this.unsubscribeNetworkChange();
384
+ this.unsubscribeNetworkChange = undefined;
385
+ }
324
386
  }
325
387
  }
326
388
 
@@ -140,13 +140,22 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
140
140
  return result;
141
141
  });
142
142
  const onAccountChange = (callback) => {
143
- var _a;
144
- const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
143
+ var _a, _b;
144
+ // First, try to use the Aptos-specific onAccountChange feature if available
145
+ const aptosOnAccountChange = (_a = features['aptos:onAccountChange']) === null || _a === void 0 ? void 0 : _a.onAccountChange;
146
+ if (aptosOnAccountChange) {
147
+ logger.debug('[AptosWalletStandardConnector] Using aptos:onAccountChange feature');
148
+ const unsubscribe = aptosOnAccountChange(callback);
149
+ // Ensure we return a synchronous unsubscribe function
150
+ return typeof unsubscribe === 'function' ? unsubscribe : () => { };
151
+ }
152
+ // Fall back to standard:events if Aptos-specific feature is not available
153
+ const onMethod = (_b = features['standard:events']) === null || _b === void 0 ? void 0 : _b.on;
145
154
  if (!onMethod) {
146
155
  logger.debug('[AptosWalletStandardConnector] Events not implemented by wallet');
147
156
  return () => { };
148
157
  }
149
- logger.debug('[AptosWalletStandardConnector] Setting up account change listener');
158
+ logger.debug('[AptosWalletStandardConnector] Setting up account change listener via standard:events');
150
159
  const wrappedCallback = (prop) => {
151
160
  var _a;
152
161
  const account = (_a = prop.accounts) === null || _a === void 0 ? void 0 : _a[0];
@@ -164,13 +173,22 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
164
173
  return onMethod('change', wrappedCallback);
165
174
  };
166
175
  const onNetworkChange = (callback) => {
167
- var _a;
168
- const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
176
+ var _a, _b;
177
+ // First, try to use the Aptos-specific onNetworkChange feature if available
178
+ const aptosOnNetworkChange = (_a = features['aptos:onNetworkChange']) === null || _a === void 0 ? void 0 : _a.onNetworkChange;
179
+ if (aptosOnNetworkChange) {
180
+ logger.debug('[AptosWalletStandardConnector] Using aptos:onNetworkChange feature');
181
+ const unsubscribe = aptosOnNetworkChange(callback);
182
+ // Ensure we return a synchronous unsubscribe function
183
+ return typeof unsubscribe === 'function' ? unsubscribe : () => { };
184
+ }
185
+ // Fall back to standard:events if Aptos-specific feature is not available
186
+ const onMethod = (_b = features['standard:events']) === null || _b === void 0 ? void 0 : _b.on;
169
187
  if (!onMethod) {
170
188
  logger.debug('[AptosWalletStandardConnector] Events not implemented by wallet');
171
189
  return () => { };
172
190
  }
173
- logger.debug('[AptosWalletStandardConnector] Setting up network change listener');
191
+ logger.debug('[AptosWalletStandardConnector] Setting up network change listener via standard:events');
174
192
  const wrappedCallback = (prop) => {
175
193
  // Network changes might be indicated through feature changes
176
194
  // This is wallet-specific and may need adjustment
@@ -136,13 +136,22 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
136
136
  return result;
137
137
  });
138
138
  const onAccountChange = (callback) => {
139
- var _a;
140
- const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
139
+ var _a, _b;
140
+ // First, try to use the Aptos-specific onAccountChange feature if available
141
+ const aptosOnAccountChange = (_a = features['aptos:onAccountChange']) === null || _a === void 0 ? void 0 : _a.onAccountChange;
142
+ if (aptosOnAccountChange) {
143
+ logger.debug('[AptosWalletStandardConnector] Using aptos:onAccountChange feature');
144
+ const unsubscribe = aptosOnAccountChange(callback);
145
+ // Ensure we return a synchronous unsubscribe function
146
+ return typeof unsubscribe === 'function' ? unsubscribe : () => { };
147
+ }
148
+ // Fall back to standard:events if Aptos-specific feature is not available
149
+ const onMethod = (_b = features['standard:events']) === null || _b === void 0 ? void 0 : _b.on;
141
150
  if (!onMethod) {
142
151
  logger.debug('[AptosWalletStandardConnector] Events not implemented by wallet');
143
152
  return () => { };
144
153
  }
145
- logger.debug('[AptosWalletStandardConnector] Setting up account change listener');
154
+ logger.debug('[AptosWalletStandardConnector] Setting up account change listener via standard:events');
146
155
  const wrappedCallback = (prop) => {
147
156
  var _a;
148
157
  const account = (_a = prop.accounts) === null || _a === void 0 ? void 0 : _a[0];
@@ -160,13 +169,22 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
160
169
  return onMethod('change', wrappedCallback);
161
170
  };
162
171
  const onNetworkChange = (callback) => {
163
- var _a;
164
- const onMethod = (_a = features['standard:events']) === null || _a === void 0 ? void 0 : _a.on;
172
+ var _a, _b;
173
+ // First, try to use the Aptos-specific onNetworkChange feature if available
174
+ const aptosOnNetworkChange = (_a = features['aptos:onNetworkChange']) === null || _a === void 0 ? void 0 : _a.onNetworkChange;
175
+ if (aptosOnNetworkChange) {
176
+ logger.debug('[AptosWalletStandardConnector] Using aptos:onNetworkChange feature');
177
+ const unsubscribe = aptosOnNetworkChange(callback);
178
+ // Ensure we return a synchronous unsubscribe function
179
+ return typeof unsubscribe === 'function' ? unsubscribe : () => { };
180
+ }
181
+ // Fall back to standard:events if Aptos-specific feature is not available
182
+ const onMethod = (_b = features['standard:events']) === null || _b === void 0 ? void 0 : _b.on;
165
183
  if (!onMethod) {
166
184
  logger.debug('[AptosWalletStandardConnector] Events not implemented by wallet');
167
185
  return () => { };
168
186
  }
169
- logger.debug('[AptosWalletStandardConnector] Setting up network change listener');
187
+ logger.debug('[AptosWalletStandardConnector] Setting up network change listener via standard:events');
170
188
  const wrappedCallback = (prop) => {
171
189
  // Network changes might be indicated through feature changes
172
190
  // This is wallet-specific and may need adjustment