Description
docs/interfaces/vault.json is described in README.md as the canonical, machine-readable reference for backend integrators using @stellar/stellar-sdk, but it has drifted from the implementation in contracts/vault/src/lib.rs. It documents string panics (e.g. "vault is paused", "amount must be positive") even though every entrypoint now returns typed VaultError codes; it is missing error code 29 (DuplicateRequestId); and it omits many public functions that exist in the contract. This makes the JSON misleading for integrators and out of sync with EVENT_SCHEMA.md.
Requirements and context
Functional — reconcile docs/interfaces/vault.json against contracts/vault/src/lib.rs:
- Replace string-panic
panics arrays with the typed VaultError variant each entrypoint actually returns (the enum is at contracts/vault/src/lib.rs:42–:106; e.g. Paused (4), AmountNotPositive (6), ExceedsMaxDeduct (7), InsufficientBalance (5)).
- Add the missing error code
{ "code": 29, "name": "DuplicateRequestId" } to errors.codes.
- Add the missing public functions to the
functions array, including: set_max_deduct (:479), set_price / get_price (:1035 / :1060), remove_metadata (:1103), set_revenue_pool (:956), get_revenue_pool (:350), get_contract_addresses (:366), clear_allowed_depositors (:526), get_allowed_depositors (:407), is_request_processed (:1188), upgrade (:1142), version (:1164), and the allowlist aliases add_address / clear_all / get_allowlist (:1251–:1286).
- Ensure each documented function's
params, returns, access, and events match the source (e.g. deduct takes request_id: Option<Symbol>, returns i128).
- Remove the duplicated
set_metadata / get_metadata / require_owner entries currently listed twice in the JSON.
- Add a short backend integration guide (Markdown) that walks an integrator through:
init -> set_settlement -> set_authorized_caller -> deposit -> deduct(request_id) -> reading balances, built directly from the JSON interface and EVENT_SCHEMA.md. Cross-link it from README.md and docs/interfaces/README.md.
Non-functional / repo conventions
- Keep the JSON schema shape consistent with
docs/interfaces/settlement.json and docs/interfaces/revenue_pool.json.
- This is a docs-only change — no contract code edits — but the JSON must be validated against the actual
lib.rs symbols.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch
git checkout -b docs/vault-interface-refresh
2. Implement changes
docs/interfaces/vault.json — reconcile errors, functions, params, and events against contracts/vault/src/lib.rs.
- New
docs/INTEGRATION_GUIDE.md (or similar) — backend walkthrough.
README.md, docs/interfaces/README.md — add cross-links.
3. Write/extend tests
- No contract tests required, but verify the JSON parses (e.g.
python3 -m json.tool docs/interfaces/vault.json) and that every function name in the JSON corresponds to a pub fn in contracts/vault/src/lib.rs (a small grep cross-check is sufficient and should be noted in the PR).
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace
./scripts/check-wasm-size.sh
./scripts/coverage.sh
Example commit message
docs(vault): sync interface JSON with real ABI and add integration guide
Guidelines
- Coverage must stay >= 95% (
scripts/coverage.sh), CI-enforced via .github/workflows/coverage.yml (unaffected by docs-only changes, but keep the gate green).
- Treat
contracts/vault/src/lib.rs as the source of truth; keep docs/interfaces/vault.json and EVENT_SCHEMA.md mutually consistent.
- Timeframe: 96 hours.
Description
docs/interfaces/vault.jsonis described inREADME.mdas the canonical, machine-readable reference for backend integrators using@stellar/stellar-sdk, but it has drifted from the implementation incontracts/vault/src/lib.rs. It documents string panics (e.g."vault is paused","amount must be positive") even though every entrypoint now returns typedVaultErrorcodes; it is missing error code 29 (DuplicateRequestId); and it omits many public functions that exist in the contract. This makes the JSON misleading for integrators and out of sync withEVENT_SCHEMA.md.Requirements and context
Functional — reconcile
docs/interfaces/vault.jsonagainstcontracts/vault/src/lib.rs:panicsarrays with the typedVaultErrorvariant each entrypoint actually returns (the enum is atcontracts/vault/src/lib.rs:42–:106; e.g.Paused(4),AmountNotPositive(6),ExceedsMaxDeduct(7),InsufficientBalance(5)).{ "code": 29, "name": "DuplicateRequestId" }toerrors.codes.functionsarray, including:set_max_deduct(:479),set_price/get_price(:1035/:1060),remove_metadata(:1103),set_revenue_pool(:956),get_revenue_pool(:350),get_contract_addresses(:366),clear_allowed_depositors(:526),get_allowed_depositors(:407),is_request_processed(:1188),upgrade(:1142),version(:1164), and the allowlist aliasesadd_address/clear_all/get_allowlist(:1251–:1286).params,returns,access, andeventsmatch the source (e.g.deducttakesrequest_id: Option<Symbol>, returnsi128).set_metadata/get_metadata/require_ownerentries currently listed twice in the JSON.init->set_settlement->set_authorized_caller->deposit->deduct(request_id)-> reading balances, built directly from the JSON interface andEVENT_SCHEMA.md. Cross-link it fromREADME.mdanddocs/interfaces/README.md.Non-functional / repo conventions
docs/interfaces/settlement.jsonanddocs/interfaces/revenue_pool.json.lib.rssymbols.Acceptance criteria
contracts/vault/src/lib.rsappears exactly once indocs/interfaces/vault.jsonwith correctparams/returns/access.panicsarrays reflect typedVaultErrorvariants (not legacy string panics).DuplicateRequestId) present inerrors.codes.set_metadata/get_metadata/require_ownerentries removed.docs/and is linked fromREADME.mdanddocs/interfaces/README.md.docs/interfaces/vault.jsonis valid JSON (cargo test --workspaceand a JSON lint both pass).Suggested execution
1. Fork the repo and create a branch
2. Implement changes
docs/interfaces/vault.json— reconcile errors, functions, params, and events againstcontracts/vault/src/lib.rs.docs/INTEGRATION_GUIDE.md(or similar) — backend walkthrough.README.md,docs/interfaces/README.md— add cross-links.3. Write/extend tests
python3 -m json.tool docs/interfaces/vault.json) and that every function name in the JSON corresponds to apub fnincontracts/vault/src/lib.rs(a small grep cross-check is sufficient and should be noted in the PR).4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test --workspace ./scripts/check-wasm-size.sh ./scripts/coverage.shExample commit message
Guidelines
scripts/coverage.sh), CI-enforced via.github/workflows/coverage.yml(unaffected by docs-only changes, but keep the gate green).contracts/vault/src/lib.rsas the source of truth; keepdocs/interfaces/vault.jsonandEVENT_SCHEMA.mdmutually consistent.