Skip to content

Commit

Permalink
Add parsing of stateDiff
Browse files Browse the repository at this point in the history
  • Loading branch information
psheth9 committed May 10, 2024
1 parent ecaaa92 commit 33985fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/soroban/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export namespace Api {
interface RawLedgerEntryDiff {
type: number;
key: string;
// these are xdr.LedgerEntry in base64
before?: string;
// these are xdr.LedgerEntry in base64
after?: string;
}

Expand Down
13 changes: 12 additions & 1 deletion src/soroban/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,18 @@ function parseSuccessful(
: xdr.ScVal.scvVoid()
};
})[0]
})
}),

stateDiff: sim.stateDiff?.length ?? 0 > 0
? sim.stateDiff!.map((entryDiff) => {
return {
type: entryDiff.type,
key: entryDiff.key,
before: xdr.LedgerEntry.fromXDR(entryDiff.before, 'base64'),
after: xdr.LedgerEntry.fromXDR(entryDiff.after, 'base64'),
};
})
: null,
};

if (!sim.restorePreamble || sim.restorePreamble.transactionData === '') {
Expand Down

0 comments on commit 33985fc

Please sign in to comment.