-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,574 additions
and
987 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
programs/cardinal-creator-standard/src/instructions/mint_manager/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
pub mod init_mint_manager; | ||
pub mod remove_in_use_by; | ||
pub mod set_in_use_by; | ||
pub mod update_mint_manager; | ||
|
||
pub use init_mint_manager::*; | ||
pub use remove_in_use_by::*; | ||
pub use set_in_use_by::*; | ||
pub use update_mint_manager::*; |
17 changes: 17 additions & 0 deletions
17
programs/cardinal-creator-standard/src/instructions/mint_manager/remove_in_use_by.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::errors::ErrorCode; | ||
use crate::state::*; | ||
use anchor_lang::prelude::*; | ||
|
||
#[derive(Accounts)] | ||
pub struct RemoveInUseByCtx<'info> { | ||
#[account(mut)] | ||
mint_manager: Box<Account<'info, MintManager>>, | ||
#[account(constraint = mint_manager.in_use_by.expect("Token not in use") == user.key() @ ErrorCode::InvalidTokenUser)] | ||
user: Signer<'info>, | ||
} | ||
|
||
pub fn handler(ctx: Context<RemoveInUseByCtx>) -> Result<()> { | ||
let mint_manager = &mut ctx.accounts.mint_manager; | ||
mint_manager.in_use_by = None; | ||
Ok(()) | ||
} |
29 changes: 29 additions & 0 deletions
29
programs/cardinal-creator-standard/src/instructions/mint_manager/set_in_use_by.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::errors::ErrorCode; | ||
use crate::state::*; | ||
use anchor_lang::prelude::*; | ||
use anchor_spl::token::TokenAccount; | ||
|
||
#[derive(AnchorSerialize, AnchorDeserialize)] | ||
pub struct SetInUseByIx { | ||
pub in_use_by: Pubkey, | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct SetInUseByCtx<'info> { | ||
#[account(mut)] | ||
mint_manager: Box<Account<'info, MintManager>>, | ||
holder: Signer<'info>, | ||
|
||
#[account(constraint = holder_token_account.owner == holder.key() && holder_token_account.mint == mint_manager.mint @ ErrorCode::InvalidHolderTokenAccount)] | ||
holder_token_account: Box<Account<'info, TokenAccount>>, | ||
} | ||
|
||
pub fn handler(ctx: Context<SetInUseByCtx>, ix: SetInUseByIx) -> Result<()> { | ||
let mint_manager = &mut ctx.accounts.mint_manager; | ||
|
||
if mint_manager.in_use_by.is_some() { | ||
return Err(error!(ErrorCode::TokenAlreadyInUse)); | ||
} | ||
mint_manager.in_use_by = Some(ix.in_use_by); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.