solitaire: remove unused deps

This commit is contained in:
Reisen 2022-06-24 03:15:13 +00:00 committed by Csongor Kiss
parent cdc6edd425
commit 9aad49d631
4 changed files with 2 additions and 95 deletions

View File

@ -126,10 +126,6 @@ impl<'a, 'b: 'a, 'c, T: DeserializePayload> Peel<'a, 'b, 'c> for PayloadMessage<
Ok(PayloadMessage(data, payload))
}
fn deps() -> Vec<Pubkey> {
Data::<'b, PostedVAAData, { AccountState::Initialized }>::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
Data::persist(&self.0, program_id)
}

View File

@ -7,11 +7,7 @@
use borsh::BorshDeserialize;
use solana_program::{
pubkey::Pubkey,
system_program,
sysvar::{
self,
Sysvar as SolanaSysvar,
},
sysvar::Sysvar as SolanaSysvar,
};
use crate::{
@ -34,8 +30,6 @@ pub trait Peel<'a, 'b: 'a, 'c> {
where
Self: Sized;
fn deps() -> Vec<Pubkey>;
fn persist(&self, program_id: &Pubkey) -> Result<()>;
}
@ -54,10 +48,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for Option<T> {
}
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
if let Some(s) = self.as_ref() {
T::persist(s, program_id)
@ -84,10 +74,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>, const SEED: &'static str> Peel<'a, 'b,
}
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
T::persist(self, program_id)
}
@ -105,10 +91,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for Mut<T> {
}
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
T::persist(self, program_id)
}
@ -120,10 +102,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for MaybeMut<T> {
T::peel(ctx).map(|v| MaybeMut(v))
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
T::persist(self, program_id)
}
@ -138,10 +116,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for Signer<T> {
}
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
T::persist(self, program_id)
}
@ -156,10 +130,6 @@ impl<'a, 'b: 'a, 'c, T: Peel<'a, 'b, 'c>> Peel<'a, 'b, 'c> for System<T> {
}
}
fn deps() -> Vec<Pubkey> {
T::deps()
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
T::persist(self, program_id)
}
@ -180,10 +150,6 @@ where
}
}
fn deps() -> Vec<Pubkey> {
vec![]
}
fn persist(&self, _program_id: &Pubkey) -> Result<()> {
Ok(())
}
@ -201,9 +167,7 @@ impl<'a, 'b: 'a, 'c> Peel<'a, 'b, 'c> for Info<'b> {
Ok(ctx.info().clone())
}
fn deps() -> Vec<Pubkey> {
vec![]
}
fn persist(&self, _program_id: &Pubkey) -> Result<()> {
Ok(())
}
@ -265,14 +229,6 @@ impl<
Ok(Data(Box::new(ctx.info().clone()), data))
}
fn deps() -> Vec<Pubkey> {
if IS_INITIALIZED == AccountState::Initialized {
return vec![];
}
vec![sysvar::rent::ID, system_program::ID]
}
fn persist(&self, program_id: &Pubkey) -> Result<()> {
// TODO: Introduce Mut<> to solve the check we really want to make here.
if self.0.owner != program_id {

View File

@ -91,7 +91,6 @@ pub fn derive_from_accounts(input: TokenStream) -> TokenStream {
let from_method = generate_fields(&name, &input.data);
let persist_method = generate_persist(&input.data);
let deps_method = generate_deps_fields(&input.data);
let expanded = quote! {
/// Macro generated implementation of FromAccounts by Solitaire.
impl #combined_impl_g solitaire::FromAccounts #peel_type_g for #name #type_g {
@ -106,10 +105,6 @@ pub fn derive_from_accounts(input: TokenStream) -> TokenStream {
Ok(v)
}
fn deps() -> Vec<solana_program::pubkey::Pubkey> {
#deps_method
}
fn persist(&self, program_id: &solana_program::pubkey::Pubkey) -> solitaire::Result<()> {
solitaire::Persist::persist(self, program_id)
}
@ -183,45 +178,6 @@ fn generate_fields(name: &syn::Ident, data: &Data) -> TokenStream2 {
}
}
/// This function does the heavy lifting of generating the field parsers.
fn generate_deps_fields(data: &Data) -> TokenStream2 {
match *data {
// We only care about structures.
Data::Struct(ref data) => {
// We want to inspect its fields.
match data.fields {
// For now, we only care about struct { a: T } forms, not struct(T);
Fields::Named(ref fields) => {
// For each field, generate an expression appends it deps
let recurse = fields.named.iter().map(|f| {
let ty = &f.ty;
quote! {
deps.append(&mut <#ty as Peel>::deps());
}
});
// Write out our iterator and return the filled structure.
quote! {
let mut deps = Vec::new();
#(#recurse;)*
deps
}
}
Fields::Unnamed(_) => {
unimplemented!()
}
Fields::Unit => {
unimplemented!()
}
}
}
Data::Enum(_) | Data::Union(_) => unimplemented!(),
}
}
/// This function does the heavy lifting of generating the field parsers.
fn generate_persist(data: &Data) -> TokenStream2 {
match *data {

View File

@ -26,7 +26,6 @@ pub fn generate_to_instruction(
let ty = &field.ty;
quote! {
deps.append(&mut <#ty as solitaire::Peel>::deps());
account_metas.append(&mut <#ty as solitaire_client::Wrap>::wrap(&self.#name)?);
if let Some(pair) = <#ty as solitaire_client::Wrap>::keypair(self.#name) {
signers.push(pair);