Commit Graph

27 Commits

Author SHA1 Message Date
Sebastian Bor d6d0b92ae7
Governance: Voter-weight-addin cleanup (#2512)
* chore: Ensure voter-weight-addin is built for tests

fix: build addin during test run

fix: build voter weight addin for tests using the addin only

chore: use mutex to build addin only once

chore: move build guard to separate file

chore: update governance version for chat

* chore: create tools crate for common utility functions in governance ecosystem

* chore: add test-sdk and tools readme

* chore: rename reserved addins to specific names

* chore: remove todo comment

* chore: remove unnecessary var drop

* chore: move all account tools to shared crate

* chore: fix chat compilation

* chore: move program_id to first position
2021-10-19 11:43:01 +01: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
Sebastian Bor 11ba3fb824
Governance: Constrain active proposals (#2268)
* wip: add unresolved_proposal_count to Proposal

* chore: update create_proposal test

* chore: bump version

* feat: decrease unresolved proposal count for Cancel ix

* chore: rename unresolved to outstanding

* feat: decrease outstanding proposal count for CastVote ix

* feat: decrease outstanding proposal count for FinalizeVote ix

* feat: Prevent withdrawals with outstanding proposals

* chore: fix unit test

* chore: make clippy happy

* chore: update instructions comments

* chore: temp. exclude tests with slots wrapping
2021-08-12 03:05:03 +02:00
Sebastian Bor f6f5e9a619
Governance: Min tokens to create governance (#2203)
* feat: add min_community_tokens_to_create_governance to config

* feat: add token owner record and governing mint to CreateAccountGovernance

* feat: add token owner record and governing mint to CreateMinGovernance

* feat: add token owner record and governing mint to CreateProgramGovernance

* feat: add token owner record and governing mint to CreateTokenGovernance

* feat: remove custodian

* fix: remove mint and update comments

* chore: make clippy happy

* chore: make clippy happy
2021-08-03 09:10:45 +01:00
Sebastian Bor 965afef2cd
Governance: Realm config and max vote weight (#2188)
* feat: change mint fraction precision to 10^10

* chore: move optional fields towards the end of RealmConfig

* chore: fix comment

* feat: create realm using config args

* chore: update comments

* chore: make clippy happy

* chore: fix test name

* fix: remove realm authority from config_args and make it mandatory

* feat: implement SetRealmConfig instruction

* chore: move custodian above council in accounts list

* chore: add tests for setting realm config

* chore: bump version

* chore: make clippy happy

* chore: validate and pass realm to

* feat: validate realm config args

* feat: calculate max vote weight

* chore: make clippy happy and update comments

* fix: adjust max vote weight for vote overflow
2021-08-01 20:26:04 +01:00
Sebastian Bor a74c5b998b
Governance: Realm config (#2166)
* feat: create RealmConfig and move council to it

* feat: add realm custodian to config

* feat: add community_mint_max_vote_weight_source tp realm config

* chore: fix data types
2021-07-29 17:04:05 +01:00
Sebastian Bor 6775230b7e
Governance: validate holding account (#2157)
* fix: validate governing token holding account for deposits

* fix: validate governing token holding account for withdrawals
2021-07-28 18:49:50 +01:00
Sebastian Bor 9dd6dd25f0
Governance: Use option for proposal VoteThresholdPercentage (#2153) 2021-07-27 23:12:28 +01:00
Sebastian Bor 1eaef02a21
Governance: Capture vote_threshold_percentage on voted on proposal (#2152)
* feat: capture vote_threshold_percentage on voted on proposal

* chore: fix test
2021-07-27 16:07:01 +01:00
Sebastian Bor 4b9139981c
Governance: SetRealmAuthority instruction (#2137)
* feat: implement SetRealmAuthority

* chore: add test_sign_off_proposal_with_signatory_must_sign_error

* chore: fix test name

* chore: pass option as value

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-27 15:42:06 +01:00
Sebastian Bor 51df704edb
Governance: Capture realm authority and proposal mint vote supply (#2129)
* chore: move config towards account end to allow potential future grow

* feat: add realm authority to the account

* feat: add governing_token_mint_supply to proposal account

* feat: save realm authority when realm is created

* feat: capture governing mint supply when voting starts

* chore: update comments

* feat: capture governing_token_mint_supply when voting is decided

* Revert "feat: capture governing mint supply when voting starts"

This reverts commit c8d786d322f6c2907fa58b650100021bada9486e.

* chore: update comments on governing_token_mint_vote_supply

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-23 12:06:18 +01:00
Sebastian Bor d17679a161
Governance: Use separate thresholds to create proposals for council and community tokens (#2124)
* feat: use separate thresholds for council and community tokens to crate proposals

* chore: add tests for proposal creation

* chore: cleanup code and bump version

* chore: fix test name

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-22 19:40:30 +01:00
Sebastian Bor 5b5e5bed2a
Governance: FlagInstructionError instruction (#2099)
* feat: implement FlagInstructionError

* fix: ensure instruction can still be executed after being flagged with error

* chore: review cleanup

* chore: bump version

* chore: code review updates

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

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-20 11:53:38 +01:00
Sebastian Bor 4f2a8dbb30
Governance: Move realm and goverend_account from config to direct field (#2060)
* chore: move realm from config to governance account direct field

* chore: move governed_account from config to governance account direct field

* chore: update comments

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-12 15:38:58 +01:00
Sebastian Bor 28928eaec2
Governance: SetGovernanceConfig instruction (#2039)
* feat: implement set_governance_config instruction

* chore: add authority error tests

* chore: rename with_instruction methods

* chore: add invalid config tests

* chore: code cleanup

* chore: cleanup test
2021-07-10 11:19:22 +01:00
Sebastian Bor cf4b264c3d
Governance: future proofing for v2 (#2002)
* chore: upgrade instruction serialisation

* chore: add assert for base64 encoded instruction

* chore: move fields with dynamic size to account  end

* chore: Add VoteThresholdPercentageType to support quorum votes in future versions

* chore: Add VoteWeightSource to support account snapshots as voter weights in future versions

* chore: Add InstructionExecutionStatus to support failing proposal instructions in future versions

* fix: update voting_at_slot when proposal enters voting state

* fix: change min_tokens_to_create_proposal to u64 to support large mints

* chore: add InstructionExecutionFlags to support ordered and transactional instruction in future versions

* chore: add withdraw tests with relinquished and unrelinquished votes

* chore: add placeholder for proposal_cool_off_time

* chore: add padding to permanent accounts to use in future versions

* chore: add ProposalCoolOffTimeNotSupported error

* chore: start governance errors from 500

* chore: update versions

* chore: update comments

* chore: use slice for reserved account space

* chore: use VoteThresholdPercentage enum to store percentage value

* chore: use enum None value instead of Option for execution_status

* chore: use enum None instead of Option for execution_flags

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-07-07 14:43:31 +01:00
Sebastian Bor 775e536842
Governance: Change timestamps and time periods to UnixTimestamp (#1984)
* feat: change signing_off_at and closed_at to UnixTimestamp

* feat: change executing_at to UnixTimestamp

* feat: change voting_at and voting_completed_at to UnixTimestamp

* feat: change draft_at to UnixTimestamp

* chore: cleanup slot/timestamp comments

* chore: fix merge conflicts
2021-06-29 23:03:09 +01:00
Sebastian Bor 3c561381fd
Governance: Create token governance (#1968)
* feat: implement CreateTokenGovernance instruction

* chore: update readme

* chore: add execute transfer instruction test

* chore: update readme

* chore: update comments

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

* chore: update readme

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-29 22:22:42 +01:00
Sebastian Bor 329d7e38ee
Governance: Create mint governance (#1953)
* feat: implement CreateMintGovernance instruction

* fix: ensure mint is initialised in assert_is_valid_spl_token_mint

* fix: ensure token account is initialised in assert_is_valid_spl_token_account

* chore: move account type and instruction to the end to avoid breaking changes

* chore: make clippy happy

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-25 21:31:14 +01:00
Sebastian Bor 5b34f25b5c
Governance: use runtime program_id (#1947)
* feat: use runtime program_id
* chore: make clippy happy
2021-06-22 22:31:39 +01:00
Sebastian Bor c9e3689a94
Governance: Instructions (#1833)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-06-05 14:06:57 +01:00
Sebastian Bor f59e43757b
Governance: Voting workflow
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-29 22:51:48 +01:00
Sebastian Bor 94350d0e8e
Governance: Create Proposals and Sign Off workflow (#1767)
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-26 16:40:18 +01:00
Sebastian Bor b488aee067
Governance: Create governance accounts
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-05-23 00:36:02 +01:00
Sebastian Bor addc6bf4b4
Governance: Implement Realms
Implemented instructions:
- CreateRealm
- DepositGoverningTokens
- WithdrawGoverningTokens
-SetVoteAuthority

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
Co-authored-by: Michael Vines <mvines@gmail.com>
2021-05-19 12:20:53 +01:00