Skip to content
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

Rename TokenMetadataInitialize field token_program_id to program_id #3073

Closed
jacksondoherty opened this issue Jul 7, 2024 · 3 comments
Closed
Labels
enhancement New feature or request spl

Comments

@jacksondoherty
Copy link
Contributor

This better matches the spl_token_metadata_interface::instruction::initialize function.

The Token Metadata Interface (sRFC 17) is designed to work with external metadata programs, not just Token2022. These external programs might not be token programs, just metadata implementations.

In this example, I pass set an external metadata program as the token_program_id field which works but is confusing.

let accounts = TokenMetadataInitialize {
    token_program_id: ctx.accounts.metadata_program.to_account_info(), // <-- Here
    mint: ctx.accounts.mint.to_account_info(),
    metadata: ctx.accounts.metadata.to_account_info(),
    mint_authority: ctx.accounts.vending_machine_pda.to_account_info(),
    update_authority: ctx.accounts.vending_machine_pda.to_account_info(),
};
let vending_machine_pda_seeds: &[&[u8]; 2] = &[
    VENDING_MACHINE_PDA_SEED.as_bytes(),
    &[ctx.bumps.vending_machine_pda],
];
let signer_seeds = &[&vending_machine_pda_seeds[..]];
let cpi_ctx = CpiContext::new_with_signer(
    ctx.accounts.metadata_program.to_account_info(),
    accounts,
    signer_seeds,
);
token_metadata_initialize(
    cpi_ctx,
    token_metadata.name,
    token_metadata.symbol,
    token_metadata.uri,
)?;
@jacksondoherty
Copy link
Contributor Author

If this moves ahead, we should do similarly for TokenGroupInitialize and TokenMemberInitialize

@acheroncrypto acheroncrypto added enhancement New feature or request spl labels Jul 8, 2024
@acheroncrypto
Copy link
Collaborator

I'm usually against making breaking name changes, but we can make an exception for this case since all other fields looks to be the exact same as the spl_token_metadata_interface::instruction::initialize function's parameters, so it makes sense program_id is also the same. It also wouldn't be difficult to adapt this change since it's the only field that changes.

Happy to take a look if you'd like to make a PR for this.

@jacksondoherty
Copy link
Contributor Author

PR here: #3076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request spl
Projects
None yet
Development

No branches or pull requests

2 participants