generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Rename AssetHeader to PluginHeader
- release/core@0.9.3
- release/core@0.9.2
- release/core@0.9.1
- release/core@0.9.0
- mpl-core-v0.4.1
- mpl-core-v0.4.0
- mpl-core-v0.3.0
- mpl-core-v0.2.0
- mpl-core-v0.1.0
- mpl-core@v0.8.1-beta.1
- mpl-core@v0.8.0
- mpl-core@v0.8.0-beta.1
- mpl-core@v0.8.0-alpha.2
- mpl-core@v0.8.0-alpha.1
- mpl-core@v0.7.2
- mpl-core@v0.7.1
- mpl-core@v0.7.0
- mpl-core@v0.6.1
- mpl-core@v0.6.0
- mpl-core@v0.5.1
- mpl-core@v0.5.0
- mpl-core@v0.4.4
- mpl-core@v0.4.3
- mpl-core@v0.4.2
- js@v1.2.0
- js@v1.1.2
- js@v1.1.1
- js@v1.1.0
- js@v1.1.0-alpha.1
- js@v1.1.0-alpha.0
- js@v1.0.2
- js@v1.0.1
- js@v1.0.0
- js@v0.4.7
- js@v0.4.6
- js@v0.4.5
- devnet-20240503
- core-mainnet-beta
- core-devnet
Showing
2 changed files
with
34 additions
and
24 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use borsh::{BorshDeserialize, BorshSerialize}; | ||
use solana_program::account_info::AccountInfo; | ||
use solana_program::entrypoint::ProgramResult; | ||
use solana_program::msg; | ||
use solana_program::program_error::ProgramError; | ||
|
||
use crate::error::MplAssetError; | ||
|
||
#[repr(C)] | ||
#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)] | ||
pub struct PluginHeader { | ||
pub version: u8, | ||
pub plugin_map_offset: usize, | ||
} | ||
|
||
impl PluginHeader { | ||
pub fn load(account: &AccountInfo) -> Result<Self, ProgramError> { | ||
let mut bytes: &[u8] = &(*account.data).borrow(); | ||
PluginHeader::deserialize(&mut bytes).map_err(|error| { | ||
msg!("Error: {}", error); | ||
MplAssetError::DeserializationError.into() | ||
}) | ||
} | ||
|
||
pub fn save(&self, account: &AccountInfo) -> ProgramResult { | ||
borsh::to_writer(&mut account.data.borrow_mut()[..], self).map_err(|error| { | ||
msg!("Error: {}", error); | ||
MplAssetError::SerializationError.into() | ||
}) | ||
} | ||
} |