From 72fe3ead5e652aa100017be31f67e16842e4017f Mon Sep 17 00:00:00 2001 From: Shivaansh Kapoor Date: Fri, 30 Aug 2024 11:57:04 +0400 Subject: [PATCH] temp --- .gitignore | 3 + contracts/base/BasePaymaster.sol | 6 +- .../IBiconomySponsorshipPaymaster.sol | 45 +++- .../interfaces/IBiconomyTokenPaymaster.sol | 0 contracts/references/SampleTokenPaymaster.sol | 217 ++++++++++++++++++ ...t.sol => BiconomySponsorshipPaymaster.sol} | 37 +-- contracts/token/BiconomyTokenPaymaster.sol | 17 ++ remappings.txt | 12 +- scripts/hardhat/deploy.ts | 31 --- .../sample/deploy-verifying-paymaster.ts | 46 ---- test/foundry/base/TestBase.sol | 3 +- ...ipPaymasterWithDynamicAdjustmentTest.t.sol | 3 +- ..._TestSponsorshipPaymasterWithPremium.t.sol | 3 +- 13 files changed, 309 insertions(+), 114 deletions(-) create mode 100644 contracts/interfaces/IBiconomyTokenPaymaster.sol create mode 100644 contracts/references/SampleTokenPaymaster.sol rename contracts/sponsorship/{SponsorshipPaymasterWithDynamicAdjustment.sol => BiconomySponsorshipPaymaster.sol} (90%) create mode 100644 contracts/token/BiconomyTokenPaymaster.sol delete mode 100644 scripts/hardhat/deploy.ts delete mode 100644 scripts/hardhat/sample/deploy-verifying-paymaster.ts diff --git a/.gitignore b/.gitignore index 52b85d9..36412ab 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,9 @@ node_modules /coverage /coverage.json +/deploy.txt +deploy.txt + node_modules .env diff --git a/contracts/base/BasePaymaster.sol b/contracts/base/BasePaymaster.sol index 8a6f1a0..bc1042e 100644 --- a/contracts/base/BasePaymaster.sol +++ b/contracts/base/BasePaymaster.sol @@ -5,9 +5,9 @@ pragma solidity ^0.8.26; import { SoladyOwnable } from "../utils/SoladyOwnable.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import { IPaymaster } from "account-abstraction/contracts/interfaces/IPaymaster.sol"; -import { IEntryPoint } from "account-abstraction/contracts/interfaces/IEntryPoint.sol"; -import "account-abstraction/contracts/core/UserOperationLib.sol"; +import { IPaymaster } from "@account-abstraction/contracts/interfaces/IPaymaster.sol"; +import { IEntryPoint } from "@account-abstraction/contracts/interfaces/IEntryPoint.sol"; +import "@account-abstraction/contracts/core/UserOperationLib.sol"; /** * Helper class for creating a paymaster. * provides helper methods for staking. diff --git a/contracts/interfaces/IBiconomySponsorshipPaymaster.sol b/contracts/interfaces/IBiconomySponsorshipPaymaster.sol index 00a4c39..a2dcf17 100644 --- a/contracts/interfaces/IBiconomySponsorshipPaymaster.sol +++ b/contracts/interfaces/IBiconomySponsorshipPaymaster.sol @@ -1,12 +1,13 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.26; -interface IBiconomySponsorshipPaymaster { +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { PackedUserOperation } from "@account-abstraction/contracts/core/UserOperationLib.sol"; + +interface IBiconomySponsorshipPaymaster{ event UnaccountedGasChanged(uint256 indexed oldValue, uint256 indexed newValue); event FixedDynamicAdjustmentChanged(uint32 indexed oldValue, uint32 indexed newValue); - event VerifyingSignerChanged(address indexed oldSigner, address indexed newSigner, address indexed actor); - event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector, address indexed actor); event GasDeposited(address indexed paymasterId, uint256 indexed value); event GasWithdrawn(address indexed paymasterId, address indexed to, uint256 indexed value); @@ -14,4 +15,40 @@ interface IBiconomySponsorshipPaymaster { event DynamicAdjustmentCollected(address indexed paymasterId, uint256 indexed dynamicAdjustment); event Received(address indexed sender, uint256 value); event TokensWithdrawn(address indexed token, address indexed to, uint256 indexed amount, address actor); + + function depositFor(address paymasterId) external payable; + + function setSigner(address _newVerifyingSigner) external payable; + + function setFeeCollector(address _newFeeCollector) external payable; + + function setUnaccountedGas(uint48 value) external payable; + + function withdrawERC20(IERC20 token, address target, uint256 amount) external; + + function withdrawEth(address payable recipient, uint256 amount) external payable; + + function getBalance(address paymasterId) external view returns (uint256 balance); + + function getHash( + PackedUserOperation calldata userOp, + address paymasterId, + uint48 validUntil, + uint48 validAfter, + uint32 dynamicAdjustment + ) + external + view + returns (bytes32); + + function parsePaymasterAndData(bytes calldata paymasterAndData) + external + pure + returns ( + address paymasterId, + uint48 validUntil, + uint48 validAfter, + uint32 dynamicAdjustment, + bytes calldata signature + ); } diff --git a/contracts/interfaces/IBiconomyTokenPaymaster.sol b/contracts/interfaces/IBiconomyTokenPaymaster.sol new file mode 100644 index 0000000..e69de29 diff --git a/contracts/references/SampleTokenPaymaster.sol b/contracts/references/SampleTokenPaymaster.sol new file mode 100644 index 0000000..7da5e64 --- /dev/null +++ b/contracts/references/SampleTokenPaymaster.sol @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.23; + +// Import the required libraries and contracts +import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; + +import "@account-abstraction/contracts/interfaces/IEntryPoint.sol"; +import "@account-abstraction/contracts/core/BasePaymaster.sol"; +import "@account-abstraction/contracts/core/Helpers.sol"; +import "@account-abstraction/contracts/samples/utils/UniswapHelper.sol"; +import "@account-abstraction/contracts/samples/utils/OracleHelper.sol"; + +/// @title Sample ERC-20 Token Paymaster for ERC-4337 +/// This Paymaster covers gas fees in exchange for ERC20 tokens charged using allowance pre-issued by ERC-4337 accounts. +/// The contract refunds excess tokens if the actual gas cost is lower than the initially provided amount. +/// The token price cannot be queried in the validation code due to storage access restrictions of ERC-4337. +/// The price is cached inside the contract and is updated in the 'postOp' stage if the change is >10%. +/// It is theoretically possible the token has depreciated so much since the last 'postOp' the refund becomes negative. +/// The contract reverts the inner user transaction in that case but keeps the charge. +/// The contract also allows honest clients to prepay tokens at a higher price to avoid getting reverted. +/// It also allows updating price configuration and withdrawing tokens by the contract owner. +/// The contract uses an Oracle to fetch the latest token prices. +/// @dev Inherits from BasePaymaster. +contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper { + + using UserOperationLib for PackedUserOperation; + + struct TokenPaymasterConfig { + /// @notice The price markup percentage applied to the token price (1e26 = 100%). Ranges from 1e26 to 2e26 + uint256 priceMarkup; + + /// @notice Exchange tokens to native currency if the EntryPoint balance of this Paymaster falls below this value + uint128 minEntryPointBalance; + + /// @notice Estimated gas cost for refunding tokens after the transaction is completed + uint48 refundPostopCost; + + /// @notice Transactions are only valid as long as the cached price is not older than this value + uint48 priceMaxAge; + } + + event ConfigUpdated(TokenPaymasterConfig tokenPaymasterConfig); + + event UserOperationSponsored(address indexed user, uint256 actualTokenCharge, uint256 actualGasCost, uint256 actualTokenPriceWithMarkup); + + event Received(address indexed sender, uint256 value); + + /// @notice All 'price' variables are multiplied by this value to avoid rounding up + uint256 private constant PRICE_DENOMINATOR = 1e26; + + TokenPaymasterConfig public tokenPaymasterConfig; + + /// @notice Initializes the TokenPaymaster contract with the given parameters. + /// @param _token The ERC20 token used for transaction fee payments. + /// @param _entryPoint The EntryPoint contract used in the Account Abstraction infrastructure. + /// @param _wrappedNative The ERC-20 token that wraps the native asset for current chain. + /// @param _uniswap The Uniswap V3 SwapRouter contract. + /// @param _tokenPaymasterConfig The configuration for the Token Paymaster. + /// @param _oracleHelperConfig The configuration for the Oracle Helper. + /// @param _uniswapHelperConfig The configuration for the Uniswap Helper. + /// @param _owner The address that will be set as the owner of the contract. + constructor( + IERC20Metadata _token, + IEntryPoint _entryPoint, + IERC20 _wrappedNative, + ISwapRouter _uniswap, + TokenPaymasterConfig memory _tokenPaymasterConfig, + OracleHelperConfig memory _oracleHelperConfig, + UniswapHelperConfig memory _uniswapHelperConfig, + address _owner + ) + BasePaymaster( + _entryPoint + ) + OracleHelper( + _oracleHelperConfig + ) + UniswapHelper( + _token, + _wrappedNative, + _uniswap, + _uniswapHelperConfig + ) + { + setTokenPaymasterConfig(_tokenPaymasterConfig); + transferOwnership(_owner); + } + + /// @notice Updates the configuration for the Token Paymaster. + /// @param _tokenPaymasterConfig The new configuration struct. + function setTokenPaymasterConfig( + TokenPaymasterConfig memory _tokenPaymasterConfig + ) public onlyOwner { + require(_tokenPaymasterConfig.priceMarkup <= 2 * PRICE_DENOMINATOR, "TPM: price markup too high"); + require(_tokenPaymasterConfig.priceMarkup >= PRICE_DENOMINATOR, "TPM: price markup too low"); + tokenPaymasterConfig = _tokenPaymasterConfig; + emit ConfigUpdated(_tokenPaymasterConfig); + } + + function setUniswapConfiguration( + UniswapHelperConfig memory _uniswapHelperConfig + ) external onlyOwner { + _setUniswapHelperConfiguration(_uniswapHelperConfig); + } + + /// @notice Allows the contract owner to withdraw a specified amount of tokens from the contract. + /// @param to The address to transfer the tokens to. + /// @param amount The amount of tokens to transfer. + function withdrawToken(address to, uint256 amount) external onlyOwner { + SafeERC20.safeTransfer(token, to, amount); + } + + /// @notice Validates a paymaster user operation and calculates the required token amount for the transaction. + /// @param userOp The user operation data. + /// @param requiredPreFund The maximum cost (in native token) the paymaster has to prefund. + /// @return context The context containing the token amount and user sender address (if applicable). + /// @return validationResult A uint256 value indicating the result of the validation (always 0 in this implementation). + function _validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32, uint256 requiredPreFund) + internal + override + returns (bytes memory context, uint256 validationResult) {unchecked { + uint256 priceMarkup = tokenPaymasterConfig.priceMarkup; + uint256 dataLength = userOp.paymasterAndData.length - PAYMASTER_DATA_OFFSET; + require(dataLength == 0 || dataLength == 32, + "TPM: invalid data length" + ); + uint256 maxFeePerGas = userOp.unpackMaxFeePerGas(); + uint256 refundPostopCost = tokenPaymasterConfig.refundPostopCost; + require(refundPostopCost < userOp.unpackPostOpGasLimit(), "TPM: postOpGasLimit too low"); + uint256 preChargeNative = requiredPreFund + (refundPostopCost * maxFeePerGas); + // note: as price is in native-asset-per-token and we want more tokens increasing it means dividing it by markup + uint256 cachedPriceWithMarkup = cachedPrice * PRICE_DENOMINATOR / priceMarkup; + if (dataLength == 32) { + uint256 clientSuppliedPrice = uint256(bytes32(userOp.paymasterAndData[PAYMASTER_DATA_OFFSET : PAYMASTER_DATA_OFFSET + 32])); + if (clientSuppliedPrice < cachedPriceWithMarkup) { + // note: smaller number means 'more native asset per token' + cachedPriceWithMarkup = clientSuppliedPrice; + } + } + uint256 tokenAmount = weiToToken(preChargeNative, cachedPriceWithMarkup); + SafeERC20.safeTransferFrom(token, userOp.sender, address(this), tokenAmount); + context = abi.encode(tokenAmount, userOp.sender); + validationResult = _packValidationData( + false, + uint48(cachedPriceTimestamp + tokenPaymasterConfig.priceMaxAge), + 0 + ); + } + } + + /// @notice Performs post-operation tasks, such as updating the token price and refunding excess tokens. + /// @dev This function is called after a user operation has been executed or reverted. + /// @param context The context containing the token amount and user sender address. + /// @param actualGasCost The actual gas cost of the transaction. + /// @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, bytes calldata context, uint256 actualGasCost, uint256 actualUserOpFeePerGas) internal override { + unchecked { + uint256 priceMarkup = tokenPaymasterConfig.priceMarkup; + ( + uint256 preCharge, + address userOpSender + ) = abi.decode(context, (uint256, address)); + uint256 _cachedPrice = updateCachedPrice(false); + // note: as price is in native-asset-per-token and we want more tokens increasing it means dividing it by markup + uint256 cachedPriceWithMarkup = _cachedPrice * PRICE_DENOMINATOR / priceMarkup; + // Refund tokens based on actual gas cost + uint256 actualChargeNative = actualGasCost + tokenPaymasterConfig.refundPostopCost * actualUserOpFeePerGas; + uint256 actualTokenNeeded = weiToToken(actualChargeNative, cachedPriceWithMarkup); + if (preCharge > actualTokenNeeded) { + // If the initially provided token amount is greater than the actual amount needed, refund the difference + SafeERC20.safeTransfer( + token, + userOpSender, + preCharge - actualTokenNeeded + ); + } else if (preCharge < actualTokenNeeded) { + // Attempt to cover Paymaster's gas expenses by withdrawing the 'overdraft' from the client + // If the transfer reverts also revert the 'postOp' to remove the incentive to cheat + SafeERC20.safeTransferFrom( + token, + userOpSender, + address(this), + actualTokenNeeded - preCharge + ); + } + + emit UserOperationSponsored(userOpSender, actualTokenNeeded, actualGasCost, cachedPriceWithMarkup); + refillEntryPointDeposit(_cachedPrice); + } + } + + /// @notice If necessary this function uses this Paymaster's token balance to refill the deposit on EntryPoint + /// @param _cachedPrice the token price that will be used to calculate the swap amount. + function refillEntryPointDeposit(uint256 _cachedPrice) private { + uint256 currentEntryPointBalance = entryPoint.balanceOf(address(this)); + if ( + currentEntryPointBalance < tokenPaymasterConfig.minEntryPointBalance + ) { + uint256 swappedWeth = _maybeSwapTokenToWeth(token, _cachedPrice); + unwrapWeth(swappedWeth); + entryPoint.depositTo{value: address(this).balance}(address(this)); + } + } + + receive() external payable { + emit Received(msg.sender, msg.value); + } + + function withdrawEth(address payable recipient, uint256 amount) external onlyOwner { + (bool success,) = recipient.call{value: amount}(""); + require(success, "withdraw failed"); + } +} \ No newline at end of file diff --git a/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol b/contracts/sponsorship/BiconomySponsorshipPaymaster.sol similarity index 90% rename from contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol rename to contracts/sponsorship/BiconomySponsorshipPaymaster.sol index 906e9d2..41c7c90 100644 --- a/contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol +++ b/contracts/sponsorship/BiconomySponsorshipPaymaster.sol @@ -4,20 +4,21 @@ pragma solidity ^0.8.26; /* solhint-disable reason-string */ import "../base/BasePaymaster.sol"; -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 "@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 { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { SafeTransferLib } from "solady/src/utils/SafeTransferLib.sol"; +import { SafeTransferLib } from "@solady/src/utils/SafeTransferLib.sol"; import { IBiconomySponsorshipPaymaster } from "../interfaces/IBiconomySponsorshipPaymaster.sol"; /** * @title BiconomySponsorshipPaymaster * @author livingrockrises - * @notice Based on Infinitism 'VerifyingPaymaster' contract + * @author ShivaanshK + * @notice Based on Infinitism's 'VerifyingPaymaster' contract * @dev This contract is used to sponsor the transaction fees of the user operations * Uses a verifying signer to provide the signature if predetermined conditions are met * regarding the user operation calldata. Also this paymaster is Singleton in nature which @@ -43,7 +44,7 @@ contract BiconomySponsorshipPaymaster is uint32 private constant PRICE_DENOMINATOR = 1e6; // note: could rename to PAYMASTER_ID_OFFSET - uint256 private constant VALID_PND_OFFSET = PAYMASTER_DATA_OFFSET; + uint256 private constant PAYMASTER_ID_OFFSET = PAYMASTER_DATA_OFFSET; // Limit for unaccounted gas cost uint16 private constant UNACCOUNTED_GAS_LIMIT = 10_000; @@ -95,7 +96,7 @@ contract BiconomySponsorshipPaymaster is * @notice If _newVerifyingSigner is set to zero address, it will revert with an error. * After setting the new signer address, it will emit an event VerifyingSignerChanged. */ - function setSigner(address _newVerifyingSigner) external payable onlyOwner { + function setSigner(address _newVerifyingSigner) external payable override onlyOwner { if (isContract(_newVerifyingSigner)) revert VerifyingSignerCanNotBeContract(); if (_newVerifyingSigner == address(0)) { revert VerifyingSignerCanNotBeZero(); @@ -114,7 +115,7 @@ contract BiconomySponsorshipPaymaster is * @notice If _newFeeCollector is set to zero address, it will revert with an error. * After setting the new fee collector address, it will emit an event FeeCollectorChanged. */ - function setFeeCollector(address _newFeeCollector) external payable onlyOwner { + function setFeeCollector(address _newFeeCollector) external payable override onlyOwner { if (_newFeeCollector == address(0)) revert FeeCollectorCanNotBeZero(); address oldFeeCollector = feeCollector; feeCollector = _newFeeCollector; @@ -126,7 +127,7 @@ contract BiconomySponsorshipPaymaster is * @param value The new value to be set as the unaccountedEPGasOverhead. * @notice only to be called by the owner of the contract. */ - function setUnaccountedGas(uint48 value) external payable onlyOwner { + function setUnaccountedGas(uint48 value) external payable override onlyOwner { if (value > UNACCOUNTED_GAS_LIMIT) { revert UnaccountedGasTooHigh(); } @@ -138,7 +139,7 @@ contract BiconomySponsorshipPaymaster is /** * @dev Override the default implementation. */ - function deposit() external payable virtual override { + function deposit() external payable override virtual { revert UseDepositForInstead(); } @@ -148,7 +149,7 @@ contract BiconomySponsorshipPaymaster is * @param target address to send to * @param amount amount to withdraw */ - function withdrawERC20(IERC20 token, address target, uint256 amount) external payable onlyOwner nonReentrant { + function withdrawERC20(IERC20 token, address target, uint256 amount) external onlyOwner nonReentrant { _withdrawERC20(token, target, amount); } @@ -169,7 +170,7 @@ contract BiconomySponsorshipPaymaster is emit GasWithdrawn(msg.sender, withdrawAddress, amount); } - function withdrawEth(address payable recipient, uint256 amount) external onlyOwner nonReentrant { + function withdrawEth(address payable recipient, uint256 amount) external payable onlyOwner nonReentrant { (bool success,) = recipient.call{ value: amount }(""); if (!success) { revert WithdrawalFailed(); @@ -236,11 +237,11 @@ contract BiconomySponsorshipPaymaster is ) { unchecked { - paymasterId = address(bytes20(paymasterAndData[VALID_PND_OFFSET:VALID_PND_OFFSET + 20])); - validUntil = uint48(bytes6(paymasterAndData[VALID_PND_OFFSET + 20:VALID_PND_OFFSET + 26])); - validAfter = uint48(bytes6(paymasterAndData[VALID_PND_OFFSET + 26:VALID_PND_OFFSET + 32])); - dynamicAdjustment = uint32(bytes4(paymasterAndData[VALID_PND_OFFSET + 32:VALID_PND_OFFSET + 36])); - signature = paymasterAndData[VALID_PND_OFFSET + 36:]; + paymasterId = address(bytes20(paymasterAndData[PAYMASTER_ID_OFFSET:PAYMASTER_ID_OFFSET + 20])); + validUntil = uint48(bytes6(paymasterAndData[PAYMASTER_ID_OFFSET + 20:PAYMASTER_ID_OFFSET + 26])); + validAfter = uint48(bytes6(paymasterAndData[PAYMASTER_ID_OFFSET + 26:PAYMASTER_ID_OFFSET + 32])); + dynamicAdjustment = uint32(bytes4(paymasterAndData[PAYMASTER_ID_OFFSET + 32:PAYMASTER_ID_OFFSET + 36])); + signature = paymasterAndData[PAYMASTER_ID_OFFSET + 36:]; } } diff --git a/contracts/token/BiconomyTokenPaymaster.sol b/contracts/token/BiconomyTokenPaymaster.sol new file mode 100644 index 0000000..9658bc0 --- /dev/null +++ b/contracts/token/BiconomyTokenPaymaster.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.26; + +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/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"; + + +contract BiconomyTokenPaymaster { + +} \ No newline at end of file diff --git a/remappings.txt b/remappings.txt index 6710ed5..f34af2e 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,8 +1,8 @@ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ @prb/test/=node_modules/@prb/test/ -nexus/=lib/nexus/ -forge-std/=lib/forge-std/ -account-abstraction=node_modules/account-abstraction/ -modulekit/=node_modules/modulekit/src/ -sentinellist/=node_modules/sentinellist/ -solady/=node_modules/solady +@nexus/=lib/nexus/ +@forge-std/=lib/forge-std/ +@account-abstraction=node_modules/account-abstraction/ +@modulekit/=node_modules/modulekit/src/ +@sentinellist/=node_modules/sentinellist/ +@solady/=node_modules/solady diff --git a/scripts/hardhat/deploy.ts b/scripts/hardhat/deploy.ts deleted file mode 100644 index f1ac8e7..0000000 --- a/scripts/hardhat/deploy.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ethers } from "hardhat"; - -async function main() { - const currentTimestampInSeconds = Math.round(Date.now() / 1000); - const unlockTime = currentTimestampInSeconds + 60; - - const lockedAmount = ethers.parseEther("0.001"); - - const lock = await ethers.deployContract("Lock", [unlockTime], { - value: lockedAmount, - }); - - await lock.waitForDeployment(); - - console.log( - `Lock with ${ethers.formatEther( - lockedAmount, - )}ETH and unlock timestamp ${unlockTime} deployed to ${lock.target}`, - ); -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main() - .then(() => { - process.exit(0); - }) - .catch((error) => { - console.error(error); - process.exitCode = 1; - }); diff --git a/scripts/hardhat/sample/deploy-verifying-paymaster.ts b/scripts/hardhat/sample/deploy-verifying-paymaster.ts deleted file mode 100644 index db310e7..0000000 --- a/scripts/hardhat/sample/deploy-verifying-paymaster.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { ethers } from "hardhat"; - -const entryPointAddress = - process.env.ENTRY_POINT_ADDRESS || - "0x0000000071727De22E5E9d8BAf0edAc6f37da032"; - -const verifyingSigner = - process.env.PAYMASTER_SIGNER_ADDRESS_PROD || - "0x2cf491602ad22944D9047282aBC00D3e52F56B37"; - -const deployEntryPoint = process.env.DEPLOY_ENTRY_POINT || true; - -async function main() { - let targetEntryPoint = entryPointAddress; - - if (deployEntryPoint) { - // Note: unless the network is actual chain where entrypoint is deployed, we have to deploy for hardhat node tests - const entryPoint = await ethers.deployContract("EntryPoint"); - - await entryPoint.waitForDeployment(); - - targetEntryPoint = entryPoint.target as string; - - console.log(`EntryPoint updated to ${entryPoint.target}`); - } - - const verifyingPaymaster = await ethers.deployContract("VerifyingPaymaster", [ - targetEntryPoint, - verifyingSigner, - ]); - - await verifyingPaymaster.waitForDeployment(); - - console.log(`VerifyingPaymaster deployed to ${verifyingPaymaster.target}`); -} - -// We recommend this pattern to be able to use async/await everywhere -// and properly handle errors. -main() - .then(() => { - process.exit(0); - }) - .catch((error) => { - console.error(error); - process.exitCode = 1; - }); diff --git a/test/foundry/base/TestBase.sol b/test/foundry/base/TestBase.sol index 69eaceb..669fd19 100644 --- a/test/foundry/base/TestBase.sol +++ b/test/foundry/base/TestBase.sol @@ -22,8 +22,7 @@ import { Bootstrap, BootstrapConfig } from "nexus/contracts/utils/Bootstrap.sol" import { CheatCodes } from "nexus/test/foundry/utils/CheatCodes.sol"; import { BaseEventsAndErrors } from "./BaseEventsAndErrors.sol"; -import { BiconomySponsorshipPaymaster } from - "../../../contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol"; +import { BiconomySponsorshipPaymaster } from "../../../contracts/sponsorship/BiconomySponsorshipPaymaster.sol"; abstract contract TestBase is CheatCodes, BaseEventsAndErrors { // ----------------------------------------- diff --git a/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol b/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol index a77dbb1..05b9362 100644 --- a/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol +++ b/test/foundry/unit/concrete/TestSponsorshipPaymasterWithDynamicAdjustmentTest.t.sol @@ -3,8 +3,7 @@ pragma solidity ^0.8.26; import { TestBase } from "../../base/TestBase.sol"; import { IBiconomySponsorshipPaymaster } from "../../../../contracts/interfaces/IBiconomySponsorshipPaymaster.sol"; -import { BiconomySponsorshipPaymaster } from - "../../../../contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol"; +import { BiconomySponsorshipPaymaster } from "../../../../contracts/sponsorship/BiconomySponsorshipPaymaster.sol"; import { PackedUserOperation } from "account-abstraction/contracts/core/UserOperationLib.sol"; import { MockToken } from "./../../../../lib/nexus/contracts/mocks/MockToken.sol"; diff --git a/test/foundry/unit/fuzz/TestFuzz_TestSponsorshipPaymasterWithPremium.t.sol b/test/foundry/unit/fuzz/TestFuzz_TestSponsorshipPaymasterWithPremium.t.sol index 5fb3416..bac7265 100644 --- a/test/foundry/unit/fuzz/TestFuzz_TestSponsorshipPaymasterWithPremium.t.sol +++ b/test/foundry/unit/fuzz/TestFuzz_TestSponsorshipPaymasterWithPremium.t.sol @@ -3,8 +3,7 @@ pragma solidity ^0.8.26; import { TestBase } from "../../base/TestBase.sol"; import { IBiconomySponsorshipPaymaster } from "../../../../contracts/interfaces/IBiconomySponsorshipPaymaster.sol"; -import { BiconomySponsorshipPaymaster } from - "../../../../contracts/sponsorship/SponsorshipPaymasterWithDynamicAdjustment.sol"; +import { BiconomySponsorshipPaymaster } from "../../../../contracts/sponsorship/BiconomySponsorshipPaymaster.sol"; import { MockToken } from "./../../../../lib/nexus/contracts/mocks/MockToken.sol"; import { PackedUserOperation } from "account-abstraction/contracts/interfaces/PackedUserOperation.sol";