Skip to content

feat(bindings): add Rust RPC client crate (bindings/rust) - #1

Open
mohadon0 wants to merge 1 commit into
mainfrom
feat/rust-bindings-crate
Open

feat(bindings): add Rust RPC client crate (bindings/rust)#1
mohadon0 wants to merge 1 commit into
mainfrom
feat/rust-bindings-crate

Conversation

@mohadon0

Copy link
Copy Markdown
Owner

Summary

Adds bindings/rust — a native Rust async RPC client for TrustLink, distinct from the on-chain contract crate. Rust backend services, CLIs, and Rust-based indexers can now integrate with TrustLink without going through the TypeScript or Python SDKs.

What was added

bindings/rust/ — a new Cargo crate (trustlink-client) structured as:

File Purpose
src/types.rs Attestation, AttestationStatus, GlobalStats, TrustLinkError, ContractErrorCode
src/xdr.rs ScVal encode/decode helpers (no WASM target, no Soroban SDK runtime)
src/rpc.rs Low-level simulateTransaction JSON-RPC transport via reqwest
src/client.rs TrustLinkClient — high-level public API
tests/client_tests.rs Offline integration tests using mockito

Methods implemented

Client method Contract function
has_valid_claim has_valid_claim
has_valid_claim_from_issuer has_valid_claim_from_issuer
has_any_claim has_any_claim
has_all_claims has_all_claims
get_attestation get_attestation
get_attestation_status get_attestation_status
get_subject_attestations get_subject_attestations
get_issuer_attestations get_issuer_attestations
is_issuer is_issuer
get_global_stats get_global_stats

Design decisions

  • All queries run via the Soroban RPC simulateTransaction endpoint (read-only, no signing key or XLM required).
  • No Soroban SDK runtime or WASM toolchain dependency — pure async HTTP client using reqwest.
  • Follows the same method-coverage approach as bindings/python.
  • Contract-level errors (e.g. NotFound, Unauthorized) surface as typed TrustLinkError::Contract { code: ContractErrorCode }.

Testing

Tests use mockito to stub the RPC endpoint and run fully offline:

  • has_valid_claim returns true / false
  • has_any_claim / has_all_claims correct boolean logic
  • get_attestation correctly maps contract error Feature: Add attestation count queries Haroldwonder/TrustLink#4ContractErrorCode::NotFound
  • get_subject_attestations transport path verified
  • TrustLinkClient::new rejects invalid contract strkeys

Acceptance criteria

  • bindings/rust crate exists
  • Core read queries implemented: has_valid_claim, get_attestation, get_subject_attestations (plus 7 more)
  • Tests covering each method against a mocked Soroban RPC node

Add bindings/rust as a thin async Rust client over the Soroban JSON-RPC
simulateTransaction endpoint, covering the read-heavy query surface first.

Implements:
- has_valid_claim / has_valid_claim_from_issuer
- has_any_claim / has_all_claims
- get_attestation / get_attestation_status
- get_subject_attestations / get_issuer_attestations
- is_issuer / get_global_stats

Internal modules:
- src/types.rs  — Attestation, AttestationStatus, GlobalStats, TrustLinkError
- src/xdr.rs    — SCVal encode/decode helpers (no WASM target required)
- src/rpc.rs    — low-level simulateTransaction JSON-RPC transport
- src/client.rs — TrustLinkClient public API
- tests/client_tests.rs — mockito-based offline integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant