Skip to content

Commit

Permalink
break SetFee
Browse files Browse the repository at this point in the history
  • Loading branch information
nkramer44 committed Oct 18, 2024
1 parent 4ded61d commit 58a2099
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.xrpl.xrpl4j.model.jackson.modules.BaseFeeDropsDeserializer;

import java.util.Optional;

import javax.annotation.Nullable;

/**
Expand All @@ -56,14 +57,13 @@ static ImmutableSetFee.Builder builder() {
/**
* The charge, in drops of XRP, for the reference transaction, as hex. (This is the transaction cost before scaling
* for load.)
* <p>
* This method only exists for historical purposes. When deserialized from a {@link SetFee} transaction from ledgers
* prior to the {@code XRPFees} amendment, this field will still be set based on {@link #baseFeeDrops()}.
*
* @return A hex {@link String} baseFee value.
*
* @deprecated Prefer {@link #baseFeeDrops()} over this field because the XRPFees ammendment now serializes this
* object's base fee into XRP drops.
*/
@Value.Default
@Deprecated
@Value.Derived
@JsonIgnore
default String baseFee() {
return baseFeeDrops().value().toString(16);
Expand All @@ -83,40 +83,24 @@ default String baseFee() {
XrpCurrencyAmount baseFeeDrops();

/**
* The cost, in fee units, of the reference transaction. This field can be {@code null} if this {@link SetFee}
* transaction was included in a ledger after the XRPFees amendment was enabled because this amendment removes the
* {@code ReferenceFeeUnits} field from the {@link SetFee} transaction.
* The cost, in fee units, of the reference transaction. {@link SetFee} transactions deserialized from ledgers prior
* to the {@code XRPFees} amendment will always have this field, but transactions deserialized from ledgers post
* {@code XRPFees} activation will never have this field.
*
* @return An {@link UnsignedInteger} cost of ref transaction.
*
* @deprecated Prefer {@link #maybeReferenceFeeUnits()} over this field.
*/
@Deprecated
@Nullable
@Value.Default
@JsonIgnore
default UnsignedInteger referenceFeeUnits() {
return maybeReferenceFeeUnits().orElse(null);
}

/**
* The cost, in fee units, of the reference transaction, or empty if this {@link SetFee} transaction occurred after
* the XRPFees amendment was enabled.
*
* @return An optionally-present {@link UnsignedInteger}.
*/
@JsonProperty("ReferenceFeeUnits")
Optional<UnsignedInteger> maybeReferenceFeeUnits();
Optional<UnsignedInteger> referenceFeeUnits();

/**
* The base reserve, in drops.
* <p>
* This method only exists for historical purposes. When deserialized from a {@link SetFee} transaction from ledgers
* prior to the {@code XRPFees} amendment, this field will still be set based on {@link #reserveBaseDrops()}}.
*
* @return An {@link UnsignedInteger} base reserve value in {@link org.xrpl.xrpl4j.model.client.fees.FeeDrops}.
*
* @deprecated Prefer {@link #reserveBaseDrops()} over this field.
*/
@Value.Default
@Deprecated
@Value.Derived
@JsonIgnore
default UnsignedInteger reserveBase() {
return UnsignedInteger.valueOf(reserveBaseDrops().value().longValue());
Expand All @@ -136,14 +120,14 @@ default UnsignedInteger reserveBase() {

/**
* The incremental reserve, in drops.
* <p>
* This method only exists for historical purposes. When deserialized from a {@link SetFee} transaction from ledgers
* prior to the {@code XRPFees} amendment, this field will still be set based on {@link #reserveIncrementDrops()}.
*
* @return An {@link UnsignedInteger} incremental reserve in {@link org.xrpl.xrpl4j.model.client.fees.FeeDrops}.
*
* @deprecated Prefer {@link #reserveIncrementDrops()} over this field.
*/
@Deprecated
@Value.Derived
@JsonIgnore
@Value.Default
default UnsignedInteger reserveIncrement() {
return UnsignedInteger.valueOf(reserveIncrementDrops().value().longValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public void testConstructWithNoFeeUnits() {
assertThat(setFee.ledgerSequence()).isNotEmpty().get().isEqualTo(LedgerIndex.of(UnsignedInteger.valueOf(67850752)));
assertThat(setFee.baseFee()).isEqualTo("a");
assertThat(setFee.baseFeeDrops()).isEqualTo(XrpCurrencyAmount.ofDrops(10));
assertThat(setFee.referenceFeeUnits()).isNull();
assertThat(setFee.maybeReferenceFeeUnits()).isEmpty();
assertThat(setFee.referenceFeeUnits()).isEmpty();
assertThat(setFee.reserveIncrement()).isEqualTo(UnsignedInteger.valueOf(5000000));
assertThat(setFee.reserveIncrementDrops()).isEqualTo(XrpCurrencyAmount.ofDrops(5000000));
assertThat(setFee.reserveBase()).isEqualTo(UnsignedInteger.valueOf(20000000));
Expand All @@ -73,7 +72,7 @@ public void testConstructWithFeeUnits() {
.baseFeeDrops(XrpCurrencyAmount.ofDrops(10))
.reserveBaseDrops(XrpCurrencyAmount.ofDrops(20000000))
.reserveIncrementDrops(XrpCurrencyAmount.ofDrops(5000000))
.maybeReferenceFeeUnits(UnsignedInteger.valueOf(10))
.referenceFeeUnits(UnsignedInteger.valueOf(10))
.ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(67850752))))
.build();

Expand All @@ -84,8 +83,7 @@ public void testConstructWithFeeUnits() {
assertThat(setFee.ledgerSequence()).isNotEmpty().get().isEqualTo(LedgerIndex.of(UnsignedInteger.valueOf(67850752)));
assertThat(setFee.baseFee()).isEqualTo("a");
assertThat(setFee.baseFeeDrops()).isEqualTo(XrpCurrencyAmount.ofDrops(10));
assertThat(setFee.referenceFeeUnits()).isNotNull().isEqualTo(UnsignedInteger.valueOf(10));
assertThat(setFee.maybeReferenceFeeUnits()).isNotEmpty().get().isEqualTo(UnsignedInteger.valueOf(10));
assertThat(setFee.referenceFeeUnits()).isNotEmpty().get().isEqualTo(UnsignedInteger.valueOf(10));
assertThat(setFee.reserveIncrement()).isEqualTo(UnsignedInteger.valueOf(5000000));
assertThat(setFee.reserveIncrementDrops()).isEqualTo(XrpCurrencyAmount.ofDrops(5000000));
assertThat(setFee.reserveBase()).isEqualTo(UnsignedInteger.valueOf(20000000));
Expand All @@ -99,7 +97,7 @@ public void testDeserializePreXrpFeesTransaction() throws JsonProcessingExceptio
.fee(XrpCurrencyAmount.ofDrops(12))
.sequence(UnsignedInteger.valueOf(2470665))
.baseFeeDrops(XrpCurrencyAmount.ofDrops(10))
.maybeReferenceFeeUnits(UnsignedInteger.valueOf(10))
.referenceFeeUnits(UnsignedInteger.valueOf(10))
.reserveBaseDrops(XrpCurrencyAmount.ofDrops(20000000))
.reserveIncrementDrops(XrpCurrencyAmount.ofDrops(5000000))
.ledgerSequence(Optional.of(LedgerIndex.of(UnsignedInteger.valueOf(67850752))))
Expand Down

0 comments on commit 58a2099

Please sign in to comment.