@dynamic-labs/ethereum 1.1.0-alpha.14 → 1.1.0-alpha.16

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
+ ## [1.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.15...v1.1.0-alpha.16) (2024-01-30)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * add fallback to getWalletBookWallet for customers still passing in name, add deprecation warn ([#4518](https://github.com/dynamic-labs/DynamicAuth/issues/4518)) ([b233ea1](https://github.com/dynamic-labs/DynamicAuth/commit/b233ea1cd640d8d9d94c52ab230787f3d869151a))
8
+ * handle braavos network change to account which doesn not exist ([#4519](https://github.com/dynamic-labs/DynamicAuth/issues/4519)) ([486020f](https://github.com/dynamic-labs/DynamicAuth/commit/486020fb09a274388ba34c8d1b37ac3a1ff3dba6))
9
+
10
+ ## [1.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.14...v1.1.0-alpha.15) (2024-01-28)
11
+
12
+
13
+ ### Features
14
+
15
+ * add wallet group override to wallet book ([#4488](https://github.com/dynamic-labs/DynamicAuth/issues/4488)) ([cb19ad3](https://github.com/dynamic-labs/DynamicAuth/commit/cb19ad3ea82de488752ceceeaf0e1458a388df6e))
16
+ * enable solana embedded wallets ([#4457](https://github.com/dynamic-labs/DynamicAuth/issues/4457)) ([b0c47f4](https://github.com/dynamic-labs/DynamicAuth/commit/b0c47f4475baa12f52076da46ef993c13bd2c243))
17
+ * group ArgentX wallets ([#4495](https://github.com/dynamic-labs/DynamicAuth/issues/4495)) ([b10d79a](https://github.com/dynamic-labs/DynamicAuth/commit/b10d79a668efecedca37ddb358e6adf95319650d))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * add support for newest backpack extension ([#4468](https://github.com/dynamic-labs/DynamicAuth/issues/4468)) ([a219f32](https://github.com/dynamic-labs/DynamicAuth/commit/a219f325be672599e50b07f6751234a7fc98286e))
23
+ * bump timeout for slower connections ([#4475](https://github.com/dynamic-labs/DynamicAuth/issues/4475)) ([7a07ff5](https://github.com/dynamic-labs/DynamicAuth/commit/7a07ff589eaaf3b28a94d277df3eedabbca60702))
24
+ * change out getWalletBookWallet for findWalletBookWallet to avoid throwing during lookup ([#4477](https://github.com/dynamic-labs/DynamicAuth/issues/4477)) ([4648040](https://github.com/dynamic-labs/DynamicAuth/commit/4648040c166e73dd2c31b0e27897713339436c2f))
25
+ * connect to wallet with wallet connect even if network is not supported ([#4465](https://github.com/dynamic-labs/DynamicAuth/issues/4465)) ([9dbca3e](https://github.com/dynamic-labs/DynamicAuth/commit/9dbca3eb4d4990ee4be642677c1604170b425dc3))
26
+ * pass id to wagmi chain override ([#4512](https://github.com/dynamic-labs/DynamicAuth/issues/4512)) ([2bf2f04](https://github.com/dynamic-labs/DynamicAuth/commit/2bf2f0487f5b1be936dd279107c11fe5d2b42666))
27
+ * switching wallet in extension caused connected flag to be false temporarily ([#4454](https://github.com/dynamic-labs/DynamicAuth/issues/4454)) ([3650f6e](https://github.com/dynamic-labs/DynamicAuth/commit/3650f6ec471a7c779f4d304ab94c9350dd55055b))
28
+
2
29
  ## [1.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.13...v1.1.0-alpha.14) (2024-01-23)
3
30
 
4
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "1.1.0-alpha.14",
3
+ "version": "1.1.0-alpha.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -32,12 +32,12 @@
32
32
  "@walletconnect/universal-provider": "2.10.6",
33
33
  "eventemitter3": "5.0.1",
34
34
  "buffer": "6.0.3",
35
- "@dynamic-labs/rpc-providers": "1.1.0-alpha.14",
36
- "@dynamic-labs/turnkey": "1.1.0-alpha.14",
37
- "@dynamic-labs/types": "1.1.0-alpha.14",
38
- "@dynamic-labs/utils": "1.1.0-alpha.14",
39
- "@dynamic-labs/wallet-book": "1.1.0-alpha.14",
40
- "@dynamic-labs/wallet-connector-core": "1.1.0-alpha.14",
35
+ "@dynamic-labs/rpc-providers": "1.1.0-alpha.16",
36
+ "@dynamic-labs/turnkey": "1.1.0-alpha.16",
37
+ "@dynamic-labs/types": "1.1.0-alpha.16",
38
+ "@dynamic-labs/utils": "1.1.0-alpha.16",
39
+ "@dynamic-labs/wallet-book": "1.1.0-alpha.16",
40
+ "@dynamic-labs/wallet-connector-core": "1.1.0-alpha.16",
41
41
  "stream": "0.0.2"
42
42
  },
43
43
  "peerDependencies": {
@@ -40,7 +40,7 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
40
40
  if (!provider) {
41
41
  return;
42
42
  }
43
- const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this, viem.createPublicClient({ transport: viem.custom(provider) }));
43
+ const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this);
44
44
  if (!(setupResponse === null || setupResponse === void 0 ? void 0 : setupResponse.tearDownEventListeners))
45
45
  return;
46
46
  this.teardownEventListeners = setupResponse.tearDownEventListeners;
@@ -1,5 +1,5 @@
1
1
  import { __rest, __awaiter } from '../../_virtual/_tslib.js';
2
- import { createPublicClient, custom, createWalletClient } from 'viem';
2
+ import { createWalletClient, custom } from 'viem';
3
3
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
4
  import '../polyfills.js';
5
5
  import '@dynamic-labs/turnkey';
@@ -36,7 +36,7 @@ class Coinbase extends EthWalletConnector {
36
36
  if (!provider) {
37
37
  return;
38
38
  }
39
- const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this, createPublicClient({ transport: custom(provider) }));
39
+ const setupResponse = (_c = (_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b._setupEventListeners) === null || _c === void 0 ? void 0 : _c.call(_b, this);
40
40
  if (!(setupResponse === null || setupResponse === void 0 ? void 0 : setupResponse.tearDownEventListeners))
41
41
  return;
42
42
  this.teardownEventListeners = setupResponse.tearDownEventListeners;
@@ -6,7 +6,6 @@ var _tslib = require('../_virtual/_tslib.cjs');
6
6
  var viem = require('viem');
7
7
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
8
  var utils = require('@dynamic-labs/utils');
9
- var eventListenerHandlers = require('./utils/eventListenerHandlers.cjs');
10
9
  var eip6963Provider = require('./eip6963Provider.cjs');
11
10
 
12
11
  class EthProviderHelper {
@@ -124,14 +123,14 @@ class EthProviderHelper {
124
123
  return signedMessage;
125
124
  });
126
125
  }
127
- _setupEventListeners(walletConnector, publicClient) {
126
+ _setupEventListeners(walletConnector) {
128
127
  const web3Provider = this.findProvider();
129
128
  if (!web3Provider) {
130
129
  return {
131
130
  tearDownEventListeners: () => { },
132
131
  };
133
132
  }
134
- const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers.eventListenerHandlers(walletConnector, publicClient);
133
+ const { handleAccountChange, handleChainChange, handleDisconnect } = walletConnectorCore.eventListenerHandlers(walletConnector);
135
134
  web3Provider.on('accountsChanged', handleAccountChange);
136
135
  web3Provider.on('chainChanged', handleChainChange);
137
136
  web3Provider.on('disconnect', handleDisconnect);
@@ -1,4 +1,4 @@
1
- import { Hex, PublicClient, WalletClient } from 'viem';
1
+ import { Hex, WalletClient } from 'viem';
2
2
  import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
3
  import { WalletSchema } from '@dynamic-labs/wallet-book';
4
4
  import { IEthereum, ProviderFlag } from './types';
@@ -31,7 +31,7 @@ export declare class EthProviderHelper {
31
31
  fetchPublicAddress(): Promise<Hex | undefined>;
32
32
  fetchPublicAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
33
33
  signMessage(messageToSign: string): Promise<string | undefined>;
34
- _setupEventListeners(walletConnector: WalletConnector, publicClient: PublicClient): {
34
+ _setupEventListeners(walletConnector: WalletConnector): {
35
35
  tearDownEventListeners: () => void;
36
36
  };
37
37
  }
@@ -1,8 +1,7 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
2
  import { createWalletClient, custom, getAddress } from 'viem';
3
- import { ProviderLookup, logger } from '@dynamic-labs/wallet-connector-core';
3
+ import { ProviderLookup, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
4
4
  import { getProvidersFromWindow } from '@dynamic-labs/utils';
5
- import { eventListenerHandlers } from './utils/eventListenerHandlers.js';
6
5
  import { Eip6963ProviderSingleton } from './eip6963Provider.js';
7
6
 
8
7
  class EthProviderHelper {
@@ -120,14 +119,14 @@ class EthProviderHelper {
120
119
  return signedMessage;
121
120
  });
122
121
  }
123
- _setupEventListeners(walletConnector, publicClient) {
122
+ _setupEventListeners(walletConnector) {
124
123
  const web3Provider = this.findProvider();
125
124
  if (!web3Provider) {
126
125
  return {
127
126
  tearDownEventListeners: () => { },
128
127
  };
129
128
  }
130
- const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(walletConnector, publicClient);
129
+ const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(walletConnector);
131
130
  web3Provider.on('accountsChanged', handleAccountChange);
132
131
  web3Provider.on('chainChanged', handleChainChange);
133
132
  web3Provider.on('disconnect', handleDisconnect);
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var _tslib = require('../../_virtual/_tslib.cjs');
4
- var viem = require('viem');
5
4
  var walletBook = require('@dynamic-labs/wallet-book');
6
5
  var ethProviderHelper = require('../ethProviderHelper.cjs');
7
6
  var EthWalletConnector = require('../EthWalletConnector.cjs');
@@ -17,20 +16,23 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
17
16
  }
18
17
  getEthProviderHelper() {
19
18
  if (!this.wallet) {
20
- this.wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
19
+ // changing this to findWalletBookWallet so it returns undefined if not found which
20
+ // allows the getEthProviderHelper to return undefined if the wallet is not installed
21
+ this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
21
22
  }
22
23
  if (this.wallet && !this.ethProviderHelper) {
23
24
  this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet);
24
25
  }
26
+ // this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
25
27
  return this.ethProviderHelper;
26
28
  }
27
29
  getMobileOrInstalledWallet() {
28
- var _a, _b, _c;
30
+ var _a, _b, _c, _d;
29
31
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
30
32
  if (!this.wallet)
31
- this.wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
33
+ this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
32
34
  if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
33
- ((_c = (_b = this.wallet.walletConnect) === null || _b === void 0 ? void 0 : _b.sdks) === null || _c === void 0 ? void 0 : _c.includes('sign_v2'))) {
35
+ ((_d = (_c = (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.walletConnect) === null || _c === void 0 ? void 0 : _c.sdks) === null || _d === void 0 ? void 0 : _d.includes('sign_v2'))) {
34
36
  return new walletConnectV2.WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
35
37
  }
36
38
  else {
@@ -46,7 +48,7 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
46
48
  const ethProviderHelper = this.getEthProviderHelper();
47
49
  if (!ethProviderHelper)
48
50
  return;
49
- const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this, viem.createPublicClient({ transport: viem.custom(provider) }));
51
+ const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
50
52
  this.teardownEventListeners = tearDownEventListeners;
51
53
  }
52
54
  getWalletClient() {
@@ -1,6 +1,5 @@
1
1
  import { __awaiter } from '../../_virtual/_tslib.js';
2
- import { createPublicClient, custom } from 'viem';
3
- import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
2
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
3
  import { EthProviderHelper } from '../ethProviderHelper.js';
5
4
  import { EthWalletConnector } from '../EthWalletConnector.js';
6
5
  import { WalletConnectV2 } from '../walletConnect/walletConnectV2.js';
@@ -15,20 +14,23 @@ class InjectedWalletBase extends EthWalletConnector {
15
14
  }
16
15
  getEthProviderHelper() {
17
16
  if (!this.wallet) {
18
- this.wallet = getWalletBookWallet(this.walletBook, this.key);
17
+ // changing this to findWalletBookWallet so it returns undefined if not found which
18
+ // allows the getEthProviderHelper to return undefined if the wallet is not installed
19
+ this.wallet = findWalletBookWallet(this.walletBook, this.key);
19
20
  }
20
21
  if (this.wallet && !this.ethProviderHelper) {
21
22
  this.ethProviderHelper = new EthProviderHelper(this.wallet);
22
23
  }
24
+ // this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
23
25
  return this.ethProviderHelper;
24
26
  }
25
27
  getMobileOrInstalledWallet() {
26
- var _a, _b, _c;
28
+ var _a, _b, _c, _d;
27
29
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
28
30
  if (!this.wallet)
29
- this.wallet = getWalletBookWallet(this.walletBook, this.key);
31
+ this.wallet = findWalletBookWallet(this.walletBook, this.key);
30
32
  if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
31
- ((_c = (_b = this.wallet.walletConnect) === null || _b === void 0 ? void 0 : _b.sdks) === null || _c === void 0 ? void 0 : _c.includes('sign_v2'))) {
33
+ ((_d = (_c = (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.walletConnect) === null || _c === void 0 ? void 0 : _c.sdks) === null || _d === void 0 ? void 0 : _d.includes('sign_v2'))) {
32
34
  return new WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
33
35
  }
34
36
  else {
@@ -44,7 +46,7 @@ class InjectedWalletBase extends EthWalletConnector {
44
46
  const ethProviderHelper = this.getEthProviderHelper();
45
47
  if (!ethProviderHelper)
46
48
  return;
47
- const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this, createPublicClient({ transport: custom(provider) }));
49
+ const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
48
50
  this.teardownEventListeners = tearDownEventListeners;
49
51
  }
50
52
  getWalletClient() {
package/src/types.d.ts CHANGED
@@ -26,11 +26,6 @@ export type IEthereum = {
26
26
  export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb' | 'isRabby' | 'isOkxWallet';
27
27
  export type EthProviderCondition = ProviderCondition<ProviderFlag>;
28
28
  export type Provider = () => PublicClient | undefined;
29
- export type AccountChangeEventHandler = (accounts: string[]) => Promise<void>;
30
- export type ChainChangeEventHandler = (chainId: string | number) => Promise<void>;
31
- export type DisconnectEventHandler = (error?: {
32
- code: number;
33
- }) => Promise<void>;
34
29
  export type ExternalProviderEventEmitter = PublicClient & {
35
30
  on: (event: string, listener: (...args: Array<any>) => unknown) => void;
36
31
  removeListener: (event: string, listener: (...args: Array<any>) => unknown) => void;
@@ -39,9 +39,6 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
39
39
  this.projectId = opts.projectId;
40
40
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
41
41
  this.preferredChains = opts.walletConnectPreferredChains || [];
42
- if (!this.preferredChains.includes('eip155:1')) {
43
- this.preferredChains.push('eip155:1');
44
- }
45
42
  this.hasSwitchedNetwork =
46
43
  (_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
47
44
  const lsCurrentChain = localStorage.getItem(this.currentChainKey);
@@ -55,6 +52,16 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
55
52
  .filter((network) => network.chainId !== 11297108109)
56
53
  .map((network) => `eip155:${network.chainId}`));
57
54
  }
55
+ getMappedChainsByPreferredOrder() {
56
+ // adding Ethereum to avoid an error connecting if none of the evm networks are supported by the wallet
57
+ const allChains = this.getMappedChains();
58
+ if (!allChains.includes('eip155:1')) {
59
+ allChains.push('eip155:1');
60
+ }
61
+ const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
62
+ const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
63
+ return [...reorderedChains, ...remainingChains];
64
+ }
58
65
  initConnection() {
59
66
  return _tslib.__awaiter(this, void 0, void 0, function* () {
60
67
  const { provider } = WalletConnectV2;
@@ -67,7 +74,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
67
74
  }
68
75
  const optionalNamespaces = {
69
76
  eip155: {
70
- chains: this.getMappedChains(),
77
+ chains: this.getMappedChainsByPreferredOrder(),
71
78
  events: ['chainChanged', 'accountsChanged'],
72
79
  methods: [
73
80
  'eth_chainId',
@@ -89,7 +96,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
89
96
  })
90
97
  .catch((e) => {
91
98
  walletConnectorCore.logger.error(e);
92
- ee.emit('walletconnect_connection_failed');
99
+ ee.emit('walletconnect_connection_failed', e);
93
100
  });
94
101
  });
95
102
  }
@@ -27,6 +27,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
27
27
  private _hasSwitchedNetwork;
28
28
  constructor(opts: WalletConnectorV2Opts);
29
29
  private getMappedChains;
30
+ private getMappedChainsByPreferredOrder;
30
31
  private initConnection;
31
32
  private createInitProviderPromise;
32
33
  private initProvider;
@@ -30,9 +30,6 @@ class WalletConnectV2 extends EthWalletConnector {
30
30
  this.projectId = opts.projectId;
31
31
  this.deepLinkPreference = opts.deepLinkPreference || 'native';
32
32
  this.preferredChains = opts.walletConnectPreferredChains || [];
33
- if (!this.preferredChains.includes('eip155:1')) {
34
- this.preferredChains.push('eip155:1');
35
- }
36
33
  this.hasSwitchedNetwork =
37
34
  (_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
38
35
  const lsCurrentChain = localStorage.getItem(this.currentChainKey);
@@ -46,6 +43,16 @@ class WalletConnectV2 extends EthWalletConnector {
46
43
  .filter((network) => network.chainId !== 11297108109)
47
44
  .map((network) => `eip155:${network.chainId}`));
48
45
  }
46
+ getMappedChainsByPreferredOrder() {
47
+ // adding Ethereum to avoid an error connecting if none of the evm networks are supported by the wallet
48
+ const allChains = this.getMappedChains();
49
+ if (!allChains.includes('eip155:1')) {
50
+ allChains.push('eip155:1');
51
+ }
52
+ const reorderedChains = this.preferredChains.filter((chain) => allChains.includes(chain));
53
+ const remainingChains = allChains.filter((chain) => !this.preferredChains.includes(chain));
54
+ return [...reorderedChains, ...remainingChains];
55
+ }
49
56
  initConnection() {
50
57
  return __awaiter(this, void 0, void 0, function* () {
51
58
  const { provider } = WalletConnectV2;
@@ -58,7 +65,7 @@ class WalletConnectV2 extends EthWalletConnector {
58
65
  }
59
66
  const optionalNamespaces = {
60
67
  eip155: {
61
- chains: this.getMappedChains(),
68
+ chains: this.getMappedChainsByPreferredOrder(),
62
69
  events: ['chainChanged', 'accountsChanged'],
63
70
  methods: [
64
71
  'eth_chainId',
@@ -80,7 +87,7 @@ class WalletConnectV2 extends EthWalletConnector {
80
87
  })
81
88
  .catch((e) => {
82
89
  logger.error(e);
83
- ee.emit('walletconnect_connection_failed');
90
+ ee.emit('walletconnect_connection_failed', e);
84
91
  });
85
92
  });
86
93
  }
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _tslib = require('../../_virtual/_tslib.cjs');
6
-
7
- const eventListenerHandlers = (walletConnector, publicClient) => {
8
- const handleAccountChange = (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
9
- if (accounts.length === 0) {
10
- walletConnector.emit('disconnect');
11
- return;
12
- }
13
- walletConnector.emit('accountChange', { accounts });
14
- });
15
- const handleChainChange = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
16
- const chainId = yield publicClient.getChainId();
17
- walletConnector.emit('chainChange', {
18
- chain: chainId.toString(),
19
- });
20
- });
21
- const handleDisconnect = (error) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
- if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
23
- return;
24
- }
25
- walletConnector.emit('disconnect');
26
- });
27
- return {
28
- handleAccountChange,
29
- handleChainChange,
30
- handleDisconnect,
31
- };
32
- };
33
-
34
- exports.eventListenerHandlers = eventListenerHandlers;
@@ -1,8 +0,0 @@
1
- import { PublicClient } from 'viem';
2
- import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
3
- import { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler } from '../types';
4
- export declare const eventListenerHandlers: (walletConnector: WalletConnector, publicClient: PublicClient) => {
5
- handleAccountChange: AccountChangeEventHandler;
6
- handleChainChange: ChainChangeEventHandler;
7
- handleDisconnect: DisconnectEventHandler;
8
- };
@@ -1,30 +0,0 @@
1
- import { __awaiter } from '../../_virtual/_tslib.js';
2
-
3
- const eventListenerHandlers = (walletConnector, publicClient) => {
4
- const handleAccountChange = (accounts) => __awaiter(void 0, void 0, void 0, function* () {
5
- if (accounts.length === 0) {
6
- walletConnector.emit('disconnect');
7
- return;
8
- }
9
- walletConnector.emit('accountChange', { accounts });
10
- });
11
- const handleChainChange = () => __awaiter(void 0, void 0, void 0, function* () {
12
- const chainId = yield publicClient.getChainId();
13
- walletConnector.emit('chainChange', {
14
- chain: chainId.toString(),
15
- });
16
- });
17
- const handleDisconnect = (error) => __awaiter(void 0, void 0, void 0, function* () {
18
- if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
19
- return;
20
- }
21
- walletConnector.emit('disconnect');
22
- });
23
- return {
24
- handleAccountChange,
25
- handleChainChange,
26
- handleDisconnect,
27
- };
28
- };
29
-
30
- export { eventListenerHandlers };