Skip to content

Commit 8cceb16

Browse files
committed
feat(truapi-server): add Rust host runtime
WASM host runtime that hosts implement: dispatcher, SCALE frames, subscription streams, chain runtime, host logic (sessions, SSO pairing, permissions, statement store, dotns) and the wasm bindings. Includes the committed generated dispatcher/wire-table under src/generated/.
1 parent 4843b5c commit 8cceb16

46 files changed

Lines changed: 24760 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 3274 additions & 379 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[package]
2+
name = "truapi-server"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
description = "TrUAPI server runtime: dispatcher, frames, SCALE, streams"
6+
license = "MIT"
7+
8+
[lib]
9+
crate-type = ["rlib", "cdylib"]
10+
11+
[features]
12+
default = []
13+
14+
[dependencies]
15+
truapi = { path = "../truapi" }
16+
truapi-platform = { path = "../truapi-platform" }
17+
async-trait = "0.1"
18+
derive_more = { version = "2", features = ["display"] }
19+
futures = "0.3"
20+
futures-timer = { version = "3", features = ["wasm-bindgen"] }
21+
parity-scale-codec = { version = "3", features = ["derive"] }
22+
primitive-types = { version = "0.13", default-features = false, features = ["serde"] }
23+
serde = { version = "1", features = ["derive"] }
24+
serde_json = "1"
25+
thiserror = "1"
26+
unicode-normalization = "0.1"
27+
url = "2"
28+
hex = "0.4"
29+
blake2-rfc = { version = "0.2", default-features = false }
30+
sp-crypto-hashing = { version = "0.1", default-features = false }
31+
bs58 = { version = "0.5", default-features = false, features = ["alloc"] }
32+
schnorrkel = { version = "0.11.5", default-features = false, features = ["alloc", "getrandom"] }
33+
getrandom = { version = "0.2", features = ["js"] }
34+
p256 = { version = "0.13", default-features = false, features = ["ecdh"] }
35+
hkdf = "0.12"
36+
sha2 = "0.10"
37+
aes-gcm = { version = "0.10", default-features = false, features = ["aes", "alloc"] }
38+
tracing = "0.1"
39+
# `registry` + `std` only: pulls the Registry + per-layer filter/reload, but
40+
# not `env-filter` (which drags in `regex`, heavy on wasm).
41+
tracing-subscriber = { version = "0.3", default-features = false, features = ["registry", "std"] }
42+
43+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
44+
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["native"] }
45+
46+
[target.'cfg(target_arch = "wasm32")'.dependencies]
47+
js-sys = "0.3"
48+
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["web"] }
49+
wasm-bindgen = "0.2.118"
50+
wasm-bindgen-futures = "0.4"
51+
console_error_panic_hook = "0.1"
52+
futures-util = "0.3"
53+
pin-project = "1"
54+
send_wrapper = { version = "0.6", features = ["futures"] }
55+
web-time = "1"
56+
web-sys = { version = "0.3", features = [
57+
"BinaryType",
58+
"CloseEvent",
59+
"console",
60+
"Event",
61+
"MessageEvent",
62+
"WebSocket",
63+
] }
64+
65+
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
66+
wasm-bindgen-test = "0.3"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# truapi-server
2+
3+
_Runtime core for TrUAPI: dispatcher, protocol frames, SCALE-coded wire envelope._
4+
5+
## What this crate is for
6+
7+
`truapi-server` is the runtime that turns trait implementations of the
8+
`truapi` API into a working host. It owns:
9+
10+
- the [`ProtocolMessage`] wire envelope and SCALE codec
11+
- the [`Dispatcher`] that routes incoming frames to per-method handlers
12+
- the subscription lifecycle (start/receive/stop/interrupt)
13+
- the [`Transport`] trait that platform-specific IPC backends implement
14+
- the auto-generated dispatcher/wire-table tables shipped under
15+
[`crate::generated`]
16+
17+
## Wire envelope
18+
19+
Every frame on the wire is encoded as:
20+
21+
```text
22+
[requestId: SCALE str][discriminant: u8][payload bytes...]
23+
```
24+
25+
The discriminant identifies a method + frame kind via the auto-generated
26+
[`crate::generated::wire_table::WIRE_TABLE`]. Each method's ids are exposed
27+
as a named const (`PREIMAGE_SUBMIT`, ...); both `WIRE_TABLE` and the generated
28+
dispatcher reference those consts. Method ordering is part of the wire
29+
protocol; only ever append.
30+
31+
The payload bytes are the SCALE-encoded inner value, inlined without a
32+
length prefix. The discriminant is carried directly as `Payload::id`, and the
33+
dispatcher routes on that numeric id via id-keyed tables.

0 commit comments

Comments
 (0)