@dynamic-labs/aptos 4.42.0 → 4.44.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,31 @@
1
1
 
2
+ ## [4.44.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.43.0...v4.44.0) (2025-11-05)
3
+
4
+
5
+ ### Features
6
+
7
+ * add isAptosWallet method ([#9827](https://github.com/dynamic-labs/dynamic-auth/issues/9827)) ([3810b7b](https://github.com/dynamic-labs/dynamic-auth/commit/3810b7b83039a1521cb67ed13dd256eeb336b432))
8
+ * show all Aptos wallets even if not installed ([#9837](https://github.com/dynamic-labs/dynamic-auth/issues/9837)) ([bc32f55](https://github.com/dynamic-labs/dynamic-auth/commit/bc32f55da243574ee1fa1522b65cf5bd1de4958f))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * backpack wallet for solana wallet connect ([#9833](https://github.com/dynamic-labs/dynamic-auth/issues/9833)) ([013bbdd](https://github.com/dynamic-labs/dynamic-auth/commit/013bbdd771adae02d03439074dd4c006e2a9515d))
14
+ * sendbalance on aptos ([#9829](https://github.com/dynamic-labs/dynamic-auth/issues/9829)) ([8bd57b9](https://github.com/dynamic-labs/dynamic-auth/commit/8bd57b96a376095f51a469fe894496952cf2bc0f))
15
+
16
+ ## [4.43.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.42.0...v4.43.0) (2025-11-04)
17
+
18
+
19
+ ### Features
20
+
21
+ * add getOnrampQrCode ([#9794](https://github.com/dynamic-labs/dynamic-auth/issues/9794)) ([08a3dc9](https://github.com/dynamic-labs/dynamic-auth/commit/08a3dc944c0391f279f836f15255e6c16da18931))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * aptos wallet event listeners ([#9818](https://github.com/dynamic-labs/dynamic-auth/issues/9818)) ([5aa28c1](https://github.com/dynamic-labs/dynamic-auth/commit/5aa28c109909d4a81362f181be7be0df29d6a257))
27
+ * 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))
28
+
2
29
  ## [4.42.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.41.1...v4.42.0) (2025-11-04)
3
30
 
4
31
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.42.0";
6
+ var version = "4.44.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.42.0";
2
+ var version = "4.44.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.42.0",
3
+ "version": "4.44.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,14 @@
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.42.0",
23
+ "@dynamic-labs/assert-package-version": "4.44.0",
24
24
  "@wallet-standard/core": "1.1.1",
25
25
  "@wallet-standard/features": "1.0.3",
26
- "@dynamic-labs/logger": "4.42.0",
27
- "@dynamic-labs/utils": "4.42.0",
28
- "@dynamic-labs/wallet-book": "4.42.0",
29
- "@dynamic-labs/wallet-connector-core": "4.42.0"
26
+ "@dynamic-labs/logger": "4.44.0",
27
+ "@dynamic-labs/types": "4.44.0",
28
+ "@dynamic-labs/utils": "4.44.0",
29
+ "@dynamic-labs/wallet-book": "4.44.0",
30
+ "@dynamic-labs/wallet-connector-core": "4.44.0"
30
31
  },
31
32
  "peerDependencies": {}
32
33
  }
@@ -23,6 +23,7 @@ var AptosWallet = require('../../wallet/AptosWallet.cjs');
23
23
  */
24
24
  class AptosWalletConnector extends walletConnectorCore.WalletConnectorBase {
25
25
  constructor(name, opts) {
26
+ var _a;
26
27
  super({ metadata: opts.metadata, walletBook: opts.walletBook });
27
28
  this.name = 'Aptos';
28
29
  this.ChainWallet = AptosWallet.AptosWallet;
@@ -33,6 +34,22 @@ class AptosWalletConnector extends walletConnectorCore.WalletConnectorBase {
33
34
  this.isConnecting = false;
34
35
  this.name = name;
35
36
  this.logger = new logger.Logger(this.name);
37
+ this.aptosNetworks = (_a = opts.aptosNetworks) !== null && _a !== void 0 ? _a : [];
38
+ }
39
+ getEnabledNetworks() {
40
+ return this.aptosNetworks;
41
+ }
42
+ getNetwork() {
43
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
44
+ const provider = this.getProvider();
45
+ assertProvider.assertProvider(provider);
46
+ const network = yield invokeWalletMethod.invokeWalletMethod(provider, 'aptos:network', 'network');
47
+ if (network === null || network === void 0 ? void 0 : network.chainId) {
48
+ return network.chainId;
49
+ }
50
+ // default to mainnet
51
+ return 1;
52
+ });
36
53
  }
37
54
  /**
38
55
  * Connects to the Aptos wallet.
@@ -121,12 +138,9 @@ class AptosWalletConnector extends walletConnectorCore.WalletConnectorBase {
121
138
  return parseTransactionResponse.parseTransactionResponse(response);
122
139
  }
123
140
  catch (error) {
124
- // If signAndSubmit not available, fall back to sign + submit
141
+ this.logger.error('[signAndSubmitTransaction] Error:', error);
142
+ throw new utils.DynamicError('Failed to sign and submit transaction');
125
143
  }
126
- // Fallback: sign then submit separately
127
- const signedTx = yield this.signTransaction(transaction);
128
- const authenticator = 'args' in signedTx ? signedTx.args : signedTx;
129
- return this.submitTransaction(authenticator);
130
144
  });
131
145
  }
132
146
  /**
@@ -1,8 +1,9 @@
1
1
  import type { AccountAuthenticator, AnyRawTransaction } from '@aptos-labs/ts-sdk';
2
- import { Aptos } from '@aptos-labs/ts-sdk';
2
+ import { Aptos, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
3
3
  import type { AccountInfo, AptosSignMessageInput, AptosSignMessageOutput, NetworkInfo, UserResponse } from '@aptos-labs/wallet-standard';
4
4
  import { Logger } from '@dynamic-labs/logger';
5
5
  import { type Chain, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
6
+ import { GenericNetwork } from '@dynamic-labs/types';
6
7
  import type { AptosWalletConnectorProps, IAptosProvider } from '../../types';
7
8
  import { AptosWallet } from '../../wallet/AptosWallet';
8
9
  /**
@@ -24,12 +25,15 @@ export declare abstract class AptosWalletConnector extends WalletConnectorBase<t
24
25
  logger: Logger;
25
26
  /** Connection state */
26
27
  protected isConnecting: boolean;
28
+ aptosNetworks: GenericNetwork[];
27
29
  constructor(name: string, opts: AptosWalletConnectorProps);
28
30
  /**
29
31
  * Abstract method to get the wallet provider.
30
32
  * Must be implemented by concrete connector classes.
31
33
  */
32
34
  abstract getProvider(): IAptosProvider | undefined;
35
+ getEnabledNetworks(): GenericNetwork[];
36
+ getNetwork(): Promise<number | undefined>;
33
37
  /**
34
38
  * Connects to the Aptos wallet.
35
39
  */
@@ -55,7 +59,7 @@ export declare abstract class AptosWalletConnector extends WalletConnectorBase<t
55
59
  /**
56
60
  * Signs and submits a transaction.
57
61
  */
58
- signAndSubmitTransaction(transaction: AnyRawTransaction): Promise<string>;
62
+ signAndSubmitTransaction(transaction: InputGenerateTransactionPayloadData): Promise<string>;
59
63
  /**
60
64
  * Submits a signed transaction.
61
65
  */
@@ -19,6 +19,7 @@ import { AptosWallet } from '../../wallet/AptosWallet.js';
19
19
  */
20
20
  class AptosWalletConnector extends WalletConnectorBase {
21
21
  constructor(name, opts) {
22
+ var _a;
22
23
  super({ metadata: opts.metadata, walletBook: opts.walletBook });
23
24
  this.name = 'Aptos';
24
25
  this.ChainWallet = AptosWallet;
@@ -29,6 +30,22 @@ class AptosWalletConnector extends WalletConnectorBase {
29
30
  this.isConnecting = false;
30
31
  this.name = name;
31
32
  this.logger = new Logger(this.name);
33
+ this.aptosNetworks = (_a = opts.aptosNetworks) !== null && _a !== void 0 ? _a : [];
34
+ }
35
+ getEnabledNetworks() {
36
+ return this.aptosNetworks;
37
+ }
38
+ getNetwork() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const provider = this.getProvider();
41
+ assertProvider(provider);
42
+ const network = yield invokeWalletMethod(provider, 'aptos:network', 'network');
43
+ if (network === null || network === void 0 ? void 0 : network.chainId) {
44
+ return network.chainId;
45
+ }
46
+ // default to mainnet
47
+ return 1;
48
+ });
32
49
  }
33
50
  /**
34
51
  * Connects to the Aptos wallet.
@@ -117,12 +134,9 @@ class AptosWalletConnector extends WalletConnectorBase {
117
134
  return parseTransactionResponse(response);
118
135
  }
119
136
  catch (error) {
120
- // If signAndSubmit not available, fall back to sign + submit
137
+ this.logger.error('[signAndSubmitTransaction] Error:', error);
138
+ throw new DynamicError('Failed to sign and submit transaction');
121
139
  }
122
- // Fallback: sign then submit separately
123
- const signedTx = yield this.signTransaction(transaction);
124
- const authenticator = 'args' in signedTx ? signedTx.args : signedTx;
125
- return this.submitTransaction(authenticator);
126
140
  });
127
141
  }
128
142
  /**
package/src/index.cjs CHANGED
@@ -17,6 +17,7 @@ var assertProvider = require('./utils/assertProvider/assertProvider.cjs');
17
17
  var getWalletStandardWallets = require('./utils/getWalletStandardWallets/getWalletStandardWallets.cjs');
18
18
  var invokeWalletMethod = require('./utils/invokeWalletMethod/invokeWalletMethod.cjs');
19
19
  var isWalletWithRequiredFeatureSet = require('./utils/isWalletWithRequiredFeatureSet/isWalletWithRequiredFeatureSet.cjs');
20
+ var isAptosWallet = require('./wallet/isAptosWallet/isAptosWallet.cjs');
20
21
  var parseConnectionResult = require('./utils/parseConnectionResult/parseConnectionResult.cjs');
21
22
  var parseTransactionResponse = require('./utils/parseTransactionResponse/parseTransactionResponse.cjs');
22
23
 
@@ -34,6 +35,7 @@ exports.assertProvider = assertProvider.assertProvider;
34
35
  exports.getWalletStandardWallets = getWalletStandardWallets.getWalletStandardWallets;
35
36
  exports.invokeWalletMethod = invokeWalletMethod.invokeWalletMethod;
36
37
  exports.isWalletWithRequiredFeatureSet = isWalletWithRequiredFeatureSet.isWalletWithRequiredFeatureSet;
38
+ exports.isAptosWallet = isAptosWallet.isAptosWallet;
37
39
  exports.parseConnectionResult = parseConnectionResult.parseConnectionResult;
38
40
  exports.parseTransactionResponse = parseTransactionResponse.parseTransactionResponse;
39
41
  exports.AptosWalletConnectors = AptosWalletConnectors;
package/src/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { assertProvider } from './utils/assertProvider';
5
5
  export { getWalletStandardWallets } from './utils/getWalletStandardWallets';
6
6
  export { invokeWalletMethod } from './utils/invokeWalletMethod';
7
7
  export { isWalletWithRequiredFeatureSet } from './utils/isWalletWithRequiredFeatureSet';
8
+ export { isAptosWallet } from './wallet/isAptosWallet/isAptosWallet';
8
9
  export { parseConnectionResult, type ParsedAccountInfo, } from './utils/parseConnectionResult';
9
10
  export { parseTransactionResponse } from './utils/parseTransactionResponse';
10
11
  export declare const AptosWalletConnectors: (props: any) => import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor[];
package/src/index.js CHANGED
@@ -13,6 +13,7 @@ export { assertProvider } from './utils/assertProvider/assertProvider.js';
13
13
  export { getWalletStandardWallets } from './utils/getWalletStandardWallets/getWalletStandardWallets.js';
14
14
  export { invokeWalletMethod } from './utils/invokeWalletMethod/invokeWalletMethod.js';
15
15
  export { isWalletWithRequiredFeatureSet } from './utils/isWalletWithRequiredFeatureSet/isWalletWithRequiredFeatureSet.js';
16
+ export { isAptosWallet } from './wallet/isAptosWallet/isAptosWallet.js';
16
17
  export { parseConnectionResult } from './utils/parseConnectionResult/parseConnectionResult.js';
17
18
  export { parseTransactionResponse } from './utils/parseTransactionResponse/parseTransactionResponse.js';
18
19
 
@@ -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
 
@@ -60,14 +60,14 @@ class InjectedWalletBase extends AptosWalletConnector.AptosWalletConnector {
60
60
  getAddress() {
61
61
  return _tslib.__awaiter(this, void 0, void 0, function* () {
62
62
  var _a;
63
- if (!this.isInstalledOnBrowser()) {
63
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
64
+ if (didOpenInAppBrowser) {
64
65
  return;
65
66
  }
66
67
  // If no address, we need to connect first to trigger the wallet popup
67
68
  yield this.connect();
68
69
  // Now try to get the address again
69
- const address = yield ((_a = this.aptosProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
70
- return address;
70
+ return (_a = this.aptosProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
71
71
  });
72
72
  }
73
73
  signMessage(messageToSign) {
@@ -56,14 +56,14 @@ class InjectedWalletBase extends AptosWalletConnector {
56
56
  getAddress() {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  var _a;
59
- if (!this.isInstalledOnBrowser()) {
59
+ const didOpenInAppBrowser = this.openInAppBrowserIfRequired();
60
+ if (didOpenInAppBrowser) {
60
61
  return;
61
62
  }
62
63
  // If no address, we need to connect first to trigger the wallet popup
63
64
  yield this.connect();
64
65
  // Now try to get the address again
65
- const address = yield ((_a = this.aptosProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
66
- return address;
66
+ return (_a = this.aptosProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
67
67
  });
68
68
  }
69
69
  signMessage(messageToSign) {
@@ -77,24 +77,27 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
77
77
  * Fetches all available injected Aptos wallet connectors.
78
78
  *
79
79
  * This function discovers and creates wallet connector constructors from two sources:
80
- * 1. Wallet book entries - Traditional wallets defined in the wallet book
81
- * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard
80
+ * 1. Wallet book entries - All Aptos wallets defined in the wallet book (including uninstalled wallet-standard wallets)
81
+ * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard (installed wallets only)
82
+ *
83
+ * The function creates connectors for:
84
+ * - Installed wallet-standard wallets (discovered via wallet-standard)
85
+ * - Uninstalled wallet-standard wallets (from wallet book, will use wallet-standard when installed)
86
+ * - Traditional wallets without wallet-standard support (from wallet book)
82
87
  *
83
88
  * The function automatically filters out wallets that:
84
89
  * - Have custom connector implementations
85
- * - Are already handled by wallet-standard connectors
90
+ * - Are already discovered via wallet-standard (to avoid duplicates)
86
91
  * - Don't support the required Aptos feature set
87
92
  *
88
93
  * @param options - Configuration options
89
94
  * @param options.walletBook - The wallet book schema containing wallet metadata
90
- * @param options.authMode - The authentication mode for filtering wallet features
91
95
  * @returns Array of wallet connector constructor classes
92
96
  *
93
97
  * @example
94
98
  * ```typescript
95
99
  * const connectors = fetchInjectedWalletConnectors({
96
100
  * walletBook,
97
- * authMode: 'connect-and-sign'
98
101
  * });
99
102
  *
100
103
  * // Instantiate connectors
@@ -105,40 +108,15 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
105
108
  */
106
109
  const fetchInjectedWalletConnectors = ({ walletBook: walletBook$1, }) => {
107
110
  var _a;
108
- // Get wallet book connectors for traditional Aptos wallets
109
- const walletBookConnectors = Object.entries((_a = walletBook$1 === null || walletBook$1 === void 0 ? void 0 : walletBook$1.wallets) !== null && _a !== void 0 ? _a : {})
110
- .filter(([key, wallet]) => {
111
- var _a, _b, _c;
112
- const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'aptos');
113
- const isAptosWallet = Boolean(injectedConfig);
114
- // Filter out wallets that require a custom connector or wallets that support wallet-standard,
115
- // since they are already handled automatically with the wallet-standard connector
116
- const shouldBeFiltered = walletsWithCustomConnectors.includes(key) ||
117
- ((_c = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.features) === null || _c === void 0 ? void 0 : _c.length);
118
- return isAptosWallet && !shouldBeFiltered;
119
- })
120
- .map(([key, wallet]) => {
121
- const { shortName } = wallet;
122
- const name = shortName || wallet.name;
123
- return class extends InjectedWalletBase.InjectedWalletBase {
124
- constructor() {
125
- super(...arguments);
126
- this.name = name;
127
- // This is the key from the wallet book entry so that we don't purely rely on the normalized name
128
- this.overrideKey = key;
129
- }
130
- getProvider() {
131
- return this.findProvider();
132
- }
133
- };
134
- });
135
- // Get wallet-standard wallets
111
+ // Get wallet-standard wallets (only installed wallets are discovered)
136
112
  const { aptosWallets } = getWalletStandardWallets.getWalletStandardWallets();
113
+ // Create a map of wallet-standard wallet names for quick lookup
114
+ const walletStandardWalletNames = new Set(aptosWallets.map((wallet) => wallet.name));
137
115
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Found wallet-standard wallets:', aptosWallets.map((w) => ({
138
116
  features: Object.keys(w.features),
139
117
  name: w.name,
140
118
  })));
