docs(soroban): add per-contract API reference and consolidated error table#20
Merged
Meshmulla merged 1 commit intoJul 24, 2026
Conversation
…table soroban/src/ has ~35 contract modules with no unified reference for their public entry points or error codes, so contributors had to read each source file directly (stellar-kracken#12). - soroban/docs/API_REFERENCE.md: every public function under soroban/src/, with arguments, authorization requirements, and emitted events, derived from each function's doc comment where one exists. Grouped by what's actually compiled into the release wasm build vs. cfg(test)-only standalone contracts vs. files unreferenced by any build target - distinctions not otherwise documented anywhere. - soroban/docs/ERRORS.md: every #[contracterror] numeric code across the workspace, grouped by originating contract, plus a check that each contract's own codes are contiguous and collision-free. - README.md: links to both new docs. Closes stellar-kracken#12
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this resolves
soroban/src/has ~35 contract modules with no unified reference for their public entry points or error codes, so contributors and integrators had to read each source file directly to understand what's callable, what auth it requires, or what a given error code means (#12).Approach
soroban/docs/API_REFERENCE.md— every public function undersoroban/src/: signature, arguments, authorization requirement, and emitted events. Descriptions are derived from each function's///doc comment where one exists (most modules already had good rustdoc-style comments); where a module had none (alert_system,analytics_aggregator,circuit_breaker,operator_rotation,report_hash,source_blessing,threshold_window,version_migration_helper, plus gaps ingovernance,bridge_reserve_verifier,insurance_pool), the description was written by reading the function body.While mapping this out, it became clear
soroban/src/mixes three very different compilation states that aren't documented anywhere:BridgeWatchContract(lib.rs) plusEmergencyFundRecovery, the only two#[contract]types unconditionally compiled into the releasewasm32-unknown-unknownbuild.cfg(test)-only standalone contracts — 11 modules (governance,insurance_pool,asset_registry,rate_limiter, etc.) each define their own#[contract]type but are gated to avoid wasm symbol collisions withBridgeWatchContract, per the existing comment inlib.rs. They're compiled and tested bycargo test, but excluded from the release wasm artifact.alert_system.rs,fee_distribution.rs,bridge_reserve_verifier.rs, etc.) have nomoddeclaration or#[path]include anywhere in the workspace, so they're never compiled by any build target and their inline test suites never run in CI.The reference is organized around this so nobody mistakes a
cfg(test)-only or unreferenced module for something that's actually live.soroban/docs/ERRORS.md— every#[contracterror]numeric code (8 enums, ~100 codes total) grouped by originating contract, plus a verification that each contract's own codes are contiguous starting at 1 with no gaps or duplicates. Also flags thatmigration.rsandversion_migration_helper.rsboth define aMigrationErrortype (different, non-colliding Rust types, since they're#[contracttype]result variants rather than numeric error codes — but same name, worth knowing).README.md— links to both new docs.Scope note: per the issue's own "Where to look" pointers, this covers
soroban/src/andsoroban/docs/only, notescrow_contract/ortransfer_state_machine/.How this was tested
#[contracterror]enum discriminants in source.API_REFERENCE.mdandERRORS.md) resolves against a real heading using GitHub's heading-slug algorithm..rsfiles touched), but ran the full CI checklist locally to confirm nothing regressed:cargo fmt --all -- --check— passcargo clippy --all-targets --all-features -- -D warnings— passcargo build --release --target wasm32-unknown-unknown— passcargo test(full workspace) — 506+ tests pass, 0 failedCloses #12