@dynamic-labs/ethereum 2.0.0-alpha.2 → 2.0.0-alpha.20

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/package.json +10 -11
  3. package/src/EthWalletConnector.cjs +1 -20
  4. package/src/EthWalletConnector.d.ts +9 -10
  5. package/src/EthWalletConnector.js +3 -22
  6. package/src/coinbase/client/client.cjs +2 -2
  7. package/src/coinbase/client/client.d.ts +2 -2
  8. package/src/coinbase/client/client.js +2 -2
  9. package/src/coinbase/coinbase.cjs +30 -9
  10. package/src/coinbase/coinbase.d.ts +19 -17
  11. package/src/coinbase/coinbase.js +31 -10
  12. package/src/ethProviderHelper.cjs +10 -5
  13. package/src/ethProviderHelper.d.ts +4 -3
  14. package/src/ethProviderHelper.js +10 -5
  15. package/src/index.cjs +7 -13
  16. package/src/index.d.ts +1 -0
  17. package/src/index.js +7 -13
  18. package/src/injected/ExodusEvm.cjs +1 -0
  19. package/src/injected/ExodusEvm.d.ts +1 -0
  20. package/src/injected/ExodusEvm.js +1 -0
  21. package/src/injected/InjectedWalletBase.cjs +6 -14
  22. package/src/injected/InjectedWalletBase.d.ts +2 -2
  23. package/src/injected/InjectedWalletBase.js +6 -14
  24. package/src/injected/PhantomEvm.cjs +4 -3
  25. package/src/injected/PhantomEvm.d.ts +2 -1
  26. package/src/injected/PhantomEvm.js +4 -3
  27. package/src/injected/fetchInjectedWalletConnectors.d.ts +0 -1
  28. package/src/walletConnect/fetchWalletConnectWallets.cjs +14 -33
  29. package/src/walletConnect/fetchWalletConnectWallets.d.ts +2 -5
  30. package/src/walletConnect/fetchWalletConnectWallets.js +14 -33
  31. package/src/walletConnect/index.d.ts +1 -2
  32. package/src/walletConnect/walletConnect.cjs +418 -79
  33. package/src/walletConnect/walletConnect.d.ts +309 -28
  34. package/src/walletConnect/walletConnect.js +417 -79
  35. package/src/walletConnect/client/client.cjs +0 -201
  36. package/src/walletConnect/client/client.d.ts +0 -17
  37. package/src/walletConnect/client/client.js +0 -187
  38. package/src/walletConnect/client/index.d.ts +0 -1
  39. package/src/walletConnect/client/types.d.ts +0 -4
  40. package/src/walletConnect/walletConnectV2.cjs +0 -475
  41. package/src/walletConnect/walletConnectV2.d.ts +0 -333
  42. package/src/walletConnect/walletConnectV2.js +0 -466
