Skip to content

Commit 0d719c4

Browse files
committed
3. Accomodate XDR additions or renames:
* This accounts for any fields that encountered a rename as part of the new XDR version. In this case, `readBytes` was renamed to `diskReadBytes` because it's measured differently as a result of Core's state living in memory rather than on disk in most cases. * It also accounts for the unused extension point actually having a name now, so `xdr.ExtensionPoint` needs to use the structure- specific `xdr.SorobanTransactionDataExt`, instead.
1 parent c738615 commit 0d719c4

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/sorobandata_builder.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export class SorobanDataBuilder {
4141
resources: new xdr.SorobanResources({
4242
footprint: new xdr.LedgerFootprint({ readOnly: [], readWrite: [] }),
4343
instructions: 0,
44-
readBytes: 0,
44+
diskReadBytes: 0,
4545
writeBytes: 0
4646
}),
47-
ext: new xdr.ExtensionPoint(0),
47+
ext: new xdr.SorobanTransactionDataExt(0),
4848
resourceFee: new xdr.Int64(0)
4949
});
5050
} else if (
@@ -88,14 +88,14 @@ export class SorobanDataBuilder {
8888
* by transaction simulation/preflight from a Soroban RPC server.
8989
*
9090
* @param {number} cpuInstrs number of CPU instructions
91-
* @param {number} readBytes number of bytes being read
92-
* @param {number} writeBytes number of bytes being written
91+
* @param {number} diskReadBytes number of bytes being read from disk
92+
* @param {number} writeBytes number of bytes being written to disk/memory
9393
*
9494
* @returns {SorobanDataBuilder}
9595
*/
96-
setResources(cpuInstrs, readBytes, writeBytes) {
96+
setResources(cpuInstrs, diskReadBytes, writeBytes) {
9797
this._data.resources().instructions(cpuInstrs);
98-
this._data.resources().readBytes(readBytes);
98+
this._data.resources().diskReadBytes(diskReadBytes);
9999
this._data.resources().writeBytes(writeBytes);
100100

101101
return this;

test/unit/sorobandata_builder_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ describe('SorobanTransactionData can be built', function () {
66
const c = new StellarBase.Contract(contractId);
77

88
const sentinel = new xdr.SorobanTransactionData({
9-
ext: new xdr.ExtensionPoint(0),
9+
ext: new xdr.SorobanTransactionDataExt(0),
1010
resources: new xdr.SorobanResources({
1111
footprint: new xdr.LedgerFootprint({ readOnly: [], readWrite: [] }),
1212
instructions: 1,
13-
readBytes: 2,
13+
diskReadBytes: 2,
1414
writeBytes: 3
1515
}),
1616
resourceFee: new xdr.Int64(5)

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ export class SorobanDataBuilder {
11901190
setResourceFee(fee: IntLike): SorobanDataBuilder;
11911191
setResources(
11921192
cpuInstrs: number,
1193-
readBytes: number,
1193+
diskReadBytes: number,
11941194
writeBytes: number
11951195
): SorobanDataBuilder;
11961196

0 commit comments

Comments
 (0)