@dynamic-labs/ethereum 4.0.0-alpha.5 → 4.0.0-alpha.51

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 (71) hide show
  1. package/CHANGELOG.md +468 -0
  2. package/package.cjs +8 -0
  3. package/package.js +4 -0
  4. package/package.json +12 -17
  5. package/src/coinbase/coinbase.cjs +1 -3
  6. package/src/coinbase/coinbase.d.ts +2 -5
  7. package/src/coinbase/coinbase.js +2 -4
  8. package/src/coinbase/types.d.ts +2 -2
  9. package/src/ethProviderHelper.cjs +50 -44
  10. package/src/ethProviderHelper.d.ts +5 -7
  11. package/src/ethProviderHelper.js +51 -45
  12. package/src/index.cjs +17 -3
  13. package/src/index.d.ts +2 -1
  14. package/src/index.js +8 -4
  15. package/src/injected/ExodusEvm.cjs +3 -5
  16. package/src/injected/ExodusEvm.d.ts +1 -3
  17. package/src/injected/ExodusEvm.js +3 -5
  18. package/src/injected/FallbackEvmConnector.cjs +3 -5
  19. package/src/injected/FallbackEvmConnector.d.ts +1 -3
  20. package/src/injected/FallbackEvmConnector.js +3 -5
  21. package/src/injected/InjectedWalletBase.cjs +20 -27
  22. package/src/injected/InjectedWalletBase.d.ts +6 -10
  23. package/src/injected/InjectedWalletBase.js +19 -28
  24. package/src/injected/PhantomEvm.cjs +4 -6
  25. package/src/injected/PhantomEvm.d.ts +1 -3
  26. package/src/injected/PhantomEvm.js +4 -6
  27. package/src/injected/fetchInjectedWalletConnectors.cjs +48 -39
  28. package/src/injected/fetchInjectedWalletConnectors.js +49 -40
  29. package/src/injected/index.d.ts +1 -1
  30. package/src/metaMask/MetaMaskConnector.cjs +376 -0
  31. package/src/metaMask/MetaMaskConnector.d.ts +52 -0
  32. package/src/metaMask/MetaMaskConnector.js +372 -0
  33. package/src/metaMask/utils/createMetaMaskSDKDisplayUriState.cjs +58 -0
  34. package/src/metaMask/utils/createMetaMaskSDKDisplayUriState.d.ts +14 -0
  35. package/src/metaMask/utils/createMetaMaskSDKDisplayUriState.js +54 -0
  36. package/src/metaMask/utils/isPendingWalletRequestPermissionError.cjs +11 -0
  37. package/src/metaMask/utils/isPendingWalletRequestPermissionError.d.ts +1 -0
  38. package/src/metaMask/utils/isPendingWalletRequestPermissionError.js +7 -0
  39. package/src/metaMask/utils/waitForConnection.cjs +10 -0
  40. package/src/metaMask/utils/waitForConnection.d.ts +2 -0
  41. package/src/metaMask/utils/waitForConnection.js +6 -0
  42. package/src/utils/createInjectedConnector/createInjectedConnector.cjs +93 -0
  43. package/src/utils/createInjectedConnector/createInjectedConnector.d.ts +16 -0
  44. package/src/utils/createInjectedConnector/createInjectedConnector.js +89 -0
  45. package/src/utils/createInjectedConnector/index.d.ts +1 -0
  46. package/src/utils/getConnectorConstructorForEip6963Wallet/getConnectorConstructorForEip6963Wallet.cjs +30 -0
  47. package/src/utils/getConnectorConstructorForEip6963Wallet/getConnectorConstructorForEip6963Wallet.d.ts +3 -0
  48. package/src/utils/getConnectorConstructorForEip6963Wallet/getConnectorConstructorForEip6963Wallet.js +26 -0
  49. package/src/utils/getConnectorConstructorForEip6963Wallet/index.d.ts +1 -0
  50. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs +44 -0
  51. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.d.ts +3 -0
  52. package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js +40 -0
  53. package/src/utils/getConnectorConstructorInjectedWallet/index.d.ts +1 -0
  54. package/src/utils/logger.cjs +10 -0
  55. package/src/utils/logger.d.ts +2 -0
  56. package/src/utils/logger.js +6 -0
  57. package/src/utils/normalizeRpcError/index.d.ts +1 -0
  58. package/src/utils/normalizeRpcError/normalizeRpcError.cjs +51 -0
  59. package/src/utils/normalizeRpcError/normalizeRpcError.d.ts +5 -0
  60. package/src/utils/normalizeRpcError/normalizeRpcError.js +47 -0
  61. package/src/walletConnect/walletConnect.cjs +5 -11
  62. package/src/walletConnect/walletConnect.d.ts +4 -6
  63. package/src/walletConnect/walletConnect.js +5 -11
  64. package/src/injected/UnknownInjected.cjs +0 -21
  65. package/src/injected/UnknownInjected.d.ts +0 -8
  66. package/src/injected/UnknownInjected.js +0 -17
  67. package/src/utils/isString.d.ts +0 -1
  68. package/src/utils/last.d.ts +0 -1
  69. package/src/utils/parseIntSafe.cjs +0 -23
  70. package/src/utils/parseIntSafe.d.ts +0 -1
  71. package/src/utils/parseIntSafe.js +0 -19
