Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 3e4e2d6

Browse files
authored
Governance: Review feedback (#139)
* chore: Update active_proposal_count comment * chore: Update account indices in process_create_proposal * fix: Disallow u8::MAX for deposit_exempt_proposal_count * chore: Use u64 without option for extra_lamports * fix: Use explicit version 1 for TokenOwnerRecord migration * chore: Update math for RealmConfigAccount::get_max_size * fix: Flag ProposalCoolOffTimeNotSupported as legacy instead of reusing it
1 parent 103e801 commit 3e4e2d6

22 files changed

+88
-52
lines changed

governance/program/src/error.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ pub enum GovernanceError {
255255
#[error("Given VoteWeightSource is not supported")]
256256
VoteWeightSourceNotSupported, // 559
257257

258-
/// GoverningTokenMint not allowed to vote
259-
#[error("GoverningTokenMint not allowed to vote")]
260-
GoverningTokenMintNotAllowedToVote, // 560
258+
/// Legacy1
259+
#[error("Legacy1")]
260+
Legacy1, // 560
261261

262262
/// Governance PDA must sign
263263
#[error("Governance PDA must sign")]
@@ -450,6 +450,14 @@ pub enum GovernanceError {
450450
/// Invalid ProposalDeposit account address
451451
#[error("Invalid ProposalDeposit account address")]
452452
InvalidProposalDepositAccountAddress, // 608
453+
454+
/// Invalid deposit_exempt_proposal_count
455+
#[error("Invalid deposit_exempt_proposal_count")]
456+
InvalidDepositExemptProposalCount, // 609
457+
458+
/// GoverningTokenMint not allowed to vote
459+
#[error("GoverningTokenMint not allowed to vote")]
460+
GoverningTokenMintNotAllowedToVote, // 610
453461
}
454462

455463
impl PrintProgramError for GovernanceError {

governance/program/src/processor/process_add_signatory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn process_add_signatory(
6262
program_id,
6363
system_info,
6464
&rent,
65-
None,
65+
0,
6666
)?;
6767

6868
proposal_data.signatories_count = proposal_data.signatories_count.checked_add(1).unwrap();

governance/program/src/processor/process_cast_vote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn process_cast_vote(
214214
program_id,
215215
system_info,
216216
&rent,
217-
None,
217+
0,
218218
)?;
219219

220220
Ok(())

governance/program/src/processor/process_create_governance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn process_create_governance(
7272
program_id,
7373
system_info,
7474
&rent,
75-
None,
75+
0,
7676
)?;
7777

7878
Ok(())

governance/program/src/processor/process_create_mint_governance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn process_create_mint_governance(
8282
program_id,
8383
system_info,
8484
&rent,
85-
None,
85+
0,
8686
)?;
8787

8888
if transfer_mint_authorities {

governance/program/src/processor/process_create_native_treasury.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn process_create_native_treasury(
4242
&system_program::id(), // System program as the PDA owner
4343
system_info,
4444
&rent,
45-
None,
45+
0,
4646
)?;
4747

4848
Ok(())

governance/program/src/processor/process_create_program_governance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub fn process_create_program_governance(
8484
program_id,
8585
system_info,
8686
&rent,
87-
None,
87+
0,
8888
)?;
8989

9090
if transfer_upgrade_authority {

governance/program/src/processor/process_create_proposal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ pub fn process_create_proposal(
8585
proposal_owner_record_data
8686
.assert_token_owner_or_delegate_is_signer(governance_authority_info)?;
8787

88-
let realm_config_info = next_account_info(account_info_iter)?; // 10
88+
let realm_config_info = next_account_info(account_info_iter)?; // 8
8989
let realm_config_data =
9090
get_realm_config_data_for_realm(program_id, realm_config_info, realm_info.key)?;
9191

9292
let voter_weight = proposal_owner_record_data.resolve_voter_weight(
93-
account_info_iter, // voter_weight_record *11
93+
account_info_iter, // voter_weight_record *9
9494
&realm_data,
9595
&realm_config_data,
9696
VoterWeightAction::CreateProposal,
@@ -177,7 +177,7 @@ pub fn process_create_proposal(
177177
program_id,
178178
system_info,
179179
&rent,
180-
None,
180+
0,
181181
)?;
182182

183183
governance_data.active_proposal_count = governance_data
@@ -188,7 +188,7 @@ pub fn process_create_proposal(
188188
// Take Proposal deposit if needed
189189
let proposal_deposit_amount = governance_data.get_proposal_deposit_amount();
190190
if proposal_deposit_amount > 0 {
191-
let proposal_deposit_info = next_account_info(account_info_iter)?; // *8
191+
let proposal_deposit_info = next_account_info(account_info_iter)?; // *10
192192
let proposal_deposit_data = ProposalDeposit {};
193193

194194
create_and_serialize_account_signed::<ProposalDeposit>(
@@ -199,7 +199,7 @@ pub fn process_create_proposal(
199199
program_id,
200200
system_info,
201201
&rent,
202-
Some(proposal_deposit_amount),
202+
proposal_deposit_amount,
203203
)?;
204204
}
205205

governance/program/src/processor/process_create_realm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn process_create_realm(
118118
program_id,
119119
system_info,
120120
rent,
121-
None,
121+
0,
122122
)?;
123123

124124
// Create and serialize Realm
@@ -151,7 +151,7 @@ pub fn process_create_realm(
151151
program_id,
152152
system_info,
153153
rent,
154-
None,
154+
0,
155155
)?;
156156

157157
Ok(())

governance/program/src/processor/process_create_token_governance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn process_create_token_governance(
8282
program_id,
8383
system_info,
8484
&rent,
85-
None,
85+
0,
8686
)?;
8787

8888
if transfer_account_authorities {

0 commit comments

Comments
 (0)