Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanphan committed May 8, 2024
2 parents 204e2f1 + e2b10c5 commit 64bc55b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "mpl-core"
description = "A flexible digital asset standard for Solana"
repository = "https://github.com/metaplex-foundation/mpl-core"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
readme = "README.md"
license-file = "../../LICENSE"
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/src/hooked/advanced_types.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/src/hooked/asset.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(feature = "anchor")]
use anchor_lang::prelude::AnchorSerialize;
#[cfg(not(feature = "anchor"))]
use borsh::BorshSerialize;

use crate::{
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/src/hooked/collection.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(feature = "anchor")]
use anchor_lang::prelude::AnchorSerialize;
#[cfg(not(feature = "anchor"))]
use borsh::BorshSerialize;

use crate::{
Expand Down
11 changes: 8 additions & 3 deletions clients/rust/src/hooked/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -110,15 +115,15 @@ pub fn load_key(account: &AccountInfo, offset: usize) -> Result<Key, std::io::Er
}

/// A trait for generic blobs of data that have size.
pub trait DataBlob: BorshSerialize + BorshDeserialize {
pub trait DataBlob: CrateSerialize + CrateDeserialize {
/// Get the size of an empty instance of the data blob.
fn get_initial_size() -> usize;
/// Get the current size of the data blob.
fn get_size(&self) -> usize;
}

/// 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;

Expand Down
7 changes: 5 additions & 2 deletions clients/rust/src/hooked/plugin.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -17,7 +20,7 @@ use crate::{
};

/// Fetch the plugin from the registry.
pub fn fetch_plugin<T: DataBlob + SolanaAccount, U: BorshDeserialize>(
pub fn fetch_plugin<T: DataBlob + SolanaAccount, U: CrateDeserialize>(
account: &AccountInfo,
plugin_type: PluginType,
) -> Result<(PluginAuthority, U, usize), std::io::Error> {
Expand Down
3 changes: 3 additions & 0 deletions clients/rust/src/indexable_asset.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 64bc55b

Please sign in to comment.