@@ -1,4 +1,4 @@
1
- import { Chain, FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
1
+ import { Chain, GetAddressOpts } from '@dynamic-labs/wallet-connector-core';
2
2
  import { EthProviderHelper } from '..';
3
3
  import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
4
4
  type CoinbaseOpts = EthWalletConnectorOpts & {
@@ -7,6 +7,7 @@ type CoinbaseOpts = EthWalletConnectorOpts & {
7
7
  };
8
8
  export declare class Coinbase extends EthWalletConnector {
9
9
  name: string;
10
+ overrideKey: string;
10
11
  supportedChains: Chain[];
11
12
  connectedChain: Chain;
12
13
  canConnectViaQrCode: boolean;
@@ -14,7 +15,7 @@ export declare class Coinbase extends EthWalletConnector {
14
15
  ethProviderHelper: EthProviderHelper | undefined;
15
16
  constructor({ appName, appLogoUrl, evmNetworks, ...props }: CoinbaseOpts);
16
17
  setupEventListeners(): void;
17
- getWalletClient(): {
18
+ getWalletClient(chainId?: string): {
18
19
  account: import("viem").Account | undefined;
19
20
  batch?: {
20
21
  multicall?: boolean | {
@@ -32,20 +33,20 @@ export declare class Coinbase extends EthWalletConnector {
32
33
  type: string;
33
34
  uid: string;
34
35
  addChain: (args: import("viem").AddChainParameters) => Promise<void>;
35
- deployContract: <const TAbi extends import("viem").Abi | readonly unknown[], TChainOverride extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi, import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride>) => Promise<`0x${string}`>;
36
+ deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi, import("viem").Chain | undefined, import("viem").Account | undefined, chainOverride>) => Promise<`0x${string}`>;
36
37
  getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
37
38
  getChainId: () => Promise<number>;
38
39
  getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
39
- prepareTransactionRequest: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_1>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
40
+ prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends import("viem").Chain | undefined = undefined, TAccountOverride extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, import("viem").Account | undefined, TChainOverride, TAccountOverride, TParameterType>>;
40
41
  requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
41
42
  requestPermissions: (args: {
42
43
  [x: string]: Record<string, any>;
43
44
  eth_accounts: Record<string, any>;
44
45
  }) => Promise<import("viem").RequestPermissionsReturnType>;
45
- sendRawTransaction: (args: import("node_modules/viem/_types/actions/wallet/sendRawTransaction").SendRawTransactionParameters) => Promise<`0x${string}`>;
46
- sendTransaction: <TChainOverride_2 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_2>) => Promise<`0x${string}`>;
46
+ sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
47
+ sendTransaction: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_1>) => Promise<`0x${string}`>;
47
48
  signMessage: (args: import("viem").SignMessageParameters<import("viem").Account | undefined>) => Promise<`0x${string}`>;
48
- signTransaction: <TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("node_modules/viem/_types/actions/wallet/signTransaction").SignTransactionParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_3>) => Promise<`0x${string}`>;
49
+ signTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_2>) => Promise<`0x${string}`>;
49
50
  signTypedData: <const TTypedData extends {
50
51
  [x: string]: readonly import("viem").TypedDataParameter[];
51
52
  [x: `string[${string}]`]: undefined;
@@ -256,7 +257,7 @@ export declare class Coinbase extends EthWalletConnector {
256
257
  }, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, import("viem").Account | undefined>) => Promise<`0x${string}`>;
257
258
  switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
258
259
  watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
259
- writeContract: <const TAbi_1 extends import("viem").Abi | readonly unknown[], TFunctionName extends string, TChainOverride_4 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_1, TFunctionName, import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_4>) => Promise<`0x${string}`>;
260
+ writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "nonpayable" | "payable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, import("viem").Chain | undefined, import("viem").Account | undefined, TChainOverride_3>) => Promise<`0x${string}`>;
260
261
  extend: <const client extends {
261
262
  [x: string]: unknown;
262
263
  account?: undefined;
@@ -270,7 +271,7 @@ export declare class Coinbase extends EthWalletConnector {
270
271
  transport?: undefined;
271
272
  type?: undefined;
272
273
  uid?: undefined;
273
- } & Partial<Pick<import("viem").PublicActions, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, import("viem").Account | undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<import("viem").Chain | undefined, import("viem").Account | undefined>>) => client) => import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, import("viem").Account | undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<import("viem").Chain | undefined, import("viem").Account | undefined>>;
274
+ } & Partial<Pick<import("viem").PublicActions<import("viem").Transport, import("viem").Chain | undefined, import("viem").Account | undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<import("viem").Chain | undefined, import("viem").Account | undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, import("viem").Account | undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<import("viem").Chain | undefined, import("viem").Account | undefined>>) => client) => import("viem").Client<import("viem").Transport, import("viem").Chain | undefined, import("viem").Account | undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<import("viem").Chain | undefined, import("viem").Account | undefined>>;
274
275
  } | {
275
276
  account: undefined;
276
277
  batch?: {
@@ -289,20 +290,20 @@ export declare class Coinbase extends EthWalletConnector {
289
290
  type: string;
290
291
  uid: string;
291
292
  addChain: (args: import("viem").AddChainParameters) => Promise<void>;
292
- deployContract: <const TAbi_2 extends import("viem").Abi | readonly unknown[], TChainOverride_5 extends import("viem").Chain | undefined = undefined>(args: import("viem").DeployContractParameters<TAbi_2, undefined, undefined, TChainOverride_5>) => Promise<`0x${string}`>;
293
+ deployContract: <const abi_2 extends import("viem").Abi | readonly unknown[], chainOverride_1 extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi_2, undefined, undefined, chainOverride_1>) => Promise<`0x${string}`>;
293
294
  getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
294
295
  getChainId: () => Promise<number>;
295
296
  getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
296
- prepareTransactionRequest: <TChainOverride_6 extends import("viem").Chain | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_6>) => Promise<import("viem").PrepareTransactionRequestReturnType>;
297
+ prepareTransactionRequest: <TParameterType_1 extends import("viem").PrepareTransactionRequestParameterType, TChainOverride_4 extends import("viem").Chain | undefined = undefined, TAccountOverride_1 extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride_4, TAccountOverride_1, TParameterType_1>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, undefined, TChainOverride_4, TAccountOverride_1, TParameterType_1>>;
297
298
  requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
298
299
  requestPermissions: (args: {
299
300
  [x: string]: Record<string, any>;
300
301
  eth_accounts: Record<string, any>;
301
302
  }) => Promise<import("viem").RequestPermissionsReturnType>;
302
- sendRawTransaction: (args: import("node_modules/viem/_types/actions/wallet/sendRawTransaction").SendRawTransactionParameters) => Promise<`0x${string}`>;
303
- sendTransaction: <TChainOverride_7 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_7>) => Promise<`0x${string}`>;
303
+ sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
304
+ sendTransaction: <TChainOverride_5 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_5>) => Promise<`0x${string}`>;
304
305
  signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
