Skip to content

Commit b9f686c

Browse files
authored
fix: create empty token accounts with invalid mints (#1093)
1 parent 57ef210 commit b9f686c

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

programs/compressed-token/src/delegation.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ pub fn create_input_and_output_accounts_approve(
7474
Vec<PackedCompressedAccountWithMerkleContext>,
7575
Vec<OutputCompressedAccountWithPackedContext>,
7676
)> {
77+
if inputs.input_token_data_with_context.is_empty() {
78+
return err!(ErrorCode::NoInputTokenAccountsProvided);
79+
}
7780
let (mut compressed_input_accounts, input_token_data, sum_lamports) =
7881
get_input_compressed_accounts_with_merkle_context_and_check_signer::<NOT_FROZEN>(
7982
authority,
@@ -201,6 +204,9 @@ pub fn create_input_and_output_accounts_revoke(
201204
Vec<PackedCompressedAccountWithMerkleContext>,
202205
Vec<OutputCompressedAccountWithPackedContext>,
203206
)> {
207+
if inputs.input_token_data_with_context.is_empty() {
208+
return err!(ErrorCode::NoInputTokenAccountsProvided);
209+
}
204210
let (mut compressed_input_accounts, input_token_data, sum_lamports) =
205211
get_input_compressed_accounts_with_merkle_context_and_check_signer::<NOT_FROZEN>(
206212
authority,

programs/compressed-token/src/freeze.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ pub fn create_input_and_output_accounts_freeze_or_thaw<
7676
Vec<PackedCompressedAccountWithMerkleContext>,
7777
Vec<OutputCompressedAccountWithPackedContext>,
7878
)> {
79+
if inputs.input_token_data_with_context.is_empty() {
80+
return err!(crate::ErrorCode::NoInputTokenAccountsProvided);
81+
}
7982
let (mut compressed_input_accounts, input_token_data, _) =
8083
get_input_compressed_accounts_with_merkle_context_and_check_signer::<FROZEN_INPUTS>(
8184
&inputs.owner,

programs/compressed-token/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,6 @@ pub enum ErrorCode {
184184
#[msg("Compress or decompress recipient is the same account as the token pool pda.")]
185185
IsTokenPoolPda,
186186
InvalidTokenPoolPda,
187+
NoInputTokenAccountsProvided,
188+
NoInputsProvided,
187189
}

programs/compressed-token/src/process_mint.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ pub fn process_mint_to<'info>(
6868
amounts.len()
6969
);
7070
return err!(crate::ErrorCode::PublicKeyAmountMissmatch);
71+
} else if recipient_pubkeys.is_empty() {
72+
msg!("recipient_pubkeys is empty");
73+
return err!(crate::ErrorCode::NoInputsProvided);
7174
}
7275

7376
#[cfg(target_os = "solana")]

programs/compressed-token/src/process_transfer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ pub fn process_transfer<'a, 'b, 'c, 'info: 'b + 'c>(
4242
CompressedTokenInstructionDataTransfer::deserialize(&mut inputs.as_slice())?;
4343
bench_sbf_end!("t_deserialize");
4444
bench_sbf_start!("t_context_and_check_sig");
45+
if inputs.input_token_data_with_context.is_empty()
46+
&& inputs.compress_or_decompress_amount.is_none()
47+
{
48+
return err!(crate::ErrorCode::NoInputTokenAccountsProvided);
49+
}
4550
let (mut compressed_input_accounts, input_token_data, input_lamports) =
4651
get_input_compressed_accounts_with_merkle_context_and_check_signer::<NOT_FROZEN>(
4752
&ctx.accounts.authority.key(),

0 commit comments

Comments
 (0)