Skip to content

Commit

Permalink
Introduced IBaseOpenfortPaymaster
Browse files Browse the repository at this point in the history
  • Loading branch information
eloi010 committed Oct 9, 2023
1 parent 160d7ef commit d6b5533
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions contracts/interfaces/IBaseOpenfortPaymaster.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import {IPaymaster, UserOperation} from "account-abstraction/interfaces/IPaymaster.sol";

interface IBaseOpenfortPaymaster is IPaymaster {
/**
* @inheritdoc IPaymaster
*/
function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost)
external
returns (bytes memory context, uint256 validationData);

/**
* @inheritdoc IPaymaster
*/
function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external;

/**
* Return current paymaster's deposit on the EntryPoint.
*/
function getDeposit() external view returns (uint256);
}
8 changes: 4 additions & 4 deletions contracts/paymaster/BaseOpenfortPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
pragma solidity ^0.8.19;

import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {IPaymaster} from "account-abstraction/interfaces/IPaymaster.sol";
import {IEntryPoint, UserOperation, UserOperationLib} from "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/core/Helpers.sol";
import {IBaseOpenfortPaymaster} from "../interfaces/IBaseOpenfortPaymaster.sol";
import {OpenfortErrorsAndEvents} from "../interfaces/OpenfortErrorsAndEvents.sol";

/**
* Helper class for creating an Openfort paymaster.
* Provides helper methods for staking.
* Validates that the postOp is called only by the EntryPoint
*/
abstract contract BaseOpenfortPaymaster is IPaymaster, Ownable2Step {
abstract contract BaseOpenfortPaymaster is IBaseOpenfortPaymaster, Ownable2Step {
uint256 private constant INIT_POST_OP_GAS = 40_000; // Initial value for postOpGas
uint256 internal constant ADDRESS_OFFSET = 20; // length of an address
IEntryPoint public immutable entryPoint;
Expand All @@ -32,7 +32,7 @@ abstract contract BaseOpenfortPaymaster is IPaymaster, Ownable2Step {
}

/**
* @inheritdoc IPaymaster
* @inheritdoc IBaseOpenfortPaymaster
*/
function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 maxCost)
external
Expand All @@ -49,7 +49,7 @@ abstract contract BaseOpenfortPaymaster is IPaymaster, Ownable2Step {
returns (bytes memory context, uint256 validationData);

/**
* @inheritdoc IPaymaster
* @inheritdoc IBaseOpenfortPaymaster
*/
function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external override {
_requireFromEntryPoint();
Expand Down

0 comments on commit d6b5533

Please sign in to comment.