Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Executor
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IExecutor, Action} from "./IExecutor.sol";
import {flipBit, hasBit} from "../utils/math/BitMap.sol";
/// @title IDAO
/// @author Aragon X - 2024
/// @notice Simple Executor that loops through the actions and executes them.
/// @dev This doesn't use any type of permission for execution and can be called by anyone.
/// Most useful use-case is to deploy it as non-upgradeable and call from another contract via delegatecall.
/// If used with delegatecall, DO NOT add state variables in sequential slots, otherwise this will overwrite
/// the storage of the calling contract.
/// @custom:security-contact [email protected]
contract Executor is IExecutor, ERC165 {
/// @notice The internal constant storing the maximal action array length.
uint256 internal constant MAX_ACTIONS = 256;
// keccak256("osx-commons.storage.Executor")
bytes32 private constant REENTRANCY_GUARD_STORAGE_LOCATION =
0x4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec;
/// @notice The first out of two values to which the `_reentrancyStatus` state variable (used by the `nonReentrant` modifier) can be set indicating that a function was not entered.
uint256 private constant _NOT_ENTERED = 1;
/// @notice The second out of two values to which the `_reentrancyStatus` state variable (used by the `nonReentrant` modifier) can be set indicating that a function was entered.
uint256 private constant _ENTERED = 2;
/// @notice Thrown if the action array length is larger than `MAX_ACTIONS`.
error TooManyActions();
/// @notice Thrown if an action has insufficient gas left.
error InsufficientGas();
/// @notice Thrown if action execution has failed.
/// @param index The index of the action in the action array that failed.
error ActionFailed(uint256 index);
/// @notice Thrown if a call is reentrant.
error ReentrantCall();
/// @notice Initializes the contract with a non-entered reentrancy status.
/// @dev Sets the reentrancy guard status to `_NOT_ENTERED` to prevent reentrant calls from the start.
constructor() {
_storeReentrancyStatus(_NOT_ENTERED);
}
/// @notice Prevents reentrant calls to a function.
/// @dev This modifier checks the reentrancy status before function execution. If already entered, it reverts with
/// `ReentrantCall()`. Sets the status to `_ENTERED` during execution and resets it to `_NOT_ENTERED` afterward.
modifier nonReentrant() {
if (_getReentrancyStatus() == _ENTERED) {
revert ReentrantCall();
}
_storeReentrancyStatus(_ENTERED);
_;
_storeReentrancyStatus(_NOT_ENTERED);
}
/// @notice Checks if this or the parent contract supports an interface by its ID.
/// @param _interfaceId The ID of the interface.
/// @return Returns `true` if the interface is supported.
function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
return _interfaceId == type(IExecutor).interfaceId || super.supportsInterface(_interfaceId);
}
/// @inheritdoc IExecutor
function execute(
bytes32 _callId,
Action[] memory _actions,
uint256 _allowFailureMap
)
public
virtual
override
nonReentrant
returns (bytes[] memory execResults, uint256 failureMap)
{
// Check that the action array length is within bounds.
if (_actions.length > MAX_ACTIONS) {
revert TooManyActions();
}
execResults = new bytes[](_actions.length);
uint256 gasBefore;
uint256 gasAfter;
for (uint256 i = 0; i < _actions.length; ) {
gasBefore = gasleft();
(bool success, bytes memory data) = _actions[i].to.call{value: _actions[i].value}(
_actions[i].data
);
gasAfter = gasleft();
// Check if failure is allowed
if (!success) {
if (!hasBit(_allowFailureMap, uint8(i))) {
revert ActionFailed(i);
}
// Make sure that the action call did not fail because 63/64 of `gasleft()` was insufficient to execute the external call `.to.call` (see [ERC-150](https://eips.ethereum.org/EIPS/eip-150)).
// In specific scenarios, i.e. proposal execution where the last action in the action array is allowed to fail, the account calling `execute` could force-fail this action by setting a gas limit
// where 63/64 is insufficient causing the `.to.call` to fail, but where the remaining 1/64 gas are sufficient to successfully finish the `execute` call.
if (gasAfter < gasBefore / 64) {
revert InsufficientGas();
}
// Store that this action failed.
failureMap = flipBit(failureMap, uint8(i));
}
execResults[i] = data;
unchecked {
++i;
}
}
emit Executed({
actor: msg.sender,
callId: _callId,
actions: _actions,
allowFailureMap: _allowFailureMap,
failureMap: failureMap,
execResults: execResults
});
}
/// @notice Gets the current reentrancy status.
/// @return status This returns the current reentrancy status.
function _getReentrancyStatus() private view returns (uint256 status) {
// solhint-disable-next-line no-inline-assembly
assembly {
status := sload(REENTRANCY_GUARD_STORAGE_LOCATION)
}
}
/// @notice Stores the reentrancy status at a specific storage slot.
/// @param _status The reentrancy status to be stored, typically `_ENTERED` or `_NOT_ENTERED`.
/// @dev Uses inline assembly to store the `_status` value at `REENTRANCY_GUARD_STORAGE_LOCATION` to manage
/// reentrancy status efficiently.
function _storeReentrancyStatus(uint256 _status) private {
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(REENTRANCY_GUARD_STORAGE_LOCATION, _status)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
/// @notice The action struct to be consumed by the DAO's `execute` function resulting in an external call.
/// @param to The address to call.
/// @param value The native token value to be sent with the call.
/// @param data The bytes-encoded function selector and calldata for the call.
struct Action {
address to;
uint256 value;
bytes data;
}
/// @title IExecutor
/// @author Aragon X - 2024
/// @notice The interface required for Executors within the Aragon App DAO framework.
/// @custom:security-contact [email protected]
interface IExecutor {
/// @notice Emitted when a proposal is executed.
/// @dev The value of `callId` is defined by the component/contract calling the execute function.
/// A `Plugin` implementation can use it, for example, as a nonce.
/// @param actor The address of the caller.
/// @param callId The ID of the call.
/// @param actions The array of actions executed.
/// @param allowFailureMap The allow failure map encoding which actions are allowed to fail.
/// @param failureMap The failure map encoding which actions have failed.
/// @param execResults The array with the results of the executed actions.
event Executed(
address indexed actor,
bytes32 callId,
Action[] actions,
uint256 allowFailureMap,
uint256 failureMap,
bytes[] execResults
);
/// @notice Executes a list of actions. If a zero allow-failure map is provided, a failing action reverts the entire execution. If a non-zero allow-failure map is provided, allowed actions can fail without the entire call being reverted.
/// @param _callId The ID of the call. The definition of the value of `callId` is up to the calling contract and can be used, e.g., as a nonce.
/// @param _actions The array of actions.
/// @param _allowFailureMap A bitmap allowing execution to succeed, even if individual actions might revert. If the bit at index `i` is 1, the execution succeeds even if the `i`th action reverts. A failure map value of 0 requires every action to not revert.
/// @return The array of results obtained from the executed actions in `bytes`.
/// @return The resulting failure map containing the actions have actually failed.
function execute(
bytes32 _callId,
Action[] memory _actions,
uint256 _allowFailureMap
) external returns (bytes[] memory, uint256);
}// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.8; /// @param bitmap The `uint256` representation of bits. /// @param index The index number to check whether 1 or 0 is set. /// @return Returns `true` if the bit is set at `index` on `bitmap`. /// @custom:security-contact [email protected] function hasBit(uint256 bitmap, uint8 index) pure returns (bool) { uint256 bitValue = bitmap & (1 << index); return bitValue > 0; } /// @param bitmap The `uint256` representation of bits. /// @param index The index number to set the bit. /// @return Returns a new number in which the bit is set at `index`. /// @custom:security-contact [email protected] function flipBit(uint256 bitmap, uint8 index) pure returns (uint256) { return bitmap ^ (1 << index); }
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@aragon/osx/=lib/osx/packages/contracts/src/",
"@aragon/osx-commons-contracts/=lib/osx-commons/contracts/",
"@aragon/admin-plugin/=lib/admin-plugin/packages/contracts/src/",
"@aragon/multisig-plugin/=lib/multisig-plugin/packages/contracts/src/",
"@aragon/token-voting-plugin/=lib/token-voting-plugin/src/",
"@aragon/staged-proposal-processor-plugin/=lib/staged-proposal-processor-plugin/src/",
"@ensdomains/ens-contracts/=lib/ens-contracts/",
"@ensdomains/buffer/=lib/buffer/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/openzeppelin-foundry-upgrades/=lib/staged-proposal-processor-plugin/node_modules/@openzeppelin/openzeppelin-foundry-upgrades/src/",
"admin-plugin/=lib/admin-plugin/",
"buffer/=lib/buffer/contracts/",
"ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
"ens-contracts/=lib/ens-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"multisig-plugin/=lib/multisig-plugin/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
"osx-commons/=lib/osx-commons/",
"osx/=lib/osx/",
"plugin-version-1.3/=lib/token-voting-plugin/lib/plugin-version-1.3/packages/contracts/src/",
"solidity-stringutils/=lib/staged-proposal-processor-plugin/node_modules/solidity-stringutils/",
"staged-proposal-processor-plugin/=lib/staged-proposal-processor-plugin/src/",
"token-voting-plugin/=lib/token-voting-plugin/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ActionFailed","type":"error"},{"inputs":[],"name":"InsufficientGas","type":"error"},{"inputs":[],"name":"ReentrantCall","type":"error"},{"inputs":[],"name":"TooManyActions","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"actor","type":"address"},{"indexed":false,"internalType":"bytes32","name":"callId","type":"bytes32"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Action[]","name":"actions","type":"tuple[]"},{"indexed":false,"internalType":"uint256","name":"allowFailureMap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"failureMap","type":"uint256"},{"indexed":false,"internalType":"bytes[]","name":"execResults","type":"bytes[]"}],"name":"Executed","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_callId","type":"bytes32"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Action[]","name":"_actions","type":"tuple[]"},{"internalType":"uint256","name":"_allowFailureMap","type":"uint256"}],"name":"execute","outputs":[{"internalType":"bytes[]","name":"execResults","type":"bytes[]"},{"internalType":"uint256","name":"failureMap","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6080806040523460395760017f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec556105b4908161003e8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a71461042d575063c71bf32414610032575f80fd5b346104155760603660031901126104155760243567ffffffffffffffff81116104155736602382011215610415578060040135610076610071826104a6565b610480565b9160208383815201906024829360051b820101903682116104155760248101925b82841061034f57858560443560027f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec54146103405760027f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec555f906101008451116103315783519161010b610071846104a6565b9280845261011b601f19916104a6565b015f5b8181106103205750505f905b855182101561020d575a915f806001600160a01b03610149848b610556565b5151166020610158858c610556565b510151906040610168868d610556565b51015191602083519301915af1923d15610205573d9361018a610071866104be565b9485523d5f602087013e5b5a90156101c0575b5050600191926101ad8287610556565b526101b88186610556565b50019061012a565b600160ff84161b91828716156101f25760061c116101e35760019218918861019d565b6307099c5360e21b5f5260045ffd5b8363a6a7dbbd60e01b5f5260045260245ffd5b606093610195565b92939190506040519460a0860190600435875260a060208801525180915260c086019060c08160051b88010193915f905b8282106102d35750505050847fd4e57c2049f004fb297ef78591cd409503ceb6b2c722d7ffed032fc99e5f3b589160406102c997015283606082015280830360808201528061028e3394876104fe565b0390a260017f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec556040519283926040845260408401906104fe565b9060208301520390f35b9091929460208061031260019360bf198d8203018652606060408b51878060a01b038151168452858101518685015201519181604082015201906104da565b97019201920190929161023e565b80606060208093880101520161011e565b6308e3b1eb60e11b5f5260045ffd5b6306fda65d60e31b5f5260045ffd5b833567ffffffffffffffff8111610415578201906060602319833603011261041557604051916060830183811067ffffffffffffffff8211176104195760405260248101356001600160a01b038116810361041557835260448101356020840152606481013567ffffffffffffffff81116104155760249101019036601f83011215610415578135926103e4610071856104be565b8481523660208686010111610415575f60208681978280980183860137830101526040820152815201930192610097565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b34610415576020366003190112610415576004359063ffffffff60e01b8216809203610415576020916331c6fcc960e21b811490811561046f575b5015158152f35b6301ffc9a760e01b14905083610468565b6040519190601f01601f1916820167ffffffffffffffff81118382101761041957604052565b67ffffffffffffffff81116104195760051b60200190565b67ffffffffffffffff811161041957601f01601f191660200190565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9080602083519182815201916020808360051b8301019401925f915b83831061052957505050505090565b9091929394602080610547600193601f1986820301875289516104da565b9701930193019193929061051a565b805182101561056a5760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfea2646970667358221220b65d5f1650056d45c6742dd3157a53f5d123297560a3a8cbfc70ca64bfc8897664736f6c634300081c0033
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a71461042d575063c71bf32414610032575f80fd5b346104155760603660031901126104155760243567ffffffffffffffff81116104155736602382011215610415578060040135610076610071826104a6565b610480565b9160208383815201906024829360051b820101903682116104155760248101925b82841061034f57858560443560027f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec54146103405760027f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec555f906101008451116103315783519161010b610071846104a6565b9280845261011b601f19916104a6565b015f5b8181106103205750505f905b855182101561020d575a915f806001600160a01b03610149848b610556565b5151166020610158858c610556565b510151906040610168868d610556565b51015191602083519301915af1923d15610205573d9361018a610071866104be565b9485523d5f602087013e5b5a90156101c0575b5050600191926101ad8287610556565b526101b88186610556565b50019061012a565b600160ff84161b91828716156101f25760061c116101e35760019218918861019d565b6307099c5360e21b5f5260045ffd5b8363a6a7dbbd60e01b5f5260045260245ffd5b606093610195565b92939190506040519460a0860190600435875260a060208801525180915260c086019060c08160051b88010193915f905b8282106102d35750505050847fd4e57c2049f004fb297ef78591cd409503ceb6b2c722d7ffed032fc99e5f3b589160406102c997015283606082015280830360808201528061028e3394876104fe565b0390a260017f4d6542319dfb3f7c8adbb488d7b4d7cf849381f14faf4b64de3ac05d08c0bdec556040519283926040845260408401906104fe565b9060208301520390f35b9091929460208061031260019360bf198d8203018652606060408b51878060a01b038151168452858101518685015201519181604082015201906104da565b97019201920190929161023e565b80606060208093880101520161011e565b6308e3b1eb60e11b5f5260045ffd5b6306fda65d60e31b5f5260045ffd5b833567ffffffffffffffff8111610415578201906060602319833603011261041557604051916060830183811067ffffffffffffffff8211176104195760405260248101356001600160a01b038116810361041557835260448101356020840152606481013567ffffffffffffffff81116104155760249101019036601f83011215610415578135926103e4610071856104be565b8481523660208686010111610415575f60208681978280980183860137830101526040820152815201930192610097565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b34610415576020366003190112610415576004359063ffffffff60e01b8216809203610415576020916331c6fcc960e21b811490811561046f575b5015158152f35b6301ffc9a760e01b14905083610468565b6040519190601f01601f1916820167ffffffffffffffff81118382101761041957604052565b67ffffffffffffffff81116104195760051b60200190565b67ffffffffffffffff811161041957601f01601f191660200190565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9080602083519182815201916020808360051b8301019401925f915b83831061052957505050505090565b9091929394602080610547600193601f1986820301875289516104da565b9701930193019193929061051a565b805182101561056a5760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfea2646970667358221220b65d5f1650056d45c6742dd3157a53f5d123297560a3a8cbfc70ca64bfc8897664736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.