forked from alchemyplatform/aa-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounts.ts
111 lines (105 loc) · 3.16 KB
/
accounts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import {
Account,
Address,
Chain,
GetContractReturnType,
Hex,
PublicClient,
Transport,
WalletClient,
} from "viem";
import {biconomy_v2} from "./accounts/biconomy-v2";
import {coinbaseSmartWallet} from "./accounts/coinbaseSmartWallet";
import {kernel} from "./accounts/kernel";
import {lightAccount} from "./accounts/lightAccount";
import {lightAccountV2} from "./accounts/lightAccountV2";
import {modularAccount} from "./accounts/modularAccount";
import {multiOwnerLightAccount} from "./accounts/multiOwnerLightAccount";
import {safe} from "./accounts/safe";
import {simpleAccount} from "./accounts/simpleAccount";
import {nexus} from "./accounts/nexus";
import {kernel_v3} from "./accounts/kernel-v3";
import {TOKEN_ARTIFACTS} from "./artifacts/tokens";
import {EntryPointV06, EntryPointV07} from "./utils/entryPoint";
import {PackedUserOperation, UserOperation} from "./utils/userOp";
export interface AccountData<
TEntryPoint extends EntryPointV06 | EntryPointV07,
TUserOperation extends
| UserOperation
| PackedUserOperation = TEntryPoint extends EntryPointV06
? UserOperation
: PackedUserOperation,
> {
entryPoint: TEntryPoint;
createAccount: (salt: bigint, ownerAddress: Address) => Promise<Address>;
getAccountAddress: (salt: bigint, ownerAddress: Address) => Promise<Address>;
getOwnerSignature: (
signer: WalletClient<Transport, Chain, Account>,
userOp: TUserOperation,
entryPoint: TEntryPoint,
) => Promise<Hex>;
encodeUserOpExecute: (to: Address, value: bigint, data: Hex) => Hex;
encodeRuntimeExecute?: (
to: Address,
value: bigint,
data: Hex,
owner?: WalletClient<Transport, Chain, Account>,
accountAddress?: Address,
) => Promise<Hex>;
getDummySignature: (userOp: TUserOperation) => Hex;
getInitCode: (salt: bigint, ownerAddress: Address) => Hex;
// Session key methods
installSessionKeyPlugin?: (
account: Address,
owner: WalletClient<Transport, Chain, Account>,
) => void;
addSessionKeyCalldata?: (
key: Hex,
target: Address,
tokens: GetContractReturnType<
typeof TOKEN_ARTIFACTS.USDC.abi,
PublicClient<Transport, Chain>
>[],
spendLimit: bigint,
account?: Address,
) => Hex;
getSessionKeySignature?: (
signer: WalletClient<Transport, Chain, Account>,
userOp: TUserOperation,
entryPoint: TEntryPoint,
) => Promise<Hex>;
useSessionKeyERC20TransferCalldata?: (
token: GetContractReturnType<
typeof TOKEN_ARTIFACTS.USDC.abi,
PublicClient<Transport, Chain>
>,
key: Hex,
to: Address,
amount: bigint,
) => Hex;
useSessionKeyNativeTokenTransferCalldata?: (
key: Hex,
to: Address,
amount: bigint,
) => Hex;
getNonceKey?: () => `0x${string}`;
}
export type AccountDataV06 = AccountData<EntryPointV06>;
export type AccountDataV07 = AccountData<EntryPointV07>;
export interface AccountConfig {
name: string;
accountFixture: () => Promise<AccountDataV06 | AccountDataV07>;
}
export const ACCOUNTS_TO_BENCHMARK: AccountConfig[] = [
modularAccount,
biconomy_v2,
kernel,
safe,
simpleAccount,
lightAccount,
lightAccountV2,
multiOwnerLightAccount,
coinbaseSmartWallet,
nexus,
kernel_v3,
];