permissionless 0.0.13 → 0.0.15

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/_cjs/accounts/index.js +3 -1
  3. package/_cjs/accounts/index.js.map +1 -1
  4. package/_cjs/accounts/kernel/abi/KernelAccountAbi.js +84 -0
  5. package/_cjs/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
  6. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +211 -0
  7. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
  8. package/_cjs/accounts/signerToSafeSmartAccount.js +2 -2
  9. package/_cjs/actions/pimlico/sponsorUserOperation.js +12 -4
  10. package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
  11. package/_cjs/actions/pimlico/validateSponsorshipPolicies.js +16 -0
  12. package/_cjs/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
  13. package/_cjs/actions/pimlico.js +3 -1
  14. package/_cjs/actions/pimlico.js.map +1 -1
  15. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  16. package/_cjs/clients/decorators/pimlico.js +3 -1
  17. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  18. package/_cjs/utils/getRequiredPrefund.js +12 -0
  19. package/_cjs/utils/getRequiredPrefund.js.map +1 -0
  20. package/_cjs/utils/index.js +3 -1
  21. package/_cjs/utils/index.js.map +1 -1
  22. package/_esm/accounts/index.js +2 -1
  23. package/_esm/accounts/index.js.map +1 -1
  24. package/_esm/accounts/kernel/abi/KernelAccountAbi.js +87 -0
  25. package/_esm/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
  26. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +262 -0
  27. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
  28. package/_esm/accounts/signerToSafeSmartAccount.js +2 -2
  29. package/_esm/actions/pimlico/sponsorUserOperation.js +13 -5
  30. package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
  31. package/_esm/actions/pimlico/validateSponsorshipPolicies.js +47 -0
  32. package/_esm/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
  33. package/_esm/actions/pimlico.js +2 -1
  34. package/_esm/actions/pimlico.js.map +1 -1
  35. package/_esm/clients/createSmartAccountClient.js +1 -1
  36. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  37. package/_esm/clients/decorators/pimlico.js +38 -1
  38. package/_esm/clients/decorators/pimlico.js.map +1 -1
  39. package/_esm/utils/getRequiredPrefund.js +22 -0
  40. package/_esm/utils/getRequiredPrefund.js.map +1 -0
  41. package/_esm/utils/index.js +2 -1
  42. package/_esm/utils/index.js.map +1 -1
  43. package/_types/accounts/index.d.ts +2 -1
  44. package/_types/accounts/index.d.ts.map +1 -1
  45. package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts +68 -0
  46. package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts.map +1 -0
  47. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +25 -0
  48. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -0
  49. package/_types/actions/pimlico/sponsorUserOperation.d.ts +4 -3
  50. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  51. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +54 -0
  52. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -0
  53. package/_types/actions/pimlico.d.ts +4 -3
  54. package/_types/actions/pimlico.d.ts.map +1 -1
  55. package/_types/clients/createSmartAccountClient.d.ts +6 -1
  56. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  57. package/_types/clients/decorators/pimlico.d.ts +40 -3
  58. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  59. package/_types/types/pimlico.d.ts +21 -1
  60. package/_types/types/pimlico.d.ts.map +1 -1
  61. package/_types/utils/getRequiredPrefund.d.ts +20 -0
  62. package/_types/utils/getRequiredPrefund.d.ts.map +1 -0
  63. package/_types/utils/index.d.ts +2 -1
  64. package/_types/utils/index.d.ts.map +1 -1
  65. package/accounts/index.ts +8 -1
  66. package/accounts/kernel/abi/KernelAccountAbi.ts +87 -0
  67. package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +363 -0
  68. package/accounts/signerToSafeSmartAccount.ts +2 -2
  69. package/actions/pimlico/sponsorUserOperation.ts +20 -7
  70. package/actions/pimlico/validateSponsorshipPolicies.ts +76 -0
  71. package/actions/pimlico.ts +13 -4
  72. package/clients/createSmartAccountClient.ts +6 -1
  73. package/clients/decorators/pimlico.ts +52 -5
  74. package/package.json +1 -1
  75. package/types/pimlico.ts +21 -1
  76. package/utils/getRequiredPrefund.ts +31 -0
  77. package/utils/index.ts +6 -0
