File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
contracts/governance/utils Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,28 @@ import {SafeCast} from "../../utils/math/SafeCast.sol";
7
7
8
8
/**
9
9
* @dev Extension of {Votes} that adds checkpoints for delegations and balances.
10
+ *
11
+ * WARNING: While this contract extends {Votes}, valid uses of {Votes} may not be compatible with
12
+ * {VotesExtended} without additional considerations. This implementation of {_transferVotingUnits} must
13
+ * run AFTER the voting weight movement is registered, such that it is reflected on {_getVotingUnits}.
14
+ *
15
+ * Said differently, {VotesExtended} MUST be integrated in a way that calls {_transferVotingUnits} AFTER the
16
+ * asset transfer is registered and balances are updated:
17
+ *
18
+ * ```solidity
19
+ * contract VotingToken is Token, VotesExtended {
20
+ * function transfer(address from, address to, uint256 tokenId) public override {
21
+ * super.transfer(from, to, tokenId); // <- Perform the transfer first ...
22
+ * _transferVotingUnits(from, to, 1); // <- ... then call _transferVotingUnits.
23
+ * }
24
+ *
25
+ * function _getVotingUnits(address account) internal view override returns (uint256) {
26
+ * return balanceOf(account);
27
+ * }
28
+ * }
29
+ * ```
30
+ *
31
+ * {ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.
10
32
*/
11
33
abstract contract VotesExtended is Votes {
12
34
using SafeCast for uint256 ;
File renamed without changes.
You can’t perform that action at this time.
0 commit comments