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

Implement multi read parent read params usage #1062

Merged
merged 8 commits into from
Feb 11, 2025

Conversation

ilija42
Copy link
Contributor

@ilija42 ilija42 commented Feb 11, 2025

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.

// 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.
Copy link
Contributor

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"?

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
35.3% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

@chris-de-leon-cll chris-de-leon-cll merged commit f689da7 into develop Feb 11, 2025
34 of 36 checks passed
@chris-de-leon-cll chris-de-leon-cll deleted the change-multiread branch February 11, 2025 19:50
#[account(
init_if_needed,
payer = signer,
space = size_of::<MultiRead3>() + 8,
Copy link

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 a max_len to it for example).

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.

6 participants