Skip to content

Commit a8d4b45

Browse files
authored
Merge pull request #19 from pimlicolabs/chore/update-schema
Chore/update schema
2 parents 92d924d + 3c033e4 commit a8d4b45

3 files changed

Lines changed: 261 additions & 15 deletions

File tree

mock-contract-deployer/src/constants.ts

Lines changed: 18 additions & 0 deletions
Large diffs are not rendered by default.

mock-contract-deployer/src/index.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import {
2828
KERNEL_V07_META_FACTORY_CREATECALL,
2929
KERNEL_V07_ACCOUNT_V3_1_LOGIC_CREATECALL,
3030
KERNEL_V07_FACTORY_V3_1_CREATECALL,
31+
KERNEL_KERNEL_V3_3_FACTORY_CREATECALL,
32+
KERNEL_KERNEL_V3_3_DELEGATION_CREATECALL,
33+
KERNEL_V3_3_ECDSA_VALIDATOR_CREATECALL,
3134
LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
3235
SAFE_MULTI_SEND_CALL_ONLY_CREATECALL,
3336
SAFE_MULTI_SEND_CREATECALL,
@@ -41,6 +44,7 @@ import {
4144
SIMPLE_ACCOUNT_FACTORY_V06_CREATECALL,
4245
SIMPLE_ACCOUNT_FACTORY_V07_CREATECALL,
4346
SIMPLE_ACCOUNT_FACTORY_V08_CREATECALL,
47+
SIMPLE_7702_ACCOUNT_IMPLEMENTATION_V08_CREATECALL,
4448
} from "./constants";
4549

4650
const DETERMINISTIC_DEPLOYER = "0x4e59b44847b379578588920ca78fbf26c0b4956c";
@@ -159,6 +163,18 @@ const main = async () => {
159163
})
160164
.then(() => console.log("[V0.8 CORE] Deploying EntryPoint"));
161165

