rust-contract-domain-modeling
Domain-driven modeling patterns for Axone contracts. Use when introducing domain concepts, encoding invariants, or deciding boundaries between domain, handlers, services, gateways, queries, and state.
For you if you are doing domain-driven design on Axone contracts
/ 下载安装
/ 通过 npx 安装 校验哈希
npx oh-my-skill add axone-protocol/contracts/rust-contract-domain-modeling/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- axone-protocol/contracts/rust-contract-domain-modeling/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify axone-protocol/contracts/rust-contract-domain-modeling安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
124GitHub stars
~525最小装载
~903含声明引用
~903文本包总量
索引托管
怎么用
商店整理自技能原文 · 版本 7a14fd6 · 表述以原文为准它做什么
安装后,Claude 会帮你把业务规则封装到专门的领域层(domain/)中,而不是分散在处理、查询或存储代码里。它建议使用构造函数(如 new、try_new)来拒绝无效数据。
什么时候触发
当你在设计 Axone 合约时,引入领域概念、编码不变约束,或决定 domain、handlers、services、gateways、queries、state 等层的边界时触发。
装好后可以这样说
Claude 会按边界规则给出建议。
Claude 会推荐构造函数和 TryFrom 模式。
技能原文 SKILL.md
Rust Contract Domain Modeling
Goal
Keep business invariants in explicit domain types instead of scattering them across handlers, query builders, or storage code.
Boundary Rules
domain/owns business concepts and invariants.handlers/decode messages, orchestrate use cases, and shape responses.services/compose domain logic with environment-dependent enrichment or cross-module coordination.gateway/isolates external module interaction and protocol-specific I/O.queries/build external query payloads or request strings; they should not become the home of business rules.state/persists data and reconstructs domain values; it should not silently redefine domain invariants.
Domain Rules
- Prefer constructors such as
newortry_newthat reject invalid states up front. - Use
TryFromwhen validating a parsed or transport-level representation into a domain type. - Keep domain methods deterministic and side-effect-light whenever possible.
- If a value is reconstructed from trusted state, make that explicit with a constructor such as
from_state. - Model canonical representations once in the domain layer, then reuse them everywhere else.
Patterns From This Repository
Case::newandTryFrom<Term>validate that a case is a ground Prolog dict before it can circulate as a domain object.Constitution::try_newvalidates UTF-8, required predicates, and engine feedback before a constitution exists as a valid domain value.Constitution::from_statereconstructs a previously validated value from storage without re-running external validation.Decision::newcaptures an immutable decision snapshot from already validated inputs.Authority::newcanonicalizes a bech32 account into the DID form exposed by the contract.
Design Heuristics
- Put parsing and invariant checks as close as possible to the creation of the domain object.
- Keep handlers thin. If a handler starts accumulating validation branches, move that logic into a domain type or service.
- Avoid passing partially validated strings through multiple layers when a dedicated type can encode the guarantee once.
- Make invalid states unrepresentable where practical, especially for smart-contract-critical logic.
References
- For concrete domain examples from this repository, read [repo-patterns](./references/repo-patterns.md).
按 BSD-3-Clause 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…