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

Feature Request: Union Account Loaders #2211

Closed
mgild opened this issue Oct 7, 2022 · 1 comment
Closed

Feature Request: Union Account Loaders #2211

mgild opened this issue Oct 7, 2022 · 1 comment

Comments

@mgild
Copy link
Contributor

mgild commented Oct 7, 2022

If I am versioning an account type in an action, it would be great to support something like

#[derive(Accounts)]
pub struct ExampleAction<'info> {
    pub union: UnionAccountLoader<'info, AccountDataV1, AccountDataV2>,
}

This could be extended to support optional accounts as well

#[derive(Accounts)]
pub struct ExampleAction<'info> {
    pub optional: UnionAccountLoader<'info, OptionalAccount, None>,
}

Perhaps None could be a special case since it is not a type, but then load and load_mut could also take the type you are trying to load as well.

@Henry-E
Copy link
Contributor

Henry-E commented Dec 7, 2022

I'm not sure how feasible it is for us to support a list of possible generic types for accounts. However, there is an optional account feature coming to anchor that has syntax more like Option<UnionAccountLoader<'info, OptionalAccount>>. Check out #2101

@Henry-E Henry-E closed this as completed Dec 7, 2022
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

No branches or pull requests

2 participants