Skip to content

Commit

Permalink
Rust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbogle committed May 27, 2022
1 parent 8840eb9 commit c873a99
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
7 changes: 4 additions & 3 deletions programs/hydra/src/processors/signing/sign_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ pub fn sign_metadata(ctx: Context<SignMetadata>) -> Result<()> {
ctx.accounts.fanout.key().as_ref(),
&[*ctx.bumps.get("holding_account").unwrap()],
]],
).map_err(|e| {
error::Error::ProgramError(ProgramErrorWithOrigin{
)
.map_err(|e| {
error::Error::ProgramError(ProgramErrorWithOrigin {
program_error: e,
error_origin: None,
compared_values: None
compared_values: None,
})
})?;
Ok(())
Expand Down
5 changes: 1 addition & 4 deletions programs/hydra/src/processors/stake/set_for.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ pub struct SetForTokenMemberStake<'info> {
pub token_program: Program<'info, Token>,
}

pub fn set_for_token_member_stake(
ctx: Context<SetForTokenMemberStake>,
shares: u64,
) -> Result<()> {
pub fn set_for_token_member_stake(ctx: Context<SetForTokenMemberStake>, shares: u64) -> Result<()> {
let fanout = &mut ctx.accounts.fanout;
let member = &ctx.accounts.member;
let membership_voucher = &mut ctx.accounts.membership_voucher;
Expand Down
5 changes: 1 addition & 4 deletions programs/hydra/src/utils/logic/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ pub fn calculate_dist_amount(
Ok(dist_amount as u64)
}

pub fn update_fanout_for_add(
fanout: &mut Account<Fanout>,
shares: u64,
) -> Result<()> {
pub fn update_fanout_for_add(fanout: &mut Account<Fanout>, shares: u64) -> Result<()> {
let less_shares = fanout
.total_available_shares
.checked_sub(shares)
Expand Down
5 changes: 1 addition & 4 deletions programs/hydra/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ pub fn parse_fanout_mint(
Ok(fanout_for_mint_object)
}

pub fn parse_token_account(
account: &AccountInfo,
owner: &Pubkey,
) -> Result<TokenAccount> {
pub fn parse_token_account(account: &AccountInfo, owner: &Pubkey) -> Result<TokenAccount> {
let ref_data = account.try_borrow_data()?;
let mut account_data: &[u8] = &ref_data;
let account_object = TokenAccount::try_deserialize(&mut account_data)?;
Expand Down
11 changes: 2 additions & 9 deletions programs/hydra/src/utils/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ pub fn assert_owned_by(account: &AccountInfo, owner: &Pubkey) -> Result<()> {
}
}

pub fn assert_membership_model(
fanout: &Account<Fanout>,
model: MembershipModel,
) -> Result<()> {
pub fn assert_membership_model(fanout: &Account<Fanout>, model: MembershipModel) -> Result<()> {
if fanout.membership_model != model {
return Err(HydraError::InvalidMembershipModel.into());
}
Expand Down Expand Up @@ -130,7 +127,6 @@ pub fn assert_owned_by_one(account: &AccountInfo, owners: Vec<&Pubkey>) -> Resul
Err(HydraError::IncorrectOwner.into())
}


#[cfg(test)]
mod tests {
// Note this useful idiom: importing names from outer (for mod tests) scope.
Expand All @@ -143,7 +139,7 @@ mod tests {
let owner2 = Pubkey::new_unique();
let ad = Pubkey::new_unique();
let actual_owner = Pubkey::new_unique();
let lam= &mut 10000;
let lam = &mut 10000;
let a = AccountInfo::new(&ad, false, false, lam, &mut [0; 0], &actual_owner, false, 0);

let e = assert_owned_by_one(&a, vec![&owner, &owner2, &owner1]);
Expand All @@ -153,8 +149,5 @@ mod tests {
let e = assert_owned_by_one(&a, vec![&owner, &actual_owner, &owner1]);

assert_eq!(e.is_ok(), true);

}


}

0 comments on commit c873a99

Please sign in to comment.