@@ -0,0 +1,89 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import '@dynamic-labs/utils';
4
+ import { InjectedWalletBase } from '../../injected/InjectedWalletBase.js';
5
+ import '@dynamic-labs/wallet-connector-core';
6
+ import '../logger.js';
7
+
8
+ const createInjectedConnector = (customConnectorFn) => (props) => {
9
+ const delegate = customConnectorFn(props);
10
+ return [
11
+ class extends InjectedWalletBase {
12
+ constructor(props) {
13
+ super(Object.assign(Object.assign({}, props), { metadata: delegate.metadata }));
14
+ this.name = delegate.metadata.name;
15
+ }
16
+ init() {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ return delegate.init();
19
+ });
20
+ }
21
+ findProvider() {
22
+ return delegate.findProvider();
23
+ }
24
+ signMessage(messageToSign) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return delegate.signMessage(messageToSign);
27
+ });
28
+ }
29
+ connect() {
30
+ const _super = Object.create(null, {
31
+ connect: { get: () => super.connect }
32
+ });
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if (delegate.connect) {
35
+ return delegate.connect();
36
+ }
37
+ return _super.connect.call(this);
38
+ });
39
+ }
40
+ endSession() {
41
+ const _super = Object.create(null, {
42
+ endSession: { get: () => super.endSession }
43
+ });
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ if (delegate.disconnect) {
46
+ yield delegate.disconnect();
47
+ }
48
+ return _super.endSession.call(this);
49
+ });
50
+ }
51
+ getAddress() {
52
+ const _super = Object.create(null, {
53
+ getAddress: { get: () => super.getAddress }
54
+ });
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (delegate.getAddress) {
57
+ return delegate.getAddress();
58
+ }
59
+ return _super.getAddress.call(this);
60
+ });
61
+ }
62
+ getConnectedAccounts() {
63
+ const _super = Object.create(null, {
64
+ getConnectedAccounts: { get: () => super.getConnectedAccounts }
65
+ });
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ if (delegate.getConnectedAccounts) {
68
+ return delegate.getConnectedAccounts();
69
+ }
70
+ return _super.getConnectedAccounts.call(this);
71
+ });
72
+ }
73
+ filter() {
74
+ if (delegate.filter) {
75
+ return delegate.filter();
76
+ }
77
+ return super.filter();
78
+ }
79
+ supportsNetworkSwitching() {
80
+ if (delegate.supportsNetworkSwitching) {
81
+ return delegate.supportsNetworkSwitching();
82
+ }
83
+ return super.supportsNetworkSwitching();
84
+ }
85
+ },
86
+ ];
87
+ };
88
+
89
+ export { createInjectedConnector };
@@ -0,0 +1 @@
1
+ export * from './createInjectedConnector';
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var utils = require('@dynamic-labs/utils');
7
+ var InjectedWalletBase = require('../../injected/InjectedWalletBase.cjs');
8
+
9
+ const getConnectorConstructorForEip6963Wallet = (walletDetail) => {
10
+ const { info, provider } = walletDetail;
11
+ const sanitizedName = utils.sanitizeName(info.name);
12
+ return class extends InjectedWalletBase.InjectedWalletBase {
13
+ constructor(props) {
14
+ super(Object.assign(Object.assign({}, props), { metadata: {
15
+ groupKey: sanitizedName,
16
+ icon: info.icon,
17
+ id: info.uuid,
18
+ name: info.name,
19
+ rdns: info.rdns,
20
+ } }));
21
+ this.name = info.name;
22
+ this.overrideKey = `${sanitizedName}evm`;
23
+ }
24
+ findProvider() {
25
+ return provider;
26
+ }
27
+ };
28
+ };
29
+
30
+ exports.getConnectorConstructorForEip6963Wallet = getConnectorConstructorForEip6963Wallet;
@@ -0,0 +1,3 @@
1
+ import { Eip6963ProviderDetail } from '@dynamic-labs/utils';
2
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ export declare const getConnectorConstructorForEip6963Wallet: (walletDetail: Eip6963ProviderDetail) => WalletConnectorConstructor;
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+ import { sanitizeName } from '@dynamic-labs/utils';
3
+ import { InjectedWalletBase } from '../../injected/InjectedWalletBase.js';
4
+
5
+ const getConnectorConstructorForEip6963Wallet = (walletDetail) => {
6
+ const { info, provider } = walletDetail;
7
+ const sanitizedName = sanitizeName(info.name);
8
+ return class extends InjectedWalletBase {
9
+ constructor(props) {
10
+ super(Object.assign(Object.assign({}, props), { metadata: {
11
+ groupKey: sanitizedName,
12
+ icon: info.icon,
13
+ id: info.uuid,
14
+ name: info.name,
15
+ rdns: info.rdns,
16
+ } }));
17
+ this.name = info.name;
18
+ this.overrideKey = `${sanitizedName}evm`;
19
+ }
20
+ findProvider() {
21
+ return provider;
22
+ }
23
+ };
24
+ };
25
+
26
+ export { getConnectorConstructorForEip6963Wallet };
@@ -0,0 +1 @@
1
+ export { getConnectorConstructorForEip6963Wallet } from './getConnectorConstructorForEip6963Wallet';
@@ -0,0 +1,44 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var InjectedWalletBase = require('../../injected/InjectedWalletBase.cjs');
8
+ var logger = require('../logger.cjs');
9
+
10
+ const getConnectorConstructorInjectedWallet = (key, wallet) => {
11
+ const { shortName } = wallet;
12
+ const name = shortName || wallet.name;
13
+ const walletConnectorFallback = Boolean(wallet.walletConnect);
14
+ return class extends InjectedWalletBase.InjectedWalletBase {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.name = name;
18
+ this.walletConnectorFallback = walletConnectorFallback;
19
+ // this is the key from the wallet book entry so that we don't purely rely on the normalized name
20
+ this.overrideKey = key;
21
+ }
22
+ getAddress() {
23
+ const _super = Object.create(null, {
24
+ getAddress: { get: () => super.getAddress }
25
+ });
26
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
27
+ var _a;
28
+ if (this.isInstalledOnBrowser()) {
29
+ return _super.getAddress.call(this);
30
+ }
31
+ const inAppBrowserBase = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl;
32
+ if (!inAppBrowserBase) {
33
+ const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
34
+ logger.logger.error(error.message);
35
+ throw error;
36
+ }
37
+ window.location.href = `${inAppBrowserBase}/${window.location.href}`;
38
+ return undefined;
39
+ });
40
+ }
41
+ };
42
+ };
43
+
44
+ exports.getConnectorConstructorInjectedWallet = getConnectorConstructorInjectedWallet;
@@ -0,0 +1,3 @@
1
+ import { WalletSchema } from '@dynamic-labs/wallet-book';
2
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
3
+ export declare const getConnectorConstructorInjectedWallet: (key: string, wallet: WalletSchema) => WalletConnectorConstructor;
@@ -0,0 +1,40 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { InjectedWalletBase } from '../../injected/InjectedWalletBase.js';
4
+ import { logger } from '../logger.js';
5
+
6
+ const getConnectorConstructorInjectedWallet = (key, wallet) => {
7
+ const { shortName } = wallet;
8
+ const name = shortName || wallet.name;
9
+ const walletConnectorFallback = Boolean(wallet.walletConnect);
10
+ return class extends InjectedWalletBase {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.name = name;
14
+ this.walletConnectorFallback = walletConnectorFallback;
15
+ // this is the key from the wallet book entry so that we don't purely rely on the normalized name
16
+ this.overrideKey = key;
17
+ }
18
+ getAddress() {
19
+ const _super = Object.create(null, {
20
+ getAddress: { get: () => super.getAddress }
21
+ });
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a;
24
+ if (this.isInstalledOnBrowser()) {
25
+ return _super.getAddress.call(this);
26
+ }
27
+ const inAppBrowserBase = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl;
28
+ if (!inAppBrowserBase) {
29
+ const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
30
+ logger.error(error.message);
31
+ throw error;
32
+ }
33
+ window.location.href = `${inAppBrowserBase}/${window.location.href}`;
34
+ return undefined;
35
+ });
36
+ }
37
+ };
38
+ };
39
+
40
+ export { getConnectorConstructorInjectedWallet };
@@ -0,0 +1 @@
1
+ export { getConnectorConstructorInjectedWallet } from './getConnectorConstructorInjectedWallet';
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var logger$1 = require('@dynamic-labs/logger');
7
+
8
+ const logger = new logger$1.Logger('@dynamic-labs/ethereum');
9
+
10
+ exports.logger = logger;
@@ -0,0 +1,2 @@
1
+ import { Logger } from '@dynamic-labs/logger';
2
+ export declare const logger: Logger;
@@ -0,0 +1,6 @@
1
+ 'use client'
2
+ import { Logger } from '@dynamic-labs/logger';
3
+
4
+ const logger = new Logger('@dynamic-labs/ethereum');
5
+
6
+ export { logger };
@@ -0,0 +1 @@
1
+ export { normalizeRpcError } from './normalizeRpcError';
@@ -0,0 +1,51 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var viem = require('viem');
7
+
8
+ /**
9
+ * Some wallets may not reject some operations following the EIP-1193 standard.
10
+ * This function normalizes the errors to follow the EIP-1193 standard.
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const normalizeRpcError = (err) => {
14
+ /**
15
+ * When the error already comply with the EIP-1193 standard, we don't need to normalize it
16
+ */
17
+ if (err.code === 4001) {
18
+ throw err;
19
+ }
20
+ let mappedError = null;
21
+ try {
22
+ mappedError = mapRpcError(err);
23
+ }
24
+ catch (e) {
25
+ // ignore errors when mapping
26
+ }
27
+ if (mappedError) {
28
+ throw mappedError;
29
+ }
30
+ /**
31
+ * If no error is mapped, we rethrow the original error
32
+ */
33
+ throw err;
34
+ };
35
+ const mapRpcError = (err) => {
36
+ /**
37
+ * Checks for user rejection error message
38
+ * Rainbow Extension will return a message like "User rejected the request"
39
+ * BitGet will return a message like "user reject this request"
40
+ * Keplr will return a message that matches "Request rejected"
41
+ */
42
+ if (typeof err.message === 'string' &&
43
+ (err.message.includes('User rejected the request') ||
44
+ err.message.includes('user reject this request') ||
45
+ err.message === 'Request rejected')) {
46
+ return new viem.UserRejectedRequestError(err);
47
+ }
48
+ return null;
49
+ };
50
+
51
+ exports.normalizeRpcError = normalizeRpcError;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Some wallets may not reject some operations following the EIP-1193 standard.
3
+ * This function normalizes the errors to follow the EIP-1193 standard.
4
+ */
5
+ export declare const normalizeRpcError: (err: any) => never;
@@ -0,0 +1,47 @@
1
+ 'use client'
2
+ import { UserRejectedRequestError } from 'viem';
3
+
4
+ /**
5
+ * Some wallets may not reject some operations following the EIP-1193 standard.
6
+ * This function normalizes the errors to follow the EIP-1193 standard.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ const normalizeRpcError = (err) => {
10
+ /**
11
+ * When the error already comply with the EIP-1193 standard, we don't need to normalize it
12
+ */
13
+ if (err.code === 4001) {
14
+ throw err;
15
+ }
16
+ let mappedError = null;
17
+ try {
18
+ mappedError = mapRpcError(err);
19
+ }
20
+ catch (e) {
21
+ // ignore errors when mapping
22
+ }
23
+ if (mappedError) {
24
+ throw mappedError;
25
+ }
26
+ /**
27
+ * If no error is mapped, we rethrow the original error
28
+ */
29
+ throw err;
30
+ };
31
+ const mapRpcError = (err) => {
32
+ /**
33
+ * Checks for user rejection error message
34
+ * Rainbow Extension will return a message like "User rejected the request"
35
+ * BitGet will return a message like "user reject this request"
36
+ * Keplr will return a message that matches "Request rejected"
37
+ */
38
+ if (typeof err.message === 'string' &&
39
+ (err.message.includes('User rejected the request') ||
40
+ err.message.includes('user reject this request') ||
41
+ err.message === 'Request rejected')) {
42
+ return new UserRejectedRequestError(err);
43
+ }
44
+ return null;
45
+ };
46
+
47
+ export { normalizeRpcError };
@@ -8,10 +8,8 @@ var EthereumProvider = require('@walletconnect/ethereum-provider');
8
8
  var EventEmitter = require('eventemitter3');
