@dynamic-labs/ethereum-core 4.15.0 → 4.17.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.
- package/CHANGELOG.md +24 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connector/EthereumWalletConnector.cjs +33 -0
- package/src/connector/EthereumWalletConnector.d.ts +4 -2
- package/src/connector/EthereumWalletConnector.js +33 -0
- package/src/index.cjs +4 -0
- package/src/index.js +2 -0
- package/src/types.d.ts +4 -0
- package/src/utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.cjs +27 -0
- package/src/utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.d.ts +2 -0
- package/src/utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js +23 -0
- package/src/utils/viem/hasAtomicStatusCapability/index.d.ts +1 -0
- package/src/utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.cjs +15 -0
- package/src/utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.d.ts +2 -0
- package/src/utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js +11 -0
- package/src/utils/viem/hasPaymasterServiceCapability/index.d.ts +1 -0
- package/src/utils/viem/index.d.ts +2 -0
- package/src/wallet/EthereumWallet.cjs +50 -1
- package/src/wallet/EthereumWallet.d.ts +6 -0
- package/src/wallet/EthereumWallet.js +50 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.17.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.16.0...v4.17.0) (2025-05-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add chain id option to create kernel client in react-native ([#8650](https://github.com/dynamic-labs/dynamic-auth/issues/8650)) ([1450bea](https://github.com/dynamic-labs/dynamic-auth/commit/1450bea6f979a82ed4880700aff14fa1ead9dc60))
|
|
8
|
+
* add sendCalls method to EthereumWallet ([#8634](https://github.com/dynamic-labs/dynamic-auth/issues/8634)) ([7c9aef9](https://github.com/dynamic-labs/dynamic-auth/commit/7c9aef95382b4823a40279bebfb084de32c25610))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* 7702 do not override existing old aa ([#8630](https://github.com/dynamic-labs/dynamic-auth/issues/8630)) ([a731d9e](https://github.com/dynamic-labs/dynamic-auth/commit/a731d9e77ecd9e1dec3a7704a63989b5f2741a57))
|
|
14
|
+
* improve error message when email login fails ([#8649](https://github.com/dynamic-labs/dynamic-auth/issues/8649)) ([e1c03ac](https://github.com/dynamic-labs/dynamic-auth/commit/e1c03ac6dc83386c63d63db59d31355bc4fe2959))
|
|
15
|
+
* improve react-native stability on android ([#8652](https://github.com/dynamic-labs/dynamic-auth/issues/8652)) ([1617546](https://github.com/dynamic-labs/dynamic-auth/commit/1617546e6053c2ab32f7d385336c47df185d077f))
|
|
16
|
+
|
|
17
|
+
## [4.16.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.15.0...v4.16.0) (2025-05-03)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* (GVTY-3020) add send balance to waas sui connector ([#8638](https://github.com/dynamic-labs/dynamic-auth/issues/8638)) ([97f0af0](https://github.com/dynamic-labs/dynamic-auth/commit/97f0af0504a0079ebf0958fde1f8edc34c035927))
|
|
23
|
+
* add isAtomicSupported and isPaymasterServiceSupported methods to EthereumWallet ([#8627](https://github.com/dynamic-labs/dynamic-auth/issues/8627)) ([df82b9e](https://github.com/dynamic-labs/dynamic-auth/commit/df82b9e86eafea9dd6c505227722450bc56d7c57))
|
|
24
|
+
* add solana mpc to global wallets ([#8605](https://github.com/dynamic-labs/dynamic-auth/issues/8605)) ([6261bf9](https://github.com/dynamic-labs/dynamic-auth/commit/6261bf9bec45b1d1afa13869cf5d10cda215783e))
|
|
25
|
+
|
|
2
26
|
## [4.15.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.14.0...v4.15.0) (2025-04-30)
|
|
3
27
|
|
|
4
28
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "Core package for utilities and types for viem",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.0.660",
|
|
22
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
23
|
-
"@dynamic-labs/logger": "4.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
25
|
-
"@dynamic-labs/types": "4.
|
|
26
|
-
"@dynamic-labs/utils": "4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "4.17.0",
|
|
23
|
+
"@dynamic-labs/logger": "4.17.0",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "4.17.0",
|
|
25
|
+
"@dynamic-labs/types": "4.17.0",
|
|
26
|
+
"@dynamic-labs/utils": "4.17.0",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.17.0",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.17.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"viem": "^2.21.60"
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var viem = require('viem');
|
|
8
8
|
var accounts = require('viem/accounts');
|
|
9
|
+
var experimental = require('viem/experimental');
|
|
9
10
|
var utils = require('@dynamic-labs/utils');
|
|
10
11
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
11
12
|
require('../utils/logger.cjs');
|
|
@@ -13,6 +14,8 @@ require('../utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs');
|
|
|
13
14
|
var chainsMap = require('../utils/viem/chainsMap/chainsMap.cjs');
|
|
14
15
|
var createViemUiTransaction = require('../utils/viem/createViemUiTransaction/createViemUiTransaction.cjs');
|
|
15
16
|
var getOrMapViemChain = require('../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
|
|
17
|
+
var hasAtomicStatusCapability = require('../utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.cjs');
|
|
18
|
+
var hasPaymasterServiceCapability = require('../utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.cjs');
|
|
16
19
|
var findEvmNetwork = require('../utils/findEvmNetwork/findEvmNetwork.cjs');
|
|
17
20
|
var getNameservice = require('../utils/getNameservice/getNameservice.cjs');
|
|
18
21
|
var EthereumWallet = require('../wallet/EthereumWallet.cjs');
|
|
@@ -307,6 +310,36 @@ class EthereumWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
307
310
|
getEnabledNetworks() {
|
|
308
311
|
return this.evmNetworks;
|
|
309
312
|
}
|
|
313
|
+
isAtomicSupported(chainId) {
|
|
314
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
const walletClient = yield this.getWalletClient();
|
|
316
|
+
if (!walletClient) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const capabilities = yield experimental.getCapabilities(walletClient);
|
|
320
|
+
const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
|
|
321
|
+
walletConnectorCore.logger.debug('[EthereumWalletConnector] isAtomicSupported', {
|
|
322
|
+
capabilities,
|
|
323
|
+
chainId: chainIdToCheck,
|
|
324
|
+
});
|
|
325
|
+
return hasAtomicStatusCapability.hasAtomicStatusCapability(capabilities, chainIdToCheck);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
isPaymasterServiceSupported(chainId) {
|
|
329
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
const walletClient = yield this.getWalletClient();
|
|
331
|
+
if (!walletClient) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
const capabilities = yield experimental.getCapabilities(walletClient);
|
|
335
|
+
const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
|
|
336
|
+
walletConnectorCore.logger.debug('[EthereumWalletConnector] isPaymasterServiceSupported', {
|
|
337
|
+
capabilities,
|
|
338
|
+
chainId: chainIdToCheck,
|
|
339
|
+
});
|
|
340
|
+
return hasPaymasterServiceCapability.hasPaymasterServiceCapability(capabilities, chainIdToCheck);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
310
343
|
}
|
|
311
344
|
|
|
312
345
|
exports.EthereumWalletConnector = EthereumWalletConnector;
|
|
@@ -60,7 +60,7 @@ export declare abstract class EthereumWalletConnector extends WalletConnectorBas
|
|
|
60
60
|
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
61
61
|
getChainId: () => Promise<number>;
|
|
62
62
|
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
63
|
-
prepareAuthorization: (parameters: import("
|
|
63
|
+
prepareAuthorization: (parameters: import("viem/experimental").PrepareAuthorizationParameters<Account>) => Promise<import("viem/experimental").PrepareAuthorizationReturnType>;
|
|
64
64
|
prepareTransactionRequest: <const request extends import("viem").PrepareTransactionRequestRequest<ViemChain, chainOverride_1>, chainOverride_1 extends ViemChain | undefined = undefined, accountOverride extends `0x${string}` | Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<ViemChain, Account, chainOverride_1, accountOverride, request>) => Promise<import("viem").UnionRequiredBy<Extract<import("viem").UnionOmit<import("viem").ExtractChainFormatterParameters<import("viem").DeriveChain<ViemChain, chainOverride_1>, "transactionRequest", import("viem").TransactionRequest>, "from"> & (import("viem").DeriveChain<ViemChain, chainOverride_1> extends infer T_14 ? T_14 extends import("viem").DeriveChain<ViemChain, chainOverride_1> ? T_14 extends ViemChain ? {
|
|
65
65
|
chain: T_14;
|
|
66
66
|
} : {
|
|
@@ -6573,7 +6573,7 @@ export declare abstract class EthereumWalletConnector extends WalletConnectorBas
|
|
|
6573
6573
|
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
6574
6574
|
sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
6575
6575
|
sendTransaction: <const request_1 extends import("viem").SendTransactionRequest<ViemChain, chainOverride_2>, chainOverride_2 extends ViemChain | undefined = undefined>(args: import("viem").SendTransactionParameters<ViemChain, Account, chainOverride_2, request_1>) => Promise<`0x${string}`>;
|
|
6576
|
-
signAuthorization: (parameters: import("
|
|
6576
|
+
signAuthorization: (parameters: import("viem/experimental").SignAuthorizationParameters<Account>) => Promise<import("viem/experimental").SignAuthorizationReturnType>;
|
|
6577
6577
|
signMessage: (args: import("viem").SignMessageParameters<Account>) => Promise<`0x${string}`>;
|
|
6578
6578
|
signTransaction: <chainOverride_3 extends ViemChain | undefined, const request_2 extends import("viem").UnionOmit<import("viem").ExtractChainFormatterParameters<import("viem").DeriveChain<ViemChain, chainOverride_3>, "transactionRequest", import("viem").TransactionRequest>, "from"> = import("viem").UnionOmit<import("viem").ExtractChainFormatterParameters<import("viem").DeriveChain<ViemChain, chainOverride_3>, "transactionRequest", import("viem").TransactionRequest>, "from">>(args: import("viem").SignTransactionParameters<ViemChain, Account, chainOverride_3, request_2>) => Promise<import("viem").TransactionSerialized<import("viem").GetTransactionType<request_2, (request_2 extends {
|
|
6579
6579
|
accessList?: undefined;
|
|
@@ -7716,5 +7716,7 @@ export declare abstract class EthereumWalletConnector extends WalletConnectorBas
|
|
|
7716
7716
|
confirmTransactionStatus(txHash: string): Promise<TransactionReceipt>;
|
|
7717
7717
|
getBlockExplorerUrlsForCurrentNetwork(): Promise<string[]>;
|
|
7718
7718
|
getEnabledNetworks(): GenericNetwork[];
|
|
7719
|
+
isAtomicSupported(chainId?: number): Promise<boolean>;
|
|
7720
|
+
isPaymasterServiceSupported(chainId?: number): Promise<boolean>;
|
|
7719
7721
|
}
|
|
7720
7722
|
export {};
|
|
@@ -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,6 +10,8 @@ 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';
|
|
13
|
+
import { hasAtomicStatusCapability } from '../utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js';
|
|
14
|
+
import { hasPaymasterServiceCapability } from '../utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js';
|
|
12
15
|
import { findEvmNetwork } from '../utils/findEvmNetwork/findEvmNetwork.js';
|
|
13
16
|
import { getNameservice } from '../utils/getNameservice/getNameservice.js';
|
|
14
17
|
import { EthereumWallet } from '../wallet/EthereumWallet.js';
|
|
@@ -303,6 +306,36 @@ class EthereumWalletConnector extends WalletConnectorBase {
|
|
|
303
306
|
getEnabledNetworks() {
|
|
304
307
|
return this.evmNetworks;
|
|
305
308
|
}
|
|
309
|
+
isAtomicSupported(chainId) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
311
|
+
const walletClient = yield this.getWalletClient();
|
|
312
|
+
if (!walletClient) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
const capabilities = yield getCapabilities(walletClient);
|
|
316
|
+
const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
|
|
317
|
+
logger.debug('[EthereumWalletConnector] isAtomicSupported', {
|
|
318
|
+
capabilities,
|
|
319
|
+
chainId: chainIdToCheck,
|
|
320
|
+
});
|
|
321
|
+
return hasAtomicStatusCapability(capabilities, chainIdToCheck);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
isPaymasterServiceSupported(chainId) {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
326
|
+
const walletClient = yield this.getWalletClient();
|
|
327
|
+
if (!walletClient) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
const capabilities = yield getCapabilities(walletClient);
|
|
331
|
+
const chainIdToCheck = chainId !== null && chainId !== void 0 ? chainId : (yield walletClient.getChainId());
|
|
332
|
+
logger.debug('[EthereumWalletConnector] isPaymasterServiceSupported', {
|
|
333
|
+
capabilities,
|
|
334
|
+
chainId: chainIdToCheck,
|
|
335
|
+
});
|
|
336
|
+
return hasPaymasterServiceCapability(capabilities, chainIdToCheck);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
306
339
|
}
|
|
307
340
|
|
|
308
341
|
export { EthereumWalletConnector };
|
package/src/index.cjs
CHANGED
|
@@ -19,6 +19,8 @@ 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 hasAtomicStatusCapability = require('./utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.cjs');
|
|
23
|
+
var hasPaymasterServiceCapability = require('./utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.cjs');
|
|
22
24
|
var unFormatTransaction = require('./utils/viem/unFormatTransaction/unFormatTransaction.cjs');
|
|
23
25
|
var abi = require('./utils/viem/erc20/abi.cjs');
|
|
24
26
|
var interceptTransport = require('./utils/viem/interceptTransport/interceptTransport.cjs');
|
|
@@ -45,6 +47,8 @@ exports.createWalletClientWithUiConfirmation = createWalletClientWithUiConfirmat
|
|
|
45
47
|
exports.getChain = getOrMapViemChain.getChain;
|
|
46
48
|
exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
|
|
47
49
|
exports.mapChain = getOrMapViemChain.mapChain;
|
|
50
|
+
exports.hasAtomicStatusCapability = hasAtomicStatusCapability.hasAtomicStatusCapability;
|
|
51
|
+
exports.hasPaymasterServiceCapability = hasPaymasterServiceCapability.hasPaymasterServiceCapability;
|
|
48
52
|
exports.unFormatTransaction = unFormatTransaction.unFormatTransaction;
|
|
49
53
|
exports.erc20Abi = abi.erc20Abi;
|
|
50
54
|
exports.interceptTransport = interceptTransport.interceptTransport;
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,8 @@ 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 { hasAtomicStatusCapability } from './utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js';
|
|
19
|
+
export { hasPaymasterServiceCapability } from './utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js';
|
|
18
20
|
export { unFormatTransaction } from './utils/viem/unFormatTransaction/unFormatTransaction.js';
|
|
19
21
|
export { erc20Abi } from './utils/viem/erc20/abi.js';
|
|
20
22
|
export { interceptTransport } from './utils/viem/interceptTransport/interceptTransport.js';
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var logger = require('../../logger.cjs');
|
|
7
|
+
|
|
8
|
+
const hasAtomicStatusCapability = (capabilities, chainId) => {
|
|
9
|
+
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const chainCapabilities = capabilities[chainId];
|
|
13
|
+
const hasAtomicStatus = Boolean(chainCapabilities['atomic'] &&
|
|
14
|
+
(chainCapabilities['atomic'].status === 'ready' ||
|
|
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;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.hasAtomicStatusCapability = hasAtomicStatusCapability;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { logger } from '../../logger.js';
|
|
3
|
+
|
|
4
|
+
const hasAtomicStatusCapability = (capabilities, chainId) => {
|
|
5
|
+
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const chainCapabilities = capabilities[chainId];
|
|
9
|
+
const hasAtomicStatus = Boolean(chainCapabilities['atomic'] &&
|
|
10
|
+
(chainCapabilities['atomic'].status === 'ready' ||
|
|
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;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { hasAtomicStatusCapability };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hasAtomicStatusCapability } from './hasAtomicStatusCapability';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const hasPaymasterServiceCapability = (capabilities, chainId) => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const chainCapabilities = capabilities[chainId];
|
|
12
|
+
return Boolean((_a = chainCapabilities['paymasterService']) === null || _a === void 0 ? void 0 : _a.supported);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.hasPaymasterServiceCapability = hasPaymasterServiceCapability;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const hasPaymasterServiceCapability = (capabilities, chainId) => {
|
|
3
|
+
var _a;
|
|
4
|
+
if (!(capabilities === null || capabilities === void 0 ? void 0 : capabilities[chainId])) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const chainCapabilities = capabilities[chainId];
|
|
8
|
+
return Boolean((_a = chainCapabilities['paymasterService']) === null || _a === void 0 ? void 0 : _a.supported);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { hasPaymasterServiceCapability };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hasPaymasterServiceCapability } from './hasPaymasterServiceCapability';
|
|
@@ -6,6 +6,8 @@ export * from './createTransportWithUiConfirmation';
|
|
|
6
6
|
export * from './createViemUiTransaction';
|
|
7
7
|
export * from './createWalletClientWithUiConfirmation';
|
|
8
8
|
export * from './getOrMapViemChain';
|
|
9
|
+
export * from './hasAtomicStatusCapability';
|
|
10
|
+
export * from './hasPaymasterServiceCapability';
|
|
9
11
|
export * from './unFormatTransaction';
|
|
10
12
|
export * from './erc20';
|
|
11
13
|
export * from './interceptTransport';
|
|
@@ -5,9 +5,10 @@ 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');
|
|
@@ -109,6 +110,54 @@ class EthereumWallet extends walletConnectorCore.Wallet {
|
|
|
109
110
|
getTransportConfig() {
|
|
110
111
|
return this._connector.providersConfig.httpTransportConfig;
|
|
111
112
|
}
|
|
113
|
+
isPaymasterServiceSupported(chainId) {
|
|
114
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return this._connector.isPaymasterServiceSupported(chainId);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
isAtomicSupported(chainId) {
|
|
119
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return this._connector.isAtomicSupported(chainId);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
sendCalls(callParams, options) {
|
|
124
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
var _a;
|
|
126
|
+
const chainId = (_a = callParams.chain) === null || _a === void 0 ? void 0 : _a.id;
|
|
127
|
+
const walletClient = yield this.getWalletClient(chainId === null || chainId === void 0 ? void 0 : chainId.toString());
|
|
128
|
+
const atomicStatusSupported = yield this.isAtomicSupported(chainId);
|
|
129
|
+
if (!atomicStatusSupported) {
|
|
130
|
+
logger.logger.debug('[EthereumWallet] atomic is not supported wallet or chain', {
|
|
131
|
+
chainId,
|
|
132
|
+
wallet: {
|
|
133
|
+
address: this.address,
|
|
134
|
+
key: this.key,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
throw new Error('Atomic is not supported for this wallet and chain');
|
|
138
|
+
}
|
|
139
|
+
const paymasterServiceSupported = yield this.isPaymasterServiceSupported(chainId);
|
|
140
|
+
if (paymasterServiceSupported && (options === null || options === void 0 ? void 0 : options.paymasterURL)) {
|
|
141
|
+
callParams.capabilities = {
|
|
142
|
+
paymasterService: {
|
|
143
|
+
url: options === null || options === void 0 ? void 0 : options.paymasterURL,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
logger.logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
|
|
148
|
+
atomicStatusSupported,
|
|
149
|
+
callOptions: options,
|
|
150
|
+
callParams,
|
|
151
|
+
chainId,
|
|
152
|
+
paymasterServiceSupported,
|
|
153
|
+
});
|
|
154
|
+
const result = yield experimental.sendCalls(walletClient, callParams);
|
|
155
|
+
logger.logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
|
|
156
|
+
result,
|
|
157
|
+
});
|
|
158
|
+
return result;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
112
161
|
}
|
|
113
162
|
|
|
114
163
|
exports.EthereumWallet = EthereumWallet;
|
|
@@ -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,4 +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;
|
|
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>;
|
|
37
43
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
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';
|
|
@@ -105,6 +106,54 @@ class EthereumWallet extends Wallet {
|
|
|
105
106
|
getTransportConfig() {
|
|
106
107
|
return this._connector.providersConfig.httpTransportConfig;
|
|
107
108
|
}
|
|
109
|
+
isPaymasterServiceSupported(chainId) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
return this._connector.isPaymasterServiceSupported(chainId);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
isAtomicSupported(chainId) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return this._connector.isAtomicSupported(chainId);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
sendCalls(callParams, options) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
var _a;
|
|
122
|
+
const chainId = (_a = callParams.chain) === null || _a === void 0 ? void 0 : _a.id;
|
|
123
|
+
const walletClient = yield this.getWalletClient(chainId === null || chainId === void 0 ? void 0 : chainId.toString());
|
|
124
|
+
const atomicStatusSupported = yield this.isAtomicSupported(chainId);
|
|
125
|
+
if (!atomicStatusSupported) {
|
|
126
|
+
logger.debug('[EthereumWallet] atomic is not supported wallet or chain', {
|
|
127
|
+
chainId,
|
|
128
|
+
wallet: {
|
|
129
|
+
address: this.address,
|
|
130
|
+
key: this.key,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
throw new Error('Atomic is not supported for this wallet and chain');
|
|
134
|
+
}
|
|
135
|
+
const paymasterServiceSupported = yield this.isPaymasterServiceSupported(chainId);
|
|
136
|
+
if (paymasterServiceSupported && (options === null || options === void 0 ? void 0 : options.paymasterURL)) {
|
|
137
|
+
callParams.capabilities = {
|
|
138
|
+
paymasterService: {
|
|
139
|
+
url: options === null || options === void 0 ? void 0 : options.paymasterURL,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
|
|
144
|
+
atomicStatusSupported,
|
|
145
|
+
callOptions: options,
|
|
146
|
+
callParams,
|
|
147
|
+
chainId,
|
|
148
|
+
paymasterServiceSupported,
|
|
149
|
+
});
|
|
150
|
+
const result = yield sendCalls(walletClient, callParams);
|
|
151
|
+
logger.logVerboseTroubleshootingMessage('[EthereumWallet] sendCalls', {
|
|
152
|
+
result,
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
108
157
|
}
|
|
109
158
|
|
|
110
159
|
export { EthereumWallet };
|