ERC20Votes: WIP

This commit is contained in:
Hadrien Croubois
2023-08-25 15:37:55 +02:00
parent 69d8ea737b
commit d9f2d6369d
5 changed files with 251 additions and 216 deletions

View File

@ -0,0 +1,26 @@
--- governance/utils/Votes.sol 2023-08-21 16:07:18.144728664 +0200
+++ governance/utils/Votes.sol 2023-08-25 10:52:12.904396821 +0200
@@ -217,6 +217,10 @@
return SafeCast.toUint32(_delegateCheckpoints[account].length());
}
+ function _numCheckpointsTotalSupply() internal view virtual returns (uint32) {
+ return SafeCast.toUint32(_totalCheckpoints[account].length());
+ }
+
/**
* @dev Get the `pos`-th checkpoint for `account`.
*/
@@ -227,6 +231,12 @@
return _delegateCheckpoints[account].at(pos);
}
+ function _checkpointsTotalSupply(
+ uint32 pos
+ ) internal view virtual returns (Checkpoints.Checkpoint224 memory) {
+ return _totalCheckpoints.at(pos);
+ }
+
function _push(
Checkpoints.Trace224 storage store,
function(uint224, uint224) view returns (uint224) op,

View File

@ -1,13 +1,15 @@
--- utils/structs/Checkpoints.sol 2023-08-21 16:07:18.151395512 +0200
+++ utils/structs/Checkpoints.sol 2023-08-25 10:43:19.822052443 +0200
@@ -200,10 +200,11 @@
+++ utils/structs/Checkpoints.sol 2023-08-25 10:51:17.586593500 +0200
@@ -199,11 +199,12 @@
function _unsafeAccess(
Checkpoint224[] storage self,
uint256 pos
) private pure returns (Checkpoint224 storage result) {
- ) private pure returns (Checkpoint224 storage result) {
- assembly {
- mstore(0, self.slot)
- result.slot := add(keccak256(0, 0x20), pos)
- }
+ ) private view returns (Checkpoint224 storage result) {
+ return self[pos]; // explicit (safe) for formal verification hooking
+ // assembly {
+ // mstore(0, self.slot)
@ -16,14 +18,16 @@
}
struct Trace160 {
@@ -387,9 +388,10 @@
@@ -386,10 +387,11 @@
function _unsafeAccess(
Checkpoint160[] storage self,
uint256 pos
) private pure returns (Checkpoint160 storage result) {
- ) private pure returns (Checkpoint160 storage result) {
- assembly {
- mstore(0, self.slot)
- result.slot := add(keccak256(0, 0x20), pos)
- }
+ ) private view returns (Checkpoint160 storage result) {
+ return self[pos]; // explicit (safe) for formal verification hooking
+ // assembly {
+ // mstore(0, self.slot)