spec: rule 3 assumes one enum per contract, which shared error types break

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript
Lĩnh vực
documentation

Hướng nghiên cứu

Start by reading SPEC.md rule 3, rule 4, and the reference allocation table. Decide whether shared #[contracterror] enums should be permitted or discouraged, and check prior art from Soroban workspaces as the issue suggests. Update the spec so its rules and allocation table agree; done means it explains the chosen policy and, if relevant, how existing shared enums should migrate.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

good first issue spec

Which rule

SPEC.md rule 3, "Each contract MUST own exactly one block", and by extension the whole framing that an enum corresponds to a contract.

The layout it does not fit

A workspace with a shared error crate:

contracts/
  shared/src/error.rs      // pub enum CommonError
  token/src/error.rs       // pub enum TokenError
  router/src/error.rs      // pub enum RouterError

CommonError is re-exported and returned by three contracts. Under the current spec it needs a block, but it is not a contract, and a caller receiving one of its codes genuinely cannot tell which contract produced it — which rule 4 exists to prevent.

The reference allocation gestures at this with a 900-999 row labelled "shared / library errors", but the rules never actually say how a shared type is meant to work, so the table and the rules disagree.

The real question

Is a shared error enum acceptable at all?

There is a coherent argument that it is not: if the caller cannot identify the origin, the error is less useful, and the fix is per-contract enums that wrap or duplicate the shared variants. There is an equally coherent argument that duplicating "unauthorized" across six contracts is worse, and that the origin belongs in the transaction data rather than the code.

The spec should pick one and say why. Right now it silently assumes the problem does not exist.

Suggested resolution

Either:

  • (a) Explicitly permit shared enums, require them to sit in a designated shared block, and add a note that codes in that block do not identify a contract; or
  • (b) Recommend against them, with a short migration sketch for workspaces that already have one.

Whichever is chosen, rule 3 needs rewording from "contract" to "#[contracterror] enum", since that is what the tooling actually keys on.

Good first issue because

This is a documentation and reasoning change, not code. Prior art from a real Soroban workspace that has solved it either way would be the most valuable thing anyone could add here.

Ngôn ngữ chính
JavaScript
Star
0
Fork
1
Merge trung bình
14 giờ 38 phút
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codepacct/codepact-conventions

Tất cả issue của codepacct/codepact-conventions

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.