account.data -> data() (#15778)
This commit is contained in:
committed by
GitHub
parent
8a3135d17b
commit
52e54e1100
@@ -8,8 +8,9 @@ use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use serde_derive::Serialize;
|
||||
use solana_metrics::inc_new_counter_info;
|
||||
use solana_sdk::{
|
||||
decode_error::DecodeError, instruction::InstructionError, keyed_account::KeyedAccount,
|
||||
process_instruction::InvokeContext, program_utils::limited_deserialize, pubkey::Pubkey,
|
||||
account::ReadableAccount, decode_error::DecodeError, instruction::InstructionError,
|
||||
keyed_account::KeyedAccount, process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize, pubkey::Pubkey,
|
||||
};
|
||||
use std::cmp;
|
||||
use thiserror::Error;
|
||||
@@ -188,7 +189,7 @@ impl ExchangeProcessor {
|
||||
error!("Not enough accounts");
|
||||
return Err(InstructionError::InvalidArgument);
|
||||
}
|
||||
Self::is_account_unallocated(&keyed_accounts[NEW_ACCOUNT_INDEX].try_account_ref()?.data)?;
|
||||
Self::is_account_unallocated(&keyed_accounts[NEW_ACCOUNT_INDEX].try_account_ref()?.data())?;
|
||||
Self::serialize(
|
||||
&ExchangeState::Account(
|
||||
TokenAccountInfo::default()
|
||||
@@ -216,13 +217,13 @@ impl ExchangeProcessor {
|
||||
}
|
||||
|
||||
let mut to_account =
|
||||
Self::deserialize_account(&keyed_accounts[TO_ACCOUNT_INDEX].try_account_ref()?.data)?;
|
||||
Self::deserialize_account(&keyed_accounts[TO_ACCOUNT_INDEX].try_account_ref()?.data())?;
|
||||
|
||||
if &faucet::id() == keyed_accounts[FROM_ACCOUNT_INDEX].unsigned_key() {
|
||||
to_account.tokens[token] += tokens;
|
||||
} else {
|
||||
let state: ExchangeState =
|
||||
bincode::deserialize(&keyed_accounts[FROM_ACCOUNT_INDEX].try_account_ref()?.data)
|
||||
bincode::deserialize(&keyed_accounts[FROM_ACCOUNT_INDEX].try_account_ref()?.data())
|
||||
.map_err(Self::map_to_invalid_arg)?;
|
||||
match state {
|
||||
ExchangeState::Account(mut from_account) => {
|
||||
@@ -302,10 +303,11 @@ impl ExchangeProcessor {
|
||||
return Err(InstructionError::InvalidArgument);
|
||||
}
|
||||
|
||||
Self::is_account_unallocated(&keyed_accounts[ORDER_INDEX].try_account_ref()?.data)?;
|
||||
Self::is_account_unallocated(&keyed_accounts[ORDER_INDEX].try_account_ref()?.data())?;
|
||||
|
||||
let mut account =
|
||||
Self::deserialize_account(&keyed_accounts[ACCOUNT_INDEX].try_account_ref_mut()?.data)?;
|
||||
let mut account = Self::deserialize_account(
|
||||
&keyed_accounts[ACCOUNT_INDEX].try_account_ref_mut()?.data(),
|
||||
)?;
|
||||
|
||||
if &account.owner != keyed_accounts[OWNER_INDEX].unsigned_key() {
|
||||
error!("Signer does not own account");
|
||||
@@ -355,7 +357,8 @@ impl ExchangeProcessor {
|
||||
return Err(InstructionError::InvalidArgument);
|
||||
}
|
||||
|
||||
let order = Self::deserialize_order(&keyed_accounts[ORDER_INDEX].try_account_ref()?.data)?;
|
||||
let order =
|
||||
Self::deserialize_order(&keyed_accounts[ORDER_INDEX].try_account_ref()?.data())?;
|
||||
|
||||
if &order.owner != keyed_accounts[OWNER_INDEX].unsigned_key() {
|
||||
error!("Signer does not own order");
|
||||
@@ -389,11 +392,13 @@ impl ExchangeProcessor {
|
||||
}
|
||||
|
||||
let mut to_order =
|
||||
Self::deserialize_order(&keyed_accounts[TO_ORDER_INDEX].try_account_ref()?.data)?;
|
||||
Self::deserialize_order(&keyed_accounts[TO_ORDER_INDEX].try_account_ref()?.data())?;
|
||||
let mut from_order =
|
||||
Self::deserialize_order(&keyed_accounts[FROM_ORDER_INDEX].try_account_ref()?.data)?;
|
||||
Self::deserialize_order(&keyed_accounts[FROM_ORDER_INDEX].try_account_ref()?.data())?;
|
||||
let mut profit_account = Self::deserialize_account(
|
||||
&keyed_accounts[PROFIT_ACCOUNT_INDEX].try_account_ref()?.data,
|
||||
&keyed_accounts[PROFIT_ACCOUNT_INDEX]
|
||||
.try_account_ref()?
|
||||
.data(),
|
||||
)?;
|
||||
|
||||
if to_order.side != OrderSide::Ask {
|
||||
|
Reference in New Issue
Block a user