Solana Programs for Foster Studio
pub struct MerchProduct {
pub id: Pubkey,
pub authority: Pubkey,
pub name: String,
pub uri: String,
pub category: String,
pub current_supply: u64,
pub max_supply: MaxSupply,
pub sale_start_at: Option<i64>,
pub sale_end_at: Option<i64>,
pub linked_master_nft: Option<Pubkey>,
pub claims_per_edition: u32,
pub payments: Vec<PaymentConfig>,
pub affiliate_commission_bps: u16,
}id: the product is identified by it's id, public key of the accountauthority: represents the wallet that can edit the productname: name of the producturi: a pointer to the off-chain metadata including photos, metadata, etccategory: arbitrary text to categorize the productcurrent_supply: number of items soldmax_supply: enum representing max supplysale_start_at: time after which the product can be boughtsale_end_at: time before with the product can be boughtlinked_master_nft: master edition nft that the supply of the product is tied toclaims_per_edition: number of items the owner of an edition can purchasepayments: vector of payment configsaffiliate_commission_bps: affiliate fee %, in basis points
pub enum MaxSupply {
None,
Some(u64),
FollowMasterEdition,
}None: no max supply, unlimited supplySome(u64): supply limited tou64FollowMasterEdition: follow the supply of the linked master edition
pub struct PaymentConfig {
pub tag: String,
pub mint: Pubkey,
pub amount: u64,
pub recipient: Pubkey,
}tag: identifier for the payment, to be shown to the usermint:- for sol:
Pubkey::default() - for token: the mint address of the token
- for sol:
amount:- for sol: amount in lamport
- for token: token amount, without decimals
recipient:- for sol: recipient public key
- for token: associated token account address
Configure Product is used to both create and update a MerchProduct.
Transaction must be signed by product.authority.
Used to delete a MerchProduct.
Processes payments as per product.payments.
If a referrer account is specified:
(product.payments[i].amount * product.affiliate_commission_bps)/10000
extra is transferred to the referrer
Tests can be run with
anchor test