Move Feature struct to solana-program

This commit is contained in:
Michael Vines
2020-10-30 13:40:55 -07:00
parent 8415c22b59
commit 4b65e32f22
10 changed files with 140 additions and 105 deletions

View File

@ -15,7 +15,6 @@ use solana_sdk::{
feature_set::FEATURE_NAMES,
message::Message,
pubkey::Pubkey,
system_instruction,
transaction::Transaction,
};
use std::{collections::HashMap, fmt, sync::Arc};
@ -281,7 +280,7 @@ fn process_status(
let feature_id = &feature_ids[i];
let feature_name = FEATURE_NAMES.get(feature_id).unwrap();
if let Some(account) = account {
if let Some(feature) = Feature::from_account(&account) {
if let Some(feature) = feature::from_account(&account) {
let feature_status = match feature.activated_at {
None => CliFeatureStatus::Pending,
Some(activation_slot) => CliFeatureStatus::Active(activation_slot),
@ -322,7 +321,7 @@ fn process_activate(
.next()
.unwrap();
if let Some(account) = account {
if Feature::from_account(&account).is_some() {
if feature::from_account(&account).is_some() {
return Err(format!("{} has already been activated", feature_id).into());
}
}
@ -342,15 +341,11 @@ fn process_activate(
&config.signers[0].pubkey(),
|lamports| {
Message::new(
&[
system_instruction::transfer(
&config.signers[0].pubkey(),
&feature_id,
lamports,
),
system_instruction::allocate(&feature_id, Feature::size_of() as u64),
system_instruction::assign(&feature_id, &feature::id()),
],
&feature::activate_with_lamports(
&feature_id,
&config.signers[0].pubkey(),
lamports,
),
Some(&config.signers[0].pubkey()),
)
},