Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #19

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,180 changes: 758 additions & 422 deletions programs/candy-guard/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions programs/candy-guard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
overflow-checks = true

[workspace]
resolver = "2"
members = [
"program",
"macro"
Expand Down
9 changes: 6 additions & 3 deletions programs/candy-guard/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ pub fn derive(input: TokenStream) -> TokenStream {
size
}

pub fn route<'info>(
ctx: Context<'_, '_, '_, 'info, crate::instructions::Route<'info>>,
pub fn route<'c, 'info>(
ctx: Context<'_, '_, 'c, 'info, crate::instructions::Route<'info>>,
route_context: crate::instructions::RouteContext<'info>,
args: crate::instructions::RouteArgs
) -> anchor_lang::Result<()> {
) -> anchor_lang::Result<()>
where
'c: 'info
{
match args.guard {
#(#route_arm,)*
_ => err!(CandyGuardError::InstructionNotFound)
Expand Down
8 changes: 4 additions & 4 deletions programs/candy-guard/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ no-entrypoint = []
test-bpf = []

[dependencies]
anchor-lang = "0.28.0"
anchor-lang = "0.30.1"
arrayref = "0.3.6"
mpl-core = { version = "0.8.0" }
mpl-core-candy-guard-derive = { path = "../macro", version = "0.2.1" }
Expand All @@ -27,10 +27,10 @@ mpl-core-candy-machine-core = { path = "../../candy-machine-core/program", versi
] }
mpl-token-metadata = "3.2.1"
regex-lite = "0.1.6"
solana-gateway = { version = "0.4.0", features = ["no-entrypoint"] }
solana-program = "~1.16.5"
solana-gateway = { version = "0.6.0", features = ["no-entrypoint"] }
solana-program = "1.18.26"
spl-associated-token-account = { version = ">= 1.1.3, < 3.0", features = [
"no-entrypoint",
] }
spl-token = { version = ">= 3.5.0, < 5.0", features = ["no-entrypoint"] }
spl-token-2022 = { version = ">= 0.6", features = ["no-entrypoint"] }
spl-token-2022 = { version = "3.0.4", features = ["no-entrypoint"] }
7 changes: 5 additions & 2 deletions programs/candy-guard/program/src/guards/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ impl Guard for Allocation {
/// candy guard pubkey, candy machine pubkey]`).
/// 1. `[signer]` Candy Guard authority.
/// 2. `[]` System program account.
fn instruction<'info>(
fn instruction<'c, 'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
route_context: RouteContext<'info>,
_data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
msg!("Instruction: Initialize (Allocation guard)");

let allocation = try_get_account_info(ctx.remaining_accounts, 0)?;
Expand Down
7 changes: 5 additions & 2 deletions programs/candy-guard/program/src/guards/allow_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ impl Guard for AllowList {
/// payer/minter key, candy guard pubkey, candy machine pubkey]`).
/// 1. `[]` System program account.
/// 2. `[optional]` Minter account.
fn instruction<'info>(
fn instruction<'c, 'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
route_context: RouteContext<'info>,
data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
msg!("AllowList: validate proof instruction");

let candy_guard = route_context
Expand Down
56 changes: 37 additions & 19 deletions programs/candy-guard/program/src/guards/freeze_sol_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ impl Guard for FreezeSolPayment {
/// * initialize
/// * thaw
/// * unlock funds
fn instruction<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
fn instruction<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext<'info>,
data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
// determines the instruction to execute
let instruction: FreezeInstruction =
if let Ok(instruction) = FreezeInstruction::try_from_slice(&data[0..1]) {
Expand Down Expand Up @@ -132,7 +135,7 @@ impl Guard for FreezeSolPayment {
}

impl Condition for FreezeSolPayment {
fn validate<'info>(
fn validate<'c, 'info>(
&self,
ctx: &mut EvaluationContext,
_guard_set: &GuardSet,
Expand Down Expand Up @@ -200,12 +203,15 @@ impl Condition for FreezeSolPayment {
Ok(())
}

fn post_actions<'info>(
fn post_actions<'c, 'info>(
&self,
ctx: &mut EvaluationContext,
ctx: &mut EvaluationContext<'_, 'c, 'info>,
_guard_set: &GuardSet,
_mint_args: &[u8],
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
// freezes the nft
freeze_nft(ctx, ctx.indices["freeze_sol_payment"], &self.destination)
}
Expand Down Expand Up @@ -297,11 +303,14 @@ pub enum FreezeInstruction {
}

/// Helper function to freeze an nft.
pub fn freeze_nft(
ctx: &EvaluationContext,
pub fn freeze_nft<'c, 'info>(
ctx: &EvaluationContext<'_, 'c, 'info>,
account_index: usize,
destination: &Pubkey,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let freeze_pda = try_get_account_info(ctx.accounts.remaining, account_index)?;

let mut freeze_escrow: Account<FreezeEscrow> = Account::try_from(freeze_pda)?;
Expand Down Expand Up @@ -350,12 +359,15 @@ pub fn freeze_nft(
}

/// Helper function to initialize the freeze pda.
pub fn initialize_freeze<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
pub fn initialize_freeze<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext,
data: Vec<u8>,
destination: Pubkey,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let candy_guard_key = &ctx.accounts.candy_guard.key();
let candy_machine_key = &ctx.accounts.candy_machine.key();

Expand Down Expand Up @@ -452,11 +464,14 @@ pub fn initialize_freeze<'info>(
}

/// Helper function to thaw an nft.
pub fn thaw_nft<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
pub fn thaw_nft<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext,
_data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let current_timestamp = Clock::get()?.unix_timestamp;

let freeze_pda = try_get_account_info(ctx.remaining_accounts, 0)?;
Expand Down Expand Up @@ -557,11 +572,14 @@ pub fn thaw_nft<'info>(
}

/// Helper function to unlock funds.
fn unlock_funds<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
fn unlock_funds<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext,
_data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let candy_guard_key = &ctx.accounts.candy_guard.key();
let candy_machine_key = &ctx.accounts.candy_machine.key();

Expand Down
27 changes: 18 additions & 9 deletions programs/candy-guard/program/src/guards/freeze_token_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ impl Guard for FreezeTokenPayment {
/// * initialize
/// * thaw
/// * unlock funds
fn instruction<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
fn instruction<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext<'info>,
data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
// determines the instruction to execute
let instruction: FreezeInstruction =
if let Ok(instruction) = FreezeInstruction::try_from_slice(&data[0..1]) {
Expand Down Expand Up @@ -284,12 +287,15 @@ impl Condition for FreezeTokenPayment {
Ok(())
}

fn post_actions<'info>(
fn post_actions<'c, 'info>(
&self,
ctx: &mut EvaluationContext,
ctx: &mut EvaluationContext<'_, 'c, 'info>,
_guard_set: &GuardSet,
_mint_args: &[u8],
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
// freezes the nft
freeze_nft(
ctx,
Expand All @@ -300,10 +306,13 @@ impl Condition for FreezeTokenPayment {
}

// Helper function to unlocks frozen funds.
fn unlock_funds<'info>(
ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
fn unlock_funds<'c, 'info>(
ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
route_context: RouteContext<'info>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let candy_guard_key = &ctx.accounts.candy_guard.key();
let candy_machine_key = &ctx.accounts.candy_machine.key();

Expand Down
18 changes: 12 additions & 6 deletions programs/candy-guard/program/src/guards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ pub trait Condition {
///
/// This function only gets called when all guards have been successfuly validated.
/// Any error generated will make the transaction to fail.
fn post_actions(
fn post_actions<'c, 'info>(
&self,
_ctx: &mut EvaluationContext,
_ctx: &mut EvaluationContext<'_, 'c, 'info>,
_guard_set: &GuardSet,
_mint_args: &[u8],
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
Ok(())
}
}
Expand All @@ -130,11 +133,14 @@ pub trait Guard: Condition + AnchorSerialize + AnchorDeserialize {

/// Executes an instruction. This function is called from the `route` instruction
/// handler.
fn instruction<'info>(
_ctx: &Context<'_, '_, '_, 'info, Route<'info>>,
fn instruction<'c, 'info>(
_ctx: &Context<'_, '_, 'c, 'info, Route<'info>>,
_route_context: RouteContext<'info>,
_data: Vec<u8>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
err!(CandyGuardError::InstructionNotFound)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn initialize(ctx: Context<Initialize>, data: Vec<u8>) -> Result<()> {

let candy_guard = &mut ctx.accounts.candy_guard;
candy_guard.base = ctx.accounts.base.key();
candy_guard.bump = *ctx.bumps.get("candy_guard").unwrap();
candy_guard.bump = ctx.bumps.candy_guard;
candy_guard.authority = ctx.accounts.authority.key();

let account_info = candy_guard.to_account_info();
Expand Down
18 changes: 12 additions & 6 deletions programs/candy-guard/program/src/instructions/mint_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ use crate::{

use super::MintAccounts;

pub fn mint_v1<'info>(
ctx: Context<'_, '_, '_, 'info, MintV1<'info>>,
pub fn mint_v1<'c, 'info>(
ctx: Context<'_, '_, 'c, 'info, MintV1<'info>>,
mint_args: Vec<u8>,
label: Option<String>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let owner_info = if let Some(owner) = ctx.accounts.owner.as_ref() {
owner.to_account_info()
} else {
Expand Down Expand Up @@ -52,11 +55,14 @@ pub fn mint_v1<'info>(
process_mint(&mut ctx, mint_args, label)
}

pub fn process_mint(
ctx: &mut EvaluationContext<'_, '_, '_>,
pub fn process_mint<'c, 'info>(
ctx: &mut EvaluationContext<'_, 'c, 'info>,
mint_args: Vec<u8>,
label: Option<String>,
) -> Result<()> {
) -> Result<()>
where
'c: 'info,
{
let account_info = ctx.accounts.candy_guard.to_account_info();
let account_data = account_info.data.borrow();
// loads the active guard set
Expand Down
Loading