Commit Graph

54 Commits

Author SHA1 Message Date
Sebastian Bor 10cf50ec2e
Governance: Use mint authority to revoke membership tokens (#3498)
* chore: fix process_revoke_governing_tokens feature

* feat: Use governing token mint authority to authorise token revocation

* chore: Fix authority spelling
2022-08-22 21:52:05 +02:00
Sebastian Bor 6dfc68db13
Governance: Council membership & plugins (#3344)
* chore: Use GovernanceTokenConfig

* wip: add council_token_config to RealmConfigAccount

* chore: update comment

* wip: use GoverningTokenConfigArgs for community token config

* chore: Change Proxy token type to Dormant

* chore: Update comments

* chore: Use GoverningTokenConfigAccountArgs for instructions creators

* chore: Use default  GoverningTokenType

* chore: Make community_token_args optional

* chore: Make Clippy happy

* chore: Update comments

* chore: Always create RealmConfigAccount

* chore: Set CouncilTokenConfig when realm is created

* feat: Update RealmConfigArgs in SetRealmConfig

* chore: Make Clippy happy

* chore: Assert RealmConfigAccount PDA

* wip: Use default RealmConfigAccount if the account doesn't exist

* chore: Remove use_community_voter_weight_addin and use_max_community_voter_weight_addin from RealmConfig

* chore: code review cleanup

* wip: Use voter weight addin for Council

* feat: Use max_voter_weight_plugin for Council

* feat: Impl RevokeGoverningTokens instruction

* chore: Make Clippy happy

* feat: Enforce governing token withdraw and deposit rules

* feat: Support minting deposits

* feat: Do not enforce token source owner for deposit validation

* chore: test_deposit_community_tokens_using_mint

* chore: Remove not implemented comment

* fix: Fix progrma id for resolving realm config for chat

* chore: Update instructions comments

* feat: Do not allow community Liquid token change to Membership

* chore: test_set_realm_config_with_liquid_community_token_cannot_be_changed_to_memebership_error

* chore: test_set_realm_config_for_community_token

* chore: use GoverningTokenConfig for test args

* chore: Refactor SetRealmConfigArgs

* chore: Update RealmSetupArgs names

* chore: test_set_realm_config_for_council_token_config

* chore: Revoke council tokens tests

* chore: test_revoke_council_tokens_with_realm_authority_must_sign_error

* chore: test_revoke_council_tokens_with_invalid_realm_authority_error

* chore: test_revoke_council_tokens_with_invalid_token_holding_error

* chore: RevokeGoverningToken tests

* chore: Dormant and Membership tokens tests

* chore: Using council plugin tests

* chore: RealmConfigAccount validation tests

* chore: Update Dormant token type configs

* fix: Reset legacy fields

* chore: Use Default macro for derivable defaults

* Chore: use assert functions to validate spl-token account and mint

* chore: Update Membership tokens comments

* chore: Pass governing_token_config_args as reference

* chore: Use single statement to return InvalidRevokeAmount error

* chore: Make Clippy happy - add derived Eq

Co-authored-by: Jon Cinque
2022-08-19 19:49:41 +02:00
hana 65769ce23d
Update rust to 1.60, solana to 1.11.6 (#3492)
also change bpf to sbf throughout the codebase

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-08-18 12:16:02 -07:00
Sebastian Bor aaca5353bc
chore: add test to show flash loan attack is not possible (#3238) 2022-06-11 12:56:06 +01:00
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 219b6a1b78
Governance: Council Vote Threshold (#3135)
* wip: Replace proposal_cool_off_time with council_vote_threshold

* wip: serialise governance vec

* wip: cool off time

* chore: create test to deserialize legacy config

* wip: default council_vote_threshold from community_vote_threshold for legacy accounts

* chore: fix chat compilation

* feat: use community_vote_threshold for voting

* feat: assert all voting thresholds are not disabled

* chore: simplify tests without config mutation

* feat: assert proposal is created for valid vote threshold

* chore: update test name

* chore: test_finalize_council_vote

* chore: test_cast_council_vote

* chore: test for disabled voter threshold

* feat: Ensure GovernanceConfig reserved buffer is always empty

* chore: change error name to AtLeastOneVoteThresholdRequired

* chore: add comments

* chore: Add VoteThreshold.Any comments
2022-05-06 17:24:46 +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 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 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 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 2600963545
Governance: Track proposals in Voting state for realms and governances (#2838)
* wip: add voting_proposal_count to Realm

* feat: track voting proposal count when proposal enters voting state

* chore: pass signatory or owner record

* chore: rename assert_can_create_governance to assert_create_authority_can_create_governance

* feat: decrease voting proposal count when proposal is canceled

* chore: remove clock and rent accounts

* chore: remove clock and rent

* chore: remove rent and clock

* chore: remove rent and clock

* chore: remove clock

* chore: remove rent

* chore: remove rent

* chore: remove rent

* fix: decrease voting_proposal_count when proposal is finalised

* fix: update voting_proposal_count when proposal vote is tipped

* wip: add muted checks for ream and governance config change
2022-01-29 23:52:11 +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
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 2e69f37633
Governance: Proposals signed off by owner (#2835)
* feat: allow proposal owner to sign off proposal directly

* chore: add proposal by owner sign off tests

* chore: add test for owner trying to sign off proposal with signatory
2022-01-29 15:48:05 +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 6070eb5f6c
Governance: Allow realm authority create governances (#2828)
* feat: make it possible for realm authority to create governances

* chore: refactor create governance authority check into a single instruction

* chore: add tests to create governance with ream authority signer

* chore: make clippy happy

* chore: update comments

* chore: fix merge conflicts

Co-authored-by: Jon Cinque jon.cinque@gmail.com
2022-01-29 02:50:13 +00:00
Sebastian Bor aee41fcccd
Governance: Make realm authority check optional (#2827)
* feat: support unchecked SetRealmAuthority

* chore: add test for unchecked set realm authority

Co-authored-by: Jon Cinque
2022-01-29 02:08:52 +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
Sebastian Bor 24bb1c8158
Governance: Native Treasuries (#2692)
* feat: Implement CreateNativeTreasury instruction

* chore: fix fmt

* chore: make clippy happy

* chore: remove account check

* feat: sign with treasury account seeds

* chore: comment out unused code

* feat: Use system as the treasury account owner

* feat: Assert valid governance account

* chore: Make clippy happy

* fix: Use explicit system program id

* feat: add treasury seeds only when required by the instruction

* chore: review celanup

* chore: make clippy happy

* chore: rename  create_and_serialize_account_signed2

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

* chore: update create_and_serialize_account_signed2 name

* fix: remove NativeTreasury from account enums

* chore: update treasury seeds prefix

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-01-03 22:30:34 +00:00
Sebastian Bor 78cb324352
Governance: Program metadata (#2679)
* feat: implement UpdateProgramMetadata instruction

* feat: put metadata info into the logs

* feat: use CARGO PKG version

* feat: add updated_at for program metadata

* chore: Update instruction comments

* chore: replace .unwrap() with ?

* fix: Change max size to support XXX.YYY.ZZZ version format
2021-12-31 00:44:32 +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 ef72e56738
Governance: Use max_voting_time to determine proposal final state (#2529)
* feat: do not allow withdrawing votes before proposal is finalised

* feat: do not allow proposal cancellation before proposal is finalised

* chore: update comments and add test

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-10-20 20:48:02 +01:00
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