Use canonical types over the native FFI - #345
Merged
Merged
Conversation
…uapi into feat/signing-host-ring-vrf
Use codec-derived runtime payloads and metadata-aware storage projections so field ordering and variant encoding stay aligned with chain types. Derive SSO message labels once and keep normal transcript events at debug.
Native executors need dispatch futures that can move across Tokio worker threads. Keep concise async signatures while teaching rustdoc codegen to unwrap async-trait futures.
HostDevicePermissionRequest, RemotePermission, HostPushNotificationRequest, and HostFeatureSupportedRequest derive uniffi in truapi and cross the FFI directly; their Native* mirrors and From conversions are deleted, and NativePermissionAuthorizationRequest (which genuinely flattens the RemotePermissionRequest wrapper) now wraps the canonical inner types. AuthState, SessionUiInfo, HostTheme, and the authorization mirrors keep reshaping and stay. Bytes32 moves from the v01 root to the crate root: the [u8; 32] conversion is version-neutral and applies to every protocol version. The Kotlin and Swift host shells and the hosts/android app consume the canonical names from the uniffi.truapi namespace; enum entries are unchanged.
v01::ThemeVariant and truapi_platform::PermissionAuthorizationStatus derive uniffi and cross the FFI directly; the HostTheme and NativePermissionAuthorizationStatus mirrors and their From conversions are deleted, with unchanged enum entries for hosts. The error mirrors (HostStorageError, HostRejection, HostNavigateRejection) stay: uniffi 0.29's Kotlin backend cannot lower cross-namespace types on the callback error path (each package defines its own RustBuffer JNA class, and the generated vtable glue mixes them), so callback error types must live in the crate that declares the callback interface.
…r FFI truapi_platform::AuthState, SessionUiInfo, and PermissionAuthorizationRequest (with the canonical nested RemotePermissionRequest wrapper, matching the review tree's nesting) derive uniffi and cross the FFI directly; their native mirrors and From conversions are deleted. truapi-platform registers its own Bytes32 custom type so SessionUiInfo's 32-byte fields pass as plain bytes. What stays hand-written in native.rs is by design: NativeRuntimeConfig (flat pre-validation config input), NativePairingDeeplinkScheme (native-only), and the error types (uniffi's Kotlin backend cannot lower cross-namespace callback error types).
HostStorageError and HostNavigateRejection carry v01::HostLocalStorageReadError and v01::HostNavigateToError as their single variant payload instead of restating the variants, so the error content is defined once in truapi (which gains Display and uniffi derives on those enums). The wrapper enums stay in truapi-server because uniffi's Kotlin backend requires callback error types to be namespace-local; payload fields cross namespaces fine since they serialize through the shared byte buffer rather than the vtable's RustBuffer lowering.
pgherveou
marked this pull request as ready for review
August 6, 2026 09:40
The variants keep their wire positions (SCALE encodes the Either discriminant by index, confirmed by the golden wire-equality tests), so the protocol is unchanged. The generated TypeScript client's discriminant strings change from "Left"/"Right" to "Index"/"Raw", which is a breaking API change for web products; Swift and Kotlin hosts see .index/.raw. Also drops a stale native/reviews.rs that a merge resurrected without any module reference.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
ERussel
approved these changes
Aug 7, 2026
ERussel
reviewed
Aug 7, 2026
ERussel
left a comment
Contributor
There was a problem hiding this comment.
Can you, please:
- ios/truapi-host/rebuild.sh
- ios/truapi-host/publish.sh 0.4.0
- Commit changed Package.swift
Collaborator
Author
|
The uploaded asset was downloaded independently and its checksum matches |
pgherveou
enabled auto-merge
August 7, 2026 16:38
valentinfernandez1
approved these changes
Aug 7, 2026
TarikGul
added a commit
that referenced
this pull request
Aug 11, 2026
Brings the branch up to `aa878d1f`, so the PR is mergeable again. One conflict, in `host_core.rs`, between two additions to the same region: this branch's native-only `impl SigningHostRuntime` carrying the renewal entry points, and `ConnectionAdapters` from the Chat integration (#326). Both are kept; neither references the other. The rest of main merged cleanly, including the FFI type rename (#345), Extrinsic V5 signing (#333), and RFC-0026 chain discovery (#354, #358). Verified on the merge result: `cargo +nightly fmt --check`, `clippy --workspace --all-targets --all-features -D warnings`, 683 workspace tests, and `cargo check --target wasm32-unknown-unknown -p truapi-server`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Follow-up to the discussion in #330 (comment): the native FFI surface uses the canonical protocol types directly. No mirrored copies, no restated declarations to keep in sync.
Summary
truapiandtruapi-platformcarry a feature-gateduniffidependency and deriveuniffi::Record/uniffi::Enumdirectly on the types that cross the native FFI: the user-confirmation review tree, navigate decisions, device/remote permissions, push notifications, feature queries, auth state, and the permission admin API. Each type is defined exactly once.truapi-serverenables theuniffifeatures for non-wasm builds only and re-exports the library crates' scaffolding so library-mode bindgen sees their metadata.[u8; 32]fields keep their canonical shape: a version-neutralBytes32alias plusuniffi::custom_type!passes them as plain bytes (Datain Swift,ByteArrayin Kotlin). No newtype, no call-site changes, wire format untouched by construction.DerivationIndex's variants are renamedLeft/Right→Index/Raw. The wire is unchanged (SCALE encodes theEitherdiscriminant by position, confirmed by the golden wire-equality tests), but the generated TypeScript client's discriminant strings change with it — a breaking@parity/truapiAPI change for web products matching ontag. dotli does not reference the type; the playground and this repo's tests are updated.Bindings and packaging
Bindings span three uniffi namespaces (
truapi,truapi_platform,truapi_server). Swift: the generated sources compile together into theTrUAPIHostmodule, each C FFI namespace is asystemLibrarytarget, and the xcframework ships all three headers. Kotlin: per-namespace packages with cross-imports. Hosts see the canonical shapes, e.g.UserConfirmationReview.signPayload(SignPayloadReview)andDerivationIndex.index/.raw.Host integration references
@parity/ios-host@0.4.0.pg/truapi-canonical-reviewsadapts the Android host to these bindings. Its:bindings:truapi-hostmodule compiles the Rust core from a TrUAPI checkout viatruapi.dir. Verified on Linux::app:assembleVanillaDebugbuilds and theConfirmationReviewMappingTestsuite passes.iOS binary release
Package.swiftconsumes@parity/ios-host@0.4.0with checksuma3029c071ef37e876ae51e45c177eab09cb976f9dbd729b93a2191d6ca8331be.useLocalBinaryremainsfalsein the committed manifest; local rebuilt XCFrameworks are opt-in for development only.Verification
cargo build --workspace --all-targets --all-features,cargo +nightly fmt --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo test --workspace --all-featurescargo check --target wasm32-unknown-unknown -p truapi-server(uniffi features stay off for wasm)make uniffi/make uniffi-kotlingenerate cleanly;./scripts/codegen.shleaves the committed generated Rust untouched;@parity/truapipassestscand all bun tests including golden wire-equality; the Android app builds end to end.iOS release automation
@parity/ios-host <version>alongside the npm targets. The trusted post-CI release workflow rebuilds the XCFramework on an arm64 macOS runner, rejects stale generated outputs, and runs the Swift package tests in an iOS simulator before publishing.@parity/ios-host@<version>from the pinned release SHA and makes a normalPackage.swiftfollow-up commit only after the asset is live. A compare-before-write guard prevents a delayed run from overwriting a newer manifest.