Skip to content

Commit

Permalink
Add group + members to editions initialise and mint
Browse files Browse the repository at this point in the history
  • Loading branch information
nilpferdschaefer committed May 13, 2024
1 parent 0472b1d commit 2896d06
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 93 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions programs/libreplex_editions/src/instructions/initialise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub struct InitialiseCtx<'info> {
#[account(mut)]
pub group_mint: Signer<'info>,

#[account(mut)]
pub group: Signer<'info>,

#[account()]
pub system_program: Program<'info, System>,

Expand Down Expand Up @@ -76,6 +79,8 @@ pub fn initialise(ctx: Context<InitialiseCtx>, input: InitialiseInput) -> Result

let group_mint = &ctx.accounts.group_mint;

let group = &ctx.accounts.group;



let url_is_template = match input.offchain_url.matches("{}").count() {
Expand All @@ -101,6 +106,7 @@ pub fn initialise(ctx: Context<InitialiseCtx>, input: InitialiseInput) -> Result
max_number_of_tokens: input.max_number_of_tokens,
number_of_tokens_issued: 0,
group_mint: group_mint.key(),
group: group.key(),
cosigner_program_id: match input.creator_cosign_program_id {
Some(x) => x,
_ => system_program::ID
Expand Down Expand Up @@ -150,6 +156,7 @@ pub fn initialise(ctx: Context<InitialiseCtx>, input: InitialiseInput) -> Result
additional_metadata: vec![],
}),
Some(TokenGroupInput {
group: group.to_account_info(),
max_size: match editions_deployment.max_number_of_tokens {
0 => u32::MAX,
_ => editions_deployment.max_number_of_tokens as u32
Expand Down
17 changes: 12 additions & 5 deletions programs/libreplex_editions/src/instructions/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use dyn_fmt::AsStrFormatExt;
use anchor_lang::{prelude::*, system_program};
use anchor_spl::{
associated_token::AssociatedToken, token_2022, token_interface::Mint
associated_token::AssociatedToken, token_2022
};


Expand Down Expand Up @@ -57,9 +57,13 @@ pub struct MintCtx<'info> {
#[account(mut)]
pub mint: Signer<'info>,

#[account(mut)]
pub member: Signer<'info>,

/// CHECK: Checked in constraint
#[account(mut,
constraint = editions_deployment.group_mint == group_mint.key())]
pub group_mint: InterfaceAccount<'info, Mint>,
constraint = editions_deployment.group == group.key())]
pub group: UncheckedAccount<'info>,

/// CHECK: passed in via CPI to mpl_token_metadata program
#[account(mut)]
Expand Down Expand Up @@ -103,7 +107,9 @@ pub fn mint<'info>(ctx: Context<'_, '_, '_, 'info, MintCtx<'info>>) -> Result<()
let associated_token_program = &ctx.accounts.associated_token_program;
let system_program = &ctx.accounts.system_program;
let mint = &ctx.accounts.mint;
let group_mint = &ctx.accounts.group_mint;
let member = &ctx.accounts.member;

