Skip to content

Comments

refactor: split ContractSelf into context-specific structs#20624

Merged
benesjan merged 3 commits intomerge-train/fairiesfrom
jan/split-contract-self
Feb 18, 2026
Merged

refactor: split ContractSelf into context-specific structs#20624
benesjan merged 3 commits intomerge-train/fairiesfrom
jan/split-contract-self

Conversation

@benesjan
Copy link
Contributor

@benesjan benesjan commented Feb 18, 2026

When I initially implemented ContractSelf I chose an incorrect pattern and that is having 1 ContractSelf struct for all the function types and then having there a generic Context param that specializes it for the given execution context. This has undesirable effects like needing to use unit types to disable certain functionality in utility and public contexts:

image

Another advantage with the change is that we follow the pattern of having PrivateContext, PublicContext and UtilityContext.

Summary

  • Split the monolithic ContractSelf generic struct into three context-specific structs: ContractSelfPrivate, ContractSelfPublic, and ContractSelfUtility
  • Each struct lives in its own file under contract_self/ and only carries the type parameters and fields relevant to its context (e.g. ContractSelfPublic has no enqueue_self/enqueue_self_static fields, ContractSelfUtility has no call/enqueue fields)
  • Updated all macro code generation to use the new struct names

Test plan

  • nargo compile --package nft_contract compiles successfully

🤖 Generated with Claude Code

@benesjan benesjan requested a review from nventuro as a code owner February 18, 2026 09:22
@benesjan benesjan marked this pull request as draft February 18, 2026 09:24
…blic, ContractSelfUtility

Each context-specific struct now lives in its own file under contract_self/ and only
contains the type parameters and fields relevant to that context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@benesjan benesjan force-pushed the jan/split-contract-self branch from 7cab322 to 5466b11 Compare February 18, 2026 09:30
@benesjan benesjan marked this pull request as ready for review February 18, 2026 09:37
@benesjan benesjan requested review from mverzilli and removed request for nventuro February 18, 2026 10:46
Copy link
Contributor

@mverzilli mverzilli left a comment

Choose a reason for hiding this comment

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

Nice!

@benesjan benesjan merged commit 9694858 into merge-train/fairies Feb 18, 2026
9 checks passed
@benesjan benesjan deleted the jan/split-contract-self branch February 18, 2026 14:10
github-merge-queue bot pushed a commit that referenced this pull request Feb 19, 2026
BEGIN_COMMIT_OVERRIDE
refactor: authwit not consumable when reject all is set (#20533)
fix: displaying debug logs from public function simulations (#20551)
fix: allow compiling mixed (contract + noir script) aztec project
(#20428)
refactor: split ContractSelf into context-specific structs (#20624)
feat: add optional additional scopes to wallet transaction API (#20487)
feat(aztec.js): add additionalScopes to ContractFunctionPattern in
capabilities (#20660)
END_COMMIT_OVERRIDE
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