Problem
Adding a TrUAPI function requires touching three places:
- rust/crates/truapi/src/api/*.rs — trait method with &self, CallContext, async_trait
- rust/crates/truapi/src/v01/*.rs — concrete types
- rust/crates/truapi/src/versioned/*.rs — versioned_type! wrappers
The trait signatures mix protocol information with runtime concerns, and there's no way to tell request-response from subscription by reading the code.
Proposal
Simplify the spec surface to carry only protocol information:
#[wire(request_id = 12)]
fn host_derive_entropy(key: Vec) -> Result<Entropy, DeriveEntropyError>
#[wire(request_id = 120)]
fn remote_preimage_lookup_subscribe(key: PreimageKey) -> Subscription<Option, PreimageLookupError>
- Result<T, E> = request-response
- Subscription<T, E> = subscription (marker type for codegen)
- No &self, CallContext, async_trait, CallError — generated by codegen for the runtime
- Wire IDs stay explicit and manually assigned (stable across renames, required by other implementors)
Auto-generated from the spec
- Runtime boilerplate (&self, CallContext, async_trait, CallError)
- Versioned wrappers (versioned_type! enums)
- TS client (SCALE codecs, Result wrapping, Observable for subscriptions)
- Explorer/playground metadata
Migration
- Prototype the simplified surface for one group
- Extend codegen to produce the current /api traits and /versioned wrappers from it
- Migrate remaining groups
- Add contributor guide: "How to add a new TrUAPI function"
Problem
Adding a TrUAPI function requires touching three places:
The trait signatures mix protocol information with runtime concerns, and there's no way to tell request-response from subscription by reading the code.
Proposal
Simplify the spec surface to carry only protocol information:
#[wire(request_id = 12)]
fn host_derive_entropy(key: Vec) -> Result<Entropy, DeriveEntropyError>
#[wire(request_id = 120)]
fn remote_preimage_lookup_subscribe(key: PreimageKey) -> Subscription<Option, PreimageLookupError>
Auto-generated from the spec
Migration