Skip to content

Commit

Permalink
Rename stateDiff to stateChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
psheth9 committed May 15, 2024
1 parent 297525a commit 0263f61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/soroban/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export namespace Api {
value: string;
}

interface RawLedgerEntryDiff {
interface RawLedgerEntryChange {
type: number;
// This is LedgerKey in base64
key: string;
Expand All @@ -185,7 +185,7 @@ export namespace Api {
after?: string;
}

interface LedgerEntryDiff{
interface LedgerEntryChange{
type: number;
key: xdr.LedgerKey;
before?: xdr.LedgerEntry;
Expand Down Expand Up @@ -279,7 +279,7 @@ export namespace Api {
result?: SimulateHostFunctionResult;

// State Difference information
stateDiff?: LedgerEntryDiff[];
stateChanges?: LedgerEntryChange[];
}

/** Includes details about why the simulation failed */
Expand Down Expand Up @@ -365,6 +365,6 @@ export namespace Api {
};

// State Difference information
stateDiff?: RawLedgerEntryDiff[];
stateChanges?: RawLedgerEntryChange[];
}
}
12 changes: 6 additions & 6 deletions src/soroban/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ function parseSuccessful(
})[0]
}),

stateDiff: sim.stateDiff?.length ?? 0 > 0
? sim.stateDiff!.map((entryDiff) => {
stateChanges: sim.stateChanges?.length ?? 0 > 0
? sim.stateChanges!.map((entryChange) => {
return {
type: entryDiff.type,
key: xdr.LedgerKey.fromXDR(entryDiff.key, 'base64'),
before: !!entryDiff.before ? xdr.LedgerEntry.fromXDR(entryDiff.before, 'base64') : undefined,
after: !!entryDiff.after ? xdr.LedgerEntry.fromXDR(entryDiff.after, 'base64') : undefined,
type: entryChange.type,
key: xdr.LedgerKey.fromXDR(entryChange.key, 'base64'),
before: !!entryChange.before ? xdr.LedgerEntry.fromXDR(entryChange.before, 'base64') : undefined,
after: !!entryChange.after ? xdr.LedgerEntry.fromXDR(entryChange.after, 'base64') : undefined,
};
})
: undefined,
Expand Down
8 changes: 4 additions & 4 deletions test/unit/server/soroban/simulate_transaction_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Server#simulateTransaction", async function (done) {
retval: xdr.ScVal.fromXDR(simulationResponse.results[0].xdr, "base64"),
},
cost: simulationResponse.cost,
stateDiff: [
stateChanges: [
{
type: 1,
key: "example-key",
Expand Down Expand Up @@ -189,7 +189,7 @@ describe("Server#simulateTransaction", async function (done) {
delete expected.cost;
delete expected.transactionData;
delete expected.minResourceFee;
delete expected.stateDiff;
delete expected.stateChanges;
expected.error = "This is an error";
expected.events = [];

Expand All @@ -215,7 +215,7 @@ function cloneSimulation(sim) {
retval: xdr.ScVal.fromXDR(sim.result.retval.toXDR()),
},
cost: sim.cost,
stateDiff: sim.stateDiff,
stateChanges: sim.stateChanges,
_parsed: sim._parsed,
};
}
Expand Down Expand Up @@ -278,7 +278,7 @@ function baseSimulationResponse(results) {
cpuInsns: "1",
memBytes: "2",
},
stateDiff: [
stateChanges: [
{
type: 1,
key: "example-key",
Expand Down

0 comments on commit 0263f61

Please sign in to comment.