Skip to content

Conversation

@grod220
Copy link
Member

@grod220 grod220 commented Nov 6, 2025

Integrating feedback from Foundation

Problem

It's likely that a few high profile mint authorities will not consider the original deployment of token-wrap the one they want folks to use for their mint. They may prefer an alternative configuration (especially for token-2022s) and will fork+deploy their own. These authorities need a way to signal on-chain that a different token wrap deployment is the "canonical" one for their mint.

Solution

This PR adds a CanonicalPointer PDA which allows mint authorities to set a field with a pubkey to the alternative deployment. One instruction is added to create/update this PDA.

Edge cases

If there is no authority, a pointer cannot be created. If one is created and later the mint authority is set to None, the canonical pointer state is frozen as well.

Comment on lines 23 to 39
pub(crate) fn get_wrapped_mint_address_with_seed(
unwrapped_mint: &Pubkey,
wrapped_token_program_id: &Pubkey,
) -> (Pubkey, u8) {
get_wrapped_mint_address_with_seed_for_program(unwrapped_mint, wrapped_token_program_id, &id())
}

pub(crate) fn get_wrapped_mint_address_with_seed_for_program(
unwrapped_mint: &Pubkey,
wrapped_token_program_id: &Pubkey,
program_id: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&get_wrapped_mint_seeds(unwrapped_mint, wrapped_token_program_id),
&id(),
program_id,
)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a _for_program() variants to allow for these forks to utilize our package for their address lookups

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I'd just have them all just take program_id and not support duplicate versions of all of the helpers.

If this is easier for SemVer, though, nbd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id() is so deeply embedded into the program+clients that requiring the program_id is a far reaching change. I think I'll keep this forward compatible for now and revisit for a later breaking change if we find lots of folks forking and wanting the simpler name.

Copy link

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! A few nits, take them or leave them!

Comment on lines 23 to 39
pub(crate) fn get_wrapped_mint_address_with_seed(
unwrapped_mint: &Pubkey,
wrapped_token_program_id: &Pubkey,
) -> (Pubkey, u8) {
get_wrapped_mint_address_with_seed_for_program(unwrapped_mint, wrapped_token_program_id, &id())
}

pub(crate) fn get_wrapped_mint_address_with_seed_for_program(
unwrapped_mint: &Pubkey,
wrapped_token_program_id: &Pubkey,
program_id: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&get_wrapped_mint_seeds(unwrapped_mint, wrapped_token_program_id),
&id(),
program_id,
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I'd just have them all just take program_id and not support duplicate versions of all of the helpers.

If this is easier for SemVer, though, nbd.

Comment on lines 26 to 27
/// The mint authority of an unwrapped mint's on-chain signal another token-wrap
/// deployment is the "canonical" one.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this comment is a little bit confusing. Do you think we can clarify it a bit?

return Err(ProgramError::MissingRequiredSignature);
}

let mint_data = unwrapped_mint_info.try_borrow_data()?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking the mint's owner here? Maybe it's inconsequential, since the mint address can't be duplicated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, will add a check+test

@grod220 grod220 merged commit b7cfafc into main Nov 18, 2025
17 of 18 checks passed
@grod220 grod220 deleted the redirect-pointer branch November 18, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants