-
Notifications
You must be signed in to change notification settings - Fork 44
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
Implement multi read parent read params usage #1062
Conversation
// this works by having hard coder codec modifier define fields that are filled out by subsequent reads. | ||
multiRead []string | ||
// reads of size one is a regular Account read. | ||
// When multiple read reads are present, first read has type info that other sequential reads are filling out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should "multiple read reads" say "multiple reads"?
|
#[account( | ||
init_if_needed, | ||
payer = signer, | ||
space = size_of::<MultiRead3>() + 8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: instead of doing this size_of::
, the Anchor way of doing this is to:
- Add
#[derive(InitSpace)]
to the struct - Use
MultRead3::INIT_SPACE
here
See the docs. That way it will also handle some other types, such as vectors (where you can specify amax_len
to it for example).
Description
Enables CR to multi read same PDA account multiple times, this is useful for handling very complex chain agnostic <> chain specific data restructuring without having to immediately develop new codec modifiers.