Skip to content

sdk: move six host-side policies into shared Rust (Kotlin/Swift parity) #5092

Open

Description

@QuantumExplorer

Six capabilities in docs/sdk/sdk-parity-manifest.json are partial on both SDKs because each host app computes a policy itself instead of asking Rust. The manifest records the gaps; this issue records the target designs, which until #5060 lived only in the deleted docs/sdk/KOTLIN_SWIFT_SHARED_PARITY_SPEC.md (section 7). Each is its own piece of work; delete the host copies only after both apps consume the shared result.

S1: masternode discovery (network.masternode_discovery)

  • A standalone Rust entry point taking (network, quorum_base) and returning owned typed records with both the Core peer address and the DAPI URL, plus a free function (or: move discovery into SDK construction and expose its cached result).
  • One endpoint parser in rs-sdk-trusted-context-provider, shared by the provider and the bridge.
  • Define: explicit-configuration precedence; HTTP status, timeout and failure fallback; version/status filtering; testnet's default port 1443 when none is given; bracketed IPv6; malformed or missing ports. Hosts must not fetch twice.
  • Replace the Kotlin test that pins 443 for non-mainnet (the legacy single-argument overload).

S2: Platform-address funding (identity.platform_address_auto_funding)

  • Account-scoped Rust composites for identity registration and top-up from DIP-17 Platform addresses, taking (wallet_id, PlatformPayment account_index, target credits). Rust enumerates hydrated and derived candidates, fetches authoritative balances and nonces, selects deterministically under fee constraints, signs, submits and returns the result.
  • The account index is mandatory when several Platform Payment accounts exist.
  • Tests: only the chosen account is used, hydrated candidates after a restart, exact target, insufficient funds, concurrent balance/nonce revalidation.
  • Delete the host pre-enumeration and greedy packing loops.

S3a: token authorization and proposal evaluation (tokens.authorization_decisions, tokens.max_supply_proposal_discovery)

  • A versioned Rust decision for action + token configuration + actor context: allowed or denied, a stable reason discriminant, and zero or more authorization alternatives or group rules. Cover every group-capable action, including maxSupplyChangeRules; do not collapse alternatives into one "required key".
  • Stable repr discriminants or versioned JSON, typed host decoding, owned-array/free rules.

S3b: direct-purchase quote (tokens.direct_purchase_quote)

  • A Rust quote for schedule + amount: selected threshold, unit price, and a full-domain u64 total. Both apps render it and delete their local tier and price arithmetic. Rust stays authoritative at broadcast.

S4: protocol constants and codecs (protocol.address_validation)

  • Versioned consensus identity-funding denominations, separate from presentational UI presets.
  • Address validation returns the typed family, network, payload and failure reason rather than Bool.
  • Android bridges platform_wallet_parse_invitation instead of a second codec.
  • Remove hard-coded protocol tables and app-local Base58/Bech32 validators once the shared replacements are adopted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions