@aa-sdk/core 4.0.0-alpha.0 → 4.0.0-alpha.2
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/dist/cjs/account/simple.js.map +1 -1
- package/dist/cjs/account/smartContractAccount.js +2 -1
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/cjs/client/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/smartAccountClient.js.map +1 -1
- package/dist/cjs/ens/utils.d.ts +1 -1
- package/dist/cjs/ens/utils.js +3 -3
- package/dist/cjs/ens/utils.js.map +1 -1
- package/dist/cjs/entrypoint/index.js.map +1 -1
- package/dist/cjs/errors/account.js.map +1 -1
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/client.js.map +1 -1
- package/dist/cjs/errors/entrypoint.js.map +1 -1
- package/dist/cjs/errors/signer.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js +35 -60
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.js +17 -15
- package/dist/cjs/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/cjs/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/cjs/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/cjs/signer/local-account.d.ts +2 -2
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/schema.js.map +1 -1
- package/dist/cjs/signer/utils.d.ts +1 -9
- package/dist/cjs/signer/utils.js +1 -16
- package/dist/cjs/signer/utils.js.map +1 -1
- package/dist/cjs/signer/wallet-client.d.ts +2 -2
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/utils/defaults.d.ts +1 -1
- package/dist/cjs/utils/defaults.js +25 -25
- package/dist/cjs/utils/defaults.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -4
- package/dist/cjs/utils/index.js +1 -33
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/account/simple.js.map +1 -1
- package/dist/esm/account/smartContractAccount.js +2 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/ens/utils.d.ts +1 -1
- package/dist/esm/ens/utils.js +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/index.d.ts +2 -3
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.js +17 -15
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +2 -2
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.js.map +1 -1
- package/dist/esm/signer/utils.d.ts +1 -9
- package/dist/esm/signer/utils.js +0 -14
- package/dist/esm/signer/utils.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +2 -2
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/utils/defaults.d.ts +1 -1
- package/dist/esm/utils/defaults.js +2 -2
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -4
- package/dist/esm/utils/index.js +0 -18
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +49 -0
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts +23 -0
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts +24 -0
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransactions.d.ts +23 -0
- package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +15 -0
- package/dist/types/client/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/bundlerClient.d.ts +9 -0
- package/dist/types/client/decorators/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts +8 -0
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts +46 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/entrypoint/index.d.ts +14 -0
- package/dist/types/entrypoint/index.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +34 -0
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +5 -0
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +9 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +6 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +3 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +6 -0
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +3 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts +21 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/defaults/paymasterAndData.d.ts +8 -0
- package/dist/types/middleware/defaults/paymasterAndData.d.ts.map +1 -1
- package/dist/types/middleware/defaults/userOpSigner.d.ts +10 -0
- package/dist/types/middleware/defaults/userOpSigner.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +5 -2
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/schema.d.ts +14 -0
- package/dist/types/signer/schema.d.ts.map +1 -1
- package/dist/types/signer/utils.d.ts +21 -9
- package/dist/types/signer/utils.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +5 -2
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/utils/defaults.d.ts +1 -1
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +54 -11
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/account/simple.ts +6 -0
- package/src/account/smartContractAccount.ts +120 -15
- package/src/actions/smartAccount/buildUserOperation.ts +23 -0
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +22 -0
- package/src/actions/smartAccount/sendTransaction.ts +24 -0
- package/src/actions/smartAccount/sendTransactions.ts +23 -0
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +24 -0
- package/src/client/bundlerClient.ts +32 -0
- package/src/client/decorators/bundlerClient.ts +9 -0
- package/src/client/decorators/smartAccountClient.ts +8 -0
- package/src/client/smartAccountClient.ts +41 -0
- package/src/ens/utils.ts +46 -2
- package/src/entrypoint/index.ts +30 -62
- package/src/errors/account.ts +34 -0
- package/src/errors/base.ts +5 -2
- package/src/errors/client.ts +9 -0
- package/src/errors/entrypoint.ts +6 -0
- package/src/errors/signer.ts +3 -0
- package/src/errors/transaction.ts +6 -0
- package/src/index.ts +1 -28
- package/src/logger.ts +3 -0
- package/src/middleware/defaults/feeEstimator.ts +24 -4
- package/src/middleware/defaults/paymasterAndData.ts +8 -0
- package/src/middleware/defaults/userOpSigner.ts +10 -0
- package/src/signer/local-account.ts +3 -0
- package/src/signer/schema.ts +14 -0
- package/src/signer/utils.ts +20 -32
- package/src/signer/wallet-client.ts +3 -0
- package/src/utils/defaults.ts +3 -4
- package/src/utils/index.ts +54 -36
- package/src/version.ts +1 -1
- package/dist/cjs/chains/index.d.ts +0 -20
- package/dist/cjs/chains/index.js +0 -169
- package/dist/cjs/chains/index.js.map +0 -1
- package/dist/esm/chains/index.d.ts +0 -20
- package/dist/esm/chains/index.js +0 -166
- package/dist/esm/chains/index.js.map +0 -1
- package/dist/types/chains/index.d.ts +0 -21
- package/dist/types/chains/index.d.ts.map +0 -1
- package/src/chains/index.ts +0 -194
|
@@ -135,6 +135,26 @@ export function createSmartAccountClient<
|
|
|
135
135
|
config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>
|
|
136
136
|
): SmartAccountClient<TTransport, TChain, TAccount>;
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { createSmartAccountClient, toSmartContractAccount } from "@aa-sdk/core";
|
|
144
|
+
* import { http } from "viem";
|
|
145
|
+
* import { sepolia } from "viem/chains";
|
|
146
|
+
*
|
|
147
|
+
* const client = createSmartAccountClient({
|
|
148
|
+
* chain: sepolia,
|
|
149
|
+
* transport: http("RPC_URL"),
|
|
150
|
+
* // optionally hoist the account
|
|
151
|
+
* account: toSmartContractAccount(...),
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @param {SmartAccountClientConfig} config The configuration for creating the smart account client
|
|
156
|
+
* @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account
|
|
157
|
+
*/
|
|
138
158
|
export function createSmartAccountClient(
|
|
139
159
|
config: SmartAccountClientConfig
|
|
140
160
|
): SmartAccountClient {
|
|
@@ -263,6 +283,27 @@ export function createSmartAccountClientFromExisting<
|
|
|
263
283
|
TContext
|
|
264
284
|
>;
|
|
265
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* import {
|
|
292
|
+
* createBundlerClient,
|
|
293
|
+
* createSmartAccountClientFromExisting,
|
|
294
|
+
* toSmartContractAccount
|
|
295
|
+
* } from "@aa-sdk/core";
|
|
296
|
+
*
|
|
297
|
+
* const bundlerClient = createBundlerClient(...);
|
|
298
|
+
* const client = createSmartAccountClientFromExisting({
|
|
299
|
+
* client,
|
|
300
|
+
* account: toSmartContractAccount(...),
|
|
301
|
+
* })
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @param {Omit<SmartAccountClientConfig, "transport" | "chain"> & {client: BundlerClient}} config the configuration object which includes the client
|
|
305
|
+
* @returns {SmartAccountClient} A smart account client created from the existing BundlerClient
|
|
306
|
+
*/
|
|
266
307
|
export function createSmartAccountClientFromExisting(
|
|
267
308
|
config: Omit<SmartAccountClientConfig, "transport" | "chain"> & {
|
|
268
309
|
client: BundlerClient;
|
package/src/ens/utils.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import type { Chain } from "viem/chains";
|
|
2
1
|
import * as chains from "viem/chains";
|
|
3
|
-
import { mainnet } from "
|
|
2
|
+
import { mainnet, type Chain } from "viem/chains";
|
|
4
3
|
|
|
5
4
|
export const ChainsById: Map<number, chains.Chain> = new Map(
|
|
6
5
|
Object.values(chains).map((x) => [x.id, x])
|
|
7
6
|
);
|
|
8
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Converts a given chain ID to a coin type, following specific standards for mainnet and non-mainnet chains.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { convertChainIdToCoinType } from "@aa-sdk/core";
|
|
14
|
+
* import { sepolia } from "viem/chains";
|
|
15
|
+
*
|
|
16
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {number} chainId the blockchain chain ID that you want to convert to a coin type
|
|
20
|
+
* @returns {number} the corresponding coin type for the given chain ID
|
|
21
|
+
*/
|
|
9
22
|
export const convertChainIdToCoinType = (chainId: number): number => {
|
|
10
23
|
if (chainId === mainnet.id) {
|
|
11
24
|
// this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)
|
|
@@ -16,6 +29,21 @@ export const convertChainIdToCoinType = (chainId: number): number => {
|
|
|
16
29
|
return (0x80000000 | chainId) >>> 0;
|
|
17
30
|
};
|
|
18
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Converts a coin type to a chain ID based on predefined mappings. This function follows ENSIP-9 for coin type 60 and ENSIP-11 for other coin types.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { convertChainIdToCoinType, convertCoinTypeToChainId } from "@aa-sdk/core";
|
|
38
|
+
* import { sepolia } from "viem/chains";
|
|
39
|
+
*
|
|
40
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
41
|
+
* const chainId = convertCoinTypeToChainId(coinType);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param {number} coinType the coin type to be converted to a chain ID
|
|
45
|
+
* @returns {number} the corresponding chain ID
|
|
46
|
+
*/
|
|
19
47
|
export const convertCoinTypeToChainId = (coinType: number): number => {
|
|
20
48
|
if (coinType === 60) {
|
|
21
49
|
// this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)
|
|
@@ -26,6 +54,22 @@ export const convertCoinTypeToChainId = (coinType: number): number => {
|
|
|
26
54
|
return (0x7fffffff & coinType) >> 0;
|
|
27
55
|
};
|
|
28
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Converts a coin type to its corresponding blockchain chain based on a predefined mapping.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { convertChainIdToCoinType, convertCoinTypeToChain } from "@aa-sdk/core";
|
|
63
|
+
* import { sepolia } from "viem/chains";
|
|
64
|
+
*
|
|
65
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
66
|
+
* const chain = convertCoinTypeToChain(coinType);
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {number} coinType The numerical identifier for the coin type
|
|
70
|
+
* @returns {Chain} The corresponding blockchain chain
|
|
71
|
+
* @throws {Error} If the coin type does not map to a supported chain
|
|
72
|
+
*/
|
|
29
73
|
export const convertCoinTypeToChain = (coinType: number): Chain => {
|
|
30
74
|
const chainId = convertCoinTypeToChainId(coinType);
|
|
31
75
|
const chain = ChainsById.get(chainId);
|
package/src/entrypoint/index.ts
CHANGED
|
@@ -17,6 +17,20 @@ export const entryPointRegistry: EntryPointRegistry = {
|
|
|
17
17
|
"0.7.0": EntryPoint_v7,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the given value is a valid key of the EntryPointRegistry.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { isEntryPointVersion } from "@aa-sdk/core";
|
|
26
|
+
*
|
|
27
|
+
* const valid = isEntryPointVersion("0.6.0");
|
|
28
|
+
* const invalid = isEntryPointVersion("0.8.0");
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {*} value The value to be checked
|
|
32
|
+
* @returns {boolean} true if the value is a valid key of EntryPointRegistry, false otherwise
|
|
33
|
+
*/
|
|
20
34
|
export const isEntryPointVersion = (
|
|
21
35
|
value: any
|
|
22
36
|
): value is keyof EntryPointRegistry => {
|
|
@@ -44,6 +58,22 @@ export function getEntryPoint<TChain extends Chain = Chain>(
|
|
|
44
58
|
options?: GetEntryPointOptions<DefaultEntryPointVersion>
|
|
45
59
|
): EntryPointDefRegistry<TChain>[DefaultEntryPointVersion];
|
|
46
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the entry point definition for the specified chain and version, falling back to the default version if not provided. Throws an error if the entry point address cannot be found.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { getEntryPoint } from "@aa-sdk/core";
|
|
67
|
+
* import { sepolia } from "viem/chains";
|
|
68
|
+
*
|
|
69
|
+
* const entryPoint060 = getEntryPoint(sepolia);
|
|
70
|
+
* const entryPoint070 = getEntryPoint(sepolia, { version: "0.7.0" });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param {Chain} chain The chain for which the entry point is being retrieved
|
|
74
|
+
* @param {GetEntryPointOptions<TEntryPointVersion>} options Options containing the version and address overrides for the entry point
|
|
75
|
+
* @returns {EntryPointDefRegistry<TChain>[EntryPointVersion]} The entry point definition for the specified chain and version
|
|
76
|
+
*/
|
|
47
77
|
export function getEntryPoint<
|
|
48
78
|
TEntryPointVersion extends EntryPointVersion,
|
|
49
79
|
TChain extends Chain = Chain
|
|
@@ -88,65 +118,3 @@ export function getEntryPoint<
|
|
|
88
118
|
|
|
89
119
|
throw new EntryPointNotFoundError(chain, version);
|
|
90
120
|
}
|
|
91
|
-
|
|
92
|
-
// // =================================================================================
|
|
93
|
-
// // TODO: Add tests for the following cases
|
|
94
|
-
|
|
95
|
-
// const chain: Chain = mainnet;
|
|
96
|
-
|
|
97
|
-
// // 1. left and right hand side version type should match, as well as the param
|
|
98
|
-
|
|
99
|
-
// // === Error ===
|
|
100
|
-
// const ep1_a: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
101
|
-
// version: "0.7.0",
|
|
102
|
-
// }); // error
|
|
103
|
-
// const ep1_b: EntryPointDef<"0.7.0"> = getEntryPoint(chain); // error
|
|
104
|
-
// const ep1_c: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
105
|
-
// version: "0.7.0",
|
|
106
|
-
// }); // error
|
|
107
|
-
// const ep1_d: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
108
|
-
// version: "0.7.0",
|
|
109
|
-
// }); // error
|
|
110
|
-
|
|
111
|
-
// // === Valid ===
|
|
112
|
-
// const ep1a: EntryPointDef<"0.6.0"> = getEntryPoint(chain);
|
|
113
|
-
// const ep1b: EntryPointDef<"0.6.0"> = getEntryPoint(chain, { version: "0.6.0" });
|
|
114
|
-
// const ep1c: EntryPointDef<"0.7.0"> = getEntryPoint(chain, { version: "0.7.0" });
|
|
115
|
-
// const ep1d: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
116
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
117
|
-
// });
|
|
118
|
-
// const ep1e: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
119
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
120
|
-
// version: "0.6.0",
|
|
121
|
-
// });
|
|
122
|
-
// const ep1f: EntryPointDef<"0.7.0"> = getEntryPoint(chain, {
|
|
123
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
124
|
-
// version: "0.7.0",
|
|
125
|
-
// });
|
|
126
|
-
|
|
127
|
-
// // 2. If non-default type is specified, version option param of the type is required
|
|
128
|
-
|
|
129
|
-
// // === Error ===
|
|
130
|
-
// const ep2_a: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain); // error
|
|
131
|
-
// const ep2_b: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
132
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
133
|
-
// });
|
|
134
|
-
|
|
135
|
-
// // === Valid ===
|
|
136
|
-
// const ep2a: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
137
|
-
// version: "0.7.0",
|
|
138
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
139
|
-
// });
|
|
140
|
-
// const ep2b: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
141
|
-
// version: "0.6.0",
|
|
142
|
-
// });
|
|
143
|
-
// const ep2c: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain);
|
|
144
|
-
// const ep2d: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
145
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
146
|
-
// });
|
|
147
|
-
// const ep2e: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
148
|
-
// version: "0.7.0",
|
|
149
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
150
|
-
// });
|
|
151
|
-
|
|
152
|
-
// // =================================================================================
|
package/src/errors/account.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { Chain } from "viem";
|
|
|
2
2
|
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
3
3
|
import { BaseError } from "./base.js";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This error is thrown when an account could not be found to execute a specific action. It extends the `BaseError` class.
|
|
7
|
+
*/
|
|
5
8
|
export class AccountNotFoundError extends BaseError {
|
|
6
9
|
override name = "AccountNotFoundError";
|
|
7
10
|
|
|
@@ -11,6 +14,10 @@ export class AccountNotFoundError extends BaseError {
|
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Represents an error that is thrown when no default factory is defined for a specific account type on a given chain and entry point version.
|
|
19
|
+
* This error suggests providing an override via the `factoryAddress` parameter when creating an account.
|
|
20
|
+
*/
|
|
14
21
|
export class DefaultFactoryNotDefinedError extends BaseError {
|
|
15
22
|
override name = "DefaultFactoryNotDefinedError";
|
|
16
23
|
constructor(accountType: string, chain: Chain, version: EntryPointVersion) {
|
|
@@ -23,6 +30,9 @@ export class DefaultFactoryNotDefinedError extends BaseError {
|
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Custom error class for handling errors when getting a counterfactual address. This extends the `BaseError` class and provides a custom error message and name.
|
|
35
|
+
*/
|
|
26
36
|
export class GetCounterFactualAddressError extends BaseError {
|
|
27
37
|
override name = "GetCounterFactualAddressError";
|
|
28
38
|
constructor() {
|
|
@@ -30,6 +40,9 @@ export class GetCounterFactualAddressError extends BaseError {
|
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
|
|
43
|
+
/**
|
|
44
|
+
* An error class representing the condition where upgrades are not supported for a specific account type. This error extends the `BaseError` class and provides a custom error message based on the account type.
|
|
45
|
+
*/
|
|
33
46
|
export class UpgradesNotSupportedError extends BaseError {
|
|
34
47
|
override name = "UpgradesNotSupported";
|
|
35
48
|
constructor(accountType: string) {
|
|
@@ -37,6 +50,9 @@ export class UpgradesNotSupportedError extends BaseError {
|
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Error thrown when attempting to sign a transaction that is not supported by smart contracts.
|
|
55
|
+
*/
|
|
40
56
|
export class SignTransactionNotSupportedError extends BaseError {
|
|
41
57
|
override name = "SignTransactionNotSupported";
|
|
42
58
|
constructor() {
|
|
@@ -44,6 +60,9 @@ export class SignTransactionNotSupportedError extends BaseError {
|
|
|
44
60
|
}
|
|
45
61
|
}
|
|
46
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Custom error class `FailedToGetStorageSlotError` which is used to signal a failure when attempting to retrieve a storage slot. This error includes the slot and slot descriptor in its message and inherits from `BaseError`.
|
|
65
|
+
*/
|
|
47
66
|
export class FailedToGetStorageSlotError extends BaseError {
|
|
48
67
|
override name = "FailedToGetStorageSlotError";
|
|
49
68
|
constructor(slot: string, slotDescriptor: string) {
|
|
@@ -51,6 +70,9 @@ export class FailedToGetStorageSlotError extends BaseError {
|
|
|
51
70
|
}
|
|
52
71
|
}
|
|
53
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Represents an error indicating that batch execution is not supported for a specific account type.
|
|
75
|
+
*/
|
|
54
76
|
export class BatchExecutionNotSupportedError extends BaseError {
|
|
55
77
|
override name = "BatchExecutionNotSupportedError";
|
|
56
78
|
constructor(accountType: string) {
|
|
@@ -58,6 +80,9 @@ export class BatchExecutionNotSupportedError extends BaseError {
|
|
|
58
80
|
}
|
|
59
81
|
}
|
|
60
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Represents an error that occurs when an account requires an owner to execute but none is provided.
|
|
85
|
+
*/
|
|
61
86
|
export class AccountRequiresOwnerError extends BaseError {
|
|
62
87
|
override name = "AccountRequiresOwnerError";
|
|
63
88
|
constructor(accountType: string) {
|
|
@@ -65,6 +90,9 @@ export class AccountRequiresOwnerError extends BaseError {
|
|
|
65
90
|
}
|
|
66
91
|
}
|
|
67
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Represents an error that occurs when an attempt is made to call `UpgradeToAndCall` on an account type that does not support it. Includes the account type in the error message.
|
|
95
|
+
*/
|
|
68
96
|
export class UpgradeToAndCallNotSupportedError extends BaseError {
|
|
69
97
|
override name = "UpgradeToAndCallNotSupportedError";
|
|
70
98
|
constructor(accountType: string) {
|
|
@@ -72,6 +100,9 @@ export class UpgradeToAndCallNotSupportedError extends BaseError {
|
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Represents an error thrown when an account type does not match the expected type.
|
|
105
|
+
*/
|
|
75
106
|
export class IncorrectAccountType extends BaseError {
|
|
76
107
|
override name = "IncorrectAccountTypeError";
|
|
77
108
|
constructor(expected: string, actual: string) {
|
|
@@ -79,6 +110,9 @@ export class IncorrectAccountType extends BaseError {
|
|
|
79
110
|
}
|
|
80
111
|
}
|
|
81
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Error class indicating that a smart account operation requires a signer.
|
|
115
|
+
*/
|
|
82
116
|
export class SmartAccountWithSignerRequiredError extends BaseError {
|
|
83
117
|
override name = "SmartAccountWithSignerRequiredError";
|
|
84
118
|
constructor() {
|
package/src/errors/base.ts
CHANGED
|
@@ -16,8 +16,11 @@ type BaseErrorParameters = {
|
|
|
16
16
|
}
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* A custom error class that extends from `ViemBaseError`. This class allows for error messages to include links to relevant documentation based on provided `docsPath` and `docsSlug` parameters.
|
|
21
|
+
* This is based on on viem's BaseError type (obviously from the import and extend)
|
|
22
|
+
* we want the errors here to point to our docs if we supply a docsPath though
|
|
23
|
+
*/
|
|
21
24
|
export class BaseError extends ViemBaseError {
|
|
22
25
|
override name = "AASDKError";
|
|
23
26
|
override version = VERSION;
|
package/src/errors/client.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Client } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents an error thrown when a client is not compatible with the expected client type for a specific method. The error message provides guidance on how to create a compatible client.
|
|
6
|
+
*/
|
|
4
7
|
export class IncompatibleClientError extends BaseError {
|
|
5
8
|
override name = "IncompatibleClientError";
|
|
6
9
|
constructor(expectedClient: string, method: string, client: Client) {
|
|
@@ -13,6 +16,9 @@ export class IncompatibleClientError extends BaseError {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Represents an error that occurs when an invalid RPC URL is provided. This class extends the `BaseError` class and includes the invalid URL in the error message.
|
|
21
|
+
*/
|
|
16
22
|
export class InvalidRpcUrlError extends BaseError {
|
|
17
23
|
override name = "InvalidRpcUrlError";
|
|
18
24
|
constructor(rpcUrl?: string) {
|
|
@@ -20,6 +26,9 @@ export class InvalidRpcUrlError extends BaseError {
|
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Error class representing a "Chain Not Found" error, typically thrown when no chain is supplied to the client.
|
|
31
|
+
*/
|
|
23
32
|
export class ChainNotFoundError extends BaseError {
|
|
24
33
|
override name = "ChainNotFoundError";
|
|
25
34
|
constructor() {
|
package/src/errors/entrypoint.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Chain } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents an error thrown when an entry point is not found for a specific chain and entry point version. This error indicates that a default entry point does not exist for the given chain and version, and suggests providing an override.
|
|
6
|
+
*/
|
|
4
7
|
export class EntryPointNotFoundError extends BaseError {
|
|
5
8
|
override name = "EntryPointNotFoundError";
|
|
6
9
|
|
|
@@ -14,6 +17,9 @@ export class EntryPointNotFoundError extends BaseError {
|
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Represents an error thrown when an invalid entry point version is encountered for a specific chain. This error extends the `BaseError` class.
|
|
22
|
+
*/
|
|
17
23
|
export class InvalidEntryPointError extends BaseError {
|
|
18
24
|
override name = "InvalidEntryPointError";
|
|
19
25
|
|
package/src/errors/signer.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseError } from "./base.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Represents an error thrown when an invalid signer type is provided to the SmartAccountSigner.
|
|
5
|
+
*/
|
|
3
6
|
export class InvalidSignerTypeError extends BaseError {
|
|
4
7
|
override name = "InvalidSignerTypeError";
|
|
5
8
|
constructor(signerType?: string) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Hex } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a transaction is missing the `to` address parameter. This class extends the `BaseError` class.
|
|
6
|
+
*/
|
|
4
7
|
export class TransactionMissingToParamError extends BaseError {
|
|
5
8
|
override name = "TransactionMissingToParamError";
|
|
6
9
|
constructor() {
|
|
@@ -8,6 +11,9 @@ export class TransactionMissingToParamError extends BaseError {
|
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Represents an error that occurs when a transaction cannot be found for a given user operation. This error extends from `BaseError`. The `hash` of the transaction is provided to indicate which transaction could not be found.
|
|
16
|
+
*/
|
|
11
17
|
export class FailedToFindTransactionError extends BaseError {
|
|
12
18
|
override name = "FailedToFindTransactionError";
|
|
13
19
|
constructor(hash: Hex) {
|
package/src/index.ts
CHANGED
|
@@ -31,27 +31,6 @@ export { sendTransactions } from "./actions/smartAccount/sendTransactions.js";
|
|
|
31
31
|
export { sendUserOperation } from "./actions/smartAccount/sendUserOperation.js";
|
|
32
32
|
export type * from "./actions/smartAccount/types.js";
|
|
33
33
|
export { waitForUserOperationTransaction } from "./actions/smartAccount/waitForUserOperationTransacation.js";
|
|
34
|
-
export {
|
|
35
|
-
arbitrum,
|
|
36
|
-
arbitrumGoerli,
|
|
37
|
-
arbitrumSepolia,
|
|
38
|
-
base,
|
|
39
|
-
baseGoerli,
|
|
40
|
-
baseSepolia,
|
|
41
|
-
fraxtal,
|
|
42
|
-
fraxtalSepolia,
|
|
43
|
-
goerli,
|
|
44
|
-
mainnet,
|
|
45
|
-
optimism,
|
|
46
|
-
optimismGoerli,
|
|
47
|
-
optimismSepolia,
|
|
48
|
-
polygon,
|
|
49
|
-
polygonAmoy,
|
|
50
|
-
polygonMumbai,
|
|
51
|
-
sepolia,
|
|
52
|
-
zora,
|
|
53
|
-
zoraSepolia,
|
|
54
|
-
} from "./chains/index.js";
|
|
55
34
|
export type * from "./client/bundlerClient.js";
|
|
56
35
|
export {
|
|
57
36
|
createBundlerClient,
|
|
@@ -130,16 +109,12 @@ export type {
|
|
|
130
109
|
SmartAccountAuthenticator,
|
|
131
110
|
SmartAccountSigner,
|
|
132
111
|
} from "./signer/types.js";
|
|
133
|
-
export {
|
|
134
|
-
verifyEIP6492Signature,
|
|
135
|
-
wrapSignatureWith6492,
|
|
136
|
-
} from "./signer/utils.js";
|
|
112
|
+
export { wrapSignatureWith6492 } from "./signer/utils.js";
|
|
137
113
|
export { WalletClientSigner } from "./signer/wallet-client.js";
|
|
138
114
|
export { split, type SplitTransportParams } from "./transport/split.js";
|
|
139
115
|
export type * from "./types.js";
|
|
140
116
|
export type * from "./utils/index.js";
|
|
141
117
|
export {
|
|
142
|
-
AlchemyChainMap,
|
|
143
118
|
BigNumberishRangeSchema,
|
|
144
119
|
BigNumberishSchema,
|
|
145
120
|
ChainSchema,
|
|
@@ -156,9 +131,7 @@ export {
|
|
|
156
131
|
bypassPaymasterAndDataEmptyHex,
|
|
157
132
|
concatPaymasterAndData,
|
|
158
133
|
deepHexlify,
|
|
159
|
-
defineReadOnly,
|
|
160
134
|
filterUndefined,
|
|
161
|
-
getChain,
|
|
162
135
|
getDefaultSimpleAccountFactoryAddress,
|
|
163
136
|
getDefaultUserOperationFeeOptions,
|
|
164
137
|
isBigNumberish,
|
package/src/logger.ts
CHANGED
|
@@ -7,6 +7,9 @@ export enum LogLevel {
|
|
|
7
7
|
NONE = 0,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Logger class provides static methods for logging at different levels such as error, warn, debug, info, and verbose. This class allows setting log levels and log filters to control the logging behavior.
|
|
12
|
+
*/
|
|
10
13
|
export class Logger {
|
|
11
14
|
static logLevel: LogLevel = LogLevel.INFO;
|
|
12
15
|
static logFilter?: string;
|
|
@@ -3,11 +3,30 @@ import { applyUserOpOverrideOrFeeOption } from "../../utils/index.js";
|
|
|
3
3
|
import type { MiddlewareClient } from "../actions";
|
|
4
4
|
import type { ClientMiddlewareFn } from "../types";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Default fee estimator middleware function that estimates the maximum fee per gas and maximum priority fee per gas for a given client and applies the necessary overrides and fee options.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createSmartAccountClient, defaultFeeEstimator, createBundlerClient } from "@aa-sdk/core";
|
|
12
|
+
*
|
|
13
|
+
* const bundlerClient = createBundlerClient(...);
|
|
14
|
+
*
|
|
15
|
+
* // NOTE: this is already provided by the smart account client
|
|
16
|
+
* const client = createSmartAccountClient({
|
|
17
|
+
* feeEstimator: defaultFeeEstimator(bundlerClient),
|
|
18
|
+
* ...otherParams
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @template {MiddlewareClient} C The type of the client
|
|
23
|
+
* @param {C} client The client to perform the fee estimation
|
|
24
|
+
* @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees
|
|
25
|
+
*/
|
|
26
|
+
export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
7
27
|
client: C
|
|
8
|
-
)
|
|
9
|
-
(
|
|
10
|
-
async (struct, { overrides, feeOptions }) => {
|
|
28
|
+
): ClientMiddlewareFn {
|
|
29
|
+
return async (struct, { overrides, feeOptions }) => {
|
|
11
30
|
// maxFeePerGas must be at least the sum of maxPriorityFeePerGas and baseFee
|
|
12
31
|
// so we need to accommodate for the fee option applied maxPriorityFeePerGas for the maxFeePerGas
|
|
13
32
|
//
|
|
@@ -48,3 +67,4 @@ export const defaultFeeEstimator: <C extends MiddlewareClient>(
|
|
|
48
67
|
struct.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
49
68
|
return struct;
|
|
50
69
|
};
|
|
70
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { UserOperationStruct } from "../../types";
|
|
2
2
|
import type { ClientMiddlewareFn } from "../types";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Middleware function that sets the `paymasterAndData` field in the given struct based on the entry point version of the account.
|
|
6
|
+
* This is the default used by `createSmartAccountClient` and is not necessary to be used directly.
|
|
7
|
+
*
|
|
8
|
+
* @param {UserOperationStruct} struct the user operation structure to be modified
|
|
9
|
+
* @param {{ account: Account }} context an object containing the account information
|
|
10
|
+
* @returns {Promise<UserOperationStruct>} a promise that resolves to the modified user operation structure
|
|
11
|
+
*/
|
|
4
12
|
export const defaultPaymasterAndData: ClientMiddlewareFn = async (
|
|
5
13
|
struct,
|
|
6
14
|
{ account }
|
|
@@ -8,6 +8,16 @@ import {
|
|
|
8
8
|
} from "../../utils/index.js";
|
|
9
9
|
import type { ClientMiddlewareFn } from "../types";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Provides a default middleware function for signing user operations with a client account. This function validates the request and adds the signature to it.
|
|
13
|
+
* This is already included in the client returned from `createSmartAccountClient`
|
|
14
|
+
*
|
|
15
|
+
* @param {UserOperationStruct} struct The user operation structure to be signed
|
|
16
|
+
* @param {*} context The middleware context containing the client and account information
|
|
17
|
+
* @param {Client} context.client The client object, which should include account and chain information
|
|
18
|
+
* @param {Account} [context.account] Optional, the account used for signing, defaults to the client's account if not provided
|
|
19
|
+
* @returns {Promise<UserOperationStruct>} A promise that resolves to the signed user operation structure
|
|
20
|
+
*/
|
|
11
21
|
export const defaultUserOpSigner: ClientMiddlewareFn = async (
|
|
12
22
|
struct,
|
|
13
23
|
{ client, account = client.account }
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
|
|
12
12
|
import type { SmartAccountSigner } from "./types.js";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
16
|
+
*/
|
|
14
17
|
export class LocalAccountSigner<
|
|
15
18
|
T extends HDAccount | PrivateKeyAccount | LocalAccount
|
|
16
19
|
> implements SmartAccountSigner<T>
|
package/src/signer/schema.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { SmartAccountSigner } from "./types";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided object is a `SmartAccountSigner`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { isSigner, LocalAccountSigner } from "@aa-sdk/core";
|
|
10
|
+
*
|
|
11
|
+
* const signer = new LocalAccountSigner(...);
|
|
12
|
+
* console.log(isSigner(signer)); // true
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param {any} signer the object to check
|
|
16
|
+
* @returns {boolean} A boolean indicating whether the object is a `SmartAccountSigner`
|
|
17
|
+
*/
|
|
4
18
|
export const isSigner = (signer: any): signer is SmartAccountSigner => {
|
|
5
19
|
return (
|
|
6
20
|
signer != null &&
|