From 59f886131be0dee0c881fdc01f4039d6c915f284 Mon Sep 17 00:00:00 2001 From: aboudjem Date: Fri, 13 Oct 2023 17:38:48 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20add=20natspec=20on=20gasestimato?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/smart-account/utils/GasEstimator.sol | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/contracts/smart-account/utils/GasEstimator.sol b/contracts/smart-account/utils/GasEstimator.sol index 1f787c848..9307728d6 100644 --- a/contracts/smart-account/utils/GasEstimator.sol +++ b/contracts/smart-account/utils/GasEstimator.sol @@ -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 } }