feat(rpc): implement typed simulate_transaction method (#99)#112
Open
Sendi0011 wants to merge 5 commits intoToolbox-Lab:mainfrom
Open
feat(rpc): implement typed simulate_transaction method (#99)#112Sendi0011 wants to merge 5 commits intoToolbox-Lab:mainfrom
Sendi0011 wants to merge 5 commits intoToolbox-Lab:mainfrom
Conversation
Replace the raw serde_json::Value stub with a fully typed implementation of the simulateTransaction Soroban RPC method. Changes: - Add SimulateTransactionResponse struct with all fields from the Soroban RPC spec: soroban_data (transactionData XDR), min_resource_fee, auth entries, per-invocation results, diagnostic events, and cost estimates - Add supporting types: SimulateResult, SimulateCost, SimulateFootprint, SimulateAuthEntry, SimulateSorobanData - simulate_transaction now returns PrismResult<SimulateTransactionResponse> instead of PrismResult<serde_json::Value> - Simulation-level errors (response.error field) are surfaced as PrismError::RpcError so callers get a proper Rust error - Add is_success() and return_value_xdr() convenience methods on the response type - Re-export public simulation types from network::mod for ergonomic access Closes Toolbox-Lab#99
|
@Sendi0011 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- main upgraded call() to generic call<T: Deserialize> and added typed GetTransactionResponse — kept those changes in full - adapted simulate_transaction to use the new generic call<T> directly instead of going through serde_json::Value, removing the intermediate from_value() step - all other main changes (address types, xdr codec, config updates) merged cleanly
Contributor
|
@Sendi0011 please resolve conflicts |
Main renamed RpcClient to SorobanRpcClient, changed constructor to take &NetworkConfig, added reqwest headers, and made JsonRpcRequest generic. Also fixed several bugs in main's call() (wrong variable names: envelope, response_body, rpc_resp, self.config.rpc_url). Resolution: - Keep our typed SimulateTransactionResponse + simulate_transaction impl - Adopt main's SorobanRpcClient struct, new(&NetworkConfig), and improved call() - Fix all callers: state.rs, decode/mod.rs, contract_error.rs, serve.rs - get_transaction now returns GetTransactionResponse; updated callers accordingly - Drop duplicate struct definitions and broken test blocks from main
Author
Gm @Emrys02 i have resolve the conflicts |
…/state.rs Conflicts were minor — main renamed tx_data -> tx_response in decode/mod.rs and replay/state.rs, and still had the envelope/rpc_resp bugs plus duplicate struct definitions in rpc.rs. Kept our typed simulate_transaction, fixed all bugs, merged duplicate test blocks into one.
Contributor
|
@Sendi0011 I merged a PR before yours, please fix conflict, i will merge this to avoid more conflict |
Main cleaned up the file (removed doc comments on private items, dropped explicit ::<serde_json::Value> turbofish, added HTTP non-2xx error check). Kept our typed simulate_transaction impl and simulate tests, adopted all other improvements from main.
Author
|
Gm @Emrys02 all conflicts resolved |
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.
feat(rpc): implement typed
simulate_transactionmethod — closes #99What changed
The existing
simulate_transactionstub returned a rawserde_json::Value, giving callers no type safety and forcing them to manually dig through JSON to extract footprint/auth data. This PR replaces it with a fully typed implementation.Key additions in
crates/core/src/network/rpc.rs:SimulateTransactionResponse— top-level typed response matching the Soroban RPC spec, with fields forsoroban_data(theSorobanTransactionDataXDR to stamp onto the tx),min_resource_fee,authentries, per-invocationresults, diagnosticevents, andcostestimatesSimulateResult— per-invocation return value XDR + auth entriesSimulateCost,SimulateFootprint,SimulateAuthEntry,SimulateSorobanData— supporting typessimulate_transactionnow returnsPrismResult<SimulateTransactionResponse>— simulation-level errors (theerrorfield in the response) are surfaced asPrismError::RpcErrorso callers get a proper Rust error without inspecting the structis_success()andreturn_value_xdr()convenience methods on the responsecrates/core/src/network/mod.rs: re-exports the public simulation types for ergonomic access asprism_core::network::SimulateTransactionResponseetc.How to use after this PR: