diff --git a/clients/rust/src/generated/types/add_blocker.rs b/clients/rust/src/generated/types/add_blocker.rs index a9c34951..ec184a62 100644 --- a/clients/rust/src/generated/types/add_blocker.rs +++ b/clients/rust/src/generated/types/add_blocker.rs @@ -5,9 +5,13 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use borsh::BorshDeserialize; -use borsh::BorshSerialize; +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct AddBlocker {} diff --git a/clients/rust/src/generated/types/immutable_metadata.rs b/clients/rust/src/generated/types/immutable_metadata.rs index 4f0af1e8..9607042e 100644 --- a/clients/rust/src/generated/types/immutable_metadata.rs +++ b/clients/rust/src/generated/types/immutable_metadata.rs @@ -5,9 +5,13 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -use borsh::BorshDeserialize; -use borsh::BorshSerialize; +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize, BorshSerialize}; -#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))] +#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct ImmutableMetadata {} diff --git a/clients/rust/src/hooked/advanced_types.rs b/clients/rust/src/hooked/advanced_types.rs index eb3ec77e..9d08c525 100644 --- a/clients/rust/src/hooked/advanced_types.rs +++ b/clients/rust/src/hooked/advanced_types.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "anchor")] +use anchor_lang::prelude::AnchorDeserialize; +#[cfg(not(feature = "anchor"))] use borsh::BorshDeserialize; use solana_program::pubkey::Pubkey; use std::{cmp::Ordering, io::ErrorKind}; diff --git a/clients/rust/src/hooked/asset.rs b/clients/rust/src/hooked/asset.rs index 17d695b9..3b72f45a 100644 --- a/clients/rust/src/hooked/asset.rs +++ b/clients/rust/src/hooked/asset.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "anchor")] +use anchor_lang::prelude::AnchorSerialize; +#[cfg(not(feature = "anchor"))] use borsh::BorshSerialize; use crate::{ diff --git a/clients/rust/src/hooked/collection.rs b/clients/rust/src/hooked/collection.rs index 5aa9e51a..82ca0877 100644 --- a/clients/rust/src/hooked/collection.rs +++ b/clients/rust/src/hooked/collection.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "anchor")] +use anchor_lang::prelude::AnchorSerialize; +#[cfg(not(feature = "anchor"))] use borsh::BorshSerialize; use crate::{ diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs index ecf95a51..aa5e2a6a 100644 --- a/clients/rust/src/hooked/mod.rs +++ b/clients/rust/src/hooked/mod.rs @@ -10,7 +10,12 @@ pub use asset::*; pub mod collection; pub use collection::*; -use borsh::{BorshDeserialize, BorshSerialize}; +#[cfg(feature = "anchor")] +use anchor_lang::prelude::{ + AnchorDeserialize as CrateDeserialize, AnchorSerialize as CrateSerialize, +}; +#[cfg(not(feature = "anchor"))] +use borsh::{BorshDeserialize as CrateDeserialize, BorshSerialize as CrateSerialize}; use num_traits::FromPrimitive; use std::{cmp::Ordering, mem::size_of}; @@ -110,7 +115,7 @@ pub fn load_key(account: &AccountInfo, offset: usize) -> Result usize; /// Get the current size of the data blob. @@ -118,7 +123,7 @@ pub trait DataBlob: BorshSerialize + BorshDeserialize { } /// A trait for Solana accounts. -pub trait SolanaAccount: BorshSerialize + BorshDeserialize { +pub trait SolanaAccount: CrateSerialize + CrateDeserialize { /// Get the discriminator key for the account. fn key() -> Key; diff --git a/clients/rust/src/hooked/plugin.rs b/clients/rust/src/hooked/plugin.rs index 6725a30f..a2ed5bcd 100644 --- a/clients/rust/src/hooked/plugin.rs +++ b/clients/rust/src/hooked/plugin.rs @@ -1,4 +1,7 @@ -use borsh::BorshDeserialize; +#[cfg(feature = "anchor")] +use anchor_lang::prelude::AnchorDeserialize as CrateDeserialize; +#[cfg(not(feature = "anchor"))] +use borsh::BorshDeserialize as CrateDeserialize; use num_traits::FromPrimitive; use solana_program::account_info::AccountInfo; @@ -14,7 +17,7 @@ use crate::{ }; /// Fetch the plugin from the registry. -pub fn fetch_plugin( +pub fn fetch_plugin( account: &AccountInfo, plugin_type: PluginType, ) -> Result<(PluginAuthority, U, usize), std::io::Error> { diff --git a/clients/rust/src/indexable_asset.rs b/clients/rust/src/indexable_asset.rs index bd3c0147..38f11bd4 100644 --- a/clients/rust/src/indexable_asset.rs +++ b/clients/rust/src/indexable_asset.rs @@ -1,4 +1,7 @@ +#[cfg(feature = "anchor")] +use anchor_lang::prelude::AnchorDeserialize; use base64::prelude::*; +#[cfg(not(feature = "anchor"))] use borsh::BorshDeserialize; use num_traits::FromPrimitive; use solana_program::pubkey::Pubkey;