mallow-auction-client 0.2.0

Codama-generated Rust client for the mallow_auction Anchor program.
Documentation
//! 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 solana_address::Address;
use crate::generated::types::TokenStandard;
use borsh::BorshSerialize;
use borsh::BorshDeserialize;


#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct AuctionConfig {
pub discriminator: [u8; 8],
pub bump: [u8; 1],
pub version: u8,
/// Pubkey of the marketplace authority's wallet
pub marketplace_authority: Address,
/// Seller of the NFT
pub seller: Address,
/// Mint account of the NFT
pub mint: Address,
/// Mint account of the bid token (e.g. FOXY)
pub bid_mint: Address,
/// Start time as unix timestamp
pub start_time: i64,
/// End time as unix timestamp
pub end_time: i64,
/// The current highest bid amount
pub highest_bid_amount: u64,
/// The current highest bidder or default pubkey if no bids have been made
pub highest_bidder: Address,
/// The minimum bid price
pub reserve_price: u64,
/// The duration of auction in seconds. It is used to determine the end time
/// of reserve price auctions when the first bid is made.
pub duration: u32,
/// @deprecated Use min_bid_increment and absolute_increment instead
/// The minimum increase basis points in bid price from the previous bid
pub min_bid_increment_bps: u16,
/// Time in seconds before the end time where an extension will be made when bidding
pub time_ext_period: u32,
/// Time in seconds to increase the end time by when an extension is made
pub time_ext_delta: u32,
/// Account to receive fees determined by the fee config
pub fee_account: Address,
/// The resolved fee_bps for this auction based on user/nft status at time of creating auction
pub fee_bps: u16,
/// The timestamp of when the auction was paused, or 0 if not paused
pub paused_at: i64,
/// @deprecated True if the mint should be burned when the auction ends (DRiP Ultimate auctions)
pub burn_on_complete: bool,
/// True if the buyer has acknowledged winning a burn_on_complete auction
pub buyer_ack: bool,
/// True if the seller has acknowledged sale of a burn_on_complete auction
pub seller_ack: bool,
/// The token standard of the item on auction
pub token_standard: TokenStandard,
/// The minimum bid increment
pub min_bid_increment: u64,
/// True if the bid increment should be an absolute amount instead of basis points of the current bid
pub absolute_increment: bool,
/// True if the primary proceeds should go to seller (less normal royalties)
pub disable_primary_split: bool,
}


pub const AUCTION_CONFIG_DISCRIMINATOR: [u8; 8] = [195, 54, 8, 51, 28, 231, 33, 142];

impl AuctionConfig {
      pub const LEN: usize = 272;
  
          /// Prefix values used to generate a PDA for this account.
    ///
    /// Values are positional and appear in the following order:
    ///
                  ///   0. mint (`Address`)
                        ///   1. `AuctionConfig::PREFIX`
                            pub const PREFIX: &'static [u8] = "auction_config".as_bytes();
      
      pub fn create_pda(
                                          mint: Address,
                                                        bump: u8,
    ) -> Result<solana_address::Address, solana_address::error::AddressError> {
      solana_address::Address::create_program_address(
        &[
                                    mint.as_ref(),
                                                "auction_config".as_bytes(),
                                &[bump],
        ],
        &crate::MALLOW_AUCTION_ID,
      )
    }

    pub fn find_pda(
                                  mint: &Address,
                                            ) -> (solana_address::Address, u8) {
      solana_address::Address::find_program_address(
        &[
                                    mint.as_ref(),
                                                "auction_config".as_bytes(),
                              ],
        &crate::MALLOW_AUCTION_ID,
      )
    }
  
  #[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_account_info::AccountInfo<'a>> for AuctionConfig {
  type Error = std::io::Error;

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

#[cfg(feature = "fetch")]
pub fn fetch_auction_config(
  rpc: &solana_rpc_client::rpc_client::RpcClient,
  address: &solana_address::Address,
) -> Result<crate::shared::DecodedAccount<AuctionConfig>, std::io::Error> {
  let accounts = fetch_all_auction_config(rpc, &[*address])?;
  Ok(accounts[0].clone())
}

#[cfg(feature = "fetch")]
pub fn fetch_all_auction_config(
  rpc: &solana_rpc_client::rpc_client::RpcClient,
  addresses: &[solana_address::Address],
) -> Result<Vec<crate::shared::DecodedAccount<AuctionConfig>>, std::io::Error> {
    let accounts = rpc.get_multiple_accounts(addresses)
      .map_err(|e| std::io::Error::other(e.to_string()))?;
    let mut decoded_accounts: Vec<crate::shared::DecodedAccount<AuctionConfig>> = Vec::new();
    for i in 0..addresses.len() {
      let address = addresses[i];
      let account = accounts[i].as_ref()
        .ok_or(std::io::Error::other(format!("Account not found: {address}")))?;
      let data = AuctionConfig::from_bytes(&account.data)?;
      decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
    }
    Ok(decoded_accounts)
}

#[cfg(feature = "fetch")]
pub fn fetch_maybe_auction_config(
  rpc: &solana_rpc_client::rpc_client::RpcClient,
  address: &solana_address::Address,
) -> Result<crate::shared::MaybeAccount<AuctionConfig>, std::io::Error> {
    let accounts = fetch_all_maybe_auction_config(rpc, &[*address])?;
    Ok(accounts[0].clone())
}

#[cfg(feature = "fetch")]
pub fn fetch_all_maybe_auction_config(
  rpc: &solana_rpc_client::rpc_client::RpcClient,
  addresses: &[solana_address::Address],
) -> Result<Vec<crate::shared::MaybeAccount<AuctionConfig>>, std::io::Error> {
    let accounts = rpc.get_multiple_accounts(addresses)
      .map_err(|e| std::io::Error::other(e.to_string()))?;
    let mut decoded_accounts: Vec<crate::shared::MaybeAccount<AuctionConfig>> = Vec::new();
    for i in 0..addresses.len() {
      let address = addresses[i];
      if let Some(account) = accounts[i].as_ref() {
        let data = AuctionConfig::from_bytes(&account.data)?;
        decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
      } else {
        decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
      }
    }
  Ok(decoded_accounts)
}

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

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

  #[cfg(feature = "anchor")]
  impl anchor_lang::Owner for AuctionConfig {
      fn owner() -> anchor_lang::solana_program::pubkey::Pubkey {
        anchor_lang::solana_program::pubkey::Pubkey::from(
          crate::MALLOW_AUCTION_ID.to_bytes()
        )
      }
  }

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

  
  #[cfg(feature = "anchor-idl-build")]
  impl anchor_lang::Discriminator for AuctionConfig {
    const DISCRIMINATOR: &[u8] = &[0; 8];
  }