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

token 2022: make IncorrectMintAuthority a TokenError #5596

Conversation

buffalojoec
Copy link
Contributor

This PR makes IncorrectMintAuthority a TokenError, rather than a TokenMetadataError, since it will likely be used across multiple extension processors (such as SPL Token Group).

@buffalojoec buffalojoec force-pushed the 10-18-token_2022_move_update_authority_check_to_shared_file branch from 58ac7c2 to da87e3e Compare October 18, 2023 13:44
@buffalojoec buffalojoec force-pushed the 10-18-token_2022_make_IncorrectMintAuthority_a_TokenError_ branch from 2776f2e to 82f3418 Compare October 18, 2023 13:44
@buffalojoec buffalojoec force-pushed the 10-18-token_2022_move_update_authority_check_to_shared_file branch from da87e3e to 7e44111 Compare October 18, 2023 13:50
@buffalojoec buffalojoec force-pushed the 10-18-token_2022_make_IncorrectMintAuthority_a_TokenError_ branch from 82f3418 to 31ee52e Compare October 18, 2023 13:50
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Can we instead switch to the current TokenError::OwnerMismatch instead of adding a new error?

@buffalojoec
Copy link
Contributor Author

Can we instead switch to the current TokenError::OwnerMismatch instead of adding a new error?

Wouldn't that be confusing to some people since the mint authority is a separate thing from the owner?

@joncinque
Copy link
Contributor

Wouldn't that be confusing to some people since the mint authority is a separate thing from the owner?

It's true that Owner is a very overloaded term in token, and especially in token-2022. Anytime we validate an owner or authority (freeze, transfer fee, confidential transfer, metadata, metadata pointer, transfer hook, etc etc etc), we call validate_owner, which can return OwnerMismatch.

If we want to maintain ABI compatibility in Token-2022, it must return the same errors as tokenkeg for things like mint, freeze, and owner. We can make a new error for the other authorities though, and potentially use that new error in instructions that aren't present in tokenkeg. That seems like it'll be needlessly brittle and prone to error though.

We can also decide to break ABI compatibility, but it seems like a lot of work just to fix error text. We could also change the name OwnerMismatch to something else, but that might cause other kinds of confusion.

So to me, since we don't have a great alternative, I prefer to stick with what we have in OwnerMismatch, even though it's imperfect. What do you think?

@buffalojoec
Copy link
Contributor Author

We can also decide to break ABI compatibility, but it seems like a lot of work just to fix error text. We could also change the name OwnerMismatch to something else, but that might cause other kinds of confusion.

No, we definitely don't want to break ABI compatibility or rename the enum variant.

We can make a new error for the other authorities though, and potentially use that new error in instructions that aren't present in tokenkeg. That seems like it'll be needlessly brittle and prone to error though.

This was what I was going for - particularly for SPL Token Metadata. However, if on the Tokenkeg/Token2022 side of things we're throwing OwnerMismatch on mint authority checks, then it makes sense to just follow that pattern with SPL Token Metadata.

So to me, since we don't have a great alternative, I prefer to stick with what we have in OwnerMismatch, even though it's imperfect. What do you think?

Yeah, that sounds like the best move here. I'll update the changes.

@buffalojoec
Copy link
Contributor Author

Going to submit a new PR for the above and close this one.

@buffalojoec buffalojoec force-pushed the 10-18-token_2022_move_update_authority_check_to_shared_file branch from 7e44111 to 85939c3 Compare October 19, 2023 15:21
@buffalojoec buffalojoec force-pushed the 10-18-token_2022_move_update_authority_check_to_shared_file branch from 85939c3 to f103552 Compare October 19, 2023 15:26
@buffalojoec buffalojoec deleted the 10-18-token_2022_make_IncorrectMintAuthority_a_TokenError_ branch February 23, 2024 21:37
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.

2 participants