From CpiAccount for ProgramAccount
This commit is contained in:
parent
e187cb5cbb
commit
fa67756774
|
@ -10,7 +10,7 @@ mod puppet_master {
|
|||
pub fn pull_strings(ctx: Context<PullStrings>, data: u64) -> ProgramResult {
|
||||
let cpi_program = ctx.accounts.puppet_program.clone();
|
||||
let cpi_accounts = SetData {
|
||||
puppet: ctx.accounts.puppet.clone(),
|
||||
puppet: ctx.accounts.puppet.clone().into(),
|
||||
};
|
||||
let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);
|
||||
puppet::cpi::set_data(cpi_ctx, data)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
AccountDeserialize, AccountSerialize, Accounts, AccountsInit, ToAccountInfo, ToAccountInfos,
|
||||
ToAccountMetas,
|
||||
AccountDeserialize, AccountSerialize, Accounts, AccountsInit, CpiAccount, ToAccountInfo,
|
||||
ToAccountInfos, ToAccountMetas,
|
||||
};
|
||||
use solana_sdk::account_info::AccountInfo;
|
||||
use solana_sdk::instruction::AccountMeta;
|
||||
|
@ -129,3 +129,15 @@ impl<'a, T: AccountSerialize + AccountDeserialize + Clone> DerefMut for ProgramA
|
|||
&mut self.account
|
||||
}
|
||||
}
|
||||
|
||||
impl<'info, T> From<CpiAccount<'info, T>> for ProgramAccount<'info, T>
|
||||
where
|
||||
T: AccountSerialize + AccountDeserialize + Clone,
|
||||
{
|
||||
fn from(a: CpiAccount<'info, T>) -> Self {
|
||||
Self {
|
||||
info: a.to_account_info(),
|
||||
account: Deref::deref(&a).clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue