@dynamic-labs/ethereum 3.0.0-alpha.5 → 3.0.0-alpha.50

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,6 +1,6 @@
1
1
  import { Account, Hex, PublicClient, Transport, Chain as ViemChain, WalletClient } from 'viem';
2
2
  import { IChainRpcProviders } from '@dynamic-labs/rpc-provider-ethereum';
3
- import { EvmNetwork, GenericNetwork, IUITransaction } from '@dynamic-labs/types';
3
+ import { EvmNetwork, GenericNetwork, IUITransaction, TransactionReceipt } from '@dynamic-labs/types';
4
4
  import { WalletBookSchema } from '@dynamic-labs/wallet-book';
5
5
  import { ISendBalanceWalletConnector, NameServiceData, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
6
6
  export type SwitchNetworkOps = {
@@ -23,7 +23,7 @@ export declare abstract class EthWalletConnector extends WalletConnectorBase imp
23
23
  getPublicClient(): Promise<void | PublicClient<Transport, ViemChain> | undefined>;
24
24
  constructor(props: EthWalletConnectorOpts);
25
25
  getNetwork(): Promise<number | undefined>;
26
- getNameService(): Promise<NameServiceData | undefined>;
26
+ getNameService(address: string): Promise<NameServiceData | undefined>;
27
27
  isTestnet(): Promise<boolean>;
28
28
  parseAddress(address: string): string;
29
29
  getSigner(): Promise<{
@@ -3064,7 +3064,7 @@ export declare abstract class EthWalletConnector extends WalletConnectorBase imp
3064
3064
  uid?: undefined;
3065
3065
  } & import("viem").ExactPartial<Pick<import("viem").PublicActions<Transport, ViemChain, Account>, "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getChainId" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "prepareTransactionRequest" | "readContract" | "sendRawTransaction" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<ViemChain, Account>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<Transport, ViemChain, Account, import("viem").WalletRpcSchema, import("viem").WalletActions<ViemChain, Account>>) => client) => import("viem").Client<Transport, ViemChain, Account, import("viem").WalletRpcSchema, { [K_1 in keyof client]: client[K_1]; } & import("viem").WalletActions<ViemChain, Account>>;
3066
3066
  } | undefined>;
3067
- getBalance(): Promise<string | undefined>;
3067
+ getBalance(address: string): Promise<string | undefined>;
3068
3068
  supportsNetworkSwitching(): boolean;
3069
3069
  switchNetwork({ networkName, networkChainId, }: SwitchNetworkOps): Promise<void>;
3070
3070
  getConnectedAccounts(): Promise<string[]>;
@@ -3082,5 +3082,6 @@ export declare abstract class EthWalletConnector extends WalletConnectorBase imp
3082
3082
  setActiveChain(chain: ViemChain | undefined): void;
3083
3083
  getActiveChain(): ViemChain | undefined;
3084
3084
  createUiTransaction(from: string): Promise<IUITransaction>;
3085
+ confirmTransactionStatus(txHash: string): Promise<TransactionReceipt>;
3085
3086
  }
3086
3087
  export {};
@@ -3,7 +3,7 @@ import { __awaiter } from '../_virtual/_tslib.js';
3
3
  import { getAddress, formatEther } from 'viem';
4
4
  import { toAccount } from 'viem/accounts';
5
5
  import { parseEvmNetworks, retryableFn, FALLBACK_UNDEFINED, DynamicError } from '@dynamic-labs/utils';
6
- import { chainsMap, getOrMapViemChain, createViemUiTransaction } from '@dynamic-labs/viem-utils';
6
+ import { chainsMap, getOrMapViemChain, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
7
7
  import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
8
8
  import { findEvmNetwork } from './utils/findEvmNetwork.js';
9
9
  import { getNameservice } from './utils/getNameservice.js';
@@ -62,13 +62,10 @@ class EthWalletConnector extends WalletConnectorBase {
62
62
  return chainId;
63
63
  });
64
64
  }
