PresetSingleAction.sol
PresetAction.sol is an executive law that enables the execution of a predefined set of function calls. It provides a mechanism to execute multiple actions in a specific order with fixed parameters.
Overview
This law provides a mechanism to:
Execute multiple function calls in sequence
Use predefined target contracts and functions
Pass fixed parameters to the functions
Track execution history
Enforce execution rules
Configuration
When adopting a PresetAction instance, three parameters must be provided:
targets
(address[]): Array of target contract addressesvalues
(uint256[]): Array of ETH values to send with each callcalldatas
(bytes[]): Array of encoded function call data
Usage
Proposing an Action
When calling the law, no parameters are required. The law executes the predefined set of actions in the order they were configured.
Execution Flow
Configuration Validation
Verifies target addresses
Validates calldata formats
Checks execution conditions
Function Execution
Executes each function call in sequence
Sends ETH if values > 0
Maintains execution order
State Management
Records execution history
Updates execution state
Tracks function calls
Technical Specifications
State Variables
struct Data {
address[] targets; // Array of target contracts
uint256[] values; // Array of ETH values
bytes[] calldatas; // Array of function call data
}
mapping(bytes32 lawHash => Data) public data;
Functions
initializeLaw
initializeLaw
function initializeLaw(
uint16 index,
string memory nameDescription,
bytes memory inputParams,
Conditions memory conditions,
bytes memory config
) public override
Initializes law with configuration parameters
Sets up target contracts and functions
Stores execution parameters
handleRequest
handleRequest
function handleRequest(
address caller,
address powers,
uint16 lawId,
bytes memory lawCalldata,
uint256 nonce
) public view virtual override returns (
uint256 actionId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes memory stateChange
)
Processes the execution request
Validates configuration
Prepares function calls
Returns execution data
Error Conditions
Function Call Errors
"Invalid target"
"Invalid calldata"
"Function call failed"
Parameter Errors
"Invalid value"
"Invalid calldata format"
"Array length mismatch"
Validation Errors
Zero address target
Invalid calldata
Invalid value amount
Current Deployments
421614
Arbitrum Sepolia
0x81Bb430DF6ab37466270ECFE6f7c29B3D3e44A35
11155420
Optimism Sepolia
0x81Bb430DF6ab37466270ECFE6f7c29B3D3e44A35
11155111
Ethereum Sepolia
0x81Bb430DF6ab37466270ECFE6f7c29B3D3e44A35
Last updated