141
- // Create connectors for wallet-standard wallets
119
+ // Create connectors for installed wallet-standard wallets
142
120
  const walletStandardConnectors = aptosWallets
143
121
  .filter((wallet) =>
144
122
  // Type incompatibility between @wallet-standard versions, casting is safe here
@@ -160,6 +138,46 @@ const fetchInjectedWalletConnectors = ({ walletBook: walletBook$1, }) => {
160
138
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
161
139
  wallet, walletBookMetadata);
162
140
  });
141
+ // Get wallet book connectors for ALL Aptos wallets
142
+ // This includes:
143
+ // 1. Traditional wallets (no wallet-standard support)
144
+ // 2. Wallet-standard wallets that are NOT yet installed (discovered via wallet book)
145
+ const walletBookConnectors = Object.entries((_a = walletBook$1 === null || walletBook$1 === void 0 ? void 0 : walletBook$1.wallets) !== null && _a !== void 0 ? _a : {})
146
+ .filter(([key, wallet]) => {
147
+ var _a, _b;
148
+ const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'aptos');
149
+ const isAptosWallet = Boolean(injectedConfig);
150
+ // Filter out wallets that require a custom connector
151
+ const needsCustomConnector = walletsWithCustomConnectors.includes(key);
152
+ // Filter out wallets that are already discovered via wallet-standard (installed)
153
+ // We want to show uninstalled wallet-standard wallets from wallet book
154
+ const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
155
+ const isAlreadyDiscoveredViaWalletStandard = walletStandardName && walletStandardWalletNames.has(walletStandardName);
156
+ return (isAptosWallet &&
157
+ !needsCustomConnector &&
158
+ !isAlreadyDiscoveredViaWalletStandard);
159
+ })
160
+ .map(([key, wallet]) => {
161
+ const { shortName } = wallet;
162
+ const name = shortName || wallet.name;
163
+ // Get wallet metadata from wallet book
164
+ const walletBookMetadata = walletConnectorCore.getWalletMetadataFromWalletBook({
165
+ walletBook: walletBook$1,
166
+ walletBookWallet: wallet,
167
+ walletKey: key,
168
+ });
169
+ return class extends InjectedWalletBase.InjectedWalletBase {
170
+ constructor(props) {
171
+ super(name, Object.assign(Object.assign({}, props), { aptosNetworks: props.aptosNetworks, metadata: walletBookMetadata, walletBook: props.walletBook }));
172
+ this.name = name;
173
+ // This is the key from the wallet book entry so that we don't purely rely on the normalized name
174
+ this.overrideKey = key;
175
+ }
176
+ getProvider() {
177
+ return this.findProvider();
178
+ }
179
+ };
180
+ });
163
181
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Created wallet-standard connectors:', walletStandardConnectors.map((w) => w.name));
164
182
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Created wallet-book connectors:', walletBookConnectors.map((w) => w.name));
165
183
  return [
@@ -17,24 +17,27 @@ export declare const injectedWalletOverrides: WalletConnectorConstructor[];
17
17
  * Fetches all available injected Aptos wallet connectors.
18
18
  *
19
19
  * This function discovers and creates wallet connector constructors from two sources:
20
- * 1. Wallet book entries - Traditional wallets defined in the wallet book
21
- * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard
20
+ * 1. Wallet book entries - All Aptos wallets defined in the wallet book (including uninstalled wallet-standard wallets)
21
+ * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard (installed wallets only)
22
+ *
23
+ * The function creates connectors for:
24
+ * - Installed wallet-standard wallets (discovered via wallet-standard)
25
+ * - Uninstalled wallet-standard wallets (from wallet book, will use wallet-standard when installed)
26
+ * - Traditional wallets without wallet-standard support (from wallet book)
22
27
  *
23
28
  * The function automatically filters out wallets that:
24
29
  * - Have custom connector implementations
25
- * - Are already handled by wallet-standard connectors
30
+ * - Are already discovered via wallet-standard (to avoid duplicates)
26
31
  * - Don't support the required Aptos feature set
27
32
  *
28
33
  * @param options - Configuration options
29
34
  * @param options.walletBook - The wallet book schema containing wallet metadata
30
- * @param options.authMode - The authentication mode for filtering wallet features
31
35
  * @returns Array of wallet connector constructor classes
32
36
  *
33
37
  * @example
34
38
  * ```typescript
35
39
  * const connectors = fetchInjectedWalletConnectors({
36
40
  * walletBook,
37
- * authMode: 'connect-and-sign'
38
41
  * });
39
42
  *
40
43
  * // Instantiate connectors
@@ -73,24 +73,27 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
73
73
  * Fetches all available injected Aptos wallet connectors.
74
74
  *
75
75
  * This function discovers and creates wallet connector constructors from two sources:
76
- * 1. Wallet book entries - Traditional wallets defined in the wallet book
77
- * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard
76
+ * 1. Wallet book entries - All Aptos wallets defined in the wallet book (including uninstalled wallet-standard wallets)
77
+ * 2. Wallet-standard wallets - AIP-62 compliant wallets discovered via wallet-standard (installed wallets only)
78
+ *
79
+ * The function creates connectors for:
80
+ * - Installed wallet-standard wallets (discovered via wallet-standard)
81
+ * - Uninstalled wallet-standard wallets (from wallet book, will use wallet-standard when installed)
82
+ * - Traditional wallets without wallet-standard support (from wallet book)
78
83
  *
79
84
  * The function automatically filters out wallets that:
80
85
  * - Have custom connector implementations
81
- * - Are already handled by wallet-standard connectors
86
+ * - Are already discovered via wallet-standard (to avoid duplicates)
82
87
  * - Don't support the required Aptos feature set
83
88
  *
84
89
  * @param options - Configuration options
85
90
  * @param options.walletBook - The wallet book schema containing wallet metadata
86
- * @param options.authMode - The authentication mode for filtering wallet features
87
91
  * @returns Array of wallet connector constructor classes
88
92
  *
89
93
  * @example
90
94
  * ```typescript
91
95
  * const connectors = fetchInjectedWalletConnectors({
92
96
  * walletBook,
93
- * authMode: 'connect-and-sign'
94
97
  * });
95
98
  *
96
99
  * // Instantiate connectors
@@ -101,40 +104,15 @@ const shouldAddWalletStandardConnector = (wallet, walletBook) => {
101
104
  */
102
105
  const fetchInjectedWalletConnectors = ({ walletBook, }) => {
103
106
  var _a;
104
- // Get wallet book connectors for traditional Aptos wallets
105
- const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
106
- .filter(([key, wallet]) => {
107
- var _a, _b, _c;
108
- const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'aptos');
109
- const isAptosWallet = Boolean(injectedConfig);
110
- // Filter out wallets that require a custom connector or wallets that support wallet-standard,
111
- // since they are already handled automatically with the wallet-standard connector
112
- const shouldBeFiltered = walletsWithCustomConnectors.includes(key) ||
113
- ((_c = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.features) === null || _c === void 0 ? void 0 : _c.length);
114
- return isAptosWallet && !shouldBeFiltered;
115
- })
116
- .map(([key, wallet]) => {
117
- const { shortName } = wallet;
118
- const name = shortName || wallet.name;
119
- return class extends InjectedWalletBase {
120
- constructor() {
121
- super(...arguments);
122
- this.name = name;
123
- // This is the key from the wallet book entry so that we don't purely rely on the normalized name
124
- this.overrideKey = key;
125
- }
126
- getProvider() {
127
- return this.findProvider();
128
- }
129
- };
130
- });
131
- // Get wallet-standard wallets
107
+ // Get wallet-standard wallets (only installed wallets are discovered)
132
108
  const { aptosWallets } = getWalletStandardWallets();
109
+ // Create a map of wallet-standard wallet names for quick lookup
110
+ const walletStandardWalletNames = new Set(aptosWallets.map((wallet) => wallet.name));
133
111
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Found wallet-standard wallets:', aptosWallets.map((w) => ({
134
112
  features: Object.keys(w.features),
135
113
  name: w.name,
136
114
  })));
