Skip to content

Commit

Permalink
Fix clippy warnings #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Semen Medvedev committed Apr 1, 2022
1 parent fb41043 commit 3734b64
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion addin-fixed-weights/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ fn get_voter_weight_fixed(token_owner: &Pubkey) -> Result<u64,ProgramError> {
.iter()
.find(|&&item| item.0 == *token_owner )
.map(|item| item.1 )
.ok_or(VoterWeightAddinError::WrongTokenOwner.into())
.ok_or_else(|| VoterWeightAddinError::WrongTokenOwner.into())
}
1 change: 1 addition & 0 deletions addin-vesting/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ pub fn create_voter_weight_record(
}

/// Creates a `ChangeVotePercentage` instruction with realm
#[allow(clippy::too_many_arguments)]
pub fn set_vote_percentage_with_realm(
program_id: &Pubkey,
seeds: [u8; 32],
Expand Down
4 changes: 2 additions & 2 deletions governance-lib/src/addin_fixed_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ impl<'a> AddinFixedWeights<'a> {
&self.program_id,
&realm.address,
&realm.community_mint,
&token_owner);
token_owner);

if !self.interactor.account_exists(&voter_weight_record_pubkey) {
let setup_voter_weight_record_instruction: Instruction =
spl_governance_addin_fixed_weights::instruction::setup_voter_weight_record(
&self.program_id,
&realm.address,
&realm.data.community_mint,
&token_owner,
token_owner,
&self.interactor.payer.pubkey(),
);

Expand Down
4 changes: 2 additions & 2 deletions governance-lib/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ impl<'a> SplGovernanceInteractor<'a> {
SplGovernanceInteractor {
url: url.to_string(),
solana_client: RpcClient::new_with_commitment(url.to_string(),CommitmentConfig::confirmed()),
payer: payer,
payer,
spl_governance_program_address: program_address,
spl_governance_voter_weight_addin_address: addin_address,
}
}
pub fn account_exists(&self, address: &Pubkey) -> bool {
self.solana_client.get_account(&address).is_ok()
self.solana_client.get_account(address).is_ok()
}
pub fn get_realm_address(&self, name: &str) -> Pubkey {
get_realm_address(&self.spl_governance_program_address, name)
Expand Down
6 changes: 3 additions & 3 deletions governance-lib/src/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> Realm<'a> {
}

pub fn create_token_owner_record<'b:'a>(&'b self, token_owner: &Pubkey) -> Result<TokenOwner<'a>,ClientError> {
let token_owner_record_address: Pubkey = self.get_token_owner_record_address(&token_owner);
let token_owner_record_address: Pubkey = self.get_token_owner_record_address(token_owner);

if !self.interactor.account_exists(&token_owner_record_address) {
let create_token_owner_record_instruction: Instruction =
Expand Down Expand Up @@ -87,8 +87,8 @@ impl<'a> Realm<'a> {
TokenOwner {
realm: self,
//authority: token_owner_keypair,
token_owner_record_address: token_owner_record_address,
token_owner_record: self.get_token_owner_record_v2(&token_owner),
token_owner_record_address,
token_owner_record: self.get_token_owner_record_v2(token_owner),
// voter_weight_record_authority: None,
voter_weight_record_address: None,
// voter_weight_record: None,
Expand Down
36 changes: 18 additions & 18 deletions governance-test-scripts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ use governance_lib::{
addin_fixed_weights::AddinFixedWeights,
};

const GOVERNANCE_KEY_FILE_PATH: &'static str = "solana-program-library/target/deploy/spl_governance-keypair.json";
const VOTER_WEIGHT_ADDIN_KEY_FILE_PATH: &'static str = "target/deploy/spl_governance_addin_fixed_weights-keypair.json";
const COMMUTINY_MINT_KEY_FILE_PATH: &'static str = "governance-test-scripts/community_mint.keypair";
const GOVERNED_MINT_KEY_FILE_PATH: &'static str = "governance-test-scripts/governance.keypair";
const PAYER_KEY_FILE_PATH: &'static str = "artifacts/payer.keypair";
const GOVERNANCE_KEY_FILE_PATH: &str = "solana-program-library/target/deploy/spl_governance-keypair.json";
const VOTER_WEIGHT_ADDIN_KEY_FILE_PATH: &str = "target/deploy/spl_governance_addin_fixed_weights-keypair.json";
const COMMUTINY_MINT_KEY_FILE_PATH: &str = "governance-test-scripts/community_mint.keypair";
const GOVERNED_MINT_KEY_FILE_PATH: &str = "governance-test-scripts/governance.keypair";
const PAYER_KEY_FILE_PATH: &str = "artifacts/payer.keypair";

const VOTERS_KEY_FILE_PATH: [&str;5] = [
"artifacts/voter1.keypair",
Expand All @@ -51,11 +51,11 @@ const VOTERS_KEY_FILE_PATH: [&str;5] = [
"artifacts/voter5.keypair",
];

// const REALM_NAME: &'static str = "Test Realm";
const REALM_NAME: &'static str = "Test_Realm_4";
// const REALM_NAME: &'static str = "Test Realm 6";
const PROPOSAL_NAME: &'static str = "Proposal To Vote";
const PROPOSAL_DESCRIPTION: &'static str = "proposal_description";
// const REALM_NAME: &str = "Test Realm";
const REALM_NAME: &str = "Test_Realm_4";
// const REALM_NAME: &str = "Test Realm 6";
const PROPOSAL_NAME: &str = "Proposal To Vote";
const PROPOSAL_DESCRIPTION: &str = "proposal_description";

fn main() {

Expand Down Expand Up @@ -130,13 +130,13 @@ fn main() {
gov_config).unwrap();
println!("{:?}", governance);

let proposal_number: u32 =
if governance.get_proposal_count() > 0 {
// governance.get_proposal_count()
0
} else {
0
};
let proposal_number: u32 = 0;
// if governance.get_proposal_count() > 0 {
// // governance.get_proposal_count()
// 0
// } else {
// 0
// };
let proposal: Proposal = governance.create_proposal(
&voter_keypairs[0],
&token_owners[0],
Expand All @@ -158,7 +158,7 @@ fn main() {
let yes = i == 0 || i == 3 || i == 4;
let result = proposal.cast_vote(
&voter_keypairs[i],
&owner, yes);
owner, yes);
println!("CastVote {} {:?}", i, result);
}
}

0 comments on commit 3734b64

Please sign in to comment.