Created
December 18, 2024 16:52
-
-
Save mgild/8a6a31999c7baf9d921c4a5181d8d05b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone)] | |
pub struct LutProgram; | |
impl anchor_lang::Id for LutProgram { | |
fn id() -> Pubkey { | |
address_lookup_table::program::ID | |
} | |
} | |
#[derive(Clone, shrinkwraprs::Shrinkwrap)] | |
pub struct AddressLookupTable<'info>(pub solana_program::address_lookup_table::state::AddressLookupTable<'info>); | |
impl AccountSerialize for AddressLookupTable<'_> {} | |
impl<'info> AccountDeserialize for AddressLookupTable<'info> { | |
fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self> { | |
// Deserialize into the temporary struct | |
let table = SolanaAddressLookupTable::deserialize(buf) | |
.map_err(|_| ProgramError::InvalidAccountData)?; | |
// Construct a new AddressLookupTable with a lifetime tied to 'info | |
let new_table = SolanaAddressLookupTable { | |
meta: table.meta, | |
addresses: std::borrow::Cow::Owned(table.addresses.into_owned()), | |
}; | |
Ok(AddressLookupTable(new_table)) | |
} | |
} | |
impl Owner for AddressLookupTable<'_> { | |
fn owner() -> Pubkey { | |
address_lookup_table::program::ID | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment