Skip to content

Commit

Permalink
Formatting fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Nov 18, 2024
1 parent c3b8144 commit 981abde
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 38 deletions.
2 changes: 1 addition & 1 deletion programs/mpl-hybrid/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ pub enum MplHybridError {

/// 6016 (0x1780) - Invalid Token Account Mint
#[msg("Invalid Authorities")]
InvalidAuthority
InvalidAuthority,
}
5 changes: 2 additions & 3 deletions programs/mpl-hybrid/src/instructions/init_escrow_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anchor_lang::{prelude::*, Discriminator};
use mpl_utils::create_or_allocate_account_raw;
use solana_program::program_memory::sol_memcpy;


#[derive(Accounts)]
pub struct InitEscrowV2Ctx<'info> {
/// CHECK: This account is checked and initialized in the handler.
Expand All @@ -20,7 +19,7 @@ pub struct InitEscrowV2Ctx<'info> {
#[account(mut)]
authority: Signer<'info>,

system_program: Program<'info, System>
system_program: Program<'info, System>,
}

pub fn handler_init_escrow_v2(ctx: Context<InitEscrowV2Ctx>) -> Result<()> {
Expand All @@ -45,7 +44,7 @@ pub fn handler_init_escrow_v2(ctx: Context<InitEscrowV2Ctx>) -> Result<()> {
escrow_data.extend(
EscrowV2 {
authority: authority.key(),
bump: ctx.bumps.escrow
bump: ctx.bumps.escrow,
}
.try_to_vec()?,
);
Expand Down
17 changes: 6 additions & 11 deletions programs/mpl-hybrid/src/instructions/migrate_nft_v1.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use crate::constants::*;
use crate::error::MplHybridError;
use crate::state::*;
use crate::{constants::*};
use anchor_lang::prelude::*;
use anchor_lang::{
accounts::{program::Program, signer::Signer, unchecked_account::UncheckedAccount},
system_program::System,
};
use anchor_lang::{prelude::*};
use mpl_core::instructions::{
TransferV1Cpi, TransferV1InstructionArgs
};
use mpl_core::instructions::{TransferV1Cpi, TransferV1InstructionArgs};

#[derive(Accounts)]
pub struct MigrateNftV1Ctx<'info> {
Expand Down Expand Up @@ -49,11 +47,10 @@ pub struct MigrateNftV1Ctx<'info> {
address = MPL_CORE @ MplHybridError::InvalidMplCore
)]
mpl_core: AccountInfo<'info>,
system_program: Program<'info, System>
system_program: Program<'info, System>,
}

