generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection doesn't implement plugin_list or plugin_header #40
Comments
to get this working in my implementation I just copied the impl from Asset into my program for Collection: use anchor_lang::AnchorSerialize;
use mpl_core::{
accounts::{BaseCollectionV1, PluginHeaderV1, PluginRegistryV1},
registry_records_to_plugin_list, PluginsList,
};
pub struct Collection {
pub base: BaseCollectionV1,
pub plugin_list: PluginsList,
pub plugin_header: PluginHeaderV1,
}
impl Collection {
pub fn deserialize_asset(data: &[u8]) -> Result<Collection, std::io::Error> {
let base = BaseCollectionV1::from_bytes(data)?;
let base_data = base.try_to_vec()?;
let (plugin_header, plugin_list) = if base_data.len() != data.len() {
let plugin_header = PluginHeaderV1::from_bytes(&data[base_data.len()..])?;
let plugin_registry = PluginRegistryV1::from_bytes(
&data[plugin_header.plugin_registry_offset as usize..],
)?;
let plugin_list = registry_records_to_plugin_list(&plugin_registry.registry, data)?;
(Some(plugin_header), Some(plugin_list))
} else {
(None, None)
};
Ok(Self {
base,
plugin_list: plugin_list.unwrap_or_default(),
plugin_header: plugin_header.unwrap(),
})
}
#[inline(always)]
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
Self::deserialize_asset(data)
}
}
impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Collection {
type Error = std::io::Error;
fn try_from(
account_info: &solana_program::account_info::AccountInfo<'a>,
) -> Result<Self, Self::Error> {
let data: &[u8] = &(*account_info.data).borrow();
Self::deserialize_asset(data)
}
} |
This should all be supported as of 012d081#diff-414d3e177a37705c274f497133d951f14ec67efa2d6350e7e4f2e7f936bcc4cb However, I now see that it looks like we need to add support for external plugin adapters on collections |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mpl-core = "0.3.0"
Assets can be deserialised, Collections can not. I am only able to deserialise into a BaseCollection which doesn't contain the plugin_list so I am unable to see plugins applied to the collection in my program.
mpl-core/clients/rust/src/hooked/advanced_types.rs
Lines 132 to 144 in 84de75a
The text was updated successfully, but these errors were encountered: