Commit Graph

14 Commits

Author SHA1 Message Date
Sebastian Bor ebc91e871a
Governance: add v2 account padding (#2842)
* chore: create RealmV2 account type

* feat: add padding to Realm account

* chore: move RealmConfigArgsV1 and GovernanceInstructionV1 to tests

* chore: Add RealmV2 comments

* chore: rename TokenOwnerRecord to V2 and add reserved space

* feat: translate TokenOwnerRecordV1

* chore: rename Governance to GovernanceV2

* feat: add reserved_v2 to Governance

* chore: make clippy happy

* feat: translate GovernanceV1 accounts

* chore: fix chat build

* fix: update seeds logic for governance V1 accounts

* fix: add check for RealmV1 and GovernanceV1

* chore: add padding to ProposalTransaction

* chore: add padding to VoteRecordV2

* chore: add padding to SignatoryRecord V2

* feat: translate SignatoryRecordV1 account
2022-01-31 03:58:28 +00:00
Sebastian Bor 0e85d2e3e0
Governance: Rename tokens_to_create to weight_to_create (#2839)
* chore: assert options length when serialising ProposalV1

* chore: rename tokens_to_create to weight_to_create

* fix: use saturating_sub for voting_proposal_count

* chore: update voting_proposal_count comments

* Revert "chore: update voting_proposal_count comments"

This reverts commit 3e2eb9d90afdd4f6001d17b14f9579fb72ebb895.

* Revert "fix: use saturating_sub for voting_proposal_count"

This reverts commit 5d357049b7bbc12d8ec9d46caefe3b740967fae3.
2022-01-30 22:23:11 +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
Christian Kamm 5850973d97
Governance: Add VoteTipping option (#2826)
* spl-governance: Add VoteTipping option

This allows two new tipping styles in addition to the previous "Strict"
mode:
- Early: Where a yes majority above the yes vote threshold will
  complete the vote, even if below 50% of total possible votes.
- Disabled: Where votes never complete early.

* address review nits
2022-01-29 18:13:18 +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 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 5d330d1a74
Governance: Voter weight action & target (#2803)
* feat: add weight action and target to VoterWeightRecord

* chore: update comments

* chore: change voter-weight-addin to mock

* chore: fix tests

* chore: add action, target and expiry validation tests

* chore: add full target test checks

* chore: update comments

* chore: rename addin to addin-mock

* chore: rename voter-weight-addin to addin

* chore: fix tests
2022-01-26 17:00:00 +00:00
Sebastian Bor 56953b2286
Governance: Transfer freeze and close authorities (#2799)
* fix: transfer mint freeze authority for mint governance

* chore: update transfer_mint_authorities comments

* feat: transfer close_authority when creating token account governance

* chore: update spl-token function names

* chore: remove redundant set_spl_token_mint_authority
2022-01-25 11:02:43 +00:00
Sebastian Bor 2ae2f5f067
Governance Chat: Voter weight (#2778)
* chore: update governance chat program version to 0.2.0

* feat: support voter weight for chat

* chore: move ensure_voter_weight_addin_is_built to test sdk

* chore: add program version to logs

* fix: workaround for logs

* chore: add test for chat message using voter weight addin

* chore: remove logger overrides

Co-authored-by: Jon Cinque
2022-01-24 17:59:21 +00:00
Jon Cinque d5581dbd62
governance: Remove dependency on ProcessInstructionWithContext (#2589) 2021-11-17 15:48:01 +01: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
Sebastian Bor dc7f6be034
Governance: Add deposit amount (#2485)
* feat: add amount to Deposit instruction

* feat: use try_from_slice_unchecked to support forward compatibility

* chore: make clippy happy

* chore: update comments
2021-10-13 19:59:30 +01:00
Sebastian Bor c99f4195f1
Governance: Voters weights add-in (#2450)
* feat: setup and configure voter weight addin

feat: add use_voter_weight_add_in flag to realm config

chore: use spl-governance 1.1.1 version

chore: make clippy happy

chore: add test to deserialise v1 CreateRealm instruction from v2

feat: add voter-weight-addin skeleton project

chore: build voter-weight-addin before governance

fix: temp workaround to make spl_governance_voter_weight_addin available in CI

chore: add tests with voter-weight-addin

feat: implement deposit instruction for voter weight addin

feat: add voter_weight_expiry

fix: set voter_weight_expiry

chore: restore positive execute tests

chore: restore ignored tests

wip: pass voter weight accounts to create_account_governance2

wip: read voter weight account

chore: make clippy happy

wip: add realm and validation to voter_weight deposit

fix: update addin

chore: make clippy happy

chore: fix voter_weight_record names

feat: use voter weight provided by addin when governance created

chore: update addin

chore: remove governance stake pool program

feat: remove time offset from revise

chore: fix build

feat: create RealmAddins account when realm with addin is created

chore: make clippy happy

feat: set voter weight addin using SetRealmConfig instruction

chore: make clippy happy

chore: update comments

chore: reorder SetrealmConfig accounts

chore: infer use_community_voter_weight_addin

chore: infer use_community_voter_weight_addin

chore: update voter weight addin comments

feat: use voter weight addin id from RealmAddins account

* feat: use voter weight addin to create proposal

* feat: use voter weight addin to cast vote

* chore: make clippy happy

* feat: use voter weight addin to create token governance

* feat: use voter weight addin to create mint governance

* feat: use voter weight adding to create program governance

* chore: create assert_can_withdraw_governing_tokens() helper function

* chore: fix compilation

* fix: ensure governance authority signed transaction to create governance

* feat: implement CreateTokenOwnerRecord instruction

* chore: fix chat tests

* chore: update comments

* chore: rename RealmAddins account to RealmConfig account

* chore: add more reserved space to GovernanceConfig account

* chore: update instruction comments

* chore: update comments

* chore: fix compilation

* chore: remove ignore directive for tests

* feat: panic when depositing tokens into a realm with voter weight addin

* chore: rename community_voter_weight to community_voter_weight_addin

* feat: make payer account optional for SetRealmConfig
2021-10-13 13:15:22 +01:00
Sebastian Bor b3684bbfe9
Governance: Chat program (#2319)
* chore: create test-sdk crate

* chore: create test-sdk crate

* chore: use shred test bench to run tests

* chore: scaffold governance chat program

* chore: move process_transaction to bench

* chore: add with_proposal factory function

* chore: move token utility functions to bench

* chore: create test realm

* chore: move create_token_account_with_transfer_authority to bench

* chore: create test governance

* chore: create test proposal

* feat: implement process_post_message

* chore: move get_clock to bench

* chore: add clock and message author

* chore: move get_borsh_account and get_account to bench

* feat: add reaply_to

* chore: update comments

* chore: update comments and make clippy happy

* chore: add reply to test

* chore: assert is valid replyTo chat message

* chore: add error test cases

* chore: add not enough tokens error test

* chore: update Reaction comment

* feat: assert new account is not initialised

* chore: upgrade chat version

* chore: add license

* chore: update cargo lock

* chore: fix solana version

* chore: update cargo.lock

* chore: move chat program inside governance folder
2021-09-09 15:45:01 +01:00