Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct all breaking changes in RPC for Protocol 22 #1084

Merged
merged 10 commits into from
Nov 8, 2024
Prev Previous commit
Next Next commit
Drop simulateTransaction cost field
  • Loading branch information
Shaptic committed Oct 9, 2024
commit f25a4e78d4be89c36d47d5b7db1ddc1a720c1a12
8 changes: 0 additions & 8 deletions src/rpc/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { Contract, SorobanDataBuilder, xdr } from '@stellar/stellar-base';

/* tslint:disable-next-line:no-namespace */
export namespace Api {

export interface Cost {
cpuInsns: string;
memBytes: string;
}

export interface GetHealthResponse {
status: 'healthy';
}
Expand Down Expand Up @@ -317,7 +311,6 @@ export namespace Api {
extends BaseSimulateTransactionResponse {
transactionData: SorobanDataBuilder;
minResourceFee: string;
cost: Cost;

/** present only for invocation simulation */
result?: SimulateHostFunctionResult;
Expand Down Expand Up @@ -403,7 +396,6 @@ export namespace Api {
* invokeHostFunctionOperation is supported per transaction.
* */
results?: RawSimulateHostFunctionResult[];
cost?: Cost;
/** Present if succeeded but has expired ledger entries */
restorePreamble?: {
minResourceFee: string;
Expand Down
5 changes: 2 additions & 3 deletions src/rpc/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,10 @@ function parseSuccessful(
...partial,
transactionData: new SorobanDataBuilder(sim.transactionData!),
minResourceFee: sim.minResourceFee!,
cost: sim.cost!,
...// coalesce 0-or-1-element results[] list into a single result struct
// coalesce 0-or-1-element results[] list into a single result struct
// with decoded fields if present
// eslint-disable-next-line no-self-compare
((sim.results?.length ?? 0 > 0) && {
...((sim.results?.length ?? 0 > 0) && {
result: sim.results!.map((row) => ({
auth: (row.auth ?? []).map((entry) =>
xdr.SorobanAuthorizationEntry.fromXDR(entry, 'base64')
Expand Down
11 changes: 0 additions & 11 deletions test/unit/server/soroban/simulate_transaction_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe("Server#simulateTransaction", async function (done) {
),
retval: xdr.ScVal.fromXDR(simulationResponse.results[0].xdr, "base64"),
},
cost: simulationResponse.cost,
stateChanges: [
{
type: 2,
Expand Down Expand Up @@ -242,7 +241,6 @@ describe("Server#simulateTransaction", async function (done) {
const expected = cloneSimulation(parsedSimulationResponse);
// drop fields that go away with errors
delete expected.result;
delete expected.cost;
delete expected.transactionData;
delete expected.minResourceFee;
delete expected.stateChanges;
Expand Down Expand Up @@ -270,7 +268,6 @@ function cloneSimulation(sim) {
),
retval: xdr.ScVal.fromXDR(sim.result.retval.toXDR()),
},
cost: sim.cost,
stateChanges: sim.stateChanges,
_parsed: sim._parsed,
};
Expand Down Expand Up @@ -332,10 +329,6 @@ function baseSimulationResponse(results) {
minResourceFee: "15",
transactionData: new SorobanDataBuilder().build().toXDR("base64"),
...(results !== undefined && { results }),
cost: {
cpuInsns: "1",
memBytes: "2",
},
stateChanges: [
{
type: 2,
Expand Down Expand Up @@ -440,10 +433,6 @@ describe("works with real responses", function () {
xdr: "AAAAEAAAAAEAAAACAAAADwAAAAVIZWxsbwAAAAAAAA8AAAAFQWxvaGEAAAA=",
},
],
cost: {
cpuInsns: "1322134",
memBytes: "1207047",
},
restorePreamble: {
transactionData: "",
minResourceFee: "0",
Expand Down