Skip to content

Commit

Permalink
fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagaprasadvr committed Dec 19, 2024
1 parent 8574dc8 commit 0572cc9
Show file tree
Hide file tree
Showing 82 changed files with 6,295 additions and 525 deletions.
27 changes: 27 additions & 0 deletions packages/renderers-rust/e2e/anchor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "codama-renderers-rust-e2e-anchor"
version = "0.0.0"
edition = "2021"

[features]
anchor = ["dep:anchor-lang"]
anchor-idl-build = ["anchor", "anchor-lang?/idl-build"]
serde = ["dep:serde", "dep:serde_with"]
test-sbf = []

[dependencies]
anchor-lang = { version = "0.30.0", optional = true }
borsh = "^1.5.3"
borsh-derive = "^1.5.3"
kaigan = "0.2.5"
num-derive = "^0.3"
num-traits = "^0.2"
serde = { version = "^1.0", features = ["derive"], optional = true }
serde_with = { version = "^3.0", optional = true }
solana-program = "~1.18"
thiserror = "^1.0"

[dev-dependencies]
assert_matches = "1.5.0"
solana-program-test = "~1.18"
solana-sdk = "~1.18"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!
use crate::generated::types::CpiRule;
use crate::generated::types::MetadataAdditionalFieldRule;
use crate::generated::types::TransferAmountRule;
use borsh::BorshDeserialize;
use borsh::BorshSerialize;
use solana_program::pubkey::Pubkey;

#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct GuardV1 {
pub discriminator: [u8; 8],
/// Mint token representing the guard, do not confuse with the mint of the token being transferred.
#[cfg_attr(
feature = "serde",
serde(with = "serde_with::As::<serde_with::DisplayFromStr>")
)]
pub mint: Pubkey,
/// Bump seed for the guard account.
pub bump: u8,
/// CPI ruleset for the guard.
pub cpi_rule: Option<CpiRule>,
/// Transfer amount ruleset for the guard.
pub transfer_amount_rule: Option<TransferAmountRule>,
/// Additional fields ruleset for the guard.
pub additional_fields_rule: Vec<MetadataAdditionalFieldRule>,
}

impl GuardV1 {
#[inline(always)]
pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
let mut data = data;
Self::deserialize(&mut data)
}
}

impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for GuardV1 {
type Error = std::io::Error;

fn try_from(
account_info: &solana_program::account_info::AccountInfo<'a>,
) -> Result<Self, Self::Error> {
let mut data: &[u8] = &(*account_info.data).borrow();
Self::deserialize(&mut data)
}
}

#[cfg(feature = "anchor")]
impl anchor_lang::AccountDeserialize for GuardV1 {
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
Ok(Self::deserialize(buf)?)
}
}

#[cfg(feature = "anchor")]
impl anchor_lang::AccountSerialize for GuardV1 {}

#[cfg(feature = "anchor")]
impl anchor_lang::Owner for GuardV1 {
fn owner() -> Pubkey {
crate::WEN_TRANSFER_GUARD_ID
}
}

#[cfg(feature = "anchor-idl-build")]
impl anchor_lang::IdlBuild for GuardV1 {}

#[cfg(feature = "anchor-idl-build")]
impl anchor_lang::Discriminator for GuardV1 {
const DISCRIMINATOR: [u8; 8] = [0; 8];
}
10 changes: 10 additions & 0 deletions packages/renderers-rust/e2e/anchor/src/generated/accounts/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!
pub(crate) mod r#guard_v1;

pub use self::r#guard_v1::*;
10 changes: 10 additions & 0 deletions packages/renderers-rust/e2e/anchor/src/generated/errors/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!
pub(crate) mod wen_transfer_guard;

pub use self::wen_transfer_guard::WenTransferGuardError;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!
use num_derive::FromPrimitive;
use thiserror::Error;

#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum WenTransferGuardError {
/// 6000 - Cpi Rule Enforcement Failed
#[error("Cpi Rule Enforcement Failed")]
CpiRuleEnforcementFailed = 0x1770,
/// 6001 - Transfer Amount Rule Enforce Failed
#[error("Transfer Amount Rule Enforce Failed")]
TransferAmountRuleEnforceFailed = 0x1771,
/// 6002 - Metadata Field Does Not Exist
#[error("Metadata Field Does Not Exist")]
MetadataFieldDoesNotExist = 0x1772,
/// 6003 - Metadata Field Does Not Pass
#[error("Metadata Field Does Not Pass")]
MetadataFieldDoesNotPass = 0x1773,
/// 6004 - Guard token amount should be at least 1
#[error("Guard token amount should be at least 1")]
GuardTokenAmountShouldBeAtLeastOne = 0x1774,
/// 6005 - Not owned by token 2022 program
#[error("Not owned by token 2022 program")]
NotOwnedByToken2022Program = 0x1775,
/// 6006 - Must be initialized by Transfer Hook Authority
#[error("Must be initialized by Transfer Hook Authority")]
MustBeInitializedByTransferHookAuthority = 0x1776,
/// 6007 - Mint's assigned Transfer Hook Program is not this one
#[error("Mint's assigned Transfer Hook Program is not this one")]
MintAssignedTransferHookProgramIsNotThisOne = 0x1777,
}

impl solana_program::program_error::PrintProgramError for WenTransferGuardError {
fn print<E>(&self) {
solana_program::msg!(&self.to_string());
}
}
Loading

0 comments on commit 0572cc9

Please sign in to comment.