Skip to content

Commit

Permalink
remove setFootprint
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Aug 14, 2023
1 parent 9acb455 commit 4da8f81
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 51 deletions.
27 changes: 0 additions & 27 deletions src/main/java/org/stellar/sdk/SorobanDataBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,33 +103,6 @@ public SorobanDataBuilder setResources(
return this;
}

/**
* Sets the storage access footprint to be a certain set of ledger keys.
*
* <p>You can also set each field explicitly via {@link
* SorobanDataBuilder#setReadOnly(Collection)} and {@link
* SorobanDataBuilder#setReadWrite(Collection)}.
*
* <p>Passing {@code null} to either parameter will leave that portion of the footprint untouched.
* If you want to clear a portion of the footprint, pass an empty collection.
*
* @param readOnly the set of ledger keys to set in the read-only portion of the transaction's
* sorobanData
* @param readWrite the set of ledger keys to set in the read-write portion of the transaction's
* sorobanData
* @return this builder instance
*/
public SorobanDataBuilder setFootprint(
@Nullable Collection<LedgerKey> readOnly, @Nullable Collection<LedgerKey> readWrite) {
if (readOnly != null) {
data.getResources().getFootprint().setReadOnly(readOnly.toArray(new LedgerKey[0]));
}
if (readWrite != null) {
data.getResources().getFootprint().setReadWrite(readWrite.toArray(new LedgerKey[0]));
}
return this;
}

/**
* Sets the read-only portion of the storage access footprint to be a certain set of ledger keys.
*
Expand Down
26 changes: 2 additions & 24 deletions src/test/java/org/stellar/sdk/SorobanDataBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,14 @@ public void testConstructorFromSorobanTransactionData() {

@Test
public void testSetProperties() {
SorobanTransactionData actualData0 =
SorobanTransactionData actualData =
new SorobanDataBuilder()
.setReadOnly(of(readOnly))
.setReadWrite(of(readWrite))
.setRefundableFee(5)
.setResources(1, 2, 3, 4)
.build();
assertEquals(presetSorobanData, actualData0);

SorobanTransactionData actualData1 =
new SorobanDataBuilder()
.setFootprint(of(readOnly), of(readWrite))
.setRefundableFee(5)
.setResources(1, 2, 3, 4)
.build();
assertEquals(presetSorobanData, actualData1);
assertEquals(presetSorobanData, actualData);
}

@Test
Expand All @@ -136,20 +128,6 @@ public void testLeavesUntouchedFootprintsUntouched() {
SorobanTransactionData data4 =
new SorobanDataBuilder(presetSorobanData).setReadWrite(new ArrayList<>()).build();
assertArrayEquals(new LedgerKey[] {}, data4.getResources().getFootprint().getReadWrite());

SorobanTransactionData data5 =
new SorobanDataBuilder(presetSorobanData).setFootprint(null, null).build();
assertArrayEquals(
new LedgerKey[] {readOnly}, data5.getResources().getFootprint().getReadOnly());
assertArrayEquals(
new LedgerKey[] {readWrite}, data5.getResources().getFootprint().getReadWrite());

SorobanTransactionData data6 =
new SorobanDataBuilder(presetSorobanData)
.setFootprint(new ArrayList<>(), new ArrayList<>())
.build();
assertArrayEquals(new LedgerKey[] {}, data6.getResources().getFootprint().getReadOnly());
assertArrayEquals(new LedgerKey[] {}, data6.getResources().getFootprint().getReadWrite());
}

@Test
Expand Down

0 comments on commit 4da8f81

Please sign in to comment.