feat(bindings): add Rust RPC client crate (bindings/rust) - #1
Open
mohadon0 wants to merge 1 commit into
Open
Conversation
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
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.
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:src/types.rsAttestation,AttestationStatus,GlobalStats,TrustLinkError,ContractErrorCodesrc/xdr.rsScValencode/decode helpers (no WASM target, no Soroban SDK runtime)src/rpc.rssimulateTransactionJSON-RPC transport viareqwestsrc/client.rsTrustLinkClient— high-level public APItests/client_tests.rsmockitoMethods implemented
has_valid_claimhas_valid_claimhas_valid_claim_from_issuerhas_valid_claim_from_issuerhas_any_claimhas_any_claimhas_all_claimshas_all_claimsget_attestationget_attestationget_attestation_statusget_attestation_statusget_subject_attestationsget_subject_attestationsget_issuer_attestationsget_issuer_attestationsis_issueris_issuerget_global_statsget_global_statsDesign decisions
simulateTransactionendpoint (read-only, no signing key or XLM required).reqwest.bindings/python.NotFound,Unauthorized) surface as typedTrustLinkError::Contract { code: ContractErrorCode }.Testing
Tests use
mockitoto stub the RPC endpoint and run fully offline:has_valid_claimreturns true / falsehas_any_claim/has_all_claimscorrect boolean logicget_attestationcorrectly maps contract error Feature: Add attestation count queries Haroldwonder/TrustLink#4 →ContractErrorCode::NotFoundget_subject_attestationstransport path verifiedTrustLinkClient::newrejects invalid contract strkeysAcceptance criteria
bindings/rustcrate existshas_valid_claim,get_attestation,get_subject_attestations(plus 7 more)