@dynamic-labs/ethereum 2.1.0-alpha.28 → 2.1.0-alpha.29

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.
@@ -2,6 +2,7 @@
2
2
  import { __rest, __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { toHex, toBytes, createWalletClient, custom } from 'viem';
4
4
  import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
5
+ import { chainsMap } from '@dynamic-labs/viem-utils';
5
6
  import { EthWalletConnector } from '../EthWalletConnector.js';
6
7
  import { getCoinbaseProvider } from './helpers.js';
7
8
 
@@ -27,9 +28,13 @@ class Coinbase extends EthWalletConnector {
27
28
  getConnectedAccounts() {
28
29
  return __awaiter(this, void 0, void 0, function* () {
29
30
  try {
30
- return yield this.coinbaseProvider.request({
31
+ const accounts = yield this.coinbaseProvider.request({
31
32
  method: 'eth_accounts',
32
33
  });
34
+ if (accounts[0]) {
35
+ this.setActiveAccount(accounts[0]);
36
+ }
37
+ return accounts;
33
38
  }
34
39
  catch (error) {
35
40
  return [];
@@ -41,6 +46,7 @@ class Coinbase extends EthWalletConnector {
41
46
  const [address] = yield this.coinbaseProvider.request({
42
47
  method: 'eth_requestAccounts',
43
48
  });
49
+ this.setActiveAccount(address);
44
50
  return address;
45
51
  });
46
52
  }
@@ -71,9 +77,10 @@ class Coinbase extends EthWalletConnector {
71
77
  this.coinbaseProvider.removeListener('disconnect', handleDisconnect);
72
78
  };
73
79
  }
74
- getWalletClient() {
80
+ getWalletClient(chainId) {
75
81
  return createWalletClient({
76
- // add account and chain
82
+ account: this.getActiveAccount(),
83
+ chain: chainId ? chainsMap[chainId] : undefined,
77
84
  transport: custom(this.coinbaseProvider),
78
85
  });
79
86
  }