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: Refactor StateWithExtensionsMut functionality into trait #6329

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

joncinque
Copy link
Contributor

Problem

As part of moving token-2022 to Pod-style deserialization in #6316, we'll eventually need to make new PodStateWithExtensions*, in which the BaseState itself is a Pod type.

That's easy for the non-mutable case, since we have BaseStateWithExtensions that neatly encompasses all of the functionality on a trait. We don't have a mutable version of BaseStateWithExtensions.

Solution

Create BaseStateWithExtensionsMut. This essentially moves all of the common functionality of StateWithExtensionsMut into a trait requiring only two functions:

  • get_tlv_data_mut: just the mutable verison of get_tlv_data in BaseStateWithExtensions
  • get_account_type_mut: some way to access the account type part of the slice in a mutable way, so that it can be written to during initialization

This PR contains no functional changes, just moving functionality to the new trait.

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

One small question, one suggestion for deduping

token/program-2022/src/extension/mod.rs Show resolved Hide resolved
token/program-2022/src/extension/mod.rs Outdated Show resolved Hide resolved
@joncinque joncinque merged commit a42d7bd into solana-labs:master Mar 5, 2024
35 checks passed
@joncinque joncinque deleted the tk22swemut branch March 5, 2024 10:22
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