@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
package/src/account/simple.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import type { Address } from "abitype";
|
|
2
|
-
import {
|
|
3
|
-
concatHex,
|
|
4
|
-
encodeFunctionData,
|
|
5
|
-
isHex,
|
|
6
|
-
type Chain,
|
|
7
|
-
type FallbackTransport,
|
|
8
|
-
type Hex,
|
|
9
|
-
type Transport,
|
|
10
|
-
} from "viem";
|
|
11
|
-
import { SimpleAccountAbi_v6 } from "../abis/SimpleAccountAbi_v6.js";
|
|
12
|
-
import { SimpleAccountAbi_v7 } from "../abis/SimpleAccountAbi_v7.js";
|
|
13
|
-
import { SimpleAccountFactoryAbi } from "../abis/SimpleAccountFactoryAbi.js";
|
|
14
|
-
import { createBundlerClient } from "../client/bundlerClient.js";
|
|
15
|
-
import {
|
|
16
|
-
defaultEntryPointVersion,
|
|
17
|
-
getEntryPoint,
|
|
18
|
-
} from "../entrypoint/index.js";
|
|
19
|
-
import type {
|
|
20
|
-
DefaultEntryPointVersion,
|
|
21
|
-
EntryPointParameter,
|
|
22
|
-
EntryPointVersion,
|
|
23
|
-
} from "../entrypoint/types.js";
|
|
24
|
-
import { AccountRequiresOwnerError } from "../errors/account.js";
|
|
25
|
-
import type { SmartAccountSigner } from "../signer/types.js";
|
|
26
|
-
import type { BatchUserOperationCallData } from "../types.js";
|
|
27
|
-
import { getDefaultSimpleAccountFactoryAddress } from "../utils/defaults.js";
|
|
28
|
-
import { BaseSmartContractAccount } from "./base.js";
|
|
29
|
-
import { SimpleSmartAccountParamsSchema } from "./schema.js";
|
|
30
|
-
import {
|
|
31
|
-
toSmartContractAccount,
|
|
32
|
-
type SmartContractAccountWithSigner,
|
|
33
|
-
type ToSmartContractAccountParams,
|
|
34
|
-
} from "./smartContractAccount.js";
|
|
35
|
-
import type { SimpleSmartAccountParams } from "./types.js";
|
|
36
|
-
|
|
37
|
-
class SimpleSmartContractAccount<
|
|
38
|
-
TTransport extends Transport | FallbackTransport = Transport,
|
|
39
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
40
|
-
> extends BaseSmartContractAccount<TTransport, TSigner> {
|
|
41
|
-
protected index: bigint;
|
|
42
|
-
protected entryPointVersion: EntryPointVersion;
|
|
43
|
-
|
|
44
|
-
constructor(params: SimpleSmartAccountParams<TTransport, TSigner>) {
|
|
45
|
-
SimpleSmartAccountParamsSchema().parse(params);
|
|
46
|
-
|
|
47
|
-
// This is a hack for now, we should kill the SimpleSmart Account when we kill Base Account
|
|
48
|
-
const client = createBundlerClient({
|
|
49
|
-
transport: params.transport as TTransport,
|
|
50
|
-
chain: params.chain,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// @ts-expect-error zod custom type not recognized as required params for signers
|
|
54
|
-
super({ ...params, rpcClient: client });
|
|
55
|
-
this.signer = params.signer as TSigner;
|
|
56
|
-
this.index = params.salt ?? 0n;
|
|
57
|
-
this.entryPointVersion =
|
|
58
|
-
params.entryPointVersion ?? defaultEntryPointVersion;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getDummySignature(): `0x${string}` {
|
|
62
|
-
return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async encodeExecute(
|
|
66
|
-
target: Hex,
|
|
67
|
-
value: bigint,
|
|
68
|
-
data: Hex
|
|
69
|
-
): Promise<`0x${string}`> {
|
|
70
|
-
return encodeFunctionData({
|
|
71
|
-
abi:
|
|
72
|
-
this.entryPointVersion === "0.6.0"
|
|
73
|
-
? SimpleAccountAbi_v6
|
|
74
|
-
: SimpleAccountAbi_v7,
|
|
75
|
-
functionName: "execute",
|
|
76
|
-
args: [target, value, data],
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
override async encodeBatchExecute(
|
|
81
|
-
txs: BatchUserOperationCallData
|
|
82
|
-
): Promise<`0x${string}`> {
|
|
83
|
-
const [targets, datas] = txs.reduce(
|
|
84
|
-
(accum, curr) => {
|
|
85
|
-
accum[0].push(curr.target);
|
|
86
|
-
accum[1].push(curr.data);
|
|
87
|
-
|
|
88
|
-
return accum;
|
|
89
|
-
},
|
|
90
|
-
[[], []] as [Address[], Hex[]]
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
return encodeFunctionData({
|
|
94
|
-
abi:
|
|
95
|
-
this.entryPointVersion === "0.6.0"
|
|
96
|
-
? SimpleAccountAbi_v6
|
|
97
|
-
: SimpleAccountAbi_v7,
|
|
98
|
-
functionName: "executeBatch",
|
|
99
|
-
args: [targets, datas],
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
signMessage(msg: Uint8Array | string): Promise<`0x${string}`> {
|
|
104
|
-
return this.signer.signMessage(
|
|
105
|
-
typeof msg === "string" && !isHex(msg) ? msg : { raw: msg }
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
public async getAccountInitCode(): Promise<`0x${string}`> {
|
|
110
|
-
return concatHex([
|
|
111
|
-
this.factoryAddress,
|
|
112
|
-
encodeFunctionData({
|
|
113
|
-
abi: SimpleAccountFactoryAbi,
|
|
114
|
-
functionName: "createAccount",
|
|
115
|
-
args: [await this.signer.getAddress(), this.index],
|
|
116
|
-
}),
|
|
117
|
-
]);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export type SimpleSmartAccount<
|
|
122
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
123
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
124
|
-
> = SmartContractAccountWithSigner<
|
|
125
|
-
"SimpleAccount",
|
|
126
|
-
TSigner,
|
|
127
|
-
TEntryPointVersion
|
|
128
|
-
>;
|
|
129
|
-
|
|
130
|
-
export type CreateSimpleAccountParams<
|
|
131
|
-
TTransport extends Transport = Transport,
|
|
132
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
133
|
-
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion
|
|
134
|
-
> = Pick<
|
|
135
|
-
ToSmartContractAccountParams<
|
|
136
|
-
"SimpleAccount",
|
|
137
|
-
TTransport,
|
|
138
|
-
Chain,
|
|
139
|
-
TEntryPointVersion
|
|
140
|
-
>,
|
|
141
|
-
"chain" | "transport"
|
|
142
|
-
> & {
|
|
143
|
-
signer: TSigner;
|
|
144
|
-
salt?: bigint;
|
|
145
|
-
accountAddress?: Address;
|
|
146
|
-
factoryAddress?: Address;
|
|
147
|
-
initCode?: Hex;
|
|
148
|
-
} & EntryPointParameter<TEntryPointVersion, Chain>;
|
|
149
|
-
|
|
150
|
-
export async function createSimpleSmartAccount<
|
|
151
|
-
TTransport extends Transport = Transport,
|
|
152
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
153
|
-
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion
|
|
154
|
-
>(
|
|
155
|
-
config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>
|
|
156
|
-
): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Creates a simple smart account using the provided parameters, including chain, entry point, factory address, and additional parameters. This function also ensures that a signer is provided.
|
|
160
|
-
*
|
|
161
|
-
* @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account
|
|
162
|
-
* @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods
|
|
163
|
-
*/
|
|
164
|
-
export async function createSimpleSmartAccount({
|
|
165
|
-
chain,
|
|
166
|
-
entryPoint = getEntryPoint(chain),
|
|
167
|
-
factoryAddress = getDefaultSimpleAccountFactoryAddress(
|
|
168
|
-
chain,
|
|
169
|
-
entryPoint.version
|
|
170
|
-
),
|
|
171
|
-
...params
|
|
172
|
-
}: CreateSimpleAccountParams): Promise<SimpleSmartAccount> {
|
|
173
|
-
if (!params.signer) throw new AccountRequiresOwnerError("SimpleAccount");
|
|
174
|
-
const simpleAccount = new SimpleSmartContractAccount(
|
|
175
|
-
SimpleSmartAccountParamsSchema().parse({
|
|
176
|
-
chain,
|
|
177
|
-
entryPointAddress: entryPoint.address,
|
|
178
|
-
factoryAddress,
|
|
179
|
-
...params,
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const parsedParams = SimpleSmartAccountParamsSchema().parse({
|
|
184
|
-
chain,
|
|
185
|
-
entryPointAddress: entryPoint.address,
|
|
186
|
-
entryPointVersion: entryPoint.version,
|
|
187
|
-
factoryAddress,
|
|
188
|
-
...params,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const base = await toSmartContractAccount({
|
|
192
|
-
source: "SimpleAccount",
|
|
193
|
-
transport: params.transport,
|
|
194
|
-
chain,
|
|
195
|
-
encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),
|
|
196
|
-
encodeExecute: (tx) =>
|
|
197
|
-
simpleAccount.encodeExecute.bind(simpleAccount)(
|
|
198
|
-
tx.target,
|
|
199
|
-
tx.value ?? 0n,
|
|
200
|
-
tx.data
|
|
201
|
-
),
|
|
202
|
-
entryPoint,
|
|
203
|
-
getAccountInitCode: async () => {
|
|
204
|
-
if (parsedParams.initCode) return parsedParams.initCode as Hex;
|
|
205
|
-
return simpleAccount.getAccountInitCode();
|
|
206
|
-
},
|
|
207
|
-
getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),
|
|
208
|
-
signMessage: ({ message }) =>
|
|
209
|
-
simpleAccount.signMessage(
|
|
210
|
-
typeof message === "string" ? message : message.raw
|
|
211
|
-
),
|
|
212
|
-
// @ts-expect-error these types still represent the same thing, but they are just a little off in there definitions
|
|
213
|
-
signTypedData: simpleAccount.signTypedData.bind(simpleAccount),
|
|
214
|
-
accountAddress: parsedParams.accountAddress,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
...base,
|
|
219
|
-
getSigner: () => simpleAccount.getSigner(),
|
|
220
|
-
};
|
|
221
|
-
}
|
package/src/account/types.ts
DELETED
|
@@ -1,184 +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 {
|
|
9
|
-
SimpleSmartAccountParamsSchema,
|
|
10
|
-
createBaseSmartAccountParamsSchema,
|
|
11
|
-
} from "./schema";
|
|
12
|
-
|
|
13
|
-
/** @deprecated */
|
|
14
|
-
export type SignTypedDataParams = Omit<SignTypedDataParameters, "privateKey">;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated don't use base smart account anymore, migrate to using toSmartContractAccount instead
|
|
18
|
-
*/
|
|
19
|
-
export type BaseSmartAccountParams<
|
|
20
|
-
TTransport extends Transport = Transport,
|
|
21
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
22
|
-
> = z.input<
|
|
23
|
-
ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>
|
|
24
|
-
>;
|
|
25
|
-
|
|
26
|
-
export type SimpleSmartAccountParams<
|
|
27
|
-
TTransport extends Transport = Transport,
|
|
28
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
29
|
-
> = z.input<
|
|
30
|
-
ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>
|
|
31
|
-
>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use `toSmartContractAccount` instead for creating instances of smart accounts
|
|
35
|
-
*/
|
|
36
|
-
export interface ISmartContractAccount<
|
|
37
|
-
TTransport extends Transport = Transport,
|
|
38
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
39
|
-
> {
|
|
40
|
-
/**
|
|
41
|
-
* The RPC provider the account uses to make RPC calls
|
|
42
|
-
*/
|
|
43
|
-
readonly rpcProvider:
|
|
44
|
-
| BundlerClient<TTransport>
|
|
45
|
-
| BundlerClient<HttpTransport>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @returns the init code for the account
|
|
49
|
-
*/
|
|
50
|
-
getInitCode(): Promise<Hex>;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* This is useful for estimating gas costs. It should return a signature that doesn't cause the account to revert
|
|
54
|
-
* when validation is run during estimation.
|
|
55
|
-
*
|
|
56
|
-
* @returns a dummy signature that doesn't cause the account to revert during estimation
|
|
57
|
-
*/
|
|
58
|
-
getDummySignature(): Hex | Promise<Hex>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Encodes a call to the account's execute function.
|
|
62
|
-
*
|
|
63
|
-
* @param target - the address receiving the call data
|
|
64
|
-
* @param value - optionally the amount of native token to send
|
|
65
|
-
* @param data - the call data or "0x" if empty
|
|
66
|
-
*/
|
|
67
|
-
encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Encodes a batch of transactions to the account's batch execute function.
|
|
71
|
-
* NOTE: not all accounts support batching.
|
|
72
|
-
*
|
|
73
|
-
* @param txs - An Array of objects containing the target, value, and data for each transaction
|
|
74
|
-
* @returns the encoded callData for a UserOperation
|
|
75
|
-
*/
|
|
76
|
-
encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @returns the nonce of the account
|
|
80
|
-
*/
|
|
81
|
-
getNonce(): Promise<bigint>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* If your account handles 1271 signatures of personal_sign differently
|
|
85
|
-
* than it does UserOperations, you can implement two different approaches to signing
|
|
86
|
-
*
|
|
87
|
-
* @param uoHash -- The hash of the UserOperation to sign
|
|
88
|
-
* @returns the signature of the UserOperation
|
|
89
|
-
*/
|
|
90
|
-
signUserOperationHash(uoHash: Hash): Promise<Hash>;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Returns a signed and prefixed message.
|
|
94
|
-
*
|
|
95
|
-
* @param msg - the message to sign
|
|
96
|
-
* @returns the signature of the message
|
|
97
|
-
*/
|
|
98
|
-
signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Signs a typed data object as per ERC-712
|
|
102
|
-
*
|
|
103
|
-
* @param params - {@link SignTypedDataParams}
|
|
104
|
-
* @returns the signed hash for the message passed
|
|
105
|
-
*/
|
|
106
|
-
signTypedData(params: SignTypedDataParams): Promise<Hash>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* If the account is not deployed, it will sign the message and then wrap it in 6492 format
|
|
110
|
-
*
|
|
111
|
-
* @param msg - the message to sign
|
|
112
|
-
* @returns ths signature wrapped in 6492 format
|
|
113
|
-
*/
|
|
114
|
-
signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* If the account is not deployed, it will sign the typed data blob and then wrap it in 6492 format
|
|
118
|
-
*
|
|
119
|
-
* @param params - {@link SignTypedDataParams}
|
|
120
|
-
* @returns the signed hash for the params passed in wrapped in 6492 format
|
|
121
|
-
*/
|
|
122
|
-
signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @returns the address of the account
|
|
126
|
-
*/
|
|
127
|
-
getAddress(): Promise<Address>;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @returns the current account signer instance that the smart account client
|
|
131
|
-
* operations are being signed with.
|
|
132
|
-
*
|
|
133
|
-
* The signer is expected to be the owner or one of the owners of the account
|
|
134
|
-
* for the signatures to be valid for the acting account.
|
|
135
|
-
*/
|
|
136
|
-
getSigner(): TSigner;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The factory address of the smart account created by the factory
|
|
140
|
-
*
|
|
141
|
-
* @returns the address of the factory contract for the smart account
|
|
142
|
-
*/
|
|
143
|
-
getFactoryAddress(): Address;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* The entrypoint address is the address ERC 4337 entrypoint singleton contract
|
|
147
|
-
* that this smart account and the connected bundler client use
|
|
148
|
-
*
|
|
149
|
-
* @returns the address of the entry point contract for the smart account
|
|
150
|
-
*/
|
|
151
|
-
getEntryPointAddress(): Address;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Allows you to add additional functionality and utility methods to this account
|
|
155
|
-
* via a decorator pattern.
|
|
156
|
-
*
|
|
157
|
-
* NOTE: this method does not allow you to override existing methods on the account.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```ts
|
|
161
|
-
* const account = new BaseSmartCobntractAccount(...).extend((account) => ({
|
|
162
|
-
* readAccountState: async (...args) => {
|
|
163
|
-
* return this.rpcProvider.readContract({
|
|
164
|
-
* address: await this.getAddress(),
|
|
165
|
-
* abi: ThisContractsAbi
|
|
166
|
-
* args: args
|
|
167
|
-
* });
|
|
168
|
-
* }
|
|
169
|
-
* }));
|
|
170
|
-
*
|
|
171
|
-
* account.debugSendUserOperation(...);
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* @param extendFn -- this function gives you access to the created account instance and returns an object
|
|
175
|
-
* with the extension methods
|
|
176
|
-
* @returns -- the account with the extension methods added
|
|
177
|
-
*/
|
|
178
|
-
extend: <R>(extendFn: (self: this) => R) => this & R;
|
|
179
|
-
|
|
180
|
-
encodeUpgradeToAndCall: (
|
|
181
|
-
upgradeToImplAddress: Address,
|
|
182
|
-
upgradeToInitData: Hex
|
|
183
|
-
) => Promise<Hex>;
|
|
184
|
-
}
|
package/src/chains/index.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { defineChain, type Chain } from "viem";
|
|
2
|
-
import {
|
|
3
|
-
arbitrum as vab,
|
|
4
|
-
arbitrumGoerli as vabg,
|
|
5
|
-
arbitrumSepolia as vabs,
|
|
6
|
-
base as vbase,
|
|
7
|
-
baseGoerli as vbaseg,
|
|
8
|
-
baseSepolia as vbases,
|
|
9
|
-
goerli as vgo,
|
|
10
|
-
mainnet as vmain,
|
|
11
|
-
optimism as vop,
|
|
12
|
-
optimismGoerli as vopg,
|
|
13
|
-
optimismSepolia as vops,
|
|
14
|
-
polygon as vpg,
|
|
15
|
-
polygonMumbai as vpgm,
|
|
16
|
-
polygonAmoy as vpga,
|
|
17
|
-
sepolia as vsep,
|
|
18
|
-
fraxtal as vfrax,
|
|
19
|
-
zora as vzora,
|
|
20
|
-
zoraSepolia as vzoras,
|
|
21
|
-
} from "viem/chains";
|
|
22
|
-
|
|
23
|
-
export const arbitrum: Chain = {
|
|
24
|
-
...vab,
|
|
25
|
-
rpcUrls: {
|
|
26
|
-
...vab.rpcUrls,
|
|
27
|
-
alchemy: {
|
|
28
|
-
http: ["https://arb-mainnet.g.alchemy.com/v2"],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const arbitrumGoerli: Chain = {
|
|
34
|
-
...vabg,
|
|
35
|
-
rpcUrls: {
|
|
36
|
-
...vabg.rpcUrls,
|
|
37
|
-
alchemy: {
|
|
38
|
-
http: ["https://arb-goerli.g.alchemy.com/v2"],
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const arbitrumSepolia: Chain = {
|
|
44
|
-
...vabs,
|
|
45
|
-
rpcUrls: {
|
|
46
|
-
...vabs.rpcUrls,
|
|
47
|
-
alchemy: {
|
|
48
|
-
http: ["https://arb-sepolia.g.alchemy.com/v2"],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
export const goerli: Chain = {
|
|
53
|
-
...vgo,
|
|
54
|
-
rpcUrls: {
|
|
55
|
-
...vgo.rpcUrls,
|
|
56
|
-
alchemy: {
|
|
57
|
-
http: ["https://eth-goerli.g.alchemy.com/v2"],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
export const mainnet: Chain = {
|
|
62
|
-
...vmain,
|
|
63
|
-
rpcUrls: {
|
|
64
|
-
...vmain.rpcUrls,
|
|
65
|
-
alchemy: {
|
|
66
|
-
http: ["https://eth-mainnet.g.alchemy.com/v2"],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
export const optimism: Chain = {
|
|
71
|
-
...vop,
|
|
72
|
-
rpcUrls: {
|
|
73
|
-
...vop.rpcUrls,
|
|
74
|
-
alchemy: {
|
|
75
|
-
http: ["https://opt-mainnet.g.alchemy.com/v2"],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
export const optimismGoerli: Chain = {
|
|
80
|
-
...vopg,
|
|
81
|
-
rpcUrls: {
|
|
82
|
-
...vopg.rpcUrls,
|
|
83
|
-
alchemy: {
|
|
84
|
-
http: ["https://opt-goerli.g.alchemy.com/v2"],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
export const optimismSepolia: Chain = {
|
|
89
|
-
...vops,
|
|
90
|
-
rpcUrls: {
|
|
91
|
-
...vops.rpcUrls,
|
|
92
|
-
alchemy: {
|
|
93
|
-
http: ["https://opt-sepolia.g.alchemy.com/v2"],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
export const sepolia: Chain = {
|
|
98
|
-
...vsep,
|
|
99
|
-
rpcUrls: {
|
|
100
|
-
...vsep.rpcUrls,
|
|
101
|
-
alchemy: {
|
|
102
|
-
http: ["https://eth-sepolia.g.alchemy.com/v2"],
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
export const base: Chain = {
|
|
107
|
-
...vbase,
|
|
108
|
-
rpcUrls: {
|
|
109
|
-
...vbase.rpcUrls,
|
|
110
|
-
alchemy: {
|
|
111
|
-
http: ["https://base-mainnet.g.alchemy.com/v2"],
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
export const baseGoerli: Chain = {
|
|
116
|
-
...vbaseg,
|
|
117
|
-
rpcUrls: {
|
|
118
|
-
...vbaseg.rpcUrls,
|
|
119
|
-
alchemy: {
|
|
120
|
-
http: ["https://base-goerli.g.alchemy.com/v2"],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
export const baseSepolia: Chain = {
|
|
125
|
-
...vbases,
|
|
126
|
-
rpcUrls: {
|
|
127
|
-
...vbases.rpcUrls,
|
|
128
|
-
alchemy: {
|
|
129
|
-
http: ["https://base-sepolia.g.alchemy.com/v2"],
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const polygonMumbai: Chain = {
|
|
135
|
-
...vpgm,
|
|
136
|
-
rpcUrls: {
|
|
137
|
-
...vpgm.rpcUrls,
|
|
138
|
-
alchemy: {
|
|
139
|
-
http: ["https://polygon-mumbai.g.alchemy.com/v2"],
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const polygonAmoy: Chain = {
|
|
145
|
-
...vpga,
|
|
146
|
-
rpcUrls: {
|
|
147
|
-
...vpga.rpcUrls,
|
|
148
|
-
alchemy: {
|
|
149
|
-
http: ["https://polygon-amoy.g.alchemy.com/v2"],
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export const polygon: Chain = {
|
|
155
|
-
...vpg,
|
|
156
|
-
rpcUrls: {
|
|
157
|
-
...vpg.rpcUrls,
|
|
158
|
-
alchemy: {
|
|
159
|
-
http: ["https://polygon-mainnet.g.alchemy.com/v2"],
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export const fraxtal: Chain = {
|
|
165
|
-
...vfrax,
|
|
166
|
-
rpcUrls: {
|
|
167
|
-
...vfrax.rpcUrls,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export const fraxtalSepolia: Chain = defineChain({
|
|
172
|
-
id: 2523,
|
|
173
|
-
name: "Fraxtal Sepolia",
|
|
174
|
-
nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
|
|
175
|
-
rpcUrls: {
|
|
176
|
-
default: {
|
|
177
|
-
http: ["https://rpc.testnet-sepolia.frax.com"],
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
export const zora: Chain = {
|
|
183
|
-
...vzora,
|
|
184
|
-
rpcUrls: {
|
|
185
|
-
...vzora.rpcUrls,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export const zoraSepolia: Chain = {
|
|
190
|
-
...vzoras,
|
|
191
|
-
rpcUrls: {
|
|
192
|
-
...vzoras.rpcUrls,
|
|
193
|
-
},
|
|
194
|
-
};
|