Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,913 changes: 3,468 additions & 445 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = ["rust/crates/*"]
exclude = ["rust/crates/truapi-server"]

[workspace.package]
edition = "2024"
Expand Down
3 changes: 3 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
allow = [
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"CC0-1.0",
"Unicode-3.0",
"Unlicense",
"Zlib",
Expand Down
66 changes: 66 additions & 0 deletions rust/crates/truapi-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[package]
name = "truapi-server"
version = "0.1.0"
edition.workspace = true
description = "TrUAPI server runtime: dispatcher, frames, SCALE, streams"
license = "MIT"

[lib]
crate-type = ["rlib", "cdylib"]

[features]
default = []

[dependencies]
truapi = { path = "../truapi" }
truapi-platform = { path = "../truapi-platform" }
async-trait = "0.1"
derive_more = { version = "2", features = ["display"] }
futures = "0.3"
futures-timer = { version = "3", features = ["wasm-bindgen"] }
parity-scale-codec = { version = "3", features = ["derive"] }
primitive-types = { version = "0.13", default-features = false, features = ["serde"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"
unicode-normalization = "0.1"
url = "2"
hex = "0.4"
blake2-rfc = { version = "0.2", default-features = false }
sp-crypto-hashing = { version = "0.1", default-features = false }
bs58 = { version = "0.5", default-features = false, features = ["alloc"] }
schnorrkel = { version = "0.11.5", default-features = false, features = ["alloc", "getrandom"] }
getrandom = { version = "0.2", features = ["js"] }
p256 = { version = "0.13", default-features = false, features = ["ecdh"] }
hkdf = "0.12"
sha2 = "0.10"
aes-gcm = { version = "0.10", default-features = false, features = ["aes", "alloc"] }
tracing = "0.1"
# `registry` + `std` only: pulls the Registry + per-layer filter/reload, but
# not `env-filter` (which drags in `regex`, heavy on wasm).
tracing-subscriber = { version = "0.3", default-features = false, features = ["registry", "std"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["native"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3"
subxt-rpcs = { version = "0.50.1", default-features = false, features = ["web"] }
wasm-bindgen = "0.2.118"
wasm-bindgen-futures = "0.4"
console_error_panic_hook = "0.1"
futures-util = "0.3"
pin-project = "1"
send_wrapper = { version = "0.6", features = ["futures"] }
web-time = "1"
web-sys = { version = "0.3", features = [
"BinaryType",
"CloseEvent",
"console",
"Event",
"MessageEvent",
"WebSocket",
] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"
33 changes: 33 additions & 0 deletions rust/crates/truapi-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# truapi-server

_Runtime core for TrUAPI: dispatcher, protocol frames, SCALE-coded wire envelope._

## What this crate is for

`truapi-server` is the runtime that turns trait implementations of the
`truapi` API into a working host. It owns:

- the [`ProtocolMessage`] wire envelope and SCALE codec
- the [`Dispatcher`] that routes incoming frames to per-method handlers
- the subscription lifecycle (start/receive/stop/interrupt)
- the [`Transport`] trait that platform-specific IPC backends implement
- the auto-generated dispatcher/wire-table tables shipped under
[`crate::generated`]

## Wire envelope

Every frame on the wire is encoded as:

```text
[requestId: SCALE str][discriminant: u8][payload bytes...]
```

The discriminant identifies a method + frame kind via the auto-generated
[`crate::generated::wire_table::WIRE_TABLE`]. Each method's ids are exposed
as a named const (`PREIMAGE_SUBMIT`, ...); both `WIRE_TABLE` and the generated
dispatcher reference those consts. Method ordering is part of the wire
protocol; only ever append.

The payload bytes are the SCALE-encoded inner value, inlined without a
length prefix. The discriminant is carried directly as `Payload::id`, and the
dispatcher routes on that numeric id via id-keyed tables.
16 changes: 16 additions & 0 deletions rust/crates/truapi-server/src/host_logic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Host-agnostic logic the Rust core owns on behalf of every platform host.
//!
//! Platform callbacks are a syscall layer for OS primitives (modals, native
//! storage, URL handler, notification center). Everything else lives here so
//! iOS, Android, and web hosts share one canonical implementation.

pub mod dotns;
pub mod entropy;
pub mod features;
pub mod identity;
pub mod permissions;
pub mod product_account;
pub mod session;
pub mod session_store;
pub mod sso;
pub mod statement_store;
Loading