@@ -0,0 +1,262 @@
1
+ import { concatHex, encodeFunctionData, isAddressEqual } from "viem";
2
+ import { toAccount } from "viem/accounts";
3
+ import { getBytecode, getChainId, readContract, signMessage, signTypedData } from "viem/actions";
4
+ import { getAccountNonce } from "../../actions/public/getAccountNonce.js";
5
+ import { getSenderAddress } from "../../actions/public/getSenderAddress.js";
6
+ import { getUserOperationHash } from "../../utils/getUserOperationHash.js";
7
+ import { SignTransactionNotSupportedBySmartAccount } from "../types.js";
8
+ import { KernelExecuteAbi, KernelInitAbi } from "./abi/KernelAccountAbi.js";
9
+ /**
10
+ * The account creation ABI for a kernel smart account (from the KernelFactory)
11
+ */
12
+ const createAccountAbi = [
13
+ {
14
+ inputs: [
15
+ {
16
+ internalType: "address",
17
+ name: "_implementation",
18
+ type: "address"
19
+ },
20
+ {
21
+ internalType: "bytes",
22
+ name: "_data",
23
+ type: "bytes"
24
+ },
25
+ {
26
+ internalType: "uint256",
27
+ name: "_index",
28
+ type: "uint256"
29
+ }
30
+ ],
31
+ name: "createAccount",
32
+ outputs: [
33
+ {
34
+ internalType: "address",
35
+ name: "proxy",
36
+ type: "address"
37
+ }
38
+ ],
39
+ stateMutability: "payable",
40
+ type: "function"
41
+ }
42
+ ];
43
+ /**
44
+ * Default addresses for kernel smart account
45
+ */
46
+ const KERNEL_ADDRESSES = {
47
+ ECDSA_VALIDATOR: "0xd9AB5096a832b9ce79914329DAEE236f8Eea0390",
48
+ ACCOUNT_V2_2_LOGIC: "0x0DA6a956B9488eD4dd761E59f52FDc6c8068E6B5",
49
+ FACTORY_ADDRESS: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3"
50
+ };
51
+ /**
52
+ * Get the account initialization code for a kernel smart account
53
+ * @param owner
54
+ * @param index
55
+ * @param factoryAddress
56
+ * @param accountLogicAddress
57
+ * @param ecdsaValidatorAddress
58
+ */
59
+ const getAccountInitCode = async ({ owner, index, factoryAddress, accountLogicAddress, ecdsaValidatorAddress }) => {
60
+ if (!owner)
61
+ throw new Error("Owner account not found");
62
+ // Build the account initialization data
63
+ const initialisationData = encodeFunctionData({
64
+ abi: KernelInitAbi,
65
+ functionName: "initialize",
66
+ args: [ecdsaValidatorAddress, owner]
67
+ });
68
+ // Build the account init code
69
+ return concatHex([
70
+ factoryAddress,
71
+ encodeFunctionData({
72
+ abi: createAccountAbi,
73
+ functionName: "createAccount",
74
+ args: [accountLogicAddress, initialisationData, index]
75
+ })
76
+ ]);
77
+ };
78
+ /**
79
+ * Check the validity of an existing account address, or fetch the pre-deterministic account address for a kernel smart wallet
80
+ * @param client
81
+ * @param owner
82
+ * @param entryPoint
83
+ * @param ecdsaValidatorAddress
84
+ * @param initCodeProvider
85
+ * @param deployedAccountAddress
86
+ */
87
+ const getAccountAddress = async ({ client, owner, entryPoint, initCodeProvider, ecdsaValidatorAddress, deployedAccountAddress }) => {
88
+ // If we got an already deployed account, ensure it's well deployed, and the validator & signer are correct
89
+ if (deployedAccountAddress !== undefined) {
90
+ // Get the owner of the deployed account, ensure it's the same as the owner given in params
91
+ const deployedAccountOwner = await readContract(client, {
92
+ address: ecdsaValidatorAddress,
93
+ abi: [
94
+ {
95
+ inputs: [
96
+ {
97
+ internalType: "address",
98
+ name: "",
99
+ type: "address"
100
+ }
101
+ ],
102
+ name: "ecdsaValidatorStorage",
103
+ outputs: [
104
+ {
105
+ internalType: "address",
106
+ name: "owner",
107
+ type: "address"
108
+ }
109
+ ],
110
+ stateMutability: "view",
111
+ type: "function"
112
+ }
113
+ ],
114
+ functionName: "ecdsaValidatorStorage",
115
+ args: [deployedAccountAddress]
116
+ });
117
+ // Ensure the address match
118
+ if (!isAddressEqual(deployedAccountOwner, owner)) {
119
+ throw new Error("Invalid owner for the already deployed account");
120
+ }
121
+ // If ok, return the address
122
+ return deployedAccountAddress;
123
+ }
124
+ // Find the init code for this account
125
+ const initCode = await initCodeProvider();
126
+ // Get the sender address based on the init code
127
+ return getSenderAddress(client, {
128
+ initCode,
129
+ entryPoint
130
+ });
131
+ };
132
+ /**
133
+ * Build a kernel smart account from a private key, that use the ECDSA signer behind the scene
134
+ * @param client
135
+ * @param privateKey
136
+ * @param entryPoint
137
+ * @param index
138
+ * @param factoryAddress
139
+ * @param accountLogicAddress
140
+ * @param ecdsaValidatorAddress
141
+ * @param deployedAccountAddress
142
+ */
143
+ export async function signerToEcdsaKernelSmartAccount(client, { signer, entryPoint, index = 0n, factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS, accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_V2_2_LOGIC, ecdsaValidatorAddress = KERNEL_ADDRESSES.ECDSA_VALIDATOR, deployedAccountAddress }) {
144
+ // Get the private key related account
145
+ const viemSigner = signer.type === "local"
146
+ ? {
147
+ ...signer,
148
+ signTransaction: (_, __) => {
149
+ throw new SignTransactionNotSupportedBySmartAccount();
150
+ }
151
+ }
152
+ : signer;
153
+ // Helper to generate the init code for the smart account
154
+ const generateInitCode = () => getAccountInitCode({
155
+ owner: viemSigner.address,
156
+ index,
157
+ factoryAddress,
158
+ accountLogicAddress,
159
+ ecdsaValidatorAddress
160
+ });
161
+ // Fetch account address and chain id
162
+ const [accountAddress, chainId] = await Promise.all([
163
+ getAccountAddress({
164
+ client,
165
+ entryPoint,
166
+ owner: viemSigner.address,
167
+ ecdsaValidatorAddress,
168
+ initCodeProvider: generateInitCode,
169
+ deployedAccountAddress
170
+ }),
171
+ getChainId(client)
172
+ ]);
173
+ if (!accountAddress)
174
+ throw new Error("Account address not found");
175
+ // Build the EOA Signer
176
+ const account = toAccount({
177
+ address: accountAddress,
178
+ async signMessage({ message }) {
179
+ return signMessage(client, { account: viemSigner, message });
180
+ },
181
+ async signTransaction(_, __) {
182
+ throw new SignTransactionNotSupportedBySmartAccount();
183
+ },
184
+ async signTypedData(typedData) {
185
+ return signTypedData(client, { account: viemSigner, ...typedData });
186
+ }
187
+ });
188
+ return {
189
+ ...account,
190
+ client: client,
191
+ publicKey: accountAddress,
192
+ entryPoint: entryPoint,
193
+ source: "kernelEcdsaSmartAccount",
194
+ // Get the nonce of the smart account
195
+ async getNonce() {
196
+ return getAccountNonce(client, {
197
+ sender: accountAddress,
198
+ entryPoint: entryPoint
199
+ });
200
+ },
201
+ // Sign a user operation
202
+ async signUserOperation(userOperation) {
203
+ const hash = getUserOperationHash({
204
+ userOperation: {
205
+ ...userOperation,
206
+ signature: "0x"
207
+ },
208
+ entryPoint: entryPoint,
209
+ chainId: chainId
210
+ });
211
+ const signature = await signMessage(client, {
212
+ account: viemSigner,
213
+ message: { raw: hash }
214
+ });
215
+ // Always use the sudo mode, since we will use external paymaster
216
+ return concatHex(["0x00000000", signature]);
217
+ },
218
+ // Encode the init code
219
+ async getInitCode() {
220
+ const contractCode = await getBytecode(client, {
221
+ address: accountAddress
222
+ });
223
+ if ((contractCode?.length ?? 0) > 2)
224
+ return "0x";
225
+ return generateInitCode();
226
+ },
227
+ // Encode the deploy call data
228
+ async encodeDeployCallData(_) {
229
+ throw new Error("Simple account doesn't support account deployment");
230
+ },
231
+ // Encode a call
232
+ async encodeCallData(_tx) {
233
+ if (Array.isArray(_tx)) {
234
+ // Encode a batched call
235
+ return encodeFunctionData({
236
+ abi: KernelExecuteAbi,
237
+ functionName: "executeBatch",
238
+ args: [
239
+ _tx.map((tx) => ({
240
+ to: tx.to,
241
+ value: tx.value,
242
+ data: tx.data
243
+ }))
244
+ ]
245
+ });
246
+ }
247
+ else {
248
+ // Encode a simple call
249
+ return encodeFunctionData({
250
+ abi: KernelExecuteAbi,
251
+ functionName: "execute",
252
+ args: [_tx.to, _tx.value, _tx.data, 0]
253
+ });
254
+ }
255
+ },
256
+ // Get simple dummy signature
257
+ async getDummySignature() {
258
+ return "0x00000000fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
259
+ }
260
+ };
261
+ }
262
+ //# sourceMappingURL=signerToEcdsaKernelSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerToEcdsaKernelSmartAccount.js","sourceRoot":"","sources":["../../../accounts/kernel/signerToEcdsaKernelSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,SAAS,EACT,kBAAkB,EAClB,cAAc,EACjB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EACH,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAE1E,OAAO,EACH,yCAAyC,EAE5C,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAO3E;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACrB;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI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xE,CAAC;QAED,gBAAgB;QAChB,KAAK,CAAC,cAAc,CAAC,GAAG;YACpB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACpB,wBAAwB;gBACxB,OAAO,kBAAkB,CAAC;oBACtB,GAAG,EAAE,gBAAgB;oBACrB,YAAY,EAAE,cAAc;oBAC5B,IAAI,EAAE;wBACF,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;4BACb,EAAE,EAAE,EAAE,CAAC,EAAE;4BACT,KAAK,EAAE,EAAE,CAAC,KAAK;4BACf,IAAI,EAAE,EAAE,CAAC,IAAI;yBAChB,CAAC,CAAC;qBACN;iBACJ,CAAC,CAAA;aACL;iBAAM;gBACH,uBAAuB;gBACvB,OAAO,kBAAkB,CAAC;oBACtB,GAAG,EAAE,gBAAgB;oBACrB,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;iBACzC,CAAC,CAAA;aACL;QACL,CAAC;QAED,6BAA6B;QAC7B,KAAK,CAAC,iBAAiB;YACnB,OAAO,8IAA8I,CAAA;QACzJ,CAAC;KACJ,CAAA;AACL,CAAC"}
@@ -18,8 +18,8 @@ const EIP712_SAFE_OPERATION_TYPE = {
18
18
  };
