Skip to content

Commit

Permalink
Add sensible defaults when parsing simulation response (#131)
Browse files Browse the repository at this point in the history
* handle empty strings and missing events
  • Loading branch information
willemneal authored Aug 24, 2023
1 parent 377e3fe commit 96bb293
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ export function parseRawSimulation(
// Gordon Ramsey in shambles
return sim;
}

return {
id: sim.id,
minResourceFee: sim.minResourceFee,
latestLedger: sim.latestLedger,
cost: sim.cost,
transactionData: new SorobanDataBuilder(sim.transactionData),
events: sim.events.map((event) =>
transactionData: new SorobanDataBuilder(
sim.transactionData === "" ? undefined : sim.transactionData
),
events: (sim.events ?? []).map((event) =>
xdr.DiagnosticEvent.fromXDR(event, "base64")
),
...(sim.error !== undefined && { error: sim.error }), // only if present
Expand Down

0 comments on commit 96bb293

Please sign in to comment.