let group = &ctx.accounts.group;
let group_extension_program = &ctx.accounts.group_extension_program;
// mutable borrows
let editions_deployment = &mut ctx.accounts.editions_deployment;
Expand Down Expand Up @@ -161,7 +167,8 @@ pub fn mint<'info>(ctx: Context<'_, '_, '_, 'info, MintCtx<'info>>) -> Result<()
}),
None,
Some(TokenMemberInput {
group_mint: group_mint.to_account_info(),
member: member.to_account_info(),
group: group.to_account_info(),
}),
Some(deployment_seeds),
None,
Expand Down
2 changes: 2 additions & 0 deletions programs/libreplex_editions/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct EditionsDeployment {

pub group_mint: Pubkey,

pub group: Pubkey,

#[max_len(SYMBOL_LIMIT)]
pub symbol: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub struct InitialiseEditionControlsCtx<'info> {
#[account(mut)]
pub group_mint: Signer<'info>,

#[account(mut)]
pub group: Signer<'info>,

#[account()]
pub system_program: Program<'info, System>,

Expand All @@ -83,6 +86,8 @@ pub fn initialise_editions_controls(ctx: Context<InitialiseEditionControlsCtx>,
let hashlist = &ctx.accounts.hashlist;
let payer = &ctx.accounts.payer;
let creator = &ctx.accounts.creator;

let group = &ctx.accounts.group;
let group_mint = &ctx.accounts.group_mint;
let system_program = &ctx.accounts.system_program;
let token_program = &ctx.accounts.token_program;
Expand All @@ -109,10 +114,12 @@ pub fn initialise_editions_controls(ctx: Context<InitialiseEditionControlsCtx>,
hashlist: hashlist.to_account_info(),
payer: payer.to_account_info(),
creator: editions_controls.to_account_info(),
group: group.to_account_info(),
group_mint: group_mint.to_account_info(),
system_program: system_program.to_account_info(),
token_program: token_program.to_account_info(),
group_extension_program: group_extension_program.to_account_info()
group_extension_program: group_extension_program.to_account_info(),

},
),
core_input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use anchor_lang::{prelude::*, system_program};
use anchor_spl::{
associated_token::AssociatedToken, token_2022, token_interface::Mint
associated_token::AssociatedToken, token_2022
};


Expand Down Expand Up @@ -80,9 +80,12 @@ pub struct MintWithControlsCtx<'info> {
#[account(mut)]
pub mint: Signer<'info>,

#[account(mut)]
pub member: Signer<'info>,

#[account(mut,
constraint = editions_deployment.group_mint == group_mint.key())]
pub group_mint: InterfaceAccount<'info, Mint>,
constraint = editions_deployment.group == group.key())]
pub group: UncheckedAccount<'info>,

/// CHECK: passed in via CPI to mpl_token_metadata program
#[account(mut)]
Expand Down Expand Up @@ -130,14 +133,14 @@ pub fn mint_with_controls(ctx: Context<MintWithControlsCtx>, mint_input: MintInp
let token_account = &ctx.accounts.token_account;
let associated_token_program = &ctx.accounts.associated_token_program;
let minter = &ctx.accounts.minter;
let group_mint = &ctx.accounts.group_mint;
let group = &ctx.accounts.group;
let system_program = &ctx.accounts.system_program;
let token_program = &ctx.accounts.token_program;
let minter_stats = &mut ctx.accounts.minter_stats;
let treasury = &ctx.accounts.treasury;
let minter_stats_phase = &mut ctx.accounts.minter_stats_phase;
let group_extension_program = &ctx.accounts.group_extension_program;

let member = &ctx.accounts.member;

let current_phase = &editions_controls.phases[mint_input.phase_index as usize];
check_phase_constraints(current_phase,
Expand Down Expand Up @@ -189,12 +192,13 @@ pub fn mint_with_controls(ctx: Context<MintWithControlsCtx>, mint_input: MintInp
signer: editions_controls.to_account_info(),
minter: minter.to_account_info(),
mint: mint.to_account_info(),
group_mint: group_mint.to_account_info(),
group: group.to_account_info(),
token_account: token_account.to_account_info(),
token_program: token_program.to_account_info(),
associated_token_program: associated_token_program.to_account_info(),
system_program: system_program.to_account_info(),
group_extension_program: group_extension_program.to_account_info()
group_extension_program: group_extension_program.to_account_info(),
member: member.to_account_info(),
},
&[seeds]
))?;
Expand Down
2 changes: 1 addition & 1 deletion programs/libreplex_shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libreplex_shared"
version = "0.1.0"
version = "0.2.0"
description = "Created with Anchor"
edition = "2021"
license = "MIT"
Expand Down
Loading

0 comments on commit 2896d06

Please sign in to comment.