Skip to content

Commit

Permalink
refactor: mockups/*Consumer._estimateBaseFee(..) overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Aug 9, 2024
1 parent 380d3eb commit 79d2dbe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
13 changes: 7 additions & 6 deletions contracts/mockups/UsingWitOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ abstract contract UsingWitOracle
}

/// @dev Estimate the minimum reward required for posting a data request (based on `tx.gasprice`).
function _witOracleEstimateBaseFee()
virtual internal view
returns (uint256)
{
function _witOracleEstimateBaseFee() virtual internal view returns (uint256) {
return _witOracleEstimateBaseFee(tx.gasprice);
}

function _witOracleEstimateBaseFee(uint256 _evmGasPrice) virtual internal view returns (uint256) {
return (
(100 + __witOracleBaseFeeOverheadPercentage)
* __witOracle.estimateBaseFee(tx.gasprice)
__witOracle.estimateBaseFee(_evmGasPrice)
* (100 + __witOracleBaseFeeOverheadPercentage)
) / 100;
}
}
24 changes: 8 additions & 16 deletions contracts/mockups/WitOracleConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,18 @@ abstract contract WitOracleConsumer
/// ===============================================================================================================
/// --- WitOracleConsumer virtual methods ----------------------------------------------------------------------------

/// @dev Estimate the minimum reward required for posting a data request (based on `tx.gasprice` and
/// @dev `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee() virtual override internal view returns (uint256) {
return _witOracleEstimateBaseFeeWithCallback(__witOracleCallbackGasLimit);
}


/// @dev Estimate the minimum reward required for posting a data request, based on `tx.gasprice` and
/// @dev the given `_witOracleCallbackGasLimit` value.
/// @param _witOracleCallbackGasLimit Maximum gas to be spent when reporting the data request result.
function _witOracleEstimateBaseFeeWithCallback(
uint24 _witOracleCallbackGasLimit
)
virtual internal view returns (uint256)
/// @dev Estimate the minimum reward required for posting a data request (based on given gas price and
/// @dev immutable `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee(uint256 _evmGasPrice)
virtual override
internal view
returns (uint256)
{
return (
(100 + __witOracleBaseFeeOverheadPercentage)
* __witOracle.estimateBaseFeeWithCallback(
tx.gasprice,
_witOracleCallbackGasLimit
_evmGasPrice,
__witOracleCallbackGasLimit
)
) / 100;
}
Expand Down
14 changes: 7 additions & 7 deletions contracts/mockups/WitOracleRequestConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ abstract contract WitOracleRequestConsumer
WitOracleConsumer(_callbackGasLimit)
{}

/// @dev Estimate the minimum reward required for posting a data request (based on `tx.gasprice` and
/// @dev `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee()
virtual override(UsingWitOracle, WitOracleConsumer)
internal view
/// @dev Estimate the minimum reward required for posting a data request (based on given gas price and
/// @dev immutable `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee(uint256 _evmGasPrice)
virtual override (UsingWitOracle, WitOracleConsumer)
internal view
returns (uint256)
{
return WitOracleConsumer._witOracleEstimateBaseFee();
}
return WitOracleConsumer._witOracleEstimateBaseFee(_evmGasPrice);
}

/// @dev Pulls a data update from the Wit/oracle blockchain based on the underlying `witOracleRequest`,
/// @dev the default `__witOracleDefaultQuerySLA` data security parameters and the immutable value of
Expand Down
12 changes: 6 additions & 6 deletions contracts/mockups/WitOracleRequestTemplateConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ abstract contract WitOracleRequestTemplateConsumer
WitOracleConsumer(_callbackGasLimit)
{}

/// @dev Estimate the minimum reward required for posting a data request (based on `tx.gasprice` and
/// @dev `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee()
virtual override(UsingWitOracle, WitOracleConsumer)
internal view
/// @dev Estimate the minimum reward required for posting a data request (based on given gas price and
/// @dev immutable `__witOracleCallbackGasLimit`).
function _witOracleEstimateBaseFee(uint256 _evmGasPrice)
virtual override (UsingWitOracle, WitOracleConsumer)
internal view
returns (uint256)
{
return WitOracleConsumer._witOracleEstimateBaseFee();
return WitOracleConsumer._witOracleEstimateBaseFee(_evmGasPrice);
}

/// @dev Pulls a fresh update from the Wit/oracle blockchain based on some data request built out
Expand Down

0 comments on commit 79d2dbe

Please sign in to comment.