Skip to content

Commit

Permalink
Merge pull request #111 from metaplex-foundation/feat/anchor-types
Browse files Browse the repository at this point in the history
Adding Anchor types from the Kinobi 0.18.7 preview
  • Loading branch information
blockiosaurus authored May 8, 2024
2 parents 38774bf + 708976f commit 6432bc5
Show file tree
Hide file tree
Showing 57 changed files with 1,112 additions and 646 deletions.
1,152 changes: 699 additions & 453 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ crate-type = ["cdylib", "lib"]
[features]
test-sbf = []
serde = ["dep:serde", "dep:serde_with"]
anchor = ["dep:anchor-lang"]

[dependencies]
borsh = "^0.10"
Expand All @@ -23,6 +24,7 @@ serde_with = { version = "^3.0", optional = true }
solana-program = "> 1.14, < 1.18"
thiserror = "^1.0"
base64 = "0.22.0"
anchor-lang = { version = "0.30.0", optional = true }

[dev-dependencies]
assert_matches = "1.5.0"
Expand Down
10 changes: 7 additions & 3 deletions clients/rust/src/generated/accounts/base_asset_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
use crate::generated::types::Key;
use crate::generated::types::UpdateAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::pubkey::Pubkey;

#[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 BaseAssetV1 {
pub key: Key,
#[cfg_attr(
Expand Down
10 changes: 7 additions & 3 deletions clients/rust/src/generated/accounts/base_collection_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
//!
use crate::generated::types::Key;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::pubkey::Pubkey;

#[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 BaseCollectionV1 {
pub key: Key,
#[cfg_attr(
Expand Down
10 changes: 7 additions & 3 deletions clients/rust/src/generated/accounts/hashed_asset_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
//!
use crate::generated::types::Key;
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 HashedAssetV1 {
pub key: Key,
pub hash: [u8; 32],
Expand Down
10 changes: 7 additions & 3 deletions clients/rust/src/generated/accounts/plugin_header_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
//!
use crate::generated::types::Key;
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 PluginHeaderV1 {
pub key: Key,
pub plugin_registry_offset: u64,
Expand Down
10 changes: 7 additions & 3 deletions clients/rust/src/generated/accounts/plugin_registry_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
use crate::generated::types::ExternalPluginRecord;
use crate::generated::types::Key;
use crate::generated::types::RegistryRecord;
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 PluginRegistryV1 {
pub key: Key,
pub registry: Vec<RegistryRecord>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use crate::generated::types::Plugin;
use crate::generated::types::PluginAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct AddCollectionPluginV1 {
Expand Down Expand Up @@ -85,7 +87,8 @@ impl AddCollectionPluginV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct AddCollectionPluginV1InstructionData {
discriminator: u8,
}
Expand All @@ -96,8 +99,10 @@ impl AddCollectionPluginV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AddCollectionPluginV1InstructionArgs {
pub plugin: Plugin,
pub init_authority: Option<PluginAuthority>,
Expand Down
13 changes: 9 additions & 4 deletions clients/rust/src/generated/instructions/add_plugin_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use crate::generated::types::Plugin;
use crate::generated::types::PluginAuthority;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct AddPluginV1 {
Expand Down Expand Up @@ -94,7 +96,8 @@ impl AddPluginV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct AddPluginV1InstructionData {
discriminator: u8,
}
Expand All @@ -105,8 +108,10 @@ impl AddPluginV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AddPluginV1InstructionArgs {
pub plugin: Plugin,
pub init_authority: Option<PluginAuthority>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use crate::generated::types::PluginAuthority;
use crate::generated::types::PluginType;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct ApproveCollectionPluginAuthorityV1 {
Expand Down Expand Up @@ -85,7 +87,8 @@ impl ApproveCollectionPluginAuthorityV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct ApproveCollectionPluginAuthorityV1InstructionData {
discriminator: u8,
}
Expand All @@ -96,8 +99,10 @@ impl ApproveCollectionPluginAuthorityV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ApproveCollectionPluginAuthorityV1InstructionArgs {
pub plugin_type: PluginType,
pub new_authority: PluginAuthority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use crate::generated::types::PluginAuthority;
use crate::generated::types::PluginType;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct ApprovePluginAuthorityV1 {
Expand Down Expand Up @@ -96,7 +98,8 @@ impl ApprovePluginAuthorityV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct ApprovePluginAuthorityV1InstructionData {
discriminator: u8,
}
Expand All @@ -107,8 +110,10 @@ impl ApprovePluginAuthorityV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ApprovePluginAuthorityV1InstructionArgs {
pub plugin_type: PluginType,
pub new_authority: PluginAuthority,
Expand Down
13 changes: 9 additions & 4 deletions clients/rust/src/generated/instructions/burn_collection_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
//!
use crate::generated::types::CompressionProof;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct BurnCollectionV1 {
Expand Down Expand Up @@ -76,7 +78,8 @@ impl BurnCollectionV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct BurnCollectionV1InstructionData {
discriminator: u8,
}
Expand All @@ -87,8 +90,10 @@ impl BurnCollectionV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BurnCollectionV1InstructionArgs {
pub compression_proof: Option<CompressionProof>,
}
Expand Down
13 changes: 9 additions & 4 deletions clients/rust/src/generated/instructions/burn_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
//!
use crate::generated::types::CompressionProof;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[cfg(feature = "anchor")]
use anchor_lang::prelude::{AnchorDeserialize, AnchorSerialize};
#[cfg(not(feature = "anchor"))]
use borsh::{BorshDeserialize, BorshSerialize};

/// Accounts.
pub struct BurnV1 {
Expand Down Expand Up @@ -100,7 +102,8 @@ impl BurnV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct BurnV1InstructionData {
discriminator: u8,
}
Expand All @@ -111,8 +114,10 @@ impl BurnV1InstructionData {
}
}

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct BurnV1InstructionArgs {
pub compression_proof: Option<CompressionProof>,
}
Expand Down
9 changes: 6 additions & 3 deletions clients/rust/src/generated/instructions/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
//! [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};

/// Accounts.
pub struct Collect {
Expand Down Expand Up @@ -45,7 +47,8 @@ impl Collect {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct CollectInstructionData {
discriminator: u8,
}
Expand Down
9 changes: 6 additions & 3 deletions clients/rust/src/generated/instructions/compress_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
//! [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};

/// Accounts.
pub struct CompressV1 {
Expand Down Expand Up @@ -86,7 +88,8 @@ impl CompressV1 {
}
}

#[derive(BorshDeserialize, BorshSerialize)]
#[cfg_attr(not(feature = "anchor"), derive(BorshSerialize, BorshDeserialize))]
#[cfg_attr(feature = "anchor", derive(AnchorSerialize, AnchorDeserialize))]
pub struct CompressV1InstructionData {
discriminator: u8,
}
Expand Down
Loading

0 comments on commit 6432bc5

Please sign in to comment.