Skip to content

Commit

Permalink
execute
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbir committed Aug 28, 2024
1 parent 58bb6dc commit 0006ae4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/proofSubmitter/ProofSubmitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "./Erc4337Account.sol";
import "./IProofSubmitter.sol";
import "../proofSubmitterFactory/IProofSubmitterFactory.sol";
import "../lib/eigenLayer/IEigenPodManager.sol";
import "../lib/@openzeppelin/contracts/utils/Address.sol";


contract ProofSubmitter is Erc4337Account, IProofSubmitter {
Expand All @@ -25,6 +26,14 @@ contract ProofSubmitter is Erc4337Account, IProofSubmitter {
_;
}

/// @notice If caller is any account other than the EntryPoint or the owner, revert
modifier onlyEntryPointOrOwner() {
if (msg.sender != entryPoint && msg.sender != owner()) {
revert ProofSubmitter__CallerNeitherEntryPointNorOwner(msg.sender);
}
_;
}

/// @notice If caller not factory, revert
modifier onlyFactory() {
if (msg.sender != address(i_factory)) {
Expand Down Expand Up @@ -65,6 +74,26 @@ contract ProofSubmitter is Erc4337Account, IProofSubmitter {
emit ProofSubmitter__OperatorDismissed(_operator);
}

/**
* execute a transaction (called directly from owner, or by entryPoint)
*/
function execute(address target, bytes calldata data) external onlyEntryPointOrOwner {
Address.functionCall(target, data);
}

/**
* execute a sequence of transactions
*/
function executeBatch(address[] calldata targets, bytes[] calldata data) external onlyEntryPointOrOwner {
if (targets.length != data.length) {
revert ProofSubmitter__WrongArrayLengths(targets.length, data.length);
}

for (uint256 i = 0; i < targets.length; i++) {
Address.functionCall(targets[i], data[i]);
}
}

function _call(address target, bytes memory data) internal {
(bool success, bytes memory result) = target.call(data);
if (!success) {
Expand Down

0 comments on commit 0006ae4

Please sign in to comment.