@dynamic-labs/ethereum-core 4.16.0 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { getAddress, formatEther } from 'viem';
4
4
  import { toAccount } from 'viem/accounts';
5
+ import { getCapabilities } from 'viem/experimental';
5
6
  import { parseEvmNetworks, retryableFn, FALLBACK_UNDEFINED, DynamicError, UserRejectedRequestError, isMobile } from '@dynamic-labs/utils';
6
7
  import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
7
8
  import '../utils/logger.js';
@@ -9,7 +10,6 @@ import '../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
9
10
  import { chainsMap } from '../utils/viem/chainsMap/chainsMap.js';
10
11
  import { createViemUiTransaction } from '../utils/viem/createViemUiTransaction/createViemUiTransaction.js';
11
12
  import { getOrMapViemChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
12
- import { getWalletCapabilities } from '../utils/viem/getWalletCapabilities/getWalletCapabilities.js';
13
13
  import { hasAtomicStatusCapability } from '../utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js';
14
14
  import { hasPaymasterServiceCapability } from '../utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js';
15
15
  import { findEvmNetwork } from '../utils/findEvmNetwork/findEvmNetwork.js';
@@ -312,7 +312,7 @@ class EthereumWalletConnector extends WalletConnectorBase {
312
312
  if (!walletClient) {
313
313
  return false;
314
314
  }
315
- const capabilities = yield getWalletCapabilities(walletClient);
315
+ const capabilities = yield getCapabilities(walletClient);
316
316
  const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
317
317
  logger.debug('[EthereumWalletConnector] isAtomicSupported', {
318
318
  capabilities,
@@ -327,7 +327,7 @@ class EthereumWalletConnector extends WalletConnectorBase {
327
327
  if (!walletClient) {
328
328
  return false;
329
329
  }
330
- const capabilities = yield getWalletCapabilities(walletClient);
330
+ const capabilities = yield getCapabilities(walletClient);
331
331
  const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
332
332
  logger.debug('[EthereumWalletConnector] isPaymasterServiceSupported', {
333
333
  capabilities,
package/src/index.cjs CHANGED
@@ -19,7 +19,6 @@ var createTransportWithUiConfirmation = require('./utils/viem/createTransportWit
19
19
  var createViemUiTransaction = require('./utils/viem/createViemUiTransaction/createViemUiTransaction.cjs');
20
20
  var createWalletClientWithUiConfirmation = require('./utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.cjs');
21
21
  var getOrMapViemChain = require('./utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
22
- var getWalletCapabilities = require('./utils/viem/getWalletCapabilities/getWalletCapabilities.cjs');
23
22
  var hasAtomicStatusCapability = require('./utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.cjs');
24
23
  var hasPaymasterServiceCapability = require('./utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.cjs');
25
24
  var unFormatTransaction = require('./utils/viem/unFormatTransaction/unFormatTransaction.cjs');
@@ -48,7 +47,6 @@ exports.createWalletClientWithUiConfirmation = createWalletClientWithUiConfirmat
48
47
  exports.getChain = getOrMapViemChain.getChain;
49
48
  exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
50
49
  exports.mapChain = getOrMapViemChain.mapChain;
51
- exports.getWalletCapabilities = getWalletCapabilities.getWalletCapabilities;
52
50
  exports.hasAtomicStatusCapability = hasAtomicStatusCapability.hasAtomicStatusCapability;
53
51
  exports.hasPaymasterServiceCapability = hasPaymasterServiceCapability.hasPaymasterServiceCapability;
54
52
  exports.unFormatTransaction = unFormatTransaction.unFormatTransaction;
package/src/index.js CHANGED
@@ -15,7 +15,6 @@ export { createTransportWithUiConfirmation } from './utils/viem/createTransportW
15
15
  export { createViemUiTransaction } from './utils/viem/createViemUiTransaction/createViemUiTransaction.js';
16
16
  export { createWalletClientWithUiConfirmation } from './utils/viem/createWalletClientWithUiConfirmation/createWalletClientWithUiConfirmation.js';
17
17
  export { getChain, getOrMapViemChain, mapChain } from './utils/viem/getOrMapViemChain/getOrMapViemChain.js';
18
- export { getWalletCapabilities } from './utils/viem/getWalletCapabilities/getWalletCapabilities.js';
19
18
  export { hasAtomicStatusCapability } from './utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js';
20
19
  export { hasPaymasterServiceCapability } from './utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js';
21
20
  export { unFormatTransaction } from './utils/viem/unFormatTransaction/unFormatTransaction.js';
@@ -9,6 +9,13 @@ var ViemUiTransaction = require('../ViemUiTransaction/ViemUiTransaction.cjs');
9
9
 
10
10
  const createAccountWithUiConfirmation = ({ address, account, provider, walletConnector, walletUiUtils, }) => accounts.toAccount({
11
11
  address,
12
+ signAuthorization: (...args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
13
+ const accountInstance = yield account();
14
+ if (!accountInstance.signAuthorization) {
15
+ throw new Error('signAuthorization not found');
16
+ }
17
+ return accountInstance.signAuthorization(...args);
18
+ }),
12
19
  signMessage: (...args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
13
20
  return walletUiUtils.signMessage({
14
21
  handler: () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return (yield account()).signMessage(...args); }),
@@ -29,43 +29,43 @@ export declare const createAccountWithUiConfirmation: ({ address, account, provi
29
29
  [x: `bool[${string}]`]: undefined;
30
30
  [x: `bytes[${string}]`]: undefined;
31
31
  [x: `bytes1[${string}]`]: undefined;
32
- [x: `bytes32[${string}]`]: undefined;
33
- [x: `bytes31[${string}]`]: undefined;
34
- [x: `bytes30[${string}]`]: undefined;
35
- [x: `bytes29[${string}]`]: undefined;
36
- [x: `bytes28[${string}]`]: undefined;
37
- [x: `bytes27[${string}]`]: undefined;
38
- [x: `bytes26[${string}]`]: undefined;
39
- [x: `bytes25[${string}]`]: undefined;
40
- [x: `bytes24[${string}]`]: undefined;
41
- [x: `bytes23[${string}]`]: undefined;
42
- [x: `bytes22[${string}]`]: undefined;
43
- [x: `bytes21[${string}]`]: undefined;
44
- [x: `bytes20[${string}]`]: undefined;
45
32
  [x: `bytes2[${string}]`]: undefined;
46
- [x: `bytes19[${string}]`]: undefined;
47
- [x: `bytes18[${string}]`]: undefined;
48
- [x: `bytes17[${string}]`]: undefined;
49
- [x: `bytes16[${string}]`]: undefined;
50
- [x: `bytes15[${string}]`]: undefined;
51
- [x: `bytes14[${string}]`]: undefined;
52
- [x: `bytes13[${string}]`]: undefined;
53
- [x: `bytes12[${string}]`]: undefined;
54
- [x: `bytes11[${string}]`]: undefined;
55
- [x: `bytes10[${string}]`]: undefined;
56
- [x: `bytes9[${string}]`]: undefined;
57
- [x: `bytes8[${string}]`]: undefined;
58
- [x: `bytes7[${string}]`]: undefined;
59
- [x: `bytes6[${string}]`]: undefined;
60
- [x: `bytes5[${string}]`]: undefined;
61
- [x: `bytes4[${string}]`]: undefined;
62
33
  [x: `bytes3[${string}]`]: undefined;
34
+ [x: `bytes4[${string}]`]: undefined;
35
+ [x: `bytes5[${string}]`]: undefined;
36
+ [x: `bytes6[${string}]`]: undefined;
37
+ [x: `bytes7[${string}]`]: undefined;
38
+ [x: `bytes8[${string}]`]: undefined;
39
+ [x: `bytes9[${string}]`]: undefined;
40
+ [x: `bytes10[${string}]`]: undefined;
41
+ [x: `bytes11[${string}]`]: undefined;
42
+ [x: `bytes12[${string}]`]: undefined;
43
+ [x: `bytes13[${string}]`]: undefined;
44
+ [x: `bytes14[${string}]`]: undefined;
45
+ [x: `bytes15[${string}]`]: undefined;
46
+ [x: `bytes16[${string}]`]: undefined;
47
+ [x: `bytes17[${string}]`]: undefined;
48
+ [x: `bytes18[${string}]`]: undefined;
49
+ [x: `bytes19[${string}]`]: undefined;
50
+ [x: `bytes20[${string}]`]: undefined;
51
+ [x: `bytes21[${string}]`]: undefined;
52
+ [x: `bytes22[${string}]`]: undefined;
53
+ [x: `bytes23[${string}]`]: undefined;
54
+ [x: `bytes24[${string}]`]: undefined;
55
+ [x: `bytes25[${string}]`]: undefined;
56
+ [x: `bytes26[${string}]`]: undefined;
57
+ [x: `bytes27[${string}]`]: undefined;
58
+ [x: `bytes28[${string}]`]: undefined;
59
+ [x: `bytes29[${string}]`]: undefined;
60
+ [x: `bytes30[${string}]`]: undefined;
61
+ [x: `bytes31[${string}]`]: undefined;
62
+ [x: `bytes32[${string}]`]: undefined;
63
63
  [x: `int[${string}]`]: undefined;
64
- [x: `int40[${string}]`]: undefined;
65
- [x: `int32[${string}]`]: undefined;
66
- [x: `int24[${string}]`]: undefined;
67
- [x: `int16[${string}]`]: undefined;
68
64
  [x: `int8[${string}]`]: undefined;
65
+ [x: `int16[${string}]`]: undefined;
66
+ [x: `int24[${string}]`]: undefined;
67
+ [x: `int32[${string}]`]: undefined;
68
+ [x: `int40[${string}]`]: undefined;
69
69
  [x: `int48[${string}]`]: undefined;
70
70
  [x: `int56[${string}]`]: undefined;
71
71
  [x: `int64[${string}]`]: undefined;
@@ -94,11 +94,11 @@ export declare const createAccountWithUiConfirmation: ({ address, account, provi
94
94
  [x: `int248[${string}]`]: undefined;
95
95
  [x: `int256[${string}]`]: undefined;
96
96
  [x: `uint[${string}]`]: undefined;
97
- [x: `uint40[${string}]`]: undefined;
98
- [x: `uint32[${string}]`]: undefined;
99
- [x: `uint24[${string}]`]: undefined;
100
- [x: `uint16[${string}]`]: undefined;
101
97
  [x: `uint8[${string}]`]: undefined;
98
+ [x: `uint16[${string}]`]: undefined;
99
+ [x: `uint24[${string}]`]: undefined;
100
+ [x: `uint32[${string}]`]: undefined;
101
+ [x: `uint40[${string}]`]: undefined;
102
102
  [x: `uint48[${string}]`]: undefined;
103
103
  [x: `uint56[${string}]`]: undefined;
104
104
  [x: `uint64[${string}]`]: undefined;
@@ -131,42 +131,42 @@ export declare const createAccountWithUiConfirmation: ({ address, account, provi
131
131
  bool?: undefined;
132
132
  bytes?: undefined;
133
133
  bytes1?: undefined;
134
- bytes32?: undefined;
135
- bytes31?: undefined;
136
- bytes30?: undefined;
137
- bytes29?: undefined;
138
- bytes28?: undefined;
139
- bytes27?: undefined;
140
- bytes26?: undefined;
141
- bytes25?: undefined;
142
- bytes24?: undefined;
143
- bytes23?: undefined;
144
- bytes22?: undefined;
145
- bytes21?: undefined;
146
- bytes20?: undefined;
147
134
  bytes2?: undefined;
148
- bytes19?: undefined;
149
- bytes18?: undefined;
150
- bytes17?: undefined;
151
- bytes16?: undefined;
152
- bytes15?: undefined;
153
- bytes14?: undefined;
154
- bytes13?: undefined;
155
- bytes12?: undefined;
156
- bytes11?: undefined;
157
- bytes10?: undefined;
158
- bytes9?: undefined;
159
- bytes8?: undefined;
160
- bytes7?: undefined;
161
- bytes6?: undefined;
162
- bytes5?: undefined;
163
- bytes4?: undefined;
164
135
  bytes3?: undefined;
165
- int40?: undefined;
166
- int32?: undefined;
167
- int24?: undefined;
168
- int16?: undefined;
136
+ bytes4?: undefined;
137
+ bytes5?: undefined;
138
+ bytes6?: undefined;
139
+ bytes7?: undefined;
140
+ bytes8?: undefined;
141
+ bytes9?: undefined;
142
+ bytes10?: undefined;
143
+ bytes11?: undefined;
144
+ bytes12?: undefined;
145
+ bytes13?: undefined;
146
+ bytes14?: undefined;
147
+ bytes15?: undefined;
148
+ bytes16?: undefined;
149
+ bytes17?: undefined;
150
+ bytes18?: undefined;
151
+ bytes19?: undefined;
152
+ bytes20?: undefined;
153
+ bytes21?: undefined;
154
+ bytes22?: undefined;
155
+ bytes23?: undefined;
156
+ bytes24?: undefined;
157
+ bytes25?: undefined;
158
+ bytes26?: undefined;
159
+ bytes27?: undefined;
160
+ bytes28?: undefined;
161
+ bytes29?: undefined;
162
+ bytes30?: undefined;
163
+ bytes31?: undefined;
164
+ bytes32?: undefined;
169
165
  int8?: undefined;
166
+ int16?: undefined;
167
+ int24?: undefined;
168
+ int32?: undefined;
169
+ int40?: undefined;
170
170
  int48?: undefined;
171
171
  int56?: undefined;
172
172
  int64?: undefined;
@@ -194,11 +194,11 @@ export declare const createAccountWithUiConfirmation: ({ address, account, provi
194
194
  int240?: undefined;
195
195
  int248?: undefined;
196
196
  int256?: undefined;
197
- uint40?: undefined;
198
- uint32?: undefined;
199
- uint24?: undefined;
200
- uint16?: undefined;
201
197
  uint8?: undefined;
198
+ uint16?: undefined;
199
+ uint24?: undefined;
200
+ uint32?: undefined;
201
+ uint40?: undefined;
202
202
  uint48?: undefined;
203
203
  uint56?: undefined;
204
204
  uint64?: undefined;
@@ -5,6 +5,13 @@ import { ViemUiTransaction } from '../ViemUiTransaction/ViemUiTransaction.js';
5
5
 
6
6
  const createAccountWithUiConfirmation = ({ address, account, provider, walletConnector, walletUiUtils, }) => toAccount({
7
7
  address,
8
+ signAuthorization: (...args) => __awaiter(void 0, void 0, void 0, function* () {
9
+ const accountInstance = yield account();
10
+ if (!accountInstance.signAuthorization) {
11
+ throw new Error('signAuthorization not found');
12
+ }
13
+ return accountInstance.signAuthorization(...args);
14
+ }),
8
15
  signMessage: (...args) => __awaiter(void 0, void 0, void 0, function* () {
9
16
  return walletUiUtils.signMessage({
10
17
  handler: () => __awaiter(void 0, void 0, void 0, function* () { return (yield account()).signMessage(...args); }),
@@ -3,14 +3,25 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
+ var logger = require('../../logger.cjs');
7
+
6
8
  const hasAtomicStatusCapability = (capabilities, chainId) => {
7
9
  if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
8
10
  return false;
9
11
  }
10
12
  const chainCapabilities = capabilities[chainId];
11
- return Boolean(chainCapabilities['atomic'] &&
13
+ const hasAtomicStatus = Boolean(chainCapabilities['atomic'] &&
12
14
  (chainCapabilities['atomic'].status === 'ready' ||
13
15
  chainCapabilities['atomic'].status === 'supported'));
16
+ // coinbase uses 'atomicBatch.support' instead of 'atomic.status'
17
+ const hasAtomicBatchSupport = Boolean(chainCapabilities['atomicBatch'] &&
18
+ chainCapabilities['atomicBatch'].supported === true);
19
+ logger.logger.debug('[hasAtomicStatusCapability]', {
20
+ chainCapabilities,
21
+ hasAtomicBatchSupport,
22
+ hasAtomicStatus,
23
+ });
24
+ return hasAtomicStatus || hasAtomicBatchSupport;
14
25
  };
15
26
 
16
27
  exports.hasAtomicStatusCapability = hasAtomicStatusCapability;
@@ -1,12 +1,23 @@
1
1
  'use client'
2
+ import { logger } from '../../logger.js';
3
+
2
4
  const hasAtomicStatusCapability = (capabilities, chainId) => {
3
5
  if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
4
6
  return false;
5
7
  }
6
8
  const chainCapabilities = capabilities[chainId];
7
- return Boolean(chainCapabilities['atomic'] &&
9
+ const hasAtomicStatus = Boolean(chainCapabilities['atomic'] &&
8
10
  (chainCapabilities['atomic'].status === 'ready' ||
9
11
  chainCapabilities['atomic'].status === 'supported'));
12
+ // coinbase uses 'atomicBatch.support' instead of 'atomic.status'
13
+ const hasAtomicBatchSupport = Boolean(chainCapabilities['atomicBatch'] &&
14
+ chainCapabilities['atomicBatch'].supported === true);
15
+ logger.debug('[hasAtomicStatusCapability]', {
16
+ chainCapabilities,
17
+ hasAtomicBatchSupport,
18
+ hasAtomicStatus,
19
+ });
20
+ return hasAtomicStatus || hasAtomicBatchSupport;
10
21
  };
11
22
 
12
23
  export { hasAtomicStatusCapability };
@@ -6,7 +6,6 @@ export * from './createTransportWithUiConfirmation';
6
6
  export * from './createViemUiTransaction';
7
7
  export * from './createWalletClientWithUiConfirmation';
8
8
  export * from './getOrMapViemChain';
9
- export * from './getWalletCapabilities';
10
9
  export * from './hasAtomicStatusCapability';
11
10
  export * from './hasPaymasterServiceCapability';
12
11
  export * from './unFormatTransaction';
@@ -5,16 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var viem = require('viem');
8
+ var experimental = require('viem/experimental');
8
9
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
10
  require('@dynamic-labs/utils');
10
- require('../utils/logger.cjs');
11
+ var logger = require('../utils/logger.cjs');
11
12
  require('../utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs');
12
13
  require('../utils/viem/chainsMap/chainsMap.cjs');
13
14
  var interceptTransport = require('../utils/viem/interceptTransport/interceptTransport.cjs');
14
15
  var abi = require('../utils/viem/erc20/abi.cjs');
15
16
  require('viem/accounts');
16
17
  var getOrMapViemChain = require('../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
17
- require('viem/experimental');
18
18
  var parseAddress = require('../utils/parseAddress/parseAddress.cjs');
19
19
 
20
20
  class EthereumWallet extends walletConnectorCore.Wallet {
@@ -110,14 +110,74 @@ class EthereumWallet extends walletConnectorCore.Wallet {
110
110
  getTransportConfig() {
111
111
  return this._connector.providersConfig.httpTransportConfig;
112
112
  }
113
- isPaymasterServiceSupported() {
113
+ isPaymasterServiceSupported(chainId) {
114
114
  return _tslib.__awaiter(this, void 0, void 0, function* () {
115
- return this._connector.isPaymasterServiceSupported();
115
+ try {
116
+ const supported = yield this._connector.isPaymasterServiceSupported(chainId);
117
+ return supported;
118
+ }
119
+ catch (error) {
120
+ logger.logger.error('[EthereumWallet] isPaymasterServiceSupported', {
121
+ chainId,
122
+ error,
123
+ });
124
+ return false;
125
+ }
116
126
  });
117
127
  }
118
- isAtomicSupported() {
128
+ isAtomicSupported(chainId) {
119
129
  return _tslib.__awaiter(this, void 0, void 0, function* () {
120
- return this._connector.isAtomicSupported();
130
+ try {
131
+ const supported = yield this._connector.isAtomicSupported(chainId);
132
+ return supported;
133
+ }
134
+ catch (error) {
135
+ logger.logger.error('[EthereumWallet] isAtomicSupported', {
136
+ chainId,
137
+ error,
138
+ });
139
+ return false;
140
+ }
141
+ });
142
+ }
143
+ sendCalls(callParams, options) {
144
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
145
+ var _a;
146
+ const chainId = (_a = callParams.chain) === null || _a === void 0 ? void 0 : _a.id;
147
+ const walletClient = yield this.getWalletClient(chainId === null || chainId === void 0 ? void 0 : chainId.toString());
148
+ const atomicStatusSupported = yield this.isAtomicSupported(chainId);
149
+ if (!atomicStatusSupported) {
150
+ logger.logger.debug('[EthereumWallet] atomic is not supported wallet or chain', {
151
+ chainId,
152
+ wallet: {
153
+ address: this.address,
154
+ key: this.key,
155
+ },
156
+ });
157
+ throw new Error('Atomic is not supported for this wallet and chain');
158
+ }
159
+ const paymasterServiceSupported = yield this.isPaymasterServiceSupported(chainId);
160
+ if (paymasterServiceSupported && (options === null || options === void 0 ? void 0 : options.paymasterURL)) {
161
+ callParams.capabilities = {
162
+ paymasterService: {
163
+ [chainId]: {
164
+ url: options === null || options === void 0 ? void 0 : options.paymasterURL,
165
+ },
166
+ },
167
+ };
168
+ }
169
+ logger.logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
170
+ atomicStatusSupported,
171
+ callOptions: options,
172
+ callParams,
173
+ chainId,
174
+ paymasterServiceSupported,
175
+ });
176
+ const result = yield experimental.sendCalls(walletClient, callParams);
177
+ logger.logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
178
+ result,
179
+ });
180
+ return result;
121
181
  });
122
182
  }
123
183
  }
@@ -1,4 +1,5 @@
1
1
  import { Account, Chain, HttpTransportConfig, PublicClient, Transport, WalletClient } from 'viem';
2
+ import { SendCallsParameters, SendCallsReturnType } from 'viem/experimental';
2
3
  import { Wallet, WalletProps } from '@dynamic-labs/wallet-connector-core';
3
4
  import { EthereumWalletConnector } from '../connector';
4
5
  export declare class EthereumWallet extends Wallet<EthereumWalletConnector> {
@@ -34,6 +35,9 @@ export declare class EthereumWallet extends Wallet<EthereumWalletConnector> {
34
35
  */
35
36
  getWalletClient(chainId?: string): Promise<WalletClient<Transport, Chain, Account>>;
36
37
  getTransportConfig(): HttpTransportConfig | undefined;
37
- isPaymasterServiceSupported(): Promise<boolean>;
38
- isAtomicSupported(): Promise<boolean>;
38
+ isPaymasterServiceSupported(chainId?: number): Promise<boolean>;
39
+ isAtomicSupported(chainId?: number): Promise<boolean>;
40
+ sendCalls(callParams: Omit<SendCallsParameters, 'account'>, options?: {
41
+ paymasterURL?: string;
42
+ }): Promise<SendCallsReturnType>;
39
43
  }
@@ -1,16 +1,16 @@
1
1
  'use client'
2
2
  import { __awaiter } from '../../_virtual/_tslib.js';
3
3
  import { getContract, parseUnits, parseEther, createWalletClient, custom } from 'viem';
4
+ import { sendCalls } from 'viem/experimental';
4
5
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
5
6
  import '@dynamic-labs/utils';
6
- import '../utils/logger.js';
7
+ import { logger } from '../utils/logger.js';
7
8
  import '../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
8
9
  import '../utils/viem/chainsMap/chainsMap.js';
9
10
  import { interceptTransport } from '../utils/viem/interceptTransport/interceptTransport.js';
10
11
  import { erc20Abi } from '../utils/viem/erc20/abi.js';
11
12
  import 'viem/accounts';
12
13
  import { getChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
13
- import 'viem/experimental';
14
14
  import { parseAddress } from '../utils/parseAddress/parseAddress.js';
15
15
 
16
16
  class EthereumWallet extends Wallet {
@@ -106,14 +106,74 @@ class EthereumWallet extends Wallet {
106
106
  getTransportConfig() {
107
107
  return this._connector.providersConfig.httpTransportConfig;
108
108
  }
109
- isPaymasterServiceSupported() {
109
+ isPaymasterServiceSupported(chainId) {
110
110
  return __awaiter(this, void 0, void 0, function* () {
111
- return this._connector.isPaymasterServiceSupported();
111
+ try {
112
+ const supported = yield this._connector.isPaymasterServiceSupported(chainId);
113
+ return supported;
114
+ }
115
+ catch (error) {
116
+ logger.error('[EthereumWallet] isPaymasterServiceSupported', {
117
+ chainId,
118
+ error,
119
+ });
120
+ return false;
121
+ }
112
122
  });
113
123
  }
114
- isAtomicSupported() {
124
+ isAtomicSupported(chainId) {
115
125
  return __awaiter(this, void 0, void 0, function* () {
116
- return this._connector.isAtomicSupported();
126
+ try {
127
+ const supported = yield this._connector.isAtomicSupported(chainId);
128
+ return supported;
129
+ }
130
+ catch (error) {
131
+ logger.error('[EthereumWallet] isAtomicSupported', {
132
+ chainId,
133
+ error,
134
+ });
135
+ return false;
136
+ }
137
+ });
138
+ }
139
+ sendCalls(callParams, options) {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ var _a;
142
+ const chainId = (_a = callParams.chain) === null || _a === void 0 ? void 0 : _a.id;
143
+ const walletClient = yield this.getWalletClient(chainId === null || chainId === void 0 ? void 0 : chainId.toString());
144
+ const atomicStatusSupported = yield this.isAtomicSupported(chainId);
145
+ if (!atomicStatusSupported) {
146
+ logger.debug('[EthereumWallet] atomic is not supported wallet or chain', {
147
+ chainId,
148
+ wallet: {
149
+ address: this.address,
150
+ key: this.key,
151
+ },
152
+ });
153
+ throw new Error('Atomic is not supported for this wallet and chain');
154
+ }
155
+ const paymasterServiceSupported = yield this.isPaymasterServiceSupported(chainId);
156
+ if (paymasterServiceSupported && (options === null || options === void 0 ? void 0 : options.paymasterURL)) {
157
+ callParams.capabilities = {
158
+ paymasterService: {
159
+ [chainId]: {
160
+ url: options === null || options === void 0 ? void 0 : options.paymasterURL,
161
+ },
162
+ },
163
+ };
164
+ }
165
+ logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
166
+ atomicStatusSupported,
167
+ callOptions: options,
168
+ callParams,
169
+ chainId,
170
+ paymasterServiceSupported,
171
+ });
172
+ const result = yield sendCalls(walletClient, callParams);
173
+ logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
174
+ result,
175
+ });
176
+ return result;
117
177
  });
118
178
  }
119
179
  }
@@ -1,11 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../../../_virtual/_tslib.cjs');
7
- var experimental = require('viem/experimental');
8
-
9
- const getWalletCapabilities = (walletClient) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return walletClient.extend(experimental.eip5792Actions()).getCapabilities(); });
10
-
11
- exports.getWalletCapabilities = getWalletCapabilities;
@@ -1,4 +0,0 @@
1
- import { WalletClient } from 'viem';
2
- export declare const getWalletCapabilities: (walletClient: WalletClient) => Promise<{
3
- [x: number]: import("viem").WalletCapabilities;
4
- }>;
@@ -1,7 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../../../_virtual/_tslib.js';
3
- import { eip5792Actions } from 'viem/experimental';
4
-
5
- const getWalletCapabilities = (walletClient) => __awaiter(void 0, void 0, void 0, function* () { return walletClient.extend(eip5792Actions()).getCapabilities(); });
6
-
7
- export { getWalletCapabilities };
@@ -1 +0,0 @@
1
- export { getWalletCapabilities } from './getWalletCapabilities';