generated from defi-wonderland/solidity-foundry-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79c9de5
commit 3868cb4
Showing
6 changed files
with
469 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
forge-std/=node_modules/forge-std/src | ||
halmos-cheatcodes=node_modules/halmos-cheatcodes | ||
@defi-wonderland/prophet-core-contracts/=node_modules/@defi-wonderland/prophet-core-contracts | ||
@defi-wonderland/prophet-modules-contracts/=node_modules/@defi-wonderland/prophet-modules-contracts | ||
@defi-wonderland/prophet-core/=node_modules/@defi-wonderland/prophet-core | ||
@defi-wonderland/prophet-modules/=node_modules/@defi-wonderland/prophet-modules | ||
|
||
contracts/=src/contracts | ||
interfaces/=src/interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; | ||
import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; | ||
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; | ||
|
||
import {Arbitrable} from 'contracts/Arbitrable.sol'; | ||
import {IEBOFinalityModule} from 'interfaces/IEBOFinalityModule.sol'; | ||
|
||
/** | ||
* @title EBOFinalityModule | ||
* @notice Module allowing users to index data into the subgraph | ||
* as a result of a request being finalized | ||
*/ | ||
contract EBOFinalityModule is Module, Arbitrable, IEBOFinalityModule { | ||
/// @inheritdoc IEBOFinalityModule | ||
address public eboRequestCreator; | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _oracle The address of the Oracle | ||
* @param _eboRequestCreator The address of the EBORequestCreator | ||
* @param _arbitrator The address of The Graph's Arbitrator | ||
* @param _council The address of The Graph's Council | ||
*/ | ||
constructor( | ||
IOracle _oracle, | ||
address _eboRequestCreator, | ||
address _arbitrator, | ||
address _council | ||
) Module(_oracle) Arbitrable(_arbitrator, _council) { | ||
_setEBORequestCreator(_eboRequestCreator); | ||
} | ||
|
||
/// @inheritdoc IEBOFinalityModule | ||
function finalizeRequest( | ||
IOracle.Request calldata _request, | ||
IOracle.Response calldata _response, | ||
address _finalizer | ||
) external override(Module, IEBOFinalityModule) onlyOracle { | ||
if (_request.requester != eboRequestCreator) revert EBOFinalityModule_InvalidRequester(); | ||
|
||
if (_response.requestId != 0) { | ||
_validateResponse(_request, _response); | ||
|
||
// TODO: Redeclare the `Response` struct | ||
// emit NewEpoch(_response.epoch, _response.chainId, _response.block); | ||
} | ||
|
||
emit RequestFinalized(_response.requestId, _response, _finalizer); | ||
} | ||
|
||
/// @inheritdoc IEBOFinalityModule | ||
function amendEpoch( | ||
uint256 _epoch, | ||
uint256[] calldata _chainIds, | ||
uint256[] calldata _blockNumbers | ||
) external onlyArbitrator { | ||
uint256 _length = _chainIds.length; | ||
if (_length != _blockNumbers.length) revert EBOFinalityModule_LengthMismatch(); | ||
|
||
for (uint256 _i; _i < _length; ++_i) { | ||
emit AmendEpoch(_epoch, _chainIds[_i], _blockNumbers[_i]); | ||
} | ||
} | ||
|
||
/// @inheritdoc IEBOFinalityModule | ||
function setEBORequestCreator(address _eboRequestCreator) external onlyArbitrator { | ||
_setEBORequestCreator(_eboRequestCreator); | ||
} | ||
|
||
/// @inheritdoc IModule | ||
function moduleName() external pure returns (string memory _moduleName) { | ||
_moduleName = 'EBOFinalityModule'; | ||
} | ||
|
||
/** | ||
* @notice Sets the address of the EBORequestCreator | ||
* @param _eboRequestCreator The address of the EBORequestCreator | ||
*/ | ||
function _setEBORequestCreator(address _eboRequestCreator) private { | ||
eboRequestCreator = _eboRequestCreator; | ||
emit SetEBORequestCreator(_eboRequestCreator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; | ||
import {IFinalityModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/finality/IFinalityModule.sol'; | ||
|
||
import {IArbitrable} from 'interfaces/IArbitrable.sol'; | ||
|
||
/** | ||
* @title EBOFinalityModule | ||
* @notice Module allowing users to index data into the subgraph | ||
* as a result of a request being finalized | ||
*/ | ||
interface IEBOFinalityModule is IFinalityModule, IArbitrable { | ||
/*/////////////////////////////////////////////////////////////// | ||
EVENTS | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Emitted when the block number has been resolved for a particular epoch-chainId pair | ||
* @param _epoch The new epoch | ||
* @param _chainId The chain ID | ||
* @param _blockNumber The block number for the epoch-chainId pair | ||
*/ | ||
event NewEpoch(uint256 _epoch, uint256 indexed _chainId, uint256 _blockNumber); | ||
|
||
/** | ||
* @notice Emitted when a block number is amended | ||
* @param _epoch The epoch to amend | ||
* @param _chainId The chain ID to amend | ||
* @param _blockNumber The amended block number | ||
*/ | ||
event AmendEpoch(uint256 _epoch, uint256 indexed _chainId, uint256 _blockNumber); | ||
|
||
/** | ||
* @notice Emitted when the EBORequestCreator is set | ||
* @param _eboRequestCreator The address of the EBORequestCreator | ||
*/ | ||
event SetEBORequestCreator(address _eboRequestCreator); | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
ERRORS | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Thrown when the requester is not the EBORequestCreator | ||
*/ | ||
error EBOFinalityModule_InvalidRequester(); | ||
|
||
/** | ||
* @notice Thrown when the lengths of chain IDs and block numbers do not match | ||
*/ | ||
error EBOFinalityModule_LengthMismatch(); | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
VARIABLES | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Returns the address of the EBORequestCreator | ||
* @return _eboRequestCreator The address of the EBORequestCreator | ||
*/ | ||
function eboRequestCreator() external view returns (address _eboRequestCreator); | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
LOGIC | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* @notice Finalizes the request by publishing the response | ||
* @dev Callable only by the Oracle | ||
* @param _request The request being finalized | ||
* @param _response The final response | ||
* @param _finalizer The address that initiated the finalization | ||
*/ | ||
function finalizeRequest( | ||
IOracle.Request calldata _request, | ||
IOracle.Response calldata _response, | ||
address _finalizer | ||
) external; | ||
|
||
/** | ||
* @notice Allows to amend data in case of an error or an emergency | ||
* @dev Callable only by The Graph's Arbitrator | ||
* @param _epoch The epoch to amend | ||
* @param _chainIds The chain IDs to amend | ||
* @param _blockNumbers The amended block numbers | ||
*/ | ||
function amendEpoch(uint256 _epoch, uint256[] calldata _chainIds, uint256[] calldata _blockNumbers) external; | ||
|
||
/** | ||
* @notice Sets the address of the EBORequestCreator | ||
* @dev Callable only by The Graph's Arbitrator | ||
* @param _eboRequestCreator The address of the EBORequestCreator | ||
*/ | ||
function setEBORequestCreator(address _eboRequestCreator) external; | ||
} |
Oops, something went wrong.