-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(SubgraphService): add current epoch to IndexingRewardsCollected… (
#1036) * chore(SubgraphService): add current epoch to IndexingRewardsCollected event * fix: add missing parameter to natspec
- Loading branch information
Showing
5 changed files
with
77 additions
and
5 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
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,63 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
pragma solidity 0.8.27; | ||
|
||
import { IEpochManager } from "@graphprotocol/contracts/contracts/epochs/IEpochManager.sol"; | ||
|
||
contract MockEpochManager is IEpochManager { | ||
// -- Variables -- | ||
|
||
uint256 public epochLength; | ||
uint256 public lastRunEpoch; | ||
uint256 public lastLengthUpdateEpoch; | ||
uint256 public lastLengthUpdateBlock; | ||
|
||
// -- Configuration -- | ||
|
||
function setEpochLength(uint256 _epochLength) public { | ||
lastLengthUpdateEpoch = 1; | ||
lastLengthUpdateBlock = blockNum(); | ||
epochLength = _epochLength; | ||
} | ||
|
||
// -- Epochs | ||
|
||
function runEpoch() public { | ||
lastRunEpoch = currentEpoch(); | ||
} | ||
|
||
// -- Getters -- | ||
|
||
function isCurrentEpochRun() public view returns (bool) { | ||
return lastRunEpoch == currentEpoch(); | ||
} | ||
|
||
function blockNum() public view returns (uint256) { | ||
return block.number; | ||
} | ||
|
||
function blockHash(uint256 _block) public view returns (bytes32) { | ||
return blockhash(_block); | ||
} | ||
|
||
function currentEpoch() public view returns (uint256) { | ||
return lastLengthUpdateEpoch + epochsSinceUpdate(); | ||
} | ||
|
||
function currentEpochBlock() public view returns (uint256) { | ||
return lastLengthUpdateBlock + (epochsSinceUpdate() * epochLength); | ||
} | ||
|
||
function currentEpochBlockSinceStart() public view returns (uint256) { | ||
return blockNum() - currentEpochBlock(); | ||
} | ||
|
||
function epochsSince(uint256 _epoch) public view returns (uint256) { | ||
uint256 epoch = currentEpoch(); | ||
return _epoch < epoch ? (epoch - _epoch) : 0; | ||
} | ||
|
||
function epochsSinceUpdate() public view returns (uint256) { | ||
return (blockNum() - lastLengthUpdateBlock) / epochLength; | ||
} | ||
} |
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