Skip to content

Commit

Permalink
cargo clippy --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Oct 4, 2024
1 parent e5c05df commit 391b631
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
50 changes: 25 additions & 25 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn create_product<'a>(

// Guards
assert_signer("vendor", ctx.accounts.vendor)?;
if args.name.len() == 0 {
if args.name.is_empty() {
msg!("Name should not be empty");
return Err(ProgramError::InvalidArgument);
};
Expand Down Expand Up @@ -174,7 +174,7 @@ fn create_product<'a>(
base_size,
Some(base_size + metadata_size),
&token_program_id,
&[&product_mint_seeds],
&[product_mint_seeds],
)?;

// init Permanent Delegate
Expand Down Expand Up @@ -293,7 +293,7 @@ fn create_device<'a>(
)?;

assert_signer("vendor", ctx.accounts.vendor)?;
if args.name.len() == 0 {
if args.name.is_empty() {
msg!("Name should not be empty");
return Err(ProgramError::InvalidArgument);
};
Expand Down Expand Up @@ -322,7 +322,7 @@ fn create_device<'a>(
)?;

let product_ata_pubkey = get_associated_token_address_with_program_id(
&device_pubkey,
device_pubkey,
&product_mint_pubkey,
&token_program_id,
);
Expand Down Expand Up @@ -417,8 +417,8 @@ fn activate_device<'a>(
)?;

let product_ata_pubkey = get_associated_token_address_with_program_id(
&device_pubkey,
&product_mint_pubkey,
device_pubkey,
product_mint_pubkey,
&token_program_id,
);

Expand Down Expand Up @@ -522,7 +522,7 @@ fn create_activated_device<'a>(
)?;

assert_signer("vendor", ctx.accounts.vendor)?;
if args.name.len() == 0 {
if args.name.is_empty() {
msg!("Name should not be empty");
return Err(ProgramError::InvalidArgument);
};
Expand Down Expand Up @@ -555,7 +555,7 @@ fn create_activated_device<'a>(
)?;

let product_ata_pubkey = get_associated_token_address_with_program_id(
&device_pubkey,
device_pubkey,
&product_mint_pubkey,
&token_program_id,
);
Expand All @@ -568,7 +568,7 @@ fn create_activated_device<'a>(

let device_ata_pubkey = get_associated_token_address_with_program_id(
owner_pubkey,
&device_mint_pubkey,
device_mint_pubkey,
&token_program_id,
);
assert_same_pubkeys(
Expand Down Expand Up @@ -732,15 +732,15 @@ fn create_device_mint_internal(
base_size,
Some(base_size + metadata_size),
accounts.token_program.key,
&[&device_mint_seeds],
&[device_mint_seeds],
)?;

// init Mint Close Authroity
invoke(
&spl_token_2022::instruction::initialize_mint_close_authority(
accounts.token_program.key,
&device_mint_pubkey,
Some(&device_mint_pubkey),
device_mint_pubkey,
Some(device_mint_pubkey),
)?,
&[
// 0. `[writable]` The mint account to initialize.
Expand All @@ -752,7 +752,7 @@ fn create_device_mint_internal(
invoke(
&spl_token_2022::instruction::initialize_non_transferable_mint(
accounts.token_program.key,
&device_mint_pubkey,
device_mint_pubkey,
)?,
&[
// 0. `[writable]` The mint account to initialize.
Expand All @@ -764,7 +764,7 @@ fn create_device_mint_internal(
invoke(
&metadata_pointer::instruction::initialize(
accounts.token_program.key,
&device_mint_pubkey,
device_mint_pubkey,
None,
Some(*device_mint_pubkey),
)?,
Expand All @@ -778,8 +778,8 @@ fn create_device_mint_internal(
invoke_signed(
&spl_token_2022::instruction::initialize_mint2(
accounts.token_program.key,
&device_mint_pubkey,
&device_mint_pubkey,
device_mint_pubkey,
device_mint_pubkey,
None,
0,
)?,
Expand All @@ -794,10 +794,10 @@ fn create_device_mint_internal(
invoke_signed(
&spl_token_metadata_interface::instruction::initialize(
accounts.token_program.key,
&device_mint_pubkey,
&device_mint_pubkey,
&device_mint_pubkey,
&device_mint_pubkey,
device_mint_pubkey,
device_mint_pubkey,
device_mint_pubkey,
device_mint_pubkey,
metadata.name,
metadata.symbol,
metadata.uri,
Expand All @@ -819,8 +819,8 @@ fn create_device_mint_internal(
invoke_signed(
&spl_token_metadata_interface::instruction::update_field(
accounts.token_program.key,
&device_mint_pubkey,
&device_mint_pubkey,
device_mint_pubkey,
device_mint_pubkey,
Field::Key(field),
value,
),
Expand Down Expand Up @@ -856,7 +856,7 @@ fn activate_device_internal(
accounts.payer.key,
accounts.owner.key,
accounts.device_mint.key,
&accounts.token_program.key,
accounts.token_program.key,
),
&[
// 0. `[writeable,signer]` Funding account (must be a system account)
Expand All @@ -877,7 +877,7 @@ fn activate_device_internal(
// mint to user
invoke_signed(
&spl_token_2022::instruction::mint_to(
&accounts.token_program.key,
accounts.token_program.key,
accounts.device_mint.key,
accounts.device_atoken.key,
accounts.device_mint.key,
Expand All @@ -898,7 +898,7 @@ fn activate_device_internal(
// disable mint
invoke_signed(
&spl_token_2022::instruction::set_authority(
&accounts.token_program.key,
accounts.token_program.key,
accounts.device_mint.key,
None,
spl_token_2022::instruction::AuthorityType::MintTokens,
Expand Down
1 change: 0 additions & 1 deletion program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl ProgramDataAccount {
}
}

///
#[derive(Clone, BorshSerialize, BorshDeserialize, Debug)]
pub struct ProgramData {
pub bump: u8,
Expand Down

0 comments on commit 391b631

Please sign in to comment.