305
- signTransaction: <TChainOverride_8 extends import("viem").Chain | undefined = undefined>(args: import("node_modules/viem/_types/actions/wallet/signTransaction").SignTransactionParameters<undefined, undefined, TChainOverride_8>) => Promise<`0x${string}`>;
306
+ signTransaction: <TChainOverride_6 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<undefined, undefined, TChainOverride_6>) => Promise<`0x${string}`>;
306
307
  signTypedData: <const TTypedData_1 extends {
307
308
  [x: string]: readonly import("viem").TypedDataParameter[];
308
309
  [x: `string[${string}]`]: undefined;
@@ -513,7 +514,7 @@ export declare class Coinbase extends EthWalletConnector {
513
514
  }, TPrimaryType_1 extends string>(args: import("viem").SignTypedDataParameters<TTypedData_1, TPrimaryType_1, undefined>) => Promise<`0x${string}`>;
514
515
  switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
515
516
  watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
516
- writeContract: <const TAbi_3 extends import("viem").Abi | readonly unknown[], TFunctionName_1 extends string, TChainOverride_9 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<TAbi_3, TFunctionName_1, undefined, undefined, TChainOverride_9>) => Promise<`0x${string}`>;
517
+ writeContract: <const abi_3 extends import("viem").Abi | readonly unknown[], functionName_1 extends import("viem").ContractFunctionName<abi_3, "nonpayable" | "payable">, args_1 extends import("viem").ContractFunctionArgs<abi_3, "pure" | "view", functionName_1>, TChainOverride_7 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_3, functionName_1, args_1, undefined, undefined, TChainOverride_7>) => Promise<`0x${string}`>;
517
518
  extend: <const client_1 extends {
518
519
  [x: string]: unknown;
519
520
  account?: undefined;
@@ -527,11 +528,12 @@ export declare class Coinbase extends EthWalletConnector {
527
528
  transport?: undefined;
528
529
  type?: undefined;
529
530
  uid?: undefined;
530
- } & Partial<Pick<import("viem").PublicActions, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client_1) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K_1 in keyof client_1]: client_1[K_1]; } & import("viem").WalletActions<undefined, undefined>>;
531
+ } & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, undefined, undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client_1) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K_1 in keyof client_1]: client_1[K_1]; } & import("viem").WalletActions<undefined, undefined>>;
531
532
  } | undefined;
532
533
  isInstalledOnBrowser(): boolean;
533
- fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
534
+ getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
534
535
  signMessage(messageToSign: string): Promise<string | undefined>;
535
536
  endSession(): Promise<void>;
537
+ private setupCoinbaseProviderEventListeners;
536
538
  }
537
539
  export {};
@@ -1,22 +1,22 @@
1
1
  import { __rest, __awaiter } from '../../_virtual/_tslib.js';
2
2
  import { createWalletClient, custom } from 'viem';
3
3
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
4
+ import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
4
5
  import '../polyfills.js';
5
6
  import '@dynamic-labs/turnkey';
6
7
  import '@dynamic-labs/utils';
7
8
  import { EthProviderHelper } from '../ethProviderHelper.js';
8
9
  import { EthWalletConnector } from '../EthWalletConnector.js';
