Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eloi010 committed Nov 21, 2023
1 parent 043ae2d commit e3ed943
Show file tree
Hide file tree
Showing 17 changed files with 1,708 additions and 2,072 deletions.
13 changes: 3 additions & 10 deletions contracts/core/base/BaseOpenfortAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {SafeCastUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/mat
import {BaseAccount, UserOperation, IEntryPoint, UserOperationLib} from "account-abstraction/core/BaseAccount.sol";
import {TokenCallbackHandler} from "account-abstraction/samples/callback/TokenCallbackHandler.sol";
import {_packValidationData} from "account-abstraction/core/Helpers.sol";
import {OpenfortErrorsAndEvents} from "../../interfaces/OpenfortErrorsAndEvents.sol";

/**
* @title BaseOpenfortAccount (Non upgradeable by default)
Expand All @@ -25,7 +26,8 @@ abstract contract BaseOpenfortAccount is
Initializable,
EIP712Upgradeable,
IERC1271Upgradeable,
TokenCallbackHandler
TokenCallbackHandler,
OpenfortErrorsAndEvents
{
using ECDSAUpgradeable for bytes32;

Expand Down Expand Up @@ -59,15 +61,6 @@ abstract contract BaseOpenfortAccount is

mapping(address sessionKey => SessionKeyStruct sessionKeyData) public sessionKeys;

event AccountImplementationDeployed(address indexed creator);
event SessionKeyRegistered(address indexed key);
event SessionKeyRevoked(address indexed key);

error ZeroAddressNotAllowed();
error NotOwnerOrEntrypoint();
error NotOwner();
error InvalidParameterLength();

receive() external payable virtual {}

constructor() {
Expand Down
5 changes: 2 additions & 3 deletions contracts/core/base/BaseRecoverableAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ abstract contract BaseRecoverableAccount is BaseOpenfortAccount, Ownable2StepUpg
// keccak256("Recover(address recoveryAddress,uint64 executeAfter,uint32 guardiansRequired)");
bytes32 private constant RECOVER_TYPEHASH = 0x9f7aca777caf11405930359f601a4db01fad1b2d79ef3f2f9e93c835e9feffa5;

event EntryPointUpdated(address oldEntryPoint, address newEntryPoint);
event Locked(bool isLocked);
event GuardianProposed(address indexed guardian, uint256 executeAfter);
event GuardianAdded(address indexed guardian);
Expand All @@ -63,7 +62,7 @@ abstract contract BaseRecoverableAccount is BaseOpenfortAccount, Ownable2StepUpg
event GuardianRevocationCancelled(address indexed guardian);
event RecoveryExecuted(address indexed recoveryAddress, uint64 executeAfter);
event RecoveryCompleted(address indexed recoveryAddress);
event RecoveryCanceled(address indexed recoveryAddress);
event RecoveryCancelled(address indexed recoveryAddress);

error AccountLocked();
error AccountNotLocked();
Expand Down Expand Up @@ -410,7 +409,7 @@ abstract contract BaseRecoverableAccount is BaseOpenfortAccount, Ownable2StepUpg
function cancelRecovery() external onlyOwner {
_requireRecovery(true);
address recoveryOwner = recoveryDetails.recoveryAddress;
emit RecoveryCanceled(recoveryOwner);
emit RecoveryCancelled(recoveryOwner);
delete recoveryDetails;
_setLock(0);
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/core/eip6551/EIP6551OpenfortAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ contract EIP6551OpenfortAccount is BaseOpenfortAccount, IERC6551Account, IERC655

error OperationNotAllowed();

event EntryPointUpdated(address oldEntryPoint, address newEntryPoint);

receive() external payable override(BaseOpenfortAccount, IERC6551Account) {}

/*
Expand Down
10 changes: 10 additions & 0 deletions contracts/interfaces/OpenfortErrorsAndEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ interface OpenfortErrorsAndEvents {
/// @notice Error when a function requires msg.value to be different than owner()
error OwnerNotAllowed();

error ZeroAddressNotAllowed();
error NotOwnerOrEntrypoint();
error NotOwner();
error InvalidParameterLength();

event AccountImplementationDeployed(address indexed creator);
event SessionKeyRegistered(address indexed key);
event SessionKeyRevoked(address indexed key);
event EntryPointUpdated(address oldEntryPoint, address newEntryPoint);

// Paymaster specifics

/**
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions script/debugUserOp.s.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.19;

import "forge-std/Script.sol";
import {Script} from "forge-std/Script.sol";
import {UserOperation, EntryPoint} from "account-abstraction/core/EntryPoint.sol";

contract DebugUserOp is Script {
Expand All @@ -26,6 +26,6 @@ contract DebugUserOp is Script {

entryPoint.simulateHandleOp(userOp, address(0), "");
// simulateHandleOp() will always return the following error:
// error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);
// error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 0 additions & 39 deletions script/deployRecoverableAccounts.sol

This file was deleted.

File renamed without changes.
File renamed without changes.
220 changes: 0 additions & 220 deletions test/foundry/4337/Specific4337Tests.t.sol

This file was deleted.

Loading

0 comments on commit e3ed943

Please sign in to comment.