137
- // Create connectors for wallet-standard wallets
115
+ // Create connectors for installed wallet-standard wallets
138
116
  const walletStandardConnectors = aptosWallets
139
117
  .filter((wallet) =>
140
118
  // Type incompatibility between @wallet-standard versions, casting is safe here
@@ -156,6 +134,46 @@ const fetchInjectedWalletConnectors = ({ walletBook, }) => {
156
134
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
157
135
  wallet, walletBookMetadata);
158
136
  });
137
+ // Get wallet book connectors for ALL Aptos wallets
138
+ // This includes:
139
+ // 1. Traditional wallets (no wallet-standard support)
140
+ // 2. Wallet-standard wallets that are NOT yet installed (discovered via wallet book)
141
+ const walletBookConnectors = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
142
+ .filter(([key, wallet]) => {
143
+ var _a, _b;
144
+ const injectedConfig = (_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'aptos');
145
+ const isAptosWallet = Boolean(injectedConfig);
146
+ // Filter out wallets that require a custom connector
147
+ const needsCustomConnector = walletsWithCustomConnectors.includes(key);
148
+ // Filter out wallets that are already discovered via wallet-standard (installed)
149
+ // We want to show uninstalled wallet-standard wallets from wallet book
150
+ const walletStandardName = (_b = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.walletStandard) === null || _b === void 0 ? void 0 : _b.name;
151
+ const isAlreadyDiscoveredViaWalletStandard = walletStandardName && walletStandardWalletNames.has(walletStandardName);
152
+ return (isAptosWallet &&
153
+ !needsCustomConnector &&
154
+ !isAlreadyDiscoveredViaWalletStandard);
155
+ })
156
+ .map(([key, wallet]) => {
157
+ const { shortName } = wallet;
158
+ const name = shortName || wallet.name;
159
+ // Get wallet metadata from wallet book
160
+ const walletBookMetadata = getWalletMetadataFromWalletBook({
161
+ walletBook,
162
+ walletBookWallet: wallet,
163
+ walletKey: key,
164
+ });
165
+ return class extends InjectedWalletBase {
166
+ constructor(props) {
167
+ super(name, Object.assign(Object.assign({}, props), { aptosNetworks: props.aptosNetworks, metadata: walletBookMetadata, walletBook: props.walletBook }));
168
+ this.name = name;
169
+ // This is the key from the wallet book entry so that we don't purely rely on the normalized name
170
+ this.overrideKey = key;
171
+ }
172
+ getProvider() {
173
+ return this.findProvider();
174
+ }
175
+ };
176
+ });
159
177
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Created wallet-standard connectors:', walletStandardConnectors.map((w) => w.name));
160
178
  logger.logVerboseTroubleshootingMessage('[APTOS fetchInjectedWalletConnectors] Created wallet-book connectors:', walletBookConnectors.map((w) => w.name));