9
9
  var viem = require('viem');
10
10
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
11
- var walletBook = require('@dynamic-labs/wallet-book');
12
11
  var utils = require('@dynamic-labs/utils');
13
12
  var ethereumCore = require('@dynamic-labs/ethereum-core');
14
- var parseIntSafe = require('../utils/parseIntSafe.cjs');
15
13
 
16
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
15
 
@@ -23,12 +21,10 @@ const sessionTopicKey = (walletName) => `dynamic-wc2-session-topic-${walletName}
23
21
  const swicthedNetworkKey = (walletName) => `dynamic-wc2-switched-network-${walletName}`;
24
22
  const currentChainKey = (walletName) => `dynamic-wc2-current-chain-${walletName}`;
25
23
  const ee = new EventEmitter__default["default"]();
26
- class WalletConnect extends ethereumCore.EthWalletConnector {
24
+ class WalletConnect extends ethereumCore.EthereumWalletConnector {
27
25
  constructor(opts) {
28
26
  var _a;
29
27
  super(opts);
30
- this.supportedChains = ['EVM', 'ETH'];
31
- this.connectedChain = 'EVM';
32
28
  this.isInitialized = false;
33
29
  this.canConnectViaQrCode = true;
34
30
  this.isWalletConnect = true;
@@ -46,7 +42,7 @@ class WalletConnect extends ethereumCore.EthWalletConnector {
46
42
  (_a = Boolean(localStorage.getItem(this.swicthedNetworkKey))) !== null && _a !== void 0 ? _a : false;
47
43
  const lsCurrentChain = localStorage.getItem(this.currentChainKey);
48
44
  this.currentChainId = lsCurrentChain
49
- ? parseIntSafe.parseIntSafe(lsCurrentChain)
45
+ ? utils.parseIntSafe(lsCurrentChain)
50
46
  : undefined;
51
47
  }
52
48
  getMappedChains() {
@@ -199,7 +195,7 @@ class WalletConnect extends ethereumCore.EthWalletConnector {
199
195
  }
200
196
  const { name, data } = params.event;
201
197
  if (name === 'chainChanged') {
202
- const chainId = parseIntSafe.parseIntSafe(data);
198
+ const chainId = utils.parseIntSafe(data);
203
199
  if (chainId === this.currentChainId) {
204
200
  walletConnectorCore.logger.debug(`ignoring chainChanged event with same chain id as current chain id: ${chainId}`);
205
201
  return;
@@ -271,8 +267,7 @@ class WalletConnect extends ethereumCore.EthWalletConnector {
271
267
  throw new utils.DynamicError('No provider found');
272
268
  }
273
269
  }
274
- const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key, this.walletFallback);
275
- walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, metadata, {
270
+ walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, this.metadata.deepLinks, {
276
271
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
277
272
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
278
273
  }, this.deepLinkPreference);
@@ -357,9 +352,8 @@ class WalletConnect extends ethereumCore.EthWalletConnector {
357
352
  if (!this.session) {
358
353
  return;
359
354
  }
360
- const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
361
355
  const deepLink = walletConnectorCore.getDeepLink({
362
- metadata,
356
+ deepLinks: this.metadata.deepLinks,
363
357
  mode: 'regular',
364
358
  preference: this.deepLinkPreference,
365
359
  uri: (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.signer.uri,
@@ -1,17 +1,15 @@
1
1
  import type { SessionTypes } from '@walletconnect/types';
2
2
  import { WalletClient, Account, Transport, Chain as ViemChain } from 'viem';
3
- import { Chain, GetAddressOpts, DeepLinkVariant, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
3
+ import { GetAddressOpts, DeepLinkVariant, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
4
4
  import { EvmNetwork } from '@dynamic-labs/types';
5
- import { EthWalletConnector, EthWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
6
- export type WalletConnectOpts = EthWalletConnectorOpts & {
5
+ import { EthereumWalletConnector, EthereumWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
6
+ export type WalletConnectOpts = EthereumWalletConnectorOpts & {
7
7
  projectId?: string;
8
8
  walletName: string;
9
9
  deepLinkPreference?: DeepLinkVariant;
10
10
  walletConnectPreferredChains?: `eip155:${number}`[];
11
11
  };
12
- export declare class WalletConnect extends EthWalletConnector implements IWalletConnectConnector {
13
- supportedChains: Chain[];
14
- connectedChain: Chain;
12
+ export declare class WalletConnect extends EthereumWalletConnector implements IWalletConnectConnector {
15
13
  name: string;
16
14
  session: SessionTypes.Struct | undefined;
17
15
  isInitialized: boolean;
@@ -4,22 +4,18 @@ import EthereumProvider from '@walletconnect/ethereum-provider';
4
4
  import EventEmitter from 'eventemitter3';
5
5
  import { createWalletClient, custom } from 'viem';
6
6
  import { logger, performPlatformSpecificConnectionMethod, getDeepLink } from '@dynamic-labs/wallet-connector-core';
7
- import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
8
- import { DynamicError, sleep, isMobile } from '@dynamic-labs/utils';
9
- import { EthWalletConnector, chainsMap } from '@dynamic-labs/ethereum-core';
10
- import { parseIntSafe } from '../utils/parseIntSafe.js';
7
+ import { parseIntSafe, DynamicError, sleep, isMobile } from '@dynamic-labs/utils';
8
+ import { EthereumWalletConnector, chainsMap } from '@dynamic-labs/ethereum-core';
11
9
 
12
10
  const activeAccountKey = (walletName) => `dynamic-wc2-active-account-${walletName}`;
13
11
  const sessionTopicKey = (walletName) => `dynamic-wc2-session-topic-${walletName}`;
14
12
  const swicthedNetworkKey = (walletName) => `dynamic-wc2-switched-network-${walletName}`;
15
13
  const currentChainKey = (walletName) => `dynamic-wc2-current-chain-${walletName}`;
16
14
  const ee = new EventEmitter();
17
- class WalletConnect extends EthWalletConnector {
15
+ class WalletConnect extends EthereumWalletConnector {
18
16
  constructor(opts) {
19
17
  var _a;
20
18
  super(opts);
21
- this.supportedChains = ['EVM', 'ETH'];
22
- this.connectedChain = 'EVM';
23
19
  this.isInitialized = false;
24
20
  this.canConnectViaQrCode = true;
25
21
  this.isWalletConnect = true;
@@ -262,8 +258,7 @@ class WalletConnect extends EthWalletConnector {
262
258
  throw new DynamicError('No provider found');
263
259
  }
264
260
  }
265
- const metadata = getWalletBookWallet(this.walletBook, this.key, this.walletFallback);
266
- performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, metadata, {
261
+ performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, this.metadata.deepLinks, {
267
262
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
268
263
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
269
264
  }, this.deepLinkPreference);
@@ -348,9 +343,8 @@ class WalletConnect extends EthWalletConnector {
348
343
  if (!this.session) {
349
344
  return;
350
345
  }
351
- const metadata = getWalletBookWallet(this.walletBook, this.key);
352
346
  const deepLink = getDeepLink({
353
- metadata,
347
+ deepLinks: this.metadata.deepLinks,
354
348
  mode: 'regular',
355
349
  preference: this.deepLinkPreference,
356
350
  uri: (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.signer.uri,
@@ -1,21 +0,0 @@
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 UnknownInjected extends InjectedWalletBase {
10
- constructor(props) {
11
- super(props);
12
- this.name = 'Unknown';
13
- this.overrideKey = 'unknown';
14
- this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
15
- }
16
- isInstalledOnBrowser() {
17
- return false;
18
- }
19
- }
20
-
21
- exports.UnknownInjected = UnknownInjected;
@@ -1,8 +0,0 @@
1
- import { EthWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
2
- import InjectedWalletBase from './InjectedWalletBase';
3
- export declare class UnknownInjected extends InjectedWalletBase {
4
- name: string;
5
- overrideKey: string;
6
- constructor(props: EthWalletConnectorOpts);
7
- isInstalledOnBrowser(): boolean;
8
- }
@@ -1,17 +0,0 @@
1
- 'use client'
2
- import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
3
- import InjectedWalletBase from './InjectedWalletBase.js';
4
-
5
- class UnknownInjected extends InjectedWalletBase {
6
- constructor(props) {
7
- super(props);
8
- this.name = 'Unknown';
9
- this.overrideKey = 'unknown';
10
- this.wallet = findWalletBookWallet(this.walletBook, this.key);
11
- }
12
- isInstalledOnBrowser() {
13
- return false;
14
- }
15
- }
16
-
17
- export { UnknownInjected };
@@ -1 +0,0 @@
1
- export declare const isString: (value: unknown) => value is string;
@@ -1 +0,0 @@
1
- export declare const last: <T = unknown>(array: T[]) => T | undefined;
@@ -1,23 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
-
8
- const parseIntSafe = (value, radix = 10) => {
9
- try {
10
- const int = parseInt(String(value), radix);
11
- if (isNaN(int)) {
12
- walletConnectorCore.logger.error(`Error parsing ${value}`);
13
- return undefined;
14
- }
15
- return int;
16
- }
17
- catch (e) {
18
- walletConnectorCore.logger.error(`Error parsing ${value} to int: ${e}`);
19
- }
20
- return undefined;
21
- };
22
-
23
- exports.parseIntSafe = parseIntSafe;
@@ -1 +0,0 @@
1
- export declare const parseIntSafe: (value: string | number, radix?: number) => number | undefined;
@@ -1,19 +0,0 @@
1
- 'use client'
2
- import { logger } from '@dynamic-labs/wallet-connector-core';
3
-
4
- const parseIntSafe = (value, radix = 10) => {
5
- try {
6
- const int = parseInt(String(value), radix);
7
- if (isNaN(int)) {
8
- logger.error(`Error parsing ${value}`);
9
- return undefined;
10
- }
11
- return int;
12
- }
13
- catch (e) {
14
- logger.error(`Error parsing ${value} to int: ${e}`);
15
- }
16
- return undefined;
17
- };
18
-
19
- export { parseIntSafe };