UNPKG

@owlprotocol/contracts-account-abstraction

Version:

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

273 lines (268 loc) 12.4 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 IPaymaster_exports = {}; __export(IPaymaster_exports, { IPaymaster: () => IPaymaster }); module.exports = __toCommonJS(IPaymaster_exports); const IPaymaster = { compiler: { version: "0.8.23+commit.f704f362" }, language: "Solidity", output: { abi: [ { inputs: [ { internalType: "enum IPaymaster.PostOpMode", name: "mode", type: "uint8" }, { internalType: "bytes", name: "context", type: "bytes" }, { internalType: "uint256", name: "actualGasCost", type: "uint256" }, { internalType: "uint256", name: "actualUserOpFeePerGas", type: "uint256" } ], name: "postOp", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "sender", type: "address" }, { internalType: "uint256", name: "nonce", type: "uint256" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "callData", type: "bytes" }, { internalType: "bytes32", name: "accountGasLimits", type: "bytes32" }, { internalType: "uint256", name: "preVerificationGas", type: "uint256" }, { internalType: "bytes32", name: "gasFees", type: "bytes32" }, { internalType: "bytes", name: "paymasterAndData", type: "bytes" }, { internalType: "bytes", name: "signature", type: "bytes" } ], internalType: "struct PackedUserOperation", name: "userOp", type: "tuple" }, { internalType: "bytes32", name: "userOpHash", type: "bytes32" }, { internalType: "uint256", name: "maxCost", type: "uint256" } ], name: "validatePaymasterUserOp", outputs: [ { internalType: "bytes", name: "context", type: "bytes" }, { internalType: "uint256", name: "validationData", type: "uint256" } ], stateMutability: "nonpayable", type: "function" } ], devdoc: { kind: "dev", methods: { "postOp(uint8,bytes,uint256,uint256)": { params: { actualGasCost: "- Actual gas used so far (without this postOp call).", actualUserOpFeePerGas: "- the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas and maxPriorityFee (and basefee) It is not the same as tx.gasprice, which is what the bundler pays.", context: "- The context value returned by validatePaymasterUserOp", mode: "- Enum with the following options: opSucceeded - User operation succeeded. opReverted - User op reverted. The paymaster still has to pay for gas. postOpReverted - never passed in a call to postOp()." } }, "validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)": { params: { maxCost: "- The maximum cost of this transaction (based on maximum gas and gas price from userOp).", userOp: "- The user operation.", userOpHash: "- Hash of the user's request data." }, returns: { context: " - Value to send to a postOp. Zero length to signify postOp is not required.", validationData: '- Signature and time-range of this operation, encoded the same as the return value of validateUserOperation. <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure, other values are invalid for paymaster. <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite" <6-byte> validAfter - first timestamp this operation is valid Note that the validation code cannot use block.timestamp (or block.number) directly.' } } }, version: 1 }, userdoc: { kind: "user", methods: { "postOp(uint8,bytes,uint256,uint256)": { notice: "Post-operation handler. Must verify sender is the entryPoint." }, "validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)": { notice: "Payment validation: check if paymaster agrees to pay. Must verify sender is the entryPoint. Revert to reject this request. Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted). The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns." } }, notice: "The interface exposed by a paymaster contract, who agrees to pay the gas for user's operations. A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.", version: 1 } }, settings: { compilationTarget: { "@account-abstraction/contracts/interfaces/IPaymaster.sol": "IPaymaster" }, evmVersion: "paris", libraries: {}, metadata: { bytecodeHash: "ipfs", useLiteralContent: true }, optimizer: { enabled: true, runs: 1e6 }, remappings: [], viaIR: true }, sources: { "@account-abstraction/contracts/interfaces/IPaymaster.sol": { content: `// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.5; import "./PackedUserOperation.sol"; /** * The interface exposed by a paymaster contract, who agrees to pay the gas for user's operations. * A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction. */ interface IPaymaster { enum PostOpMode { // User op succeeded. opSucceeded, // User op reverted. Still has to pay for gas. opReverted, // Only used internally in the EntryPoint (cleanup after postOp reverts). Never calling paymaster with this value postOpReverted } /** * Payment validation: check if paymaster agrees to pay. * Must verify sender is the entryPoint. * Revert to reject this request. * Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted). * The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns. * @param userOp - The user operation. * @param userOpHash - Hash of the user's request data. * @param maxCost - The maximum cost of this transaction (based on maximum gas and gas price from userOp). * @return context - Value to send to a postOp. Zero length to signify postOp is not required. * @return validationData - Signature and time-range of this operation, encoded the same as the return * value of validateUserOperation. * <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure, * other values are invalid for paymaster. * <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite" * <6-byte> validAfter - first timestamp this operation is valid * Note that the validation code cannot use block.timestamp (or block.number) directly. */ function validatePaymasterUserOp( PackedUserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost ) external returns (bytes memory context, uint256 validationData); /** * Post-operation handler. * Must verify sender is the entryPoint. * @param mode - Enum with the following options: * opSucceeded - User operation succeeded. * opReverted - User op reverted. The paymaster still has to pay for gas. * postOpReverted - never passed in a call to postOp(). * @param context - The context value returned by validatePaymasterUserOp * @param actualGasCost - Actual gas used so far (without this postOp call). * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas * and maxPriorityFee (and basefee) * It is not the same as tx.gasprice, which is what the bundler pays. */ function postOp( PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas ) external; } `, keccak256: "0x49d8dbf8a85b006bcd89bbc40e4e9e113997cc016007de85263bdae70572d07f", license: "GPL-3.0" }, "@account-abstraction/contracts/interfaces/PackedUserOperation.sol": { content: "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/**\n * User Operation struct\n * @param sender - The sender account of this request.\n * @param nonce - Unique value the sender uses to verify it is not a replay.\n * @param initCode - If set, the account contract will be created by this constructor/\n * @param callData - The method call to execute on this account.\n * @param accountGasLimits - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\n * @param preVerificationGas - Gas not calculated by the handleOps method, but added to the gas paid.\n * Covers batch overhead.\n * @param gasFees - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.\n * @param paymasterAndData - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\n * The paymaster will pay for the transaction instead of the sender.\n * @param signature - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\n */\nstruct PackedUserOperation {\n address sender;\n uint256 nonce;\n bytes initCode;\n bytes callData;\n bytes32 accountGasLimits;\n uint256 preVerificationGas;\n bytes32 gasFees;\n bytes paymasterAndData;\n bytes signature;\n}\n", keccak256: "0x1129b46381db68eddbc5cb49e50664667b66b03c480453858e7b25eabe444359", license: "GPL-3.0" } }, version: 1 };