community-dapp/packages/contracts
r4bbit fade61df30
chore: add optimism sepolia deployment config
2024-02-16 07:53:07 +01:00
..
abi chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
contracts feat(Directory): add ownership capabilities to `Directory` (#90) 2023-10-30 16:10:19 +01:00
lib refactor: use minime and require limit when evaluating votes (#72) 2023-10-04 11:18:42 +02:00
out feat(Directory): add ownership capabilities to `Directory` (#90) 2023-10-30 16:10:19 +01:00
script chore: add optimism sepolia deployment config 2024-02-16 07:53:07 +01:00
test feat(Directory): add ownership capabilities to `Directory` (#90) 2023-10-30 16:10:19 +01:00
.editorconfig chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.env.example chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.gas-snapshot refactor: use OZs `Ownable2Step` for access control (#73) 2023-10-04 13:23:35 +02:00
.gitattributes chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.gitignore chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.gitmodules chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.prettierignore chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
.solhint.json chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
PROPERTIES.md chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
README.md chore: add optimism sepolia deployment config 2024-02-16 07:53:07 +01:00
codecov.yml chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
foundry.toml fix: adjust remappings and rpc configs (#95) 2023-11-02 12:25:15 +01:00
package.json chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
pnpm-lock.yaml chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
prettierrc.yml chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00
remappings.txt fix: adjust remappings and rpc configs (#95) 2023-11-02 12:25:15 +01:00
slither.config.json chore: add config files from foundry template (#69) 2023-10-04 10:47:40 +02:00

README.md

status-community-dapp/contracts

Community directory curator contracts

Deployments

Contract Address Snapshot
Optimism Goerli
Directory 0xB3Ef5B0825D5f665bE14394eea41E684CE96A4c5 a3967fc
VotingContract 0x744Fd6e98dad09Fb8CCF530B5aBd32B56D64943b a3967fc
FeaturedVotingContract 0x898331B756EE1f29302DeF227a4471e960c50612 a3967fc
Optimism Sepolia
Directory 0x6B94e21FAB8Af38E8d89dd4A0480C04e9a5c53Ab baaa3d0
VotingContract 0x7Ff554af5b6624db2135E4364F416d1D397f43e6 baaa3d0
FeaturedVotingContract 0x336DFD512164Fe8CFA809BdE94B13E76e42edD6B baaa3d0
Optimism Mainnet
Directory 0xA8d270048a086F5807A8dc0a9ae0e96280C41e3A af44986
VotingContract 0x321Ba646d994200257Ce4bfe18F66C9283ad1407 af44986
FeaturedVotingContract 0x2EA9700E7F27E09F254f2DaEc5E05015b2b961d0 af44986

Mock Contract

Mock Contract is a mock of voting smart contract for community curation.

This Contract is responsible for creating voting rooms in which you can vote for addition or deletion of community into directory. Directory of communities will be held on another smart contract at finalization this contract will call smart contract with directory, to make necessary changes. When voting room is initialized for given community another can't be started for the same community until previous one was finalized.

Lifecycle of voting room: 1. initialize voting room. 2. period of time when votes are accepted. 3. voting time is finished votes are no longer accepted and voting room can be finalized. 4. finalization

Voting room initialization

function initializeVotingRoom(uint8 voteType, address publicKey) public

When initializing a voting user needs to supply a type of vote (0: removal, 1: addition) and publicKey of community. Voting room can't be created if given community is undergoing vote. If voting room has been created message is emitted.

after voting room creation event is emitted

event VotingRoomStarted(uint256 roomId)

TODO: -vote type chosen automatically based if community is in directory

Voting room structure

    enum VoteType { REMOVE, ADD }

    struct VotingRoom {
        uint256 startBlock; // block at which vote was initialized
        uint256 endAt; // timestamp of when the voting room will close
        VoteType voteType; // type of voting room (1: removal, 2: addition)
        bool finalized; // was voting room finalized ( community added/delted from directory )
        address community; // publicKey of community
        uint256 totalVotesFor; // sum of snt votes for vote
        uint256 totalVotesAgainst; // sum of snt votes against
        mapping(address => bool) voted; // list of voters that voted
    }

Finalizing voting room

Once time of voting has passed community needs to be added or removed from directory according to vote result. For that smart contract has vote finalization function.

function finalizeVotingRoom(uint128 voteID) public

after finalization event is emitted

event VotingRoomFinalized(uint256 roomId);

Voting

Everyone can send a list of aggregated and signed votes

    struct SignedVote {
        address voter; // address of voter
        uint256 roomIdAndType; // first bit is type of vote (0: against, 1: for) rest of bits are room Id.
        uint256 sntAmount; // amount of snt to vote
        bytes32 r; // r parameter of signature
        bytes32 vs; // vs parameter of signature [see](https://eips.ethereum.org/EIPS/eip-2098)
    }

    function castVotes(SignedVote[] calldata votes) public