permissionless 0.1.35 → 0.1.36
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/CHANGELOG.md +6 -0
- package/_cjs/actions/erc7579/supportsExecutionMode.js +4 -4
- package/_cjs/actions/erc7579/supportsExecutionMode.js.map +1 -1
- package/_cjs/utils/encode7579CallData.js +1 -1
- package/_cjs/utils/encode7579CallData.js.map +1 -1
- package/_esm/actions/erc7579/supportsExecutionMode.js +4 -4
- package/_esm/actions/erc7579/supportsExecutionMode.js.map +1 -1
- package/_esm/utils/encode7579CallData.js +1 -1
- package/_esm/utils/encode7579CallData.js.map +1 -1
- package/_types/actions/erc7579/supportsExecutionMode.d.ts +3 -3
- package/_types/actions/erc7579/supportsExecutionMode.d.ts.map +1 -1
- package/actions/erc7579/supportsExecutionMode.test.ts +53 -0
- package/actions/erc7579/supportsExecutionMode.ts +7 -7
- package/actions/smartAccount/prepareUserOperationRequest.test.ts +371 -2
- package/actions/smartAccount.test.ts +198 -0
- package/clients/createBundlerClient.test.ts +26 -0
- package/clients/createSmartAccountClient.test.ts +55 -0
- package/clients/decorators/smartAccount.test.ts +55 -0
- package/package.json +1 -1
- package/utils/deepHexlify.test.ts +57 -0
- package/utils/encode7579CallData.test.ts +68 -0
- package/utils/encode7579CallData.ts +1 -1
- package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +31 -0
- package/utils/getEntryPointVersion.test.ts +52 -0
- package/utils/getPackedUserOperation.test.ts +204 -0
- package/utils/getRequiredPrefund.test.ts +71 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,8 @@ exports.supportsExecutionMode = exports.encodeExecutionMode = void 0;
|
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const utils_1 = require("../../utils/index.js");
|
|
6
6
|
const signUserOperationHashWithECDSA_1 = require("../../utils/signUserOperationHashWithECDSA.js");
|
|
7
|
-
function parseCallType(
|
|
8
|
-
switch (
|
|
7
|
+
function parseCallType(callType) {
|
|
8
|
+
switch (callType) {
|
|
9
9
|
case "call":
|
|
10
10
|
return "0x00";
|
|
11
11
|
case "delegatecall":
|
|
@@ -19,8 +19,8 @@ function encodeExecutionMode({ type, revertOnError, selector, context }) {
|
|
|
19
19
|
(0, viem_1.toHex)((0, viem_1.toBytes)(parseCallType(type), { size: 1 })),
|
|
20
20
|
(0, viem_1.toHex)((0, viem_1.toBytes)(revertOnError ? "0x01" : "0x00", { size: 1 })),
|
|
21
21
|
(0, viem_1.toHex)((0, viem_1.toBytes)("0x0", { size: 4 })),
|
|
22
|
-
(0, viem_1.toHex)((0, viem_1.toBytes)(selector, { size: 4 })),
|
|
23
|
-
(0, viem_1.toHex)((0, viem_1.toBytes)(context, { size: 22 }))
|
|
22
|
+
(0, viem_1.toHex)((0, viem_1.toBytes)(selector ?? "0x", { size: 4 })),
|
|
23
|
+
(0, viem_1.toHex)((0, viem_1.toBytes)(context ?? "0x", { size: 22 }))
|
|
24
24
|
]);
|
|
25
25
|
}
|
|
26
26
|
exports.encodeExecutionMode = encodeExecutionMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportsExecutionMode.js","sourceRoot":"","sources":["../../../actions/erc7579/supportsExecutionMode.ts"],"names":[],"mappings":";;;AAAA,+BAWa;AAIb,wCAA2C;AAC3C,+FAAyF;AAmBzF,SAAS,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"supportsExecutionMode.js","sourceRoot":"","sources":["../../../actions/erc7579/supportsExecutionMode.ts"],"names":[],"mappings":";;;AAAA,+BAWa;AAIb,wCAA2C;AAC3C,+FAAyF;AAmBzF,SAAS,aAAa,CAAC,QAAkB;IACrC,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,MAAM;YACP,OAAO,MAAM,CAAA;QACjB,KAAK,cAAc;YACf,OAAO,MAAM,CAAA;QACjB,KAAK,WAAW;YACZ,OAAO,MAAM,CAAA;IACrB,CAAC;AACL,CAAC;AAED,SAAgB,mBAA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;gBACrC,IAAI,EAAE,MAAM,CAAC,IAAI;aACpB,CAAC,CAAA;QACN,CAAC;QAED,MAAM,KAAK,CAAA;IACf,CAAC;AACL,CAAC;AAzFD,sDAyFC"}
|
|
@@ -5,7 +5,7 @@ const viem_1 = require("viem");
|
|
|
5
5
|
const supportsExecutionMode_1 = require("../actions/erc7579/supportsExecutionMode.js");
|
|
6
6
|
function encode7579CallData({ mode, callData }) {
|
|
7
7
|
if (Array.isArray(callData) && mode?.type !== "batchcall") {
|
|
8
|
-
throw new Error(`mode ${mode} does not supported for batchcall calldata`);
|
|
8
|
+
throw new Error(`mode ${JSON.stringify(mode)} does not supported for batchcall calldata`);
|
|
9
9
|
}
|
|
10
10
|
const executeAbi = [
|
|
11
11
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode7579CallData.js","sourceRoot":"","sources":["../../utils/encode7579CallData.ts"],"names":[],"mappings":";;;AAAA,+BAOa;AACb,oFAIiD;AAiBjD,SAAgB,kBAAkB,CAA4B,EAC1D,IAAI,EACJ,QAAQ,EACqB;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACX,QAAQ,IAAI,4CAA4C,
|
|
1
|
+
{"version":3,"file":"encode7579CallData.js","sourceRoot":"","sources":["../../utils/encode7579CallData.ts"],"names":[],"mappings":";;;AAAA,+BAOa;AACb,oFAIiD;AAiBjD,SAAgB,kBAAkB,CAA4B,EAC1D,IAAI,EACJ,QAAQ,EACqB;IAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACX,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4CAA4C,CAC3E,CAAA;IACL,CAAC;IAED,MAAM,UAAU,GAAG;QACf;YACI,I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AC;gBACN,QAAQ,CAAC,EAAE;gBACX,IAAA,YAAK,EAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBACnC,QAAQ,CAAC,IAAI;aAChB,CAAC;SACL;KACJ,CAAC,CAAA;AACN,CAAC;AApFD,gDAoFC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContractFunctionExecutionError, decodeFunctionResult, encodeFunctionData, encodePacked, toBytes, toHex } from "viem";
|
|
2
2
|
import { parseAccount } from "../../utils/index.js";
|
|
3
3
|
import { AccountOrClientNotFoundError } from "../../utils/signUserOperationHashWithECDSA.js";
|
|
4
|
-
function parseCallType(
|
|
5
|
-
switch (
|
|
4
|
+
function parseCallType(callType) {
|
|
5
|
+
switch (callType) {
|
|
6
6
|
case "call":
|
|
7
7
|
return "0x00";
|
|
8
8
|
case "delegatecall":
|
|
@@ -16,8 +16,8 @@ export function encodeExecutionMode({ type, revertOnError, selector, context })
|
|
|
16
16
|
toHex(toBytes(parseCallType(type), { size: 1 })),
|
|
17
17
|
toHex(toBytes(revertOnError ? "0x01" : "0x00", { size: 1 })),
|
|
18
18
|
toHex(toBytes("0x0", { size: 4 })),
|
|
19
|
-
toHex(toBytes(selector, { size: 4 })),
|
|
20
|
-
toHex(toBytes(context, { size: 22 }))
|
|
19
|
+
toHex(toBytes(selector ?? "0x", { size: 4 })),
|
|
20
|
+
toHex(toBytes(context ?? "0x", { size: 22 }))
|
|
21
21
|
]);
|
|
22
22
|
}
|
|
23
23
|
export async function supportsExecutionMode(client, args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportsExecutionMode.js","sourceRoot":"","sources":["../../../actions/erc7579/supportsExecutionMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,8BAA8B,EAG9B,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,KAAK,EACR,MAAM,MAAM,CAAA;AAIb,OAAO,EAAE,YAAY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CAAC,UAAU,EAAE,CAAA;YAC1C,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,cAAc,EAAE,CAAA;YAElD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC;gBACnC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,WAAW;gBACxB,EAAE,EAAE,OAAO,CAAC,OAAO;gBACnB,IAAI,EAAE,kBAAkB,CAAC;oBACrB,GAAG;oBACH,YAAY,EAAE,uBAAuB;oBACrC,IAAI,EAAE,CAAC,WAAW,CAAC;iBACtB,CAAC;aACL,CAAC,CAAA;YAEF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;YAChD,CAAC;YAED,OAAO,oBAAoB,CAAC;gBACxB,GAAG;gBACH,YAAY,EAAE,uBAAuB;gBACrC,IAAI,EAAE,MAAM,CAAC,IAAI;aACpB,CAAC,CAAA;QACN,CAAC;QAED,MAAM,KAAK,CAAA;IACf,CAAC;AACL,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { concatHex, encodeAbiParameters, encodeFunctionData, toHex } from "viem"
|
|
|
2
2
|
import { encodeExecutionMode } from "../actions/erc7579/supportsExecutionMode.js";
|
|
3
3
|
export function encode7579CallData({ mode, callData }) {
|
|
4
4
|
if (Array.isArray(callData) && mode?.type !== "batchcall") {
|
|
5
|
-
throw new Error(`mode ${mode} does not supported for batchcall calldata`);
|
|
5
|
+
throw new Error(`mode ${JSON.stringify(mode)} does not supported for batchcall calldata`);
|
|
6
6
|
}
|
|
7
7
|
const executeAbi = [
|
|
8
8
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode7579CallData.js","sourceRoot":"","sources":["../../utils/encode7579CallData.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,EACR,MAAM,MAAM,CAA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EAAE,SAAS;YACvB,IAAI,EAAE;gBACF,mBAAmB,CAAC,IAAI,CAAC;gBACzB,mBAAmB,CACf;oBACI;wBACI,IAAI,EAAE,gBAAgB;wBACtB,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE;4BACR;gCACI,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,SAAS;6BAClB;4BACD;gCACI,IAAI,EAAE,OAAO;gCACb,IAAI,EAAE,SAAS;6BAClB;4BACD;gCACI,IAAI,EAAE,UAAU;gCAChB,IAAI,EAAE,OAAO;6BAChB;yBACJ;qBACJ;iBACJ,EACD;oBACI,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;wBACjB,OAAO;4BACH,MAAM,EAAE,GAAG,CAAC,EAAE;4BACd,KAAK,EAAE,GAAG,CAAC,KAAK;4BAChB,QAAQ,EAAE,GAAG,CAAC,IAAI;yBACrB,CAAA;oBACL,CAAC,CAAC;iBACL,CACJ;aACJ;SACJ,CAAC,CAAA;IACN,CAAC;IAED,OAAO,kBAAkB,CAAC;QACtB,GAAG,EAAE,UAAU;QACf,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE;YACF,mBAAmB,CAAC,IAAI,CAAC;YACzB,SAAS,CAAC;gBACN,QAAQ,CAAC,EAAE;gBACX,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;gBACnC,QAAQ,CAAC,IAAI;aAChB,CAAC;SACL;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -5,9 +5,9 @@ import type { EntryPoint } from "../../types/entrypoint";
|
|
|
5
5
|
export type CallType = "call" | "delegatecall" | "batchcall";
|
|
6
6
|
export type ExecutionMode<callType extends CallType> = {
|
|
7
7
|
type: callType;
|
|
8
|
-
revertOnError
|
|
9
|
-
selector
|
|
10
|
-
context
|
|
8
|
+
revertOnError?: boolean;
|
|
9
|
+
selector?: Hex;
|
|
10
|
+
context?: Hex;
|
|
11
11
|
};
|
|
12
12
|
export type SupportsExecutionModeParameters<TEntryPoint extends EntryPoint, TSmartAccount extends SmartAccount<TEntryPoint> | undefined = SmartAccount<TEntryPoint> | undefined, callType extends CallType = CallType> = GetAccountParameter<TEntryPoint, TSmartAccount> & ExecutionMode<callType>;
|
|
13
13
|
export declare function encodeExecutionMode<callType extends CallType>({ type, revertOnError, selector, context }: ExecutionMode<callType>): Hex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supportsExecutionMode.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/supportsExecutionMode.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,GAAG,EACR,KAAK,SAAS,EAMjB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,WAAW,CAAA;AAE5D,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,QAAQ,IAAI;IACnD,IAAI,EAAE,QAAQ,CAAA;IACd,aAAa,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"supportsExecutionMode.d.ts","sourceRoot":"","sources":["../../../actions/erc7579/supportsExecutionMode.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,GAAG,EACR,KAAK,SAAS,EAMjB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAw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|
+
expect(supportsExecutionModeBatchCallBeforeDeploy).toBe(
|
|
67
|
+
supportsExecutionModeBatchCallBeforeDeployPostDeploy
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
testWithRpc.skipIf(!getErc7579SmartAccountClient)(
|
|
72
|
+
"supportsExecutionMode",
|
|
73
|
+
async ({ rpc }) => {
|
|
74
|
+
const { anvilRpc, altoRpc, paymasterRpc } = rpc
|
|
75
|
+
|
|
76
|
+
if (!getErc7579SmartAccountClient) {
|
|
77
|
+
throw new Error("getErc7579SmartAccountClient not defined")
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const smartClient = await getErc7579SmartAccountClient({
|
|
81
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
82
|
+
privateKey: generatePrivateKey(),
|
|
83
|
+
altoRpc: altoRpc,
|
|
84
|
+
anvilRpc: anvilRpc,
|
|
85
|
+
paymasterClient: getPimlicoPaymasterClient({
|
|
86
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
87
|
+
paymasterRpc
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const supportsExecutionModeBatchCallBeforeDeploy =
|
|
92
|
+
await supportsExecutionMode(smartClient as any, {
|
|
93
|
+
account: smartClient.account as any,
|
|
94
|
+
type: "delegatecall"
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
expect(supportsExecutionModeBatchCallBeforeDeploy).toBe(true)
|
|
98
|
+
|
|
99
|
+
// deploy account
|
|
100
|
+
await smartClient.sendTransaction({
|
|
101
|
+
to: zeroAddress,
|
|
102
|
+
value: 0n,
|
|
103
|
+
data: "0x"
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const supportsExecutionModeBatchCallBeforeDeployPostDeploy =
|
|
107
|
+
await supportsExecutionMode(smartClient as any, {
|
|
108
|
+
account: smartClient.account as any,
|
|
109
|
+
type: "batchcall",
|
|
110
|
+
revertOnError: false,
|
|
111
|
+
selector: "0x0",
|
|
112
|
+
context: "0x"
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
expect(
|
|
116
|
+
supportsExecutionModeBatchCallBeforeDeployPostDeploy
|
|
117
|
+
).toBe(true)
|
|
118
|
+
|
|
66
119
|
expect(supportsExecutionModeBatchCallBeforeDeploy).toBe(
|
|
67
120
|
supportsExecutionModeBatchCallBeforeDeployPostDeploy
|
|
68
121
|
)
|
|
@@ -20,9 +20,9 @@ export type CallType = "call" | "delegatecall" | "batchcall"
|
|
|
20
20
|
|
|
21
21
|
export type ExecutionMode<callType extends CallType> = {
|
|
22
22
|
type: callType
|
|
23
|
-
revertOnError
|
|
24
|
-
selector
|
|
25
|
-
context
|
|
23
|
+
revertOnError?: boolean
|
|
24
|
+
selector?: Hex
|
|
25
|
+
context?: Hex
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type SupportsExecutionModeParameters<
|
|
@@ -33,8 +33,8 @@ export type SupportsExecutionModeParameters<
|
|
|
33
33
|
callType extends CallType = CallType
|
|
34
34
|
> = GetAccountParameter<TEntryPoint, TSmartAccount> & ExecutionMode<callType>
|
|
35
35
|
|
|
36
|
-
function parseCallType(
|
|
37
|
-
switch (
|
|
36
|
+
function parseCallType(callType: CallType) {
|
|
37
|
+
switch (callType) {
|
|
38
38
|
case "call":
|
|
39
39
|
return "0x00"
|
|
40
40
|
case "delegatecall":
|
|
@@ -56,8 +56,8 @@ export function encodeExecutionMode<callType extends CallType>({
|
|
|
56
56
|
toHex(toBytes(parseCallType(type), { size: 1 })),
|
|
57
57
|
toHex(toBytes(revertOnError ? "0x01" : "0x00", { size: 1 })),
|
|
58
58
|
toHex(toBytes("0x0", { size: 4 })),
|
|
59
|
-
toHex(toBytes(selector, { size: 4 })),
|
|
60
|
-
toHex(toBytes(context, { size: 22 }))
|
|
59
|
+
toHex(toBytes(selector ?? "0x", { size: 4 })),
|
|
60
|
+
toHex(toBytes(context ?? "0x", { size: 22 }))
|
|
61
61
|
]
|
|
62
62
|
)
|
|
63
63
|
}
|
|
@@ -2,11 +2,15 @@ import { type Chain, type Client, type Transport, zeroAddress } from "viem"
|
|
|
2
2
|
import { generatePrivateKey } from "viem/accounts"
|
|
3
3
|
import { describe, expect } from "vitest"
|
|
4
4
|
import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getCoreSmartAccounts,
|
|
7
|
+
getPimlicoBundlerClient,
|
|
8
|
+
getPimlicoPaymasterClient
|
|
9
|
+
} from "../../../permissionless-test/src/utils"
|
|
6
10
|
import type { SmartAccount } from "../../accounts"
|
|
7
|
-
import type { SmartAccountClient } from "../../clients/createSmartAccountClient"
|
|
8
11
|
import type { EntryPoint } from "../../types/entrypoint"
|
|
9
12
|
import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from "../../utils"
|
|
13
|
+
import { pimlicoPaymasterActions } from "../pimlico"
|
|
10
14
|
import { prepareUserOperationRequest } from "./prepareUserOperationRequest"
|
|
11
15
|
|
|
12
16
|
describe.each(getCoreSmartAccounts())(
|
|
@@ -81,6 +85,189 @@ describe.each(getCoreSmartAccounts())(
|
|
|
81
85
|
}
|
|
82
86
|
)
|
|
83
87
|
|
|
88
|
+
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
89
|
+
"prepareUserOperationRequest_v06",
|
|
90
|
+
async ({ rpc }) => {
|
|
91
|
+
const { anvilRpc, altoRpc, paymasterRpc } = rpc
|
|
92
|
+
|
|
93
|
+
const smartClient = await getSmartAccountClient({
|
|
94
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
95
|
+
privateKey: generatePrivateKey(),
|
|
96
|
+
altoRpc: altoRpc,
|
|
97
|
+
anvilRpc: anvilRpc
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const pimlicoBundlerClient = getPimlicoBundlerClient({
|
|
101
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
102
|
+
altoRpc: altoRpc
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const pimlicoPaymasterActions = getPimlicoPaymasterClient({
|
|
106
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
107
|
+
paymasterRpc: paymasterRpc
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const userOperation = await prepareUserOperationRequest(
|
|
111
|
+
smartClient as Client<
|
|
112
|
+
Transport,
|
|
113
|
+
Chain,
|
|
114
|
+
SmartAccount<EntryPoint>
|
|
115
|
+
>,
|
|
116
|
+
{
|
|
117
|
+
userOperation: {
|
|
118
|
+
callData: await smartClient.account.encodeCallData({
|
|
119
|
+
to: zeroAddress,
|
|
120
|
+
data: "0x",
|
|
121
|
+
value: 0n
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
middleware: {
|
|
125
|
+
gasPrice: async () =>
|
|
126
|
+
(
|
|
127
|
+
await pimlicoBundlerClient.getUserOperationGasPrice()
|
|
128
|
+
).fast,
|
|
129
|
+
sponsorUserOperation:
|
|
130
|
+
pimlicoPaymasterActions.sponsorUserOperation
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
expect(userOperation).toBeTruthy()
|
|
136
|
+
expect(userOperation.sender).toBe(smartClient.account.address)
|
|
137
|
+
expect(userOperation.nonce).toBe(
|
|
138
|
+
await smartClient.account.getNonce()
|
|
139
|
+
)
|
|
140
|
+
expect(userOperation.initCode).toBe(
|
|
141
|
+
await smartClient.account.getInitCode()
|
|
142
|
+
)
|
|
143
|
+
expect(userOperation.callData).toBe(
|
|
144
|
+
await smartClient.account.encodeCallData({
|
|
145
|
+
to: zeroAddress,
|
|
146
|
+
data: "0x",
|
|
147
|
+
value: 0n
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
expect(userOperation.callGasLimit).toBeTruthy()
|
|
151
|
+
expect(userOperation.verificationGasLimit).toBeTruthy()
|
|
152
|
+
expect(userOperation.maxFeePerGas).toBeTruthy()
|
|
153
|
+
expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
|
|
154
|
+
expect(userOperation.paymasterAndData).toBeTruthy()
|
|
155
|
+
expect(userOperation.signature).toBe(
|
|
156
|
+
// @ts-ignore: since tests return all smart account client, some of them don't support V06.
|
|
157
|
+
// The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
|
|
158
|
+
await smartClient.account.getDummySignature(userOperation)
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
expect(userOperation.factory).toBe(undefined)
|
|
162
|
+
expect(userOperation.factoryData).toBe(undefined)
|
|
163
|
+
expect(userOperation.paymaster).toBe(undefined)
|
|
164
|
+
expect(userOperation.paymasterVerificationGasLimit).toBe(
|
|
165
|
+
undefined
|
|
166
|
+
)
|
|
167
|
+
expect(userOperation.paymasterPostOpGasLimit).toBe(undefined)
|
|
168
|
+
expect(userOperation.paymasterData).toBe(undefined)
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
testWithRpc.skipIf(!supportsEntryPointV06)(
|
|
173
|
+
"prepareUserOperationRequest_v06",
|
|
174
|
+
async ({ rpc }) => {
|
|
175
|
+
const { anvilRpc, altoRpc, paymasterRpc } = rpc
|
|
176
|
+
|
|
177
|
+
const smartClient = await getSmartAccountClient({
|
|
178
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
179
|
+
privateKey: generatePrivateKey(),
|
|
180
|
+
altoRpc: altoRpc,
|
|
181
|
+
anvilRpc: anvilRpc
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const pimlicoBundlerClient = getPimlicoBundlerClient({
|
|
185
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
186
|
+
altoRpc: altoRpc
|
|
187
|
+
})
|
|
188
|
+
const pimlicoPaymasterActions = getPimlicoPaymasterClient({
|
|
189
|
+
entryPoint: ENTRYPOINT_ADDRESS_V06,
|
|
190
|
+
paymasterRpc: paymasterRpc
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
const userOperation = await prepareUserOperationRequest(
|
|
194
|
+
smartClient as Client<
|
|
195
|
+
Transport,
|
|
196
|
+
Chain,
|
|
197
|
+
SmartAccount<EntryPoint>
|
|
198
|
+
>,
|
|
199
|
+
{
|
|
200
|
+
userOperation: {
|
|
201
|
+
callData: await smartClient.account.encodeCallData({
|
|
202
|
+
to: zeroAddress,
|
|
203
|
+
data: "0x",
|
|
204
|
+
value: 0n
|
|
205
|
+
})
|
|
206
|
+
},
|
|
207
|
+
middleware: async <T>(args: {
|
|
208
|
+
userOperation: T
|
|
209
|
+
entryPoint: EntryPoint
|
|
210
|
+
}) => {
|
|
211
|
+
const gasPrice = (
|
|
212
|
+
await pimlicoBundlerClient.getUserOperationGasPrice()
|
|
213
|
+
).fast
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
...args.userOperation,
|
|
217
|
+
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
218
|
+
maxPriorityFeePerGas:
|
|
219
|
+
gasPrice.maxPriorityFeePerGas,
|
|
220
|
+
...(await pimlicoPaymasterActions.sponsorUserOperation(
|
|
221
|
+
{
|
|
222
|
+
userOperation: {
|
|
223
|
+
...args.userOperation,
|
|
224
|
+
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
225
|
+
maxPriorityFeePerGas:
|
|
226
|
+
gasPrice.maxPriorityFeePerGas
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
))
|
|
230
|
+
} as T
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
expect(userOperation).toBeTruthy()
|
|
236
|
+
expect(userOperation.sender).toBe(smartClient.account.address)
|
|
237
|
+
expect(userOperation.nonce).toBe(
|
|
238
|
+
await smartClient.account.getNonce()
|
|
239
|
+
)
|
|
240
|
+
expect(userOperation.initCode).toBe(
|
|
241
|
+
await smartClient.account.getInitCode()
|
|
242
|
+
)
|
|
243
|
+
expect(userOperation.callData).toBe(
|
|
244
|
+
await smartClient.account.encodeCallData({
|
|
245
|
+
to: zeroAddress,
|
|
246
|
+
data: "0x",
|
|
247
|
+
value: 0n
|
|
248
|
+
})
|
|
249
|
+
)
|
|
250
|
+
expect(userOperation.callGasLimit).toBeTruthy()
|
|
251
|
+
expect(userOperation.verificationGasLimit).toBeTruthy()
|
|
252
|
+
expect(userOperation.maxFeePerGas).toBeTruthy()
|
|
253
|
+
expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
|
|
254
|
+
expect(userOperation.paymasterAndData).toBeTruthy()
|
|
255
|
+
expect(userOperation.signature).toBe(
|
|
256
|
+
// @ts-ignore: since tests return all smart account client, some of them don't support V06.
|
|
257
|
+
// The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
|
|
258
|
+
await smartClient.account.getDummySignature(userOperation)
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
expect(userOperation.factory).toBe(undefined)
|
|
262
|
+
expect(userOperation.factoryData).toBe(undefined)
|
|
263
|
+
expect(userOperation.paymaster).toBe(undefined)
|
|
264
|
+
expect(userOperation.paymasterVerificationGasLimit).toBe(
|
|
265
|
+
undefined
|
|
266
|
+
)
|
|
267
|
+
expect(userOperation.paymasterPostOpGasLimit).toBe(undefined)
|
|
268
|
+
expect(userOperation.paymasterData).toBe(undefined)
|
|
269
|
+
}
|
|
270
|
+
)
|
|
84
271
|
testWithRpc.skipIf(!supportsEntryPointV07)(
|
|
85
272
|
"prepareUserOperationRequest_v07",
|
|
86
273
|
async ({ rpc }) => {
|
|
@@ -147,5 +334,187 @@ describe.each(getCoreSmartAccounts())(
|
|
|
147
334
|
expect(userOperation.initCode).toBe(undefined)
|
|
148
335
|
}
|
|
149
336
|
)
|
|
337
|
+
|
|
338
|
+
testWithRpc.skipIf(!supportsEntryPointV07)(
|
|
339
|
+
"prepareUserOperationRequest_v07",
|
|
340
|
+
async ({ rpc }) => {
|
|
341
|
+
const { anvilRpc, altoRpc, paymasterRpc } = rpc
|
|
342
|
+
|
|
343
|
+
const smartClient = await getSmartAccountClient({
|
|
344
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
345
|
+
privateKey: generatePrivateKey(),
|
|
346
|
+
altoRpc: altoRpc,
|
|
347
|
+
anvilRpc: anvilRpc
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
const pimlicoBundlerClient = getPimlicoBundlerClient({
|
|
351
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
352
|
+
altoRpc: altoRpc
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
const pimlicoPaymasterActions = getPimlicoPaymasterClient({
|
|
356
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
357
|
+
paymasterRpc: paymasterRpc
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
const userOperation = await prepareUserOperationRequest(
|
|
361
|
+
smartClient as Client<
|
|
362
|
+
Transport,
|
|
363
|
+
Chain,
|
|
364
|
+
SmartAccount<EntryPoint>
|
|
365
|
+
>,
|
|
366
|
+
{
|
|
367
|
+
userOperation: {
|
|
368
|
+
callData: await smartClient.account.encodeCallData({
|
|
369
|
+
to: zeroAddress,
|
|
370
|
+
data: "0x",
|
|
371
|
+
value: 0n
|
|
372
|
+
})
|
|
373
|
+
},
|
|
374
|
+
middleware: {
|
|
375
|
+
gasPrice: async () =>
|
|
376
|
+
(
|
|
377
|
+
await pimlicoBundlerClient.getUserOperationGasPrice()
|
|
378
|
+
).fast,
|
|
379
|
+
sponsorUserOperation:
|
|
380
|
+
pimlicoPaymasterActions.sponsorUserOperation
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
expect(userOperation).toBeTruthy()
|
|
386
|
+
expect(userOperation.sender).toBe(smartClient.account.address)
|
|
387
|
+
expect(userOperation.nonce).toBe(
|
|
388
|
+
await smartClient.account.getNonce()
|
|
389
|
+
)
|
|
390
|
+
expect(userOperation.factory).toBe(
|
|
391
|
+
await smartClient.account.getFactory()
|
|
392
|
+
)
|
|
393
|
+
expect(userOperation.factoryData).toBe(
|
|
394
|
+
await smartClient.account.getFactoryData()
|
|
395
|
+
)
|
|
396
|
+
expect(userOperation.callData).toBe(
|
|
397
|
+
await smartClient.account.encodeCallData({
|
|
398
|
+
to: zeroAddress,
|
|
399
|
+
data: "0x",
|
|
400
|
+
value: 0n
|
|
401
|
+
})
|
|
402
|
+
)
|
|
403
|
+
expect(userOperation.callGasLimit).toBeTruthy()
|
|
404
|
+
expect(userOperation.verificationGasLimit).toBeTruthy()
|
|
405
|
+
expect(userOperation.maxFeePerGas).toBeTruthy()
|
|
406
|
+
expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
|
|
407
|
+
expect(userOperation.paymaster).toBeTruthy()
|
|
408
|
+
expect(userOperation.paymasterVerificationGasLimit).toBeTruthy()
|
|
409
|
+
expect(userOperation.signature).toBe(
|
|
410
|
+
// @ts-ignore: since tests return all smart account client, some of them don't support V07.
|
|
411
|
+
// The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
|
|
412
|
+
await smartClient.account.getDummySignature(userOperation)
|
|
413
|
+
)
|
|
414
|
+
expect(userOperation.paymasterPostOpGasLimit).toBe(1n)
|
|
415
|
+
expect(userOperation.paymasterData).toBeTruthy()
|
|
416
|
+
expect(userOperation.paymasterAndData).toBe(undefined)
|
|
417
|
+
expect(userOperation.initCode).toBe(undefined)
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
testWithRpc.skipIf(!supportsEntryPointV07)(
|
|
422
|
+
"prepareUserOperationRequest_v07",
|
|
423
|
+
async ({ rpc }) => {
|
|
424
|
+
const { anvilRpc, altoRpc, paymasterRpc } = rpc
|
|
425
|
+
|
|
426
|
+
const smartClient = await getSmartAccountClient({
|
|
427
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
428
|
+
privateKey: generatePrivateKey(),
|
|
429
|
+
altoRpc: altoRpc,
|
|
430
|
+
anvilRpc: anvilRpc
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
const pimlicoBundlerClient = getPimlicoBundlerClient({
|
|
434
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
435
|
+
altoRpc: altoRpc
|
|
436
|
+
})
|
|
437
|
+
const pimlicoPaymasterActions = getPimlicoPaymasterClient({
|
|
438
|
+
entryPoint: ENTRYPOINT_ADDRESS_V07,
|
|
439
|
+
paymasterRpc: paymasterRpc
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
const userOperation = await prepareUserOperationRequest(
|
|
443
|
+
smartClient as Client<
|
|
444
|
+
Transport,
|
|
445
|
+
Chain,
|
|
446
|
+
SmartAccount<EntryPoint>
|
|
447
|
+
>,
|
|
448
|
+
{
|
|
449
|
+
userOperation: {
|
|
450
|
+
callData: await smartClient.account.encodeCallData({
|
|
451
|
+
to: zeroAddress,
|
|
452
|
+
data: "0x",
|
|
453
|
+
value: 0n
|
|
454
|
+
})
|
|
455
|
+
},
|
|
456
|
+
middleware: async <T>(args: {
|
|
457
|
+
userOperation: T
|
|
458
|
+
entryPoint: EntryPoint
|
|
459
|
+
}) => {
|
|
460
|
+
const gasPrice = (
|
|
461
|
+
await pimlicoBundlerClient.getUserOperationGasPrice()
|
|
462
|
+
).fast
|
|
463
|
+
|
|
464
|
+
return {
|
|
465
|
+
...args.userOperation,
|
|
466
|
+
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
467
|
+
maxPriorityFeePerGas:
|
|
468
|
+
gasPrice.maxPriorityFeePerGas,
|
|
469
|
+
...(await pimlicoPaymasterActions.sponsorUserOperation(
|
|
470
|
+
{
|
|
471
|
+
userOperation: {
|
|
472
|
+
...args.userOperation,
|
|
473
|
+
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
474
|
+
maxPriorityFeePerGas:
|
|
475
|
+
gasPrice.maxPriorityFeePerGas
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
))
|
|
479
|
+
} as T
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
expect(userOperation).toBeTruthy()
|
|
485
|
+
expect(userOperation.sender).toBe(smartClient.account.address)
|
|
486
|
+
expect(userOperation.nonce).toBe(
|
|
487
|
+
await smartClient.account.getNonce()
|
|
488
|
+
)
|
|
489
|
+
expect(userOperation.factory).toBe(
|
|
490
|
+
await smartClient.account.getFactory()
|
|
491
|
+
)
|
|
492
|
+
expect(userOperation.factoryData).toBe(
|
|
493
|
+
await smartClient.account.getFactoryData()
|
|
494
|
+
)
|
|
495
|
+
expect(userOperation.callData).toBe(
|
|
496
|
+
await smartClient.account.encodeCallData({
|
|
497
|
+
to: zeroAddress,
|
|
498
|
+
data: "0x",
|
|
499
|
+
value: 0n
|
|
500
|
+
})
|
|
501
|
+
)
|
|
502
|
+
expect(userOperation.callGasLimit).toBeTruthy()
|
|
503
|
+
expect(userOperation.verificationGasLimit).toBeTruthy()
|
|
504
|
+
expect(userOperation.maxFeePerGas).toBeTruthy()
|
|
505
|
+
expect(userOperation.maxPriorityFeePerGas).toBeTruthy()
|
|
506
|
+
expect(userOperation.paymaster).toBeTruthy()
|
|
507
|
+
expect(userOperation.paymasterVerificationGasLimit).toBeTruthy()
|
|
508
|
+
expect(userOperation.signature).toBe(
|
|
509
|
+
// @ts-ignore: since tests return all smart account client, some of them don't support V07.
|
|
510
|
+
// The TS error is because in that case, getDummySignature would not accept the userOperation of type UserOperation<V07>
|
|
511
|
+
await smartClient.account.getDummySignature(userOperation)
|
|
512
|
+
)
|
|
513
|
+
expect(userOperation.paymasterPostOpGasLimit).toBe(1n)
|
|
514
|
+
expect(userOperation.paymasterData).toBeTruthy()
|
|
515
|
+
expect(userOperation.paymasterAndData).toBe(undefined)
|
|
516
|
+
expect(userOperation.initCode).toBe(undefined)
|
|
517
|
+
}
|
|
518
|
+
)
|
|
150
519
|
}
|
|
151
520
|
)
|