Skip to content

Commit

Permalink
Merge pull request #13 from bcnmy/fix/remap
Browse files Browse the repository at this point in the history
Fix/remap
  • Loading branch information
livingrockrises authored Oct 7, 2024
2 parents acc0dca + c60ab42 commit 78646cb
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 93 deletions.
15 changes: 0 additions & 15 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "lib/nexus"]
path = lib/nexus
url = https://github.com/bcnmy/nexus
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/v3-core"]
path = lib/v3-core
url = https://github.com/Uniswap/v3-core
[submodule "lib/v3-periphery"]
path = lib/v3-periphery
url = https://github.com/Uniswap/v3-periphery
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["error", "^0.8.26"],
"compiler-version": ["error", "^0.8.27"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"reentrancy": "error",
"state-visibility": "error",
Expand Down
8 changes: 4 additions & 4 deletions contracts/base/BasePaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

/* solhint-disable reason-string */

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/interfaces/IPaymaster.sol";
import { IEntryPoint } from "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/core/UserOperationLib.sol";
/**
* Helper class for creating a paymaster.
* provides helper methods for staking.
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/BiconomySponsorshipPaymasterErrors.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

contract BiconomySponsorshipPaymasterErrors {
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/BiconomyTokenPaymasterErrors.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

contract BiconomyTokenPaymasterErrors {
/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IBiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { PackedUserOperation } from "@account-abstraction/contracts/core/UserOperationLib.sol";
import { PackedUserOperation } from "account-abstraction/core/UserOperationLib.sol";

interface IBiconomySponsorshipPaymaster{
event UnaccountedGasChanged(uint256 indexed oldValue, uint256 indexed newValue);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IBiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import { IOracle } from "./oracles/IOracle.sol";

Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/TokenPaymasterParserLib.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import { IBiconomyTokenPaymaster } from "../interfaces/IBiconomyTokenPaymaster.sol";
import "@account-abstraction/contracts/core/UserOperationLib.sol";
import "account-abstraction/core/UserOperationLib.sol";

// A helper library to parse paymaster and data
library TokenPaymasterParserLib {
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/Imports.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

/* solhint-disable reason-string */

import "@account-abstraction/contracts/core/EntryPoint.sol";
import "@account-abstraction/contracts/core/EntryPointSimulations.sol";
import "account-abstraction/core/EntryPoint.sol";
import "account-abstraction/core/EntryPointSimulations.sol";
4 changes: 2 additions & 2 deletions contracts/mocks/MockValidator.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import "@biconomy-devx/erc7579-msa/test/foundry/mocks/MockValidator.sol";
// import "nexus";
10 changes: 5 additions & 5 deletions contracts/references/SampleTokenPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ 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";
import "account-abstraction/interfaces/IEntryPoint.sol";
import "account-abstraction/core/BasePaymaster.sol";
import "account-abstraction/core/Helpers.sol";
import "account-abstraction/samples/utils/UniswapHelper.sol";
import "account-abstraction/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.
Expand Down
12 changes: 6 additions & 6 deletions contracts/sponsorship/BiconomySponsorshipPaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

/* 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/core/UserOperationLib.sol";
import "account-abstraction/core/Helpers.sol";
import { SignatureCheckerLib } from "solady/utils/SignatureCheckerLib.sol";
import { ECDSA as ECDSA_solady } from "solady/utils/ECDSA.sol";
import { BiconomySponsorshipPaymasterErrors } from "../common/BiconomySponsorshipPaymasterErrors.sol";
import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeTransferLib } from "@solady/src/utils/SafeTransferLib.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { IBiconomySponsorshipPaymaster } from "../interfaces/IBiconomySponsorshipPaymaster.sol";

/**
Expand Down
19 changes: 11 additions & 8 deletions contracts/token/BiconomyTokenPaymaster.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import { ReentrancyGuardTransient } from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import { IEntryPoint } from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import { PackedUserOperation, UserOperationLib } from "@account-abstraction/contracts/core/UserOperationLib.sol";
import { IEntryPoint } from "account-abstraction/interfaces/IEntryPoint.sol";
import { PackedUserOperation, UserOperationLib } from "account-abstraction/core/UserOperationLib.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeTransferLib } from "@solady/src/utils/SafeTransferLib.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";
import { BasePaymaster } from "../base/BasePaymaster.sol";
import { BiconomyTokenPaymasterErrors } from "../common/BiconomyTokenPaymasterErrors.sol";
import { IBiconomyTokenPaymaster } from "../interfaces/IBiconomyTokenPaymaster.sol";
import { IOracle } from "../interfaces/oracles/IOracle.sol";
import { TokenPaymasterParserLib } from "../libraries/TokenPaymasterParserLib.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/Helpers.sol";
import { SignatureCheckerLib } from "solady/utils/SignatureCheckerLib.sol";
import { ECDSA as ECDSA_solady } from "solady/utils/ECDSA.sol";
import "account-abstraction/core/Helpers.sol";
import "./swaps/Uniswapper.sol";

/**
Expand All @@ -35,6 +35,9 @@ import "./swaps/Uniswapper.sol";
* applied, and how
* to manage the assets received by the paymaster.
*/

// TODO: Review unnecessary overrides

contract BiconomyTokenPaymaster is
IBiconomyTokenPaymaster,
BasePaymaster,
Expand Down Expand Up @@ -278,7 +281,7 @@ contract BiconomyTokenPaymaster is
* @param _oracle The new native asset oracle
* @notice only to be called by the owner of the contract.
*/
function setNativeAssetToUsdOracle(IOracle _oracle) external payable override onlyOwner {
function setNativeAssetToUsdOracle(IOracle _oracle) external payable onlyOwner {
if (_oracle.decimals() != 8) {
// Native -> USD will always have 8 decimals
revert InvalidOracleDecimals();
Expand Down
6 changes: 3 additions & 3 deletions contracts/token/oracles/TwapOracle.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import {IOracle} from "../../interfaces/oracles/IOracle.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {OracleLibrary} from "@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol";
import {IUniswapV3PoolImmutables} from "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol";
import {OracleLibrary} from "@uniswap/v3-periphery/libraries/OracleLibrary.sol";
import {IUniswapV3PoolImmutables} from "@uniswap/v3-core/interfaces/pool/IUniswapV3PoolImmutables.sol";


contract TwapOracle is IOracle {
Expand Down
4 changes: 2 additions & 2 deletions 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;
pragma solidity ^0.8.27;

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

contract SoladyOwnable is Ownable {
constructor(address _owner) Ownable() {
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
optimizer_runs = 1_000_000
out = "out"
script = "scripts"
solc = "0.8.26"
solc = "0.8.27"
src = "contracts"
test = "test"
cache_path = "cache_forge"
Expand Down
1 change: 0 additions & 1 deletion lib/account-abstraction
Submodule account-abstraction deleted from 7af70c
1 change: 0 additions & 1 deletion lib/nexus
Submodule nexus deleted from b8085a
63 changes: 63 additions & 0 deletions lib/nexus/contracts/mocks/MockValidator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import { IModule } from "../interfaces/modules/IModule.sol";
import { IValidator } from "../interfaces/modules/IValidator.sol";
import { IModuleManager } from "../interfaces/base/IModuleManager.sol";
import { VALIDATION_SUCCESS, VALIDATION_FAILED, MODULE_TYPE_VALIDATOR, ERC1271_MAGICVALUE, ERC1271_INVALID } from "../types/Constants.sol";
import { PackedUserOperation } from "account-abstraction/contracts/interfaces/PackedUserOperation.sol";
import { ECDSA } from "solady/utils/ECDSA.sol";
import { SignatureCheckerLib } from "solady/utils/SignatureCheckerLib.sol";
import { MessageHashUtils } from "@openzeppelin/contracts/contracts/utils/cryptography/MessageHashUtils.sol";

contract MockValidator is IValidator {
mapping(address => address) public smartAccountOwners;

function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external view returns (uint256 validation) {
return
ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(userOpHash), userOp.signature) == smartAccountOwners[msg.sender]
? VALIDATION_SUCCESS
: VALIDATION_FAILED;
}

function isValidSignatureWithSender(address, bytes32 hash, bytes calldata signature) external view returns (bytes4) {
address owner = smartAccountOwners[msg.sender];
// MAYBE SHOULD PREPARE REPLAY RESISTANT HASH BY APPENDING MSG.SENDER
// SEE: https://github.com/bcnmy/scw-contracts/blob/3362262dab34fa0f57e2fbe0e57a4bdbd5318165/contracts/smart-account/modules/EcdsaOwnershipRegistryModule.sol#L122-L132
// OR USE EIP-712
if (SignatureCheckerLib.isValidSignatureNowCalldata(owner, hash, signature)) {
return ERC1271_MAGICVALUE;
}
if (SignatureCheckerLib.isValidSignatureNowCalldata(owner, MessageHashUtils.toEthSignedMessageHash(hash), signature)) {
return ERC1271_MAGICVALUE;
}
return ERC1271_INVALID;
}

function onInstall(bytes calldata data) external {
require(IModuleManager(msg.sender).isModuleInstalled(MODULE_TYPE_VALIDATOR, address(this), ""), "Validator is still installed");
smartAccountOwners[msg.sender] = address(bytes20(data));
}

function onUninstall(bytes calldata data) external {
data;
require(!IModuleManager(msg.sender).isModuleInstalled(MODULE_TYPE_VALIDATOR, address(this), ""), "Validator is still installed");
delete smartAccountOwners[msg.sender];
}

function isModuleType(uint256 moduleTypeId) external pure returns (bool) {
return moduleTypeId == MODULE_TYPE_VALIDATOR;
}

function isOwner(address account, address owner) external view returns (bool) {
return smartAccountOwners[account] == owner;
}

function isInitialized(address) external pure returns (bool) {
return false;
}

function getOwner(address account) external view returns (address) {
return smartAccountOwners[account];
}
}
1 change: 0 additions & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts deleted from b73bcb
1 change: 0 additions & 1 deletion lib/v3-core
Submodule v3-core deleted from 6562c5
1 change: 0 additions & 1 deletion lib/v3-periphery
Submodule v3-periphery deleted from b325bb
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
},
"dependencies": {
"@biconomy-devx/erc7579-msa": "^0.0.4",
"@openzeppelin/contracts": "^5.0.1"
"@uniswap/v3-core": "https://github.com/Uniswap/v3-core#0.8",
"@uniswap/v3-periphery": "https://github.com/Uniswap/v3-periphery#0.8",
"accountabstraction": "https://github.com/eth-infinitism/account-abstraction#develop",
"excessively-safe-call": "github:nomad-xyz/ExcessivelySafeCall",
"nexus": "https://github.com/bcnmy/nexus#dev"
},
"devDependencies": {
"@bonadocs/docgen": "^1.0.1-alpha.1",
"@ethersproject/abstract-provider": "^5.7.0",
"@openzeppelin": "https://github.com/OpenZeppelin/openzeppelin-contracts/",
"@prb/test": "^0.6.4",
"@typechain/ethers-v6": "^0.5.1",
"@types/chai": "^4.3.11",
Expand Down
24 changes: 15 additions & 9 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts/contracts/=node_modules/@openzeppelin/contracts/
@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=lib/account-abstraction/
account-abstraction=lib/account-abstraction/
@nexus/=node_modules/nexus/
forge-std/=lib/forge-std/src/
account-abstraction/=node_modules/account-abstraction/contracts/
@modulekit/=node_modules/modulekit/src/
@sentinellist/=node_modules/sentinellist/
@solady/=node_modules/solady/
sentinellist/=node_modules/sentinellist/src/
solady/=node_modules/solady/src/
@uniswap/v3-periphery/=node_modules/@uniswap/v3-periphery/contracts
@uniswap/v3-core/=node_modules/@uniswap/v3-core/contracts/

@uniswap/v3-periphery/contracts/=node_modules/@uniswap/v3-periphery/contracts
@uniswap/v3-core/contracts/=node_modules/@uniswap/v3-core/contracts/

solady/src/=node_modules/solady/src/
excessively-safe-call/=node_modules/excessively-safe-call/src/
2 changes: 1 addition & 1 deletion scripts/foundry/Base.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.23 <0.9.0;

import { Script } from "forge-std/src/Script.sol";
import { Script } from "forge-std/Script.sol";

abstract contract BaseScript is Script {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
Expand Down
2 changes: 1 addition & 1 deletion test/base/BaseEventsAndErrors.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import { EventsAndErrors } from "@nexus/test/foundry/utils/EventsAndErrors.sol";
import { BiconomySponsorshipPaymasterErrors } from "../../contracts/common/BiconomySponsorshipPaymasterErrors.sol";
Expand Down
14 changes: 7 additions & 7 deletions test/base/TestBase.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
pragma solidity ^0.8.27;

import { Test } from "forge-std/src/Test.sol";
import { Vm } from "forge-std/src/Vm.sol";
import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";

import "@solady/src/utils/ECDSA.sol";
import "solady/utils/ECDSA.sol";
import "./TestHelper.sol";

import { IAccount } from "@account-abstraction/contracts/interfaces/IAccount.sol";
import { Exec } from "@account-abstraction/contracts/utils/Exec.sol";
import { IPaymaster } from "@account-abstraction/contracts/interfaces/IPaymaster.sol";
import { IAccount } from "account-abstraction/interfaces/IAccount.sol";
import { Exec } from "account-abstraction/utils/Exec.sol";
import { IPaymaster } from "account-abstraction/interfaces/IPaymaster.sol";

import { Nexus } from "@nexus/contracts/Nexus.sol";
import { CheatCodes } from "@nexus/test/foundry/utils/CheatCodes.sol";
Expand Down
Loading

0 comments on commit 78646cb

Please sign in to comment.