Skip to content

Commit

Permalink
πŸ“ add natspec on gasestimator
Browse files Browse the repository at this point in the history
  • Loading branch information
Aboudjem committed Oct 13, 2023
1 parent 831fd20 commit 59f8861
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions contracts/smart-account/utils/GasEstimator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ pragma solidity 0.8.17;

// Generic contract for estimating gas on any target and data
contract GasEstimator {
/**
* @notice Estimates the gas consumption of a call to a given address with specific data.
* @dev This function does not revert if the call fails but instead returns the success status.
* @param _to The address to call.
* @param _data The calldata to send with the call.
* @return success A boolean indicating if the call was successful.
* @return result The bytes data returned from the called function.
* @return gas The amount of gas consumed by the call.
*/
function estimate(
address _to,
bytes calldata _data
) external returns (bool success, bytes memory result, uint256 gas) {
// solhint-disable
uint256 initialGas = gasleft();
(success, result) = _to.call(_data);
gas = initialGas - gasleft();
// solhint-enable
}
}

0 comments on commit 59f8861

Please sign in to comment.