Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC721Votes for NFT-based governance #2944

Merged
merged 329 commits into from Dec 10, 2021

Conversation

JulissaDantes
Copy link
Contributor

@JulissaDantes JulissaDantes commented Nov 3, 2021

Fixes #2873

Governance with NFT-backed votes. An ERC721Votes extension of ERC721 and a GovernorVotesERC721 module for OZ Governor contract. The contracts is be analogous to ERC20Votes and GovernorVotes, but for NFTs.

PR Checklist

  • Tests
  • Documentation
  • Changelog entry

Suggested Next steps

So far this implementation account for 1 Token = 1 vote, if a _getVotingPower internal virtual function is created, taking the token Id and returning the voting power of such token, that would allow for differently weighted token(you could call it token rarity or token value) to be used as voting power.

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, great work!

contracts/governance/extensions/GovernorVotesERC721.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorVotesERC721.sol Outdated Show resolved Hide resolved
contracts/governance/extensions/GovernorVotesERC721.sol Outdated Show resolved Hide resolved
contracts/token/ERC721/README.adoc Show resolved Hide resolved
test/governance/GovernorWorkflow.behavior.js Outdated Show resolved Hide resolved
contracts/token/ERC721/extensions/ERC721Votes.sol Outdated Show resolved Hide resolved
contracts/token/ERC721/extensions/ERC721Votes.sol Outdated Show resolved Hide resolved
test/token/ERC721/extensions/ERC721Votes.test.js Outdated Show resolved Hide resolved
test/token/ERC721/extensions/ERC721Votes.test.js Outdated Show resolved Hide resolved
test/token/ERC721/extensions/ERC721Votes.test.js Outdated Show resolved Hide resolved
@JulissaDantes JulissaDantes marked this pull request as ready for review November 4, 2021 19:37
@frangio
Copy link
Contributor

frangio commented Nov 5, 2021

Note regarding next steps: There are some challenges around implementing delegate because we need to know the voting power of an account even before it sets a delegate. So we might need to keep track of that incrementally, which will introduce some overhead to transfers. We should try to minimize that overhead.

@ghost
Copy link

ghost commented Nov 19, 2021

LibGovernor
LibERC721

I implemented erc721 voting with different weights and delegation. Since I was working with a diamond I moved the whole logic into a library, though the function names are the same as in the oz implementation.

Maybe this helps as well..

Note: I did not compare the implementation on this pr with my own so I might have missed something. I will check that in the next days.

@frangio
Copy link
Contributor

frangio commented Nov 19, 2021

We will resume this PR next week.

@JulissaDantes JulissaDantes changed the title Erc721 governance Add the possibility to include ERC721 token voting within OZ Governor module Nov 24, 2021
JulissaDantes and others added 2 commits December 6, 2021 16:21
* Add function to handle mint and burn before moving voting power

* Update README.adoc

* rename files to new names

* Rename function getTotalSupply

* Change test function name

* Fix documentation after function rename

* improve documentation

* Update Votes.sol documentation

* Add Chekpoints.sol documentation

* Improve ERc721 documentation

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
CHANGELOG.md Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/governance.adoc Outdated Show resolved Hide resolved
test/utils/Checkpoints.test.js Outdated Show resolved Hide resolved
test/utils/Checkpoints.test.js Outdated Show resolved Hide resolved
test/utils/Checkpoints.test.js Outdated Show resolved Hide resolved
test/governance/utils/Votes.test.js Outdated Show resolved Hide resolved
Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the possibility to include ERC721 token voting within OZ Governor module
3 participants