Skip to content

Commit

Permalink
fix txn parser
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Jun 14, 2024
1 parent 53e7779 commit 5e06ba6
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions transaction-status/src/parse_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,29 +298,25 @@ pub fn parse_stake(
})
}
StakeInstruction::MoveStake(lamports) => {
check_num_stake_accounts(&instruction.accounts, 5)?;
check_num_stake_accounts(&instruction.accounts, 3)?;
Ok(ParsedInstructionEnum {
instruction_type: "moveStake".to_string(),
info: json!({
"source": account_keys[instruction.accounts[0] as usize].to_string(),
"destination": account_keys[instruction.accounts[1] as usize].to_string(),
"clockSysvar": account_keys[instruction.accounts[2] as usize].to_string(),
"stakeHistorySysvar": account_keys[instruction.accounts[3] as usize].to_string(),
"stakeAuthority": account_keys[instruction.accounts[4] as usize].to_string(),
"stakeAuthority": account_keys[instruction.accounts[2] as usize].to_string(),
"lamports": lamports,
}),
})
}
StakeInstruction::MoveLamports(lamports) => {
check_num_stake_accounts(&instruction.accounts, 5)?;
check_num_stake_accounts(&instruction.accounts, 3)?;
Ok(ParsedInstructionEnum {
instruction_type: "moveLamports".to_string(),
info: json!({
"source": account_keys[instruction.accounts[0] as usize].to_string(),
"destination": account_keys[instruction.accounts[1] as usize].to_string(),
"clockSysvar": account_keys[instruction.accounts[2] as usize].to_string(),
"stakeHistorySysvar": account_keys[instruction.accounts[3] as usize].to_string(),
"stakeAuthority": account_keys[instruction.accounts[4] as usize].to_string(),
"stakeAuthority": account_keys[instruction.accounts[2] as usize].to_string(),
"lamports": lamports,
}),
})
Expand Down Expand Up @@ -1219,16 +1215,14 @@ mod test {
info: json!({
"source": source_stake_pubkey.to_string(),
"destination": destination_stake_pubkey.to_string(),
"clockSysvar": sysvar::clock::ID.to_string(),
"stakeHistorySysvar": sysvar::stake_history::ID.to_string(),
"stakeAuthority": authorized_pubkey.to_string(),
"lamports": lamports,
}),
}
);
assert!(parse_stake(
&message.instructions[0],
&AccountKeys::new(&message.account_keys[0..4], None)
&AccountKeys::new(&message.account_keys[0..2], None)
)
.is_err());
let keys = message.account_keys.clone();
Expand Down

0 comments on commit 5e06ba6

Please sign in to comment.