Skip to content

Commit 95c73f6

Browse files
Transpile 2562c11f2
1 parent e2eb335 commit 95c73f6

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

contracts/governance/utils/VotesExtendedUpgradeable.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ import {Initializable} from "../../proxy/utils/Initializable.sol";
88

99
/**
1010
* @dev Extension of {Votes} that adds checkpoints for delegations and balances.
11+
*
12+
* WARNING: While this contract extends {Votes}, valid uses of {Votes} may not be compatible with
13+
* {VotesExtended} without additional considerations. This implementation of {_transferVotingUnits} must
14+
* run AFTER the voting weight movement is registered, such that it is reflected on {_getVotingUnits}.
15+
*
16+
* Said differently, {VotesExtended} MUST be integrated in a way that calls {_transferVotingUnits} AFTER the
17+
* asset transfer is registered and balances are updated:
18+
*
19+
* ```solidity
20+
* contract VotingToken is Token, VotesExtended {
21+
* function transfer(address from, address to, uint256 tokenId) public override {
22+
* super.transfer(from, to, tokenId); // <- Perform the transfer first ...
23+
* _transferVotingUnits(from, to, 1); // <- ... then call _transferVotingUnits.
24+
* }
25+
*
26+
* function _getVotingUnits(address account) internal view override returns (uint256) {
27+
* return balanceOf(account);
28+
* }
29+
* }
30+
* ```
31+
*
32+
* {ERC20Votes} and {ERC721Votes} follow this pattern and are thus safe to use with {VotesExtended}.
1133
*/
1234
abstract contract VotesExtendedUpgradeable is Initializable, VotesUpgradeable {
1335
using SafeCast for uint256;

0 commit comments

Comments
 (0)