@aa-sdk/core 4.0.0-alpha.1 → 4.0.0-alpha.11
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/smartContractAccount.d.ts +9 -3
- package/dist/cjs/account/smartContractAccount.js +11 -6
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js +1 -5
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.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/isSmartAccountClient.js.map +1 -1
- package/dist/cjs/client/smartAccountClient.js +6 -0
- package/dist/cjs/client/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/types.d.ts +2 -7
- package/dist/cjs/client/types.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/errors/account.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/errors/useroperation.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -6
- package/dist/cjs/index.js +38 -64
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/actions.js +2 -18
- package/dist/cjs/middleware/actions.js.map +1 -1
- package/dist/cjs/middleware/defaults/gasEstimator.js +4 -2
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
- package/dist/cjs/middleware/erc7677middleware.js +77 -0
- package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
- package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
- package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
- package/dist/cjs/middleware/types.d.ts +3 -2
- package/dist/cjs/middleware/types.js.map +1 -1
- package/dist/cjs/signer/local-account.d.ts +44 -44
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/wallet-client.d.ts +44 -44
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/transport/split.js.map +1 -1
- package/dist/cjs/utils/bigint.js.map +1 -1
- package/dist/cjs/utils/bytes.js.map +1 -1
- package/dist/cjs/utils/defaults.d.ts +2 -4
- package/dist/cjs/utils/defaults.js +5 -45
- package/dist/cjs/utils/defaults.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -3
- package/dist/cjs/utils/index.js +1 -25
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/types.js.map +1 -1
- package/dist/cjs/utils/userop.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/smartContractAccount.d.ts +9 -3
- package/dist/esm/account/smartContractAccount.js +6 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js +2 -6
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.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/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js +6 -0
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -7
- package/dist/esm/client/types.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/errors/account.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/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +3 -6
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.js +3 -18
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js +4 -2
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
- package/dist/esm/middleware/erc7677middleware.js +73 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -0
- package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.d.ts +3 -2
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +44 -44
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +44 -44
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/defaults.d.ts +2 -4
- package/dist/esm/utils/defaults.js +1 -40
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -3
- package/dist/esm/utils/index.js +0 -11
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.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 +17 -11
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +2 -2
- package/dist/types/client/decorators/bundlerClient.d.ts +8 -8
- package/dist/types/client/isSmartAccountClient.d.ts +4 -4
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +2 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts +1 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +53 -4
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +15 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +12 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +5 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +8 -1
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts +5 -5
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +88 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts +3 -3
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
- package/dist/types/middleware/erc7677middleware.d.ts +62 -0
- package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
- package/dist/types/middleware/noopMiddleware.d.ts +4 -4
- package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
- package/dist/types/middleware/types.d.ts +3 -2
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +137 -45
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +133 -44
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +3 -3
- package/dist/types/utils/bigint.d.ts +14 -14
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts +5 -5
- package/dist/types/utils/defaults.d.ts +2 -12
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +12 -22
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/utils/userop.d.ts +33 -33
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/account/smartContractAccount.ts +19 -13
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +10 -10
- package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
- package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
- package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
- package/src/actions/smartAccount/sendUserOperation.ts +17 -3
- package/src/client/bundlerClient.ts +2 -2
- package/src/client/decorators/bundlerClient.ts +8 -8
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/smartAccountClient.ts +7 -0
- package/src/client/types.ts +2 -15
- package/src/ens/utils.ts +1 -2
- package/src/errors/account.ts +64 -4
- package/src/errors/client.ts +18 -0
- package/src/errors/entrypoint.ts +12 -0
- package/src/errors/signer.ts +6 -0
- package/src/errors/transaction.ts +10 -1
- package/src/errors/useroperation.ts +5 -6
- package/src/index.ts +2 -31
- package/src/logger.ts +88 -0
- package/src/middleware/actions.ts +6 -27
- package/src/middleware/defaults/gasEstimator.ts +9 -5
- package/src/middleware/erc7677middleware.ts +201 -0
- package/src/middleware/noopMiddleware.ts +6 -4
- package/src/middleware/types.ts +16 -7
- package/src/signer/local-account.ts +94 -2
- package/src/signer/wallet-client.ts +89 -0
- package/src/transport/split.ts +3 -3
- package/src/utils/bigint.ts +15 -15
- package/src/utils/bytes.ts +5 -5
- package/src/utils/defaults.ts +3 -76
- package/src/utils/index.ts +12 -35
- package/src/utils/types.ts +2 -2
- package/src/utils/userop.ts +33 -33
- package/src/version.ts +1 -1
- package/dist/cjs/account/base.d.ts +0 -49
- package/dist/cjs/account/base.js +0 -257
- package/dist/cjs/account/base.js.map +0 -1
- package/dist/cjs/account/schema.d.ts +0 -100
- package/dist/cjs/account/schema.js +0 -43
- package/dist/cjs/account/schema.js.map +0 -1
- package/dist/cjs/account/simple.d.ts +0 -14
- package/dist/cjs/account/simple.js +0 -119
- package/dist/cjs/account/simple.js.map +0 -1
- package/dist/cjs/account/types.d.ts +0 -30
- package/dist/cjs/account/types.js +0 -3
- package/dist/cjs/account/types.js.map +0 -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/account/base.d.ts +0 -49
- package/dist/esm/account/base.js +0 -253
- package/dist/esm/account/base.js.map +0 -1
- package/dist/esm/account/schema.d.ts +0 -100
- package/dist/esm/account/schema.js +0 -35
- package/dist/esm/account/schema.js.map +0 -1
- package/dist/esm/account/simple.d.ts +0 -14
- package/dist/esm/account/simple.js +0 -115
- package/dist/esm/account/simple.js.map +0 -1
- package/dist/esm/account/types.d.ts +0 -30
- package/dist/esm/account/types.js +0 -2
- package/dist/esm/account/types.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/account/base.d.ts +0 -128
- package/dist/types/account/base.d.ts.map +0 -1
- package/dist/types/account/schema.d.ts +0 -101
- package/dist/types/account/schema.d.ts.map +0 -1
- package/dist/types/account/simple.d.ts +0 -15
- package/dist/types/account/simple.d.ts.map +0 -1
- package/dist/types/account/types.d.ts +0 -144
- package/dist/types/account/types.d.ts.map +0 -1
- package/dist/types/chains/index.d.ts +0 -21
- package/dist/types/chains/index.d.ts.map +0 -1
- package/src/account/base.ts +0 -415
- package/src/account/schema.ts +0 -51
- package/src/account/simple.ts +0 -221
- package/src/account/types.ts +0 -184
- package/src/chains/index.ts +0 -194
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import type { Address } from "abitype";
|
|
2
|
-
import type { Hash, Hex, HttpTransport, Transport } from "viem";
|
|
3
|
-
import type { SignTypedDataParameters } from "viem/accounts";
|
|
4
|
-
import type { z } from "zod";
|
|
5
|
-
import type { BundlerClient } from "../client/bundlerClient";
|
|
6
|
-
import type { SmartAccountSigner } from "../signer/types";
|
|
7
|
-
import type { BatchUserOperationCallData } from "../types";
|
|
8
|
-
import type { SimpleSmartAccountParamsSchema, createBaseSmartAccountParamsSchema } from "./schema";
|
|
9
|
-
/** @deprecated */
|
|
10
|
-
export type SignTypedDataParams = Omit<SignTypedDataParameters, "privateKey">;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated don't use base smart account anymore, migrate to using toSmartContractAccount instead
|
|
13
|
-
*/
|
|
14
|
-
export type BaseSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>>;
|
|
15
|
-
export type SimpleSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated use `toSmartContractAccount` instead for creating instances of smart accounts
|
|
18
|
-
*/
|
|
19
|
-
export interface ISmartContractAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> {
|
|
20
|
-
/**
|
|
21
|
-
* The RPC provider the account uses to make RPC calls
|
|
22
|
-
*/
|
|
23
|
-
readonly rpcProvider: BundlerClient<TTransport> | BundlerClient<HttpTransport>;
|
|
24
|
-
/**
|
|
25
|
-
* @returns the init code for the account
|
|
26
|
-
*/
|
|
27
|
-
getInitCode(): Promise<Hex>;
|
|
28
|
-
/**
|
|
29
|
-
* This is useful for estimating gas costs. It should return a signature that doesn't cause the account to revert
|
|
30
|
-
* when validation is run during estimation.
|
|
31
|
-
*
|
|
32
|
-
* @returns a dummy signature that doesn't cause the account to revert during estimation
|
|
33
|
-
*/
|
|
34
|
-
getDummySignature(): Hex | Promise<Hex>;
|
|
35
|
-
/**
|
|
36
|
-
* Encodes a call to the account's execute function.
|
|
37
|
-
*
|
|
38
|
-
* @param target - the address receiving the call data
|
|
39
|
-
* @param value - optionally the amount of native token to send
|
|
40
|
-
* @param data - the call data or "0x" if empty
|
|
41
|
-
*/
|
|
42
|
-
encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;
|
|
43
|
-
/**
|
|
44
|
-
* Encodes a batch of transactions to the account's batch execute function.
|
|
45
|
-
* NOTE: not all accounts support batching.
|
|
46
|
-
*
|
|
47
|
-
* @param txs - An Array of objects containing the target, value, and data for each transaction
|
|
48
|
-
* @returns the encoded callData for a UserOperation
|
|
49
|
-
*/
|
|
50
|
-
encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;
|
|
51
|
-
/**
|
|
52
|
-
* @returns the nonce of the account
|
|
53
|
-
*/
|
|
54
|
-
getNonce(): Promise<bigint>;
|
|
55
|
-
/**
|
|
56
|
-
* If your account handles 1271 signatures of personal_sign differently
|
|
57
|
-
* than it does UserOperations, you can implement two different approaches to signing
|
|
58
|
-
*
|
|
59
|
-
* @param uoHash -- The hash of the UserOperation to sign
|
|
60
|
-
* @returns the signature of the UserOperation
|
|
61
|
-
*/
|
|
62
|
-
signUserOperationHash(uoHash: Hash): Promise<Hash>;
|
|
63
|
-
/**
|
|
64
|
-
* Returns a signed and prefixed message.
|
|
65
|
-
*
|
|
66
|
-
* @param msg - the message to sign
|
|
67
|
-
* @returns the signature of the message
|
|
68
|
-
*/
|
|
69
|
-
signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
70
|
-
/**
|
|
71
|
-
* Signs a typed data object as per ERC-712
|
|
72
|
-
*
|
|
73
|
-
* @param params - {@link SignTypedDataParams}
|
|
74
|
-
* @returns the signed hash for the message passed
|
|
75
|
-
*/
|
|
76
|
-
signTypedData(params: SignTypedDataParams): Promise<Hash>;
|
|
77
|
-
/**
|
|
78
|
-
* If the account is not deployed, it will sign the message and then wrap it in 6492 format
|
|
79
|
-
*
|
|
80
|
-
* @param msg - the message to sign
|
|
81
|
-
* @returns ths signature wrapped in 6492 format
|
|
82
|
-
*/
|
|
83
|
-
signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
84
|
-
/**
|
|
85
|
-
* If the account is not deployed, it will sign the typed data blob and then wrap it in 6492 format
|
|
86
|
-
*
|
|
87
|
-
* @param params - {@link SignTypedDataParams}
|
|
88
|
-
* @returns the signed hash for the params passed in wrapped in 6492 format
|
|
89
|
-
*/
|
|
90
|
-
signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;
|
|
91
|
-
/**
|
|
92
|
-
* @returns the address of the account
|
|
93
|
-
*/
|
|
94
|
-
getAddress(): Promise<Address>;
|
|
95
|
-
/**
|
|
96
|
-
* @returns the current account signer instance that the smart account client
|
|
97
|
-
* operations are being signed with.
|
|
98
|
-
*
|
|
99
|
-
* The signer is expected to be the owner or one of the owners of the account
|
|
100
|
-
* for the signatures to be valid for the acting account.
|
|
101
|
-
*/
|
|
102
|
-
getSigner(): TSigner;
|
|
103
|
-
/**
|
|
104
|
-
* The factory address of the smart account created by the factory
|
|
105
|
-
*
|
|
106
|
-
* @returns the address of the factory contract for the smart account
|
|
107
|
-
*/
|
|
108
|
-
getFactoryAddress(): Address;
|
|
109
|
-
/**
|
|
110
|
-
* The entrypoint address is the address ERC 4337 entrypoint singleton contract
|
|
111
|
-
* that this smart account and the connected bundler client use
|
|
112
|
-
*
|
|
113
|
-
* @returns the address of the entry point contract for the smart account
|
|
114
|
-
*/
|
|
115
|
-
getEntryPointAddress(): Address;
|
|
116
|
-
/**
|
|
117
|
-
* Allows you to add additional functionality and utility methods to this account
|
|
118
|
-
* via a decorator pattern.
|
|
119
|
-
*
|
|
120
|
-
* NOTE: this method does not allow you to override existing methods on the account.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```ts
|
|
124
|
-
* const account = new BaseSmartCobntractAccount(...).extend((account) => ({
|
|
125
|
-
* readAccountState: async (...args) => {
|
|
126
|
-
* return this.rpcProvider.readContract({
|
|
127
|
-
* address: await this.getAddress(),
|
|
128
|
-
* abi: ThisContractsAbi
|
|
129
|
-
* args: args
|
|
130
|
-
* });
|
|
131
|
-
* }
|
|
132
|
-
* }));
|
|
133
|
-
*
|
|
134
|
-
* account.debugSendUserOperation(...);
|
|
135
|
-
* ```
|
|
136
|
-
*
|
|
137
|
-
* @param extendFn -- this function gives you access to the created account instance and returns an object
|
|
138
|
-
* with the extension methods
|
|
139
|
-
* @returns -- the account with the extension methods added
|
|
140
|
-
*/
|
|
141
|
-
extend: <R>(extendFn: (self: this) => R) => this & R;
|
|
142
|
-
encodeUpgradeToAndCall: (upgradeToImplAddress: Address, upgradeToInitData: Hex) => Promise<Hex>;
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/account/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type Chain } from "viem";
|
|
2
|
-
export declare const arbitrum: Chain;
|
|
3
|
-
export declare const arbitrumGoerli: Chain;
|
|
4
|
-
export declare const arbitrumSepolia: Chain;
|
|
5
|
-
export declare const goerli: Chain;
|
|
6
|
-
export declare const mainnet: Chain;
|
|
7
|
-
export declare const optimism: Chain;
|
|
8
|
-
export declare const optimismGoerli: Chain;
|
|
9
|
-
export declare const optimismSepolia: Chain;
|
|
10
|
-
export declare const sepolia: Chain;
|
|
11
|
-
export declare const base: Chain;
|
|
12
|
-
export declare const baseGoerli: Chain;
|
|
13
|
-
export declare const baseSepolia: Chain;
|
|
14
|
-
export declare const polygonMumbai: Chain;
|
|
15
|
-
export declare const polygonAmoy: Chain;
|
|
16
|
-
export declare const polygon: Chain;
|
|
17
|
-
export declare const fraxtal: Chain;
|
|
18
|
-
export declare const fraxtalSepolia: Chain;
|
|
19
|
-
export declare const zora: Chain;
|
|
20
|
-
export declare const zoraSepolia: Chain;
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chains/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAsB/C,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAQ5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AACF,eAAO,MAAM,MAAM,EAAE,KAQpB,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,KAQ5B,CAAC;AACF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AACF,eAAO,MAAM,IAAI,EAAE,KAQlB,CAAC;AACF,eAAO,MAAM,UAAU,EAAE,KAQxB,CAAC;AACF,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAQ3B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAS3B,CAAC;AAEH,eAAO,MAAM,IAAI,EAAE,KAKlB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAKzB,CAAC"}
|
package/src/account/base.ts
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import type { Address } from "abitype";
|
|
2
|
-
import {
|
|
3
|
-
getContract,
|
|
4
|
-
http,
|
|
5
|
-
trim,
|
|
6
|
-
type GetContractReturnType,
|
|
7
|
-
type Hash,
|
|
8
|
-
type Hex,
|
|
9
|
-
type HttpTransport,
|
|
10
|
-
type PublicClient,
|
|
11
|
-
type Transport,
|
|
12
|
-
} from "viem";
|
|
13
|
-
import { EntryPointAbi_v6 as EntryPointAbi } from "../abis/EntryPointAbi_v6.js";
|
|
14
|
-
import {
|
|
15
|
-
createBundlerClient,
|
|
16
|
-
type BundlerClient,
|
|
17
|
-
} from "../client/bundlerClient.js";
|
|
18
|
-
import { getEntryPoint } from "../entrypoint/index.js";
|
|
19
|
-
import {
|
|
20
|
-
BatchExecutionNotSupportedError,
|
|
21
|
-
FailedToGetStorageSlotError,
|
|
22
|
-
GetCounterFactualAddressError,
|
|
23
|
-
UpgradeToAndCallNotSupportedError,
|
|
24
|
-
} from "../errors/account.js";
|
|
25
|
-
import { InvalidRpcUrlError } from "../errors/client.js";
|
|
26
|
-
import { Logger } from "../logger.js";
|
|
27
|
-
import type { SmartAccountSigner } from "../signer/types.js";
|
|
28
|
-
import { wrapSignatureWith6492 } from "../signer/utils.js";
|
|
29
|
-
import type { BatchUserOperationCallData, NullAddress } from "../types.js";
|
|
30
|
-
import { createBaseSmartAccountParamsSchema } from "./schema.js";
|
|
31
|
-
import type {
|
|
32
|
-
BaseSmartAccountParams,
|
|
33
|
-
ISmartContractAccount,
|
|
34
|
-
SignTypedDataParams,
|
|
35
|
-
} from "./types.js";
|
|
36
|
-
|
|
37
|
-
export enum DeploymentState {
|
|
38
|
-
UNDEFINED = "0x0",
|
|
39
|
-
NOT_DEPLOYED = "0x1",
|
|
40
|
-
DEPLOYED = "0x2",
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use `toSmartContractAccount` instead for creating SmartAccountInstances
|
|
45
|
-
*/
|
|
46
|
-
export abstract class BaseSmartContractAccount<
|
|
47
|
-
TTransport extends Transport = Transport,
|
|
48
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
49
|
-
> implements ISmartContractAccount<TTransport, TSigner>
|
|
50
|
-
{
|
|
51
|
-
protected factoryAddress: Address;
|
|
52
|
-
protected deploymentState: DeploymentState = DeploymentState.UNDEFINED;
|
|
53
|
-
protected accountAddress?: Address;
|
|
54
|
-
protected accountInitCode?: Hex;
|
|
55
|
-
protected signer: TSigner;
|
|
56
|
-
protected entryPoint: GetContractReturnType<
|
|
57
|
-
typeof EntryPointAbi,
|
|
58
|
-
PublicClient
|
|
59
|
-
>;
|
|
60
|
-
protected entryPointAddress: Address;
|
|
61
|
-
readonly rpcProvider:
|
|
62
|
-
| BundlerClient<TTransport>
|
|
63
|
-
| BundlerClient<HttpTransport>;
|
|
64
|
-
|
|
65
|
-
constructor(params_: BaseSmartAccountParams<TTransport, TSigner>) {
|
|
66
|
-
const params = createBaseSmartAccountParamsSchema<
|
|
67
|
-
TTransport,
|
|
68
|
-
TSigner
|
|
69
|
-
>().parse(params_);
|
|
70
|
-
|
|
71
|
-
this.entryPointAddress =
|
|
72
|
-
params.entryPointAddress ?? getEntryPoint(params.chain).address;
|
|
73
|
-
|
|
74
|
-
const rpcUrl =
|
|
75
|
-
typeof params.rpcClient === "string"
|
|
76
|
-
? params.rpcClient
|
|
77
|
-
: params.rpcClient.transport.type === "http"
|
|
78
|
-
? (
|
|
79
|
-
params.rpcClient.transport as ReturnType<HttpTransport>["config"] &
|
|
80
|
-
ReturnType<HttpTransport>["value"]
|
|
81
|
-
).url || params.chain.rpcUrls.default.http[0]
|
|
82
|
-
: undefined;
|
|
83
|
-
|
|
84
|
-
const fetchOptions =
|
|
85
|
-
typeof params.rpcClient === "string"
|
|
86
|
-
? undefined
|
|
87
|
-
: params.rpcClient.transport.type === "http"
|
|
88
|
-
? (
|
|
89
|
-
params.rpcClient.transport as ReturnType<HttpTransport>["config"] &
|
|
90
|
-
ReturnType<HttpTransport>["value"]
|
|
91
|
-
).fetchOptions
|
|
92
|
-
: undefined;
|
|
93
|
-
|
|
94
|
-
this.rpcProvider = rpcUrl
|
|
95
|
-
? createBundlerClient({
|
|
96
|
-
chain: params.chain,
|
|
97
|
-
transport: http(rpcUrl, {
|
|
98
|
-
fetchOptions: {
|
|
99
|
-
...fetchOptions,
|
|
100
|
-
headers: {
|
|
101
|
-
...fetchOptions?.headers,
|
|
102
|
-
...(rpcUrl.toLowerCase().indexOf("alchemy") > -1
|
|
103
|
-
? {
|
|
104
|
-
"Alchemy-Aa-Sdk-Signer":
|
|
105
|
-
params.signer?.signerType || "unknown",
|
|
106
|
-
"Alchemy-Aa-Sdk-Factory-Address": params.factoryAddress,
|
|
107
|
-
}
|
|
108
|
-
: undefined),
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
}),
|
|
112
|
-
})
|
|
113
|
-
: (params.rpcClient as BundlerClient<TTransport>);
|
|
114
|
-
|
|
115
|
-
this.accountAddress = params.accountAddress;
|
|
116
|
-
this.factoryAddress = params.factoryAddress;
|
|
117
|
-
this.signer = params.signer as TSigner;
|
|
118
|
-
this.accountInitCode = params.initCode as Hex;
|
|
119
|
-
|
|
120
|
-
this.entryPoint = getContract({
|
|
121
|
-
address: this.entryPointAddress,
|
|
122
|
-
abi: EntryPointAbi,
|
|
123
|
-
client: this.rpcProvider as PublicClient,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#region abstract-methods
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* This method should return a signature that will not `revert` during validation.
|
|
131
|
-
* It does not have to pass validation, just not cause the contract to revert.
|
|
132
|
-
* This is required for gas estimation so that the gas estimate are accurate.
|
|
133
|
-
*
|
|
134
|
-
*/
|
|
135
|
-
abstract getDummySignature(): Hex | Promise<Hex>;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* this method should return the abi encoded function data for a call to your contract's `execute` method
|
|
139
|
-
*
|
|
140
|
-
* @param target -- equivalent to `to` in a normal transaction
|
|
141
|
-
* @param value -- equivalent to `value` in a normal transaction
|
|
142
|
-
* @param data -- equivalent to `data` in a normal transaction
|
|
143
|
-
* @returns abi encoded function data for a call to your contract's `execute` method
|
|
144
|
-
*/
|
|
145
|
-
abstract encodeExecute(
|
|
146
|
-
target: string,
|
|
147
|
-
value: bigint,
|
|
148
|
-
data: string
|
|
149
|
-
): Promise<Hash>;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* this should return an ERC-191 compliant message and is used to sign UO Hashes
|
|
153
|
-
*
|
|
154
|
-
* @param msg -- the message to sign
|
|
155
|
-
*/
|
|
156
|
-
abstract signMessage(msg: string | Uint8Array): Promise<Hash>;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* this should return the init code that will be used to create an account if one does not exist.
|
|
160
|
-
* This is the concatenation of the account's factory address and the abi encoded function data of the account factory's `createAccount` method.
|
|
161
|
-
* https://github.com/eth-infinitism/account-abstraction/blob/abff2aca61a8f0934e533d0d352978055fddbd96/contracts/core/SenderCreator.sol#L12
|
|
162
|
-
*/
|
|
163
|
-
protected abstract getAccountInitCode(): Promise<Hash>;
|
|
164
|
-
|
|
165
|
-
//#endregion abstract-methods
|
|
166
|
-
|
|
167
|
-
//#region optional-methods
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* If your account handles 1271 signatures of personal_sign differently
|
|
171
|
-
* than it does UserOperations, you can implement two different approaches to signing
|
|
172
|
-
*
|
|
173
|
-
* @param uoHash -- The hash of the UserOperation to sign
|
|
174
|
-
* @returns the signature of the UserOperation
|
|
175
|
-
*/
|
|
176
|
-
async signUserOperationHash(uoHash: Hash): Promise<Hash> {
|
|
177
|
-
return this.signMessage(uoHash);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* If your contract supports signing and verifying typed data,
|
|
182
|
-
* you should implement this method.
|
|
183
|
-
*
|
|
184
|
-
* @param _params -- Typed Data params to sign
|
|
185
|
-
*/
|
|
186
|
-
async signTypedData(_params: SignTypedDataParams): Promise<`0x${string}`> {
|
|
187
|
-
throw new Error("signTypedData not supported");
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* This method should wrap the result of `signMessage` as per
|
|
192
|
-
* [EIP-6492](https://eips.ethereum.org/EIPS/eip-6492)
|
|
193
|
-
*
|
|
194
|
-
* @param msg -- the message to sign
|
|
195
|
-
* @returns the signature wrapped in 6492 format
|
|
196
|
-
*/
|
|
197
|
-
async signMessageWith6492(msg: string | Uint8Array): Promise<`0x${string}`> {
|
|
198
|
-
const [isDeployed, signature] = await Promise.all([
|
|
199
|
-
this.isAccountDeployed(),
|
|
200
|
-
this.signMessage(msg),
|
|
201
|
-
]);
|
|
202
|
-
|
|
203
|
-
return this.create6492Signature(isDeployed, signature);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Similar to the signMessageWith6492 method above,
|
|
208
|
-
* this method should wrap the result of `signTypedData` as per
|
|
209
|
-
* [EIP-6492](https://eips.ethereum.org/EIPS/eip-6492)
|
|
210
|
-
*
|
|
211
|
-
* @param params -- Typed Data params to sign
|
|
212
|
-
* @returns the signature wrapped in 6492 format
|
|
213
|
-
*/
|
|
214
|
-
async signTypedDataWith6492(
|
|
215
|
-
params: SignTypedDataParams
|
|
216
|
-
): Promise<`0x${string}`> {
|
|
217
|
-
const [isDeployed, signature] = await Promise.all([
|
|
218
|
-
this.isAccountDeployed(),
|
|
219
|
-
this.signTypedData(params),
|
|
220
|
-
]);
|
|
221
|
-
|
|
222
|
-
return this.create6492Signature(isDeployed, signature);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Not all contracts support batch execution.
|
|
227
|
-
* If your contract does, this method should encode a list of
|
|
228
|
-
* transactions into the call data that will be passed to your
|
|
229
|
-
* contract's batch execution method.
|
|
230
|
-
*
|
|
231
|
-
* @param _txs -- the transactions to batch execute
|
|
232
|
-
*/
|
|
233
|
-
async encodeBatchExecute(
|
|
234
|
-
_txs: BatchUserOperationCallData
|
|
235
|
-
): Promise<`0x${string}`> {
|
|
236
|
-
throw new BatchExecutionNotSupportedError("BaseAccount");
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* If your contract supports UUPS, you can implement this method which can be
|
|
241
|
-
* used to upgrade the implementation of the account.
|
|
242
|
-
*
|
|
243
|
-
* @param _upgradeToImplAddress -- the implementation address of the contract you want to upgrade to
|
|
244
|
-
* @param _upgradeToInitData -- the initialization data required by that account
|
|
245
|
-
*/
|
|
246
|
-
encodeUpgradeToAndCall = async (
|
|
247
|
-
_upgradeToImplAddress: Address,
|
|
248
|
-
_upgradeToInitData: Hex
|
|
249
|
-
): Promise<Hex> => {
|
|
250
|
-
throw new UpgradeToAndCallNotSupportedError("BaseAccount");
|
|
251
|
-
};
|
|
252
|
-
//#endregion optional-methods
|
|
253
|
-
|
|
254
|
-
// Extra implementations
|
|
255
|
-
async getNonce(): Promise<bigint> {
|
|
256
|
-
if (!(await this.isAccountDeployed())) {
|
|
257
|
-
return 0n;
|
|
258
|
-
}
|
|
259
|
-
const address = await this.getAddress();
|
|
260
|
-
return this.entryPoint.read.getNonce([address, BigInt(0)]);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
async getInitCode(): Promise<Hex> {
|
|
264
|
-
if (this.deploymentState === DeploymentState.DEPLOYED) {
|
|
265
|
-
return "0x";
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const contractCode = await this.rpcProvider.getBytecode({
|
|
269
|
-
address: await this.getAddress(),
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
if ((contractCode?.length ?? 0) > 2) {
|
|
273
|
-
this.deploymentState = DeploymentState.DEPLOYED;
|
|
274
|
-
return "0x";
|
|
275
|
-
} else {
|
|
276
|
-
this.deploymentState = DeploymentState.NOT_DEPLOYED;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return this._getAccountInitCode();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async getAddress(): Promise<Address> {
|
|
283
|
-
if (!this.accountAddress) {
|
|
284
|
-
const initCode = await this._getAccountInitCode();
|
|
285
|
-
Logger.verbose(
|
|
286
|
-
"[BaseSmartContractAccount](getAddress) initCode: ",
|
|
287
|
-
initCode
|
|
288
|
-
);
|
|
289
|
-
try {
|
|
290
|
-
await this.entryPoint.simulate.getSenderAddress([initCode]);
|
|
291
|
-
} catch (err: any) {
|
|
292
|
-
Logger.verbose(
|
|
293
|
-
"[BaseSmartContractAccount](getAddress) getSenderAddress err: ",
|
|
294
|
-
err
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
if (err.cause?.data?.errorName === "SenderAddressResult") {
|
|
298
|
-
this.accountAddress = err.cause.data.args[0] as Address;
|
|
299
|
-
Logger.verbose(
|
|
300
|
-
"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:",
|
|
301
|
-
this.accountAddress
|
|
302
|
-
);
|
|
303
|
-
return this.accountAddress;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (err.details === "Invalid URL") {
|
|
307
|
-
throw new InvalidRpcUrlError();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
throw new GetCounterFactualAddressError();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return this.accountAddress;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
extend = <R>(fn: (self: this) => R): this & R => {
|
|
318
|
-
const extended = fn(this) as any;
|
|
319
|
-
// this should make it so extensions can't overwrite the base methods
|
|
320
|
-
for (const key in this) {
|
|
321
|
-
delete extended[key];
|
|
322
|
-
}
|
|
323
|
-
return Object.assign(this, extended);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
getSigner(): TSigner {
|
|
327
|
-
return this.signer;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
getFactoryAddress(): Address {
|
|
331
|
-
return this.factoryAddress;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
getEntryPointAddress(): Address {
|
|
335
|
-
return this.entryPointAddress;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
async isAccountDeployed(): Promise<boolean> {
|
|
339
|
-
return (await this.getDeploymentState()) === DeploymentState.DEPLOYED;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async getDeploymentState(): Promise<DeploymentState> {
|
|
343
|
-
if (this.deploymentState === DeploymentState.UNDEFINED) {
|
|
344
|
-
const initCode = await this.getInitCode();
|
|
345
|
-
return initCode === "0x"
|
|
346
|
-
? DeploymentState.DEPLOYED
|
|
347
|
-
: DeploymentState.NOT_DEPLOYED;
|
|
348
|
-
} else {
|
|
349
|
-
return this.deploymentState;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* https://eips.ethereum.org/EIPS/eip-4337#first-time-account-creation
|
|
355
|
-
* The initCode field (if non-zero length) is parsed as a 20-byte address,
|
|
356
|
-
* followed by calldata to pass to this address.
|
|
357
|
-
* The factory address is the first 40 char after the 0x, and the callData is the rest.
|
|
358
|
-
*
|
|
359
|
-
* @returns [factoryAddress, factoryCalldata]
|
|
360
|
-
*/
|
|
361
|
-
protected async parseFactoryAddressFromAccountInitCode(): Promise<
|
|
362
|
-
[Address, Hex]
|
|
363
|
-
> {
|
|
364
|
-
const initCode = await this._getAccountInitCode();
|
|
365
|
-
const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;
|
|
366
|
-
const factoryCalldata: Hex = `0x${initCode.substring(42)}`;
|
|
367
|
-
return [factoryAddress, factoryCalldata];
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
protected async getImplementationAddress(): Promise<NullAddress | Address> {
|
|
371
|
-
const accountAddress = await this.getAddress();
|
|
372
|
-
|
|
373
|
-
const storage = await this.rpcProvider.getStorageAt({
|
|
374
|
-
address: accountAddress,
|
|
375
|
-
// This is the default slot for the implementation address for Proxies
|
|
376
|
-
slot: "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
if (storage == null) {
|
|
380
|
-
throw new FailedToGetStorageSlotError(
|
|
381
|
-
"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
|
|
382
|
-
"Proxy Implementation Address"
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return trim(storage);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
private async _getAccountInitCode(): Promise<Hash> {
|
|
390
|
-
return this.accountInitCode ?? this.getAccountInitCode();
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
private async create6492Signature(
|
|
394
|
-
isDeployed: boolean,
|
|
395
|
-
signature: Hash
|
|
396
|
-
): Promise<Hash> {
|
|
397
|
-
if (isDeployed) {
|
|
398
|
-
return signature;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const [factoryAddress, factoryCalldata] =
|
|
402
|
-
await this.parseFactoryAddressFromAccountInitCode();
|
|
403
|
-
|
|
404
|
-
Logger.verbose(
|
|
405
|
-
`[BaseSmartContractAccount](create6492Signature)\
|
|
406
|
-
factoryAddress: ${factoryAddress}, factoryCalldata: ${factoryCalldata}`
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
return wrapSignatureWith6492({
|
|
410
|
-
factoryAddress,
|
|
411
|
-
factoryCalldata,
|
|
412
|
-
signature,
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
}
|
package/src/account/schema.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Address } from "abitype/zod";
|
|
2
|
-
import { isHex, type Transport } from "viem";
|
|
3
|
-
import z from "zod";
|
|
4
|
-
import { createPublicErc4337ClientSchema } from "../client/schema.js";
|
|
5
|
-
import { isEntryPointVersion } from "../entrypoint/index.js";
|
|
6
|
-
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
7
|
-
import { isSigner } from "../signer/schema.js";
|
|
8
|
-
import type { SmartAccountSigner } from "../signer/types.js";
|
|
9
|
-
import { ChainSchema } from "../utils/index.js";
|
|
10
|
-
|
|
11
|
-
export const createBaseSmartAccountParamsSchema = <
|
|
12
|
-
TTransport extends Transport = Transport,
|
|
13
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
14
|
-
>() =>
|
|
15
|
-
z.object({
|
|
16
|
-
rpcClient: z.union([
|
|
17
|
-
z.string(),
|
|
18
|
-
createPublicErc4337ClientSchema<TTransport>(),
|
|
19
|
-
]),
|
|
20
|
-
factoryAddress: Address,
|
|
21
|
-
signer: z.custom<TSigner>(isSigner),
|
|
22
|
-
entryPointAddress: Address.optional(),
|
|
23
|
-
chain: ChainSchema,
|
|
24
|
-
accountAddress: Address.optional().describe(
|
|
25
|
-
"Optional override for the account address."
|
|
26
|
-
),
|
|
27
|
-
initCode: z
|
|
28
|
-
.string()
|
|
29
|
-
.refine(
|
|
30
|
-
(x) => isHex(x, { strict: true }),
|
|
31
|
-
"initCode must be a valid hex."
|
|
32
|
-
)
|
|
33
|
-
.optional()
|
|
34
|
-
.describe("Optional override for the account init code."),
|
|
35
|
-
entryPointVersion: z
|
|
36
|
-
.custom<EntryPointVersion>(isEntryPointVersion)
|
|
37
|
-
.optional(),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const SimpleSmartAccountParamsSchema = <
|
|
41
|
-
TTransport extends Transport = Transport,
|
|
42
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
43
|
-
>() =>
|
|
44
|
-
createBaseSmartAccountParamsSchema<TTransport, TSigner>()
|
|
45
|
-
.omit({
|
|
46
|
-
rpcClient: true,
|
|
47
|
-
})
|
|
48
|
-
.extend({
|
|
49
|
-
transport: z.custom<TTransport>(),
|
|
50
|
-
salt: z.bigint().optional(),
|
|
51
|
-
});
|