solitaire: Wrap for Info, auto Wrap for data_wrapper()
Change-Id: I5cc0ba7870e140a2acf77b8fc8814ee953f56b51
This commit is contained in:
parent
9d35ec242e
commit
60a1acf351
|
@ -23,6 +23,7 @@ use borsh::BorshSerialize;
|
||||||
|
|
||||||
use solitaire::{
|
use solitaire::{
|
||||||
AccountState,
|
AccountState,
|
||||||
|
Info,
|
||||||
Sysvar,
|
Sysvar,
|
||||||
};
|
};
|
||||||
pub use solitaire::{
|
pub use solitaire::{
|
||||||
|
@ -172,6 +173,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'b> Wrap for Info<'b> {
|
||||||
|
fn wrap(a: &AccEntry) -> StdResult<Vec<AccountMeta>, ErrBox> {
|
||||||
|
match a {
|
||||||
|
AccEntry::UnprivilegedRO(k) => Ok(vec![AccountMeta::new_readonly(k.clone(), false)]),
|
||||||
|
AccEntry::Unprivileged(k) => Ok(vec![AccountMeta::new(k.clone(), false)]),
|
||||||
|
_other => Err(format!(
|
||||||
|
"{} must be passed as Unprivileged or UnprivilegedRO",
|
||||||
|
std::any::type_name::<Self>()
|
||||||
|
)
|
||||||
|
.into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Trait used on client side to easily validate a program accounts + ix_data for a bare Solana call
|
/// Trait used on client side to easily validate a program accounts + ix_data for a bare Solana call
|
||||||
pub trait ToInstruction {
|
pub trait ToInstruction {
|
||||||
fn to_ix(
|
fn to_ix(
|
||||||
|
|
|
@ -144,6 +144,16 @@ macro_rules! data_wrapper {
|
||||||
return self.1.owner();
|
return self.1.owner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
impl<'b> solitaire_client::Wrap for $name<'b> {
|
||||||
|
fn wrap(
|
||||||
|
a: &solitaire_client::AccEntry,
|
||||||
|
) -> std::result::Result<Vec<solitaire_client::AccountMeta>, solitaire_client::ErrBox>
|
||||||
|
{
|
||||||
|
solitaire::Data::<'b, $embed, { $state }>::wrap(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue