UNPKG

@owlprotocol/contracts-account-abstraction

Version:

ERC4337 Account Abstraction support for deploying relevant smart contracts and interacting with UserOps.

61 lines (60 loc) 2.43 kB
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 simulateEntryPoint_exports = {}; __export(simulateEntryPoint_exports, { simulateEntryPoint: () => simulateEntryPoint }); module.exports = __toCommonJS(simulateEntryPoint_exports); var import_viem = require("viem"); var import_utils = require("viem/utils"); var import_actions = require("viem/actions"); var import_PimlicoEntryPointSimulations = require("../../artifacts/PimlicoEntryPointSimulations.js"); var import_EntryPoint = require("../../artifacts/EntryPoint.js"); async function simulateEntryPoint(client, parameters) { const { entryPoint, entryPointSimulationsCallData, entryPointSimulationsAddress, stateOverride } = parameters; const callData = (0, import_viem.encodeFunctionData)({ abi: import_PimlicoEntryPointSimulations.abi, functionName: "simulateEntryPoint", args: [entryPoint, entryPointSimulationsCallData] }); const callReturn = await (0, import_utils.getAction)( client, import_actions.call, "call" )({ to: entryPointSimulationsAddress, data: callData, blockTag: "latest", stateOverride: stateOverride ? [stateOverride] : void 0 }); const result = callReturn.data; if (!result) { throw new Error("simulateEntryPoint return empty data"); } const returnBytes = (0, import_viem.decodeAbiParameters)([{ name: "ret", type: "bytes[]" }], result); return returnBytes[0].map((data) => { const decodedDelegateAndError = (0, import_viem.decodeErrorResult)({ abi: import_EntryPoint.abi, data }); if (!decodedDelegateAndError?.args?.[1]) { throw new Error("Unexpected error"); } return decodedDelegateAndError.args[1]; }); }