Skip to content

Commit

Permalink
fix: modified ERC20VotesTest() to use block.timestamp instead of bloc…
Browse files Browse the repository at this point in the history
…k.number

Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Jan 24, 2025
1 parent 5171096 commit 46231eb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions contracts/openzeppelin/ERC-20-votes/erc20VotesTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,27 @@ contract ERC20VotesTest is ERC20, ERC20Permit, ERC20Votes {
{
return super.nonces(owner);
}

/// @notice Returns the current consensus timestamp
/// @dev Overrides the default block number-based implementation to use timestamps instead
/// @dev This modification is specific to Hedera's architecture where:
/// @dev - block.number refers to record file indices which don't reflect transaction timing
/// @dev - block.timestamp provides the actual consensus timestamp when the transaction executed
/// @return The current consensus timestamp as a uint48
function clock() public view override returns (uint48) {
return uint48(block.timestamp);
}

/// @notice Returns a machine-readable description of the timestamp-based clock implementation
/// @dev Overrides the default implementation to reflect the use of timestamps instead of block numbers
/// @return A string describing the clock mode configuration
// solhint-disable-next-line func-name-mixedcase
function CLOCK_MODE() public view override returns (string memory) {
// Check that the clock was not modified
if (clock() != block.timestamp) {
revert ERC6372InconsistentClock();
}
return "mode=blocknumber&from=default";
}

}

0 comments on commit 46231eb

Please sign in to comment.