跳到正文
cccskills
免费在 GitHub 公开

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.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(2)

  • SKILL.md2.6 KB
  • references/repo-patterns.md1.8 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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 new or try_new that reject invalid states up front.
  • Use TryFrom when 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::new and TryFrom<Term> validate that a case is a ground Prolog dict before it can circulate as a domain object.
  • Constitution::try_new validates UTF-8, required predicates, and engine feedback before a constitution exists as a valid domain value.
  • Constitution::from_state reconstructs a previously validated value from storage without re-running external validation.
  • Decision::new captures an immutable decision snapshot from already validated inputs.
  • Authority::new canonicalizes 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.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Best practices for designing CosmWasm smart contract APIs. Use when defining message types, designing execute/query interfaces, or optimizing API ergonomics.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

Guide for writing Rust doc comments that produce accurate generated contract documentation. Use when editing Instantiate/Execute/Query/Response types or any public schema-facing API.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

Guide for writing conventional commit messages. Use when committing changes, writing commit messages, or reviewing commit history.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

Axone contract structure and Abstract SDK patterns. Use when scaffolding or refactoring contracts, deciding layer boundaries, wiring AppContract entrypoints, or adding module metadata and replies.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

Axone deployment workflows with cargo-make, cw-orch, and Abstract. Use when publishing modules, installing them on accounts, running local chain tasks, or inspecting deployments.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

Guide for regenerating Axone contract schemas and rendered Markdown docs. Use when contract APIs or metadata change, when checking generated-doc drift, or when preparing documentation commits.

中文简介正在准备中。当前显示原文说明。

axone-protocol/contracts1232026年10月14日 更新

查看 axone-protocol 的全部技能

报告此技能的问题