9
- import '../walletConnect/walletConnectV2.js';
10
- import '@walletconnect/ethereum-provider';
11
- import '@dynamic-labs/wallet-connector-core';
12
- import '@walletconnect/client';
13
- import { getCoinbaseProvider, fetchPublicAddress, signMessage, killCoinbaseSession } from './client/client.js';
10
+ import '../walletConnect/walletConnect.js';
11
+ import { getCoinbaseProvider, getAddress, signMessage, killCoinbaseSession } from './client/client.js';
12
+ import '@dynamic-labs/rpc-provider-ethereum';
14
13
 
15
14
  class Coinbase extends EthWalletConnector {
16
15
  constructor(_a) {
17
16
  var { appName, appLogoUrl, evmNetworks } = _a, props = __rest(_a, ["appName", "appLogoUrl", "evmNetworks"]);
18
17
  super(Object.assign({ evmNetworks }, props));
19
18
  this.name = 'Coinbase';
19
+ this.overrideKey = 'coinbase';
20
20
  this.supportedChains = ['EVM', 'ETH'];
21
21
  this.connectedChain = 'EVM';
22
22
  this.canConnectViaQrCode = true;
@@ -32,6 +32,10 @@ class Coinbase extends EthWalletConnector {
32
32
  }
33
33
  setupEventListeners() {
34
34
  var _a, _b, _c;
35
+ if (!this.isInstalledOnBrowser()) {
36
+ this.setupCoinbaseProviderEventListeners();
37
+ return;
38
+ }
35
39
  const provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider();
36
40
  if (!provider) {
37
41
  return;
@@ -41,10 +45,10 @@ class Coinbase extends EthWalletConnector {
41
45
  return;
42
46
  this.teardownEventListeners = setupResponse.tearDownEventListeners;
43
47
  }
44
- getWalletClient() {
48
+ getWalletClient(chainId) {
45
49
  var _a;
46
50
  if (this.isInstalledOnBrowser()) {
47
- return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient();
51
+ return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
48
52
  }
49
53
  return createWalletClient({
50
54
  transport: custom(getCoinbaseProvider({
@@ -56,13 +60,13 @@ class Coinbase extends EthWalletConnector {
56
60
  var _a;
57
61
  return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
58
62
  }
59
- fetchPublicAddress(opts) {
63
+ getAddress(opts) {
60
64
  var _a;
61
65
  return __awaiter(this, void 0, void 0, function* () {
62
66
  if (this.isInstalledOnBrowser()) {
63
- return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
67
+ return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
64
68
  }
65
- return fetchPublicAddress(this.coinbaseProviderOpts, opts);
69
+ return getAddress(this.coinbaseProviderOpts, opts);
66
70
  });
67
71
  }
68
72
  signMessage(messageToSign) {
@@ -81,6 +85,23 @@ class Coinbase extends EthWalletConnector {
81
85
  killCoinbaseSession();
82
86
  });
83
87
  }
88
+ setupCoinbaseProviderEventListeners() {
89
+ const provider = getCoinbaseProvider({
90
+ opts: this.coinbaseProviderOpts,
91
+ });
92
+ if (!provider) {
93
+ return;
94
+ }
95
+ const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(this);
96
+ provider.on('accountsChanged', handleAccountChange);
97
+ provider.on('chainChanged', handleChainChange);
98
+ provider.on('disconnect', handleDisconnect);
99
+ this.teardownEventListeners = () => {
100
+ provider.removeListener('accountsChanged', handleAccountChange);
101
+ provider.removeListener('chainChanged', handleChainChange);
102
+ provider.removeListener('disconnect', handleDisconnect);
103
+ };
104
+ }
84
105
  }
85
106
 
86
107
  export { Coinbase };
@@ -4,8 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../_virtual/_tslib.cjs');
6
6
  var viem = require('viem');
7
+ var accounts = require('viem/accounts');
7
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
9
  var utils = require('@dynamic-labs/utils');
10
+ var viemUtils = require('@dynamic-labs/viem-utils');
9
11
  var eip6963Provider = require('./eip6963Provider.cjs');
10
12
 
11
13
  class EthProviderHelper {
@@ -75,29 +77,32 @@ class EthProviderHelper {
75
77
  findProvider() {
76
78
  return this.getInstalledProvider();
77
79
  }
78
- findWalletClient() {
80
+ findWalletClient(chainId) {
79
81
  const provider = this.findProvider();
80
82
  if (!provider) {
81
83
  return undefined;
82
84
  }
83
85
  return viem.createWalletClient({
86
+ account: this.account,
87
+ chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
84
88
  transport: viem.custom(provider),
85
89
  });
86
90
  }
87
- fetchPublicAddress() {
91
+ getAddress() {
88
92
  return _tslib.__awaiter(this, void 0, void 0, function* () {
89
93
  const client = this.findWalletClient();
90
94
  if (!client) {
91
95
  return Promise.resolve(undefined);
92
96
  }
93
- return this.fetchPublicAddressWithProvider(client);
97
+ return this.getAddressWithProvider(client);
94
98
  });
95
99
  }
96
- fetchPublicAddressWithProvider(client) {
100
+ getAddressWithProvider(client) {
97
101
  return _tslib.__awaiter(this, void 0, void 0, function* () {
98
102
  try {
99
103
  const [lowercaseAddress] = yield client.requestAddresses();
100
104
  const publicAddress = viem.getAddress(lowercaseAddress);
105
+ this.account = accounts.toAccount(publicAddress);
101
106
  return publicAddress;
102
107
  }
103
108
  catch (err) {
@@ -108,7 +113,7 @@ class EthProviderHelper {
108
113
  }
109
114
  signMessage(messageToSign) {
110
115
  return _tslib.__awaiter(this, void 0, void 0, function* () {
111
- const walletAddress = yield this.fetchPublicAddress();
116
+ const walletAddress = yield this.getAddress();
112
117
  if (!walletAddress) {
113
118
  return Promise.resolve(undefined);
114
119
  }
@@ -4,6 +4,7 @@ import { WalletSchema } from '@dynamic-labs/wallet-book';
4
4
  import { IEthereum, ProviderFlag } from './types';
5
5
  export declare class EthProviderHelper {
6
6
  private wallet;
7
+ private account;
7
8
  constructor(wallet: WalletSchema);
8
9
  getInstalledProvider(): IEthereum | undefined;
9
10
  getEip6963Config(): {
@@ -27,9 +28,9 @@ export declare class EthProviderHelper {
27
28
  eip6963ProviderLookup(rdns: string): IEthereum | undefined;
28
29
  isInstalledHelper(): boolean;
29
30
  findProvider(): IEthereum | undefined;
30
- findWalletClient(): WalletClient | undefined;
31
- fetchPublicAddress(): Promise<Hex | undefined>;
32
- fetchPublicAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
31
+ findWalletClient(chainId?: string): WalletClient | undefined;
32
+ getAddress(): Promise<Hex | undefined>;
33
+ getAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
33
34
  signMessage(messageToSign: string): Promise<string | undefined>;
34
35
  _setupEventListeners(walletConnector: WalletConnector): {
35
36
  tearDownEventListeners: () => void;
@@ -1,7 +1,9 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
2
  import { createWalletClient, custom, getAddress } from 'viem';
3
+ import { toAccount } from 'viem/accounts';
3
4
  import { ProviderLookup, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
4
5
  import { getProvidersFromWindow } from '@dynamic-labs/utils';
6
+ import { chainsMap } from '@dynamic-labs/viem-utils';
5
7
  import { Eip6963ProviderSingleton } from './eip6963Provider.js';
6
8
 
7
9
  class EthProviderHelper {
@@ -71,29 +73,32 @@ class EthProviderHelper {
71
73
  findProvider() {
72
74
  return this.getInstalledProvider();
73
75
  }
74
- findWalletClient() {
76
+ findWalletClient(chainId) {
75
77
  const provider = this.findProvider();
76
78
  if (!provider) {
77
79
  return undefined;
78
80
  }
79
81
  return createWalletClient({
82
+ account: this.account,
83
+ chain: chainId ? chainsMap[chainId] : undefined,
80
84
  transport: custom(provider),
81
85
  });
82
86
  }
83
- fetchPublicAddress() {
87
+ getAddress() {
84
88
  return __awaiter(this, void 0, void 0, function* () {
85
89
  const client = this.findWalletClient();
86
90
  if (!client) {
87
91
  return Promise.resolve(undefined);
88
92
  }
89
- return this.fetchPublicAddressWithProvider(client);
93
+ return this.getAddressWithProvider(client);
90
94
  });
91
95
  }
92
- fetchPublicAddressWithProvider(client) {
96
+ getAddressWithProvider(client) {
93
97
  return __awaiter(this, void 0, void 0, function* () {
94
98
  try {
95
99
  const [lowercaseAddress] = yield client.requestAddresses();
96
100
  const publicAddress = getAddress(lowercaseAddress);
101
+ this.account = toAccount(publicAddress);
97
102
  return publicAddress;
98
103
  }
99
104
  catch (err) {
@@ -104,7 +109,7 @@ class EthProviderHelper {
104
109
  }
105
110
  signMessage(messageToSign) {
106
111
  return __awaiter(this, void 0, void 0, function* () {
107
- const walletAddress = yield this.fetchPublicAddress();
112
+ const walletAddress = yield this.getAddress();
108
113
  if (!walletAddress) {
109
114
  return Promise.resolve(undefined);
110
115
  }
package/src/index.cjs CHANGED
@@ -7,27 +7,21 @@ var turnkey = require('@dynamic-labs/turnkey');
7
7
  var PhantomEvm = require('./injected/PhantomEvm.cjs');
8
8
  var ExodusEvm = require('./injected/ExodusEvm.cjs');
9
9
  var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
10
- require('./walletConnect/walletConnectV2.cjs');
11
- require('../_virtual/_tslib.cjs');
12
- require('@walletconnect/ethereum-provider');
13
- require('viem');
14
- require('@dynamic-labs/wallet-connector-core');
15
- require('@dynamic-labs/wallet-book');
16
- require('@dynamic-labs/utils');
17
- var EthWalletConnector = require('./EthWalletConnector.cjs');
18
- var constants = require('./constants.cjs');
19
- require('@walletconnect/client');
10
+ require('./walletConnect/walletConnect.cjs');
20
11
  var fetchWalletConnectWallets = require('./walletConnect/fetchWalletConnectWallets.cjs');
21
12
  var coinbase = require('./coinbase/coinbase.cjs');
13
+ require('@dynamic-labs/rpc-provider-ethereum');
14
+ var EthWalletConnector = require('./EthWalletConnector.cjs');
22
15
  var ethProviderHelper = require('./ethProviderHelper.cjs');
16
+ var constants = require('./constants.cjs');
23
17
 
24
18
  const EthereumWalletConnectors = (props) => [
25
19
  ...fetchInjectedWalletConnectors.injectedWalletOverrides,
26
20
  ...fetchInjectedWalletConnectors.fetchInjectedWalletConnector(props),
27
21
  ...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
28
- ...turnkey.TurnkeyWalletConnectors(props),
22
+ ...turnkey.TurnkeyEVMWalletConnectors(props),
29
23
  coinbase.Coinbase,
30
- fetchWalletConnectWallets.getWalletConnectConnector(props),
24
+ fetchWalletConnectWallets.getWalletConnectConnector(),
31
25
  ];
32
26
 
33
27
  exports.PhantomEvm = PhantomEvm.PhantomEvm;
@@ -35,6 +29,6 @@ exports.ExodusEvm = ExodusEvm.ExodusEvm;
35
29
  exports.fetchInjectedWalletConnector = fetchInjectedWalletConnectors.fetchInjectedWalletConnector;
36
30
  exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOverrides;
37
31
  exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
38
- exports.INFURA_ID = constants.INFURA_ID;
39
32
  exports.EthProviderHelper = ethProviderHelper.EthProviderHelper;
33
+ exports.INFURA_ID = constants.INFURA_ID;
40
34
  exports.EthereumWalletConnectors = EthereumWalletConnectors;
package/src/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import './polyfills';
2
2
  import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ import '@dynamic-labs/rpc-provider-ethereum';
3
4
  export * from './injected';
4
5
  export * from './EthWalletConnector';
5
6
  export * from './ethProviderHelper';
package/src/index.js CHANGED
@@ -1,30 +1,24 @@
1
1
  import './polyfills.js';
2
- import { TurnkeyWalletConnectors } from '@dynamic-labs/turnkey';
2
+ import { TurnkeyEVMWalletConnectors } from '@dynamic-labs/turnkey';
3
3
  export { PhantomEvm } from './injected/PhantomEvm.js';
4
4
  export { ExodusEvm } from './injected/ExodusEvm.js';
5
5
  import { injectedWalletOverrides, fetchInjectedWalletConnector } from './injected/fetchInjectedWalletConnectors.js';
6
6
  export { fetchInjectedWalletConnector, injectedWalletOverrides } from './injected/fetchInjectedWalletConnectors.js';
7
- import './walletConnect/walletConnectV2.js';
8
- import '../_virtual/_tslib.js';
9
- import '@walletconnect/ethereum-provider';
10
- import 'viem';
11
- import '@dynamic-labs/wallet-connector-core';
12
- import '@dynamic-labs/wallet-book';
13
- import '@dynamic-labs/utils';
14
- export { EthWalletConnector } from './EthWalletConnector.js';
15
- export { INFURA_ID } from './constants.js';
16
- import '@walletconnect/client';
7
+ import './walletConnect/walletConnect.js';
17
8
  import { fetchWalletConnectWallets, getWalletConnectConnector } from './walletConnect/fetchWalletConnectWallets.js';
18
9
  import { Coinbase } from './coinbase/coinbase.js';
10
+ import '@dynamic-labs/rpc-provider-ethereum';
11
+ export { EthWalletConnector } from './EthWalletConnector.js';
19
12
  export { EthProviderHelper } from './ethProviderHelper.js';
13
+ export { INFURA_ID } from './constants.js';
20
14
 
21
15
  const EthereumWalletConnectors = (props) => [
22
16
  ...injectedWalletOverrides,
23
17
  ...fetchInjectedWalletConnector(props),
24
18
  ...fetchWalletConnectWallets(props),
25
- ...TurnkeyWalletConnectors(props),
19
+ ...TurnkeyEVMWalletConnectors(props),
26
20
  Coinbase,
27
- getWalletConnectConnector(props),
21
+ getWalletConnectConnector(),
28
22
  ];
29
23
 
30
24
  export { EthereumWalletConnectors };
@@ -10,6 +10,7 @@ class ExodusEvm extends InjectedWalletBase {
10
10
  constructor(props) {
11
11
  super(props);
12
12
  this.name = 'ExodusEvm';
13
+ this.overrideKey = 'exodusevm';
13
14
  this.walletConnectorFallback = true;
14
15
  this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
15
16
  }
@@ -2,6 +2,7 @@ import { EthWalletConnectorOpts } from '..';
2
2
  import InjectedWalletBase from './InjectedWalletBase';
3
3
  export declare class ExodusEvm extends InjectedWalletBase {
4
4
  name: string;
5
+ overrideKey: string;
5
6
  walletConnectorFallback: boolean;
6
7
  constructor(props: EthWalletConnectorOpts);
7
8
  }
@@ -6,6 +6,7 @@ class ExodusEvm extends InjectedWalletBase {
6
6
  constructor(props) {
7
7
  super(props);
8
8
  this.name = 'ExodusEvm';
9
+ this.overrideKey = 'exodusevm';
9
10
  this.walletConnectorFallback = true;
10
11
  this.wallet = findWalletBookWallet(this.walletBook, this.key);
11
12
  }
@@ -4,7 +4,6 @@ var _tslib = require('../../_virtual/_tslib.cjs');
4
4
  var walletBook = require('@dynamic-labs/wallet-book');
5
5
  var ethProviderHelper = require('../ethProviderHelper.cjs');
6
6
  var EthWalletConnector = require('../EthWalletConnector.cjs');
7
- var walletConnectV2 = require('../walletConnect/walletConnectV2.cjs');
8
7
  var walletConnect = require('../walletConnect/walletConnect.cjs');
9
8
 
10
9
  class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
@@ -27,17 +26,10 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
27
26
  return this.ethProviderHelper;
28
27
  }
29
28
  getMobileOrInstalledWallet() {
30
- var _a, _b, _c, _d;
31
29
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
32
30
  if (!this.wallet)
33
31
  this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
34
- if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
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'))) {
36
- return new walletConnectV2.WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
37
- }
38
- else {
39
- return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
40
- }
32
+ return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
41
33
  }
42
34
  return this;
43
35
  }
@@ -51,23 +43,23 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
51
43
  const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
52
44
  this.teardownEventListeners = tearDownEventListeners;
53
45
  }
54
- getWalletClient() {
46
+ getWalletClient(chainId) {
55
47
  var _a;
56
- return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
48
+ return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
57
49
  }
58
50
  isInstalledOnBrowser() {
59
51
  var _a;
60
52
  return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
61
53
  }
62
- fetchPublicAddress() {
54
+ getAddress() {
63
55
  var _a;
64
56
  return _tslib.__awaiter(this, void 0, void 0, function* () {
65
- return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
57
+ return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
66
58
  });
67
59
  }
68
60
  connect() {
69
61
  return _tslib.__awaiter(this, void 0, void 0, function* () {
70
- yield this.fetchPublicAddress();
62
+ yield this.getAddress();
71
63
  });
72
64
  }
73
65
  signMessage(messageToSign) {
@@ -14,9 +14,9 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
14
14
  getEthProviderHelper(): EthProviderHelper | undefined;
15
15
  getMobileOrInstalledWallet(): InjectedWalletBase;
16
16
  setupEventListeners(): void;
17
- getWalletClient(): WalletClient | undefined;
17
+ getWalletClient(chainId?: string): WalletClient | undefined;
18
18
  isInstalledOnBrowser(): boolean;
19
- fetchPublicAddress(): Promise<string | undefined>;
19
+ getAddress(): Promise<string | undefined>;
20
20
  connect(): Promise<void>;
21
21
  signMessage(messageToSign: string): Promise<string | undefined>;
22
22
  proveOwnership(messageToSign: string): Promise<string | undefined>;
@@ -2,7 +2,6 @@ import { __awaiter } from '../../_virtual/_tslib.js';
2
2
  import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
3
  import { EthProviderHelper } from '../ethProviderHelper.js';
4
4
  import { EthWalletConnector } from '../EthWalletConnector.js';
5
- import { WalletConnectV2 } from '../walletConnect/walletConnectV2.js';
6
5
  import { WalletConnect } from '../walletConnect/walletConnect.js';
7
6
 
8
7
  class InjectedWalletBase extends EthWalletConnector {
@@ -25,17 +24,10 @@ class InjectedWalletBase extends EthWalletConnector {
25
24
  return this.ethProviderHelper;
26
25
  }
27
26
  getMobileOrInstalledWallet() {
28
- var _a, _b, _c, _d;
29
27
  if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
30
28
  if (!this.wallet)
31
29
  this.wallet = findWalletBookWallet(this.walletBook, this.key);
32
- if (((_a = this.constructorProps) === null || _a === void 0 ? void 0 : _a.isWalletConnectV2Enabled) &&
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'))) {
34
- return new WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
35
- }
36
- else {
37
- return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
38
- }
30
+ return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
39
31
  }
40
32
  return this;
41
33
  }
@@ -49,23 +41,23 @@ class InjectedWalletBase extends EthWalletConnector {
49
41
  const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
50
42
  this.teardownEventListeners = tearDownEventListeners;
51
43
  }
52
- getWalletClient() {
44
+ getWalletClient(chainId) {
53
45
  var _a;
54
- return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
46
+ return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
55
47
  }
56
48
  isInstalledOnBrowser() {
57
49
  var _a;
58
50
  return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
59
51
  }
60
- fetchPublicAddress() {
52
+ getAddress() {
61
53
  var _a;
62
54
  return __awaiter(this, void 0, void 0, function* () {
63
- return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.fetchPublicAddress();
55
+ return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
64
56
  });
65
57
  }
66
58
  connect() {
67
59
  return __awaiter(this, void 0, void 0, function* () {
68
- yield this.fetchPublicAddress();
60
+ yield this.getAddress();
69
61
  });
70
62
  }
71
63
  signMessage(messageToSign) {
@@ -11,15 +11,16 @@ class PhantomEvm extends InjectedWalletBase {
11
11
  constructor(props) {
12
12
  super(props);
13
13
  this.name = 'PhantomEvm';
14
+ this.overrideKey = 'phantomevm';
14
15
  this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
15
16
  }
16
- fetchPublicAddress() {
17
+ getAddress() {
17
18
  const _super = Object.create(null, {
18
- fetchPublicAddress: { get: () => super.fetchPublicAddress }
19
+ getAddress: { get: () => super.getAddress }
19
20
  });
20
21
  return _tslib.__awaiter(this, void 0, void 0, function* () {
21
22
  if (this.isInstalledOnBrowser()) {
22
- return _super.fetchPublicAddress.call(this);
23
+ return _super.getAddress.call(this);
23
24
  }
24
25
  if (utils.isMobile()) {
25
26
  utils.handleMobileWalletRedirect({
@@ -2,6 +2,7 @@ import { EthWalletConnectorOpts } from '..';
2
2
  import InjectedWalletBase from './InjectedWalletBase';
3
3
  export declare class PhantomEvm extends InjectedWalletBase {
4
4
  name: string;
5
+ overrideKey: string;
5
6
  constructor(props: EthWalletConnectorOpts);
6
- fetchPublicAddress(): Promise<string | undefined>;
7
+ getAddress(): Promise<string | undefined>;
7
8
  }