@@ -7,13 +7,13 @@ use crate::{
77 get_account_governance_address, get_mint_governance_address,
88 get_program_governance_address, get_token_governance_address, GovernanceConfig ,
99 } ,
10- proposal:: get_proposal_address,
10+ proposal:: { get_proposal_address, VoteType } ,
1111 proposal_instruction:: { get_proposal_instruction_address, InstructionData } ,
1212 realm:: { get_governing_token_holding_address, get_realm_address, RealmConfigArgs } ,
1313 realm_config:: get_realm_config_address,
1414 signatory_record:: get_signatory_record_address,
1515 token_owner_record:: get_token_owner_record_address,
16- vote_record:: get_vote_record_address,
16+ vote_record:: { get_vote_record_address, Vote } ,
1717 } ,
1818 tools:: bpf_loader_upgradeable:: get_program_data_address,
1919} ;
@@ -25,16 +25,6 @@ use solana_program::{
2525 system_program, sysvar,
2626} ;
2727
28- /// Yes/No Vote
29- #[ repr( C ) ]
30- #[ derive( Clone , Debug , PartialEq , BorshDeserialize , BorshSerialize , BorshSchema ) ]
31- pub enum Vote {
32- /// Yes vote
33- Yes ,
34- /// No vote
35- No ,
36- }
37-
3828/// Instructions supported by the Governance program
3929#[ derive( Clone , Debug , PartialEq , BorshDeserialize , BorshSerialize , BorshSchema ) ]
4030#[ repr( C ) ]
@@ -164,25 +154,36 @@ pub enum GovernanceInstruction {
164154 /// 1. `[writable]` Proposal account. PDA seeds ['governance',governance, governing_token_mint, proposal_index]
165155 /// 2. `[writable]` Governance account
166156 /// 3. `[writable]` TokenOwnerRecord account of the Proposal owner
167- /// 4. `[signer]` Governance Authority (Token Owner or Governance Delegate)
168- /// 5. `[signer]` Payer
169- /// 6. `[]` System program
170- /// 7. `[]` Rent sysvar
171- /// 8. `[]` Clock sysvar
172- /// 9. `[]` Optional Realm Config
173- /// 10. `[]` Optional Voter Weight Record
157+ /// 4. `[]` Governing Token Mint the Proposal is created for
158+ /// 5. `[signer]` Governance Authority (Token Owner or Governance Delegate)
159+ /// 6. `[signer]` Payer
160+ /// 7. `[]` System program
161+ /// 8. `[]` Rent sysvar
162+ /// 9. `[]` Clock sysvar
163+ /// 10. `[]` Optional Realm Config
164+ /// 11. `[]` Optional Voter Weight Record
174165 CreateProposal {
175166 #[ allow( dead_code) ]
176167 /// UTF-8 encoded name of the proposal
177168 name : String ,
178169
179170 #[ allow( dead_code) ]
180- /// Link to gist explaining proposal
171+ /// Link to a gist explaining the proposal
181172 description_link : String ,
182173
183174 #[ allow( dead_code) ]
184- /// Governing Token Mint the Proposal is created for
185- governing_token_mint : Pubkey ,
175+ /// Proposal vote type
176+ vote_type : VoteType ,
177+
178+ #[ allow( dead_code) ]
179+ /// Proposal options
180+ options : Vec < String > ,
181+
182+ #[ allow( dead_code) ]
183+ /// Indicates whether the proposal has the deny option
184+ /// A proposal without the rejecting option is a non binding survey
185+ /// Only proposals with the rejecting option can have executable instructions
186+ use_deny_option : bool ,
186187 } ,
187188
188189 /// Adds a signatory to the Proposal which means this Proposal can't leave Draft state until yet another Signatory signs
@@ -226,6 +227,9 @@ pub enum GovernanceInstruction {
226227 /// 6. `[]` System program
227228 /// 7. `[]` Rent sysvar
228229 InsertInstruction {
230+ #[ allow( dead_code) ]
231+ /// The index of the option the instruction is for
232+ option_index : u16 ,
229233 #[ allow( dead_code) ]
230234 /// Instruction index to be inserted at.
231235 index : u16 ,
@@ -285,7 +289,7 @@ pub enum GovernanceInstruction {
285289 /// 12. `[]` Optional Voter Weight Record
286290 CastVote {
287291 #[ allow( dead_code) ]
288- /// Yes/No vote
292+ /// User's vote
289293 vote : Vote ,
290294 } ,
291295
@@ -823,6 +827,9 @@ pub fn create_proposal(
823827 name : String ,
824828 description_link : String ,
825829 governing_token_mint : & Pubkey ,
830+ vote_type : VoteType ,
831+ options : Vec < String > ,
832+ use_deny_option : bool ,
826833 proposal_index : u32 ,
827834) -> Instruction {
828835 let proposal_address = get_proposal_address (
@@ -837,6 +844,7 @@ pub fn create_proposal(
837844 AccountMeta :: new( proposal_address, false ) ,
838845 AccountMeta :: new( * governance, false ) ,
839846 AccountMeta :: new( * proposal_owner_record, false ) ,
847+ AccountMeta :: new_readonly( * governing_token_mint, false ) ,
840848 AccountMeta :: new_readonly( * governance_authority, true ) ,
841849 AccountMeta :: new( * payer, true ) ,
842850 AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
@@ -849,7 +857,9 @@ pub fn create_proposal(
849857 let instruction = GovernanceInstruction :: CreateProposal {
850858 name,
851859 description_link,
852- governing_token_mint : * governing_token_mint,
860+ vote_type,
861+ options,
862+ use_deny_option,
853863 } ;
854864
855865 Instruction {
@@ -1095,12 +1105,17 @@ pub fn insert_instruction(
10951105 governance_authority : & Pubkey ,
10961106 payer : & Pubkey ,
10971107 // Args
1108+ option_index : u16 ,
10981109 index : u16 ,
10991110 hold_up_time : u32 ,
11001111 instruction : InstructionData ,
11011112) -> Instruction {
1102- let proposal_instruction_address =
1103- get_proposal_instruction_address ( program_id, proposal, & index. to_le_bytes ( ) ) ;
1113+ let proposal_instruction_address = get_proposal_instruction_address (
1114+ program_id,
1115+ proposal,
1116+ & option_index. to_le_bytes ( ) ,
1117+ & index. to_le_bytes ( ) ,
1118+ ) ;
11041119
11051120 let accounts = vec ! [
11061121 AccountMeta :: new_readonly( * governance, false ) ,
@@ -1114,6 +1129,7 @@ pub fn insert_instruction(
11141129 ] ;
11151130
11161131 let instruction = GovernanceInstruction :: InsertInstruction {
1132+ option_index,
11171133 index,
11181134 hold_up_time,
11191135 instruction,
0 commit comments