Skip to content

feat: Introduce AccountCodeInterface and trait AccountComponentInterface#2924

Draft
PhilippGackstatter wants to merge 7 commits into
nextfrom
pgackst-claude/account-interface-v2
Draft

feat: Introduce AccountCodeInterface and trait AccountComponentInterface#2924
PhilippGackstatter wants to merge 7 commits into
nextfrom
pgackst-claude/account-interface-v2

Conversation

@PhilippGackstatter
Copy link
Copy Markdown
Contributor

Introduces AccountCodeInterface and trait AccountComponentInterface as motivated in #2621.

I renamed AccountInterface to AccountCodeInterface because it conceptually deals with the code of an account, so this seemed more precise and less generic.

The dependencies of each component are implemented, but are not yet used by the AccountBuilder, which would be done in another PR.

The component interface is added as V2 and is intended to replace the existing AccountComponentInterface in a future PR.

One difficulty we encounter here is:

pub trait AccountComponentInterfaceV2: Into<AccountComponent> { ... }

The interface requires Into<AccountComponent>, but the TokenPolicyManager is an example of a component that does not implement it, because we use another pattern for constructing this component: impl IntoIterator for TokenPolicyManager which yields AccountComponents. We would need an OR relationship here, either implement one or the other, but this is difficult to express.

claude and others added 7 commits May 13, 2026 15:07
… helper

Pulls the const-fn validator out of StorageSlotName into a new internal
name_validation module so the same rules can be reused by an upcoming
AccountComponentName type. StorageSlotName now delegates to the helper and
exhaustively maps each internal error variant onto its StorageSlotNameError
counterpart.
Introduces a validated newtype for canonical component names:

- AccountComponentName: a Cow<'static, str>-backed newtype with a const
  fn from_static_str constructor (so hard-coded NAME constants can become
  typed names at compile time without runtime allocation) and a runtime
  fallible new() constructor. Display, FromStr, TryFrom, From-into-String
  are provided; PartialEq, Eq, Hash, PartialOrd, Ord are derived through
  Cow's content-based impls.
- AccountComponentNameError: public error mirroring StorageSlotNameError,
  populated by an exhaustive map from the internal NameValidationError
  that was extracted in the prior commit.

Validation is delegated to the shared name_validation helper, so the
syntactic rules stay in lockstep with StorageSlotName.
Adds an inherent `pub const fn name() -> AccountComponentName` method to
every leaf standard component, returning the canonical typed component
name built via AccountComponentName::from_static_str(Self::NAME):

- BasicWallet, FungibleFaucet, TokenPolicyManager
- AuthSingleSig, AuthSingleSigAcl, AuthMultisig, AuthGuardedMultisig,
  NoAuth, AuthNetworkAccount
- Ownable2Step, RoleBasedAccessControl
- MintAllowAll, MintOwnerOnly, BurnAllowAll, BurnOwnerOnly

Renames the existing FungibleFaucet::name(&self) -> &TokenName accessor to
token_name() so the new associated AccountComponentName constructor can
keep the canonical name() identifier.
Introduces the next-generation account-interface types:

- AccountComponentDependency: enum supporting both name-based static
  dependencies (Name(AccountComponentName)) and procedure-root-based
  dynamic dependencies (Procedure { description, root }).
- AccountCodeInterface: struct holding an account id and the set of
  procedure roots exposed by an account, with a contains() helper. The
  constructor enforces the [AccountCode::MIN_NUM_PROCEDURES,
  AccountCode::MAX_NUM_PROCEDURES] range and returns
  AccountCodeInterfaceError on violation.
- AccountComponentInterfaceV2: trait with Into<AccountComponent> as a
  supertrait and a defaulted empty dependencies() method.

Account and PartialAccount each get an inherent code_interface() method
that produces the corresponding AccountCodeInterface. These are
infallible because the underlying AccountCode already enforces the
procedure-count invariant.

Each of the four new items (code_interface, component_interface,
dependency, name) lives in its own submodule of account::interface.
…ents

Adds `impl AccountComponentInterfaceV2 for X` to every leaf standard
component. Dependencies are wired per the design comment on the tracking
issue:

- FungibleFaucet -> Name(TokenPolicyManager)
- RoleBasedAccessControl, MintOwnerOnly, BurnOwnerOnly -> Name(Ownable2Step)
- TokenPolicyManager emits Procedure dependencies for its active and extra
  allowed mint/burn policy roots, exercising the dynamic dependency kind.

TokenPolicyManager already implements IntoIterator<Item=AccountComponent>;
adds a From<TokenPolicyManager> for AccountComponent that produces just
the manager component to satisfy the trait's Into<AccountComponent>
supertrait.
@PhilippGackstatter PhilippGackstatter added the pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority label May 13, 2026
Base automatically changed from pgackst-claude/account-component-name to next May 20, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants