rust-contract-domain-modeling

Codifies Axone contract domain invariants to prevent logic leakage across handlers and services.

124|19|Updated Jul 11, 2022
One-click install
npx skills add https://github.com/axone-protocol/contracts --skill rust-contract-domain-modeling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-contract-domain-modeling
Source: https://github.com/axone-protocol/contracts/tree/main/.agents/skills/rust-contract-domain-modeling
Command: npx skills add https://github.com/axone-protocol/contracts --skill rust-contract-domain-modeling

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Domain-driven modeling patterns centralize invariants and boundaries in AXONE smart contracts, reducing drift between domain concepts and implementation.

Core Features & Use Cases

  • Defines domain-owned invariants and canonical representations to prevent leakage of business rules into handlers and storage.
  • Provides constructors such as new, try_new, and from_state to guarantee valid domain state and safe reconstruction.
  • Guides cross-layer design by clarifying the roles of domain, handlers, services, gateway, queries, and state in AXONE contracts.

Quick Start

Create a simple domain object with a validated constructor and demonstrate reconstruction from persisted state to illustrate the pattern.

Frequently Asked Questions about rust-contract-domain-modeling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce domain invariants in Rust smart contracts?

You enforce domain invariants in Rust smart contracts by centralizing boundary checks and canonical representations within domain-owned constructors, preventing business rule leakage into handlers and state storage.

What is the best way to prevent logic leakage in Axone contracts?

The best way to prevent logic leakage in Axone contracts is applying domain-driven modeling patterns that codify invariants at the domain layer, explicitly separating domain logic from handlers, services, and gateway boundaries.

How do I safely reconstruct domain state from persisted storage in Axone?

You safely reconstruct domain state from persisted storage by using dedicated constructors like `from_state` and `try_new`, which validate data against domain rules during the reconstruction process to guarantee validity.

Why do I need explicit domain constructors for smart contract modeling?

Explicit domain constructors are needed for smart contract modeling to ensure valid domain state creation, enforce boundary checks at instantiation, and maintain canonical representations across cross-layer components like services and queries.

When should I use domain-driven modeling patterns for Axone contract governance?

You should use domain-driven modeling patterns for Axone contract governance when you need to codify governance-related domain rules, ensuring invariants are explicitly defined and preventing unauthorized state transitions across contract boundaries.

Does domain-driven modeling require specific Rust dependencies for Axone state validation?

Domain-driven modeling for Axone state validation does not require external dependencies, as it relies on native Rust constructors and boundary checks to implement canonical representations and safe state reconstruction directly.