19
19
  const SAFE_VERSION_TO_ADDRESSES_MAP = {
20
20
  "1.4.1": {
21
- ADD_MODULES_LIB_ADDRESS: "0x191EFDC03615B575922289DC339F4c70aC5C30Af",
22
- SAFE_4337_MODULE_ADDRESS: "0x39E54Bb2b3Aa444b4B39DEe15De3b7809c36Fc38",
21
+ ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
22
+ SAFE_4337_MODULE_ADDRESS: "0xa581c4A4DB7175302464fF3C06380BC3270b4037",
23
23
  SAFE_PROXY_FACTORY_ADDRESS: "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
24
24
  SAFE_SINGLETON_ADDRESS: "0x41675C099F32341bf84BFc5382aF534df5C7461a",
25
25
  MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
@@ -5,7 +5,7 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
5
5
  * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
6
6
  *
7
7
  * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
8
- * @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
8
+ * @param args {@link PimlocoSponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
9
9
  * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
10
10
  *
11
11
  *
@@ -27,10 +27,18 @@ import { deepHexlify } from "../../utils/deepHexlify.js";
27
27
  export const sponsorUserOperation = async (client, args) => {
28
28
  const response = await client.request({
29
29
  method: "pm_sponsorUserOperation",
30
- params: [
31
- deepHexlify(args.userOperation),
32
- args.entryPoint
33
- ]
30
+ params: args.sponsorshipPolicyId
31
+ ? [
32
+ deepHexlify(args.userOperation),
33
+ args.entryPoint,
34
+ {
35
+ sponsorshipPolicyId: args.sponsorshipPolicyId
36
+ }
37
+ ]
38
+ : [
39
+ deepHexlify(args.userOperation),
40
+ args.entryPoint
41
+ ]
34
42
  });
35
43
  return {
36
44
  paymasterAndData: response.paymasterAndData,
@@ -1 +1 @@
1
- {"version":3,"file":"sponsorUserOperation.js","sourceRoot":"","sources":["../../../actions/pimlico/sponsorUserOperation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAoBxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAKrC,MAAuE,EACvE,IAAoC,EACG,EAAE;IACzC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C,QAAQ,CAAC,oBAAoB,CAAC;QAC3D,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;KAC9C,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { deepHexlify } from "../../utils/deepHexlify.js";
2
+ /**
3
+ * Returns valid sponsorship policies for a userOperation from the list of ids passed
4
+ * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
5
+ *
6
+ * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
7
+ * @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
8
+ * @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
9
+ *
10
+ * @example
11
+ * import { createClient } from "viem"
12
+ * import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
13
+ *
14
+ * const bundlerClient = createClient({
15
+ * chain: goerli,
16
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
17
+ * })
18
+ *
19
+ * await validateSponsorshipPolicies(bundlerClient, {
20
+ * userOperation: userOperationWithDummySignature,
21
+ * entryPoint: entryPoint,
22
+ * sponsorshipPolicyIds: ["sp_shiny_puma"]
23
+ * })
24
+ * Returns
25
+ * [
26
+ * {
27
+ * sponsorshipPolicyId: "sp_shiny_puma",
28
+ * data: {
29
+ * name: "Shiny Puma",
30
+ * author: "Pimlico",
31
+ * icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
32
+ * description: "This policy is for testing purposes only"
33
+ * }
34
+ * }
35
+ * ]
36
+ */
37
+ export const validateSponsorshipPolicies = async (client, args) => {
38
+ return await client.request({
39
+ method: "pm_validateSponsorshipPolicies",
40
+ params: [
41
+ deepHexlify(args.userOperation),
42
+ args.entryPoint,
43
+ args.sponsorshipPolicyIds
44
+ ]
45
+ });
46
+ };
47
+ //# sourceMappingURL=validateSponsorshipPolicies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateSponsorshipPolicies.js","sourceRoot":"","sources":["../../../actions/pimlico/validateSponsorshipPolicies.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAkBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAK5C,MAAuE,EACvE,IAA2C,EACG,EAAE;IAChD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QACxB,MAAM,EAAE,gCAAgC;QACxC,MAAM,EAAE;YACJ,WAAW,CAAC,IAAI,CAAC,aAAa,CAAiC;YAC/D,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,oBAAoB;SAC5B;KACJ,CAAC,CAAA;AACN,CAAC,CAAA"}
@@ -2,5 +2,6 @@ import { getUserOperationGasPrice } from "./pimlico/getUserOperationGasPrice.js"
2
2
  import { getUserOperationStatus } from "./pimlico/getUserOperationStatus.js";
3
3
  import { sponsorUserOperation } from "./pimlico/sponsorUserOperation.js";
4
4
  import { pimlicoBundlerActions, pimlicoPaymasterActions } from "../clients/decorators/pimlico.js";
5
- export { getUserOperationGasPrice, getUserOperationStatus, sponsorUserOperation, pimlicoBundlerActions, pimlicoPaymasterActions };
5
+ import { validateSponsorshipPolicies } from "./pimlico/validateSponsorshipPolicies.js";
6
+ export { getUserOperationGasPrice, getUserOperationStatus, sponsorUserOperation, pimlicoBundlerActions, pimlicoPaymasterActions, validateSponsorshipPolicies };
6
7
  //# sourceMappingURL=pimlico.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAGH,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAGH,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;AAM1C,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,kCAAkC,CAAA;AAYzC,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EAC1B,CAAA"}
1
+ {"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAGH,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAGH,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;AAM1C,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAGH,2BAA2B,EAC9B,MAAM,0CAA0C,CAAA;AAcjD,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC9B,CAAA"}
@@ -10,7 +10,7 @@ import { smartAccountActions } from "./decorators/smartAccount.js";
10
10
  *
11
11
  * A Bundler Client is an interface to "erc 4337" [JSON-RPC API](https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace) methods such as sending user operation, estimating gas for a user operation, get user operation receipt, etc through Bundler Actions.
12
12
  *
13
- * @param config - {@link WalletClientConfig}
13
+ * @param parameters - {@link WalletClientConfig}
14
14
  * @returns A Bundler Client. {@link SmartAccountClient}
15
15
  *
16
16
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"createSmartAccountClient.js","sourceRoot":"","sources":["../../clients/createSmartAccountClient.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAqB,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAuC,MAAM,wDAAwD,CAAA;AAC5G,OAAO,EAAyB,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAEH,mBAAmB,EACtB,MAAM,8BAA8B,CAAA;AAiCrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAKpC,UACkC,EACiC,EAAE;IACrE,MAAM,EACF,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,sBAAsB,EAC7B,SAAS,EACZ,GAAG,UAAU,CAAA;IACd,MAAM,MAAM,GAAG,YAAY,CAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAC1D,IAAI,EAAE,oBAAoB;KAC7B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,CAChB,mBAAmB,CAAC;QAChB,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;KACxD,CAAC,CACL,CAAA;AACL,CAAC,CAAA"}
1
+ {"version":3,"file":"createSmartAccountClient.js","sourceRoot":"","sources":["../../clients/createSmartAccountClient.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAqB,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAuC,MAAM,wDAAwD,CAAA;AAC5G,OAAO,EAAyB,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAEH,mBAAmB,EACtB,MAAM,8BAA8B,CAAA;AAsCrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAKpC,UACkC,EACiC,EAAE;IACrE,MAAM,EACF,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,sBAAsB,EAC7B,SAAS,EACZ,GAAG,UAAU,CAAA;IACd,MAAM,MAAM,GAAG,YAAY,CAAC;QACxB,GAAG,UAAU;QACb,GAAG;QACH,IAAI;QACJ,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;QAC1D,IAAI,EAAE,oBAAoB;KAC7B,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,CAChB,mBAAmB,CAAC;QAChB,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;KACxD,CAAC,CACL,CAAA;AACL,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { validateSponsorshipPolicies } from "../../actions/pimlico.js";
1
2
  import { getUserOperationGasPrice } from "../../actions/pimlico/getUserOperationGasPrice.js";
2
3
  import { getUserOperationStatus } from "../../actions/pimlico/getUserOperationStatus.js";
3
4
  import { sponsorUserOperation } from "../../actions/pimlico/sponsorUserOperation.js";
@@ -5,8 +6,44 @@ export const pimlicoBundlerActions = (client) => ({
5
6
  getUserOperationGasPrice: async () => getUserOperationGasPrice(client),
6
7
  getUserOperationStatus: async (args) => getUserOperationStatus(client, args)
7
8
  });
9
+ /**
10
+ * Returns valid sponsorship policies for a userOperation from the list of ids passed
11
+ * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
12
+ *
13
+ * @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
14
+ * @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
15
+ *
16
+ * @example
17
+ * import { createClient } from "viem"
18
+ * import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
19
+ *
20
+ * const bundlerClient = createClient({
21
+ * chain: goerli,
22
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
23
+ * }).extend(pimlicoPaymasterActions)
24
+
25
+ *
26
+ * await bundlerClient.validateSponsorshipPolicies({
27
+ * userOperation: userOperationWithDummySignature,
28
+ * entryPoint: entryPoint,
29
+ * sponsorshipPolicyIds: ["sp_shiny_puma"]
30
+ * })
31
+ * Returns
32
+ * [
33
+ * {
34
+ * sponsorshipPolicyId: "sp_shiny_puma",
35
+ * data: {
36
+ * name: "Shiny Puma",
37
+ * author: "Pimlico",
38
+ * icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
39
+ * description: "This policy is for testing purposes only"
40
+ * }
41
+ * }
42
+ * ]
43
+ */
8
44
  export const pimlicoPaymasterActions = (client) => ({
9
- sponsorUserOperation: async (args) => sponsorUserOperation(client, args)
45
+ sponsorUserOperation: async (args) => sponsorUserOperation(client, args),
46
+ validateSponsorshipPolicies: async (args) => validateSponsorshipPolicies(client, args)
10
47
  });
11
48
  /**
12
49
  * TODO: Add support for pimlicoActions after we support all the actions of v2 of the Pimlico API.
@@ -1 +1 @@
1
- {"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../../clients/decorators/pimlico.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAGH,sBAAsB,EACzB,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAGH,oBAAoB,EACvB,MAAM,+CAA+C,CAAA;AAmDtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACjC,MAAc,EACO,EAAE,CAAC,CAAC;IACzB,wBAAwB,EAAE,KAAK,IAAI,EAAE,CACjC,wBAAwB,CAAC,MAA8B,CAAC;IAC5D,sBAAsB,EAAE,KAAK,EAAE,IAAsC,EAAE,EAAE,CACrE,sBAAsB,CAAC,MAA8B,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AA+BF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACnC,MAAc,EACe,EAAE,CAAC,CAAC;IACjC,oBAAoB,EAAE,KAAK,EAAE,IAAoC,EAAE,EAAE,CACjE,oBAAoB,CAAC,MAAgC,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AAEF;;GAEG;AACH,sDAAsD;AACtD,eAAe;AACf,4CAA4C;AAC5C,6CAA6C;AAC7C,QAAQ;AACR,IAAI"}
1
+ {"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../../clients/decorators/pimlico.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,2BAA2B,EAC9B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEH,wBAAwB,EAC3B,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAGH,sBAAsB,EACzB,MAAM,iDAAiD,CAAA;AACxD,OAAO,EAGH,oBAAoB,EACvB,MAAM,+CAA+C,CAAA;AAmDtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACjC,MAAc,EACO,EAAE,CAAC,CAAC;IACzB,wBAAwB,EAAE,KAAK,IAAI,EAAE,CACjC,wBAAwB,CAAC,MAA8B,CAAC;IAC5D,sBAAsB,EAAE,KAAK,EAAE,IAAsC,EAAE,EAAE,CACrE,sBAAsB,CAAC,MAA8B,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AAmCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACnC,MAAc,EACe,EAAE,CAAC,CAAC;IACjC,oBAAoB,EAAE,KAAK,EAAE,IAA2C,EAAE,EAAE,CACxE,oBAAoB,CAAC,MAAgC,EAAE,IAAI,CAAC;IAChE,2BAA2B,EAAE,KAAK,EAC9B,IAA2C,EAC7C,EAAE,CAAC,2BAA2B,CAAC,MAAgC,EAAE,IAAI,CAAC;CAC3E,CAAC,CAAA;AAEF;;GAEG;AACH,sDAAsD;AACtD,eAAe;AACf,4CAA4C;AAC5C,6CAA6C;AAC7C,QAAQ;AACR,IAAI"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * Returns the minimum required funds in the senders's smart account to execute the user operation.
4
+ *
5
+ * @param arags: {userOperation} as {@link UserOperation}
6
+ * @returns requiredPrefund as {@link bigint}
7
+ *
8
+ * @example
9
+ * import { getRequiredPrefund } from "permissionless/utils"
10
+ *
11
+ * const requiredPrefund = getRequiredPrefund({
12
+ * userOperation
13
+ * })
14
+ */
15
+ export const getRequiredPrefund = ({ userOperation }) => {
16
+ const multiplier = userOperation.paymasterAndData.length > 2 ? 3n : 1n;
17
+ const requiredGas = userOperation.callGasLimit +
18
+ userOperation.verificationGasLimit * multiplier +
19
+ userOperation.preVerificationGas;
20
+ return BigInt(requiredGas) * BigInt(userOperation.maxFeePerGas);
21
+ };
22
+ //# sourceMappingURL=getRequiredPrefund.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequiredPrefund.js","sourceRoot":"","sources":["../../utils/getRequiredPrefund.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAC/B,aAAa,EACc,EAAU,EAAE;IACvC,MAAM,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACtE,MAAM,WAAW,GACb,aAAa,CAAC,YAAY;QAC1B,aAAa,CAAC,oBAAoB,GAAG,UAAU;QAC/C,aAAa,CAAC,kBAAkB,CAAA;IAEpC,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAA;AACnE,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { getRequiredPrefund } from "./getRequiredPrefund.js";
1
2
  import { getUserOperationHash } from "./getUserOperationHash.js";
2
3
  import { AccountOrClientNotFoundError, signUserOperationHashWithECDSA } from "./signUserOperationHashWithECDSA.js";
3
4
  export function parseAccount(account) {
@@ -5,5 +6,5 @@ export function parseAccount(account) {
5
6
  return { address: account, type: "json-rpc" };
6
7
  return account;
7
8
  }
8
- export { getUserOperationHash, signUserOperationHashWithECDSA, AccountOrClientNotFoundError };
9
+ export { getUserOperationHash, getRequiredPrefund, signUserOperationHashWithECDSA, AccountOrClientNotFoundError };
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,oBAAoB,EACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,4BAA4B,EAC5B,8BAA8B,EACjC,MAAM,qCAAqC,CAAA;AAE5C,MAAM,UAAU,YAAY,CAAC,OAA0B;IACnD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;IACjD,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,OAAO,EACH,oBAAoB,EAEpB,8BAA8B,EAC9B,4BAA4B,EAC/B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,kBAAkB,EACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEH,oBAAoB,EACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,4BAA4B,EAC5B,8BAA8B,EACjC,MAAM,qCAAqC,CAAA;AAE5C,MAAM,UAAU,YAAY,CAAC,OAA0B;IACnD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;IACjD,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAGlB,8BAA8B,EAC9B,4BAA4B,EAC/B,CAAA"}
@@ -2,6 +2,7 @@ import { privateKeyToSimpleSmartAccount } from "./privateKeyToSimpleSmartAccount
2
2
  import { type SimpleSmartAccount, signerToSimpleSmartAccount } from "./signerToSimpleSmartAccount.js";
3
3
  import { privateKeyToSafeSmartAccount } from "./privateKeyToSafeSmartAccount.js";
4
4
  import { type SafeSmartAccount, type SafeVersion, signerToSafeSmartAccount } from "./signerToSafeSmartAccount.js";
5
+ import { type KernelEcdsaSmartAccount, signerToEcdsaKernelSmartAccount } from "./kernel/signerToEcdsaKernelSmartAccount.js";
5
6
  import { SignTransactionNotSupportedBySmartAccount, type SmartAccount, type SmartAccountSigner } from "./types.js";
6
- export { type SafeVersion, type SmartAccountSigner, type SafeSmartAccount, signerToSafeSmartAccount, type SimpleSmartAccount, signerToSimpleSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToSimpleSmartAccount, type SmartAccount, privateKeyToSafeSmartAccount };
7
+ export { type SafeVersion, type SmartAccountSigner, type SafeSmartAccount, signerToSafeSmartAccount, type SimpleSmartAccount, signerToSimpleSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToSimpleSmartAccount, type SmartAccount, privateKeyToSafeSmartAccount, type KernelEcdsaSmartAccount, signerToEcdsaKernelSmartAccount };
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AAEpF,OAAO,EACH,KAAK,kBAAkB,EACvB,0BAA0B,EAC7B,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAEhF,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,wBAAwB,EAC3B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACH,yCAAyC,EACzC,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAC1B,MAAM,YAAY,CAAA;AAEnB,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,0BAA0B,EAC1B,yCAAyC,EACzC,8BAA8B,EAC9B,KAAK,YAAY,EACjB,4BAA4B,EAC/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AAEpF,OAAO,EACH,KAAK,kBAAkB,EACvB,0BAA0B,EAC7B,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAEhF,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,wBAAwB,EAC3B,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACH,KAAK,uBAAuB,EAC5B,+BAA+B,EAClC,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EACH,yCAAyC,EACzC,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAC1B,MAAM,YAAY,CAAA;AAEnB,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,0BAA0B,EAC1B,yCAAyC,EACzC,8BAA8B,EAC9B,KAAK,YAAY,EACjB,4BAA4B,EAC5B,KAAK,uBAAuB,EAC5B,+BAA+B,EAClC,CAAA"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The exeute abi, used to execute a transaction on the kernel smart account
3
+ */
4
+ export declare const KernelExecuteAbi: readonly [{
5
+ readonly inputs: readonly [{
6
+ readonly internalType: "address";
7
+ readonly name: "to";
8
+ readonly type: "address";
9
+ }, {
10
+ readonly internalType: "uint256";
11
+ readonly name: "value";
12
+ readonly type: "uint256";
13
+ }, {
14
+ readonly internalType: "bytes";
15
+ readonly name: "data";
16
+ readonly type: "bytes";
17
+ }, {
18
+ readonly internalType: "enum Operation";
19
+ readonly name: "";
20
+ readonly type: "uint8";
21
+ }];
22
+ readonly name: "execute";
23
+ readonly outputs: readonly [];
24
+ readonly stateMutability: "payable";
25
+ readonly type: "function";
26
+ }, {
27
+ readonly inputs: readonly [{
28
+ readonly components: readonly [{
29
+ readonly internalType: "address";
30
+ readonly name: "to";
31
+ readonly type: "address";
32
+ }, {
33
+ readonly internalType: "uint256";
34
+ readonly name: "value";
35
+ readonly type: "uint256";
36
+ }, {
37
+ readonly internalType: "bytes";
38
+ readonly name: "data";
39
+ readonly type: "bytes";
40
+ }];
41
+ readonly internalType: "struct Call[]";
42
+ readonly name: "calls";
43
+ readonly type: "tuple[]";
44
+ }];
45
+ readonly name: "executeBatch";
46
+ readonly outputs: readonly [];
47
+ readonly stateMutability: "payable";
48
+ readonly type: "function";
49
+ }];
50
+ /**
51
+ * The init abi, used to initialise kernel account
52
+ */
53
+ export declare const KernelInitAbi: readonly [{
54
+ readonly inputs: readonly [{
55
+ readonly internalType: "contract IKernelValidator";
56
+ readonly name: "_defaultValidator";
57
+ readonly type: "address";
58
+ }, {
59
+ readonly internalType: "bytes";
60
+ readonly name: "_data";
61
+ readonly type: "bytes";
62
+ }];
63
+ readonly name: "initialize";
64
+ readonly outputs: readonly [];
65
+ readonly stateMutability: "payable";
66
+ readonly type: "function";
67
+ }];
68
+ //# sourceMappingURL=KernelAccountAbi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KernelAccountAbi.d.ts","sourceRoot":"","sources":["../../../../accounts/kernel/abi/KernelAccountAbi.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DnB,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;EAmBhB,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { type Address, type Chain, type Client, type Transport } from "viem";
2
+ import type { SmartAccount } from "../types.js";
3
+ import { type SmartAccountSigner } from "../types.js";
4
+ export type KernelEcdsaSmartAccount<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined> = SmartAccount<"kernelEcdsaSmartAccount", transport, chain>;
5
+ /**
6
+ * Build a kernel smart account from a private key, that use the ECDSA signer behind the scene
7
+ * @param client
8
+ * @param privateKey
9
+ * @param entryPoint
10
+ * @param index
11
+ * @param factoryAddress
12
+ * @param accountLogicAddress
13
+ * @param ecdsaValidatorAddress
14
+ * @param deployedAccountAddress
15
+ */
16
+ export declare function signerToEcdsaKernelSmartAccount<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined>(client: Client<TTransport, TChain>, { signer, entryPoint, index, factoryAddress, accountLogicAddress, ecdsaValidatorAddress, deployedAccountAddress }: {
17
+ signer: SmartAccountSigner;
18
+ entryPoint: Address;
19
+ index?: bigint;
20
+ factoryAddress?: Address;
21
+ accountLogicAddress?: Address;
22
+ ecdsaValidatorAddress?: Address;
23
+ deployedAccountAddress?: Address;
24
+ }): Promise<KernelEcdsaSmartAccount<TTransport, TChain>>;
25
+ //# sourceMappingURL=signerToEcdsaKernelSmartAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerToEcdsaKernelSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/kernel/signerToEcdsaKernelSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,SAAS,EAIjB,MAAM,MAAM,CAAA;AAYb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAEH,KAAK,kBAAkB,EAC1B,MAAM,aAAa,CAAA;AAGpB,MAAM,MAAM,uBAAuB,CAC/B,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,IACnD,YAAY,CAAC,yBAAyB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AAuK7D;;;;;;;;;;GAUG;AACH,wBAAsB,+BAA+B,CACjD,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAEpD,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,EAClC,EACI,MAAM,EACN,UAAU,EACV,KAAU,EACV,cAAiD,EACjD,mBAAyD,EACzD,qBAAwD,EACxD,sBAAsB,EACzB,EAAE;IACC,MAAM,EAAE,kBAAkB,CAAA;IAC1B,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACnC,GACF,OAAO,CAAC,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAkItD"}