166+
walletClient
167+
.sendTransaction({
168+
to: DETERMINISTIC_DEPLOYER,
169+
data: SIMPLE_7702_ACCOUNT_IMPLEMENTATION_V08_CREATECALL,
170+
gas: 15_000_000n,
171+
nonce: nonce++,
172+
chain,
173+
})
174+
.then(() =>
175+
console.log("[V0.8 CORE] Deploying Simple7702AccountImplementation"),
176+
);
177+
162178
walletClient
163179
.sendTransaction({
164180
to: DETERMINISTIC_DEPLOYER,
@@ -445,6 +461,38 @@ const main = async () => {
445461
})
446462
.then(() => console.log("[KERNEL] Deploying V0.7 Factory V3_1"));
447463

464+
walletClient
465+
.sendTransaction({
466+
to: DETERMINISTIC_DEPLOYER,
467+
data: KERNEL_KERNEL_V3_3_DELEGATION_CREATECALL,
468+
gas: 15_000_000n,
469+
nonce: nonce++,
470+
chain,
471+
})
472+
.then(() =>
473+
console.log("[KERNEL] Deploying KERNEL V3.3 DELEGATION ADDRESS "),
474+
);
475+
476+
walletClient
477+
.sendTransaction({
478+
to: DETERMINISTIC_DEPLOYER,
479+
data: KERNEL_V3_3_ECDSA_VALIDATOR_CREATECALL,
480+
gas: 15_000_000n,
481+
nonce: nonce++,
482+
chain,
483+
})
484+
.then(() => console.log("[KERNEL] Deploying KERNEL V3.3 ECDSA VALIDATOR"));
485+
486+
walletClient
487+
.sendTransaction({
488+
to: DETERMINISTIC_DEPLOYER,
489+
data: KERNEL_KERNEL_V3_3_FACTORY_CREATECALL,
490+
gas: 15_000_000n,
491+
nonce: nonce++,
492+
chain,
493+
})
494+
.then(() => console.log("[KERNEL] Deploying KERNEL V3.3 FACTORY ADDRESS "));
495+
448496
walletClient
449497
.sendTransaction({
450498
to: DETERMINISTIC_DEPLOYER,
@@ -492,6 +540,13 @@ const main = async () => {
492540
chain,
493541
});
494542

543+
// register 0x2577507b78c2008Ff367261CB6285d44ba5eF2E9
544+
await sendTransaction(walletClient, {
545+
account: kernelFactoryOwner,
546+
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* kernel factory v0.7 */,
547+
data: "0x6e7dbabb0000000000000000000000002577507b78c2008Ff367261CB6285d44ba5eF2E90000000000000000000000000000000000000000000000000000000000000001",
548+
});
549+
495550
await sendTransaction(walletClient, {
496551
account: kernelFactoryOwner,
497552
to: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5" /* Stake 0.1 eth in the entry point */,
@@ -569,6 +624,10 @@ const main = async () => {
569624
"0xd703aaE79538628d27099B8c4f621bE4CCd142d5", // Kernel v0.3.1 Meta Factory
570625
"0x00004EC70002a32400f8ae005A26081065620D20", // LightAccountFactory v1.1.0
571626
"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba", // LightAccount v1.1.0 implementation
627+
"0xe6Cae83BdE06E4c305530e199D7217f42808555B", // Simple7702AccountImplementation v0.8.0
628+
"0x2577507b78c2008ff367261cb6285d44ba5ef2e9", // Kernel v3.3.0 Factory
629+
"0xd6CEDDe84be40893d153Be9d467CD6aD37875b28", // Kernel v3.3.0 Delegation
630+
"0x845ADb2C711129d4f3966735eD98a9F09fC4cE57", // Kernel v3.3.0 ECDSA Validator
572631
]);
573632
};
574633

mock-verifying-paymaster/src/helpers/schema.ts

Lines changed: 184 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Hex, getAddress } from "viem";
1+
import { type Hex, getAddress, pad } from "viem";
22
import { z, type infer as zodInfer } from "zod";
33

44
export enum ValidationErrors {
@@ -60,6 +60,68 @@ export const hexDataSchema = z
6060
.regex(hexDataPattern, { message: "not valid hex data" })
6161
.transform((val) => val.toLowerCase() as Hex);
6262

63+
const signedAuthorizationSchema = z.union([
64+
z.object({
65+
contractAddress: addressSchema,
66+
chainId: hexNumberSchema.transform((val) => Number(val)),
67+
nonce: hexNumberSchema.transform((val) => Number(val)),
68+
r: hexDataSchema.transform((val) => val as Hex),
69+
s: hexDataSchema.transform((val) => val as Hex),
70+
v: hexNumberSchema.optional(),
71+
yParity: hexNumberSchema.transform((val) => Number(val)),
72+
}),
73+
z.object({
74+
address: addressSchema,
75+
chainId: hexNumberSchema.transform((val) => Number(val)),
76+
nonce: hexNumberSchema.transform((val) => Number(val)),
77+
r: hexDataSchema.transform((val) => val as Hex),
78+
s: hexDataSchema.transform((val) => val as Hex),
79+
v: hexNumberSchema.optional(),
80+
yParity: hexNumberSchema.transform((val) => Number(val)),
81+
}),
82+
]);
83+
84+
const partialAuthorizationSchema = z.union([
85+
z.object({
86+
contractAddress: addressSchema,
87+
chainId: hexNumberSchema
88+
.optional()
89+
.transform((val) => (val ? Number(val) : 1)),
90+
nonce: hexNumberSchema
91+
.optional()
92+
.transform((val) => (val ? Number(val) : 0)),
93+
r: hexDataSchema
94+
.optional()
95+
.transform((val) => (val as Hex) ?? pad("0x", { size: 32 })),
96+
s: hexDataSchema
97+
.optional()
98+
.transform((val) => (val as Hex) ?? pad("0x", { size: 32 })),
99+
v: hexNumberSchema.optional(),
100+
yParity: hexNumberSchema
101+
.optional()
102+
.transform((val) => (val ? Number(val) : 0)),
103+
}),
104+
z.object({
105+
address: addressSchema,
106+
chainId: hexNumberSchema
107+
.optional()
108+
.transform((val) => (val ? Number(val) : 1)),
109+
nonce: hexNumberSchema
110+
.optional()
111+
.transform((val) => (val ? Number(val) : 0)),
112+
r: hexDataSchema
113+
.optional()
114+
.transform((val) => (val as Hex) ?? pad("0x", { size: 32 })),
115+
s: hexDataSchema
116+
.optional()
117+
.transform((val) => (val as Hex) ?? pad("0x", { size: 32 })),
118+
v: hexNumberSchema.optional(),
119+
yParity: hexNumberSchema
120+
.optional()
121+
.transform((val) => (val ? Number(val) : 0)),
122+
}),
123+
]);
124+
63125
const userOperationSchemaPaymasterV6 = z
64126
.object({
65127
sender: addressSchema,
@@ -71,7 +133,60 @@ const userOperationSchemaPaymasterV6 = z
71133
preVerificationGas: hexNumberSchema.default(1n),
72134
maxPriorityFeePerGas: hexNumberSchema,
73135
maxFeePerGas: hexNumberSchema,
74-
paymasterAndData: hexDataSchema
136+
paymasterAndData: z
137+
.union([hexDataSchema, z.literal("")])
138+
.optional()
139+
.transform((val) => {
140+
if (val === "" || val === undefined) {
141+
return "0x";
142+
}
143+
return val;
144+
}),
145+
signature: z
146+
.union([hexDataSchema, z.literal("")])
147+
.optional()
148+
.transform((val) => {
149+
if (val === "" || val === undefined) {
150+
return "0x";
151+
}
152+
return val;
153+
}),
154+
eip7702Auth: signedAuthorizationSchema.optional().nullable(),
155+
})
156+
.strict()
157+
.transform((val) => val);
158+
159+
const userOperationSchemaPaymasterV7 = z
160+
.object({
161+
sender: addressSchema,
162+
nonce: hexNumberSchema,
163+
factory: addressSchema
164+
.nullable()
165+
.optional()
166+
.transform((val) => val ?? undefined),
167+
factoryData: hexDataSchema
168+
.nullable()
169+
.optional()
170+
.transform((val) => val ?? undefined),
171+
callData: hexDataSchema,
172+
callGasLimit: hexNumberSchema.default(1n),
173+
verificationGasLimit: hexNumberSchema.default(1n),
174+
preVerificationGas: hexNumberSchema.default(1n),
175+
maxFeePerGas: hexNumberSchema,
176+
maxPriorityFeePerGas: hexNumberSchema,
177+
paymaster: addressSchema
178+
.nullable()
179+
.optional()
180+
.transform((val) => val ?? undefined),
181+
paymasterVerificationGasLimit: hexNumberSchema
182+
.nullable()
183+
.optional()
184+
.transform((val) => val ?? undefined),
185+
paymasterPostOpGasLimit: hexNumberSchema
186+
.nullable()
187+
.optional()
188+
.transform((val) => val ?? undefined),
189+
paymasterData: hexDataSchema
75190
.nullable()
76191
.optional()
77192
.transform((val) => val ?? undefined),
@@ -81,18 +196,24 @@ const userOperationSchemaPaymasterV6 = z
81196
}
82197
return val;
83198
}),
199+
eip7702Auth: signedAuthorizationSchema.optional().nullable(),
84200
})
85201
.strict()
86-
.transform((val) => {
87-
return val;
88-
});
202+
.transform((val) => val);
89203

