Skip to content

Commit

Permalink
setup for the token paymaster
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivaanshK committed Aug 30, 2024
1 parent 72fe3ea commit 5b48dfb
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/v3-periphery"]
path = lib/v3-periphery
url = https://github.com/Uniswap/v3-periphery
[submodule "lib/v3-core"]
path = lib/v3-core
url = https://github.com/Uniswap/v3-core
File renamed without changes.
6 changes: 6 additions & 0 deletions contracts/common/BiconomyTokenPaymasterErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.26;

contract BiconomyTokenPaymasterErrors {

}
6 changes: 6 additions & 0 deletions contracts/interfaces/IBiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;

interface IBiconomyTokenPaymaster {

}
7 changes: 2 additions & 5 deletions contracts/mocks/Imports.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ pragma solidity ^0.8.26;

/* solhint-disable reason-string */

import "account-abstraction/contracts/core/EntryPoint.sol";
import "account-abstraction/contracts/core/EntryPointSimulations.sol";

import "@biconomy-devx/erc7579-msa/contracts/SmartAccount.sol";
import "@biconomy-devx/erc7579-msa/contracts/factory/AccountFactory.sol";
import "@account-abstraction/contracts/core/EntryPoint.sol";
import "@account-abstraction/contracts/core/EntryPointSimulations.sol";
2 changes: 1 addition & 1 deletion contracts/sponsorship/BiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "@account-abstraction/contracts/core/UserOperationLib.sol";
import "@account-abstraction/contracts/core/Helpers.sol";
import { SignatureCheckerLib } from "@solady/src/utils/SignatureCheckerLib.sol";
import { ECDSA as ECDSA_solady } from "@solady/src/utils/ECDSA.sol";
import { BiconomySponsorshipPaymasterErrors } from "../common/Errors.sol";
import { BiconomySponsorshipPaymasterErrors } from "../common/BiconomySponsorshipPaymasterErrors.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeTransferLib } from "@solady/src/utils/SafeTransferLib.sol";
Expand Down
72 changes: 61 additions & 11 deletions contracts/token/BiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,67 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;

import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { ECDSA as ECDSA_solady } from "@solady/src/utils/ECDSA.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IEntryPoint} from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import {UserOperationLib} from "@account-abstraction/contracts/core/UserOperationLib.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {BasePaymaster} from "../base/BasePaymaster.sol";
import "@account-abstraction/contracts/core/Helpers.sol" as Helpers;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import { IEntryPoint } from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import { SignatureCheckerLib } from "@solady/src/utils/SignatureCheckerLib.sol";
import { PackedUserOperation, UserOperationLib } from "@account-abstraction/contracts/core/UserOperationLib.sol";
import { BasePaymaster } from "../base/BasePaymaster.sol";
import { BiconomyTokenPaymasterErrors } from "../common/BiconomyTokenPaymasterErrors.sol";
import { IBiconomyTokenPaymaster } from "../interfaces/IBiconomyTokenPaymaster.sol";

contract BiconomyTokenPaymaster is
BasePaymaster,
ReentrancyGuard,
BiconomyTokenPaymasterErrors,
IBiconomyTokenPaymaster
{
using UserOperationLib for PackedUserOperation;
using SignatureCheckerLib for address;

contract BiconomyTokenPaymaster {

}
constructor(
address _owner,
IEntryPoint _entryPoint
)
BasePaymaster(_owner, _entryPoint)
{ }

/**
* @dev Validate a user operation.
* This method is abstract in BasePaymaster and must be implemented in derived contracts.
* @param userOp The user operation.
* @param userOpHash The hash of the user operation.
* @param maxCost The maximum cost of the user operation.
*/
function _validatePaymasterUserOp(
PackedUserOperation calldata userOp,
bytes32 userOpHash,
uint256 maxCost
)
internal
override
returns (bytes memory context, uint256 validationData)
{
// Implementation of user operation validation logic
}

/**
* @dev Post-operation handler.
* This method is abstract in BasePaymaster and must be implemented in derived contracts.
* @param mode The mode of the post operation (opSucceeded, opReverted, or postOpReverted).
* @param context The context value returned by validatePaymasterUserOp.
* @param actualGasCost Actual gas used so far (excluding this postOp call).
* @param actualUserOpFeePerGas The gas price this UserOp pays.
*/
function _postOp(
PostOpMode mode,
bytes calldata context,
uint256 actualGasCost,
uint256 actualUserOpFeePerGas
)
internal
override
{
// Implementation of post-operation logic
}
}
2 changes: 1 addition & 1 deletion contracts/utils/SoladyOwnable.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import { Ownable } from "solady/src/auth/Ownable.sol";
import { Ownable } from "@solady/src/auth/Ownable.sol";

contract SoladyOwnable is Ownable {
constructor(address _owner) Ownable() {
Expand Down
1 change: 1 addition & 0 deletions lib/v3-core
Submodule v3-core added at e3589b
1 change: 1 addition & 0 deletions lib/v3-periphery
Submodule v3-periphery added at 80f26c
2 changes: 2 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@prb/test/=node_modules/@prb/test/
@nexus/=lib/nexus/
@forge-std/=lib/forge-std/
@uniswap/v3-periphery/=lib/v3-periphery
@uniswap/v3-core/=lib/v3-core
@account-abstraction=node_modules/account-abstraction/
@modulekit/=node_modules/modulekit/src/
@sentinellist/=node_modules/sentinellist/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.26;

import { EventsAndErrors } from "nexus/test/foundry/utils/EventsAndErrors.sol";
import { BiconomySponsorshipPaymasterErrors } from "./../../../contracts/common/Errors.sol";
import { BiconomySponsorshipPaymasterErrors } from "./../../../contracts/common/BiconomySponsorshipPaymasterErrors.sol";

contract BaseEventsAndErrors is EventsAndErrors, BiconomySponsorshipPaymasterErrors {
// ==========================
Expand Down
1 change: 1 addition & 0 deletions test/foundry/base/TestBase.sol → test/base/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ abstract contract TestBase is CheatCodes, BaseEventsAndErrors {
uint32 dynamicAdjustment
)
internal
view
{
(uint256 expectedDynamicAdjustment, uint256 actualDynamicAdjustment) = getDynamicAdjustments(
bicoPaymaster, initialDappPaymasterBalance, initialFeeCollectorBalance, dynamicAdjustment
Expand Down

0 comments on commit 5b48dfb

Please sign in to comment.