-
Notifications
You must be signed in to change notification settings - Fork 160
[Preview] Rewards Eligibility Oracle (REO) #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
RembrandtK
wants to merge
14
commits into
build-lint-upgrade
Choose a base branch
from
rewards-eligibility-oracle-2
base: build-lint-upgrade
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fed7913
feat: add Rewards Eligibility Oracle (REO)
RembrandtK 13f0ae0
refactor: consolidate test fixtures and fix documentation
RembrandtK f8233f3
refactor: address PR review feedback
RembrandtK e198a3b
feat: add test:coverage script to packages/contracts
RembrandtK 61e32c9
chore: not sure if this file format is stable or keeps changing
RembrandtK 39b161c
refactor(issuance): clean up Hardhat configuration with proper inheri…
RembrandtK a9ba749
chore: upgrade @openzeppelin/contracts to 5.4.0 in issuance packages
RembrandtK e697c3d
fix(interfaces): add incremental build logic to avoid unnecessary reb…
RembrandtK 49f19a4
fix(horizon): respect minimum delegation requirement in slash test
RembrandtK 25d88b6
fix(issuance): fix test configuration to resolve CI failure
RembrandtK 0abe931
fix(issuance): remove redundant compilation from test build script
RembrandtK 373e2e9
fix: eliminate duplicate HTML coverage reports
RembrandtK 2474216
refactor: centralize coverage detection with type-safe helper
RembrandtK f2dca10
ci: update coverage path for contracts package
RembrandtK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
71 changes: 71 additions & 0 deletions
71
packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol
This file contains hidden or 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,71 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// solhint-disable named-parameters-mapping | ||
|
||
pragma solidity 0.7.6; | ||
|
||
import { IRewardsEligibilityOracle } from "@graphprotocol/interfaces/contracts/issuance/eligibility/IRewardsEligibilityOracle.sol"; | ||
Check warning on line 7 in packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol
|
||
import { ERC165 } from "@openzeppelin/contracts/introspection/ERC165.sol"; | ||
Check warning on line 8 in packages/contracts/contracts/tests/MockRewardsEligibilityOracle.sol
|
||
|
||
/** | ||
* @title MockRewardsEligibilityOracle | ||
* @author Edge & Node | ||
* @notice A simple mock contract for the RewardsEligibilityOracle interface | ||
* @dev A simple mock contract for the RewardsEligibilityOracle interface | ||
*/ | ||
contract MockRewardsEligibilityOracle is IRewardsEligibilityOracle, ERC165 { | ||
/// @dev Mapping to store eligibility status for each indexer | ||
mapping(address => bool) private eligible; | ||
|
||
/// @dev Mapping to track which indexers have been explicitly set | ||
mapping(address => bool) private isSet; | ||
|
||
/// @dev Default response for indexers not explicitly set | ||
bool private defaultResponse; | ||
|
||
/** | ||
* @notice Constructor | ||
* @param newDefaultResponse Default response for isEligible | ||
*/ | ||
constructor(bool newDefaultResponse) { | ||
defaultResponse = newDefaultResponse; | ||
} | ||
|
||
/** | ||
* @notice Set whether a specific indexer is eligible | ||
* @param indexer The indexer address | ||
* @param eligibility Whether the indexer is eligible | ||
*/ | ||
function setIndexerEligible(address indexer, bool eligibility) external { | ||
eligible[indexer] = eligibility; | ||
isSet[indexer] = true; | ||
} | ||
|
||
/** | ||
* @notice Set the default response for indexers not explicitly set | ||
* @param newDefaultResponse The default response | ||
*/ | ||
function setDefaultResponse(bool newDefaultResponse) external { | ||
defaultResponse = newDefaultResponse; | ||
} | ||
|
||
/** | ||
* @inheritdoc IRewardsEligibilityOracle | ||
*/ | ||
function isEligible(address indexer) external view override returns (bool) { | ||
// If the indexer has been explicitly set, return that value | ||
if (isSet[indexer]) { | ||
return eligible[indexer]; | ||
} | ||
|
||
// Otherwise return the default response | ||
return defaultResponse; | ||
} | ||
|
||
/** | ||
* @inheritdoc ERC165 | ||
*/ | ||
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { | ||
return interfaceId == type(IRewardsEligibilityOracle).interfaceId || super.supportsInterface(interfaceId); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.