65
- getNameService() {
65
+ getNameService(address) {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
- const [[address], rpcProvider] = yield Promise.all([
68
- this.getConnectedAccounts(),
69
- this.getPublicClient(),
70
- ]);
71
- if (!address || !rpcProvider) {
67
+ const rpcProvider = yield this.getPublicClient();
68
+ if (!rpcProvider) {
72
69
  return;
73
70
  }
74
71
  return getNameservice({ address, rpcProvider });
@@ -96,13 +93,8 @@ class EthWalletConnector extends WalletConnectorBase {
96
93
  return this.getWalletClient();
97
94
  });
98
95
  }
99
- getBalance() {
96
+ getBalance(address) {
100
97
  return __awaiter(this, void 0, void 0, function* () {
101
- // This is equivalent to getSigner().getAddress() but does not crash
102
- // if the signer is not available
103
- const [address] = yield this.getConnectedAccounts();
104
- if (!address)
105
- return;
106
98
  const client = yield this.getPublicClient();
107
99
  const result = yield (client === null || client === void 0 ? void 0 : client.getBalance({
108
100
  address: address,
@@ -142,7 +134,7 @@ class EthWalletConnector extends WalletConnectorBase {
142
134
  return [];
143
135
  const addresses = yield retryableFn(provider.getAddresses, {
144
136
  fallbackValue: [],
145
- timeoutMs: 300,
137
+ timeoutMs: 500,
146
138
  });
147
139
  if (addresses.length) {
148
140
  this.setActiveAccount(addresses[0]);
@@ -228,7 +220,25 @@ class EthWalletConnector extends WalletConnectorBase {
228
220
  if (!publicClient || !walletClient) {
229
221
  throw new DynamicError('No public client available');
230
222
  }
231
- return createViemUiTransaction({ from, publicClient, walletClient });
223
+ return createViemUiTransaction({
224
+ from,
225
+ publicClient,
226
+ walletClient,
227
+ });
228
+ });
229
+ }
230
+ confirmTransactionStatus(txHash) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const publicClient = yield this.getPublicClient();
233
+ if (!publicClient) {
234
+ throw new DynamicError('No public client available');
235
+ }
236
+ // The number of confirmations (blocks that have passed) to wait before resolving.
237
+ const confirmations = 3;
238
+ return publicClient.waitForTransactionReceipt({
239
+ confirmations,
240
+ hash: txHash,
241
+ });
232
242
  });
233
243
  }
234
244
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var viem = require('viem');
8
- var viemUtils = require('@dynamic-labs/viem-utils');
8
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
9
9
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
10
10
  var EthWalletConnector = require('../EthWalletConnector.cjs');
11
11
  var helpers = require('./helpers.cjs');
@@ -19,7 +19,7 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
19
19
  this.supportedChains = ['EVM', 'ETH'];
20
20
  this.connectedChain = 'EVM';
21
21
  this.canConnectViaQrCode = false;
22
- this.canConnectViaCustodialService = true;
22
+ this.canConnectViaCustodialService = !this.isInstalledOnBrowser();
23
23
  this.coinbaseProviderOpts = {
24
24
  appLogoUrl: appLogoUrl,
25
25
  appName: appName,
@@ -89,7 +89,7 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
89
89
  getWalletClient(chainId) {
90
90
  return viem.createWalletClient({
91
91
  account: this.getActiveAccount(),
92
- chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
92
+ chain: chainId ? ethereumCore.chainsMap[chainId] : undefined,
93
93
  transport: viem.custom(this.coinbaseProvider),
94
94
  });
95
95
  }
@@ -9,12 +9,12 @@ export declare class Coinbase extends EthWalletConnector {
9
9
  supportedChains: Chain[];
10
10
  connectedChain: Chain;
11
11
  canConnectViaQrCode: boolean;
12
- canConnectViaCustodialService: boolean;
13
12
  coinbaseProviderOpts: GetCoinbaseProviderOpts;
14
13
  constructor({ appName, appLogoUrl, evmNetworks, coinbaseWalletPreference, ...props }: CoinbaseOpts);
15
14
  get coinbaseProvider(): ProviderInterface;
16
15
  getConnectedAccounts(): Promise<string[]>;
17
16
  isInstalledOnBrowser(): boolean;
17
+ canConnectViaCustodialService: boolean;
18
18
  getAddress(): Promise<string | undefined>;
19
19
  signMessage(messageToSign: string): Promise<string | undefined>;
20
20
  setupEventListeners(): void;
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
  import { __rest, __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { toHex, toBytes, createWalletClient, custom } from 'viem';
4
- import { chainsMap } from '@dynamic-labs/viem-utils';
4
+ import { chainsMap } from '@dynamic-labs/ethereum-core';
5
5
  import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
6
6
  import { EthWalletConnector } from '../EthWalletConnector.js';
7
7
  import { getCoinbaseProvider } from './helpers.js';
@@ -15,7 +15,7 @@ class Coinbase extends EthWalletConnector {
15
15
  this.supportedChains = ['EVM', 'ETH'];
16
16
  this.connectedChain = 'EVM';
17
17
  this.canConnectViaQrCode = false;
18
- this.canConnectViaCustodialService = true;
18
+ this.canConnectViaCustodialService = !this.isInstalledOnBrowser();
19
19
  this.coinbaseProviderOpts = {
20
20
  appLogoUrl: appLogoUrl,
21
21
  appName: appName,
@@ -7,8 +7,7 @@ var _tslib = require('../_virtual/_tslib.cjs');
7
7
  var viem = require('viem');
8
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
9
  var utils = require('@dynamic-labs/utils');
10
- var viemUtils = require('@dynamic-labs/viem-utils');
11
- var eip6963Provider = require('./eip6963Provider.cjs');
10
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
12
11
 
13
12
  class EthProviderHelper {
14
13
  constructor(wallet, connector) {
@@ -69,8 +68,8 @@ class EthProviderHelper {
69
68
  }
70
69
  eip6963ProviderLookup(rdns) {
71
70
  var _a;
72
- const { providers } = eip6963Provider.Eip6963ProviderSingleton.get();
73
- return (_a = providers.find((provider) => provider.info.rdns === rdns)) === null || _a === void 0 ? void 0 : _a.provider;
71
+ const { providers } = utils.Eip6963ProviderSingleton.get();
72
+ return (_a = providers.find((provider) => { var _a; return ((_a = provider === null || provider === void 0 ? void 0 : provider.info) === null || _a === void 0 ? void 0 : _a.rdns) === rdns; })) === null || _a === void 0 ? void 0 : _a.provider;
74
73
  }
75
74
  isInstalledHelper() {
76
75
  return this.findProvider() !== undefined;
@@ -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] : this.connector.getActiveChain(),
87
+ chain: chainId ? ethereumCore.chainsMap[chainId] : this.connector.getActiveChain(),
89
88
  transport: viem.custom(provider),
90
89
  });
91
90
  }
@@ -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';
6
- import { chainsMap } from '@dynamic-labs/viem-utils';
7
- import { Eip6963ProviderSingleton } from './eip6963Provider.js';
5
+ import { getProvidersFromWindow, Eip6963ProviderSingleton } from '@dynamic-labs/utils';
6
+ import { chainsMap } from '@dynamic-labs/ethereum-core';
8
7
 
9
8
  class EthProviderHelper {
10
9
  constructor(wallet, connector) {
@@ -66,7 +65,7 @@ class EthProviderHelper {
66
65
  eip6963ProviderLookup(rdns) {
67
66
  var _a;
68
67
  const { providers } = Eip6963ProviderSingleton.get();
69
- return (_a = providers.find((provider) => provider.info.rdns === rdns)) === null || _a === void 0 ? void 0 : _a.provider;
68
+ return (_a = providers.find((provider) => { var _a; return ((_a = provider === null || provider === void 0 ? void 0 : provider.info) === null || _a === void 0 ? void 0 : _a.rdns) === rdns; })) === null || _a === void 0 ? void 0 : _a.provider;
70
69
  }
71
70
  isInstalledHelper() {
72
71
  return this.findProvider() !== undefined;
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 };
@@ -39,7 +39,7 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
39
39
  // when the user is in a webview, customers should set the deepLinkPreference prop to universal,
40
40
  // in which case this condition will be false, and the SDK will use WalletConnect (if available)
41
41
  if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
42
- this.constructorProps.deepLinkPreference !== 'universal' &&
42
+ this.mobileExperience === 'in-app-browser' &&
43
43
  utils.isMobile()) {
44
44
  return this;
45
45
  }
@@ -37,7 +37,7 @@ class InjectedWalletBase extends EthWalletConnector {
37
37
  // when the user is in a webview, customers should set the deepLinkPreference prop to universal,
38
38
  // in which case this condition will be false, and the SDK will use WalletConnect (if available)
39
39
  if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
40
- this.constructorProps.deepLinkPreference !== 'universal' &&
40
+ this.mobileExperience === 'in-app-browser' &&
41
41
  isMobile()) {
42
42
  return this;
43
43
  }
@@ -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';