The Rust SDK now ships a complete SUM / AVG surface (server prove-path executors, drive-side verifiers, and FromProof<DocumentQuery> impls for DocumentSum / DocumentAverage / DocumentSplitSums / DocumentSplitAverages). The WASM binding catches up only on the documents/count side — the four SUM/AVG entry points in `packages/wasm-sdk/src/queries/document.rs` are stubs that return `WasmSdkError::not_implemented`:
- `getDocumentsSum` (line ~633)
- `getDocumentsSumWithProofInfo` (line ~653)
- `getDocumentsAverage` (line ~686)
- `getDocumentsAverageWithProofInfo` (line ~707)
Scope
Each pair mirrors `get_documents_count` / `get_documents_count_with_proof_info`:
- Add a `parse_documents_sum_query` (and `_average_query`) that injects `Select::Sum` / `Select::Avg` + `field = sum_property` into the parsed `DocumentQuery`. (The count side parses to `Select::Count` analogously.)
- Call `DocumentSplitSums::fetch` / `DocumentSplitAverages::fetch` (already wired through the SDK).
- Map the result to a JS `Map`:
- SUM: `Map<string, bigint>` — same shape as count, just `i64` values instead of `u64`.
- AVG: `Map<string, {count: bigint, sum: bigint}>` — emit `{count, sum}` per entry so JS callers can divide with whichever representation they prefer (`Number(sum) / Number(count)`, BigInt division, etc.).
A `split_sums_to_js_map` / `split_averages_to_js_map` helper paralleling `split_counts_to_js_map` should keep the mapping code symmetric. The proof-info variants reuse the same parse + fetch path and additionally wrap the result with `ProofMetadataResponseWasm`.
Why this is its own issue
The Rust-side fan-out lands in PR #3661 (the sum-tree feature PR). The WASM binding is a separate concern — it needs its own JS Map helpers + parser helpers and shouldn't bloat that PR's diff further. All the drive-side primitives + SDK `FromProof` impls the WASM binding depends on are in place.
Acceptance
- All four `Err(WasmSdkError::not_implemented(...))` arms replaced with the parse → fetch → map flow.
- `split_sums_to_js_map` / `split_averages_to_js_map` helpers added next to `split_counts_to_js_map`.
- Smoke test in `packages/wasm-sdk/index.html` (or equivalent) confirms a round-trip against tip-jar / grades contract fixtures.
The Rust SDK now ships a complete SUM / AVG surface (server prove-path executors, drive-side verifiers, and
FromProof<DocumentQuery>impls forDocumentSum/DocumentAverage/DocumentSplitSums/DocumentSplitAverages). The WASM binding catches up only on the documents/count side — the four SUM/AVG entry points in `packages/wasm-sdk/src/queries/document.rs` are stubs that return `WasmSdkError::not_implemented`:Scope
Each pair mirrors `get_documents_count` / `get_documents_count_with_proof_info`:
A `split_sums_to_js_map` / `split_averages_to_js_map` helper paralleling `split_counts_to_js_map` should keep the mapping code symmetric. The proof-info variants reuse the same parse + fetch path and additionally wrap the result with `ProofMetadataResponseWasm`.
Why this is its own issue
The Rust-side fan-out lands in PR #3661 (the sum-tree feature PR). The WASM binding is a separate concern — it needs its own JS Map helpers + parser helpers and shouldn't bloat that PR's diff further. All the drive-side primitives + SDK `FromProof` impls the WASM binding depends on are in place.
Acceptance