@owlprotocol/contracts-account-abstraction
Version:
ERC4337 Account Abstraction support for deploying relevant smart contracts and interacting with UserOps.
57 lines (56 loc) • 2.34 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var getPaymasterStubData_exports = {};
__export(getPaymasterStubData_exports, {
getPaymasterStubData: () => getPaymasterStubData
});
module.exports = __toCommonJS(getPaymasterStubData_exports);
var import_viem = require("viem");
var import_utils = require("viem/utils");
var import_UserOperation = require("../../models/UserOperation.js");
var import_getSupportedEntryPoints = require("../bundler/getSupportedEntryPoints.js");
async function getPaymasterStubData(client, parameters) {
const { entryPointAddress } = parameters;
const { paymaster } = client;
const supportedEntryPoints = await (0, import_utils.getAction)(client, import_getSupportedEntryPoints.getSupportedEntryPoints, "getSupportedEntryPoints")({});
if (!supportedEntryPoints.includes(entryPointAddress)) {
throw new Error(`Unsupported entrypoint ${entryPointAddress}, expected one of ${supportedEntryPoints}`);
}
const validUntil = Date.now() + 3600;
const validAfter = 0;
const paymasterDataUnsigned = (0, import_utils.encodeAbiParameters)(
[
{ name: "validUntil", type: "uint48" },
{ name: "validAfter", type: "uint48" }
],
[validUntil, validAfter]
);
const paymasterDataSigned = (0, import_viem.concatHex)([paymasterDataUnsigned, import_UserOperation.dummySignature]);
const sponsor = {
name: "Owl Protocol",
icon: "https://example.com"
};
return {
paymaster,
paymasterData: paymasterDataSigned,
paymasterVerificationGasLimit: 100000n,
paymasterPostOpGasLimit: 100000n,
sponsor,
isFinal: false
};
}