stellar / js-soroban-client

Main Soroban client library for the Javascript language
https://stellar.github.io/js-soroban-client/
Apache License 2.0
22 stars 17 forks source link

Automatically decode XDR structures in simulation responses #127

Closed Shaptic closed 1 year ago

Shaptic commented 1 year ago

The RPC response schemas for simulation have been upgraded to parse the base64-encoded XDR automatically. Succinctly,

Here is the full list of changed fields:

  export interface SimulateHostFunctionResult {
-    auth?: string[];
-    xdr: string;
+    auth: xdr.SorobanAuthorizationEntry[];
+    xdr: xdr.ScVal;
  }

  export interface SimulateTransactionResponse {
-    transactionData: string;
+    transactionData: SorobanDataBuilder;
-    events: string[];
+    events: xdr.DiagnosticEvent[];
-    results: SimulateHostFunctionResult[];
+    result?: SimulateHostFunctionResult;
  }

The true, raw, underlying schema is still accessible by adding the Raw prefix to the interface name.