VotesMockUpgradeable.sol 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../governance/utils/VotesUpgradeable.sol";
  4. import "../proxy/utils/Initializable.sol";
  5. contract VotesMockUpgradeable is Initializable, VotesUpgradeable {
  6. mapping(address => uint256) private _balances;
  7. mapping(uint256 => address) private _owners;
  8. function __VotesMock_init(string memory name) internal onlyInitializing {
  9. __EIP712_init_unchained(name, "1");
  10. }
  11. function __VotesMock_init_unchained(string memory) internal onlyInitializing {}
  12. function getTotalSupply() public view returns (uint256) {
  13. return _getTotalSupply();
  14. }
  15. function delegate(address account, address newDelegation) public {
  16. return _delegate(account, newDelegation);
  17. }
  18. function _getVotingUnits(address account) internal virtual override returns (uint256) {
  19. return _balances[account];
  20. }
  21. function mint(address account, uint256 voteId) external {
  22. _balances[account] += 1;
  23. _owners[voteId] = account;
  24. _transferVotingUnits(address(0), account, 1);
  25. }
  26. function burn(uint256 voteId) external {
  27. address owner = _owners[voteId];
  28. _balances[owner] -= 1;
  29. _transferVotingUnits(owner, address(0), 1);
  30. }
  31. function getChainId() external view returns (uint256) {
  32. return block.chainid;
  33. }
  34. /**
  35. * This empty reserved space is put in place to allow future versions to add new
  36. * variables without shifting down storage in the inheritance chain.
  37. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  38. */
  39. uint256[48] private __gap;
  40. }