Skip to content

docs: document entrypoints and errors in the spec - #277

Open
hpmaxi wants to merge 13 commits into
fix/ttl-on-creationfrom
docs/contract-spec
Open

hpmaxi wants to merge 13 commits into
fix/ttl-on-creationfrom
docs/contract-spec

Conversation

@hpmaxi

@hpmaxi hpmaxi commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #328

Most contract entrypoints had no doc, so the spec stored in each Wasm, which generated clients and block explorers read, said nothing about what a call does, its units, its errors or who signs. Two oracle errors had no doc, and two vault error docs described less than the code checks. Error codes followed no published range, although a failure inside a called contract reaches the caller with that contract's code.

Every entrypoint the kit defines or overrides, in all five contracts, now carries a short doc in OpenZeppelin's style that travels into the spec. Each contract's error codes sit in a published block, and the build fails if a code leaves it.

Changes

  • Every kit entrypoint and overridden trait method has a doc: summary, arguments with units, errors, events and signers (151 in all).
  • Every error variant says when it happens (103 in all).
  • Each contract declares its error enum through error_enum!; a code outside its block, or two overlapping blocks, fails the build.
  • The kit spec publishes the blocks and the codes in use, and how the docs name units, errors and signers.
  • A test fails when a contract doc outgrows the 1,024 bytes the spec keeps.

Deviations

  • The blocks and the macro live in strata-bindings, which all four contracts already use; a second check makes sure the blocks never overlap.
  • Docs list the errors a call can return while the contract's books are consistent. NotInitialized and AccountingMismatch mean they are not, so they are not listed per call; the kit spec says so.
  • Views carry no # Events or # Authorization section.
  • Also corrected the docs of InvalidAmount, WindDownActive, the vault's NotInitialized and the oracle's AdminRequired.
  • AGENTS.md gained one sentence pointing new error enums at error_enum!.

Acceptance criteria

  • Every public entrypoint and error variant of the five contracts has a doc in the built spec
  • Each doc fits the spec's 1,024-character limit
  • docs/kit-spec.md lists the ranges: oracle 3000–3999, vault 6000–6999, token 7000–7999, compliance 8000–8999
  • Moving a variant out of its range fails the build
  • Every contract stays well under the network's 131,072-byte size limit

Test plan

Automated tests

  1. SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_SPEC_SHAKING_V2=1 cargo test --locked: 707 passed, including two doctests on error_enum! (an in-range enum compiles; an out-of-range one fails with E0080) and every_contract_doc_fits_the_spec, which fails when a doc is longer than 1,024 bytes.
  2. cargo clippy --locked --all-targets -- -D warnings on every touched crate, also with short_wind_down and upgrade_probe: clean.
  3. The Wasm upgrade tests (--features upgrade_wasm with_wasm): vault 5, oracle 2, passed.

Manual verification

  1. stellar contract build, then stellar contract info interface --wasm target/wasm32v1-none/release/async_vault.wasm: each function shows its doc.
  2. Set InvalidCustodian = 7075 in contracts/async-vault/src/error.rs and run cargo check -p async-vault: it fails with VaultError::InvalidCustodian is outside its contract's error range.
  3. Each spec, docs blanked, matches the base: same functions, types, events and error codes. The code section of every Wasm is unchanged.
  4. TypeScript clients generated from the new Wasm type-check.

Built size (bytes) against the 131,072-byte limit:

Contract Before After Room left
async_vault 73,163 91,231 39,841 (30%)
share_token 42,919 55,355 75,717 (58%)
nav_oracle 33,080 40,133 90,939 (69%)
compliance 24,371 30,667 100,405 (77%)
identity_verifier 4,115 4,963 126,109 (96%)

Breaking changes

None. Signatures, types, events and error codes are unchanged; only the docs in each spec differ, so every Wasm hash changes.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

Each kit contract owns a block of error codes, and a failure inside a
called contract reaches the caller with that contract's code. The blocks
live in strata-bindings with a check that they never overlap, and
error_enum! declares an error enum whose build fails when a variant's code
leaves its contract's block.
The oracle, vault, share token and compliance enums go through
error_enum!, so a variant outside 3000-3999, 6000-6999, 7000-7999 or
8000-8999 fails the build.

Every variant now says when it happens: InvalidConfig and NoRecord get a
doc, and AmountTooLarge, AccountingMismatch, InvalidAmount,
WindDownActive, NotInitialized and the oracle's AdminRequired describe
what the code checks. Each enum's doc names its range.
Every oracle entrypoint and the trait methods it overrides carry a doc in
the contract spec: a summary, the arguments with units, the errors, the
events and who signs.
Every entrypoint of the compliance and identity verifier stubs, and each
trait method they override, carries a doc in the contract spec.
Every share token entrypoint, and each OpenZeppelin method it overrides,
carries a doc in the contract spec, including the library errors a call
can return.
Every vault entrypoint, view and overridden trait method carries a doc in
the contract spec. Amounts are in asset base units, shares in share base
units, prices in WAD and times in seconds. Each doc lists the errors the
call can return in a consistent state, its events and who signs.
The kit spec lists each contract's error block and the codes in use, and
says how the entrypoint docs name units, errors and signers. AGENTS.md
points new error enums at error_enum!.
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Oct 23, 2026 3:32pm UTC

Request Review

The contract spec keeps the first 1,024 bytes of a doc and drops the rest
without a warning, so an over-long doc loses its end, where the
`# Authorization` section sits. The test joins every function, enum and
variant doc of the five contracts the way soroban-sdk-macros does and
fails on any doc over the limit.
A valid report accepted after the close refuses a cancellation even while
the notice runs, so PriceAvailable says that instead of "can be priced
now". The constructor reads compliance only for the distinctness check
and never reads attester. Payouts name the asset's own error when the
holder cannot receive, legal_transfer lists TokensUnfrozen, and the
ReserveCommittedToExits and WindDownActive docs and the kit spec's note
on shared OpenZeppelin codes say what the code does.
@hpmaxi
hpmaxi marked this pull request as ready for review October 20, 2026 08:11

This branch was successfully deployed

1 active deployment
Preview — 4cb765da Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant