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

Aperta
#3 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
javascript
Ambito
documentation

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
0
Fork
1
Merge medio
14h 38m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codepacct/codepact-conventions

Tutte le issue di codepacct/codepact-conventions

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.