@dynamic-labs/ethereum 3.0.0-alpha.0 → 3.0.0-alpha.10

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.
@@ -1,8 +1,8 @@
1
1
  'use client'
2
2
  import { __rest, __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { toHex, toBytes, createWalletClient, custom } from 'viem';
4
- import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
5
4
  import { chainsMap } from '@dynamic-labs/viem-utils';
5
+ import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
6
6
  import { EthWalletConnector } from '../EthWalletConnector.js';
7
7
  import { getCoinbaseProvider } from './helpers.js';
8
8
 
@@ -16,14 +16,15 @@ class Coinbase extends EthWalletConnector {
16
16
  this.connectedChain = 'EVM';
17
17
  this.canConnectViaQrCode = false;
18
18
  this.canConnectViaCustodialService = true;
19
- this.coinbaseProvider = getCoinbaseProvider({
20
- opts: {
21
- appLogoUrl: appLogoUrl,
22
- appName: appName,
23
- evmNetworks: evmNetworks,
24
- walletPreference: coinbaseWalletPreference,
25
- },
26
- });
19
+ this.coinbaseProviderOpts = {
20
+ appLogoUrl: appLogoUrl,
21
+ appName: appName,
22
+ evmNetworks: evmNetworks,
23
+ walletPreference: coinbaseWalletPreference,
24
+ };
25
+ }
26
+ get coinbaseProvider() {
27
+ return getCoinbaseProvider(this.coinbaseProviderOpts);
27
28
  }
28
29
  getConnectedAccounts() {
29
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,7 +10,7 @@ var walletSdk = require('@coinbase/wallet-sdk');
10
10
  let coinbaseProvider;
11
11
  const baseSepolia = 84532;
12
12
  const baseMainnet = 8453;
13
- const getCoinbaseProvider = ({ opts: { appLogoUrl, appName, evmNetworks, walletPreference } = {}, }) => {
13
+ const getCoinbaseProvider = ({ appLogoUrl, appName, evmNetworks, walletPreference, } = {}) => {
14
14
  const appChainIds = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.map((network) => Number(network.chainId));
15
15
  // just brings base sepolia to the front of the list, because that is treated as the default chain
16
16
  const hasBaseSepolia = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.some((network) => network.chainId === baseSepolia);
@@ -6,7 +6,7 @@ import { CoinbaseWalletSDK } from '@coinbase/wallet-sdk';
6
6
  let coinbaseProvider;
7
7
  const baseSepolia = 84532;
8
8
  const baseMainnet = 8453;
9
- const getCoinbaseProvider = ({ opts: { appLogoUrl, appName, evmNetworks, walletPreference } = {}, }) => {
9
+ const getCoinbaseProvider = ({ appLogoUrl, appName, evmNetworks, walletPreference, } = {}) => {
10
10
  const appChainIds = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.map((network) => Number(network.chainId));
11
11
  // just brings base sepolia to the front of the list, because that is treated as the default chain
12
12
  const hasBaseSepolia = evmNetworks === null || evmNetworks === void 0 ? void 0 : evmNetworks.some((network) => network.chainId === baseSepolia);
@@ -10,10 +10,7 @@ export type GetCoinbaseProviderOpts = {
10
10
  export type CoinbaseProviderHandlerOpts = {
11
11
  onDisconnect(): Promise<void>;
12
12
  };
13
- export type GetCoinbaseProvider = (args: {
14
- handlers?: CoinbaseProviderHandlerOpts;
15
- opts?: GetCoinbaseProviderOpts;
16
- }) => ProviderInterface;
13
+ export type GetCoinbaseProvider = (opts?: GetCoinbaseProviderOpts) => ProviderInterface;
17
14
  export type CoinbaseOpts = EthWalletConnectorOpts & {
18
15
  appLogoUrl?: string;
19
16
  appName?: string;
@@ -8,7 +8,6 @@ var viem = require('viem');
8
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
9
  var utils = require('@dynamic-labs/utils');
10
10
  var viemUtils = require('@dynamic-labs/viem-utils');
11
- var eip6963Provider = require('./eip6963Provider.cjs');
12
11
 
13
12
  class EthProviderHelper {
14
13
  constructor(wallet, connector) {
@@ -69,7 +68,7 @@ class EthProviderHelper {
69
68
  }
70
69
  eip6963ProviderLookup(rdns) {
71
70
  var _a;
72
- const { providers } = eip6963Provider.Eip6963ProviderSingleton.get();
71
+ const { providers } = utils.Eip6963ProviderSingleton.get();
73
72
  return (_a = providers.find((provider) => provider.info.rdns === rdns)) === null || _a === void 0 ? void 0 : _a.provider;
74
73
  }
75
74
  isInstalledHelper() {
@@ -85,7 +84,7 @@ class EthProviderHelper {
85
84
  }
86
85
  return viem.createWalletClient({
87
86
  account: this.connector.getActiveAccount(),
88
- chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
87
+ chain: chainId ? viemUtils.chainsMap[chainId] : this.connector.getActiveChain(),
89
88
  transport: viem.custom(provider),
90
89
  });
91
90
  }
@@ -1,4 +1,4 @@
1
- import { Hex, WalletClient } from 'viem';
1
+ import { Hex, WalletClient, Account, Transport, Chain as ViemChain } 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, ExtensionLocator } from './types';
@@ -22,6 +22,10 @@ export declare class EthProviderHelper {
22
22
  features: string[];
23
23
  name: string;
24
24
  } | undefined;
25
+ walletStandardLocators?: {
26
+ name: string;
27
+ locator: string;
28
+ }[] | undefined;
25
29
  windowLocations?: string[] | undefined;
26
30
  } | undefined;
27
31
  installedProviders(): IEthereum[];
@@ -29,7 +33,7 @@ export declare class EthProviderHelper {
29
33
  eip6963ProviderLookup(rdns: string): IEthereum | undefined;
30
34
  isInstalledHelper(): boolean;
31
35
  findProvider(): IEthereum | undefined;
32
- findWalletClient(chainId?: string): WalletClient | undefined;
36
+ findWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
33
37
  getAddress(): Promise<Hex | undefined>;
34
38
  getAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
35
39
  signMessage(messageToSign: string): Promise<string | undefined>;
@@ -2,9 +2,8 @@
2
2
  import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { createWalletClient, custom, getAddress } from 'viem';
4
4
  import { ProviderLookup, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
5
- import { getProvidersFromWindow } from '@dynamic-labs/utils';
5
+ import { getProvidersFromWindow, Eip6963ProviderSingleton } from '@dynamic-labs/utils';
6
6
  import { chainsMap } from '@dynamic-labs/viem-utils';
7
- import { Eip6963ProviderSingleton } from './eip6963Provider.js';
8
7
 
9
8
  class EthProviderHelper {
10
9
  constructor(wallet, connector) {
@@ -81,7 +80,7 @@ class EthProviderHelper {
81
80
  }
82
81
  return createWalletClient({
83
82
  account: this.connector.getActiveAccount(),
84
- chain: chainId ? chainsMap[chainId] : undefined,
83
+ chain: chainId ? chainsMap[chainId] : this.connector.getActiveChain(),
85
84
  transport: custom(provider),
86
85
  });
87
86
  }
package/src/index.cjs CHANGED
@@ -4,10 +4,11 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  require('./polyfills.cjs');
7
- var turnkey = require('@dynamic-labs/turnkey');
7
+ var embeddedWalletEvm = require('@dynamic-labs/embedded-wallet-evm');
8
8
  var PhantomEvm = require('./injected/PhantomEvm.cjs');
9
9
  var ExodusEvm = require('./injected/ExodusEvm.cjs');
10
10
  var UnknownInjected = require('./injected/UnknownInjected.cjs');
11
+ var FallbackEvmConnector = require('./injected/FallbackEvmConnector.cjs');
11
12
  var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
12
13
  require('./walletConnect/walletConnect.cjs');
13
14
  var fetchWalletConnectWallets = require('./walletConnect/fetchWalletConnectWallets.cjs');
@@ -23,15 +24,17 @@ const EthereumWalletConnectors = (props) => [
23
24
  ...fetchInjectedWalletConnectors.injectedWalletOverrides,
24
25
  ...fetchInjectedWalletConnectors.fetchInjectedWalletConnector(props),
25
26
  ...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
26
- ...turnkey.TurnkeyEVMWalletConnectors(props),
27
+ ...embeddedWalletEvm.TurnkeyEVMWalletConnectors(props),
27
28
  coinbase.Coinbase,
28
29
  UnknownInjected.UnknownInjected,
30
+ FallbackEvmConnector.FallbackEvmConnector,
29
31
  fetchWalletConnectWallets.getWalletConnectConnector(),
30
32
  ];
31
33
 
32
34
  exports.PhantomEvm = PhantomEvm.PhantomEvm;
33
35
  exports.ExodusEvm = ExodusEvm.ExodusEvm;
34
36
  exports.UnknownInjected = UnknownInjected.UnknownInjected;
37
+ exports.FallbackEvmConnector = FallbackEvmConnector.FallbackEvmConnector;
35
38
  exports.fetchInjectedWalletConnector = fetchInjectedWalletConnectors.fetchInjectedWalletConnector;
36
39
  exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOverrides;
37
40
  exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
package/src/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  'use client'
2
2
  import './polyfills.js';
3
- import { TurnkeyEVMWalletConnectors } from '@dynamic-labs/turnkey';
3
+ import { TurnkeyEVMWalletConnectors } from '@dynamic-labs/embedded-wallet-evm';
4
4
  export { PhantomEvm } from './injected/PhantomEvm.js';
5
5
  export { ExodusEvm } from './injected/ExodusEvm.js';
6
6
  import { UnknownInjected } from './injected/UnknownInjected.js';
7
7
  export { UnknownInjected } from './injected/UnknownInjected.js';
8
+ import { FallbackEvmConnector } from './injected/FallbackEvmConnector.js';
9
+ export { FallbackEvmConnector } from './injected/FallbackEvmConnector.js';
8
10
  import { injectedWalletOverrides, fetchInjectedWalletConnector } from './injected/fetchInjectedWalletConnectors.js';
9
11
  export { fetchInjectedWalletConnector, injectedWalletOverrides } from './injected/fetchInjectedWalletConnectors.js';
10
12
  import './walletConnect/walletConnect.js';
@@ -24,6 +26,7 @@ const EthereumWalletConnectors = (props) => [
24
26
  ...TurnkeyEVMWalletConnectors(props),
25
27
  Coinbase,
26
28
  UnknownInjected,
29
+ FallbackEvmConnector,
27
30
  getWalletConnectConnector(),
28
31
  ];
29
32
 
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var walletBook = require('@dynamic-labs/wallet-book');
7
+ var InjectedWalletBase = require('./InjectedWalletBase.cjs');
8
+
9
+ class FallbackEvmConnector extends InjectedWalletBase {
10
+ constructor(props) {
11
+ super(props);
12
+ this.name = 'Fallback Connector';
13
+ this.overrideKey = 'fallbackconnector';
14
+ this.isAvailable = false;
15
+ this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
16
+ }
17
+ isInstalledOnBrowser() {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ exports.FallbackEvmConnector = FallbackEvmConnector;
@@ -0,0 +1,9 @@
1
+ import { EthWalletConnectorOpts } from '..';
2
+ import InjectedWalletBase from './InjectedWalletBase';
3
+ export declare class FallbackEvmConnector extends InjectedWalletBase {
4
+ name: string;
5
+ overrideKey: string;
6
+ isAvailable: boolean;
7
+ constructor(props: EthWalletConnectorOpts);
8
+ isInstalledOnBrowser(): boolean;
9
+ }
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
+ import InjectedWalletBase from './InjectedWalletBase.js';
4
+
5
+ class FallbackEvmConnector extends InjectedWalletBase {
6
+ constructor(props) {
7
+ super(props);
8
+ this.name = 'Fallback Connector';
9
+ this.overrideKey = 'fallbackconnector';
10
+ this.isAvailable = false;
11
+ this.wallet = findWalletBookWallet(this.walletBook, this.key);
12
+ }
13
+ isInstalledOnBrowser() {
14
+ return false;
15
+ }
16
+ }
17
+
18
+ export { FallbackEvmConnector };
@@ -1,4 +1,4 @@
1
- import { WalletClient } from 'viem';
1
+ import { WalletClient, Transport, Account, Chain as ViemChain } from 'viem';
2
2
  import { Chain } from '@dynamic-labs/wallet-connector-core';
3
3
  import { EvmNetwork } from '@dynamic-labs/types';
4
4
  import { WalletSchema } from '@dynamic-labs/wallet-book';
@@ -14,7 +14,7 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
14
14
  getEthProviderHelper(): EthProviderHelper | undefined;
15
15
  getMobileOrInstalledWallet(): InjectedWalletBase;
16
16
  setupEventListeners(): void;
17
- getWalletClient(chainId?: string): WalletClient | undefined;
17
+ getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
18
18
  isInstalledOnBrowser(): boolean;
19
19
  getAddress(): Promise<string | undefined>;
20
20
  connect(): Promise<void>;
@@ -1,4 +1,5 @@
1
1
  export * from './PhantomEvm';
2
2
  export * from './ExodusEvm';
3
3
  export * from './UnknownInjected';
4
+ export * from './FallbackEvmConnector';
4
5
  export * from './fetchInjectedWalletConnectors';