161
179
  return [
package/src/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AccountAuthenticator, AnyRawTransaction } from '@aptos-labs/ts-sdk';
2
2
  import type { AccountInfo, AptosSignMessageInput, AptosSignMessageOutput, NetworkInfo, UserResponse } from '@aptos-labs/wallet-standard';
3
+ import { GenericNetwork } from '@dynamic-labs/types';
3
4
  import { ProviderCondition } from '@dynamic-labs/wallet-connector-core';
4
5
  /**
5
6
  * Interface for AIP-62 compliant Aptos wallet providers.
@@ -123,6 +124,8 @@ export interface AptosWalletConnectorProps {
123
124
  walletBook: any;
124
125
  /** Wallet metadata */
125
126
  metadata?: any;
127
+ /** Aptos networks */
128
+ aptosNetworks?: GenericNetwork[];
126
129
  }
127
130
  export type AptosFeatureName = keyof NonNullable<IAptosProvider['features']>;
128
131
  export type AptosMethodName = 'connect' | 'disconnect' | 'signTransaction' | 'signMessage' | 'signAndSubmitTransaction' | 'submitTransaction' | 'getNetwork' | 'network' | 'account' | 'onAccountChange' | 'onNetworkChange';
@@ -57,15 +57,12 @@ class AptosWallet extends walletConnectorCore.Wallet {
57
57
  // Calculate amount with proper decimals (APT has 8 decimals by default)
58
58
  const decimals = (token === null || token === void 0 ? void 0 : token.decimals) || 8;
59
59
  const transferAmount = parseFloat(amount) * Math.pow(10, decimals);
60
- // Create the transfer transaction
61
- const transaction = yield aptosClient.transferCoinTransaction({
62
- amount: transferAmount,
63
- coinType: token === null || token === void 0 ? void 0 : token.address,
64
- recipient: toAddress,
65
- sender: accountInfo.address, // If undefined, defaults to APT (0x1::aptos_coin::AptosCoin)
66
- });
67
60
  // Sign and submit the transaction using the wallet provider
68
- const txHash = yield this.signAndSubmitTransaction(transaction);
61
+ const txHash = yield this.signAndSubmitTransaction({
62
+ function: '0x1::coin::transfer',
63
+ functionArguments: [toAddress, transferAmount],
64
+ typeArguments: ['0x1::aptos_coin::AptosCoin'],
65
+ });
69
66
  return txHash;
70
67
  }
