permissionless 0.0.14 → 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.
- package/CHANGELOG.md +7 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js +1 -1
- package/_cjs/actions/pimlico/validateSponsorshipPolicies.js +16 -0
- package/_cjs/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
- package/_cjs/actions/pimlico.js +3 -1
- package/_cjs/actions/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js +3 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/utils/getRequiredPrefund.js +12 -0
- package/_cjs/utils/getRequiredPrefund.js.map +1 -0
- package/_cjs/utils/index.js +3 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/accounts/signerToSafeSmartAccount.js +1 -1
- package/_esm/actions/pimlico/validateSponsorshipPolicies.js +47 -0
- package/_esm/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
- package/_esm/actions/pimlico.js +2 -1
- package/_esm/actions/pimlico.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +38 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/utils/getRequiredPrefund.js +22 -0
- package/_esm/utils/getRequiredPrefund.js.map +1 -0
- package/_esm/utils/index.js +2 -1
- package/_esm/utils/index.js.map +1 -1
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +54 -0
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -0
- package/_types/actions/pimlico.d.ts +3 -2
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +37 -0
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts +17 -0
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/utils/getRequiredPrefund.d.ts +20 -0
- package/_types/utils/getRequiredPrefund.d.ts.map +1 -0
- package/_types/utils/index.d.ts +2 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/accounts/signerToSafeSmartAccount.ts +1 -1
- package/actions/pimlico/validateSponsorshipPolicies.ts +76 -0
- package/actions/pimlico.ts +11 -2
- package/clients/decorators/pimlico.ts +48 -1
- package/package.json +1 -1
- package/types/pimlico.ts +17 -0
- package/utils/getRequiredPrefund.ts +31 -0
- package/utils/index.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -22,7 +22,7 @@ const EIP712_SAFE_OPERATION_TYPE = {
|
|
|
22
22
|
const SAFE_VERSION_TO_ADDRESSES_MAP = {
|
|
23
23
|
"1.4.1": {
|
|
24
24
|
ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
|
|
25
|
-
SAFE_4337_MODULE_ADDRESS: "
|
|
25
|
+
SAFE_4337_MODULE_ADDRESS: "0xa581c4A4DB7175302464fF3C06380BC3270b4037",
|
|
26
26
|
SAFE_PROXY_FACTORY_ADDRESS: "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
|
|
27
27
|
SAFE_SINGLETON_ADDRESS: "0x41675C099F32341bf84BFc5382aF534df5C7461a",
|
|
28
28
|
MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSponsorshipPolicies = void 0;
|
|
4
|
+
const deepHexlify_js_1 = require("../../utils/deepHexlify.js");
|
|
5
|
+
const validateSponsorshipPolicies = async (client, args) => {
|
|
6
|
+
return await client.request({
|
|
7
|
+
method: "pm_validateSponsorshipPolicies",
|
|
8
|
+
params: [
|
|
9
|
+
(0, deepHexlify_js_1.deepHexlify)(args.userOperation),
|
|
10
|
+
args.entryPoint,
|
|
11
|
+
args.sponsorshipPolicyIds
|
|
12
|
+
]
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.validateSponsorshipPolicies = validateSponsorshipPolicies;
|
|
16
|
+
//# sourceMappingURL=validateSponsorshipPolicies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateSponsorshipPolicies.js","sourceRoot":"","sources":["../../../actions/pimlico/validateSponsorshipPolicies.ts"],"names":[],"mappings":";;;AAMA,+DAAwD;AAqDjD,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,IAAA,4BAAW,EAAC,IAAI,CAAC,aAAa,CAAiC;YAC/D,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,oBAAoB;SAC5B;KACJ,CAAC,CAAA;AACN,CAAC,CAAA;AAhBY,QAAA,2BAA2B,+BAgBvC"}
|
package/_cjs/actions/pimlico.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pimlicoPaymasterActions = exports.pimlicoBundlerActions = exports.sponsorUserOperation = exports.getUserOperationStatus = exports.getUserOperationGasPrice = void 0;
|
|
3
|
+
exports.validateSponsorshipPolicies = exports.pimlicoPaymasterActions = exports.pimlicoBundlerActions = exports.sponsorUserOperation = exports.getUserOperationStatus = exports.getUserOperationGasPrice = void 0;
|
|
4
4
|
const getUserOperationGasPrice_js_1 = require("./pimlico/getUserOperationGasPrice.js");
|
|
5
5
|
Object.defineProperty(exports, "getUserOperationGasPrice", { enumerable: true, get: function () { return getUserOperationGasPrice_js_1.getUserOperationGasPrice; } });
|
|
6
6
|
const getUserOperationStatus_js_1 = require("./pimlico/getUserOperationStatus.js");
|
|
@@ -10,4 +10,6 @@ Object.defineProperty(exports, "sponsorUserOperation", { enumerable: true, get:
|
|
|
10
10
|
const pimlico_js_1 = require("../clients/decorators/pimlico.js");
|
|
11
11
|
Object.defineProperty(exports, "pimlicoBundlerActions", { enumerable: true, get: function () { return pimlico_js_1.pimlicoBundlerActions; } });
|
|
12
12
|
Object.defineProperty(exports, "pimlicoPaymasterActions", { enumerable: true, get: function () { return pimlico_js_1.pimlicoPaymasterActions; } });
|
|
13
|
+
const validateSponsorshipPolicies_js_1 = require("./pimlico/validateSponsorshipPolicies.js");
|
|
14
|
+
Object.defineProperty(exports, "validateSponsorshipPolicies", { enumerable: true, get: function () { return validateSponsorshipPolicies_js_1.validateSponsorshipPolicies; } });
|
|
13
15
|
//# sourceMappingURL=pimlico.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":";;;AAAA,uFAG8C;
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":";;;AAAA,uFAG8C;AAwC1C,yGAzCA,sDAAwB,OAyCA;AAvC5B,mFAI4C;AAoCxC,uGArCA,kDAAsB,OAqCA;AAnC1B,+EAI0C;AAgCtC,qGAjCA,8CAAoB,OAiCA;AA1BxB,iEAGyC;AAwBrC,sGA1BA,kCAAqB,OA0BA;AACrB,wGA1BA,oCAAuB,OA0BA;AAvB3B,6FAIiD;AAoB7C,4GArBA,4DAA2B,OAqBA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pimlicoPaymasterActions = exports.pimlicoBundlerActions = void 0;
|
|
4
|
+
const pimlico_js_1 = require("../../actions/pimlico.js");
|
|
4
5
|
const getUserOperationGasPrice_js_1 = require("../../actions/pimlico/getUserOperationGasPrice.js");
|
|
5
6
|
const getUserOperationStatus_js_1 = require("../../actions/pimlico/getUserOperationStatus.js");
|
|
6
7
|
const sponsorUserOperation_js_1 = require("../../actions/pimlico/sponsorUserOperation.js");
|
|
@@ -10,7 +11,8 @@ const pimlicoBundlerActions = (client) => ({
|
|
|
10
11
|
});
|
|
11
12
|
exports.pimlicoBundlerActions = pimlicoBundlerActions;
|
|
12
13
|
const pimlicoPaymasterActions = (client) => ({
|
|
13
|
-
sponsorUserOperation: async (args) => (0, sponsorUserOperation_js_1.sponsorUserOperation)(client, args)
|
|
14
|
+
sponsorUserOperation: async (args) => (0, sponsorUserOperation_js_1.sponsorUserOperation)(client, args),
|
|
15
|
+
validateSponsorshipPolicies: async (args) => (0, pimlico_js_1.validateSponsorshipPolicies)(client, args)
|
|
14
16
|
});
|
|
15
17
|
exports.pimlicoPaymasterActions = pimlicoPaymasterActions;
|
|
16
18
|
//# sourceMappingURL=pimlico.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../../clients/decorators/pimlico.ts"],"names":[],"mappings":";;;AACA,mGAG0D;AAC1D,+FAIwD;AACxD,2FAIsD;AAmD/C,MAAM,qBAAqB,GAAG,CACjC,MAAc,EACO,EAAE,CAAC,CAAC;IACzB,wBAAwB,EAAE,KAAK,IAAI,EAAE,CACjC,IAAA,sDAAwB,EAAC,MAA8B,CAAC;IAC5D,sBAAsB,EAAE,KAAK,EAAE,IAAsC,EAAE,EAAE,CACrE,IAAA,kDAAsB,EAAC,MAA8B,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AAPW,QAAA,qBAAqB,yBAOhC;
|
|
1
|
+
{"version":3,"file":"pimlico.js","sourceRoot":"","sources":["../../../clients/decorators/pimlico.ts"],"names":[],"mappings":";;;AACA,yDAIiC;AACjC,mGAG0D;AAC1D,+FAIwD;AACxD,2FAIsD;AAmD/C,MAAM,qBAAqB,GAAG,CACjC,MAAc,EACO,EAAE,CAAC,CAAC;IACzB,wBAAwB,EAAE,KAAK,IAAI,EAAE,CACjC,IAAA,sDAAwB,EAAC,MAA8B,CAAC;IAC5D,sBAAsB,EAAE,KAAK,EAAE,IAAsC,EAAE,EAAE,CACrE,IAAA,kDAAsB,EAAC,MAA8B,EAAE,IAAI,CAAC;CACnE,CAAC,CAAA;AAPW,QAAA,qBAAqB,yBAOhC;AAsEK,MAAM,uBAAuB,GAAG,CACnC,MAAc,EACe,EAAE,CAAC,CAAC;IACjC,oBAAoB,EAAE,KAAK,EAAE,IAA2C,EAAE,EAAE,CACxE,IAAA,8CAAoB,EAAC,MAAgC,EAAE,IAAI,CAAC;IAChE,2BAA2B,EAAE,KAAK,EAC9B,IAA2C,EAC7C,EAAE,CAAC,IAAA,wCAA2B,EAAC,MAAgC,EAAE,IAAI,CAAC;CAC3E,CAAC,CAAA;AARW,QAAA,uBAAuB,2BAQlC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequiredPrefund = void 0;
|
|
4
|
+
const getRequiredPrefund = ({ userOperation }) => {
|
|
5
|
+
const multiplier = userOperation.paymasterAndData.length > 2 ? 3n : 1n;
|
|
6
|
+
const requiredGas = userOperation.callGasLimit +
|
|
7
|
+
userOperation.verificationGasLimit * multiplier +
|
|
8
|
+
userOperation.preVerificationGas;
|
|
9
|
+
return BigInt(requiredGas) * BigInt(userOperation.maxFeePerGas);
|
|
10
|
+
};
|
|
11
|
+
exports.getRequiredPrefund = getRequiredPrefund;
|
|
12
|
+
//# sourceMappingURL=getRequiredPrefund.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRequiredPrefund.js","sourceRoot":"","sources":["../../utils/getRequiredPrefund.ts"],"names":[],"mappings":";;;AAoBO,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;AAVY,QAAA,kBAAkB,sBAU9B"}
|
package/_cjs/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountOrClientNotFoundError = exports.signUserOperationHashWithECDSA = exports.getUserOperationHash = exports.parseAccount = void 0;
|
|
3
|
+
exports.AccountOrClientNotFoundError = exports.signUserOperationHashWithECDSA = exports.getRequiredPrefund = exports.getUserOperationHash = exports.parseAccount = void 0;
|
|
4
|
+
const getRequiredPrefund_js_1 = require("./getRequiredPrefund.js");
|
|
5
|
+
Object.defineProperty(exports, "getRequiredPrefund", { enumerable: true, get: function () { return getRequiredPrefund_js_1.getRequiredPrefund; } });
|
|
4
6
|
const getUserOperationHash_js_1 = require("./getUserOperationHash.js");
|
|
5
7
|
Object.defineProperty(exports, "getUserOperationHash", { enumerable: true, get: function () { return getUserOperationHash_js_1.getUserOperationHash; } });
|
|
6
8
|
const signUserOperationHashWithECDSA_js_1 = require("./signUserOperationHashWithECDSA.js");
|
package/_cjs/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;AACA,uEAGkC;AAa9B,qGAdA,8CAAoB,OAcA;AAZxB,2FAG4C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;AACA,mEAGgC;AAkB5B,mGAnBA,0CAAkB,OAmBA;AAjBtB,uEAGkC;AAa9B,qGAdA,8CAAoB,OAcA;AAZxB,2FAG4C;AAcxC,6GAhBA,gEAA4B,OAgBA;AAD5B,+GAdA,kEAA8B,OAcA;AAXlC,SAAgB,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;AAJD,oCAIC"}
|
|
@@ -19,7 +19,7 @@ const EIP712_SAFE_OPERATION_TYPE = {
|
|
|
19
19
|
const SAFE_VERSION_TO_ADDRESSES_MAP = {
|
|
20
20
|
"1.4.1": {
|
|
21
21
|
ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
|
|
22
|
-
SAFE_4337_MODULE_ADDRESS: "
|
|
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",
|
|
@@ -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"}
|
package/_esm/actions/pimlico.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
|
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"}
|
|
@@ -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,+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A4C;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"}
|
package/_esm/utils/index.js
CHANGED
|
@@ -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
|
package/_esm/utils/index.js.map
CHANGED
|
@@ -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,
|
|
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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Client, Transport } from "viem";
|
|
2
|
+
import type { PimlicoPaymasterRpcSchema } from "../../types/pimlico.js";
|
|
3
|
+
import type { UserOperation } from "../../types/userOperation.js";
|
|
4
|
+
export type ValidateSponsorshipPoliciesParameters = {
|
|
5
|
+
userOperation: UserOperation;
|
|
6
|
+
entryPoint: Address;
|
|
7
|
+
sponsorshipPolicyIds: string[];
|
|
8
|
+
};
|
|
9
|
+
export type ValidateSponsorshipPoliciesReturnType = {
|
|
10
|
+
sponsorshipPolicyId: string;
|
|
11
|
+
data: {
|
|
12
|
+
name: string | null;
|
|
13
|
+
author: string | null;
|
|
14
|
+
icon: string | null;
|
|
15
|
+
description: string | null;
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
/**
|
|
19
|
+
* Returns valid sponsorship policies for a userOperation from the list of ids passed
|
|
20
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
|
|
21
|
+
*
|
|
22
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
23
|
+
* @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
|
|
24
|
+
* @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import { createClient } from "viem"
|
|
28
|
+
* import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
|
|
29
|
+
*
|
|
30
|
+
* const bundlerClient = createClient({
|
|
31
|
+
* chain: goerli,
|
|
32
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* await validateSponsorshipPolicies(bundlerClient, {
|
|
36
|
+
* userOperation: userOperationWithDummySignature,
|
|
37
|
+
* entryPoint: entryPoint,
|
|
38
|
+
* sponsorshipPolicyIds: ["sp_shiny_puma"]
|
|
39
|
+
* })
|
|
40
|
+
* Returns
|
|
41
|
+
* [
|
|
42
|
+
* {
|
|
43
|
+
* sponsorshipPolicyId: "sp_shiny_puma",
|
|
44
|
+
* data: {
|
|
45
|
+
* name: "Shiny Puma",
|
|
46
|
+
* author: "Pimlico",
|
|
47
|
+
* icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
|
|
48
|
+
* description: "This policy is for testing purposes only"
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
*/
|
|
53
|
+
export declare const validateSponsorshipPolicies: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends Account | undefined = Account | undefined>(client: Client<TTransport, TChain, TAccount, PimlicoPaymasterRpcSchema>, args: ValidateSponsorshipPoliciesParameters) => Promise<ValidateSponsorshipPoliciesReturnType>;
|
|
54
|
+
//# sourceMappingURL=validateSponsorshipPolicies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateSponsorshipPolicies.d.ts","sourceRoot":"","sources":["../../../actions/pimlico/validateSponsorshipPolicies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,KAAK,EACR,aAAa,EAEhB,MAAM,8BAA8B,CAAA;AAGrC,MAAM,MAAM,qCAAqC,GAAG;IAChD,aAAa,EAAE,aAAa,CAAA;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,oBAAoB,EAAE,MAAM,EAAE,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,qCAAqC,GAAG;IAChD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,IAAI,EAAE;QACF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;QACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;QACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;QACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC7B,CAAA;CACJ,EAAE,CAAA;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,2BAA2B,8OAM9B,qCAAqC,KAC5C,QAAQ,qCAAqC,CAS/C,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { type GetUserOperationStatusParameters, type GetUserOperationStatusRetur
|
|
|
3
3
|
import { type PimlocoSponsorUserOperationParameters, type SponsorUserOperationReturnType, sponsorUserOperation } from "./pimlico/sponsorUserOperation.js";
|
|
4
4
|
import type { PimlicoBundlerActions, PimlicoPaymasterClientActions } from "../clients/decorators/pimlico.js";
|
|
5
5
|
import { pimlicoBundlerActions, pimlicoPaymasterActions } from "../clients/decorators/pimlico.js";
|
|
6
|
-
|
|
7
|
-
export {
|
|
6
|
+
import { type ValidateSponsorshipPoliciesParameters, type ValidateSponsorshipPoliciesReturnType, validateSponsorshipPolicies } from "./pimlico/validateSponsorshipPolicies.js";
|
|
7
|
+
export type { GetUserOperationGasPriceReturnType, GetUserOperationStatusParameters, GetUserOperationStatusReturnType, PimlocoSponsorUserOperationParameters, SponsorUserOperationReturnType, PimlicoBundlerActions, PimlicoPaymasterClientActions, ValidateSponsorshipPoliciesParameters, ValidateSponsorshipPoliciesReturnType };
|
|
8
|
+
export { getUserOperationGasPrice, getUserOperationStatus, sponsorUserOperation, pimlicoBundlerActions, pimlicoPaymasterActions, validateSponsorshipPolicies };
|
|
8
9
|
//# sourceMappingURL=pimlico.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.d.ts","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,kCAAkC,EACvC,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACH,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EACrC,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACH,KAAK,qCAAqC,EAC1C,KAAK,8BAA8B,EACnC,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;AAE1C,OAAO,KAAK,EACR,qBAAqB,EACrB,6BAA6B,EAChC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,kCAAkC,CAAA;AAEzC,YAAY,EACR,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,8BAA8B,EAC9B,qBAAqB,EACrB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"pimlico.d.ts","sourceRoot":"","sources":["../../actions/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,kCAAkC,EACvC,wBAAwB,EAC3B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACH,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EACrC,sBAAsB,EACzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACH,KAAK,qCAAqC,EAC1C,KAAK,8BAA8B,EACnC,oBAAoB,EACvB,MAAM,mCAAmC,CAAA;AAE1C,OAAO,KAAK,EACR,qBAAqB,EACrB,6BAA6B,EAChC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EACH,KAAK,qCAAqC,EAC1C,KAAK,qCAAqC,EAC1C,2BAA2B,EAC9B,MAAM,0CAA0C,CAAA;AAEjD,YAAY,EACR,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,8BAA8B,EAC9B,qBAAqB,EACrB,6BAA6B,EAC7B,qCAAqC,EACrC,qCAAqC,EACxC,CAAA;AAED,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC9B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Client } from "viem";
|
|
2
|
+
import { type ValidateSponsorshipPoliciesParameters, type ValidateSponsorshipPoliciesReturnType } from "../../actions/pimlico.js";
|
|
2
3
|
import { type GetUserOperationGasPriceReturnType } from "../../actions/pimlico/getUserOperationGasPrice.js";
|
|
3
4
|
import { type GetUserOperationStatusParameters, type GetUserOperationStatusReturnType } from "../../actions/pimlico/getUserOperationStatus.js";
|
|
4
5
|
import { type PimlocoSponsorUserOperationParameters, type SponsorUserOperationReturnType } from "../../actions/pimlico/sponsorUserOperation.js";
|
|
@@ -70,7 +71,43 @@ export type PimlicoPaymasterClientActions = {
|
|
|
70
71
|
*
|
|
71
72
|
*/
|
|
72
73
|
sponsorUserOperation: (args: PimlocoSponsorUserOperationParameters) => Promise<SponsorUserOperationReturnType>;
|
|
74
|
+
validateSponsorshipPolicies: (args: ValidateSponsorshipPoliciesParameters) => Promise<ValidateSponsorshipPoliciesReturnType>;
|
|
73
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Returns valid sponsorship policies for a userOperation from the list of ids passed
|
|
78
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
|
|
79
|
+
*
|
|
80
|
+
* @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
|
|
81
|
+
* @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* import { createClient } from "viem"
|
|
85
|
+
* import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
|
|
86
|
+
*
|
|
87
|
+
* const bundlerClient = createClient({
|
|
88
|
+
* chain: goerli,
|
|
89
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
90
|
+
* }).extend(pimlicoPaymasterActions)
|
|
91
|
+
|
|
92
|
+
*
|
|
93
|
+
* await bundlerClient.validateSponsorshipPolicies({
|
|
94
|
+
* userOperation: userOperationWithDummySignature,
|
|
95
|
+
* entryPoint: entryPoint,
|
|
96
|
+
* sponsorshipPolicyIds: ["sp_shiny_puma"]
|
|
97
|
+
* })
|
|
98
|
+
* Returns
|
|
99
|
+
* [
|
|
100
|
+
* {
|
|
101
|
+
* sponsorshipPolicyId: "sp_shiny_puma",
|
|
102
|
+
* data: {
|
|
103
|
+
* name: "Shiny Puma",
|
|
104
|
+
* author: "Pimlico",
|
|
105
|
+
* icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
|
|
106
|
+
* description: "This policy is for testing purposes only"
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* ]
|
|
110
|
+
*/
|
|
74
111
|
export declare const pimlicoPaymasterActions: (client: Client) => PimlicoPaymasterClientActions;
|
|
75
112
|
/**
|
|
76
113
|
* TODO: Add support for pimlicoActions after we support all the actions of v2 of the Pimlico API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.d.ts","sourceRoot":"","sources":["../../../clients/decorators/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,MAAM,CAAA;AACxC,OAAO,EACH,KAAK,kCAAk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E;;;;;;;;;;;;;;;;;;OAkBG;IACH,sBAAsB,EAAE,CACpB,IAAI,EAAE,gCAAgC,KACrC,OAAO,CAAC,gCAAgC,CAAC,CAAA;CACjD,CAAA;AAED,eAAO,MAAM,qBAAqB,WACtB,MAAM,KACf,qBAKD,CAAA;AAEF,MAAM,MAAM,6BAA6B,GAAG;IACxC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,EAAE,CAClB,IAAI,EAAE,qCAAqC,KAC1C,OAAO,CAAC,8BAA8B,CAAC,CAAA;IAE5C,2BAA2B,EAAE,CACzB,IAAI,EAAE,qCAAqC,KAC1C,OAAO,CAAC,qCAAqC,CAAC,CAAA;CACtD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,uBAAuB,WACxB,MAAM,KACf,6BAMD,CAAA;AAEF;;GAEG"}
|
|
@@ -47,6 +47,23 @@ export type PimlicoPaymasterRpcSchema = [
|
|
|
47
47
|
verificationGasLimit: Hex;
|
|
48
48
|
callGasLimit: Hex;
|
|
49
49
|
};
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
Method: "pm_validateSponsorshipPolicies";
|
|
53
|
+
Parameters: [
|
|
54
|
+
userOperation: UserOperationWithBigIntAsHex,
|
|
55
|
+
entryPoint: Address,
|
|
56
|
+
sponsorshipPolicyIds: string[]
|
|
57
|
+
];
|
|
58
|
+
ReturnType: {
|
|
59
|
+
sponsorshipPolicyId: string;
|
|
60
|
+
data: {
|
|
61
|
+
name: string | null;
|
|
62
|
+
author: string | null;
|
|
63
|
+
icon: string | null;
|
|
64
|
+
description: string | null;
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|
50
67
|
}
|
|
51
68
|
];
|
|
52
69
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pimlico.d.ts","sourceRoot":"","sources":["../../types/pimlico.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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AAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACpC;QACI,MAAM,EAAE,yBAAyB,CAAA;QACjC,UAAU,EAAE;YACR,aAAa,EAAE,SAAS,CACpB,4BAA4B,EAC1B,cAAc,GACd,oBAAoB,GACpB,sBAAsB,GACtB,kBAAkB,CACvB;YACD,UAAU,EAAE,OAAO;YACnB,QAAQ,CAAC,EAAE;gBACP,mBAAmB,CAAC,EAAE,MAAM,CAAA;aAC/B;SACJ,CAAA;QACD,UAAU,EAAE;YACR,gBAAgB,EAAE,GAAG,CAAA;YACrB,kBAAkB,EAAE,GAAG,CAAA;YACvB,oBAAoB,EAAE,GAAG,CAAA;YACzB,YAAY,EAAE,GAAG,CAAA;SACpB,CAAA;KACJ;IACD;QACI,MAAM,EAAE,gCAAgC,CAAA;QACxC,UAAU,EAAE;YACR,aAAa,EAAE,4BAA4B;YAC3C,UAAU,EAAE,OAAO;YACnB,oBAAoB,EAAE,MAAM,EAAE;SACjC,CAAA;QACD,UAAU,EAAE;YACR,mBAAmB,EAAE,MAAM,CAAA;YAC3B,IAAI,EAAE;gBACF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;gBACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;gBACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;gBACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;aAC7B,CAAA;SACJ,EAAE,CAAA;KACN;CACJ,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { UserOperation } from "../types";
|
|
2
|
+
export type GetRequiredPrefundReturnType = {
|
|
3
|
+
userOperation: UserOperation;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Returns the minimum required funds in the senders's smart account to execute the user operation.
|
|
8
|
+
*
|
|
9
|
+
* @param arags: {userOperation} as {@link UserOperation}
|
|
10
|
+
* @returns requiredPrefund as {@link bigint}
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { getRequiredPrefund } from "permissionless/utils"
|
|
14
|
+
*
|
|
15
|
+
* const requiredPrefund = getRequiredPrefund({
|
|
16
|
+
* userOperation
|
|
17
|
+
* })
|
|
18
|
+
*/
|
|
19
|
+
export declare const getRequiredPrefund: ({ userOperation }: GetRequiredPrefundReturnType) => bigint;
|
|
20
|
+
//# sourceMappingURL=getRequiredPrefund.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRequiredPrefund.d.ts","sourceRoot":"","sources":["../../utils/getRequiredPrefund.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,MAAM,MAAM,4BAA4B,GAAG;IACvC,aAAa,EAAE,aAAa,CAAA;CAC/B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,sBAE5B,4BAA4B,KAAG,MAQjC,CAAA"}
|
package/_types/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Account, Address } from "viem";
|
|
2
|
+
import { type GetRequiredPrefundReturnType, getRequiredPrefund } from "./getRequiredPrefund.js";
|
|
2
3
|
import { type GetUserOperationHashParams, getUserOperationHash } from "./getUserOperationHash.js";
|
|
3
4
|
import { AccountOrClientNotFoundError, signUserOperationHashWithECDSA } from "./signUserOperationHashWithECDSA.js";
|
|
4
5
|
export declare function parseAccount(account: Address | Account): Account;
|
|
5
|
-
export { getUserOperationHash, type GetUserOperationHashParams, signUserOperationHashWithECDSA, AccountOrClientNotFoundError };
|
|
6
|
+
export { getUserOperationHash, getRequiredPrefund, type GetRequiredPrefundReturnType, type GetUserOperationHashParams, signUserOperationHashWithECDSA, AccountOrClientNotFoundError };
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EACH,KAAK,0BAA0B,EAC/B,oBAAoB,EACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,4BAA4B,EAC5B,8BAA8B,EACjC,MAAM,qCAAqC,CAAA;AAE5C,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAIhE;AAED,OAAO,EACH,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC/B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EACH,KAAK,4BAA4B,EACjC,kBAAkB,EACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACH,KAAK,0BAA0B,EAC/B,oBAAoB,EACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,4BAA4B,EAC5B,8BAA8B,EACjC,MAAM,qCAAqC,CAAA;AAE5C,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAIhE;AAED,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,4BAA4B,EAC/B,CAAA"}
|
|
@@ -62,7 +62,7 @@ const SAFE_VERSION_TO_ADDRESSES_MAP: {
|
|
|
62
62
|
} = {
|
|
63
63
|
"1.4.1": {
|
|
64
64
|
ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
|
|
65
|
-
SAFE_4337_MODULE_ADDRESS: "
|
|
65
|
+
SAFE_4337_MODULE_ADDRESS: "0xa581c4A4DB7175302464fF3C06380BC3270b4037",
|
|
66
66
|
SAFE_PROXY_FACTORY_ADDRESS:
|
|
67
67
|
"0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
|
|
68
68
|
SAFE_SINGLETON_ADDRESS: "0x41675C099F32341bf84BFc5382aF534df5C7461a",
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Client, Transport } from "viem"
|
|
2
|
+
import type { PimlicoPaymasterRpcSchema } from "../../types/pimlico.js"
|
|
3
|
+
import type {
|
|
4
|
+
UserOperation,
|
|
5
|
+
UserOperationWithBigIntAsHex
|
|
6
|
+
} from "../../types/userOperation.js"
|
|
7
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
8
|
+
|
|
9
|
+
export type ValidateSponsorshipPoliciesParameters = {
|
|
10
|
+
userOperation: UserOperation
|
|
11
|
+
entryPoint: Address
|
|
12
|
+
sponsorshipPolicyIds: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ValidateSponsorshipPoliciesReturnType = {
|
|
16
|
+
sponsorshipPolicyId: string
|
|
17
|
+
data: {
|
|
18
|
+
name: string | null
|
|
19
|
+
author: string | null
|
|
20
|
+
icon: string | null
|
|
21
|
+
description: string | null
|
|
22
|
+
}
|
|
23
|
+
}[]
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns valid sponsorship policies for a userOperation from the list of ids passed
|
|
27
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
|
|
28
|
+
*
|
|
29
|
+
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
|
|
30
|
+
* @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
|
|
31
|
+
* @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { createClient } from "viem"
|
|
35
|
+
* import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
|
|
36
|
+
*
|
|
37
|
+
* const bundlerClient = createClient({
|
|
38
|
+
* chain: goerli,
|
|
39
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
40
|
+
* })
|
|
41
|
+
*
|
|
42
|
+
* await validateSponsorshipPolicies(bundlerClient, {
|
|
43
|
+
* userOperation: userOperationWithDummySignature,
|
|
44
|
+
* entryPoint: entryPoint,
|
|
45
|
+
* sponsorshipPolicyIds: ["sp_shiny_puma"]
|
|
46
|
+
* })
|
|
47
|
+
* Returns
|
|
48
|
+
* [
|
|
49
|
+
* {
|
|
50
|
+
* sponsorshipPolicyId: "sp_shiny_puma",
|
|
51
|
+
* data: {
|
|
52
|
+
* name: "Shiny Puma",
|
|
53
|
+
* author: "Pimlico",
|
|
54
|
+
* icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
|
|
55
|
+
* description: "This policy is for testing purposes only"
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ]
|
|
59
|
+
*/
|
|
60
|
+
export const validateSponsorshipPolicies = async <
|
|
61
|
+
TTransport extends Transport = Transport,
|
|
62
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
63
|
+
TAccount extends Account | undefined = Account | undefined
|
|
64
|
+
>(
|
|
65
|
+
client: Client<TTransport, TChain, TAccount, PimlicoPaymasterRpcSchema>,
|
|
66
|
+
args: ValidateSponsorshipPoliciesParameters
|
|
67
|
+
): Promise<ValidateSponsorshipPoliciesReturnType> => {
|
|
68
|
+
return await client.request({
|
|
69
|
+
method: "pm_validateSponsorshipPolicies",
|
|
70
|
+
params: [
|
|
71
|
+
deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex,
|
|
72
|
+
args.entryPoint,
|
|
73
|
+
args.sponsorshipPolicyIds
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
}
|
package/actions/pimlico.ts
CHANGED
|
@@ -22,6 +22,12 @@ import {
|
|
|
22
22
|
pimlicoPaymasterActions
|
|
23
23
|
} from "../clients/decorators/pimlico.js"
|
|
24
24
|
|
|
25
|
+
import {
|
|
26
|
+
type ValidateSponsorshipPoliciesParameters,
|
|
27
|
+
type ValidateSponsorshipPoliciesReturnType,
|
|
28
|
+
validateSponsorshipPolicies
|
|
29
|
+
} from "./pimlico/validateSponsorshipPolicies.js"
|
|
30
|
+
|
|
25
31
|
export type {
|
|
26
32
|
GetUserOperationGasPriceReturnType,
|
|
27
33
|
GetUserOperationStatusParameters,
|
|
@@ -29,7 +35,9 @@ export type {
|
|
|
29
35
|
PimlocoSponsorUserOperationParameters,
|
|
30
36
|
SponsorUserOperationReturnType,
|
|
31
37
|
PimlicoBundlerActions,
|
|
32
|
-
PimlicoPaymasterClientActions
|
|
38
|
+
PimlicoPaymasterClientActions,
|
|
39
|
+
ValidateSponsorshipPoliciesParameters,
|
|
40
|
+
ValidateSponsorshipPoliciesReturnType
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
export {
|
|
@@ -37,5 +45,6 @@ export {
|
|
|
37
45
|
getUserOperationStatus,
|
|
38
46
|
sponsorUserOperation,
|
|
39
47
|
pimlicoBundlerActions,
|
|
40
|
-
pimlicoPaymasterActions
|
|
48
|
+
pimlicoPaymasterActions,
|
|
49
|
+
validateSponsorshipPolicies
|
|
41
50
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Client, Hash } from "viem"
|
|
2
|
+
import {
|
|
3
|
+
type ValidateSponsorshipPoliciesParameters,
|
|
4
|
+
type ValidateSponsorshipPoliciesReturnType,
|
|
5
|
+
validateSponsorshipPolicies
|
|
6
|
+
} from "../../actions/pimlico.js"
|
|
2
7
|
import {
|
|
3
8
|
type GetUserOperationGasPriceReturnType,
|
|
4
9
|
getUserOperationGasPrice
|
|
@@ -99,13 +104,55 @@ export type PimlicoPaymasterClientActions = {
|
|
|
99
104
|
sponsorUserOperation: (
|
|
100
105
|
args: PimlocoSponsorUserOperationParameters
|
|
101
106
|
) => Promise<SponsorUserOperationReturnType>
|
|
107
|
+
|
|
108
|
+
validateSponsorshipPolicies: (
|
|
109
|
+
args: ValidateSponsorshipPoliciesParameters
|
|
110
|
+
) => Promise<ValidateSponsorshipPoliciesReturnType>
|
|
102
111
|
}
|
|
103
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Returns valid sponsorship policies for a userOperation from the list of ids passed
|
|
115
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/ValidateSponsorshipPolicies
|
|
116
|
+
*
|
|
117
|
+
* @param args {@link ValidateSponsorshipPoliciesParameters} UserOperation you want to sponsor & entryPoint.
|
|
118
|
+
* @returns valid sponsorship policies, see {@link ValidateSponsorshipPoliciesReturnType}
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* import { createClient } from "viem"
|
|
122
|
+
* import { validateSponsorshipPolicies } from "permissionless/actions/pimlico"
|
|
123
|
+
*
|
|
124
|
+
* const bundlerClient = createClient({
|
|
125
|
+
* chain: goerli,
|
|
126
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
127
|
+
* }).extend(pimlicoPaymasterActions)
|
|
128
|
+
|
|
129
|
+
*
|
|
130
|
+
* await bundlerClient.validateSponsorshipPolicies({
|
|
131
|
+
* userOperation: userOperationWithDummySignature,
|
|
132
|
+
* entryPoint: entryPoint,
|
|
133
|
+
* sponsorshipPolicyIds: ["sp_shiny_puma"]
|
|
134
|
+
* })
|
|
135
|
+
* Returns
|
|
136
|
+
* [
|
|
137
|
+
* {
|
|
138
|
+
* sponsorshipPolicyId: "sp_shiny_puma",
|
|
139
|
+
* data: {
|
|
140
|
+
* name: "Shiny Puma",
|
|
141
|
+
* author: "Pimlico",
|
|
142
|
+
* icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4...",
|
|
143
|
+
* description: "This policy is for testing purposes only"
|
|
144
|
+
* }
|
|
145
|
+
* }
|
|
146
|
+
* ]
|
|
147
|
+
*/
|
|
104
148
|
export const pimlicoPaymasterActions = (
|
|
105
149
|
client: Client
|
|
106
150
|
): PimlicoPaymasterClientActions => ({
|
|
107
151
|
sponsorUserOperation: async (args: PimlocoSponsorUserOperationParameters) =>
|
|
108
|
-
sponsorUserOperation(client as PimlicoPaymasterClient, args)
|
|
152
|
+
sponsorUserOperation(client as PimlicoPaymasterClient, args),
|
|
153
|
+
validateSponsorshipPolicies: async (
|
|
154
|
+
args: ValidateSponsorshipPoliciesParameters
|
|
155
|
+
) => validateSponsorshipPolicies(client as PimlicoPaymasterClient, args)
|
|
109
156
|
})
|
|
110
157
|
|
|
111
158
|
/**
|
package/package.json
CHANGED
package/types/pimlico.ts
CHANGED
|
@@ -64,5 +64,22 @@ export type PimlicoPaymasterRpcSchema = [
|
|
|
64
64
|
verificationGasLimit: Hex
|
|
65
65
|
callGasLimit: Hex
|
|
66
66
|
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
Method: "pm_validateSponsorshipPolicies"
|
|
70
|
+
Parameters: [
|
|
71
|
+
userOperation: UserOperationWithBigIntAsHex,
|
|
72
|
+
entryPoint: Address,
|
|
73
|
+
sponsorshipPolicyIds: string[]
|
|
74
|
+
]
|
|
75
|
+
ReturnType: {
|
|
76
|
+
sponsorshipPolicyId: string
|
|
77
|
+
data: {
|
|
78
|
+
name: string | null
|
|
79
|
+
author: string | null
|
|
80
|
+
icon: string | null
|
|
81
|
+
description: string | null
|
|
82
|
+
}
|
|
83
|
+
}[]
|
|
67
84
|
}
|
|
68
85
|
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UserOperation } from "../types"
|
|
2
|
+
|
|
3
|
+
export type GetRequiredPrefundReturnType = {
|
|
4
|
+
userOperation: UserOperation
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Returns the minimum required funds in the senders's smart account to execute the user operation.
|
|
10
|
+
*
|
|
11
|
+
* @param arags: {userOperation} as {@link UserOperation}
|
|
12
|
+
* @returns requiredPrefund as {@link bigint}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { getRequiredPrefund } from "permissionless/utils"
|
|
16
|
+
*
|
|
17
|
+
* const requiredPrefund = getRequiredPrefund({
|
|
18
|
+
* userOperation
|
|
19
|
+
* })
|
|
20
|
+
*/
|
|
21
|
+
export const getRequiredPrefund = ({
|
|
22
|
+
userOperation
|
|
23
|
+
}: GetRequiredPrefundReturnType): bigint => {
|
|
24
|
+
const multiplier = userOperation.paymasterAndData.length > 2 ? 3n : 1n
|
|
25
|
+
const requiredGas =
|
|
26
|
+
userOperation.callGasLimit +
|
|
27
|
+
userOperation.verificationGasLimit * multiplier +
|
|
28
|
+
userOperation.preVerificationGas
|
|
29
|
+
|
|
30
|
+
return BigInt(requiredGas) * BigInt(userOperation.maxFeePerGas)
|
|
31
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Account, Address } from "viem"
|
|
2
|
+
import {
|
|
3
|
+
type GetRequiredPrefundReturnType,
|
|
4
|
+
getRequiredPrefund
|
|
5
|
+
} from "./getRequiredPrefund.js"
|
|
2
6
|
import {
|
|
3
7
|
type GetUserOperationHashParams,
|
|
4
8
|
getUserOperationHash
|
|
@@ -16,6 +20,8 @@ export function parseAccount(account: Address | Account): Account {
|
|
|
16
20
|
|
|
17
21
|
export {
|
|
18
22
|
getUserOperationHash,
|
|
23
|
+
getRequiredPrefund,
|
|
24
|
+
type GetRequiredPrefundReturnType,
|
|
19
25
|
type GetUserOperationHashParams,
|
|
20
26
|
signUserOperationHashWithECDSA,
|
|
21
27
|
AccountOrClientNotFoundError
|