pub fn handler_migrate_nft_v1(ctx: Context<MigrateNftV1Ctx>) -> Result<()> {

let authority = &mut ctx.accounts.authority;
let escrow_new = &mut ctx.accounts.escrow_new;
let escrow_old = &mut ctx.accounts.escrow_old;
Expand All @@ -62,20 +59,18 @@ pub fn handler_migrate_nft_v1(ctx: Context<MigrateNftV1Ctx>) -> Result<()> {
let mpl_core = &mut ctx.accounts.mpl_core;
let system_program = &mut ctx.accounts.system_program;


if escrow_new.authority != escrow_old.authority {
return Err(MplHybridError::InvalidAuthority.into());
}

if escrow_new.authority != authority.key() {
return Err(MplHybridError::InvalidAuthority.into());
}



let system_info = &system_program.to_account_info();

let collection_info = &collection.to_account_info();
let escrow_info = &escrow_old.to_account_info();
let escrow_info = &escrow_old.to_account_info();

//create transfer instruction
let transfer_nft_ix = TransferV1Cpi {
Expand Down
15 changes: 6 additions & 9 deletions programs/mpl-hybrid/src/instructions/migrate_tokens_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ use anchor_spl::token::Mint;
use anchor_spl::token::{Token, Transfer};
use solana_program::system_program;


#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct MigrateTokensV1Ix {
amount: u64
amount: u64,
}

#[derive(Accounts)]
pub struct MigrateTokensV1Ctx<'info> {

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

Expand Down Expand Up @@ -69,7 +67,10 @@ pub struct MigrateTokensV1Ctx<'info> {
associated_token_program: Program<'info, AssociatedToken>,
}

pub fn handler_migrate_tokens_v1(ctx: Context<MigrateTokensV1Ctx>, ix: MigrateTokensV1Ix) -> Result<()> {
pub fn handler_migrate_tokens_v1(
ctx: Context<MigrateTokensV1Ctx>,
ix: MigrateTokensV1Ix,
) -> Result<()> {
//Need to add account checks for security
let authority = &mut ctx.accounts.authority;
let escrow_new = &mut ctx.accounts.escrow_new;
Expand Down Expand Up @@ -105,11 +106,7 @@ pub fn handler_migrate_tokens_v1(ctx: Context<MigrateTokensV1Ctx>, ix: MigrateTo
}

// The escrow token account should already exist.
validate_token_account(
escrow_old_token_account,
&escrow_old.key(),
&token.key(),
)?;
validate_token_account(escrow_old_token_account, &escrow_old.key(), &token.key())?;

//create transfer token instruction
let cpi_program = token_program.to_account_info();
Expand Down
12 changes: 6 additions & 6 deletions programs/mpl-hybrid/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
pub mod capture;
pub mod capture_v2;
pub mod init_recipe;
pub mod init_escrow;
pub mod init_escrow_v2;
pub mod init_nft_data;
pub mod init_recipe;
pub mod migrate_nft_v1;
pub mod migrate_tokens_v1;
pub mod release;
pub mod release_v2;
pub mod update_escrow;
pub mod update_new_data;
pub mod update_recipe;
pub mod migrate_nft_v1;
pub mod migrate_tokens_v1;

pub use capture::*;
pub use capture_v2::*;
pub use init_recipe::*;
pub use init_escrow::*;
pub use init_escrow_v2::*;
pub use init_nft_data::*;
pub use init_recipe::*;
pub use migrate_nft_v1::*;
pub use migrate_tokens_v1::*;
pub use release::*;
pub use release_v2::*;
pub use update_escrow::*;
pub use update_new_data::*;
pub use update_recipe::*;
pub use migrate_nft_v1::*;
pub use migrate_tokens_v1::*;
8 changes: 4 additions & 4 deletions programs/mpl-hybrid/src/instructions/update_recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn handler_update_recipe_v1(
// We can't allow the max to be less than the min.
if ix.max <= ix.min {
return Err(MplHybridError::MaxMustBeGreaterThanMin.into());
}
}

let mut size_diff: isize = 0;
recipe.authority = authority.key();
Expand All @@ -86,14 +86,14 @@ pub fn handler_update_recipe_v1(
.len()
.checked_sub(recipe.name.len())
.ok_or(MplHybridError::NumericalOverflow)? as isize;
recipe.name = name;
recipe.name = name;
}
if let Some(uri) = ix.uri {
size_diff += uri
.len()
.checked_sub(recipe.uri.len())
.ok_or(MplHybridError::NumericalOverflow)? as isize;
recipe.uri = uri;
recipe.uri = uri;
}
if let Some(max) = ix.max {
recipe.max = max;
Expand All @@ -115,7 +115,7 @@ pub fn handler_update_recipe_v1(
}
if let Some(sol_fee_amount_release) = ix.sol_fee_amount_release {
recipe.sol_fee_amount_release = sol_fee_amount_release;
}
}
if let Some(path) = ix.path {
recipe.path = path;
}
Expand Down
3 changes: 1 addition & 2 deletions programs/mpl-hybrid/src/state/escrow_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ pub struct EscrowV2 {
}

impl EscrowV2 {
pub const BASE_ESCROW_V2_SIZE: usize =
8 + 32 + 1;
pub const BASE_ESCROW_V2_SIZE: usize = 8 + 32 + 1;
}
4 changes: 2 additions & 2 deletions programs/mpl-hybrid/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub mod escrow;
pub mod escrow_v2;
pub mod nft_data;
pub mod path;
pub mod recipe;
pub mod escrow_v2;

pub use escrow::*;
pub use escrow_v2::*;
pub use nft_data::*;
pub use path::*;
pub use recipe::*;
pub use escrow_v2::*;

0 comments on commit 981abde

Please sign in to comment.