Move KeyedAccount out of solana-program. Native programs are not supported by solana-program

This commit is contained in:
Michael Vines
2020-10-26 09:14:57 -07:00
parent 0475107654
commit 1b343665a1
35 changed files with 384 additions and 382 deletions

View File

@@ -4,9 +4,8 @@ use bincode::{deserialize, serialized_size};
use serde_derive::{Deserialize, Serialize};
use solana_config_program::{create_config_account, get_config_data, ConfigState};
use solana_sdk::{
account::{Account, KeyedAccount},
genesis_config::GenesisConfig,
instruction::InstructionError,
account::Account, genesis_config::GenesisConfig, instruction::InstructionError,
keyed_account::KeyedAccount,
};
// stake config ID

View File

@@ -6,14 +6,14 @@ use log::*;
use num_derive::{FromPrimitive, ToPrimitive};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::{get_signers, next_keyed_account, KeyedAccount},
clock::{Epoch, UnixTimestamp},
decode_error::DecodeError,
instruction::{AccountMeta, Instruction, InstructionError},
keyed_account::{from_keyed_account, get_signers, next_keyed_account, KeyedAccount},
program_utils::limited_deserialize,
pubkey::Pubkey,
system_instruction,
sysvar::{self, clock::Clock, rent::Rent, stake_history::StakeHistory, Sysvar},
sysvar::{self, clock::Clock, rent::Rent, stake_history::StakeHistory},
};
use thiserror::Error;
@@ -459,7 +459,7 @@ pub fn process_instruction(
StakeInstruction::Initialize(authorized, lockup) => me.initialize(
&authorized,
&lockup,
&Rent::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<Rent>(next_keyed_account(keyed_accounts)?)?,
),
StakeInstruction::Authorize(authorized_pubkey, stake_authorize) => {
me.authorize(&signers, &authorized_pubkey, stake_authorize)
@@ -479,8 +479,8 @@ pub fn process_instruction(
me.delegate(
&vote,
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<Clock>(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<StakeHistory>(next_keyed_account(keyed_accounts)?)?,
&config::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&signers,
)
@@ -493,8 +493,8 @@ pub fn process_instruction(
let source_stake = &next_keyed_account(keyed_accounts)?;
me.merge(
source_stake,
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<Clock>(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<StakeHistory>(next_keyed_account(keyed_accounts)?)?,
&signers,
)
}
@@ -504,14 +504,14 @@ pub fn process_instruction(
me.withdraw(
lamports,
to,
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&StakeHistory::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<Clock>(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<StakeHistory>(next_keyed_account(keyed_accounts)?)?,
next_keyed_account(keyed_accounts)?,
keyed_accounts.next(),
)
}
StakeInstruction::Deactivate => me.deactivate(
&Clock::from_keyed_account(next_keyed_account(keyed_accounts)?)?,
&from_keyed_account::<Clock>(next_keyed_account(keyed_accounts)?)?,
&signers,
),
@@ -523,7 +523,11 @@ pub fn process_instruction(
mod tests {
use super::*;
use bincode::serialize;
use solana_sdk::{account::Account, rent::Rent, sysvar::stake_history::StakeHistory};
use solana_sdk::{
account::Account,
rent::Rent,
sysvar::{stake_history::StakeHistory, Sysvar},
};
use std::cell::RefCell;
fn create_default_account() -> RefCell<Account> {

View File

@@ -10,10 +10,11 @@ use crate::{
};
use serde_derive::{Deserialize, Serialize};
use solana_sdk::{
account::{Account, KeyedAccount},
account::Account,
account_utils::{State, StateMut},
clock::{Clock, Epoch, UnixTimestamp},
instruction::InstructionError,
keyed_account::KeyedAccount,
pubkey::Pubkey,
rent::Rent,
stake_history::{StakeHistory, StakeHistoryEntry},