|
@@ -1,6 +1,6 @@
|
|
use crate::error::ErrorCode;
|
|
use crate::error::ErrorCode;
|
|
use crate::{
|
|
use crate::{
|
|
- AccountDeserialize, AccountSerialize, Accounts, AccountsExit, CpiAccount, ToAccountInfo,
|
|
|
|
|
|
+ AccountDeserialize, AccountSerialize, Accounts, AccountsExit, CpiAccount, Key, ToAccountInfo,
|
|
ToAccountInfos, ToAccountMetas,
|
|
ToAccountInfos, ToAccountMetas,
|
|
};
|
|
};
|
|
use solana_program::account_info::AccountInfo;
|
|
use solana_program::account_info::AccountInfo;
|
|
@@ -109,6 +109,14 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> ToAccountInfo<'inf
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<AccountInfo<'info>>
|
|
|
|
+ for ProgramState<'info, T>
|
|
|
|
+{
|
|
|
|
+ fn as_ref(&self) -> &AccountInfo<'info> {
|
|
|
|
+ &self.inner.info
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for ProgramState<'a, T> {
|
|
impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for ProgramState<'a, T> {
|
|
type Target = T;
|
|
type Target = T;
|
|
|
|
|
|
@@ -151,3 +159,9 @@ pub fn address(program_id: &Pubkey) -> Pubkey {
|
|
let owner = program_id;
|
|
let owner = program_id;
|
|
Pubkey::create_with_seed(&base, seed, owner).unwrap()
|
|
Pubkey::create_with_seed(&base, seed, owner).unwrap()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+impl<'info, T: AccountSerialize + AccountDeserialize + Clone> Key for ProgramState<'info, T> {
|
|
|
|
+ fn key(&self) -> Pubkey {
|
|
|
|
+ *self.inner.info.key
|
|
|
|
+ }
|
|
|
|
+}
|