solana-program-library
solana-program-library copied to clipboard
[token-2022] zero amount processing - HAL-07
A number of token-2022 program functions allow for zero amount processing:
-
process_transfer
-
process_approve
-
process_mint_to
-
process_burn
-
process_deposit
-
process_withdraw
Unnecessary computations can be avoided if these functions check the parameter before the main logic.
Be careful, a lot of these are actually by design -- we used to no-op for zero amounts, but that creates false positives for incorrect instructions. For example, if we return earlier, I can successfully "transfer" 0 tokens from your account to mine without a signature. So be sure that all of the ownership checks and all that are still performed.