90-
const userOperationSchemaPaymasterV7 = z
204+
const userOperationSchemaPaymasterV8 = z
91205
.object({
92206
sender: addressSchema,
93207
nonce: hexNumberSchema,
94-
factory: addressSchema.optional().transform((val) => val ?? undefined),
95-
factoryData: hexDataSchema.optional().transform((val) => val ?? undefined),
208+
factory: z
209+
.union([addressSchema, z.literal("0x7702")])
210+
.nullable()
211+
.optional()
212+
.transform((val) => val ?? undefined),
213+
factoryData: hexDataSchema
214+
.nullable()
215+
.optional()
216+
.transform((val) => val ?? undefined),
96217
callData: hexDataSchema,
97218
callGasLimit: hexNumberSchema.default(1n),
98219
verificationGasLimit: hexNumberSchema.default(1n),
@@ -121,6 +242,7 @@ const userOperationSchemaPaymasterV7 = z
121242
}
122243
return val;
123244
}),
245+
eip7702Auth: signedAuthorizationSchema.optional().nullable(),
124246
})
125247
.strict()
126248
.transform((val) => {
@@ -167,6 +289,7 @@ const eip7677UserOperationSchemaV6 = z
167289
.transform((_) => {
168290
return "0x" as Hex;
169291
}),
292+
eip7702Auth: signedAuthorizationSchema.optional().nullable(),
170293
})
171294
.strict()
172295
.transform((val) => {
@@ -213,15 +336,66 @@ const eip7677UserOperationSchemaV7 = z
213336
}
214337
return val;
215338
}),
339+
eip7702Auth: signedAuthorizationSchema.optional().nullable(),
216340
})
217341
.strict()
218342
.transform((val) => {
219343
return val;
220344
});
221345

