[Stellar] Add toggle to switch from default to explicit trait implementation#728
Merged
CoveMB merged 80 commits intoOpenZeppelin:masterfrom Jan 14, 2026
Merged
Conversation
Co-authored-by: Eric Lau <ericglau@outlook.com>
Co-authored-by: Eric Lau <ericglau@outlook.com>
Co-authored-by: Eric Lau <ericglau@outlook.com>
Member
|
The comments above need to be addressed before this can be merged. |
brozorec
approved these changes
Dec 18, 2025
Contributor
brozorec
left a comment
There was a problem hiding this comment.
LGTM 👍
I'd also suggest bumping the version to 0.5.1
…ntracts-wizard into stellar-default_impl_attribute
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #706
Summary
Enable UI and tooling to use explicit Soroban trait implementations instead of relying solely on
#[default_impl], adding regression coverage and docs for the new option.Motivation / Context
Contract authors asked for a way to inspect and customize every generated Soroban trait function instead of depending on
#[default_impl]. This work exposes that capability in the builders, UI, and MCP tools without changing the default experience.Changes
Description
packages/core/stellar/src/common-options.ts:10-36and the builder defaults now carry anexplicitImplementationsflag so every contract kind can opt in to non-macro trait bodies.packages/core/stellar/src/contract.ts:188-192introducesaddTraitForEachFunctions, letting trait mixins add all functions programmatically when macros are disabled.packages/core/stellar/src/set-access-control.ts:18-235,packages/core/stellar/src/add-pausable.ts:4-44,packages/core/stellar/src/add-upgradeable.ts:4-45) accept the flag, generate Ownable/AccessControl function bodies, and still enforce the same role/owner checks.packages/core/stellar/src/fungible.ts:25-210,packages/core/stellar/src/non-fungible.ts:28-305,packages/core/stellar/src/stablecoin.ts:48-101) and update generation blueprints so option sweeps include the new mode.packages/ui/src/stellar/TraitImplementationSection.svelte:1-33plus imports in each controls file) while schemas/prompts describe and validate it (packages/mcp/src/stellar/schemas.ts:24-35,packages/mcp/src/stellar/tools/fungible.ts:10-40,packages/common/src/ai/descriptions/stellar.ts:12-20).packages/core/stellar/src/*.compile.test.ts,packages/core/stellar/src/*.test.ts/.md,packages/mcp/src/stellar/tools/*.test.ts).Affected Functions
packages/core/stellar/src/contract.ts:188— newaddTraitForEachFunctionshelper to bulk-attach trait methods when macros are skipped.packages/core/stellar/src/set-access-control.ts:18—setAccessControlaccepts the explicit flag and adds per-function trait impls for Ownable/AccessControl when needed.packages/core/stellar/src/set-access-control.ts:84—requireAccessControlforwards the explicit flag so pausable/upgradeable traits stay consistent.packages/core/stellar/src/add-pausable.ts:4&packages/core/stellar/src/add-upgradeable.ts:4— feature mixins now require the explicit flag and pass it through to access control.packages/core/stellar/src/fungible.ts:63&:137— base, burnable, and mintable helpers emit explicit trait functions when requested.packages/core/stellar/src/non-fungible.ts:91&:212— non-fungible base, burnable/enumerable/consecutive modules support explicit implementations.packages/core/stellar/src/stablecoin.ts:48— limitation helpers forward the flag so allow/blocklist operations can be emitted explicitly.Security Impact
requireAccessControlfor gating.Testing
explicitImplementationsenabled (packages/core/stellar/src/fungible.compile.test.ts,non-fungible.compile.test.ts,stablecoin.compile.test.ts).packages/core/stellar/src/*.test.ts,.md,.snap, andpackages/mcp/src/stellar/tools/*.test.ts).Manual verification:
#[default_impl]and shows explicit bodies.pnpm test --filter='packages/core/stellar/src/*explicit*'and the relevant MCP tool tests to ensure the new flag compiles cleanly.Backward Compatibility
#[default_impl]unless the new toggle is enabled.