-
Notifications
You must be signed in to change notification settings - Fork 533
fix(abl-token): block wallets from sending, not just receiving #672
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
Merged
dev-jodee
merged 4 commits into
solana-foundation:main
from
NikkiAung:fix/abl-token-sender-block
Aug 12, 2026
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6038763
fix(abl-token): block wallets from sending, not just receiving
NikkiAung def8e0a
fix(abl-token): add resize_meta_list to migrate existing mints to the…
NikkiAung 3a7a44b
fix(#672): address dev-jodee review - CI test wiring, magic number, n…
NikkiAung 851211f
fix(#672): make resize_meta_list permissionless per Greptile review
NikkiAung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...ook/allow-block-list-token/anchor/programs/abl-token/src/instructions/resize_meta_list.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| use anchor_lang::{prelude::*, solana_program::program::invoke, solana_program::system_instruction::transfer}; | ||
| use anchor_spl::{ | ||
| token_2022::Token2022, | ||
| token_interface::{transfer_hook_update, Mint, TransferHookUpdate}, | ||
| }; | ||
|
|
||
| use spl_tlv_account_resolution::state::ExtraAccountMetaList; | ||
| use spl_transfer_hook_interface::instruction::ExecuteInstruction; | ||
|
|
||
| use crate::{get_extra_account_metas, get_meta_list_size, META_LIST_ACCOUNT_SEED}; | ||
|
|
||
| /// Rewrites an existing mint's extra-metas account to the current | ||
| /// `get_extra_account_metas()` layout, reallocating it if the size changed. | ||
| /// | ||
| /// This exists because `extra_metas_account` is a fixed-size PDA created once | ||
| /// by `init_mint`/`attach_to_mint`: if the program's extra-account list is | ||
| /// ever extended (e.g. to add the source-wallet check), mints that were set | ||
| /// up under the old layout are left with a stale, undersized account and | ||
| /// their transfers start failing the hook's account-count check. Any mint | ||
| /// authority can call this to bring an existing mint's extra-metas account | ||
| /// back in sync after such an upgrade. | ||
| #[derive(Accounts)] | ||
| pub struct ResizeMetaList<'info> { | ||
| #[account(mut)] | ||
| pub payer: Signer<'info>, | ||
|
|
||
| #[account(mut, mint::token_program = token_program)] | ||
| pub mint: Box<InterfaceAccount<'info, Mint>>, | ||
|
|
||
| #[account( | ||
| mut, | ||
| seeds = [META_LIST_ACCOUNT_SEED, mint.key().as_ref()], | ||
| bump, | ||
| )] | ||
| /// CHECK: extra metas account | ||
| pub extra_metas_account: UncheckedAccount<'info>, | ||
|
|
||
| pub system_program: Program<'info, System>, | ||
|
|
||
| pub token_program: Program<'info, Token2022>, | ||
| } | ||
|
|
||
| impl ResizeMetaList<'_> { | ||
| pub fn resize_meta_list(&mut self) -> Result<()> { | ||
| // Re-setting the transfer hook to itself has no effect on the mint, | ||
| // but the CPI only succeeds if `payer` is the mint's current | ||
| // transfer-hook authority - the same check `attach_to_mint` relies | ||
| // on, reused here so this instruction can't be called by anyone | ||
| // other than whoever is already trusted to configure this mint's hook. | ||
| let tx_hook_accs = TransferHookUpdate { | ||
| token_program_id: self.token_program.to_account_info(), | ||
| mint: self.mint.to_account_info(), | ||
| authority: self.payer.to_account_info(), | ||
| }; | ||
| let ctx = CpiContext::new(self.token_program.key(), tx_hook_accs); | ||
| transfer_hook_update(ctx, Some(crate::ID_CONST))?; | ||
|
|
||
| let account_info = self.extra_metas_account.to_account_info(); | ||
| let new_size = get_meta_list_size()?; | ||
|
|
||
| let min_balance = Rent::get()?.minimum_balance(new_size); | ||
| if min_balance > account_info.lamports() { | ||
| invoke( | ||
| &transfer(&self.payer.key(), account_info.key, min_balance - account_info.lamports()), | ||
| &[self.payer.to_account_info(), account_info.clone(), self.system_program.to_account_info()], | ||
| )?; | ||
| } | ||
| account_info.resize(new_size)?; | ||
|
|
||
| let metas = get_extra_account_metas()?; | ||
| let mut data = account_info.try_borrow_mut_data()?; | ||
| ExtraAccountMetaList::update::<ExecuteInstruction>(&mut data, &metas) | ||
| .map_err(|_| ProgramError::InvalidAccountData)?; | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an existing mint revoked its transfer-hook authority or configured an authority that cannot sign directly,
resize_meta_listalways fails attransfer_hook_updatebefore rewriting the deterministic program-owned metadata account. The mint therefore remains on the incompatible one-entry layout, causing every transfer through the upgraded hook to fail with no recovery path.Knowledge Base Used: Tokens Directory Overview