Skip to content

Commit

Permalink
fixing PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
0xripleys committed Nov 14, 2023
1 parent 6753e68 commit cf694f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ pub mod solend_market_owner {
solana_program::declare_id!("5pHk2TmnqQzRF9L6egy5FfiyBgS7G9cMZ5RFaJAvghzw");
}

/// account that can resize reserves
pub mod resizer {
solana_program::declare_id!("7v44zJeSHZdXS2djiLuCXiZt23ziMhURaPxbQ2MJ7cUh");
}

/// Processes an instruction
pub fn process_instruction(
program_id: &Pubkey,
Expand Down Expand Up @@ -2933,12 +2938,17 @@ pub fn process_resize_reserve(_program_id: &Pubkey, accounts: &[AccountInfo]) ->
let signer_info = next_account_info(account_info_iter)?;
let system_program_info = next_account_info(account_info_iter)?;

if *signer_info.key != resizer::id() || !signer_info.is_signer {
msg!("Resizer pubkey must be a signer");
return Err(LendingError::InvalidSigner.into());
}

let data: Vec<u8> = reserve_info.data.clone().borrow().to_vec();

assert!(
data.len() == 619,
"initial data doesn't match expected length!"
);
if data.len() != 619 {
msg!("initial data doesn't match expected length!");
return Err(LendingError::InvalidAccountInput.into());
}

let new_size = Reserve::LEN;
let rent = Rent::get()?;
Expand All @@ -2961,15 +2971,15 @@ pub fn process_resize_reserve(_program_id: &Pubkey, accounts: &[AccountInfo]) ->
})?;

let new_data: Vec<u8> = reserve_info.data.clone().borrow().to_vec();
assert!(
new_data.len() == 1219,
"new data doesn't match expected length!"
);
if new_data.len() != 1219 {
msg!("new data doesn't match expected length!");
return Err(LendingError::InvalidAccountInput.into());
}

assert!(
data[..] == new_data[0..619],
"new data's first 619 bytes don't match old data!"
);
if data[..] != new_data[0..619] {
msg!("new data's first 619 bytes don't match old data!");
return Err(LendingError::InvalidAccountInput.into());
}

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion token-lending/sdk/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub enum LendingInstruction {
/// Accounts expected by this instruction:
/// 0. `[]` Reserve account.
/// 1. `[signer]` fee payer.
/// 3. '[]' System Program
/// 2. '[]' System Program
ResizeReserve,
}

Expand Down

0 comments on commit cf694f0

Please sign in to comment.