71
68
  catch (error) {
@@ -1,4 +1,4 @@
1
- import type { AccountAuthenticator, AnyRawTransaction } from '@aptos-labs/ts-sdk';
1
+ import type { AccountAuthenticator, AnyRawTransaction, InputGenerateTransactionPayloadData } from '@aptos-labs/ts-sdk';
2
2
  import { Aptos } from '@aptos-labs/ts-sdk';
3
3
  import type { AccountInfo, AptosSignMessageInput, AptosSignMessageOutput, NetworkInfo, UserResponse } from '@aptos-labs/wallet-standard';
4
4
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
@@ -70,7 +70,7 @@ export declare class AptosWallet extends Wallet<AptosWalletConnector> {
70
70
  * @param transaction - The transaction to sign and submit
71
71
  * @returns The transaction hash
72
72
  */
73
- signAndSubmitTransaction(transaction: AnyRawTransaction): Promise<string>;
73
+ signAndSubmitTransaction(transaction: InputGenerateTransactionPayloadData): Promise<string>;
74
74
  /**
75
75
  * Submits a pre-signed transaction to the network.
76
76
  *
@@ -53,15 +53,12 @@ class AptosWallet extends Wallet {
53
53
  // Calculate amount with proper decimals (APT has 8 decimals by default)
54
54
  const decimals = (token === null || token === void 0 ? void 0 : token.decimals) || 8;
55
55
  const transferAmount = parseFloat(amount) * Math.pow(10, decimals);
56
- // Create the transfer transaction
57
- const transaction = yield aptosClient.transferCoinTransaction({
58
- amount: transferAmount,
59
- coinType: token === null || token === void 0 ? void 0 : token.address,
60
- recipient: toAddress,
61
- sender: accountInfo.address, // If undefined, defaults to APT (0x1::aptos_coin::AptosCoin)
62
- });
63
56
  // Sign and submit the transaction using the wallet provider
64
- const txHash = yield this.signAndSubmitTransaction(transaction);
57
+ const txHash = yield this.signAndSubmitTransaction({
58
+ function: '0x1::coin::transfer',
59
+ functionArguments: [toAddress, transferAmount],
60
+ typeArguments: ['0x1::aptos_coin::AptosCoin'],
61
+ });
65
62
  return txHash;
66
63
  }
67
64
  catch (error) {
@@ -0,0 +1 @@
1
+ export * from './isAptosWallet';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isAptosWallet = (wallet) => wallet.chain === 'APTOS';
7
+
8
+ exports.isAptosWallet = isAptosWallet;
@@ -0,0 +1,3 @@
1
+ import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import { AptosWallet } from '../AptosWallet';
3
+ export declare const isAptosWallet: (wallet: Wallet) => wallet is AptosWallet;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isAptosWallet = (wallet) => wallet.chain === 'APTOS';
3
+
4
+ export { isAptosWallet };
@@ -135,18 +135,27 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
135
135
  throw new Error('Sign and submit transaction not implemented by wallet');
136
136
  }
137
137
  const result = yield signAndSubmitMethod.signAndSubmitTransaction({
138
- transaction,
138
+ payload: transaction,
139
139
  });
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
@@ -131,18 +131,27 @@ const createAptosSignerFromWalletStandard = ({ wallet, }) => {
131
131
  throw new Error('Sign and submit transaction not implemented by wallet');
132
132
  }
133
133
  const result = yield signAndSubmitMethod.signAndSubmitTransaction({
134
- transaction,
134
+ payload: transaction,
135
135
  });
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