feat(v2): Compile-time required constraints for AnchorAccount#4503
Open
chop0 wants to merge 1 commit into
Open
feat(v2): Compile-time required constraints for AnchorAccount#4503chop0 wants to merge 1 commit into
chop0 wants to merge 1 commit into
Conversation
Custom AnchorAccount types can now declare a type-level list of AccountConstraint markers that every #[account(...)] usage must apply. The derive macro emits a const-block superset assertion per field; missing required constraints fail to compile. - traits.rs: ConstraintList, Find<C, Idx> (frunk Here/There index trick), IsSuperset<R, I>, plus required_constraints![] helper macro. - AnchorAccount gains `type RequiredConstraints: ConstraintList`. Built-in wrappers default to (); Box<T> forwards from inner T. - derive: per-field assertion built from attrs.namespaced and spliced beside the impl TryAccounts block. - tests-v2/programs/custom-constraints: TestAccount<T> (1 required) and TestMultiAccount<T> (2 required) wrappers + handlers covering single, multi (reverse-order), Box<TestAccount> forwarding, update(...) satisfaction. - tests-v2/tests/ui_required_constraints: trybuild compile-fail snapshots for missing and partial requirements.
|
@chop0 is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
Can you fix the compile-fail test issues? |
Contributor
|
@chop0 id be happy to help with the compile tests if you want, i saw in the discord u were gonna take a look this morning, but if you want me to help out let me know |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Custom AnchorAccount types can now declare a type-level list of AccountConstraint markers that every #[account(...)] usage must apply. The derive macro emits a const-block superset assertion per field; missing required constraints fail to compile.
type RequiredConstraints: ConstraintList. Built-in wrappers default to (); Box forwards from inner T.