346+
const eip7677UserOperationSchemaV8 = z
347+
.object({
348+
sender: addressSchema,
349+
nonce: hexNumberSchema,
350+
factory: z
351+
.union([addressSchema, z.literal("0x7702")])
352+
.nullable()
353+
.optional()
354+
.transform((val) => val ?? null),
355+
factoryData: hexDataSchema
356+
.nullable()
357+
.optional()
358+
.transform((val) => val ?? null),
359+
callData: hexDataSchema,
360+
callGasLimit: hexNumberSchema,
361+
verificationGasLimit: hexNumberSchema,
362+
preVerificationGas: hexNumberSchema,
363+
maxFeePerGas: hexNumberSchema,
364+
maxPriorityFeePerGas: hexNumberSchema,
365+
paymaster: addressSchema
366+
.nullable()
367+
.optional()
368+
.transform((val) => val ?? null),
369+
paymasterVerificationGasLimit: hexNumberSchema
370+
.nullable()
371+
.optional()
372+
.transform((val) => val ?? null),
373+
paymasterPostOpGasLimit: hexNumberSchema
374+
.nullable()
375+
.optional()
376+
.transform((val) => val ?? null),
377+
paymasterData: hexDataSchema
378+
.nullable()
379+
.optional()
380+
.transform((val) => val ?? null),
381+
signature: hexDataSchema.optional().transform((val) => {
382+
return val ?? "0x";
383+
}),
384+
eip7702Auth: partialAuthorizationSchema.optional().nullable(),
385+
})
386+
.strict()
387+
.transform((val) => val);
388+
222389
const eip7677UserOperationSchema = z.union([
223390
eip7677UserOperationSchemaV6,
224391
eip7677UserOperationSchemaV7,
392+
eip7677UserOperationSchemaV8,
393+
]);
394+
395+
const userOperationSchemaPaymaster = z.union([
396+
userOperationSchemaPaymasterV6,
397+
userOperationSchemaPaymasterV7,
398+
userOperationSchemaPaymasterV8,
225399
]);
226400

227401
const paymasterContextSchema = z.union([
@@ -236,12 +410,9 @@ const paymasterContextSchema = z.union([
236410

237411
export const pmSponsorUserOperationParamsSchema = z
238412
.union([
413+
z.tuple([userOperationSchemaPaymaster, addressSchema]),
239414
z.tuple([
240-
z.union([userOperationSchemaPaymasterV6, userOperationSchemaPaymasterV7]),
241-
addressSchema,
242-
]),
243-
z.tuple([
244-
z.union([userOperationSchemaPaymasterV6, userOperationSchemaPaymasterV7]),
415+
userOperationSchemaPaymaster,
245416
addressSchema,
246417
paymasterContextSchema.nullable(),
247418
]),
@@ -286,6 +457,4 @@ export const pimlicoGetTokenQuotesSchema = z.tuple([
286457
hexNumberSchema,
287458
]);
288459

289-
export type UserOperationV7 = zodInfer<typeof userOperationSchemaPaymasterV7>;
290-
export type UserOperationV6 = zodInfer<typeof userOperationSchemaPaymasterV6>;
291460
export type JsonRpcSchema = zodInfer<typeof jsonRpcSchema>;

0 commit comments

Comments
 (0)