Skip to content

feat(truapi)!: payments by id and balance through host platforms - #1314

Open
filvecchiato wants to merge 11 commits into
mainfrom
payments/by-id
Open

filvecchiato wants to merge 11 commits into
mainfrom
payments/by-id

Conversation

@filvecchiato

@filvecchiato filvecchiato commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Core side of #778. Funding is not needed for it.

  • payment.topUp takes a caller-chosen 32-byte id and is followed with the new payment.topUpStatusSubscribe (Detecting → Claiming → Claimed, ClaimedPartially or NotClaimed). The core checks the source keys and refuses an amount of zero. A ProductAccount source is passed to the host's TopUpPlatform, which derives the account.
  • payment.request takes a caller-chosen id; payment.statusSubscribe follows it through PaymentPlatform.
  • payment.balanceSubscribe streams the balance from the new BalancePlatform. The balance is what a payment request can spend, and it is sent as the current value, then each change.
  • New BalanceAccess remote permission, owned by the core:
    • balanceSubscribe asks for it on the first subscription; refused → PermissionDenied.
    • A host InsufficientBalance reaches a product without it as Rejected, checked without prompting.
    • The iOS and Android bridges map it onto their existing balance-access prompt.
  • Native: set_top_up_callbacks / notify_top_up_status, set_payment_callbacks / notify_payment_status, set_balance_callbacks / notify_balance.
  • Every method needs a signed-in session. With no platform installed it answers Unsupported.
  • Status streams end after the final status.

The host engines stay behind these platforms for now; moving them into the core is #1330. Host side: #778 and #1268.

The Android bridge change was not compiled locally (no JDK on the machine); CI covers it.

# Conflicts:
#	rust/crates/truapi-codegen/tests/golden/wire_table.rs
#	rust/crates/truapi/src/host_core.rs
#	rust/crates/truapi/src/native.rs
#	rust/crates/truapi/src/native/platform.rs
#	rust/crates/truapi/src/native/runtime.rs
#	rust/crates/truapi/src/runtime/tests.rs
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size report

Compared with main at 63a450d.

Raw Gzip Brotli
truapi-host 7.82 MiB (+9.9 KiB, +0.1%) 5.64 MiB (+3.6 KiB, +0.1%) 5.37 MiB (-137 B)
truapi-provider 4.03 MiB 1.27 MiB 959.8 KiB
truapi 6.02 MiB (+12.4 KiB, +0.2%) 849.7 KiB (+1.7 KiB, +0.2%) 696.2 KiB (+1.2 KiB, +0.2%)
Total 17.86 MiB (+22.3 KiB, +0.1%) 7.74 MiB (+5.3 KiB, +0.1%) 6.99 MiB (+1.1 KiB)

WebAssembly modules

Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 2.71 MiB (+9.9 KiB, +0.4%) 969.0 KiB (+3.6 KiB, +0.4%) 730.8 KiB (-152 B)
truapi-host/wasm/web/truapi_verifiable_bg.wasm 4.89 MiB 4.64 MiB 4.61 MiB
truapi-provider/truapi_provider_bg.wasm 3.99 MiB 1.26 MiB 952.1 KiB
Changed files (9)
Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 2.71 MiB (+9.9 KiB, +0.4%) 969.0 KiB (+3.6 KiB, +0.4%) 730.8 KiB (-152 B)
truapi/playground/codegen/truapi-dts.js 286.1 KiB (+4.4 KiB, +1.6%) 49.5 KiB (+747 B, +1.5%) 39.9 KiB (+536 B, +1.3%)
truapi/explorer/codegen/types.js 216.5 KiB (+4.1 KiB, +2.0%) 29.9 KiB (+522 B, +1.7%) 24.0 KiB (+382 B, +1.6%)
truapi/playground/codegen/services.js 99.3 KiB (+1.5 KiB, +1.6%) 15.0 KiB (+204 B, +1.3%) 12.6 KiB (+145 B, +1.1%)
truapi/generated/types.js 62.8 KiB (+987 B, +1.6%) 7.6 KiB (+98 B, +1.3%) 6.5 KiB (+83 B, +1.3%)
truapi/generated/client.js 70.6 KiB (+900 B, +1.3%) 10.6 KiB (+141 B, +1.3%) 8.9 KiB (+134 B, +1.5%)
truapi/generated/wire-decode.js 28.4 KiB (+424 B, +1.5%) 3.0 KiB (+23 B, +0.8%) 2.5 KiB (+18 B, +0.7%)
truapi/generated/wire-table.js 8.9 KiB (+107 B, +1.2%) 1.6 KiB (+11 B, +0.7%) 1.2 KiB (+6 B, +0.5%)
truapi-host/wasm/web/truapi_server.js 58.0 KiB (+3 B) 10.6 KiB (+8 B, +0.1%) 9.1 KiB (+15 B, +0.2%)

Commit: 86ccd12

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

CI Status: not green, 2 items need attention.

  • ts-host: failure
  • host-wasm: failure
All job results
job result
android-bindings success
bundle-size success
changes success
changeset-guard success
cli-package success
codegen success
e2e skipped
explorer success
headless-install success
host-android-bindings success
host-android-detekt success
host-wasm failure
ios-bindings success
ios-swift success
licenses success
playground success
provider-android-bindings skipped
release-guard success
rust success
ts-client success
ts-debugger success
ts-host failure
wasm-provider success
workflow-lint skipped

Signing credentials: failure as of 2026-10-08, a release may fail

Commit 86ccd120 · run log

@github-actions github-actions Bot added documentation Improvements or additions to documentation rfc labels Oct 7, 2026

@TarikGul TarikGul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TopUpPlatform and PaymentPlatform docs leave scoping the caller chosen id to the product up to each host, and the core could make that impossible to forget by hashing the product id into the one it hands down.

@github-actions github-actions Bot added host-ios Touches the iOS host tree host-android Touches the Android host tree labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This pull request touches an app, which is not built by default. Add a label for each build you want:

  • iOS simulator build, ios-simulator-build: builds the iOS app, runs its tests and attaches a build for the iOS Simulator on a Mac.
  • iOS device build, ios-device-build: attaches a signed build that installs on a registered iPhone or iPad.
  • Android build, android-device-build: attaches an APK that installs on an Android phone or an emulator.

Each starts as soon as it is added and follows the branch from then on.

@filvecchiato

Copy link
Copy Markdown
Collaborator Author

Done in de937c5: the core hands the host blake2_256(("truapi/payment-id", product_id, id)) for top-ups and payments, so hosts no longer scope ids themselves. Platform docs, RFC 0006 and the changesets say so; two_products_naming_one_id_reach_the_host_under_different_ids covers it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation host-android Touches the Android host tree host-ios Touches the iOS host tree rfc rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bridge and test hosts Re-introduce RFC-006 payment.topUp / balanceSubscribe on the TrUAPI runtime (iOS + Android)

2 participants