Commit Graph

9 Commits

Author SHA1 Message Date
Sebastian Bor 3d3b32dcf6
Governance: Veto vote (#3156)
* chore: remove #[repr(C)]

* wip: resolve proposal governing token mint

* fix: remove optionality from veto vote

* feat: implement tipping for veto vote

* fix: move vote_threshold to the end of Proposal struct

* chore: remove use super

* chore: make clippy happy

* chore: add change log

* feat: add council_veto_vote_threshold

* fix: resolve vote threshold for voting token mint

* chore: revert old function name

* fix: calculate max veto in coerce_max_voter_weight

* chore: make clippy happy

* chore: make clippy happy

* feat: Implement RelinquishVote for Veto

* chore: update comments

* chore: rename with_cast_vote to with_cast_yes_no_vote

* chore: rename with_cast_multi_option_vote to with_cast_vote

* chore: create use_veto_vote test scenario

* chore: Add veto vote disabled tests

* chore: Add partial Veto vote tests

* chore: update comments

* chore: test_cast_veto_vote_with_no_council_error

* chore: test_relinquish_veto_vote

* chore: rename with_token_owner_record to with_community_token_owner_record

* chore: test_relinquish_veto_vote_with_vote_record_for_different_voting_mint_error

* chore: test_cast_veto_vote_with_invalid_voting_mint_error

* chore: fix chat build

* chore: test_cast_veto_vote_with_council_only_allowed_to_veto

* fix: Use VoteKind to distinguish between Veto and Electorate votes

* chore: make clippy happy

* Update change log

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* chore: rename voting_token_mint to vote_governing_token_mint

* chore: test_cast_yes_and_veto_votes_with_yes_as_winning_vote

* fix: throw error for Community veto

* chore: Update comments

* chore: Update names and commnents

* chore: split try_get_tipped_vote_state into Electorate and Veto cases

* chore: Update comments

* chore: remove #[allow(clippy::float_cmp)]

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-05-17 16:37:43 +01:00
Sebastian Bor 3db53e278b
Governance: Rename vote_threshold_percentage to community_vote_threshold (#3132) 2022-05-02 16:15:08 +01:00
Sebastian Bor 925f8f5711
Governance: Limit proposal options to 10 (#2841)
* fix: limit proposal options to 10

* chore: increase reserved space to 64
2022-01-31 00:01:13 +00:00
Sebastian Bor 3a21fcaa94
Governance: future proof v2 Proposal account (#2837)
* wip: add Veto and Abstain votes to Proposal

* chore: rename max_executable_options to max_voter_options

* wip: add start_at to Proposal

* feat: add SignOffProposal to proposal actions

* chore: rename start_at to start_voting_at

* feat: add max_voting_time

* chore: add comments

* chore: update comments

* feat: Add Abstain and Veto vote types
2022-01-29 20:53:52 +00:00
Sebastian Bor 851efed467
Governance: Rename AccountGovernance to Governance (#2836)
* chore: rename AccountGovernance to Governance

* chore: make governed_account optional

* chore: rename account_governance to governance
2022-01-29 18:14:27 +00:00
Sebastian Bor aefbebe3ae
Governance: Multiple instructions per proposal transaction (#2833)
* feat: support multiple instructions per proposal instruction

* chore: rename instruction to transaction

* chore: rename ProposalInstruction to ProposalTransaction

* chore: rename instruction to transaction

* chore: rename InstructionExecutionStatus to TransactionExecutionStatus

* chore: rename proposal instruction to proposal transaction

* chore: make clippy happy

* chore: update instruction names to transactions

* chore: fix compilation

* chore: rename instruction to transaction

* chore: rename instruction to transaction

* chore rename instruction to transaction

Co-authored-by: Jon Cinque jon.cinque@gmail.com
2022-01-29 12:43:22 +00:00
Sebastian Bor 46d27c7bed
Governance: Add max_executable_options to VoteType (#2831)
* feat: add max_executable_options to MultiChoice vote

* chore: update Governance comments

* chore: update comments
2022-01-29 02:51:50 +00:00
Sebastian Bor 0094255292
Governance: Max voter weight addin (#2815)
* chore: change voter-weight-addin to mock

* chore: fix tests

* chore: add action, target and expiry validation tests

* chore: add full target test checks

* feat: add max community voter weight adding structures

* chore: move payer to last account position

* wip: update max_community_voter_weight_addin

* chore: simplify logic to update realm config

* wip: setup addins when realm is created

* wip: setup voter weights accounts

* chore: make clippy happy

* core: fix merge

* chore: remove old readme

* chore: add SetupMaxVoterWeightRecord to addin mock

* chore: test_create_realm_with_max_voter_weight_addin test

* chore: add SetRealmConfigArgs and refactor tests

* chore: update max voter weight tests

* chore: setup cast_vote_with_max_voter_weight_addin test

* wip: get max voter weight from plugin

* chore: update comments and make clippy happy

* wip: use max voter weight to tip proposals

* chore: rename get_max_voter_weight

* chore: load addins using different ids

* chore: add tests with all addins

* fix: coerce max vote weight when cast votes are higher

* chore: add tests with all adins being used

* chore: add test for expired max voter weight record

* chore: simplify addin mock

* wip: Create addin api crate

* chore: use native build order and dependency

* chore: fix build

* feat: add reserved space to addin records

* chore: bump versions

* fix: use [u8; 8] discriminator for addin account types

* chore: update instruction comments

* chore: use saturating_sub instead of checked_sub

Co-authored-by: Jon Cinque
2022-01-29 02:08:21 +00:00
Sebastian Bor bf7ad18f41
Governance: vote options (#2544)
* feat: use VoteChoice instead of VoteWeight

* chore: make clippy happy

* feat: use options for ye/no vote

* feat: use choices for CastVote instruction

* chore: move Vote enum to tests

* fix: iterate overall choices for withdrawal

* chore: split ProposalOption and ProposalOptionVote

* fix: calculate multi option proposal size

* chore: split weighted and fractional vote choices

* feat: add proposal type

* feat: add reject option flag

* feat: calculate final state for proposal using options results

* chore: make clippy happy

* fix: generalise max vote weight calculation for multiple options

* feat: gate vote tipping for yes/no proposals only

* chore: make clippy happy

* feat: add option_index to instruction

* feat: move instructions to options

* chore: advance clock

* chore: add await

* chore: add multi option proposal tests

* chore: move governing_mint to account list

* feat: assert valid proposal options

* feat: assert proposal is executable when instruction is added

* chore: make clippy happy

* chore: add tests to insert instructions into multi option proposal

* chore: make clippy happy

* feat: use explicit reject_option_vote_weight

* feat: use Vote struct for vote results

* feat: validate vote

* feat: reject empty proposal options

* chore: update comments

* fix: allow execute only successful options

* chore: add assertions for option statuses

* chore: add partial success test

* chore: add full success execution test

* chore: add test for instructions execution for fully denied proposal

* feat: finalise none executable proposals into completed state

* chore: fix chat

* feat: add vote_record v1 v2 roundtrip serialization

* eat: add proposal_instruction v1 v2 roundtrip serialisation

* chore: use VoteRecordV1

* chore: use legacy structs instead of legacy crate version

* chore: rename proposal to V2

* feat: translate Proposal v1 v2 versions

* chore: make clippy happy

* chore: make clippy happy

* chore: remove unnecessary clone for match

* chore: rename get_final_vote_state to resolve_final_vote_state

* fix proposal account name

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* chore: fix compilation

* chore: use borsh::maybestd::io::Write

* chore: consume self in serialise instructions to avoid cloning

* chore: update comments

* feat: add N limit placeholder to multi choice vote type

* feat: increase options size to u16

* fix: use checked math

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-11-11 19:34:00 +00:00