From 3c5eca7e38df64d22804930cacfbb7d370293f0a Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 16 Nov 2022 14:28:12 -0500 Subject: [PATCH 01/53] add lsfAMM to AccountRoot --- .../org/xrpl/xrpl4j/model/flags/Flags.java | 18 ++++++++++++++++-- .../model/flags/AccountRootFlagsTests.java | 13 ++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java index 3921ab6fe..7bbdf7790 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -410,6 +410,11 @@ public static class AccountRootFlags extends Flags { */ public static final AccountRootFlags REQUIRE_DEST_TAG = new AccountRootFlags(0x00020000); + /** + * Constant {@link AccountRootFlags} for the {@code lsfAMM} account flag. + */ + public static final AccountRootFlags AMM = new AccountRootFlags(0x02000000); + /** * Required-args Constructor. * @@ -512,6 +517,15 @@ public boolean lsfRequireAuth() { public boolean lsfRequireDestTag() { return this.isSet(AccountRootFlags.REQUIRE_DEST_TAG); } + + /** + * This account is an Automated Market Maker instance. + * + * @return {@code true} if {@code lsfAMM} is set, otherwise {@code false}. + */ + public boolean lsfAMM() { + return this.isSet(AccountRootFlags.AMM); + } } /** diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java index 19bc3865d..7ffd5e719 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ public class AccountRootFlagsTests extends AbstractFlagsTest { public static Stream data() { - return getBooleanCombinations(9); + return getBooleanCombinations(10); } @ParameterizedTest @@ -45,7 +45,8 @@ public void testDeriveIndividualFlagsFromFlags( boolean lsfNoFreeze, boolean lsfPasswordSpent, boolean lsfRequireAuth, - boolean lsfRequireDestTag + boolean lsfRequireDestTag, + boolean lsfAMM ) { long expectedFlags = (lsfDefaultRipple ? Flags.AccountRootFlags.DEFAULT_RIPPLE.getValue() : 0L) | (lsfDepositAuth ? Flags.AccountRootFlags.DEPOSIT_AUTH.getValue() : 0L) | @@ -55,7 +56,8 @@ public void testDeriveIndividualFlagsFromFlags( (lsfNoFreeze ? Flags.AccountRootFlags.NO_FREEZE.getValue() : 0L) | (lsfPasswordSpent ? Flags.AccountRootFlags.PASSWORD_SPENT.getValue() : 0L) | (lsfRequireAuth ? Flags.AccountRootFlags.REQUIRE_AUTH.getValue() : 0L) | - (lsfRequireDestTag ? Flags.AccountRootFlags.REQUIRE_DEST_TAG.getValue() : 0L); + (lsfRequireDestTag ? Flags.AccountRootFlags.REQUIRE_DEST_TAG.getValue() : 0L) | + (lsfAMM ? Flags.AccountRootFlags.AMM.getValue() : 0L); Flags.AccountRootFlags flags = Flags.AccountRootFlags.of(expectedFlags); assertThat(flags.getValue()).isEqualTo(expectedFlags); @@ -69,5 +71,6 @@ public void testDeriveIndividualFlagsFromFlags( assertThat(flags.lsfPasswordSpent()).isEqualTo(lsfPasswordSpent); assertThat(flags.lsfRequireAuth()).isEqualTo(lsfRequireAuth); assertThat(flags.lsfRequireDestTag()).isEqualTo(lsfRequireDestTag); + assertThat(flags.lsfAMM()).isEqualTo(lsfAMM); } } From 1960147a9ab9f1b35fd96ebcc9cc0febfdddc9ca Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 17 Nov 2022 13:40:15 -0500 Subject: [PATCH 02/53] add AMM object mapping --- .../modules/TradingFeeDeserializer.java | 27 ++++ .../jackson/modules/TradingFeeSerializer.java | 26 ++++ .../modules/VoteWeightDeserializer.java | 27 ++++ .../jackson/modules/VoteWeightSerializer.java | 26 ++++ .../model/jackson/modules/Xrpl4jModule.java | 12 +- .../xrpl/xrpl4j/model/ledger/AmmObject.java | 127 ++++++++++++++++++ .../org/xrpl/xrpl4j/model/ledger/Asset.java | 67 +++++++++ .../xrpl/xrpl4j/model/ledger/AuctionSlot.java | 90 +++++++++++++ .../xrpl/xrpl4j/model/ledger/AuthAccount.java | 38 ++++++ .../model/ledger/AuthAccountWrapper.java | 37 +++++ .../xrpl4j/model/ledger/LedgerObject.java | 12 +- .../xrpl/xrpl4j/model/ledger/VoteEntry.java | 52 +++++++ .../xrpl4j/model/ledger/VoteEntryWrapper.java | 38 ++++++ .../xrpl4j/model/transactions/Wrappers.java | 86 +++++++++++- .../xrpl/xrpl4j/model/AbstractJsonTest.java | 31 ++--- .../xrpl4j/model/ledger/AmmObjectTest.java | 118 ++++++++++++++++ .../xrpl/xrpl4j/model/ledger/AssetTest.java | 56 ++++++++ .../xrpl4j/model/ledger/AuctionSlotTest.java | 78 +++++++++++ .../model/ledger/VoteEntryWrapperTest.java | 33 +++++ .../model/transactions/TradingFeeTest.java | 105 +++++++++++++++ .../model/transactions/VoteWeightTest.java | 81 +++++++++++ 21 files changed, 1138 insertions(+), 29 deletions(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeDeserializer.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeSerializer.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightDeserializer.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightSerializer.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AuctionSlotTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapperTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeDeserializer.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeDeserializer.java new file mode 100644 index 000000000..75ee1f426 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeDeserializer.java @@ -0,0 +1,27 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.google.common.primitives.UnsignedInteger; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.io.IOException; + +/** + * Custom Jackson deserializer for {@link TradingFee}s. + */ +public class TradingFeeDeserializer extends StdDeserializer { + + /** + * No-args constructor. + */ + public TradingFeeDeserializer() { + super(TradingFee.class); + } + + @Override + public TradingFee deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + return TradingFee.of(UnsignedInteger.valueOf(jsonParser.getLongValue())); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeSerializer.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeSerializer.java new file mode 100644 index 000000000..98342fef2 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TradingFeeSerializer.java @@ -0,0 +1,26 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.io.IOException; + +/** + * Custom Jackson serializer for {@link TradingFee}s. + */ +public class TradingFeeSerializer extends StdScalarSerializer { + + /** + * No-args constructor. + */ + public TradingFeeSerializer() { + super(TradingFee.class, false); + } + + @Override + public void serialize(TradingFee tradingFee, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeNumber(tradingFee.value().longValue()); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightDeserializer.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightDeserializer.java new file mode 100644 index 000000000..9e3c3d345 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightDeserializer.java @@ -0,0 +1,27 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.google.common.primitives.UnsignedInteger; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +import java.io.IOException; + +/** + * Custom Jackson deserializer for {@link VoteWeight}s. + */ +public class VoteWeightDeserializer extends StdDeserializer { + + /** + * No-args constructor. + */ + public VoteWeightDeserializer() { + super(VoteWeight.class); + } + + @Override + public VoteWeight deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { + return VoteWeight.of(UnsignedInteger.valueOf(jsonParser.getLongValue())); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightSerializer.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightSerializer.java new file mode 100644 index 000000000..a71119b7f --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/VoteWeightSerializer.java @@ -0,0 +1,26 @@ +package org.xrpl.xrpl4j.model.jackson.modules; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +import java.io.IOException; + +/** + * Custom Jackson serializer for {@link VoteWeight}s. + */ +public class VoteWeightSerializer extends StdScalarSerializer { + + /** + * No-args constructor. + */ + public VoteWeightSerializer() { + super(VoteWeight.class, false); + } + + @Override + public void serialize(VoteWeight voteWeight, JsonGenerator gen, SerializerProvider provider) throws IOException { + gen.writeNumber(voteWeight.value().longValue()); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/Xrpl4jModule.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/Xrpl4jModule.java index 67254869a..4f01f74d5 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/Xrpl4jModule.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/Xrpl4jModule.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,8 +38,10 @@ import org.xrpl.xrpl4j.model.transactions.Marker; import org.xrpl.xrpl4j.model.transactions.NfTokenId; import org.xrpl.xrpl4j.model.transactions.NfTokenUri; +import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TransferFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; /** @@ -77,6 +79,12 @@ public Xrpl4jModule() { addSerializer(TransferFee.class, new TransferFeeSerializer()); addDeserializer(TransferFee.class, new TransferFeeDeserializer()); + addSerializer(TradingFee.class, new TradingFeeSerializer()); + addDeserializer(TradingFee.class, new TradingFeeDeserializer()); + + addSerializer(VoteWeight.class, new VoteWeightSerializer()); + addDeserializer(VoteWeight.class, new VoteWeightDeserializer()); + addSerializer(NfTokenUri.class, new NfTokenUriSerializer()); addSerializer(XrpCurrencyAmount.class, new XrpCurrencyAmountSerializer()); diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java new file mode 100644 index 000000000..2274b3a62 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java @@ -0,0 +1,127 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * Represents an AMM ledger object, which describes a single Automated Market Maker instance. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmObject.class) +@JsonDeserialize(as = ImmutableAmmObject.class) +public interface AmmObject extends LedgerObject { + + /** + * Construct a {@code AmmObject} builder. + * + * @return An {@link ImmutableAmmObject.Builder}. + */ + static ImmutableAmmObject.Builder builder() { + return ImmutableAmmObject.builder(); + } + + /** + * The type of ledger object, which will always be "AMM" in this case. + * + * @return Always returns {@link org.xrpl.xrpl4j.model.ledger.LedgerObject.LedgerEntryType#AMM}. + */ + @JsonProperty("LedgerEntryType") + @Value.Derived + default LedgerEntryType ledgerEntryType() { + return LedgerEntryType.AMM; + } + + /** + * A bit-map of boolean flags. No flags are defined for {@link AmmObject}, so this value is always 0. + * + * @return Always {@link Flags#UNSET}. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags flags() { + return Flags.UNSET; + } + + /** + * The definition for one of the two assets this AMM holds. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset") + Asset asset(); + + /** + * The definition for the other asset this AMM holds. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset2") + Asset asset2(); + + /** + * The address of the special account that holds this AMM's assets. + * + * @return An {@link Address}. + */ + @JsonProperty("AMMAccount") + Address ammAccount(); + + /** + * Details of the current owner of the auction slot. + * + * @return An {@link AuctionSlot}. + */ + @JsonProperty("AuctionSlot") + Optional auctionSlot(); + + /** + * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens + * can vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's + * assets which grows with the trading fees collected. + * + * @return An {@link IssuedCurrencyAmount}. + */ + @JsonProperty("LPTokenBalance") + IssuedCurrencyAmount lpTokenBalance(); + + /** + * The percentage fee to be charged for trades against this AMM instance, in units of 1/10,000. The maximum value is + * 1000, for a 1% fee. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + TradingFee tradingFee(); + + /** + * A list of vote objects, representing votes on the pool's trading fee. + * + * @return A {@link List} of {@link VoteEntry}s. + */ + @JsonProperty("VoteSlots") + List voteSlots(); + + /** + * Unwraps the {@link VoteEntryWrapper}s in {@link #voteSlots()} for easier access to {@link VoteEntry}s. + * + * @return A {@link List} of {@link VoteEntry}. + */ + @JsonIgnore + @Value.Derived + default List voteSlotsUnwrapped() { + return voteSlots().stream() + .map(VoteEntryWrapper::voteEntry) + .collect(Collectors.toList()); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java new file mode 100644 index 000000000..89b9e829a --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java @@ -0,0 +1,67 @@ +package org.xrpl.xrpl4j.model.ledger; + +/*- + * ========================LICENSE_START================================= + * xrpl4j :: model + * %% + * Copyright (C) 2020 - 2022 XRPL Foundation and its contributors + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; + +import java.util.Optional; + +/** + * Represents an Asset held by an {@link AmmObject}. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAsset.class) +@JsonDeserialize(as = ImmutableAsset.class) +public interface Asset { + + /** + * Constant {@link Asset} representing XRP. + */ + Asset XRP = Asset.builder().currency("XRP").build(); + + /** + * Construct a {@code Asset} builder. + * + * @return An {@link ImmutableAsset.Builder}. + */ + static ImmutableAsset.Builder builder() { + return ImmutableAsset.builder(); + } + + /** + * Either a 3 character currency code, or a 40 character hexadecimal encoded currency code value. + * + * @return A {@link String} containing the currency code. + */ + String currency(); + + /** + * The {@link Address} of the issuer of the currency, or empty if the currency + * is XRP. + * + * @return The {@link Address} of the issuer account. + */ + Optional
issuer(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java new file mode 100644 index 000000000..3773a3b4f --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java @@ -0,0 +1,90 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Represents an AuctionSlot object in an {@link AmmObject}, containing details of the current owner of the auction + * slot. + */ +// TODO: Add Optional field for amm_info results +@Value.Immutable +@JsonSerialize(as = ImmutableAuctionSlot.class) +@JsonDeserialize(as = ImmutableAuctionSlot.class) +public interface AuctionSlot { + + /** + * Construct a {@code AuctionSlot} builder. + * + * @return An {@link ImmutableAuctionSlot.Builder}. + */ + static ImmutableAuctionSlot.Builder builder() { + return ImmutableAuctionSlot.builder(); + } + + /** + * The current owner of this auction slot. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Address account(); + + /** + * A list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance. + * + * @return A {@link List} of {@link AuthAccountWrapper}s. + */ + @JsonProperty("AuthAccounts") + List authAccounts(); + + /** + * Extracts all the addresses found in the {@link AuthAccount}s found in {@link #authAccounts()}. + * + * @return A {@link List} of {@link Address}. + */ + @JsonIgnore + @Value.Derived + default List
authAccountsAddresses() { + return authAccounts().stream() + .map(AuthAccountWrapper::authAccount) + .map(AuthAccount::account) + .collect(Collectors.toList()); + } + + /** + * The trading fee to be charged to the auction owner. By default this is 0, meaning that the auction owner can trade + * at no fee instead of the standard fee for this AMM. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("DiscountedFee") + TradingFee discountedFee(); + + /** + * The amount the auction owner paid to win this slot, in LP Tokens. + * + * @return An {@link IssuedCurrencyAmount}. + */ + @JsonProperty("Price") + IssuedCurrencyAmount price(); + + /** + * The time when this slot expires, in seconds since the Ripple Epoch. + * + * @return An {@link UnsignedInteger} + */ + @JsonProperty("Expiration") + UnsignedInteger expiration(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java new file mode 100644 index 000000000..a826adfe3 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java @@ -0,0 +1,38 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; + +/** + * An account that is authorized to trade at the discounted fee for an AMM instance. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAuthAccount.class) +@JsonDeserialize(as = ImmutableAuthAccount.class) +public interface AuthAccount { + + /** + * Construct an {@link AuthAccount} containing the specified {@link Address}. + * + * @param account An {@link Address}. + * + * @return An {@link AuthAccount}. + */ + static AuthAccount of(Address account) { + return ImmutableAuthAccount.builder() + .account(account) + .build(); + } + + /** + * The address of the account. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Address account(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java new file mode 100644 index 000000000..c7a5bc19b --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java @@ -0,0 +1,37 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; + +/** + * A wrapper around {@link AuthAccount}s. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAuthAccountWrapper.class) +@JsonDeserialize(as = ImmutableAuthAccountWrapper.class) +public interface AuthAccountWrapper { + + /** + * Construct an {@link AuthAccountWrapper} containing the specified {@link AuthAccount}. + * + * @param authAccount An {@link AuthAccount}. + * + * @return An {@link AuthAccountWrapper}. + */ + static AuthAccountWrapper of(AuthAccount authAccount) { + return ImmutableAuthAccountWrapper.builder() + .authAccount(authAccount) + .build(); + } + + /** + * An {@link AuthAccount}. + * + * @return An {@link AuthAccount}. + */ + @JsonProperty("AuthAccount") + AuthAccount authAccount(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java index 8d7eb34af..9a84c7fb2 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,6 +50,7 @@ @JsonSubTypes.Type(value = ImmutableRippleStateObject.class, name = "RippleState"), @JsonSubTypes.Type(value = ImmutableSignerListObject.class, name = "SignerList"), @JsonSubTypes.Type(value = ImmutableTicketObject.class, name = "Ticket"), + @JsonSubTypes.Type(value = ImmutableAmmObject.class, name = "AMM"), }) // TODO: Uncomment subtypes as we implement public interface LedgerObject { @@ -131,7 +132,12 @@ enum LedgerEntryType { /** * The {@link LedgerEntryType} for {@code TicketObject} ledger objects. */ - TICKET("Ticket"); + TICKET("Ticket"), + + /** + * The {@link LedgerEntryType} for {@code AmmObject} ledger objects. + */ + AMM("AMM"); private final String value; diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java new file mode 100644 index 000000000..5fbbb15a9 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java @@ -0,0 +1,52 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +/** + * Describes a vote for the trading fee on an AMM by an LP. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableVoteEntry.class) +@JsonDeserialize(as = ImmutableVoteEntry.class) +public interface VoteEntry { + + /** + * Construct a {@code VoteEntry} builder. + * + * @return An {@link ImmutableVoteEntry.Builder}. + */ + static ImmutableVoteEntry.Builder builder() { + return ImmutableVoteEntry.builder(); + } + + /** + * The address of the LP who voted. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Address account(); + + /** + * The trading fee that the LP voted for. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + TradingFee tradingFee(); + + /** + * The weight of the LP's vote. + * + * @return The {@link VoteWeight}. + */ + @JsonProperty("VoteWeight") + VoteWeight voteWeight(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java new file mode 100644 index 000000000..560a328b0 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java @@ -0,0 +1,38 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; + +/** + * A wrapper around a {@link VoteEntry}. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableVoteEntryWrapper.class) +@JsonDeserialize(as = ImmutableVoteEntryWrapper.class) +public interface VoteEntryWrapper { + + /** + * Construct a {@link VoteEntryWrapper} containing the specified + * {@link VoteEntry}. + * + * @param voteEntry A {@link VoteEntry}. + * + * @return A {@link VoteEntryWrapper}. + */ + static VoteEntryWrapper of(VoteEntry voteEntry) { + return ImmutableVoteEntryWrapper.builder() + .voteEntry(voteEntry) + .build(); + } + + /** + * A {@link VoteEntry}. + * + * @return A {@link VoteEntry}. + */ + @JsonProperty("VoteEntry") + VoteEntry voteEntry(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index de63c5a93..287472eaf 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,7 +64,7 @@ public String toString() { */ @Value.Check public void validateAddress() { - Preconditions.checkArgument(this.value().startsWith("r"),"Invalid Address: Bad Prefix"); + Preconditions.checkArgument(this.value().startsWith("r"), "Invalid Address: Bad Prefix"); Preconditions.checkArgument(this.value().length() >= 25 && this.value().length() <= 35, "Classic Addresses must be (25,35) characters long inclusive."); } @@ -361,9 +361,10 @@ public String toString() { * Construct {@link TransferFee} as a percentage value. * * @param percent of type {@link BigDecimal} + * * @return {@link TransferFee} */ - static TransferFee ofPercent(BigDecimal percent) { + public static TransferFee ofPercent(BigDecimal percent) { Preconditions.checkArgument( Math.max(0, percent.stripTrailingZeros().scale()) <= 2, "Percent value should have a maximum of 2 decimal places." @@ -384,5 +385,80 @@ public void validateBounds() { } } - + + /** + * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. + */ + @Value.Immutable + @Wrapped + @JsonSerialize(as = TradingFee.class) + @JsonDeserialize(as = TradingFee.class) + abstract static class _TradingFee extends Wrapper implements Serializable { + + @Override + public String toString() { + return this.value().toString(); + } + + /** + * Construct {@link TradingFee} as a percentage value. + * + * @param percent The trading fee, as a {@link BigDecimal}. + * + * @return A {@link TradingFee}. + */ + public static TradingFee ofPercent(BigDecimal percent) { + Preconditions.checkArgument( + Math.max(0, percent.stripTrailingZeros().scale()) <= 3, + "Percent value should have a maximum of 3 decimal places." + ); + return TradingFee.of(UnsignedInteger.valueOf(percent.scaleByPowerOfTen(3).toBigIntegerExact())); + } + + /** + * Get the {@link TradingFee} as a {@link BigDecimal}. + * + * @return A {@link BigDecimal}. + */ + public BigDecimal bigDecimalValue() { + return BigDecimal.valueOf(value().longValue(), 3); + } + + /** + * Validates that a TradingFee is not more than 1%, or 1000. + */ + @Value.Check + public void validateBounds() { + Preconditions.checkArgument( + FluentCompareTo.is(value()).lessThanOrEqualTo(UnsignedInteger.valueOf(1_000)), + "TradingFee should be in the range 0 to 1000." + ); + } + + } + + /** + * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the VoteWeight. + */ + @Value.Immutable + @Wrapped + @JsonSerialize(as = VoteWeight.class) + @JsonDeserialize(as = VoteWeight.class) + abstract static class _VoteWeight extends Wrapper implements Serializable { + + @Override + public String toString() { + return this.value().toString(); + } + + /** + * Get the {@link VoteWeight} as a {@link BigDecimal}. + * + * @return A {@link BigDecimal}. + */ + public BigDecimal bigDecimalValue() { + return BigDecimal.valueOf(value().longValue(), 3); + } + + } } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java index ef1a9d5f7..c7a6a6d6e 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java @@ -48,13 +48,17 @@ public void setUp() { objectMapper = ObjectMapperFactory.create(); } - protected void assertCanSerializeAndDeserialize(Transaction transaction, String json) - throws JsonProcessingException, JSONException { - String serialized = objectMapper.writeValueAsString(transaction); + protected void assertCanSerializeAndDeserialize(T object, String json, Class clazz) throws JSONException, JsonProcessingException { + String serialized = objectMapper.writeValueAsString(object); JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); - Transaction deserialized = objectMapper.readValue(serialized, Transaction.class); - assertThat(deserialized).isEqualTo(transaction); + T deserialized = objectMapper.readValue(serialized, clazz); + assertThat(deserialized).isEqualTo(object); + } + + protected void assertCanSerializeAndDeserialize(Transaction transaction, String json) + throws JsonProcessingException, JSONException { + assertCanSerializeAndDeserialize(transaction, json, Transaction.class); } protected void assertCanSerializeAndDeserialize(XrplResult result, String json) @@ -77,11 +81,7 @@ protected void assertCanSerializeAndDeserialize(XrplRequestParams params, String protected void assertCanSerializeAndDeserialize(LedgerObject ledgerObject, String json) throws JsonProcessingException, JSONException { - String serialized = objectMapper.writeValueAsString(ledgerObject); - JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); - - LedgerObject deserialized = objectMapper.readValue(serialized, LedgerObject.class); - assertThat(deserialized).isEqualTo(ledgerObject); + assertCanSerializeAndDeserialize(ledgerObject, json, LedgerObject.class); } @Deprecated @@ -96,15 +96,8 @@ protected void assertCanSerializeAndDeserialize(ServerInfoLedger serverInfoLedge protected void assertCanSerializeAndDeserialize( ValidatedLedger serverInfoLedger, String json - ) - throws JsonProcessingException, JSONException { - String serialized = objectMapper.writeValueAsString(serverInfoLedger); - JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); - - ValidatedLedger deserialized = objectMapper.readValue( - serialized, ValidatedLedger.class - ); - assertThat(deserialized).isEqualTo(serverInfoLedger); + ) throws JsonProcessingException, JSONException { + assertCanSerializeAndDeserialize(serverInfoLedger, json, ValidatedLedger.class); } protected void assertCanDeserialize(String json, XrplResult result) throws JsonProcessingException { diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java new file mode 100644 index 000000000..3a38cd615 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java @@ -0,0 +1,118 @@ +package org.xrpl.xrpl4j.model.ledger; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.mockito.Mockito.mock; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +class AmmObjectTest extends AbstractJsonTest { + + @Test + void voteSlotsUnwrapped() { + VoteEntry voteEntry1 = VoteEntry.builder() + .account(mock(Address.class)) + .voteWeight(VoteWeight.of(UnsignedInteger.ONE)) + .tradingFee(TradingFee.of(UnsignedInteger.ONE)) + .build(); + VoteEntry voteEntry2 = VoteEntry.builder() + .account(mock(Address.class)) + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(2))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(2))) + .build(); + AmmObject ammObject = AmmObject.builder() + .asset(mock(Asset.class)) + .asset2(mock(Asset.class)) + .ammAccount(mock(Address.class)) + .lpTokenBalance(mock(IssuedCurrencyAmount.class)) + .tradingFee(TradingFee.of(UnsignedInteger.ONE)) + .addVoteSlots( + VoteEntryWrapper.of(voteEntry1), + VoteEntryWrapper.of(voteEntry2) + ) + .build(); + + assertThat(ammObject.voteSlotsUnwrapped()).asList() + .containsExactlyInAnyOrder(voteEntry1, voteEntry2); + } + + @Test + void testJson() throws JSONException, JsonProcessingException { + AmmObject ammObject = AmmObject.builder() + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .lpTokenBalance( + IssuedCurrencyAmount.builder() + .value("71150.53584131501") + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .build() + ) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .addVoteSlots( + VoteEntryWrapper.of( + VoteEntry.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .build() + ) + ) + .auctionSlot( + AuctionSlot.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .addAuthAccounts( + AuthAccountWrapper.of( + AuthAccount.of( + Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg") + ) + ), + AuthAccountWrapper.of( + AuthAccount.of( + Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv") + ) + ) + ) + .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) + .price( + IssuedCurrencyAmount.builder() + .value("0.8696263565463045") + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .build() + ) + .expiration(UnsignedInteger.valueOf(721870180)) + .build() + ) + .build(); + + String json = "{\n" + + " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"LedgerEntryType\" : \"AMM\",\n" + + " \"Asset\" : " + objectMapper.writeValueAsString(ammObject.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(ammObject.asset2()) + "," + + " \"AuctionSlot\" : " + objectMapper.writeValueAsString(ammObject.auctionSlot()) + "," + + " \"Flags\" : 0,\n" + + " \"LPTokenBalance\" : " + objectMapper.writeValueAsString(ammObject.lpTokenBalance()) + "," + + " \"TradingFee\" : 600,\n" + + " \"VoteSlots\" : [\n" + + objectMapper.writeValueAsString(ammObject.voteSlots().get(0)) + + " ]\n" + + "}"; + + assertCanSerializeAndDeserialize(ammObject, json); + } +} \ No newline at end of file diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java new file mode 100644 index 000000000..717a0f9e7 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java @@ -0,0 +1,56 @@ +package org.xrpl.xrpl4j.model.ledger; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.transactions.Address; + +class AssetTest extends AbstractJsonTest { + + @Test + void testXrp() { + assertThat(Asset.XRP.currency()).isEqualTo("XRP"); + assertThat(Asset.XRP.issuer()).isEmpty(); + } + + @Test + void testNonXrp() { + String usd = "USD"; + Address issuer = Address.of("rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); + Asset asset = Asset.builder() + .currency(usd) + .issuer(issuer) + .build(); + + assertThat(asset.currency()).isEqualTo(usd); + assertThat(asset.issuer()).isNotEmpty().get().isEqualTo(issuer); + } + + @Test + void testJsonForXrp() throws JSONException, JsonProcessingException { + String json = "{" + + " \"currency\": \"XRP\"" + + "}"; + + assertCanSerializeAndDeserialize(Asset.XRP, json, Asset.class); + } + + @Test + void testJsonForNonXrp() throws JSONException, JsonProcessingException { + String usd = "USD"; + Address issuer = Address.of("rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); + Asset asset = Asset.builder() + .currency(usd) + .issuer(issuer) + .build(); + String json = "{" + + " \"currency\": \"" + usd + "\"," + + " \"issuer\": \"" + asset.issuer().get().value() + "\"" + + "}"; + + assertCanSerializeAndDeserialize(asset, json, Asset.class); + } +} \ No newline at end of file diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AuctionSlotTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AuctionSlotTest.java new file mode 100644 index 000000000..bb6d9bcb6 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AuctionSlotTest.java @@ -0,0 +1,78 @@ +package org.xrpl.xrpl4j.model.ledger; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.mockito.Mockito.mock; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +class AuctionSlotTest extends AbstractJsonTest { + + @Test + void authAccountsAddresses() { + Address address1 = Address.of("rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); + Address address2 = Address.of("rB1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); + AuctionSlot slot = AuctionSlot.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .discountedFee(TradingFee.of(UnsignedInteger.ONE)) + .price(mock(IssuedCurrencyAmount.class)) + .expiration(UnsignedInteger.ONE) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(address1)), + AuthAccountWrapper.of(AuthAccount.of(address2)) + ) + .build(); + assertThat(slot.authAccountsAddresses()).asList().containsExactlyInAnyOrder(address1, address2); + } + + @Test + void testJson() throws JSONException, JsonProcessingException { + AuctionSlot slot = AuctionSlot.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) + .price( + IssuedCurrencyAmount.builder() + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .value("0.8696263565463045") + .build() + ) + .expiration(UnsignedInteger.valueOf(721870180)) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"DiscountedFee\" : 0,\n" + + " \"Expiration\" : 721870180,\n" + + " \"Price\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"0.8696263565463045\"\n" + + " }\n" + + " }"; + + assertCanSerializeAndDeserialize(slot, json, AuctionSlot.class); + } +} \ No newline at end of file diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapperTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapperTest.java new file mode 100644 index 000000000..89ddcb4f6 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapperTest.java @@ -0,0 +1,33 @@ +package org.xrpl.xrpl4j.model.ledger; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +class VoteEntryWrapperTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + VoteEntryWrapper voteWrapper = VoteEntryWrapper.of( + VoteEntry.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) + .build() + ); + String json = "{\n" + + " \"VoteEntry\" : {\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"TradingFee\" : 600,\n" + + " \"VoteWeight\" : 100000\n" + + " }\n" + + " }"; + + assertCanSerializeAndDeserialize(voteWrapper, json, VoteEntryWrapper.class); + } +} \ No newline at end of file diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java new file mode 100644 index 000000000..95eb191d1 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java @@ -0,0 +1,105 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.assertj.core.api.Assertions; +import org.immutables.value.Value; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; + +import java.math.BigDecimal; + +public class TradingFeeTest { + + ObjectMapper objectMapper = ObjectMapperFactory.create(); + + @Test + void fromUnsignedInteger() { + TradingFee fee = TradingFee.of(UnsignedInteger.ONE); + assertThat(fee.toString()).isEqualTo("1"); + assertThat(fee.value()).isEqualTo(UnsignedInteger.ONE); + } + + @Test + void ofPercent() { + TradingFee fee = TradingFee.ofPercent(BigDecimal.valueOf(0.99900)); + assertThat(fee.value()).isEqualTo(UnsignedInteger.valueOf(999)); + + fee = TradingFee.ofPercent(BigDecimal.valueOf(1.0000)); + assertThat(fee.value()).isEqualTo(UnsignedInteger.valueOf(1000)); + } + + @Test + void ofPercentWithTooManyDecimalPlaces() { + assertThatThrownBy( + () -> TradingFee.ofPercent(BigDecimal.valueOf(0.0001)) + ).isInstanceOf(IllegalArgumentException.class) + .hasMessage("Percent value should have a maximum of 3 decimal places."); + + assertThatThrownBy( + () -> TradingFee.ofPercent(BigDecimal.valueOf(0.0001000)) + ).isInstanceOf(IllegalArgumentException.class) + .hasMessage("Percent value should have a maximum of 3 decimal places."); + } + + @Test + void bigDecimalValue() { + BigDecimal percent = BigDecimal.valueOf(0.001000); + TradingFee fee = TradingFee.ofPercent(percent); + assertThat(fee.bigDecimalValue()).isEqualTo(percent); + } + + @Test + void validateBounds() { + assertThatThrownBy( + () -> TradingFee.of(UnsignedInteger.valueOf(1001)) + ).isInstanceOf(IllegalArgumentException.class) + .hasMessage("TradingFee should be in the range 0 to 1000."); + + assertDoesNotThrow(() -> TradingFee.of(UnsignedInteger.valueOf(1000))); + } + + @Test + void testJson() throws JsonProcessingException, JSONException { + TradingFee tradingFee = TradingFee.of(UnsignedInteger.valueOf(1000)); + TradingFeeWrapper wrapper = TradingFeeWrapper.of(tradingFee); + + String json = "{\"tradingFee\": \"1000\"}"; + assertSerializesAndDeserializes(wrapper, json); + } + + private void assertSerializesAndDeserializes( + TradingFeeWrapper wrapper, + String json + ) throws JsonProcessingException, JSONException { + String serialized = objectMapper.writeValueAsString(wrapper); + JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); + TradingFeeWrapper deserialized = objectMapper.readValue( + serialized, TradingFeeWrapper.class + ); + Assertions.assertThat(deserialized).isEqualTo(wrapper); + } + + @Value.Immutable + @JsonSerialize(as = ImmutableTradingFeeWrapper.class) + @JsonDeserialize(as = ImmutableTradingFeeWrapper.class) + interface TradingFeeWrapper { + + static TradingFeeWrapper of(TradingFee tradingFee) { + return ImmutableTradingFeeWrapper.builder().tradingFee(tradingFee).build(); + } + + TradingFee tradingFee(); + + } +} diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java new file mode 100644 index 000000000..0e04b42a7 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java @@ -0,0 +1,81 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.assertj.core.api.Assertions; +import org.immutables.value.Value; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; + +import java.math.BigDecimal; + +public class VoteWeightTest { + + ObjectMapper objectMapper = ObjectMapperFactory.create(); + + @Test + void bigDecimalValue() { + VoteWeight weight = VoteWeight.of(UnsignedInteger.ZERO); + assertThat(weight.bigDecimalValue().compareTo(BigDecimal.ZERO)).isEqualTo(0); + + weight = VoteWeight.of(UnsignedInteger.ONE); + assertThat(weight.bigDecimalValue().compareTo(BigDecimal.valueOf(0.001))).isEqualTo(0); + + weight = VoteWeight.of(UnsignedInteger.valueOf(999)); + assertThat(weight.bigDecimalValue().compareTo(BigDecimal.valueOf(0.999))).isEqualTo(0); + + weight = VoteWeight.of(UnsignedInteger.valueOf(99_000)); + assertThat(weight.bigDecimalValue().compareTo(BigDecimal.valueOf(99.000))).isEqualTo(0); + + weight = VoteWeight.of(UnsignedInteger.valueOf(100_000)); + assertThat(weight.bigDecimalValue().compareTo(BigDecimal.valueOf(100.000))).isEqualTo(0); + } + + @Test + void testToString() { + VoteWeight weight = VoteWeight.of(UnsignedInteger.ZERO); + assertThat(weight.toString()).isEqualTo(UnsignedInteger.ZERO.toString()); + } + + @Test + void testJson() throws JsonProcessingException, JSONException { + VoteWeight voteWeight = VoteWeight.of(UnsignedInteger.valueOf(1000)); + VoteWeightWrapper wrapper = VoteWeightWrapper.of(voteWeight); + + String json = "{\"voteWeight\": \"1000\"}"; + assertSerializesAndDeserializes(wrapper, json); + } + + private void assertSerializesAndDeserializes( + VoteWeightWrapper wrapper, + String json + ) throws JsonProcessingException, JSONException { + String serialized = objectMapper.writeValueAsString(wrapper); + JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); + VoteWeightWrapper deserialized = objectMapper.readValue( + serialized, VoteWeightWrapper.class + ); + Assertions.assertThat(deserialized).isEqualTo(wrapper); + } + + @Value.Immutable + @JsonSerialize(as = ImmutableVoteWeightWrapper.class) + @JsonDeserialize(as = ImmutableVoteWeightWrapper.class) + interface VoteWeightWrapper { + + static VoteWeightWrapper of(VoteWeight voteWeight) { + return ImmutableVoteWeightWrapper.builder().voteWeight(voteWeight).build(); + } + + VoteWeight voteWeight(); + + } +} From c3cca216fc20f9d02df5355203c9281a599b6353 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 17 Nov 2022 15:27:44 -0500 Subject: [PATCH 03/53] add AmmBid transaction type --- .../xrpl4j/model/transactions/AmmBid.java | 89 ++++++++++++ .../model/transactions/Transaction.java | 1 + .../model/transactions/TransactionType.java | 13 +- .../xrpl4j/model/transactions/AmmBidTest.java | 135 ++++++++++++++++++ 4 files changed, 234 insertions(+), 4 deletions(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java new file mode 100644 index 000000000..56521c93c --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -0,0 +1,89 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; + +import java.util.List; +import java.util.Optional; + +/** + * Object mapping for the AMMBid transaction. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmBid.class) +@JsonDeserialize(as = ImmutableAmmBid.class) +public interface AmmBid extends Transaction { + + /** + * Construct a {@code AmmBid} builder. + * + * @return An {@link ImmutableAmmBid.Builder}. + */ + static ImmutableAmmBid.Builder builder() { + return ImmutableAmmBid.builder(); + } + + /** + * Set of {@link Flags.TransactionFlags}s for this {@link AmmBid}, which only allows the + * {@code tfFullyCanonicalSig} flag. + * + *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for + * proper signature computation in rippled. + * + * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags.TransactionFlags flags() { + return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + } + + /** + * The definition for one of the assets in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset") + Asset asset(); + + /** + * The definition for the other asset in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset2") + Asset asset2(); + + /** + * Pay at least this amount for the slot. Setting this value higher makes it harder for others to outbid you. If + * omitted, pay the minimum necessary to win the bid. + * + * @return An optionally present {@link IssuedCurrencyAmount}. + */ + @JsonProperty("BidMin") + Optional bidMin(); + + /** + * Pay at most this amount for the slot. If the cost to win the bid is higher than this amount, the transaction fails. + * If omitted, pay as much as necessary to win the bid. + * + * @return An optionally present {@link IssuedCurrencyAmount}. + */ + @JsonProperty("BidMax") + Optional bidMax(); + + /** + * A list of up to 4 additional accounts that you allow to trade at the discounted fee. This cannot include the + * address of the transaction sender + * + * @return A {@link List} + */ + @JsonProperty("AuthAccounts") + List authAccounts(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index a4d9154a2..5a195a98c 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -89,6 +89,7 @@ public interface Transaction { .put(ImmutableTrustSet.class, TransactionType.TRUST_SET) .put(ImmutableTicketCreate.class, TransactionType.TICKET_CREATE) .put(ImmutableUnlModify.class, TransactionType.UNL_MODIFY) + .put(ImmutableAmmBid.class, TransactionType.AMM_BID) .build(); /** diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index cdab111a7..cbf1b96b7 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -81,7 +81,7 @@ public enum TransactionType { * The {@link TransactionType} for the {@link NfTokenMint} transaction. */ NFTOKEN_MINT("NFTokenMint"), - + /** * The {@link TransactionType} for the {@link NfTokenBurn} transaction. */ @@ -160,7 +160,12 @@ public enum TransactionType { /** * The {@link TransactionType} for the {@link UnlModify} transaction. */ - UNL_MODIFY("UNLModify"); + UNL_MODIFY("UNLModify"), + + /** + * The {@link TransactionType} for the {@link AmmBid} transaction. + */ + AMM_BID("AMMBid"); private final String value; diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java new file mode 100644 index 000000000..d58be3023 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -0,0 +1,135 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; + +class AmmBidTest extends AbstractJsonTest { + + @Test + void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { + AmmBid bid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 2147483648,\n" + + " \"Sequence\" : 9,\n" + + " \"TransactionType\" : \"AMMBid\"\n" + + "}"; + + assertCanSerializeAndDeserialize(bid, json); + } + + @Test + void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { + AmmBid bid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .bidMax( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .bidMin( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"BidMax\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"BidMin\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 2147483648,\n" + + " \"Sequence\" : 9,\n" + + " \"TransactionType\" : \"AMMBid\"\n" + + "}"; + + assertCanSerializeAndDeserialize(bid, json); + } +} \ No newline at end of file From 53df22a63213ca003bcd7fd105b23bfce2739829 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 18 Nov 2022 10:27:31 -0500 Subject: [PATCH 04/53] update definitions.json --- .../src/main/resources/definitions.json | 1317 ++++++++++++----- 1 file changed, 952 insertions(+), 365 deletions(-) diff --git a/xrpl4j-binary-codec/src/main/resources/definitions.json b/xrpl4j-binary-codec/src/main/resources/definitions.json index 768ae28b3..ab3bc26fa 100644 --- a/xrpl4j-binary-codec/src/main/resources/definitions.json +++ b/xrpl4j-binary-codec/src/main/resources/definitions.json @@ -1,29 +1,33 @@ { "TYPES": { - "Validation": 10003, "Done": -1, + "Unknown": -2, + "NotPresent": 0, + "UInt16": 1, + "UInt32": 2, + "UInt64": 3, "Hash128": 4, + "Hash256": 5, + "Amount": 6, "Blob": 7, "AccountID": 8, - "Amount": 6, - "Hash256": 5, - "UInt8": 16, - "Vector256": 19, "STObject": 14, - "Unknown": -2, - "Transaction": 10001, + "STArray": 15, + "UInt8": 16, "Hash160": 17, "PathSet": 18, + "Vector256": 19, + "UInt96": 20, + "UInt192": 21, + "UInt384": 22, + "UInt512": 23, + "Issue": 24, + "Transaction": 10001, "LedgerEntry": 10002, - "UInt16": 1, - "NotPresent": 0, - "UInt64": 3, - "UInt32": 2, - "STArray": 15 + "Validation": 10003, + "Metadata": 10004 }, "LEDGER_ENTRY_TYPES": { - "Any": -3, - "Child": -2, "Invalid": -1, "AccountRoot": 97, "DirectoryNode": 100, @@ -36,13 +40,17 @@ "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, - "DepositPreauth": 112, "Check": 67, - "Nickname": 110, - "Contract": 99, + "DepositPreauth": 112, + "NegativeUNL": 78, "NFTokenPage": 80, "NFTokenOffer": 55, - "NegativeUNL": 78 + "AMM": 121, + "Any": -3, + "Child": -2, + "Nickname": 110, + "Contract": 99, + "GeneratorMap": 103 }, "FIELDS": [ [ @@ -65,6 +73,166 @@ "type": "Unknown" } ], + [ + "ObjectEndMarker", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "ArrayEndMarker", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "hash", + { + "nth": 257, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" + } + ], + [ + "index", + { + "nth": 258, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Hash256" + } + ], + [ + "taker_gets_funded", + { + "nth": 258, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Amount" + } + ], + [ + "taker_pays_funded", + { + "nth": 259, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": false, + "type": "Amount" + } + ], + [ + "LedgerEntry", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "LedgerEntry" + } + ], + [ + "Transaction", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "Transaction" + } + ], + [ + "Validation", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": false, + "isSigningField": true, + "type": "Validation" + } + ], + [ + "Metadata", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Metadata" + } + ], + [ + "CloseResolution", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "Method", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "TransactionResult", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "TickSize", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "UNLModifyDisabling", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], + [ + "HookResult", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], [ "LedgerEntryType", { @@ -105,6 +273,66 @@ "type": "UInt16" } ], + [ + "TradingFee", + { + "nth": 5, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], + [ + "Version", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], + [ + "HookStateChangeCount", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], + [ + "HookEmitCount", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], + [ + "HookExecutionIndex", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], + [ + "HookApiVersion", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], [ "Flags", { @@ -456,27 +684,137 @@ } ], [ - "IndexNext", + "SignerListID", { - "nth": 1, + "nth": 38, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "UInt32" } ], [ - "IndexPrevious", + "SettleDelay", { - "nth": 2, + "nth": 39, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "UInt32" } ], [ - "BookNode", + "TicketCount", + { + "nth": 40, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "TicketSequence", + { + "nth": 41, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "NFTokenTaxon", + { + "nth": 42, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "MintedNFTokens", + { + "nth": 43, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "BurnedNFTokens", + { + "nth": 44, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "HookStateCount", + { + "nth": 45, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "EmitGeneration", + { + "nth": 46, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "VoteWeight", + { + "nth": 47, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "DiscountedFee", + { + "nth": 48, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], + [ + "IndexNext", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "IndexPrevious", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "BookNode", { "nth": 3, "isVLEncoded": false, @@ -535,6 +873,96 @@ "type": "UInt64" } ], + [ + "DestinationNode", + { + "nth": 9, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "Cookie", + { + "nth": 10, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ServerVersion", + { + "nth": 11, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "NFTokenOfferNode", + { + "nth": 12, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "EmitBurden", + { + "nth": 13, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookOn", + { + "nth": 16, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookInstructionCount", + { + "nth": 17, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "HookReturnCode", + { + "nth": 18, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "ReferenceCount", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], [ "EmailHash", { @@ -545,6 +973,46 @@ "type": "Hash128" } ], + [ + "TakerPaysCurrency", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "TakerPaysIssuer", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "TakerGetsCurrency", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], + [ + "TakerGetsIssuer", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash160" + } + ], [ "LedgerHash", { @@ -645,6 +1113,46 @@ "type": "Hash256" } ], + [ + "EmitParentTxnID", + { + "nth": 11, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "EmitNonce", + { + "nth": 12, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "EmitHookHash", + { + "nth": 13, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "AMMID", + { + "nth": 14, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], [ "BookDirectory", { @@ -686,9 +1194,9 @@ } ], [ - "TicketID", + "Digest", { - "nth": 20, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -696,9 +1204,9 @@ } ], [ - "Digest", + "Channel", { - "nth": 21, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -706,29 +1214,179 @@ } ], [ - "hash", + "ConsensusHash", { - "nth": 257, + "nth": 23, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Hash256" } ], [ - "index", + "CheckID", { - "nth": 258, + "nth": 24, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "ValidatedHash", + { + "nth": 25, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "PreviousPageMin", + { + "nth": 26, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "NextPageMin", + { + "nth": 27, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "NFTokenBuyOffer", + { + "nth": 28, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "NFTokenSellOffer", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookStateKey", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookHash", + { + "nth": 31, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookNamespace", + { + "nth": 32, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Hash256" + } + ], + [ + "HookSetTxnID", + { + "nth": 33, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, "type": "Hash256" } ], [ "Amount", { - "nth": 1, + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "Balance", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "LimitAmount", + { + "nth": 3, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "TakerPays", + { + "nth": 4, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "TakerGets", + { + "nth": 5, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "LowLimit", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "HighLimit", + { + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -736,9 +1394,9 @@ } ], [ - "Balance", + "Fee", { - "nth": 2, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -746,9 +1404,9 @@ } ], [ - "LimitAmount", + "SendMax", { - "nth": 3, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -756,9 +1414,9 @@ } ], [ - "TakerPays", + "DeliverMin", { - "nth": 4, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -766,9 +1424,9 @@ } ], [ - "TakerGets", + "Amount2", { - "nth": 5, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -776,9 +1434,9 @@ } ], [ - "LowLimit", + "BidMin", { - "nth": 6, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -786,9 +1444,9 @@ } ], [ - "HighLimit", + "BidMax", { - "nth": 7, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -796,9 +1454,9 @@ } ], [ - "Fee", + "MinimumOffer", { - "nth": 8, + "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -806,9 +1464,9 @@ } ], [ - "SendMax", + "RippleEscrow", { - "nth": 9, + "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -816,9 +1474,9 @@ } ], [ - "DeliverMin", + "DeliveredAmount", { - "nth": 10, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -826,9 +1484,9 @@ } ], [ - "MinimumOffer", + "NFTokenBrokerFee", { - "nth": 16, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -836,9 +1494,9 @@ } ], [ - "RippleEscrow", + "LPTokenOut", { - "nth": 17, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -846,9 +1504,9 @@ } ], [ - "DeliveredAmount", + "LPTokenIn", { - "nth": 18, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -856,9 +1514,9 @@ } ], [ - "NFTokenBrokerFee", + "EPrice", { - "nth": 19, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -866,22 +1524,22 @@ } ], [ - "taker_gets_funded", + "Price", { - "nth": 258, + "nth": 23, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], [ - "taker_pays_funded", + "LPTokenBalance", { - "nth": 259, + "nth": 24, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, + "isSerialized": true, + "isSigningField": true, "type": "Amount" } ], @@ -1086,49 +1744,49 @@ } ], [ - "Account", + "HookStateData", { - "nth": 1, + "nth": 22, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Owner", + "HookReturnString", { - "nth": 2, + "nth": 23, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Destination", + "HookParameterName", { - "nth": 3, + "nth": 24, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Issuer", + "HookParameterValue", { - "nth": 4, + "nth": 25, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "AccountID" + "type": "Blob" } ], [ - "Authorize", + "Account", { - "nth": 5, + "nth": 1, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1136,9 +1794,9 @@ } ], [ - "Unauthorize", + "Owner", { - "nth": 6, + "nth": 2, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1146,9 +1804,9 @@ } ], [ - "Target", + "Destination", { - "nth": 7, + "nth": 3, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1156,9 +1814,9 @@ } ], [ - "RegularKey", + "Issuer", { - "nth": 8, + "nth": 4, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1166,9 +1824,9 @@ } ], [ - "NFTokenMinter", + "Authorize", { - "nth": 9, + "nth": 5, "isVLEncoded": true, "isSerialized": true, "isSigningField": true, @@ -1176,623 +1834,533 @@ } ], [ - "ObjectEndMarker", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "TransactionMetaData", - { - "nth": 2, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "CreatedNode", - { - "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "DeletedNode", - { - "nth": 4, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "ModifiedNode", - { - "nth": 5, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "PreviousFields", + "Unauthorize", { "nth": 6, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "FinalFields", - { - "nth": 7, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "NewFields", + "RegularKey", { "nth": 8, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "TemplateEntry", + "NFTokenMinter", { "nth": 9, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "Memo", + "EmitCallback", { "nth": 10, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "SignerEntry", + "AMMAccount", { "nth": 11, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "NFToken", - { - "nth": 12, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "Signer", + "HookAccount", { "nth": 16, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "Majority", - { - "nth": 18, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "AccountID" } ], [ - "DisabledValidator", + "Indexes", { - "nth": 19, - "isVLEncoded": false, + "nth": 1, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STObject" + "type": "Vector256" } ], [ - "ArrayEndMarker", + "Hashes", { - "nth": 1, - "isVLEncoded": false, + "nth": 2, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Signers", + "Amendments", { "nth": 3, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": false, - "type": "STArray" - } - ], - [ - "SignerEntries", - { - "nth": 4, - "isVLEncoded": false, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Template", + "NFTokenOffers", { - "nth": 5, - "isVLEncoded": false, + "nth": 4, + "isVLEncoded": true, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Vector256" } ], [ - "Necessary", + "Paths", { - "nth": 6, + "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "PathSet" } ], [ - "Sufficient", + "Asset", { - "nth": 7, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Issue" } ], [ - "AffectedNodes", + "Asset2", { - "nth": 8, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "Issue" } ], [ - "Memos", + "TransactionMetaData", { - "nth": 9, + "nth": 2, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "NFTokens", + "CreatedNode", { - "nth": 10, + "nth": 3, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "Majorities", + "DeletedNode", { - "nth": 16, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "DisabledValidators", + "ModifiedNode", { - "nth": 17, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "STArray" + "type": "STObject" } ], [ - "CloseResolution", + "PreviousFields", { - "nth": 1, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "Method", + "FinalFields", { - "nth": 2, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TransactionResult", + "NewFields", { - "nth": 3, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STObject" } ], [ - "TakerPaysCurrency", + "TemplateEntry", { - "nth": 1, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerPaysIssuer", + "Memo", { - "nth": 2, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsCurrency", + "SignerEntry", { - "nth": 3, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "TakerGetsIssuer", + "NFToken", { - "nth": 4, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash160" + "type": "STObject" } ], [ - "Paths", + "EmitDetails", { - "nth": 1, + "nth": 13, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "PathSet" + "type": "STObject" } ], [ - "Indexes", + "Hook", { - "nth": 1, - "isVLEncoded": true, + "nth": 14, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Hashes", + "Signer", { - "nth": 2, - "isVLEncoded": true, + "nth": 16, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Amendments", + "Majority", { - "nth": 3, - "isVLEncoded": true, + "nth": 18, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "NFTokenOffers", + "DisabledValidator", { - "nth": 4, - "isVLEncoded": true, + "nth": 19, + "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Vector256" + "type": "STObject" } ], [ - "Transaction", + "EmittedTxn", { - "nth": 1, + "nth": 20, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Transaction" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "LedgerEntry", + "HookExecution", { - "nth": 1, + "nth": 21, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "LedgerEntry" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "Validation", + "HookDefinition", { - "nth": 1, + "nth": 22, "isVLEncoded": false, - "isSerialized": false, - "isSigningField": false, - "type": "Validation" + "isSerialized": true, + "isSigningField": true, + "type": "STObject" } ], [ - "SignerListID", + "HookParameter", { - "nth": 38, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "SettleDelay", + "HookGrant", { - "nth": 39, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketCount", + "VoteEntry", { - "nth": 40, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "TicketSequence", + "AuctionSlot", { - "nth": 41, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "NFTokenTaxon", + "AuthAccount", { - "nth": 42, + "nth": 28, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STObject" } ], [ - "MintedNFTokens", + "Signers", { - "nth": 43, + "nth": 3, "isVLEncoded": false, "isSerialized": true, - "isSigningField": true, - "type": "UInt32" + "isSigningField": false, + "type": "STArray" } ], [ - "BurnedNFTokens", + "SignerEntries", { - "nth": 44, + "nth": 4, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt32" + "type": "STArray" } ], [ - "Channel", + "Template", { - "nth": 22, + "nth": 5, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ConsensusHash", + "Necessary", { - "nth": 23, + "nth": 6, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "CheckID", + "Sufficient", { - "nth": 24, + "nth": 7, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "ValidatedHash", + "AffectedNodes", { - "nth": 25, + "nth": 8, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "PreviousPageMin", + "Memos", { - "nth": 26, + "nth": 9, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NextPageMin", + "NFTokens", { - "nth": 27, + "nth": 10, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenBuyOffer", + "Hooks", { - "nth": 28, + "nth": 11, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "NFTokenSellOffer", + "VoteSlots", { - "nth": 29, + "nth": 14, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Hash256" + "type": "STArray" } ], [ - "TickSize", + "Majorities", { "nth": 16, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "UNLModifyDisabling", + "DisabledValidators", { "nth": 17, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt8" + "type": "STArray" } ], [ - "DestinationNode", + "HookExecutions", { - "nth": 9, + "nth": 18, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "Cookie", + "HookParameters", { - "nth": 10, + "nth": 19, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "ServerVersion", + "HookGrants", { - "nth": 11, + "nth": 20, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ], [ - "NFTokenOfferNode", + "AuthAccounts", { - "nth": 12, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "UInt64" + "type": "STArray" } ] ], @@ -1844,8 +2412,13 @@ "temBAD_TICK_SIZE": -269, "temINVALID_ACCOUNT_ID": -268, "temCANNOT_PREAUTH_SELF": -267, - "temUNCERTAIN": -266, - "temUNKNOWN": -265, + "temINVALID_COUNT": -266, + "temUNCERTAIN": -265, + "temUNKNOWN": -264, + "temSEQ_AND_TICKET": -263, + "temBAD_NFTOKEN_TRANSFER_FEE": -262, + "temBAD_AMM_OPTIONS": -261, + "temBAD_AMM_TOKENS": -260, "tefFAILURE": -199, "tefALREADY": -198, @@ -1867,7 +2440,8 @@ "tefINVARIANT_FAILED": -182, "tefTOO_BIG": -181, "tefNO_TICKET": -180, - "tefTOKEN_IS_NOT_TRANSFERABLE": -179, + "tefNFTOKEN_IS_NOT_TRANSFERABLE": -179, + "terRETRY": -99, "terFUNDS_SPENT": -98, "terINSUF_FEE_B": -97, @@ -1879,6 +2453,8 @@ "terLAST": -91, "terNO_RIPPLE": -90, "terQUEUED": -89, + "terPRE_TICKET": -88, + "terNO_AMM": -87, "tesSUCCESS": 0, @@ -1921,19 +2497,24 @@ "tecHAS_OBLIGATIONS": 151, "tecTOO_SOON": 152, "tecMAX_SEQUENCE_REACHED": 154, - "tecNO_SUITABLE_PAGE": 155, - "tecBUY_SELL_MISMATCH": 156, - "tecOFFER_TYPE_MISMATCH": 157, - "tecCANT_ACCEPT_OWN_OFFER": 158, + "tecNO_SUITABLE_NFTOKEN_PAGE": 155, + "tecNFTOKEN_BUY_SELL_MISMATCH": 156, + "tecNFTOKEN_OFFER_TYPE_MISMATCH": 157, + "tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158, "tecINSUFFICIENT_FUNDS": 159, "tecOBJECT_NOT_FOUND": 160, "tecINSUFFICIENT_PAYMENT": 161, - "tecINCORRECT_ASSET": 162, - "tecTOO_MANY": 163 + "tecUNFUNDED_AMM": 162, + "tecAMM_BALANCE": 163, + "tecAMM_FAILED_DEPOSIT": 164, + "tecAMM_FAILED_WITHDRAW": 165, + "tecAMM_INVALID_TOKENS": 166, + "tecAMM_EXISTS": 167, + "tecAMM_FAILED_BID": 168, + "tecAMM_FAILED_VOTE": 169 }, "TRANSACTION_TYPES": { "Invalid": -1, - "Payment": 0, "EscrowCreate": 1, "EscrowFinish": 2, @@ -1956,11 +2537,17 @@ "DepositPreauth": 19, "TrustSet": 20, "AccountDelete": 21, + "SetHook": 22, "NFTokenMint": 25, "NFTokenBurn": 26, "NFTokenCreateOffer": 27, "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, + "AMMCreate": 35, + "AMMDeposit": 36, + "AMMWithdraw": 37, + "AMMVote": 38, + "AMMBid": 39, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From b078439fbc1097561ca5dd0b76c386f700cd5d96 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 18 Nov 2022 11:22:51 -0500 Subject: [PATCH 05/53] add AmmCreate transaction --- .../xrpl4j/model/transactions/AmmCreate.java | 65 +++++++++++++++++++ .../model/transactions/Transaction.java | 1 + .../model/transactions/TransactionType.java | 22 ++++++- .../model/transactions/AmmCreateTest.java | 45 +++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java new file mode 100644 index 000000000..84b6ca045 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java @@ -0,0 +1,65 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; + +/** + * Object mapping for the AMMCreate transaction. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmCreate.class) +@JsonDeserialize(as = ImmutableAmmCreate.class) +public interface AmmCreate extends Transaction { + + /** + * Construct a {@code AmmCreate} builder. + * + * @return An {@link ImmutableAmmCreate.Builder}. + */ + static ImmutableAmmCreate.Builder builder() { + return ImmutableAmmCreate.builder(); + } + + /** + * Set of {@link Flags.TransactionFlags}s for this {@link AmmCreate}, which only allows the + * {@code tfFullyCanonicalSig} flag. + * + *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for + * proper signature computation in rippled. + * + * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags.TransactionFlags flags() { + return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + } + + /** + * The first of the two assets to fund this AMM with. + * + * @return A {@link CurrencyAmount}. + */ + @JsonProperty("Amount") + CurrencyAmount amount(); + + /** + * The second of the two assets to fund this AMM with. + * + * @return A {@link CurrencyAmount}. + */ + @JsonProperty("Amount2") + CurrencyAmount amount2(); + + /** + * The fee to charge for trades against this AMM instance. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + TradingFee tradingFee(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index 5a195a98c..159ada2cb 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -90,6 +90,7 @@ public interface Transaction { .put(ImmutableTicketCreate.class, TransactionType.TICKET_CREATE) .put(ImmutableUnlModify.class, TransactionType.UNL_MODIFY) .put(ImmutableAmmBid.class, TransactionType.AMM_BID) + .put(ImmutableAmmCreate.class, TransactionType.AMM_CREATE) .build(); /** diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index cbf1b96b7..7afd5b724 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -165,7 +165,27 @@ public enum TransactionType { /** * The {@link TransactionType} for the {@link AmmBid} transaction. */ - AMM_BID("AMMBid"); + AMM_BID("AMMBid"), + + /** + * The {@link TransactionType} for the {@link AmmCreate} transaction. + */ + AMM_CREATE("AMMCreate"), + + /** + * The {@link TransactionType} for the {@link AmmDeposit} transaction. + */ + AMM_DEPOSIT("AMMDeposit"), + + /** + * The {@link TransactionType} for the {@link AmmVote} transaction. + */ + AMM_VOTE("AMMVote"), + + /** + * The {@link TransactionType} for the {@link AmmWithdraw} transaction. + */ + AMM_WITHDRAW("AMMWithdraw"); private final String value; diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java new file mode 100644 index 000000000..398135f1b --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java @@ -0,0 +1,45 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; + +class AmmCreateTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + AmmCreate ammCreate = AmmCreate.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"25\"\n" + + " },\n" + + " \"Amount2\" : \"250000000\",\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 2147483648,\n" + + " \"Sequence\" : 6,\n" + + " \"TradingFee\" : 500,\n" + + " \"TransactionType\" : \"AMMCreate\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammCreate, json); + } +} \ No newline at end of file From c4bed001d08dfad60651be045908799fd3234162 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 18 Nov 2022 15:42:33 -0500 Subject: [PATCH 06/53] add AmmDeposit transaction --- .../org/xrpl/xrpl4j/model/flags/Flags.java | 84 +++++ .../xrpl4j/model/transactions/AmmDeposit.java | 107 ++++++ .../model/transactions/Transaction.java | 1 + .../model/flags/AmmDepositFlagsTest.java | 46 +++ .../model/transactions/AmmDepositTest.java | 353 ++++++++++++++++++ 5 files changed, 591 insertions(+) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java index 7bbdf7790..0b9c3340a 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java @@ -24,6 +24,7 @@ import org.xrpl.xrpl4j.model.ledger.NfTokenOfferObject; import org.xrpl.xrpl4j.model.ledger.PayChannelObject; import org.xrpl.xrpl4j.model.transactions.AccountSet; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; import org.xrpl.xrpl4j.model.transactions.OfferCreate; import org.xrpl.xrpl4j.model.transactions.Payment; @@ -194,6 +195,89 @@ public TransactionFlags build() { } } + /** + * A set of {@link TransactionFlags} that can be set on {@link AmmDeposit} transactions. Exactly + * one flag must be set on each {@link AmmDeposit} transaction, so this class does not allow for combination + * of multiple flags. + */ + public static class AmmDepositFlags extends TransactionFlags { + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLPToken} flag. + */ + public static final AmmDepositFlags LP_TOKEN = new AmmDepositFlags(0x00010000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfSingleAsset} flag. + */ + public static final AmmDepositFlags SINGLE_ASSET = new AmmDepositFlags(0x00080000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfTwoAsset} flag. + */ + public static final AmmDepositFlags TWO_ASSET = new AmmDepositFlags(0x00100000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfOneAssetLPToken} flag. + */ + public static final AmmDepositFlags ONE_ASSET_LP_TOKEN = new AmmDepositFlags(0x00200000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLimitLPToken} flag. + */ + public static final AmmDepositFlags LIMIT_LP_TOKEN = new AmmDepositFlags(0x00400000); + + private AmmDepositFlags(long value) { + super(value); + } + + /** + * Whether the {@code tfLPToken} flag is set. + * + * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. + */ + public boolean tfLPToken() { + return this.isSet(LP_TOKEN); + } + + /** + * Whether the {@code tfSingleAsset} flag is set. + * + * @return {@code true} if {@code tfSingleAsset} is set, otherwise {@code false}. + */ + public boolean tfSingleAsset() { + return this.isSet(SINGLE_ASSET); + } + + /** + * Whether the {@code tfTwoAsset} flag is set. + * + * @return {@code true} if {@code tfTwoAsset} is set, otherwise {@code false}. + */ + public boolean tfTwoAsset() { + return this.isSet(TWO_ASSET); + } + + /** + * Whether the {@code tfOneAssetLPToken} flag is set. + * + * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. + */ + public boolean tfOneAssetLPToken() { + return this.isSet(ONE_ASSET_LP_TOKEN); + } + + /** + * Whether the {@code tfLimitLPToken} flag is set. + * + * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. + */ + public boolean tfLimitLPToken() { + return this.isSet(LIMIT_LP_TOKEN); + } + + } + /** * A set of static {@link TransactionFlags} which can be set on {@link Payment} transactions. */ diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java new file mode 100644 index 000000000..fba75c9f6 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -0,0 +1,107 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; + +import java.util.Optional; + +/** + * Object mapping for the AMMDeposit transaction. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmDeposit.class) +@JsonDeserialize(as = ImmutableAmmDeposit.class) +public interface AmmDeposit extends Transaction { + + /** + * Construct a {@code AmmDeposit} builder. + * + * @return An {@link ImmutableAmmDeposit.Builder}. + */ + static ImmutableAmmDeposit.Builder builder() { + return ImmutableAmmDeposit.builder(); + } + + /** + * A {@link Flags.AmmDepositFlags} for this transaction. + * + * @return A {@link Flags.AmmDepositFlags} for this transaction. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags.AmmDepositFlags flags() { + boolean lpTokenPresent = lpTokenOut().isPresent(); + boolean amountPresent = amount().isPresent(); + boolean amount2Present = amount2().isPresent(); + boolean effectivePricePresent = effectivePrice().isPresent(); + + if (lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent) { + return Flags.AmmDepositFlags.LP_TOKEN; + } else if (!lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent) { + return Flags.AmmDepositFlags.TWO_ASSET; + } else if (!lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { + return Flags.AmmDepositFlags.SINGLE_ASSET; + } else if (lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { + return Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN; + } else if (!lpTokenPresent && amountPresent && !amount2Present) { + return Flags.AmmDepositFlags.LIMIT_LP_TOKEN; + } else { + throw new IllegalStateException("Correct AmmDepositFlag could not be determined based on set fields."); + } + } + + /** + * The definition for one of the assets in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset") + Asset asset(); + + /** + * The definition for the other asset in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset2") + Asset asset2(); + + /** + * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets + * (tokens or XRP) in the AMM's pool. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("Amount") + Optional amount(); + + /** + * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the + * AMM's pool and cannot be the same asset as Amount. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("Amount2") + Optional amount2(); + + /** + * The maximum effective price, in the deposit asset, to pay for each LP Token received. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("EPrice") + Optional effectivePrice(); + + /** + * How many of the AMM's LP Tokens to buy. + * + * @return @return An optionally present {@link IssuedCurrencyAmount}. + */ + @JsonProperty("LPTokenOut") + Optional lpTokenOut(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index 159ada2cb..3390bec00 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -91,6 +91,7 @@ public interface Transaction { .put(ImmutableUnlModify.class, TransactionType.UNL_MODIFY) .put(ImmutableAmmBid.class, TransactionType.AMM_BID) .put(ImmutableAmmCreate.class, TransactionType.AMM_CREATE) + .put(ImmutableAmmDeposit.class, TransactionType.AMM_DEPOSIT) .build(); /** diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java new file mode 100644 index 000000000..1c016c65f --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java @@ -0,0 +1,46 @@ +package org.xrpl.xrpl4j.model.flags; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import org.junit.jupiter.api.Test; + +public class AmmDepositFlagsTest { + + @Test + void testFlagValues() { + Flags.AmmDepositFlags lpToken = Flags.AmmDepositFlags.LP_TOKEN; + assertThat(lpToken.tfLPToken()).isTrue(); + assertThat(lpToken.tfSingleAsset()).isFalse(); + assertThat(lpToken.tfTwoAsset()).isFalse(); + assertThat(lpToken.tfOneAssetLPToken()).isFalse(); + assertThat(lpToken.tfLimitLPToken()).isFalse(); + + Flags.AmmDepositFlags singleAsset = Flags.AmmDepositFlags.SINGLE_ASSET; + assertThat(singleAsset.tfLPToken()).isFalse(); + assertThat(singleAsset.tfSingleAsset()).isTrue(); + assertThat(singleAsset.tfTwoAsset()).isFalse(); + assertThat(singleAsset.tfOneAssetLPToken()).isFalse(); + assertThat(singleAsset.tfLimitLPToken()).isFalse(); + + Flags.AmmDepositFlags twoAsset = Flags.AmmDepositFlags.TWO_ASSET; + assertThat(twoAsset.tfLPToken()).isFalse(); + assertThat(twoAsset.tfSingleAsset()).isFalse(); + assertThat(twoAsset.tfTwoAsset()).isTrue(); + assertThat(twoAsset.tfOneAssetLPToken()).isFalse(); + assertThat(twoAsset.tfLimitLPToken()).isFalse(); + + Flags.AmmDepositFlags oneAssetLpToken = Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN; + assertThat(oneAssetLpToken.tfLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfSingleAsset()).isFalse(); + assertThat(oneAssetLpToken.tfTwoAsset()).isFalse(); + assertThat(oneAssetLpToken.tfOneAssetLPToken()).isTrue(); + assertThat(oneAssetLpToken.tfLimitLPToken()).isFalse(); + + Flags.AmmDepositFlags limitLpToken = Flags.AmmDepositFlags.LIMIT_LP_TOKEN; + assertThat(limitLpToken.tfLPToken()).isFalse(); + assertThat(limitLpToken.tfSingleAsset()).isFalse(); + assertThat(limitLpToken.tfTwoAsset()).isFalse(); + assertThat(limitLpToken.tfOneAssetLPToken()).isFalse(); + assertThat(limitLpToken.tfLimitLPToken()).isTrue(); + } +} diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java new file mode 100644 index 000000000..c763ec80a --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -0,0 +1,353 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +class AmmDepositTest extends AbstractJsonTest { + + @Test + void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ).build(); + + assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.LP_TOKEN); + + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"LPTokenOut\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmDepositFlags.LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } + + @Test + void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .amount( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(10)) + .build(); + + assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.TWO_ASSET); + + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Amount2\" : \"10\"," + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmDepositFlags.TWO_ASSET + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } + + @Test + void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .amount( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .build(); + + assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.SINGLE_ASSET); + + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmDepositFlags.SINGLE_ASSET + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } + + @Test + void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .amount( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .build(); + + assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN); + + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"LPTokenOut\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } + + @Test + void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .amount( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .effectivePrice(XrpCurrencyAmount.ofDrops(10)) + .build(); + + assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.LIMIT_LP_TOKEN); + + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"EPrice\" : \"10\",\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmDepositFlags.LIMIT_LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; + + assertCanSerializeAndDeserialize(deposit, json); + } + + @ParameterizedTest + @MethodSource("getBooleanCombinations") + void testInvalidFieldPresence( + boolean lpTokenPresent, + boolean amountPresent, + boolean amount2Present, + boolean effectivePricePresent + ) { + + ImmutableAmmDeposit.Builder builder = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ); + + if (lpTokenPresent) { + builder.lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ); + } + if (amountPresent) { + builder.amount(XrpCurrencyAmount.ofDrops(10)); + } + if (amount2Present) { + builder.amount2( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ); + } + if (effectivePricePresent) { + builder.effectivePrice(XrpCurrencyAmount.ofDrops(10)); + } + + assertThatThrownBy(builder::build) + .isInstanceOf(IllegalStateException.class) + .hasMessage("Correct AmmDepositFlag could not be determined based on set fields."); + } + + private static Stream getBooleanCombinations() { + // Every combination of 4 booleans + List params = new ArrayList<>(); + for (int i = 0; i < Math.pow(2, 4); i++) { + String bin = Integer.toBinaryString(i); + while (bin.length() < 4) { + bin = "0" + bin; + } + + char[] chars = bin.toCharArray(); + Boolean[] booleans = new Boolean[4]; + for (int j = 0; j < chars.length; j++) { + booleans[j] = chars[j] == '0'; + } + + if (booleans[0] && !booleans[1] && !booleans[2] && !booleans[3]) { + continue; + } + if (!booleans[0] && booleans[1] && booleans[2] && !booleans[3]) { + continue; + } + if (!booleans[0] && booleans[1] && !booleans[2] && !booleans[3]) { + continue; + } + if (booleans[0] && booleans[1] && !booleans[2] && !booleans[3]) { + continue; + } + if (!booleans[0] && booleans[1] && !booleans[2]) { + continue; + } + params.add(booleans); + } + + return params.stream().map(Arguments::of); + } + +} \ No newline at end of file From c06c2480b1ecd181159abc2f8107c5825e4e2246 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 18 Nov 2022 15:56:53 -0500 Subject: [PATCH 07/53] add AmmVote transaction --- .../xrpl4j/model/transactions/AmmDeposit.java | 3 +- .../xrpl4j/model/transactions/AmmVote.java | 67 +++++++++++++++++++ .../model/transactions/Transaction.java | 1 + .../model/transactions/AmmVoteTest.java | 46 +++++++++++++ 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index fba75c9f6..27228714b 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -27,7 +27,8 @@ static ImmutableAmmDeposit.Builder builder() { } /** - * A {@link Flags.AmmDepositFlags} for this transaction. + * A {@link Flags.AmmDepositFlags} for this transaction. This flag will always be derived from the presence + * of {@link #lpTokenOut()}, {@link #amount()}, {@link #amount2()} and {@link #effectivePrice()}. * * @return A {@link Flags.AmmDepositFlags} for this transaction. */ diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java new file mode 100644 index 000000000..591b01fa2 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java @@ -0,0 +1,67 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; + +/** + * Object mapping for the AMMVote transaction. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmVote.class) +@JsonDeserialize(as = ImmutableAmmVote.class) +public interface AmmVote extends Transaction { + + /** + * Construct a {@code AmmVote} builder. + * + * @return An {@link ImmutableAmmVote.Builder}. + */ + static ImmutableAmmVote.Builder builder() { + return ImmutableAmmVote.builder(); + } + + /** + * Set of {@link Flags.TransactionFlags}s for this {@link AmmVote}, which only allows the + * {@code tfFullyCanonicalSig} flag. + * + *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for + * proper signature computation in rippled. + * + * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags.TransactionFlags flags() { + return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + } + + /** + * The definition for one of the assets in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset") + Asset asset(); + + /** + * The definition for the other asset in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset2") + Asset asset2(); + + /** + * The proposed fee to vote for. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + TradingFee tradingFee(); + + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index 3390bec00..81332b2b8 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -92,6 +92,7 @@ public interface Transaction { .put(ImmutableAmmBid.class, TransactionType.AMM_BID) .put(ImmutableAmmCreate.class, TransactionType.AMM_CREATE) .put(ImmutableAmmDeposit.class, TransactionType.AMM_DEPOSIT) + .put(ImmutableAmmVote.class, TransactionType.AMM_VOTE) .build(); /** diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java new file mode 100644 index 000000000..a63cc09c5 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -0,0 +1,46 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.ledger.Asset; + +class AmmVoteTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + AmmVote vote = AmmVote.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 2147483648,\n" + + " \"Sequence\" : 8,\n" + + " \"TradingFee\" : 600,\n" + + " \"TransactionType\" : \"AMMVote\"\n" + + "}"; + + assertCanSerializeAndDeserialize(vote, json); + } +} \ No newline at end of file From 4538d444262ab2d8868b130ba05e7910214dd1bf Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 21 Nov 2022 11:29:05 -0500 Subject: [PATCH 08/53] add AmmWithdraw transaction --- .../org/xrpl/xrpl4j/model/flags/Flags.java | 110 ++++ .../model/transactions/AmmWithdraw.java | 132 +++++ .../model/transactions/Transaction.java | 1 + .../model/flags/AmmWithdrawFlagsTest.java | 75 +++ .../model/transactions/AmmWithdrawTest.java | 483 ++++++++++++++++++ 5 files changed, 801 insertions(+) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java index 0b9c3340a..be35a508e 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java @@ -278,6 +278,116 @@ public boolean tfLimitLPToken() { } + /** + * A set of {@link TransactionFlags} that can be set on {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} + * transactions. Exactly one flag must be set on each {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} + * transaction, so this class does not allow for combination of multiple flags. + */ + public static class AmmWithdrawFlags extends TransactionFlags { + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLPToken} flag. + */ + public static final AmmWithdrawFlags LP_TOKEN = new AmmWithdrawFlags(0x00010000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfWithdrawAll} flag. + */ + public static final AmmWithdrawFlags WITHDRAW_ALL = new AmmWithdrawFlags(0x00020000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfOneAssetWithdrawAll} flag. + */ + public static final AmmWithdrawFlags ONE_ASSET_WITHDRAW_ALL = new AmmWithdrawFlags(0x00040000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfSingleAsset} flag. + */ + public static final AmmWithdrawFlags SINGLE_ASSET = new AmmWithdrawFlags(0x00080000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfTwoAsset} flag. + */ + public static final AmmWithdrawFlags TWO_ASSET = new AmmWithdrawFlags(0x00100000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfOneAssetLPToken} flag. + */ + public static final AmmWithdrawFlags ONE_ASSET_LP_TOKEN = new AmmWithdrawFlags(0x00200000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLimitLPToken} flag. + */ + public static final AmmWithdrawFlags LIMIT_LP_TOKEN = new AmmWithdrawFlags(0x00400000); + + private AmmWithdrawFlags(long value) { + super(value); + } + + /** + * Whether the {@code tfLPToken} flag is set. + * + * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. + */ + public boolean tfLPToken() { + return this.isSet(LP_TOKEN); + } + + /** + * Whether the {@code tfWithdrawAll} flag is set. + * + * @return {@code true} if {@code tfWithdrawAll} is set, otherwise {@code false}. + */ + public boolean tfWithdrawAll() { + return this.isSet(WITHDRAW_ALL); + } + + /** + * Whether the {@code tfOneAssetWithdrawAll} flag is set. + * + * @return {@code true} if {@code tfOneAssetWithdrawAll} is set, otherwise {@code false}. + */ + public boolean tfOneAssetWithdrawAll() { + return this.isSet(ONE_ASSET_WITHDRAW_ALL); + } + + /** + * Whether the {@code tfSingleAsset} flag is set. + * + * @return {@code true} if {@code tfSingleAsset} is set, otherwise {@code false}. + */ + public boolean tfSingleAsset() { + return this.isSet(SINGLE_ASSET); + } + + /** + * Whether the {@code tfTwoAsset} flag is set. + * + * @return {@code true} if {@code tfTwoAsset} is set, otherwise {@code false}. + */ + public boolean tfTwoAsset() { + return this.isSet(TWO_ASSET); + } + + /** + * Whether the {@code tfOneAssetLPToken} flag is set. + * + * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. + */ + public boolean tfOneAssetLPToken() { + return this.isSet(ONE_ASSET_LP_TOKEN); + } + + /** + * Whether the {@code tfLimitLPToken} flag is set. + * + * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. + */ + public boolean tfLimitLPToken() { + return this.isSet(LIMIT_LP_TOKEN); + } + } + /** * A set of static {@link TransactionFlags} which can be set on {@link Payment} transactions. */ diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java new file mode 100644 index 000000000..e23133fe8 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -0,0 +1,132 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.base.Preconditions; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; + +import java.util.Optional; + +/** + * Object mapping for the AMMWithdraw transaction. + */ +public interface AmmWithdraw extends Transaction { + + /** + * Construct a {@code AmmWithdraw} builder. + * + * @return An {@link ImmutableAmmWithdraw.Builder}. + */ + static ImmutableAmmWithdraw.Builder builder() { + return ImmutableAmmWithdraw.builder(); + } + + /** + * A {@link Flags.AmmWithdrawFlags} for this transaction. + * + * @return A {@link Flags.AmmWithdrawFlags} for this transaction. + */ + @JsonProperty("Flags") + Flags.AmmWithdrawFlags flags(); + + /** + * The definition for one of the assets in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset") + Asset asset(); + + /** + * The definition for the other asset in the AMM's pool. + * + * @return An {@link Asset}. + */ + @JsonProperty("Asset2") + Asset asset2(); + + /** + * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets + * (tokens or XRP) in the AMM's pool. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("Amount") + Optional amount(); + + /** + * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the + * AMM's pool and cannot be the same asset as Amount. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("Amount2") + Optional amount2(); + + /** + * The maximum effective price, in the deposit asset, to pay for each LP Token received. + * + * @return An optionally present {@link CurrencyAmount}. + */ + @JsonProperty("EPrice") + Optional effectivePrice(); + + /** + * How many of the AMM's LP Tokens to buy. + * + * @return @return An optionally present {@link IssuedCurrencyAmount}. + */ + @JsonProperty("LPTokensIn") + Optional lpTokensIn(); + + @Value.Immutable + @JsonSerialize(as = ImmutableAmmWithdraw.class) + @JsonDeserialize(as = ImmutableAmmWithdraw.class) + abstract class AbstractAmmWithdraw implements AmmWithdraw { + + @Value.Check + void checkFieldPresenceBasedOnFlags() { + boolean lpTokenPresent = lpTokensIn().isPresent(); + boolean amountPresent = amount().isPresent(); + boolean amount2Present = amount2().isPresent(); + boolean effectivePricePresent = effectivePrice().isPresent(); + + if (flags().tfLPToken()) { + Preconditions.checkState( + lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent, + "If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present." + ); + } else if (flags().tfWithdrawAll()) { + Preconditions.checkState( + !lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent, + "If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present." + ); + } else if (flags().tfTwoAsset()) { + Preconditions.checkState( + !lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent, + "If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present." + ); + } else if (flags().tfSingleAsset() || flags().tfOneAssetWithdrawAll()) { + Preconditions.checkState( + !lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent, + "If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice cannot " + + "be present." + ); + } else if (flags().tfOneAssetLPToken()) { + Preconditions.checkState( + lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent, + "If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present." + ); + } else if (flags().tfLimitLPToken()) { + Preconditions.checkState( + !lpTokenPresent && amountPresent && !amount2Present && effectivePricePresent, + "If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present." + ); + } + } + + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index 81332b2b8..38ada9a6f 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -93,6 +93,7 @@ public interface Transaction { .put(ImmutableAmmCreate.class, TransactionType.AMM_CREATE) .put(ImmutableAmmDeposit.class, TransactionType.AMM_DEPOSIT) .put(ImmutableAmmVote.class, TransactionType.AMM_VOTE) + .put(ImmutableAmmWithdraw.class, TransactionType.AMM_WITHDRAW) .build(); /** diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java new file mode 100644 index 000000000..873d98b9b --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java @@ -0,0 +1,75 @@ +package org.xrpl.xrpl4j.model.flags; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import org.junit.jupiter.api.Test; + +public class AmmWithdrawFlagsTest { + + @Test + void testFlagValues() { + Flags.AmmWithdrawFlags lpToken = Flags.AmmWithdrawFlags.LP_TOKEN; + assertThat(lpToken.tfLPToken()).isTrue(); + assertThat(lpToken.tfWithdrawAll()).isFalse(); + assertThat(lpToken.tfOneAssetWithdrawAll()).isFalse(); + assertThat(lpToken.tfSingleAsset()).isFalse(); + assertThat(lpToken.tfTwoAsset()).isFalse(); + assertThat(lpToken.tfOneAssetLPToken()).isFalse(); + assertThat(lpToken.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags withdrawAll = Flags.AmmWithdrawFlags.WITHDRAW_ALL; + assertThat(withdrawAll.tfLPToken()).isFalse(); + assertThat(withdrawAll.tfWithdrawAll()).isTrue(); + assertThat(withdrawAll.tfOneAssetWithdrawAll()).isFalse(); + assertThat(withdrawAll.tfSingleAsset()).isFalse(); + assertThat(withdrawAll.tfTwoAsset()).isFalse(); + assertThat(withdrawAll.tfOneAssetLPToken()).isFalse(); + assertThat(withdrawAll.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags oneAssetWithdrawAll = Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL; + assertThat(oneAssetWithdrawAll.tfLPToken()).isFalse(); + assertThat(oneAssetWithdrawAll.tfWithdrawAll()).isFalse(); + assertThat(oneAssetWithdrawAll.tfOneAssetWithdrawAll()).isTrue(); + assertThat(oneAssetWithdrawAll.tfSingleAsset()).isFalse(); + assertThat(oneAssetWithdrawAll.tfTwoAsset()).isFalse(); + assertThat(oneAssetWithdrawAll.tfOneAssetLPToken()).isFalse(); + assertThat(oneAssetWithdrawAll.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags singleAsset = Flags.AmmWithdrawFlags.SINGLE_ASSET; + assertThat(singleAsset.tfLPToken()).isFalse(); + assertThat(singleAsset.tfWithdrawAll()).isFalse(); + assertThat(singleAsset.tfOneAssetWithdrawAll()).isFalse(); + assertThat(singleAsset.tfSingleAsset()).isTrue(); + assertThat(singleAsset.tfTwoAsset()).isFalse(); + assertThat(singleAsset.tfOneAssetLPToken()).isFalse(); + assertThat(singleAsset.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags twoAsset = Flags.AmmWithdrawFlags.TWO_ASSET; + assertThat(twoAsset.tfLPToken()).isFalse(); + assertThat(twoAsset.tfWithdrawAll()).isFalse(); + assertThat(twoAsset.tfOneAssetWithdrawAll()).isFalse(); + assertThat(twoAsset.tfSingleAsset()).isFalse(); + assertThat(twoAsset.tfTwoAsset()).isTrue(); + assertThat(twoAsset.tfOneAssetLPToken()).isFalse(); + assertThat(twoAsset.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags oneAssetLpToken = Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN; + assertThat(oneAssetLpToken.tfLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfWithdrawAll()).isFalse(); + assertThat(oneAssetLpToken.tfOneAssetWithdrawAll()).isFalse(); + assertThat(oneAssetLpToken.tfSingleAsset()).isFalse(); + assertThat(oneAssetLpToken.tfTwoAsset()).isFalse(); + assertThat(oneAssetLpToken.tfOneAssetLPToken()).isTrue(); + assertThat(oneAssetLpToken.tfLimitLPToken()).isFalse(); + + Flags.AmmWithdrawFlags limitLpToken = Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN; + assertThat(limitLpToken.tfLPToken()).isFalse(); + assertThat(limitLpToken.tfWithdrawAll()).isFalse(); + assertThat(limitLpToken.tfOneAssetWithdrawAll()).isFalse(); + assertThat(limitLpToken.tfSingleAsset()).isFalse(); + assertThat(limitLpToken.tfTwoAsset()).isFalse(); + assertThat(limitLpToken.tfOneAssetLPToken()).isFalse(); + assertThat(limitLpToken.tfLimitLPToken()).isTrue(); + + } +} diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java new file mode 100644 index 000000000..259562ce1 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -0,0 +1,483 @@ +package org.xrpl.xrpl4j.model.transactions; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; + +class AmmWithdrawTest extends AbstractJsonTest { + + @Test + void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"LPTokensIn\" : " + objectMapper.writeValueAsString(withdraw.lpTokensIn()) + "," + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructWithdrawAllAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.WITHDRAW_ALL + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructTwoAssetAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .amount(amount()) + .amount2(XrpCurrencyAmount.ofDrops(50000000)) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"5\"\n" + + " },\n" + + " \"Amount2\" : \"50000000\"," + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.TWO_ASSET + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructSingleAssetAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .amount(amount()) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"5\"\n" + + " },\n" + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.SINGLE_ASSET + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructOneAssetWithdrawAllAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .amount(amount()) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"5\"\n" + + " },\n" + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructOneAssetLpTokenAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .amount(amount()) + .lpTokensIn(lpTokensIn()) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"5\"\n" + + " },\n" + + " \"LPTokensIn\" : " + objectMapper.writeValueAsString(withdraw.lpTokensIn()) + "," + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingException { + AmmWithdraw withdraw = baseBuilder() + .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .amount(amount()) + .effectivePrice(amount()) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"5\"\n" + + " },\n" + + " \"EPrice\" : " + objectMapper.writeValueAsString(withdraw.effectivePrice()) + "," + + " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN + ",\n" + + " \"Sequence\" : 0,\n" + + " \"TransactionType\" : \"AMMWithdraw\"\n" + + "}"; + + assertCanSerializeAndDeserialize(withdraw, json); + } + + @Test + void constructLpTokenWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .amount(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); + } + + @Test + void constructWithdrawAllWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .lpTokensIn(lpTokensIn()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .amount(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); + } + + @Test + void constructTwoAssetWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .lpTokensIn(lpTokensIn()) + .amount(amount()) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .amount(amount()) + .amount2(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .amount(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); + } + + @Test + void constructSingleAssetWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .amount(amount()) + .lpTokensIn(lpTokensIn()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .amount(amount()) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .amount(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + } + + @Test + void constructOneAssetWithdrawAllWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .amount(amount()) + .lpTokensIn(lpTokensIn()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .amount(amount()) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .amount(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + + " cannot be present."); + } + + @Test + void constructOneAssetLpTokenWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .amount(amount()) + .amount2(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .amount(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .amount(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); + } + + @Test + void constructLimitLpTokenWithWrongFieldsPresent() { + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .lpTokensIn(lpTokensIn()) + .amount(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .amount(amount()) + .amount2(amount()) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .amount(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); + + assertThatThrownBy( + () -> baseBuilder() + .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .effectivePrice(amount()) + .build() + ).isInstanceOf(IllegalStateException.class) + .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); + } + + private ImmutableIssuedCurrencyAmount amount() { + return IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("5") + .build(); + } + + private ImmutableIssuedCurrencyAmount lpTokensIn() { + return IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build(); + } + + private ImmutableAmmWithdraw.Builder baseBuilder() { + return AmmWithdraw.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ).asset2(Asset.XRP); + } +} \ No newline at end of file From adca5a332dc6abb8a711c7d10047dc76042d6624 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 21 Nov 2022 17:05:08 -0500 Subject: [PATCH 09/53] add amm_info request response objects and XrplClient method. --- .../org/xrpl/xrpl4j/client/XrplClient.java | 69 +++-- .../xrpl/xrpl4j/client/XrplClientTest.java | 108 ++++++++ .../xrpl/xrpl4j/model/client/XrplMethods.java | 9 +- .../client/amm/AmmInfoRequestParams.java | 40 +++ .../model/client/amm/AmmInfoResult.java | 94 +++++++ .../client/amm/AmmInfoRequestParamsTest.java | 37 +++ .../model/client/amm/AmmInfoResultTest.java | 251 ++++++++++++++++++ 7 files changed, 583 insertions(+), 25 deletions(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java create mode 100644 xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java diff --git a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java index b6275db36..694a421a7 100644 --- a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java +++ b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java @@ -57,6 +57,8 @@ import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsResult; import org.xrpl.xrpl4j.model.client.accounts.GatewayBalancesRequestParams; import org.xrpl.xrpl4j.model.client.accounts.GatewayBalancesResult; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyRequestParams; import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyResult; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; @@ -89,6 +91,11 @@ import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -167,7 +174,6 @@ public XrplClient(final HttpUrl rippledUrl) { * must not be provided, and {@link Transaction#signingPublicKey()} must be provided. * * @return The {@link SubmitResult} resulting from the submission request. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. * @see "https://xrpl.org/submit.html" */ @@ -191,7 +197,6 @@ public SubmitResult submit( * @param The type of {@link Transaction} contained in the {@link SignedTransaction} object. * * @return The {@link SubmitResult} resulting from the submission request. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public SubmitResult submit( @@ -213,7 +218,6 @@ public SubmitResult submit( * @param signedTransaction A {@link org.xrpl.xrpl4j.crypto.signing.SignedTransaction} to submit. * * @return The {@link SubmitResult} resulting from the submission request. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. * @throws JsonProcessingException if any JSON is invalid. * @see "https://xrpl.org/submit.html" @@ -248,7 +252,6 @@ public SubmitResult submit( * @param A type parameter for the type of {@link Transaction} being submitted. * * @return A {@link SubmitMultiSignedResult} of type {@link T}. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public SubmitMultiSignedResult submitMultisigned( @@ -268,7 +271,6 @@ public SubmitMultiSignedResult submitMultisigned( * Get the current state of the open-ledger requirements for transaction costs. * * @return A {@link FeeResult} containing information about current transaction costs. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. * @see "https://xrpl.org/fee.html" */ @@ -284,7 +286,6 @@ public FeeResult fee() throws JsonRpcClientErrorException { * Get the ledger index of a tx result response. If not present, throw an exception. * * @return A string containing value of last validated ledger index. - * * @throws JsonRpcClientErrorException when client encounters errors related to calling rippled JSON RPC API.. */ protected UnsignedInteger getMostRecentlyValidatedLedgerIndex() throws JsonRpcClientErrorException { @@ -439,7 +440,6 @@ public Finality isFinal( * Get the "server_info" for the rippled node. * * @return A {@link ServerInfo} containing information about the server. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. * @see "https://xrpl.org/server_info.html" * @deprecated This method is deprecated to accommodate 3 different types of server_info responses from the @@ -461,7 +461,6 @@ public ServerInfo serverInfo() throws JsonRpcClientErrorException { * {@link org.xrpl.xrpl4j.model.client.serverinfo.ServerInfo}. * * @return A {@link org.xrpl.xrpl4j.model.client.serverinfo.ServerInfoResult} containing information about the server. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. * @see "https://xrpl.org/server_info.html" */ @@ -481,7 +480,6 @@ public org.xrpl.xrpl4j.model.client.serverinfo.ServerInfoResult serverInformatio * @param params The {@link AccountChannelsRequestParams} to send in the request. * * @return The {@link AccountChannelsResult} returned by the account_channels method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountChannelsResult accountChannels(AccountChannelsRequestParams params) throws JsonRpcClientErrorException { @@ -500,7 +498,6 @@ public AccountChannelsResult accountChannels(AccountChannelsRequestParams params * @param params The {@link AccountCurrenciesRequestParams} to send in the request. * * @return The {@link AccountCurrenciesResult} returned by the account_currencies method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountCurrenciesResult accountCurrencies( @@ -521,7 +518,6 @@ public AccountCurrenciesResult accountCurrencies( * @param params The {@link AccountInfoRequestParams} to send in the request. * * @return The {@link AccountInfoResult} returned by the account_info method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountInfoResult accountInfo(AccountInfoRequestParams params) throws JsonRpcClientErrorException { @@ -609,7 +605,6 @@ public NftSellOffersResult nftSellOffers(NftSellOffersRequestParams params) thro * @param params The {@link AccountObjectsRequestParams} to send in the request. * * @return The {@link AccountObjectsResult} returned by the account_objects method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountObjectsResult accountObjects(AccountObjectsRequestParams params) throws JsonRpcClientErrorException { @@ -627,7 +622,6 @@ public AccountObjectsResult accountObjects(AccountObjectsRequestParams params) t * @param params The {@link AccountOffersRequestParams} to send in the request. * * @return The {@link AccountOffersResult} returned by the account_offers method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountOffersResult accountOffers(AccountOffersRequestParams params) throws JsonRpcClientErrorException { @@ -645,7 +639,6 @@ public AccountOffersResult accountOffers(AccountOffersRequestParams params) thro * @param params A {@link DepositAuthorizedRequestParams} to send in the request. * * @return The {@link DepositAuthorizedResult} returned by the deposit_authorized method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public DepositAuthorizedResult depositAuthorized(DepositAuthorizedRequestParams params) @@ -664,7 +657,6 @@ public DepositAuthorizedResult depositAuthorized(DepositAuthorizedRequestParams * @param address The {@link Address} of the account to request. * * @return The {@link AccountTransactionsResult} returned by the account_tx method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountTransactionsResult accountTransactions(Address address) throws JsonRpcClientErrorException { @@ -680,7 +672,6 @@ public AccountTransactionsResult accountTransactions(Address address) throws Jso * @param params The {@link AccountTransactionsRequestParams} to send in the request. * * @return The {@link AccountTransactionsResult} returned by the account_tx method call. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public AccountTransactionsResult accountTransactions(AccountTransactionsRequestParams params) @@ -701,7 +692,6 @@ public AccountTransactionsResult accountTransactions(AccountTransactionsRequestP * @param Type parameter for the type of {@link Transaction} that the {@link TransactionResult} will * * @return A {@link TransactionResult} containing the requested transaction and other metadata. - * * @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error. */ public TransactionResult transaction( @@ -724,7 +714,6 @@ public TransactionResult transaction( * @param params The {@link LedgerRequestParams} to send in the request. * * @return A {@link LedgerResult} containing the ledger details. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public LedgerResult ledger(LedgerRequestParams params) throws JsonRpcClientErrorException { @@ -742,7 +731,6 @@ public LedgerResult ledger(LedgerRequestParams params) throws JsonRpcClientError * @param params The {@link RipplePathFindRequestParams} to send in the request. * * @return A {@link RipplePathFindResult} containing possible paths. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public RipplePathFindResult ripplePathFind(RipplePathFindRequestParams params) throws JsonRpcClientErrorException { @@ -760,7 +748,6 @@ public RipplePathFindResult ripplePathFind(RipplePathFindRequestParams params) t * @param params The {@link AccountLinesRequestParams} to send in the request. * * @return The {@link AccountLinesResult} containing the requested trust lines. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public AccountLinesResult accountLines(AccountLinesRequestParams params) throws JsonRpcClientErrorException { @@ -778,7 +765,6 @@ public AccountLinesResult accountLines(AccountLinesRequestParams params) throws * @param params The {@link ChannelVerifyRequestParams} to send in the request. * * @return The result of the request, as a {@link ChannelVerifyResult}. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public ChannelVerifyResult channelVerify(ChannelVerifyRequestParams params) throws JsonRpcClientErrorException { @@ -797,7 +783,6 @@ public ChannelVerifyResult channelVerify(ChannelVerifyRequestParams params) thro * @param params The {@link GatewayBalancesRequestParams} to send in the request. * * @return The result of the request, as a {@link GatewayBalancesResult}. - * * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ public GatewayBalancesResult gatewayBalances( @@ -810,6 +795,25 @@ public GatewayBalancesResult gatewayBalances( return jsonRpcClient.send(request, GatewayBalancesResult.class); } + /** + * Get info about an AMM by making a call to the amm_info rippled RPC method. + * + * @param params The {@link AmmInfoRequestParams} to send in the request. + * + * @return A {@link AmmInfoResult}. + * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. + */ + public AmmInfoResult ammInfo( + AmmInfoRequestParams params + ) throws JsonRpcClientErrorException { + JsonRpcRequest request = JsonRpcRequest.builder() + .method(XrplMethods.AMM_INFO) + .addParams(params) + .build(); + + return jsonRpcClient.send(request, AmmInfoResult.class); + } + /** * Sign a {@link Transaction} with the private key from a {@link Wallet}. * @@ -855,7 +859,6 @@ public SignedTransaction signTransaction( * @param signature The hex encoded {@link String} containing the transaction signature. * * @return A copy of {@code unsignedTransaction} with the {@link Transaction#transactionSignature()} field added. - * * @deprecated This method will go away in a future version and be replaced with the implementation in SignatureUtils * in the xrpl4j-crypto module. */ @@ -960,6 +963,26 @@ protected Transaction addSignature( return TicketCreate.builder().from((TicketCreate) unsignedTransaction) .transactionSignature(signature) .build(); + } else if (AmmBid.class.isAssignableFrom(unsignedTransaction.getClass())) { + return AmmBid.builder().from((AmmBid) unsignedTransaction) + .transactionSignature(signature) + .build(); + } else if (AmmCreate.class.isAssignableFrom(unsignedTransaction.getClass())) { + return AmmCreate.builder().from((AmmCreate) unsignedTransaction) + .transactionSignature(signature) + .build(); + } else if (AmmDeposit.class.isAssignableFrom(unsignedTransaction.getClass())) { + return AmmDeposit.builder().from((AmmDeposit) unsignedTransaction) + .transactionSignature(signature) + .build(); + } else if (AmmVote.class.isAssignableFrom(unsignedTransaction.getClass())) { + return AmmVote.builder().from((AmmVote) unsignedTransaction) + .transactionSignature(signature) + .build(); + } else if (AmmWithdraw.class.isAssignableFrom(unsignedTransaction.getClass())) { + return AmmWithdraw.builder().from((AmmWithdraw) unsignedTransaction) + .transactionSignature(signature) + .build(); } // Never happens diff --git a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java index d0cd27781..f92b2391c 100644 --- a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java +++ b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java @@ -67,6 +67,8 @@ import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsResult; import org.xrpl.xrpl4j.model.client.accounts.GatewayBalancesRequestParams; import org.xrpl.xrpl4j.model.client.accounts.GatewayBalancesResult; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyRequestParams; import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyResult; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; @@ -98,11 +100,19 @@ import org.xrpl.xrpl4j.model.client.transactions.TransactionResult; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.AccountRootObject; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.ledger.SignerEntry; import org.xrpl.xrpl4j.model.ledger.SignerEntryWrapper; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -111,6 +121,7 @@ import org.xrpl.xrpl4j.model.transactions.EscrowCreate; import org.xrpl.xrpl4j.model.transactions.EscrowFinish; import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.ImmutableAmmDeposit; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.NfTokenAcceptOffer; import org.xrpl.xrpl4j.model.transactions.NfTokenBurn; @@ -129,6 +140,7 @@ import org.xrpl.xrpl4j.model.transactions.SignerListSet; import org.xrpl.xrpl4j.model.transactions.SignerWrapper; import org.xrpl.xrpl4j.model.transactions.TicketCreate; +import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TransactionMetadata; import org.xrpl.xrpl4j.model.transactions.TrustSet; @@ -912,6 +924,88 @@ public void addSignatureTx() { .ticketCount(UnsignedInteger.ONE) .build(); assertThat(xrplClient.addSignature(ticketCreate, "sign").transactionSignature().get()).isEqualTo("sign"); + + AmmBid ammBid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .build(); + assertThat(xrplClient.addSignature(ammBid, "sign").transactionSignature().get()).isEqualTo("sign"); + + AmmCreate ammCreate = AmmCreate.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .build(); + assertThat(xrplClient.addSignature(ammCreate, "sign").transactionSignature().get()).isEqualTo("sign"); + + AmmDeposit ammDeposit = AmmDeposit.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ).build(); + assertThat(xrplClient.addSignature(ammDeposit, "sign").transactionSignature().get()).isEqualTo("sign"); + + AmmVote ammVote = AmmVote.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .build(); + assertThat(xrplClient.addSignature(ammVote, "sign").transactionSignature().get()).isEqualTo("sign"); + + AmmWithdraw ammWithdraw = AmmWithdraw.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .asset2(Asset.XRP) + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .build(); + assertThat(xrplClient.addSignature(ammWithdraw, "sign").transactionSignature().get()).isEqualTo("sign"); } @Test @@ -1478,6 +1572,20 @@ public void nftSellOffers() throws JsonRpcClientErrorException { assertThat(jsonRpcRequestArgumentCaptor.getValue().params().get(0)).isEqualTo(nftSellOffersRequestParams); } + @Test + void ammInfo() throws JsonRpcClientErrorException { + AmmInfoRequestParams params = mock(AmmInfoRequestParams.class); + JsonRpcRequest expectedRequest = JsonRpcRequest.builder() + .method(XrplMethods.AMM_INFO) + .addParams(params) + .build(); + AmmInfoResult mockResult = mock(AmmInfoResult.class); + when(jsonRpcClientMock.send(expectedRequest, AmmInfoResult.class)).thenReturn(mockResult); + AmmInfoResult result = xrplClient.ammInfo(params); + + assertThat(result).isEqualTo(mockResult); + } + @Test public void signTransaction() { Payment payment = Payment.builder() diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java index 9077711f4..cd1ca6b19 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -171,6 +171,11 @@ public class XrplMethods { */ public static final String RIPPLE_PATH_FIND = "ripple_path_find"; + /** + * Constant for the ripple_path_find rippled API method. + */ + public static final String AMM_INFO = "amm_info"; + // Payment Channel methods /** * Constant for the channel_authorize rippled API method. diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java new file mode 100644 index 000000000..a7d8fa796 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java @@ -0,0 +1,40 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.client.XrplRequestParams; +import org.xrpl.xrpl4j.model.ledger.Asset; + +/** + * Request parameters for the {@code amm_info} rippled API method. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmInfoRequestParams.class) +@JsonDeserialize(as = ImmutableAmmInfoRequestParams.class) +public interface AmmInfoRequestParams extends XrplRequestParams { + + /** + * Construct a {@code AmmInfoRequestParams} builder. + * + * @return An {@link ImmutableAmmInfoRequestParams.Builder}. + */ + static ImmutableAmmInfoRequestParams.Builder builder() { + return ImmutableAmmInfoRequestParams.builder(); + } + + /** + * One of the assets of the AMM to look up. + * + * @return An {@link Asset}. + */ + Asset asset(); + + /** + * The other of the assets of the AMM. + * + * @return An {@link Asset}. + */ + Asset asset2(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java new file mode 100644 index 000000000..6927ab769 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -0,0 +1,94 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.client.XrplResult; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; +import org.xrpl.xrpl4j.model.ledger.AmmObject; + +import java.util.Optional; + +/** + * The result of an "amm_info" rippled API method call. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmInfoResult.class) +@JsonDeserialize(as = ImmutableAmmInfoResult.class) +public interface AmmInfoResult extends XrplResult { + + /** + * Construct a {@code AmmInfoResult} builder. + * + * @return An {@link ImmutableAmmInfoResult.Builder}. + */ + static ImmutableAmmInfoResult.Builder builder() { + return ImmutableAmmInfoResult.builder(); + } + + /** + * The AMM ledger object. + * + * @return An {@link AmmObject}. + */ + AmmObject amm(); + + /** + * (Omitted if ledger_current_index is provided instead) The ledger index of the ledger version used when + * retrieving this information. The information does not contain any changes from ledger versions newer than this one. + * + * @return An optionally-present {@link LedgerIndex}. + */ + @JsonProperty("ledger_index") + Optional ledgerIndex(); + + /** + * Get {@link #ledgerIndex()}, or throw an {@link IllegalStateException} if {@link #ledgerIndex()} is empty. + * + * @return The value of {@link #ledgerIndex()}. + * @throws IllegalStateException If {@link #ledgerIndex()} is empty. + */ + @JsonIgnore + @Value.Auxiliary + default LedgerIndex ledgerIndexSafe() { + return ledgerIndex() + .orElseThrow(() -> new IllegalStateException("Result did not contain a ledgerIndex.")); + } + + /** + * (Omitted if ledger_index is provided instead) The ledger index of the current in-progress ledger, + * which was used when retrieving this information. + * + * @return An optionally-present {@link LedgerIndex}. + */ + @JsonProperty("ledger_current_index") + Optional ledgerCurrentIndex(); + + /** + * Get {@link #ledgerCurrentIndex()}, or throw an {@link IllegalStateException} if {@link #ledgerCurrentIndex()} is + * empty. + * + * @return The value of {@link #ledgerCurrentIndex()}. + * @throws IllegalStateException If {@link #ledgerCurrentIndex()} is empty. + */ + @JsonIgnore + @Value.Auxiliary + default LedgerIndex ledgerCurrentIndexSafe() { + return ledgerCurrentIndex() + .orElseThrow(() -> new IllegalStateException("Result did not contain a ledgerCurrentIndex.")); + } + + /** + * If true, the information in this response comes from a validated ledger version. + * Otherwise, the information is subject to change. + * + * @return {@code true} if the information in this response comes from a validated ledger version, {@code false} + * if not. + */ + @Value.Default + default boolean validated() { + return false; + } +} diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java new file mode 100644 index 000000000..de5eb04a9 --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java @@ -0,0 +1,37 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import static org.junit.jupiter.api.Assertions.*; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.transactions.Address; + +class AmmInfoRequestParamsTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + AmmInfoRequestParams params = AmmInfoRequestParams.builder() + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .build(); + String json = "{\n" + + " \"asset\": {\n" + + " \"currency\": \"XRP\"\n" + + " },\n" + + " \"asset2\": {\n" + + " \"currency\": \"TST\",\n" + + " \"issuer\": \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " }\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } +} \ No newline at end of file diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java new file mode 100644 index 000000000..e92da94ce --- /dev/null +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -0,0 +1,251 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; +import org.xrpl.xrpl4j.model.ledger.AmmObject; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuctionSlot; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.ledger.VoteEntry; +import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +class AmmInfoResultTest extends AbstractJsonTest { + + @Test + void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { + AmmInfoResult result = AmmInfoResult.builder() + .amm( + AmmObject.builder() + .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .auctionSlot( + AuctionSlot.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) + .expiration(UnsignedInteger.valueOf(721870180)) + .price( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("0.8696263565463045") + .build() + ) + .build() + ) + .lpTokenBalance( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("71150.53584131501") + .build() + ) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .addVoteSlots( + VoteEntryWrapper.of( + VoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .build() + ) + ) + .build() + ) + .ledgerCurrentIndex(LedgerIndex.of(UnsignedInteger.valueOf(226645))) + .validated(false) + .build(); + String json = "{\n" + + " \"amm\": {\n" + + " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"LedgerEntryType\" : \"AMM\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuctionSlot\" : {\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"DiscountedFee\" : 0,\n" + + " \"Expiration\" : 721870180,\n" + + " \"Price\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"0.8696263565463045\"\n" + + " }\n" + + " },\n" + + " \"Flags\" : 0,\n" + + " \"LPTokenBalance\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"71150.53584131501\"\n" + + " },\n" + + " \"TradingFee\" : 600,\n" + + " \"VoteSlots\" : [\n" + + " {\n" + + " \"VoteEntry\" : {\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"TradingFee\" : 600,\n" + + " \"VoteWeight\" : 100000\n" + + " }\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"ledger_current_index\": 226645,\n" + + " \"validated\": false\n" + + " }"; + + assertCanSerializeAndDeserialize(result, json); + + assertThat(result.ledgerCurrentIndexSafe()).isEqualTo(result.ledgerCurrentIndex().get()); + assertThatThrownBy(result::ledgerIndexSafe).isInstanceOf(IllegalStateException.class); + } + + @Test + void testJsonForValidatedLedger() throws JSONException, JsonProcessingException { + AmmInfoResult result = AmmInfoResult.builder() + .amm( + AmmObject.builder() + .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .auctionSlot( + AuctionSlot.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) + .expiration(UnsignedInteger.valueOf(721870180)) + .price( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("0.8696263565463045") + .build() + ) + .build() + ) + .lpTokenBalance( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("71150.53584131501") + .build() + ) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .addVoteSlots( + VoteEntryWrapper.of( + VoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .build() + ) + ) + .build() + ) + .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(226645))) + .validated(true) + .build(); + String json = "{\n" + + " \"amm\": {\n" + + " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"LedgerEntryType\" : \"AMM\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuctionSlot\" : {\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"DiscountedFee\" : 0,\n" + + " \"Expiration\" : 721870180,\n" + + " \"Price\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"0.8696263565463045\"\n" + + " }\n" + + " },\n" + + " \"Flags\" : 0,\n" + + " \"LPTokenBalance\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"71150.53584131501\"\n" + + " },\n" + + " \"TradingFee\" : 600,\n" + + " \"VoteSlots\" : [\n" + + " {\n" + + " \"VoteEntry\" : {\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"TradingFee\" : 600,\n" + + " \"VoteWeight\" : 100000\n" + + " }\n" + + " }\n" + + " ]\n" + + " },\n" + + " \"ledger_index\": 226645,\n" + + " \"validated\": true\n" + + " }"; + + assertCanSerializeAndDeserialize(result, json); + + assertThat(result.ledgerIndexSafe()).isEqualTo(result.ledgerIndex().get()); + assertThatThrownBy(result::ledgerCurrentIndexSafe).isInstanceOf(IllegalStateException.class); + } +} \ No newline at end of file From 6d835a8c572074446ccc4e2adaf7d178cfed4a92 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 28 Nov 2022 11:54:25 -0500 Subject: [PATCH 10/53] add new transactions to SignatureUtils --- .../xrpl4j/crypto/signing/SignatureUtils.java | 29 ++++- .../crypto/signing/SignatureUtilsTest.java | 121 +++++++++++++++++- 2 files changed, 146 insertions(+), 4 deletions(-) diff --git a/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java b/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java index 7fe445c54..6aa5d7ea5 100644 --- a/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java +++ b/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,6 +28,11 @@ import org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -238,6 +243,26 @@ public SignedTransaction addSignatureToTransaction( signedTransaction = TicketCreate.builder().from((TicketCreate) unsignedTransaction) .transactionSignature(signature.base16Value()) .build(); + } else if (AmmBid.class.isAssignableFrom(unsignedTransaction.getClass())) { + signedTransaction = AmmBid.builder().from((AmmBid) unsignedTransaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmCreate.class.isAssignableFrom(unsignedTransaction.getClass())) { + signedTransaction = AmmCreate.builder().from((AmmCreate) unsignedTransaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmDeposit.class.isAssignableFrom(unsignedTransaction.getClass())) { + signedTransaction = AmmDeposit.builder().from((AmmDeposit) unsignedTransaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmVote.class.isAssignableFrom(unsignedTransaction.getClass())) { + signedTransaction = AmmVote.builder().from((AmmVote) unsignedTransaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmWithdraw.class.isAssignableFrom(unsignedTransaction.getClass())) { + signedTransaction = AmmWithdraw.builder().from((AmmWithdraw) unsignedTransaction) + .transactionSignature(signature.base16Value()) + .build(); } else { // Should never happen, but will in a unit test if we miss one. throw new IllegalArgumentException("Signing fields could not be added to the unsignedTransaction."); diff --git a/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index 828e31393..847d82d47 100644 --- a/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-crypto-parent/xrpl4j-crypto-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,9 +49,17 @@ import org.xrpl.xrpl4j.crypto.PublicKey; import org.xrpl.xrpl4j.keypairs.DefaultKeyPairService; import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -77,6 +85,7 @@ import org.xrpl.xrpl4j.model.transactions.SetRegularKey; import org.xrpl.xrpl4j.model.transactions.SignerListSet; import org.xrpl.xrpl4j.model.transactions.TicketCreate; +import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TrustSet; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -515,6 +524,114 @@ void addSignatureToTicketCreate() { addSignatureToTransactionHelper(ticketCreate); } + @Test + void addSignatureToAmmBid() { + AmmBid bid = AmmBid.builder() + .account(sourceWallet.classicAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .signingPublicKey(sourceWallet.publicKey()) + .build(); + + addSignatureToTransactionHelper(bid); + } + + @Test + void addSignatureToAmmCreate() { + AmmCreate ammCreate = AmmCreate.builder() + .account(sourceWallet.classicAddress()) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey(sourceWallet.publicKey()) + .build(); + + addSignatureToTransactionHelper(ammCreate); + } + + @Test + void addSignatureToAmmDeposit() { + AmmDeposit deposit = AmmDeposit.builder() + .account(sourceWallet.classicAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .signingPublicKey(sourceWallet.publicKey()) + .build(); + + addSignatureToTransactionHelper(deposit); + } + + @Test + void addSignatureToAmmVote() { + AmmVote vote = AmmVote.builder() + .account(sourceWallet.classicAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey(sourceWallet.publicKey()) + .build(); + + addSignatureToTransactionHelper(vote); + } + + @Test + void addSignatureToAmmWithdraw() { + AmmWithdraw withdraw = AmmWithdraw.builder() + .account(sourceWallet.classicAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .asset2(Asset.XRP) + .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .signingPublicKey(sourceWallet.publicKey()) + .build(); + + addSignatureToTransactionHelper(withdraw); + } + @Test public void addSignatureToTransactionUnsupported() { Assertions.assertThrows(IllegalArgumentException.class, () -> addSignatureToTransactionHelper(transactionMock)); From 812f8f6539361f08056775c1bea47d1fbc24031d Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 2 Dec 2022 14:12:21 -0500 Subject: [PATCH 11/53] checkpoint --- .../xrpl/xrpl4j/codec/binary/types/Issue.java | 36 +++++++++++ .../xrpl4j/codec/binary/types/IssueType.java | 62 +++++++++++++++++++ .../codec/binary/types/SerializedType.java | 5 +- .../codec/binary/XrplBinaryCodecTest.java | 19 +++++- .../src/test/resources/codec-fixtures.json | 24 +++---- 5 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java create mode 100644 xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java new file mode 100644 index 000000000..70fdae77d --- /dev/null +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java @@ -0,0 +1,36 @@ +package org.xrpl.xrpl4j.codec.binary.types; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.base.Preconditions; +import org.immutables.value.Value; + +import java.util.Optional; + +@Value.Immutable +@JsonSerialize(as = ImmutableIssue.class) +@JsonDeserialize(as = ImmutableIssue.class) +public interface Issue { + + /** + * Construct a {@code Issue} builder. + * + * @return An {@link ImmutableIssue.Builder}. + */ + static ImmutableIssue.Builder builder() { + return ImmutableIssue.builder(); + } + + JsonNode currency(); + + Optional issuer(); + + @Value.Check + default void checkIssuerEmptyForXrp() { + if (currency().asText().equals("XRP")) { + Preconditions.checkState(!issuer().isPresent(), "If Issue is XRP, issuer must be empty."); + } + } + +} diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java new file mode 100644 index 000000000..109f701ad --- /dev/null +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java @@ -0,0 +1,62 @@ +package org.xrpl.xrpl4j.codec.binary.types; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.xrpl.xrpl4j.codec.addresses.UnsignedByteArray; +import org.xrpl.xrpl4j.codec.binary.BinaryCodecObjectMapperFactory; +import org.xrpl.xrpl4j.codec.binary.serdes.BinaryParser; + +public class IssueType extends SerializedType { + + private static final ObjectMapper objectMapper = BinaryCodecObjectMapperFactory.getObjectMapper(); + + public IssueType() { + this(UnsignedByteArray.ofSize(40)); + } + + public IssueType(UnsignedByteArray bytes) { + super(bytes); + } + + @Override + public IssueType fromJson(JsonNode node) throws JsonProcessingException { + if (!node.isObject()) { + throw new IllegalArgumentException("node is not an object"); + } + + Issue issue = objectMapper.treeToValue(node, Issue.class); + + UnsignedByteArray byteArray = new CurrencyType().fromJson(issue.currency()).value(); + issue.issuer().ifPresent( + issuer -> byteArray.append(new AccountIdType().fromJson(issuer).value()) + ); + + return new IssueType(byteArray); + } + + @Override + public IssueType fromParser(BinaryParser parser) { + CurrencyType currency = new CurrencyType().fromParser(parser); + if (currency.toJson().toString().equals("XRP")) { + return new IssueType(currency.value()); + } + AccountIdType issuer = new AccountIdType().fromParser(parser); + return new IssueType(currency.value().append(issuer.value())); + } + + @Override + public JsonNode toJson() { + BinaryParser parser = new BinaryParser(this.toHex()); + JsonNode currency = new CurrencyType().fromParser(parser).toJson(); + + ImmutableIssue.Builder builder = Issue.builder(); + builder.currency(currency); + if (!currency.asText().equals("XRP")) { + JsonNode issuer = new AccountIdType().fromParser(parser).toJson(); + builder.issuer(issuer); + } + + return objectMapper.valueToTree(builder.build()); + } +} diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/SerializedType.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/SerializedType.java index 47e10efce..cc67a3ff9 100644 --- a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/SerializedType.java +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/SerializedType.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,6 +57,7 @@ public abstract class SerializedType> { .put("UInt32", () -> new UInt32Type()) .put("UInt64", () -> new UInt64Type()) .put("Vector256", () -> new Vector256Type()) + .put("Issue", () -> new IssueType()) .build(); private final UnsignedByteArray bytes; diff --git a/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/XrplBinaryCodecTest.java b/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/XrplBinaryCodecTest.java index 9e51306cd..b22b20922 100644 --- a/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/XrplBinaryCodecTest.java +++ b/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/XrplBinaryCodecTest.java @@ -27,11 +27,15 @@ import com.google.common.base.Strings; import com.google.common.primitives.UnsignedInteger; import org.assertj.core.util.Lists; +import org.json.JSONException; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; import org.xrpl.xrpl4j.codec.fixtures.FixtureUtils; +import org.xrpl.xrpl4j.codec.fixtures.codec.CodecFixture; import org.xrpl.xrpl4j.codec.fixtures.data.WholeObject; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory; @@ -67,6 +71,10 @@ private static Stream dataDrivenFixtures() throws IOException { .map(Arguments::of); } + private static Stream transactionCodecFixtures() throws IOException { + return FixtureUtils.getCodecFixtures().transactions().stream().map(Arguments::of); + } + @Test void encodeDecodeSimple() throws JsonProcessingException { assertThat(encoder.encode(SIMPLE_JSON)).isEqualTo(SIMPLE_HEX); @@ -363,7 +371,7 @@ void decodeMultiSignEncodedTx() throws JsonProcessingException { Payment paymentWithoutSigners = paymentBuilder.build(); Payment paymentWithSigners = paymentBuilder.signers(signers).build(); - + final String unsignedJson = objectMapper.writeValueAsString(paymentWithSigners); final String unsignedBinaryHex = encoder.encodeForMultiSigning(unsignedJson, signerAccountId); String decoded = encoder.decode(unsignedBinaryHex); @@ -429,4 +437,13 @@ void dataDriven(WholeObject wholeObject) throws IOException { assertThat(encoder.encode(wholeObject.txJson().toString())).isEqualTo(wholeObject.expectedHex()); } + @ParameterizedTest + @MethodSource("transactionCodecFixtures") + void transactionFixtureTests(CodecFixture codecFixture) throws JsonProcessingException, JSONException { + assertThat(encoder.encode(codecFixture.json().toString())).isEqualTo(codecFixture.binary()); + JSONAssert.assertEquals( + encoder.decode(codecFixture.binary()), codecFixture.json().toString(), JSONCompareMode.STRICT + ); + } + } diff --git a/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json b/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json index 92ef8d945..1285f7deb 100644 --- a/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json +++ b/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json @@ -4493,19 +4493,21 @@ ], "transactions": [ { - "binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA", - "json": { - "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj", - "TransactionType": "Payment", - "TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639", - "SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E", - "Amount": "10000000000", - "Fee": "10", - "Flags": 0, - "Sequence": 62 + "binary": "120024220001000024000000026840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074409EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMDeposit", + "TxnSignature": "9EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, + "Fee": "1", + "Flags": 65536, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0" } } + ], "ledgerData": [ { From 7b6aaffd17b366b39e04460240206a081786f844 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 6 Dec 2022 14:26:17 -0500 Subject: [PATCH 12/53] fix bug in IssueType that prevented decode --- xrpl4j-binary-codec/pom.xml | 5 + .../xrpl4j/codec/binary/types/IssueType.java | 4 +- .../src/test/resources/codec-fixtures.json | 345 +++++++++++++----- 3 files changed, 252 insertions(+), 102 deletions(-) diff --git a/xrpl4j-binary-codec/pom.xml b/xrpl4j-binary-codec/pom.xml index 4173b976e..208e3557a 100644 --- a/xrpl4j-binary-codec/pom.xml +++ b/xrpl4j-binary-codec/pom.xml @@ -73,6 +73,11 @@ com.fasterxml.jackson.datatype jackson-datatype-jdk8 + + org.skyscreamer + jsonassert + test + diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java index 109f701ad..51ea134af 100644 --- a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/IssueType.java @@ -12,7 +12,7 @@ public class IssueType extends SerializedType { private static final ObjectMapper objectMapper = BinaryCodecObjectMapperFactory.getObjectMapper(); public IssueType() { - this(UnsignedByteArray.ofSize(40)); + this(UnsignedByteArray.ofSize(20)); } public IssueType(UnsignedByteArray bytes) { @@ -38,7 +38,7 @@ public IssueType fromJson(JsonNode node) throws JsonProcessingException { @Override public IssueType fromParser(BinaryParser parser) { CurrencyType currency = new CurrencyType().fromParser(parser); - if (currency.toJson().toString().equals("XRP")) { + if (currency.toJson().asText().equals("XRP")) { return new IssueType(currency.value()); } AccountIdType issuer = new AccountIdType().fromParser(parser); diff --git a/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json b/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json index 1285f7deb..61b96f192 100644 --- a/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json +++ b/xrpl4j-binary-codec/src/test/resources/codec-fixtures.json @@ -33,9 +33,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "059D1E86DE5DCCCF956BF4799675B2425AF9AD44FE4CCA6FEE1C812EEF6423E6", - "Indexes": [ - "908D554AA0D29F660716A3EE65C61DD886B744DDF60DE70E6B16EADB770635DB" - ] + "Indexes": ["908D554AA0D29F660716A3EE65C61DD886B744DDF60DE70E6B16EADB770635DB"] } }, { @@ -329,9 +327,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "17CC40C6872E0C0E658C49B75D0812A70D4161DDA53324DF51FA58D3819C814B", - "Indexes": [ - "571BF14F28C4D97871CDACD344A8CF57E6BA287BF0440B9E0D0683D02751CC7B" - ] + "Indexes": ["571BF14F28C4D97871CDACD344A8CF57E6BA287BF0440B9E0D0683D02751CC7B"] } }, { @@ -380,9 +376,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "1BCA9161A199AD5E907751CBF3FBA49689D517F0E8EE823AE17B737039B41DE1", - "Indexes": [ - "26B894EE68470AD5AEEB55D5EBF936E6397CEE6957B93C56A2E7882CA9082873" - ] + "Indexes": ["26B894EE68470AD5AEEB55D5EBF936E6397CEE6957B93C56A2E7882CA9082873"] } }, { @@ -446,9 +440,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "1F9FF48419CA69FDDCC294CCEEE608F5F8A8BE11E286AD5743ED2D457C5570C4", - "Indexes": [ - "7D4325BE338A40BBCBCC1F351B3272EB3E76305A878E76603DE206A795871619" - ] + "Indexes": ["7D4325BE338A40BBCBCC1F351B3272EB3E76305A878E76603DE206A795871619"] } }, { @@ -614,9 +606,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "289CFC476B5876F28C8A3B3C5B7058EC2BDF668C37B846EA7E5E1A73A4AA0816", - "Indexes": [ - "BC10E40AFB79298004CDE51CB065DBDCABA86EC406E3A1CF02CE5F8A9628A2BD" - ] + "Indexes": ["BC10E40AFB79298004CDE51CB065DBDCABA86EC406E3A1CF02CE5F8A9628A2BD"] } }, { @@ -719,9 +709,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "2C9F00EFA5CCBD43452EF364B12C8DFCEF2B910336E5EFCE3AA412A556991582", - "Indexes": [ - "F721E924498EE68BFF906CD856E8332073DD350BAC9E8977AC3F31860BA1E33A" - ] + "Indexes": ["F721E924498EE68BFF906CD856E8332073DD350BAC9E8977AC3F31860BA1E33A"] } }, { @@ -758,9 +746,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "2FB4904ACFB96228FC002335B1B5A4C5584D9D727BBE82144F0415EB4EA0C727", - "Indexes": [ - "5F22826818CC83448C9DF34939AB4019D3F80C70DEB8BDBDCF0496A36DC68719" - ], + "Indexes": ["5F22826818CC83448C9DF34939AB4019D3F80C70DEB8BDBDCF0496A36DC68719"], "TakerPaysIssuer": "2B6C42A95B3F7EE1971E4A10098E8F1B5F66AA08" } }, @@ -774,9 +760,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "2FB4904ACFB96228FC002335B1B5A4C5584D9D727BBE82145003BAF82D03A000", - "Indexes": [ - "5B7F148A8DDB4EB7386C9E75C4C1ED918DEDE5C52D5BA51B694D7271EF8BDB46" - ], + "Indexes": ["5B7F148A8DDB4EB7386C9E75C4C1ED918DEDE5C52D5BA51B694D7271EF8BDB46"], "TakerPaysIssuer": "2B6C42A95B3F7EE1971E4A10098E8F1B5F66AA08" } }, @@ -967,9 +951,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "3F2BADB38F12C87D111D3970CD1F05FE698DB86F14DC7C5FAEB05BFB6391B00E", - "Indexes": [ - "73E075E64CA5E7CE60FFCD5359C1D730EDFFEE7C4D992760A87DF7EA0A34E40F" - ] + "Indexes": ["73E075E64CA5E7CE60FFCD5359C1D730EDFFEE7C4D992760A87DF7EA0A34E40F"] } }, { @@ -994,9 +976,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "4235CD082112FB621C02D6DA2E4F4ACFAFC91CB0585E034B936C29ABF4A76B01", - "Indexes": [ - "6C4C3F1C6B9D76A6EF50F377E7C3991825694C604DBE0C1DD09362045EE41997" - ] + "Indexes": ["6C4C3F1C6B9D76A6EF50F377E7C3991825694C604DBE0C1DD09362045EE41997"] } }, { @@ -1095,9 +1075,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "48E91FD14597FB089654DADE7B70EB08CAF421EA611D703F3E871F7D4B5AAB5D", - "Indexes": [ - "25DCAC87FBE4C3B66A1AFDE3C3F98E5A16333975C4FD46682F7497F27DFB9766" - ] + "Indexes": ["25DCAC87FBE4C3B66A1AFDE3C3F98E5A16333975C4FD46682F7497F27DFB9766"] } }, { @@ -1159,9 +1137,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "4EFC0442D07AE681F7FDFAA89C75F06F8E28CFF888593440201B0320E8F2C7BD", - "Indexes": [ - "1595E5D5197330F58A479200A2FDD434D7A244BD1FFEC5E5EE8CF064AE77D3F5" - ] + "Indexes": ["1595E5D5197330F58A479200A2FDD434D7A244BD1FFEC5E5EE8CF064AE77D3F5"] } }, { @@ -1375,9 +1351,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "98082E695CAB618590BEEA0647A5F24D2B610A686ECD49310604FC7431FAAB0D", - "Indexes": [ - "9BF3216E42575CA5A3CB4D0F2021EE81D0F7835BA2EDD78E05CAB44B655962BB" - ] + "Indexes": ["9BF3216E42575CA5A3CB4D0F2021EE81D0F7835BA2EDD78E05CAB44B655962BB"] } }, { @@ -1582,9 +1556,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "62AE37A44FE44BDCFC2BA5DD14D74BEC0AC346DA2DC1F04756044364C5BB0000", - "Indexes": [ - "600A398F57CAE44461B4C8C25DE12AC289F87ED125438440B33B97417FE3D82C" - ], + "Indexes": ["600A398F57CAE44461B4C8C25DE12AC289F87ED125438440B33B97417FE3D82C"], "TakerPaysIssuer": "2B6C42A95B3F7EE1971E4A10098E8F1B5F66AA08" } }, @@ -1960,9 +1932,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "72D60CCD3905A3ABE19049B6EE76E8E0F3A2CBAC852625C757176F1B73EF617F", - "Indexes": [ - "AB124EEAB087452070EC70D9DEA1A22C9766FFBBEE1025FD46495CC74148CCA8" - ] + "Indexes": ["AB124EEAB087452070EC70D9DEA1A22C9766FFBBEE1025FD46495CC74148CCA8"] } }, { @@ -2091,9 +2061,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "80AB25842B230D48027800213EB86023A3EAF4430E22C092D333795FFF1E5219", - "Indexes": [ - "42E28285A82D01DCA856118A064C8AEEE1BF8167C08186DA5BFC678687E86F7C" - ] + "Indexes": ["42E28285A82D01DCA856118A064C8AEEE1BF8167C08186DA5BFC678687E86F7C"] } }, { @@ -2218,9 +2186,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "8ADF3C5527CCF6D0B5863365EF40254171536C3901F1CBD9E2BC5F918A7D492A", - "Indexes": [ - "BC10E40AFB79298004CDE51CB065DBDCABA86EC406E3A1CF02CE5F8A9628A2BD" - ] + "Indexes": ["BC10E40AFB79298004CDE51CB065DBDCABA86EC406E3A1CF02CE5F8A9628A2BD"] } }, { @@ -2621,9 +2587,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "A00CD19C13A5CFA3FECB409D42B38017C07A4AEAE05A7A00347DDA17199BA683", - "Indexes": [ - "E49318D6DF22411C3F35581B1D28297A36E47F68B45F36A587C156E6E43CE0A6" - ] + "Indexes": ["E49318D6DF22411C3F35581B1D28297A36E47F68B45F36A587C156E6E43CE0A6"] } }, { @@ -2670,9 +2634,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "A39F044D860C5B5846AA7E0FAAD44DC8897F0A62B2F628AA073B21B3EC146010", - "Indexes": [ - "CD34D8FF7C656B66E2298DB420C918FE27DFFF2186AC8D1785D8CBF2C6BC3488" - ] + "Indexes": ["CD34D8FF7C656B66E2298DB420C918FE27DFFF2186AC8D1785D8CBF2C6BC3488"] } }, { @@ -2721,9 +2683,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "A7E461C6DC98F472991FDE51FADDC0082D755F553F5849875D554B52624EF1C3", - "Indexes": [ - "116C6D5E5C6C59C9C5362B84CB9DD30BD3D4B7CB98CE993D49C068323BF19747" - ] + "Indexes": ["116C6D5E5C6C59C9C5362B84CB9DD30BD3D4B7CB98CE993D49C068323BF19747"] } }, { @@ -2757,9 +2717,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "AA539C8EECE0A0CFF0DBF3BFACD6B42CD4421715428AD90B034091BD3C721038", - "Indexes": [ - "72307CB57E53604A0C50E653AB10E386F3835460B5585B70CB7F668C1E04AC8B" - ] + "Indexes": ["72307CB57E53604A0C50E653AB10E386F3835460B5585B70CB7F668C1E04AC8B"] } }, { @@ -3819,9 +3777,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "D4A00D9B3452C7F93C5F0531FA8FFB4599FEEC405CA803FBEFE0FA22137D863D", - "Indexes": [ - "C1C5FB39D6C15C581D822DBAF725EF7EDE40BEC9F93C52398CF5CE9F64154D6C" - ] + "Indexes": ["C1C5FB39D6C15C581D822DBAF725EF7EDE40BEC9F93C52398CF5CE9F64154D6C"] } }, { @@ -3831,9 +3787,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "D4B68B54869E428428078E1045B8BB66C24DD101DB3FCCBB099929B3B63BCB40", - "Indexes": [ - "9A551971E78FE2FB80D930A77EA0BAC2139A49D6BEB98406427C79F52A347A09" - ] + "Indexes": ["9A551971E78FE2FB80D930A77EA0BAC2139A49D6BEB98406427C79F52A347A09"] } }, { @@ -3908,9 +3862,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "DD23E2C60C9BC58180AC6EA7C668233EC51A0947E42FD1FAD4F5FBAED9698D95", - "Indexes": [ - "908D554AA0D29F660716A3EE65C61DD886B744DDF60DE70E6B16EADB770635DB" - ] + "Indexes": ["908D554AA0D29F660716A3EE65C61DD886B744DDF60DE70E6B16EADB770635DB"] } }, { @@ -4061,9 +4013,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "E2EC9E1BC7B4667B7A5F2F68857F6E6A478A09B5BB4F99E09F694437C4152DED", - "Indexes": [ - "65492B9F30F1CBEA168509128EB8619BAE02A7A7A4725FF3F8DAA70FA707A26E" - ] + "Indexes": ["65492B9F30F1CBEA168509128EB8619BAE02A7A7A4725FF3F8DAA70FA707A26E"] } }, { @@ -4240,9 +4190,7 @@ "IndexPrevious": "0000000000000002", "Flags": 0, "RootIndex": "8E92E688A132410427806A734DF6154B7535E439B72DECA5E4BC7CE17135C5A4", - "Indexes": [ - "73E075E64CA5E7CE60FFCD5359C1D730EDFFEE7C4D992760A87DF7EA0A34E40F" - ] + "Indexes": ["73E075E64CA5E7CE60FFCD5359C1D730EDFFEE7C4D992760A87DF7EA0A34E40F"] } }, { @@ -4346,9 +4294,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "F774E0321809251174AC85531606FB46B75EEF9F842F9697531AA535D3D0C000", - "Indexes": [ - "D1CB738BD08AC36DCB77191DB87C6E40FA478B86503371ED497F30931D7F4F52" - ], + "Indexes": ["D1CB738BD08AC36DCB77191DB87C6E40FA478B86503371ED497F30931D7F4F52"], "TakerPaysIssuer": "E8ACFC6B5EF4EA0601241525375162F43C2FF285" } }, @@ -4409,9 +4355,7 @@ "LedgerEntryType": "DirectoryNode", "Flags": 0, "RootIndex": "F95F6D3A1EF7981E5CA4D5AEC4DA63392B126C76469735BCCA26150A1AF6D9C3", - "Indexes": [ - "CAD951AB279A749AE648FD1DFF56C021BD66E36187022E772C31FE52106CB13B" - ] + "Indexes": ["CAD951AB279A749AE648FD1DFF56C021BD66E36187022E772C31FE52106CB13B"] } }, { @@ -4491,7 +4435,39 @@ } } ], - "transactions": [ + "transactions": [{ + "binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA", + "json": { + "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj", + "TransactionType": "Payment", + "TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639", + "SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E", + "Amount": "10000000000", + "Fee": "10", + "Flags": 0, + "Sequence": 62 + } + }, + { + "binary": "12002315000A220000000024000000026140000000000027106840000000000000016BD5838D7EA4C680000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMCreate", + "TxnSignature": "913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100", + "Amount": "10000", + "Amount2": { + "currency": "ETH", + "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", + "value": "10000" + }, + "TradingFee": 10, + "Fee": "1", + "Flags": 0, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0" + } + }, { "binary": "120024220001000024000000026840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074409EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { @@ -4506,23 +4482,192 @@ "Sequence": 2, "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0" } - } - - ], - "ledgerData": [ + }, { - "binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00", + "binary": "120024220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "account_hash": "3B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D5", - "close_flags": 0, - "close_time": 556231910, - "close_time_resolution": 10, - "ledger_index": 32052277, - "parent_close_time": 556231902, - "parent_hash": "EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6", - "total_coins": "99994494362043555", - "transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87" + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMDeposit", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "Fee": "1", + "Flags": 524288, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A" } + }, + { + "binary": "120024220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMDeposit", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"}, + "Fee": "1", + "Flags": 1048576, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F" + } + }, + { + "binary": "120024220020000024000000026140000000000003E86840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMDeposit", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, + "Fee": "1", + "Flags": 2097152, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00" + } + }, + { + "binary": "120024220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMDeposit", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "EPrice": "25", + "Fee": "1", + "Flags": 4194304, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C" + } + }, + { + "binary": "120025220001000024000000026840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744066944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMWithdraw", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, + "Fee": "1", + "Flags": 65536, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "66944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505" + } + }, + { + "binary": "120025220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMWithdraw", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "Fee": "1", + "Flags": 524288, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C" + } + }, + { + "binary": "120025220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMWithdraw", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"}, + "Fee": "1", + "Flags": 1048576, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300" + } + }, + { + "binary": "120025220020000024000000026140000000000003E86840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744073552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMWithdraw", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, + "Fee": "1", + "Flags": 2097152, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "73552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06" + } + }, + { + "binary": "120025220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744023BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMWithdraw", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "Amount": "1000", + "EPrice": "25", + "Fee": "1", + "Flags": 4194304, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "23BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E" + } + }, + { + "binary": "120027220000000024000000026840000000000000016CD4C8E1BC9BF04000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0486DD4CC6F3B40B6C000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074406B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673EF01AE01C81149A91957F8F16BC57F3F200CD8C98375BF1791586E1F10318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMBid", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "AuthAccounts": [{"AuthAccount": {"Account": "rEaHTti4HZsMBpxTAF4ncWxkcdqDh1h6P7"}}], + "BidMax": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "35"}, + "BidMin": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "25"}, + "Fee": "1", + "Flags": 0, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "6B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A" + } + }, + { + "binary": "1200261500EA220000000024000000026840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744072767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "json": { + "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "TransactionType": "AMMVote", + "Asset": {"currency": "XRP"}, + "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, + "TradingFee": 234, + "Fee": "1", + "Flags": 0, + "Sequence": 2, + "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", + "TxnSignature": "72767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00" + } + }], + "ledgerData": [{ + "binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00", + "json": { + "account_hash": "3B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D5", + "close_flags": 0, + "close_time": 556231910, + "close_time_resolution": 10, + "ledger_index": 32052277, + "parent_close_time": 556231902, + "parent_hash": "EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6", + "total_coins": "99994494362043555", + "transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87" } - ] + }] } From ab9a263bc7cd7ef4a79d5901578ae104b9ba69cc Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 15 Dec 2022 09:49:45 -0500 Subject: [PATCH 13/53] split out AmmInfoResult amm object --- .../org/xrpl/xrpl4j/tests/AbstractIT.java | 34 ++++++ .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 106 ++++++++++++++++++ .../model/client/amm/AmmInfoResult.java | 5 +- .../xrpl4j/model/client/amm/AmmResult.java | 93 +++++++++++++++ 4 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index 999e00bb6..1c4ad1f69 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -22,14 +22,18 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.given; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.core.Is.is; +import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.client.XrplClient; +import org.xrpl.xrpl4j.model.client.Finality; +import org.xrpl.xrpl4j.model.client.FinalityStatus; import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsRequestParams; import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsResult; @@ -40,6 +44,7 @@ import org.xrpl.xrpl4j.model.client.accounts.AccountObjectsRequestParams; import org.xrpl.xrpl4j.model.client.accounts.AccountObjectsResult; import org.xrpl.xrpl4j.model.client.accounts.TrustLine; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; import org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams; import org.xrpl.xrpl4j.model.client.ledger.LedgerResult; @@ -127,6 +132,35 @@ protected T scanForResult(Supplier resultSupplier, Predicate condition }, is(notNullValue())); } + protected Finality scanForFinality( + Hash256 transactionHash, + LedgerIndex submittedOnLedgerIndex, + UnsignedInteger lastLedgerSequence, + UnsignedInteger transactionAccountSequence, + Address account + ) { + return given() + .pollInterval(100, TimeUnit.MILLISECONDS) + .atMost(30, TimeUnit.SECONDS) + .ignoreException(RuntimeException.class) + .await() + .until( + () -> xrplClient.isFinal( + transactionHash, + submittedOnLedgerIndex, + lastLedgerSequence, + transactionAccountSequence, + account + ), + is(equalTo( + Finality.builder() + .finalityStatus(FinalityStatus.VALIDATED_SUCCESS) + .resultCode(TransactionResultCodes.TES_SUCCESS) + .build() + ) + ) + ); + } protected T scanForResult(Supplier resultSupplier) { Objects.requireNonNull(resultSupplier); return given() diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java new file mode 100644 index 000000000..f8b736148 --- /dev/null +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -0,0 +1,106 @@ +package org.xrpl.xrpl4j.tests; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.base.Strings; +import com.google.common.io.BaseEncoding; +import com.google.common.primitives.UnsignedInteger; +import okhttp3.HttpUrl; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; +import org.xrpl.xrpl4j.crypto.KeyMetadata; +import org.xrpl.xrpl4j.crypto.PrivateKey; +import org.xrpl.xrpl4j.crypto.signing.SignedTransaction; +import org.xrpl.xrpl4j.crypto.signing.SingleKeySignatureService; +import org.xrpl.xrpl4j.model.client.accounts.AccountInfoRequestParams; +import org.xrpl.xrpl4j.model.client.accounts.AccountInfoResult; +import org.xrpl.xrpl4j.model.client.accounts.TrustLine; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; +import org.xrpl.xrpl4j.model.client.fees.FeeResult; +import org.xrpl.xrpl4j.model.client.fees.FeeUtils; +import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.Transaction; +import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes; +import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; +import org.xrpl.xrpl4j.tests.environment.CustomEnvironment; +import org.xrpl.xrpl4j.wallet.Wallet; + +import java.math.BigDecimal; + +public class AmmIT extends AbstractIT { + + @BeforeAll + protected static void initXrplEnvironment() { + xrplEnvironment = new CustomEnvironment( + HttpUrl.parse("http://amm.devnet.rippletest.net:51234"), + HttpUrl.parse("https://ammfaucet.devnet.rippletest.net") + ); + } + + @Test + void name() throws JsonRpcClientErrorException, JsonProcessingException { + Wallet issuerWallet = createRandomAccount(); + Wallet counterpartyWallet = createRandomAccount(); + + FeeResult feeResult = xrplClient.fee(); + + /////////////////////////// + // Create a Trust Line between issuer and counterparty denominated in a custom currency + // by submitting a TrustSet transaction + String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); + AccountInfoResult issuerAccount = scanForResult(() -> this.getValidatedAccountInfo(issuerWallet.classicAddress())); + AmmCreate ammCreate = AmmCreate.builder() + .account(issuerWallet.classicAddress()) + .sequence(issuerAccount.accountData().sequence()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .amount( + IssuedCurrencyAmount.builder() + .issuer(issuerWallet.classicAddress()) + .currency(xrpl4jCoin) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100))) + .tradingFee(TradingFee.ofPercent(BigDecimal.ONE)) + .lastLedgerSequence(issuerAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue()) + .signingPublicKey(issuerWallet.publicKey()) + .build(); + + SingleKeySignatureService signatureService = new SingleKeySignatureService( + PrivateKey.fromBase16EncodedPrivateKey(issuerWallet.privateKey().get()) + ); + + SignedTransaction signedCreate = signatureService.sign(KeyMetadata.EMPTY, ammCreate); + SubmitResult submitResult = xrplClient.submit(signedCreate); + assertThat(submitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + + scanForFinality( + signedCreate.hash(), + issuerAccount.ledgerIndexSafe(), + ammCreate.lastLedgerSequence().get(), + ammCreate.sequence(), + issuerWallet.classicAddress() + ); + + AmmInfoResult ammInfoResult = xrplClient.ammInfo( + AmmInfoRequestParams.builder() + .asset( + Asset.builder() + .issuer(issuerWallet.classicAddress()) + .currency(xrpl4jCoin) + .build() + ) + .asset2(Asset.XRP) + .build() + ); + + logger.info("ammInfoResult: {}", ammInfoResult); + } +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java index 6927ab769..72ea01916 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -31,9 +31,10 @@ static ImmutableAmmInfoResult.Builder builder() { /** * The AMM ledger object. * - * @return An {@link AmmObject}. + * @return An {@link AmmInfoResult}. */ - AmmObject amm(); + @JsonProperty("amm") + AmmResult amm(); /** * (Omitted if ledger_current_index is provided instead) The ledger index of the ledger version used when diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java new file mode 100644 index 000000000..31d1be056 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java @@ -0,0 +1,93 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuctionSlot; +import org.xrpl.xrpl4j.model.ledger.VoteEntry; +import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.util.List; +import java.util.Optional; + +@Value.Immutable +@JsonSerialize(as = ImmutableAmmResult.class) +@JsonDeserialize(as = ImmutableAmmResult.class) +public interface AmmResult { + + /** + * Construct a {@code AmmResult} builder. + * + * @return An {@link ImmutableAmmResult.Builder}. + */ + static ImmutableAmmResult.Builder builder() { + return ImmutableAmmResult.builder(); + } + + /** + * The definition for one of the two assets this AMM holds. + * + * @return An {@link Asset}. + */ + @JsonProperty("Amount") + Asset amount(); + + /** + * The definition for the other asset this AMM holds. + * + * @return An {@link Asset}. + */ + @JsonProperty("Amount2") + Asset asset2(); + + /** + * The address of the special account that holds this AMM's assets. + * + * @return An {@link Address}. + */ + @JsonProperty("AMMAccount") + Address ammAccount(); + + /** + * Details of the current owner of the auction slot. + * + * @return An {@link AuctionSlot}. + */ + @JsonProperty("AuctionSlot") + Optional auctionSlot(); + + /** + * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens + * can vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's + * assets which grows with the trading fees collected. + * + * @return An {@link IssuedCurrencyAmount}. + */ + @JsonProperty("LPTokenBalance") + @JsonAlias("LPToken") // FIXME: This is only here because AMM-net hasn't been updated and should be removed later on + IssuedCurrencyAmount lpTokenBalance(); + + /** + * The percentage fee to be charged for trades against this AMM instance, in units of 1/10,000. The maximum value is + * 1000, for a 1% fee. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + TradingFee tradingFee(); + + /** + * A list of vote objects, representing votes on the pool's trading fee. + * + * @return A {@link List} of {@link VoteEntry}s. + */ + @JsonProperty("VoteSlots") + List voteSlots(); + +} From 495ca808b01aaadca49f572647852797edbd5f30 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 10:31:30 -0500 Subject: [PATCH 14/53] write ITs and add different objects for AuctionSlots and AuthAccounts in amm_info responses --- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 285 +++++++++++++++++- .../model/client/amm/AmmInfoAuctionSlot.java | 49 +++ .../model/client/amm/AmmInfoAuthAccount.java | 30 ++ .../model/client/amm/AmmInfoResult.java | 17 +- .../xrpl4j/model/client/amm/AmmResult.java | 42 ++- .../xrpl/xrpl4j/model/ledger/VoteEntry.java | 4 + .../model/client/amm/AmmInfoResultTest.java | 4 +- 7 files changed, 402 insertions(+), 29 deletions(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index f8b736148..4a4b320c4 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -12,18 +12,30 @@ import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.KeyMetadata; import org.xrpl.xrpl4j.crypto.PrivateKey; +import org.xrpl.xrpl4j.crypto.signing.SignatureService; import org.xrpl.xrpl4j.crypto.signing.SignedTransaction; import org.xrpl.xrpl4j.crypto.signing.SingleKeySignatureService; import org.xrpl.xrpl4j.model.client.accounts.AccountInfoRequestParams; import org.xrpl.xrpl4j.model.client.accounts.AccountInfoResult; +import org.xrpl.xrpl4j.model.client.accounts.AccountLinesRequestParams; +import org.xrpl.xrpl4j.model.client.accounts.AccountLinesResult; import org.xrpl.xrpl4j.model.client.accounts.TrustLine; +import org.xrpl.xrpl4j.model.client.amm.AmmInfoAuctionSlot; import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; +import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.Transaction; @@ -33,9 +45,12 @@ import org.xrpl.xrpl4j.wallet.Wallet; import java.math.BigDecimal; +import java.util.Optional; public class AmmIT extends AbstractIT { + String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); + @BeforeAll protected static void initXrplEnvironment() { xrplEnvironment = new CustomEnvironment( @@ -45,21 +60,269 @@ protected static void initXrplEnvironment() { } @Test - void name() throws JsonRpcClientErrorException, JsonProcessingException { + void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { + Wallet issuerWallet = createRandomAccount(); + AmmInfoResult amm = createAmm(issuerWallet); + Wallet traderWallet = createRandomAccount(); + + FeeResult feeResult = xrplClient.fee(); + AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); + SingleKeySignatureService signatureService = new SingleKeySignatureService( + PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + ); + + AccountInfoResult traderAccountAfterDeposit = depositXrp( + issuerWallet, + traderWallet, + traderAccount, + amm, + signatureService, + feeResult + ); + + TradingFee newTradingFee = TradingFee.ofPercent(BigDecimal.valueOf(0.24)); + AmmVote ammVote = AmmVote.builder() + .account(traderAccount.accountData().account()) + .sequence(traderAccountAfterDeposit.accountData().sequence()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) + .signingPublicKey(traderWallet.publicKey()) + .asset2( + Asset.builder() + .currency(xrpl4jCoin) + .issuer(issuerWallet.classicAddress()) + .build() + ) + .asset(Asset.XRP) + .tradingFee(newTradingFee) + .build(); + + SignedTransaction signedVote = signatureService.sign(KeyMetadata.EMPTY, ammVote); + + SubmitResult voteSubmitResult = xrplClient.submit(signedVote); + assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + + scanForFinality( + signedVote.hash(), + traderAccount.ledgerIndexSafe(), + ammVote.lastLedgerSequence().get(), + ammVote.sequence(), + traderWallet.classicAddress() + ); + + AmmInfoResult ammAfterVote = getAmmInfo(issuerWallet); + assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); + } + + @Test + void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { + Wallet issuerWallet = createRandomAccount(); + AmmInfoResult amm = createAmm(issuerWallet); + Wallet traderWallet = createRandomAccount(); + Wallet authAccount1 = createRandomAccount(); + + FeeResult feeResult = xrplClient.fee(); + AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); + SingleKeySignatureService signatureService = new SingleKeySignatureService( + PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + ); + + AccountInfoResult traderAccountAfterDeposit = depositXrp( + issuerWallet, + traderWallet, + traderAccount, + amm, + signatureService, + feeResult + ); + + AmmBid bid = AmmBid.builder() + .account(traderAccount.accountData().account()) + .sequence(traderAccountAfterDeposit.accountData().sequence()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) + .signingPublicKey(traderWallet.publicKey()) + .asset2( + Asset.builder() + .currency(xrpl4jCoin) + .issuer(issuerWallet.classicAddress()) + .build() + ) + .asset(Asset.XRP) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(authAccount1.classicAddress())) + ) + .bidMin( + IssuedCurrencyAmount.builder() + .from(amm.amm().lpToken()) + .value("100") + .build() + ) + .build(); + + SignedTransaction signedBid = signatureService.sign(KeyMetadata.EMPTY, bid); + + SubmitResult voteSubmitResult = xrplClient.submit(signedBid); + assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + + scanForFinality( + signedBid.hash(), + traderAccount.ledgerIndexSafe(), + bid.lastLedgerSequence().get(), + bid.sequence(), + traderWallet.classicAddress() + ); + + AmmInfoResult ammAfterBid = getAmmInfo(issuerWallet); + + assertThat(ammAfterBid.amm().auctionSlot()).isNotEmpty(); + AmmInfoAuctionSlot auctionSlot = ammAfterBid.amm().auctionSlot().get(); + assertThat(auctionSlot.account()).isEqualTo(traderAccount.accountData().account()); + assertThat(auctionSlot.authAccounts()).asList().extracting("account") + .containsExactly(authAccount1.classicAddress()); + } + + @Test + void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { Wallet issuerWallet = createRandomAccount(); - Wallet counterpartyWallet = createRandomAccount(); + AmmInfoResult amm = createAmm(issuerWallet); + Wallet traderWallet = createRandomAccount(); FeeResult feeResult = xrplClient.fee(); + AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); + SingleKeySignatureService signatureService = new SingleKeySignatureService( + PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + ); + + AccountInfoResult traderAccountAfterDeposit = depositXrp( + issuerWallet, + traderWallet, + traderAccount, + amm, + signatureService, + feeResult + ); + + AmmInfoResult ammInfoAfterDeposit = getAmmInfo(issuerWallet); + AmmWithdraw withdraw = AmmWithdraw.builder() + .account(traderWallet.classicAddress()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .sequence(traderAccountAfterDeposit.accountData().sequence()) + .lastLedgerSequence( + traderAccountAfterDeposit.ledgerCurrentIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue() + ) + .signingPublicKey(traderWallet.publicKey()) + .asset2( + Asset.builder() + .currency(xrpl4jCoin) + .issuer(issuerWallet.classicAddress()) + .build() + ) + .asset(Asset.XRP) + .amount(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(90))) + .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .build(); + + SignedTransaction signedWithdraw = signatureService.sign(KeyMetadata.EMPTY, withdraw); + + SubmitResult voteSubmitResult = xrplClient.submit(signedWithdraw); + assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + + scanForFinality( + signedWithdraw.hash(), + traderAccount.ledgerIndexSafe(), + withdraw.lastLedgerSequence().get(), + withdraw.sequence(), + traderWallet.classicAddress() + ); + + AmmInfoResult ammAfterWithdraw = getAmmInfo(issuerWallet); + assertThat(ammAfterWithdraw.amm().amount2()).isInstanceOf(XrpCurrencyAmount.class) + .isEqualTo(((XrpCurrencyAmount) ammInfoAfterDeposit.amm().amount2()) + .minus((XrpCurrencyAmount) withdraw.amount().get())); + + AccountInfoResult traderAccountAfterWithdraw = xrplClient.accountInfo( + AccountInfoRequestParams.of(traderWallet.classicAddress()) + ); + + assertThat(traderAccountAfterWithdraw.accountData().balance()).isEqualTo( + traderAccountAfterDeposit.accountData().balance() + .minus(withdraw.fee()) + .plus((XrpCurrencyAmount) withdraw.amount().get()) + ); + } - /////////////////////////// - // Create a Trust Line between issuer and counterparty denominated in a custom currency - // by submitting a TrustSet transaction - String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); + private AccountInfoResult depositXrp( + Wallet issuerWallet, + Wallet traderWallet, + AccountInfoResult traderAccount, + AmmInfoResult amm, + SignatureService signatureService, + FeeResult feeResult + ) throws JsonRpcClientErrorException, JsonProcessingException { + XrpCurrencyAmount depositAmount = XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100)); + AmmDeposit deposit = AmmDeposit.builder() + .account(traderAccount.accountData().account()) + .asset2( + Asset.builder() + .currency(xrpl4jCoin) + .issuer(issuerWallet.classicAddress()) + .build() + ) + .asset(Asset.XRP) + .amount(depositAmount) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .sequence(traderAccount.accountData().sequence()) + .signingPublicKey(traderWallet.publicKey()) + .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue()) + .build(); + + SignedTransaction signedDeposit = signatureService.sign(KeyMetadata.EMPTY, deposit); + SubmitResult submitResult = xrplClient.submit(signedDeposit); + assertThat(submitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + + scanForFinality( + signedDeposit.hash(), + traderAccount.ledgerIndexSafe(), + deposit.lastLedgerSequence().get(), + deposit.sequence(), + traderWallet.classicAddress() + ); + + AccountInfoResult traderAccountAfterDeposit = xrplClient.accountInfo( + AccountInfoRequestParams.of(traderAccount.accountData().account()) + ); + + assertThat(traderAccountAfterDeposit.accountData().balance()) + .isEqualTo(traderAccount.accountData().balance().minus(deposit.fee()).minus(depositAmount)); + + AccountLinesResult traderLines = xrplClient.accountLines( + AccountLinesRequestParams.builder() + .account(traderAccount.accountData().account()) + .peer(amm.amm().ammAccount()) + .build() + ); + + assertThat(traderLines.lines()).asList().hasSize(1); + TrustLine lpLine = traderLines.lines().get(0); + assertThat(lpLine.currency()).isEqualTo(amm.amm().lpToken().currency()); + assertThat(new BigDecimal(lpLine.balance())).isGreaterThan(BigDecimal.ZERO); + + return traderAccountAfterDeposit; + } + + private AmmInfoResult createAmm(Wallet issuerWallet) throws JsonRpcClientErrorException, JsonProcessingException { AccountInfoResult issuerAccount = scanForResult(() -> this.getValidatedAccountInfo(issuerWallet.classicAddress())); + XrpCurrencyAmount reserveAmount = xrplClient.serverInformation().info() + .map( + rippled -> rippled.closedLedger().orElse(rippled.validatedLedger().get()).reserveIncXrp(), + clio -> clio.validatedLedger().get().reserveIncXrp(), + reporting -> reporting.closedLedger().orElse(reporting.validatedLedger().get()).reserveIncXrp() + ); AmmCreate ammCreate = AmmCreate.builder() .account(issuerWallet.classicAddress()) .sequence(issuerAccount.accountData().sequence()) - .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .fee(reserveAmount) .amount( IssuedCurrencyAmount.builder() .issuer(issuerWallet.classicAddress()) @@ -89,7 +352,11 @@ void name() throws JsonRpcClientErrorException, JsonProcessingException { issuerWallet.classicAddress() ); - AmmInfoResult ammInfoResult = xrplClient.ammInfo( + return getAmmInfo(issuerWallet); + } + + private AmmInfoResult getAmmInfo(Wallet issuerWallet) throws JsonRpcClientErrorException { + return xrplClient.ammInfo( AmmInfoRequestParams.builder() .asset( Asset.builder() @@ -100,7 +367,5 @@ void name() throws JsonRpcClientErrorException, JsonProcessingException { .asset2(Asset.XRP) .build() ); - - logger.info("ammInfoResult: {}", ammInfoResult); } } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java new file mode 100644 index 000000000..797eeceb8 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -0,0 +1,49 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.time.ZonedDateTime; +import java.util.List; + +@Value.Immutable +@JsonSerialize(as = ImmutableAmmInfoAuctionSlot.class) +@JsonDeserialize(as = ImmutableAmmInfoAuctionSlot.class) +public interface AmmInfoAuctionSlot { + + /** + * Construct a {@code AmmInfoAuctionSlot} builder. + * + * @return An {@link ImmutableAmmInfoAuctionSlot.Builder}. + */ + static ImmutableAmmInfoAuctionSlot.Builder builder() { + return ImmutableAmmInfoAuctionSlot.builder(); + } + + @JsonProperty("account") + Address account(); + + @JsonProperty("auth_accounts") + List authAccounts(); + + @JsonProperty("discounted_fee") + TradingFee discountedFee(); + + @JsonProperty("expiration") + @JsonFormat(pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", locale = "en_US") + ZonedDateTime expiration(); + + @JsonProperty("price") + IssuedCurrencyAmount price(); + + @JsonProperty("time_interval") + UnsignedInteger timeInterval(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java new file mode 100644 index 000000000..56c1d3025 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java @@ -0,0 +1,30 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.transactions.Address; + +@Value.Immutable +@JsonSerialize(as = ImmutableAmmInfoAuthAccount.class) +@JsonDeserialize(as = ImmutableAmmInfoAuthAccount.class) +public interface AmmInfoAuthAccount { + + /** + * Construct a {@code AmmInfoAuthAccount} builder. + * + * @return An {@link ImmutableAmmInfoAuthAccount.Builder}. + */ + static ImmutableAmmInfoAuthAccount.Builder builder() { + return ImmutableAmmInfoAuthAccount.builder(); + } + + static AmmInfoAuthAccount of(Address account) { + return builder() + .account(account) + .build(); + } + + Address account(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java index 72ea01916..524fce38a 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -8,6 +8,7 @@ import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.ledger.AmmObject; +import org.xrpl.xrpl4j.model.transactions.Hash256; import java.util.Optional; @@ -82,14 +83,22 @@ default LedgerIndex ledgerCurrentIndexSafe() { } /** - * If true, the information in this response comes from a validated ledger version. - * Otherwise, the information is subject to change. + * True if this data is from a validated ledger version; if false, this data is not final. * - * @return {@code true} if the information in this response comes from a validated ledger version, {@code false} - * if not. + * @return {@code true} if this data is from a validated ledger version, otherwise {@code false}. */ @Value.Default default boolean validated() { return false; } + + @JsonProperty("ledger_hash") + Optional ledgerHash(); + + @JsonIgnore + @Value.Auxiliary + default Hash256 ledgerHashSafe() { + return ledgerHash() + .orElseThrow(() -> new IllegalStateException("Result did not contain a ledgerHash.")); + } } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java index 31d1be056..10573752e 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java @@ -1,15 +1,20 @@ package org.xrpl.xrpl4j.model.client.amm; import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.client.XrplResult; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.ledger.Asset; import org.xrpl.xrpl4j.model.ledger.AuctionSlot; import org.xrpl.xrpl4j.model.ledger.VoteEntry; import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.CurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; @@ -19,7 +24,7 @@ @Value.Immutable @JsonSerialize(as = ImmutableAmmResult.class) @JsonDeserialize(as = ImmutableAmmResult.class) -public interface AmmResult { +public interface AmmResult extends XrplResult { /** * Construct a {@code AmmResult} builder. @@ -35,23 +40,35 @@ static ImmutableAmmResult.Builder builder() { * * @return An {@link Asset}. */ - @JsonProperty("Amount") - Asset amount(); + @JsonProperty("amount") + CurrencyAmount amount(); /** * The definition for the other asset this AMM holds. * * @return An {@link Asset}. */ - @JsonProperty("Amount2") - Asset asset2(); + @JsonProperty("amount2") + CurrencyAmount amount2(); + + @Value.Default + @JsonProperty("asset_frozen") + default boolean assetFrozen() { + return false; + } + + @Value.Default + @JsonProperty("asset2_frozen") + default boolean asset2Frozen() { + return false; + } /** * The address of the special account that holds this AMM's assets. * * @return An {@link Address}. */ - @JsonProperty("AMMAccount") + @JsonProperty("amm_account") Address ammAccount(); /** @@ -59,8 +76,8 @@ static ImmutableAmmResult.Builder builder() { * * @return An {@link AuctionSlot}. */ - @JsonProperty("AuctionSlot") - Optional auctionSlot(); + @JsonProperty("auction_slot") + Optional auctionSlot(); /** * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens @@ -69,9 +86,8 @@ static ImmutableAmmResult.Builder builder() { * * @return An {@link IssuedCurrencyAmount}. */ - @JsonProperty("LPTokenBalance") - @JsonAlias("LPToken") // FIXME: This is only here because AMM-net hasn't been updated and should be removed later on - IssuedCurrencyAmount lpTokenBalance(); + @JsonProperty("lp_token") + IssuedCurrencyAmount lpToken(); /** * The percentage fee to be charged for trades against this AMM instance, in units of 1/10,000. The maximum value is @@ -79,7 +95,7 @@ static ImmutableAmmResult.Builder builder() { * * @return A {@link TradingFee}. */ - @JsonProperty("TradingFee") + @JsonProperty("trading_fee") TradingFee tradingFee(); /** @@ -87,7 +103,7 @@ static ImmutableAmmResult.Builder builder() { * * @return A {@link List} of {@link VoteEntry}s. */ - @JsonProperty("VoteSlots") + @JsonProperty("vote_slot") List voteSlots(); } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java index 5fbbb15a9..29dbdbc47 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java @@ -1,5 +1,6 @@ package org.xrpl.xrpl4j.model.ledger; +import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -31,6 +32,7 @@ static ImmutableVoteEntry.Builder builder() { * @return An {@link Address}. */ @JsonProperty("Account") + @JsonAlias("account") Address account(); /** @@ -39,6 +41,7 @@ static ImmutableVoteEntry.Builder builder() { * @return A {@link TradingFee}. */ @JsonProperty("TradingFee") + @JsonAlias("trading_fee") TradingFee tradingFee(); /** @@ -47,6 +50,7 @@ static ImmutableVoteEntry.Builder builder() { * @return The {@link VoteWeight}. */ @JsonProperty("VoteWeight") + @JsonAlias("vote_weight") VoteWeight voteWeight(); } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index e92da94ce..bef19e35d 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -23,7 +23,7 @@ class AmmInfoResultTest extends AbstractJsonTest { - @Test + /*@Test void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( @@ -247,5 +247,5 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException assertThat(result.ledgerIndexSafe()).isEqualTo(result.ledgerIndex().get()); assertThatThrownBy(result::ledgerCurrentIndexSafe).isInstanceOf(IllegalStateException.class); - } + }*/ } \ No newline at end of file From bdd78e1066ae694e6c5ce68a08b92d6dfa6ac26c Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 11:26:15 -0500 Subject: [PATCH 15/53] fix tests --- .../xrpl/xrpl4j/codec/binary/types/Issue.java | 13 + .../model/client/amm/AmmInfoAuctionSlot.java | 38 +++ .../model/client/amm/AmmInfoAuthAccount.java | 15 + .../model/client/amm/AmmInfoResult.java | 11 + .../model/client/amm/AmmInfoVoteEntry.java | 53 +++ .../xrpl4j/model/client/amm/AmmResult.java | 26 +- .../xrpl/xrpl4j/model/ledger/AuctionSlot.java | 1 - .../model/client/amm/AmmInfoResultTest.java | 314 +++++++++--------- 8 files changed, 298 insertions(+), 173 deletions(-) create mode 100644 xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java index 70fdae77d..1f111b54a 100644 --- a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java @@ -8,6 +8,9 @@ import java.util.Optional; +/** + * JSON mapping object for the Issue serializable type. + */ @Value.Immutable @JsonSerialize(as = ImmutableIssue.class) @JsonDeserialize(as = ImmutableIssue.class) @@ -22,8 +25,18 @@ static ImmutableIssue.Builder builder() { return ImmutableIssue.builder(); } + /** + * The currency code of the Issue. + * + * @return A {@link JsonNode} containing the currency code. + */ JsonNode currency(); + /** + * The address of the issuer of this currency. Will be empty if {@link #currency()} is XRP. + * + * @return An optionally present {@link JsonNode}. + */ Optional issuer(); @Value.Check diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index 797eeceb8..885e1b33b 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; @@ -13,6 +14,11 @@ import java.time.ZonedDateTime; import java.util.List; +/** + * Object mapping for an AMM auction slot returned in response to an {@code amm_info} RPC call. The structure + * of the response object is similar but has a slightly different format from + * {@link org.xrpl.xrpl4j.model.ledger.AuctionSlot}. + */ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoAuctionSlot.class) @JsonDeserialize(as = ImmutableAmmInfoAuctionSlot.class) @@ -27,22 +33,54 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { return ImmutableAmmInfoAuctionSlot.builder(); } + /** + * The current owner of this auction slot. + * + * @return An {@link Address}. + */ @JsonProperty("account") Address account(); + /** + * A list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance. + * + * @return A {@link List} of {@link AmmInfoAuthAccount}s. + */ @JsonProperty("auth_accounts") List authAccounts(); + /** + * The trading fee to be charged to the auction owner. By default this is 0, meaning that the auction owner can trade + * at no fee instead of the standard fee for this AMM. + * + * @return A {@link TradingFee}. + */ @JsonProperty("discounted_fee") TradingFee discountedFee(); + /** + * The time when this slot expires, as a {@link ZonedDateTime}. + * + * @return An {@link ZonedDateTime} + */ @JsonProperty("expiration") @JsonFormat(pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", locale = "en_US") ZonedDateTime expiration(); + /** + * The amount the auction owner paid to win this slot, in LP Tokens. + * + * @return An {@link IssuedCurrencyAmount}. + */ @JsonProperty("price") IssuedCurrencyAmount price(); + /** + * An {@link UnsignedInteger} between 1 and 20 denoting the time slot used for the continuous auction slot pricing + * mechanism of the AMM. + * + * @return An {@link UnsignedInteger}. + */ @JsonProperty("time_interval") UnsignedInteger timeInterval(); diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java index 56c1d3025..f9a11decf 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java @@ -5,6 +5,9 @@ import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; +/** + * An account that is authorized to trade at the discounted fee for an AMM instance. + */ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoAuthAccount.class) @JsonDeserialize(as = ImmutableAmmInfoAuthAccount.class) @@ -19,12 +22,24 @@ static ImmutableAmmInfoAuthAccount.Builder builder() { return ImmutableAmmInfoAuthAccount.builder(); } + /** + * Construct an {@link AmmInfoAuthAccount} containing the given {@link Address}. + * + * @param account An {@link Address}. + * + * @return An {@link AmmInfoAuthAccount} containing the address. + */ static AmmInfoAuthAccount of(Address account) { return builder() .account(account) .build(); } + /** + * The address of the authorized account. + * + * @return An {@link Address}. + */ Address account(); } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java index 524fce38a..cb41f8e6b 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -92,9 +92,20 @@ default boolean validated() { return false; } + /** + * The identifying Hash of the ledger version used to generate this response. + * + * @return A {@link Hash256} containing the ledger hash. + */ @JsonProperty("ledger_hash") Optional ledgerHash(); + /** + * Get {@link #ledgerHash()}, or throw an {@link IllegalStateException} if {@link #ledgerHash()} is empty. + * + * @return The value of {@link #ledgerHash()}. + * @throws IllegalStateException If {@link #ledgerHash()} is empty. + */ @JsonIgnore @Value.Auxiliary default Hash256 ledgerHashSafe() { diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java new file mode 100644 index 000000000..86e61c697 --- /dev/null +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java @@ -0,0 +1,53 @@ +package org.xrpl.xrpl4j.model.client.amm; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntry; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +/** + * Describes a vote for the trading fee on an AMM by an LP. + */ +@Value.Immutable +@JsonSerialize(as = ImmutableAmmInfoVoteEntry.class) +@JsonDeserialize(as = ImmutableAmmInfoVoteEntry.class) +public interface AmmInfoVoteEntry { + + /** + * Construct a {@code AmmInfoVoteEntry} builder. + * + * @return An {@link ImmutableAmmInfoVoteEntry.Builder}. + */ + static ImmutableAmmInfoVoteEntry.Builder builder() { + return ImmutableAmmInfoVoteEntry.builder(); + } + + /** + * The address of the LP who voted. + * + * @return An {@link Address}. + */ + @JsonProperty("account") + Address account(); + + /** + * The trading fee that the LP voted for. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("trading_fee") + TradingFee tradingFee(); + + /** + * The weight of the LP's vote. + * + * @return The {@link VoteWeight}. + */ + @JsonProperty("vote_weight") + VoteWeight voteWeight(); + +} diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java index 10573752e..e7fad6b52 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java @@ -1,26 +1,26 @@ package org.xrpl.xrpl4j.model.client.amm; -import com.fasterxml.jackson.annotation.JsonAlias; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; -import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.ledger.Asset; import org.xrpl.xrpl4j.model.ledger.AuctionSlot; import org.xrpl.xrpl4j.model.ledger.VoteEntry; -import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.CurrencyAmount; -import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; import java.util.List; import java.util.Optional; +/** + * Information about the requested AMM ledger entry. This response is very closely related to + * {@link org.xrpl.xrpl4j.model.ledger.AmmObject}, however rippled returns the object in a different format in + * responses to {@code amm_info} RPC requests. + */ @Value.Immutable @JsonSerialize(as = ImmutableAmmResult.class) @JsonDeserialize(as = ImmutableAmmResult.class) @@ -51,12 +51,22 @@ static ImmutableAmmResult.Builder builder() { @JsonProperty("amount2") CurrencyAmount amount2(); + /** + * Whether the first asset of the AMM is frozen. Always false is the first asset is XRP. + * + * @return {@code true} if asset 1 is frozen, otherwise {@code false}. + */ @Value.Default @JsonProperty("asset_frozen") default boolean assetFrozen() { return false; } + /** + * Whether the second asset of the AMM is frozen. Always false is the second asset is XRP. + * + * @return {@code true} if asset 2 is frozen, otherwise {@code false}. + */ @Value.Default @JsonProperty("asset2_frozen") default boolean asset2Frozen() { @@ -74,7 +84,7 @@ default boolean asset2Frozen() { /** * Details of the current owner of the auction slot. * - * @return An {@link AuctionSlot}. + * @return An {@link AmmInfoAuctionSlot}. */ @JsonProperty("auction_slot") Optional auctionSlot(); @@ -103,7 +113,7 @@ default boolean asset2Frozen() { * * @return A {@link List} of {@link VoteEntry}s. */ - @JsonProperty("vote_slot") - List voteSlots(); + @JsonProperty("vote_slots") + List voteSlots(); } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java index 3773a3b4f..e5ab7954c 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java @@ -17,7 +17,6 @@ * Represents an AuctionSlot object in an {@link AmmObject}, containing details of the current owner of the auction * slot. */ -// TODO: Add Optional field for amm_info results @Value.Immutable @JsonSerialize(as = ImmutableAuctionSlot.class) @JsonDeserialize(as = ImmutableAuctionSlot.class) diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index bef19e35d..b52bf6361 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -17,118 +17,114 @@ import org.xrpl.xrpl4j.model.ledger.VoteEntry; import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.VoteWeight; +import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; + +import java.math.BigDecimal; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; class AmmInfoResultTest extends AbstractJsonTest { - /*@Test + @Test void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( - AmmObject.builder() - .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .asset(Asset.XRP) - .asset2( - Asset.builder() - .currency("TST") - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + AmmResult.builder() + .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .amount(XrpCurrencyAmount.ofDrops(11080000720L)) + .amount2( + IssuedCurrencyAmount.builder() + .currency("USD") + .issuer(Address.of("rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP")) + .value("11080.00072727936") .build() ) + .asset2Frozen(false) .auctionSlot( - AuctionSlot.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + AmmInfoAuctionSlot.builder() + .account(Address.of("rM7xXGzMUALmEhQ2y9FW5XG69WXwQ6xtDC")) .addAuthAccounts( - AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), - AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + AmmInfoAuthAccount.of(Address.of("rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi")), + AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration(UnsignedInteger.valueOf(721870180)) + .expiration( + ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", + DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) + .withZoneSameLocal(ZoneId.of("UTC")) + ) .price( IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("0.8696263565463045") + .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") + .issuer(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .value("100") .build() ) + .timeInterval(UnsignedInteger.ZERO) .build() ) - .lpTokenBalance( + .lpToken( IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("71150.53584131501") + .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") + .issuer(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .value("11079900") .build() ) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(225))) .addVoteSlots( - VoteEntryWrapper.of( - VoteEntry.builder() - .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .build() - ) + AmmInfoVoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(90))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(50))) + .account(Address.of("rs6HZNabrZzBBjDWCwkWcSGdDH7Xsi4Z99")) + .build(), + AmmInfoVoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(90))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(100))) + .account(Address.of("rJd7rhLSaqLHEfeqAW2vYzYYkhvyE9XfBE")) + .build() ) .build() ) - .ledgerCurrentIndex(LedgerIndex.of(UnsignedInteger.valueOf(226645))) + .ledgerCurrentIndex(LedgerIndex.of(UnsignedInteger.valueOf(102))) + .status("success") .validated(false) .build(); - String json = "{\n" + - " \"amm\": {\n" + - " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"LedgerEntryType\" : \"AMM\",\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"AuctionSlot\" : {\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"AuthAccounts\" : [\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + - " }\n" + - " },\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + - " }\n" + - " }\n" + - " ],\n" + - " \"DiscountedFee\" : 0,\n" + - " \"Expiration\" : 721870180,\n" + - " \"Price\" : {\n" + - " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + - " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"value\" : \"0.8696263565463045\"\n" + - " }\n" + - " },\n" + - " \"Flags\" : 0,\n" + - " \"LPTokenBalance\" : {\n" + - " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + - " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"value\" : \"71150.53584131501\"\n" + - " },\n" + - " \"TradingFee\" : 600,\n" + - " \"VoteSlots\" : [\n" + - " {\n" + - " \"VoteEntry\" : {\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"TradingFee\" : 600,\n" + - " \"VoteWeight\" : 100000\n" + - " }\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"ledger_current_index\": 226645,\n" + - " \"validated\": false\n" + - " }"; + + String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"amount\": \"11080000720\",\n" + + " \"amount2\": {\"currency\": \"USD\",\n" + + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + + " \"value\": \"11080.00072727936\"},\n" + + " \"asset2_frozen\": false,\n" + + " \"asset_frozen\": false,\n" + + " \"auction_slot\": {\"account\": \"rM7xXGzMUALmEhQ2y9FW5XG69WXwQ6xtDC\",\n" + + " \"auth_accounts\": [{\"account\": \"rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi\"},\n" + + " {\"account\": \"rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG\"}],\n" + + " \"discounted_fee\": 0,\n" + + " \"expiration\": \"2023-Jan-07 23:47:21.000000000 UTC\",\n" + + " \"price\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"value\": \"100\"},\n" + + " \"time_interval\": 0},\n" + + " \"lp_token\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"value\": \"11079900\"},\n" + + " \"trading_fee\": 225,\n" + + " \"vote_slots\": [{\"account\": \"rs6HZNabrZzBBjDWCwkWcSGdDH7Xsi4Z99\",\n" + + " \"trading_fee\": 50,\n" + + " \"vote_weight\": 90},\n" + + " {\"account\": \"rJd7rhLSaqLHEfeqAW2vYzYYkhvyE9XfBE\",\n" + + " \"trading_fee\": 100,\n" + + " \"vote_weight\": 90}]},\n" + + " \"ledger_current_index\": 102,\n" + + " \"status\": \"success\",\n" + + " \"validated\": false}"; assertCanSerializeAndDeserialize(result, json); @@ -140,112 +136,102 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { void testJsonForValidatedLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( - AmmObject.builder() - .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .asset(Asset.XRP) - .asset2( - Asset.builder() - .currency("TST") - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + AmmResult.builder() + .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .amount(XrpCurrencyAmount.ofDrops(11080000720L)) + .amount2( + IssuedCurrencyAmount.builder() + .currency("USD") + .issuer(Address.of("rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP")) + .value("11080.00072727936") .build() ) + .asset2Frozen(false) .auctionSlot( - AuctionSlot.builder() - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + AmmInfoAuctionSlot.builder() + .account(Address.of("rM7xXGzMUALmEhQ2y9FW5XG69WXwQ6xtDC")) .addAuthAccounts( - AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), - AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + AmmInfoAuthAccount.of(Address.of("rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi")), + AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration(UnsignedInteger.valueOf(721870180)) + .expiration( + ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", + DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) + .withZoneSameLocal(ZoneId.of("UTC")) + ) .price( IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("0.8696263565463045") + .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") + .issuer(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .value("100") .build() ) + .timeInterval(UnsignedInteger.ZERO) .build() ) - .lpTokenBalance( + .lpToken( IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("71150.53584131501") + .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") + .issuer(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .value("11079900") .build() ) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(225))) .addVoteSlots( - VoteEntryWrapper.of( - VoteEntry.builder() - .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(100000))) - .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) - .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .build() - ) + AmmInfoVoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(90))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(50))) + .account(Address.of("rs6HZNabrZzBBjDWCwkWcSGdDH7Xsi4Z99")) + .build(), + AmmInfoVoteEntry.builder() + .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(90))) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(100))) + .account(Address.of("rJd7rhLSaqLHEfeqAW2vYzYYkhvyE9XfBE")) + .build() ) .build() ) - .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(226645))) + .ledgerHash(Hash256.of("93586177048F82080AB79B8D0FA76F9D93AF458551A7358D9F0EC6D790AF5CBA")) + .ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(102))) + .status("success") .validated(true) .build(); - String json = "{\n" + - " \"amm\": {\n" + - " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"LedgerEntryType\" : \"AMM\",\n" + - " \"Asset\" : {\n" + - " \"currency\" : \"XRP\"\n" + - " },\n" + - " \"Asset2\" : {\n" + - " \"currency\" : \"TST\",\n" + - " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + - " },\n" + - " \"AuctionSlot\" : {\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"AuthAccounts\" : [\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + - " }\n" + - " },\n" + - " {\n" + - " \"AuthAccount\" : {\n" + - " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + - " }\n" + - " }\n" + - " ],\n" + - " \"DiscountedFee\" : 0,\n" + - " \"Expiration\" : 721870180,\n" + - " \"Price\" : {\n" + - " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + - " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"value\" : \"0.8696263565463045\"\n" + - " }\n" + - " },\n" + - " \"Flags\" : 0,\n" + - " \"LPTokenBalance\" : {\n" + - " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + - " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + - " \"value\" : \"71150.53584131501\"\n" + - " },\n" + - " \"TradingFee\" : 600,\n" + - " \"VoteSlots\" : [\n" + - " {\n" + - " \"VoteEntry\" : {\n" + - " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + - " \"TradingFee\" : 600,\n" + - " \"VoteWeight\" : 100000\n" + - " }\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"ledger_index\": 226645,\n" + - " \"validated\": true\n" + - " }"; + + String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"amount\": \"11080000720\",\n" + + " \"amount2\": {\"currency\": \"USD\",\n" + + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + + " \"value\": \"11080.00072727936\"},\n" + + " \"asset2_frozen\": false,\n" + + " \"asset_frozen\": false,\n" + + " \"auction_slot\": {\"account\": \"rM7xXGzMUALmEhQ2y9FW5XG69WXwQ6xtDC\",\n" + + " \"auth_accounts\": [{\"account\": \"rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi\"},\n" + + " {\"account\": \"rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG\"}],\n" + + " \"discounted_fee\": 0,\n" + + " \"expiration\": \"2023-Jan-07 23:47:21.000000000 UTC\",\n" + + " \"price\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"value\": \"100\"},\n" + + " \"time_interval\": 0},\n" + + " \"lp_token\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + " \"value\": \"11079900\"},\n" + + " \"trading_fee\": 225,\n" + + " \"vote_slots\": [{\"account\": \"rs6HZNabrZzBBjDWCwkWcSGdDH7Xsi4Z99\",\n" + + " \"trading_fee\": 50,\n" + + " \"vote_weight\": 90},\n" + + " {\"account\": \"rJd7rhLSaqLHEfeqAW2vYzYYkhvyE9XfBE\",\n" + + " \"trading_fee\": 100,\n" + + " \"vote_weight\": 90}]},\n" + + " \"ledger_hash\": \"93586177048F82080AB79B8D0FA76F9D93AF458551A7358D9F0EC6D790AF5CBA\",\n" + + " \"ledger_index\": 102,\n" + + " \"status\": \"success\",\n" + + " \"validated\": true}"; assertCanSerializeAndDeserialize(result, json); assertThat(result.ledgerIndexSafe()).isEqualTo(result.ledgerIndex().get()); assertThatThrownBy(result::ledgerCurrentIndexSafe).isInstanceOf(IllegalStateException.class); - }*/ + } } \ No newline at end of file From 6d01ba963f9e72973bd66a84e9deea1f7782c52d Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 11:59:20 -0500 Subject: [PATCH 16/53] fix checkstyle --- .../xrpl/xrpl4j/codec/binary/types/Issue.java | 3 ++ .../org/xrpl/xrpl4j/tests/AbstractIT.java | 37 ++++++++-------- .../xrpl4j/model/client/amm/AmmResult.java | 9 ++-- .../org/xrpl/xrpl4j/model/flags/Flags.java | 14 +++---- .../xrpl4j/model/transactions/AmmDeposit.java | 4 +- .../model/transactions/AmmWithdraw.java | 10 ++--- .../xrpl/xrpl4j/model/AbstractJsonTest.java | 6 ++- .../client/amm/AmmInfoRequestParamsTest.java | 2 - .../model/flags/AccountRootFlagsTests.java | 6 +-- .../model/flags/AmmDepositFlagsTest.java | 30 ++++++------- .../model/flags/AmmWithdrawFlagsTest.java | 42 +++++++++---------- .../xrpl4j/model/ledger/AmmObjectTest.java | 6 +-- .../model/transactions/TradingFeeTest.java | 2 +- .../model/transactions/VoteWeightTest.java | 2 +- 14 files changed, 88 insertions(+), 85 deletions(-) diff --git a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java index 1f111b54a..61c478b6a 100644 --- a/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java +++ b/xrpl4j-binary-codec/src/main/java/org/xrpl/xrpl4j/codec/binary/types/Issue.java @@ -39,6 +39,9 @@ static ImmutableIssue.Builder builder() { */ Optional issuer(); + /** + * Validate that {@link #issuer()} is empty if {@link #currency()} is "XRP". + */ @Value.Check default void checkIssuerEmptyForXrp() { if (currency().asText().equals("XRP")) { diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index 1c4ad1f69..137ff140d 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -118,20 +118,6 @@ protected void fundAccount(Wallet wallet) { // Ledger Helpers ////////////////////// - protected T scanForResult(Supplier resultSupplier, Predicate condition) { - return given() - .atMost(30, TimeUnit.SECONDS) - .pollInterval(100, TimeUnit.MILLISECONDS) - .await() - .until(() -> { - T result = resultSupplier.get(); - if (result == null) { - return null; - } - return condition.test(result) ? result : null; - }, is(notNullValue())); - } - protected Finality scanForFinality( Hash256 transactionHash, LedgerIndex submittedOnLedgerIndex, @@ -153,14 +139,29 @@ protected Finality scanForFinality( account ), is(equalTo( - Finality.builder() - .finalityStatus(FinalityStatus.VALIDATED_SUCCESS) - .resultCode(TransactionResultCodes.TES_SUCCESS) - .build() + Finality.builder() + .finalityStatus(FinalityStatus.VALIDATED_SUCCESS) + .resultCode(TransactionResultCodes.TES_SUCCESS) + .build() ) ) ); } + + protected T scanForResult(Supplier resultSupplier, Predicate condition) { + return given() + .atMost(30, TimeUnit.SECONDS) + .pollInterval(100, TimeUnit.MILLISECONDS) + .await() + .until(() -> { + T result = resultSupplier.get(); + if (result == null) { + return null; + } + return condition.test(result) ? result : null; + }, is(notNullValue())); + } + protected T scanForResult(Supplier resultSupplier) { Objects.requireNonNull(resultSupplier); return given() diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java index e7fad6b52..bc1ebdd4e 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java @@ -5,9 +5,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; -import org.xrpl.xrpl4j.model.ledger.Asset; -import org.xrpl.xrpl4j.model.ledger.AuctionSlot; -import org.xrpl.xrpl4j.model.ledger.VoteEntry; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.CurrencyAmount; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; @@ -38,7 +35,7 @@ static ImmutableAmmResult.Builder builder() { /** * The definition for one of the two assets this AMM holds. * - * @return An {@link Asset}. + * @return A {@link CurrencyAmount}. */ @JsonProperty("amount") CurrencyAmount amount(); @@ -46,7 +43,7 @@ static ImmutableAmmResult.Builder builder() { /** * The definition for the other asset this AMM holds. * - * @return An {@link Asset}. + * @return A {@link CurrencyAmount}. */ @JsonProperty("amount2") CurrencyAmount amount2(); @@ -111,7 +108,7 @@ default boolean asset2Frozen() { /** * A list of vote objects, representing votes on the pool's trading fee. * - * @return A {@link List} of {@link VoteEntry}s. + * @return A {@link List} of {@link AmmInfoVoteEntry}s. */ @JsonProperty("vote_slots") List voteSlots(); diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java index be35a508e..2c3301efc 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/flags/Flags.java @@ -236,7 +236,7 @@ private AmmDepositFlags(long value) { * * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. */ - public boolean tfLPToken() { + public boolean tfLpToken() { return this.isSet(LP_TOKEN); } @@ -263,7 +263,7 @@ public boolean tfTwoAsset() { * * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. */ - public boolean tfOneAssetLPToken() { + public boolean tfOneAssetLpToken() { return this.isSet(ONE_ASSET_LP_TOKEN); } @@ -272,7 +272,7 @@ public boolean tfOneAssetLPToken() { * * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. */ - public boolean tfLimitLPToken() { + public boolean tfLimitLpToken() { return this.isSet(LIMIT_LP_TOKEN); } @@ -329,7 +329,7 @@ private AmmWithdrawFlags(long value) { * * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. */ - public boolean tfLPToken() { + public boolean tfLpToken() { return this.isSet(LP_TOKEN); } @@ -374,7 +374,7 @@ public boolean tfTwoAsset() { * * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. */ - public boolean tfOneAssetLPToken() { + public boolean tfOneAssetLpToken() { return this.isSet(ONE_ASSET_LP_TOKEN); } @@ -383,7 +383,7 @@ public boolean tfOneAssetLPToken() { * * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. */ - public boolean tfLimitLPToken() { + public boolean tfLimitLpToken() { return this.isSet(LIMIT_LP_TOKEN); } } @@ -717,7 +717,7 @@ public boolean lsfRequireDestTag() { * * @return {@code true} if {@code lsfAMM} is set, otherwise {@code false}. */ - public boolean lsfAMM() { + public boolean lsfAmm() { return this.isSet(AccountRootFlags.AMM); } } diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index 27228714b..7fe41a5fc 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -64,7 +64,7 @@ default Flags.AmmDepositFlags flags() { Asset asset(); /** - * The definition for the other asset in the AMM's pool. + * The definition for the other asset in the AMM's pool. * * @return An {@link Asset}. */ @@ -100,7 +100,7 @@ default Flags.AmmDepositFlags flags() { /** * How many of the AMM's LP Tokens to buy. * - * @return @return An optionally present {@link IssuedCurrencyAmount}. + * @return An optionally present {@link IssuedCurrencyAmount}. */ @JsonProperty("LPTokenOut") Optional lpTokenOut(); diff --git a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java index e23133fe8..444565e4c 100644 --- a/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java +++ b/xrpl4j-model/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -41,7 +41,7 @@ static ImmutableAmmWithdraw.Builder builder() { Asset asset(); /** - * The definition for the other asset in the AMM's pool. + * The definition for the other asset in the AMM's pool. * * @return An {@link Asset}. */ @@ -77,7 +77,7 @@ static ImmutableAmmWithdraw.Builder builder() { /** * How many of the AMM's LP Tokens to buy. * - * @return @return An optionally present {@link IssuedCurrencyAmount}. + * @return An optionally present {@link IssuedCurrencyAmount}. */ @JsonProperty("LPTokensIn") Optional lpTokensIn(); @@ -94,7 +94,7 @@ void checkFieldPresenceBasedOnFlags() { boolean amount2Present = amount2().isPresent(); boolean effectivePricePresent = effectivePrice().isPresent(); - if (flags().tfLPToken()) { + if (flags().tfLpToken()) { Preconditions.checkState( lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent, "If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present." @@ -115,12 +115,12 @@ void checkFieldPresenceBasedOnFlags() { "If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice cannot " + "be present." ); - } else if (flags().tfOneAssetLPToken()) { + } else if (flags().tfOneAssetLpToken()) { Preconditions.checkState( lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent, "If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present." ); - } else if (flags().tfLimitLPToken()) { + } else if (flags().tfLimitLpToken()) { Preconditions.checkState( !lpTokenPresent && amountPresent && !amount2Present && effectivePricePresent, "If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present." diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java index c7a6a6d6e..1c58596ab 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/AbstractJsonTest.java @@ -48,7 +48,11 @@ public void setUp() { objectMapper = ObjectMapperFactory.create(); } - protected void assertCanSerializeAndDeserialize(T object, String json, Class clazz) throws JSONException, JsonProcessingException { + protected void assertCanSerializeAndDeserialize( + T object, + String json, + Class clazz + ) throws JSONException, JsonProcessingException { String serialized = objectMapper.writeValueAsString(object); JSONAssert.assertEquals(json, serialized, JSONCompareMode.STRICT); diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java index de5eb04a9..bbe32ed90 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java @@ -1,7 +1,5 @@ package org.xrpl.xrpl4j.model.client.amm; -import static org.junit.jupiter.api.Assertions.*; - import com.fasterxml.jackson.core.JsonProcessingException; import org.json.JSONException; import org.junit.jupiter.api.Test; diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java index 7ffd5e719..7090d1471 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java @@ -46,7 +46,7 @@ public void testDeriveIndividualFlagsFromFlags( boolean lsfPasswordSpent, boolean lsfRequireAuth, boolean lsfRequireDestTag, - boolean lsfAMM + boolean lsfAmm ) { long expectedFlags = (lsfDefaultRipple ? Flags.AccountRootFlags.DEFAULT_RIPPLE.getValue() : 0L) | (lsfDepositAuth ? Flags.AccountRootFlags.DEPOSIT_AUTH.getValue() : 0L) | @@ -57,7 +57,7 @@ public void testDeriveIndividualFlagsFromFlags( (lsfPasswordSpent ? Flags.AccountRootFlags.PASSWORD_SPENT.getValue() : 0L) | (lsfRequireAuth ? Flags.AccountRootFlags.REQUIRE_AUTH.getValue() : 0L) | (lsfRequireDestTag ? Flags.AccountRootFlags.REQUIRE_DEST_TAG.getValue() : 0L) | - (lsfAMM ? Flags.AccountRootFlags.AMM.getValue() : 0L); + (lsfAmm ? Flags.AccountRootFlags.AMM.getValue() : 0L); Flags.AccountRootFlags flags = Flags.AccountRootFlags.of(expectedFlags); assertThat(flags.getValue()).isEqualTo(expectedFlags); @@ -71,6 +71,6 @@ public void testDeriveIndividualFlagsFromFlags( assertThat(flags.lsfPasswordSpent()).isEqualTo(lsfPasswordSpent); assertThat(flags.lsfRequireAuth()).isEqualTo(lsfRequireAuth); assertThat(flags.lsfRequireDestTag()).isEqualTo(lsfRequireDestTag); - assertThat(flags.lsfAMM()).isEqualTo(lsfAMM); + assertThat(flags.lsfAmm()).isEqualTo(lsfAmm); } } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java index 1c016c65f..25e3870ee 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java @@ -9,38 +9,38 @@ public class AmmDepositFlagsTest { @Test void testFlagValues() { Flags.AmmDepositFlags lpToken = Flags.AmmDepositFlags.LP_TOKEN; - assertThat(lpToken.tfLPToken()).isTrue(); + assertThat(lpToken.tfLpToken()).isTrue(); assertThat(lpToken.tfSingleAsset()).isFalse(); assertThat(lpToken.tfTwoAsset()).isFalse(); - assertThat(lpToken.tfOneAssetLPToken()).isFalse(); - assertThat(lpToken.tfLimitLPToken()).isFalse(); + assertThat(lpToken.tfOneAssetLpToken()).isFalse(); + assertThat(lpToken.tfLimitLpToken()).isFalse(); Flags.AmmDepositFlags singleAsset = Flags.AmmDepositFlags.SINGLE_ASSET; - assertThat(singleAsset.tfLPToken()).isFalse(); + assertThat(singleAsset.tfLpToken()).isFalse(); assertThat(singleAsset.tfSingleAsset()).isTrue(); assertThat(singleAsset.tfTwoAsset()).isFalse(); - assertThat(singleAsset.tfOneAssetLPToken()).isFalse(); - assertThat(singleAsset.tfLimitLPToken()).isFalse(); + assertThat(singleAsset.tfOneAssetLpToken()).isFalse(); + assertThat(singleAsset.tfLimitLpToken()).isFalse(); Flags.AmmDepositFlags twoAsset = Flags.AmmDepositFlags.TWO_ASSET; - assertThat(twoAsset.tfLPToken()).isFalse(); + assertThat(twoAsset.tfLpToken()).isFalse(); assertThat(twoAsset.tfSingleAsset()).isFalse(); assertThat(twoAsset.tfTwoAsset()).isTrue(); - assertThat(twoAsset.tfOneAssetLPToken()).isFalse(); - assertThat(twoAsset.tfLimitLPToken()).isFalse(); + assertThat(twoAsset.tfOneAssetLpToken()).isFalse(); + assertThat(twoAsset.tfLimitLpToken()).isFalse(); Flags.AmmDepositFlags oneAssetLpToken = Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN; - assertThat(oneAssetLpToken.tfLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfLpToken()).isFalse(); assertThat(oneAssetLpToken.tfSingleAsset()).isFalse(); assertThat(oneAssetLpToken.tfTwoAsset()).isFalse(); - assertThat(oneAssetLpToken.tfOneAssetLPToken()).isTrue(); - assertThat(oneAssetLpToken.tfLimitLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfOneAssetLpToken()).isTrue(); + assertThat(oneAssetLpToken.tfLimitLpToken()).isFalse(); Flags.AmmDepositFlags limitLpToken = Flags.AmmDepositFlags.LIMIT_LP_TOKEN; - assertThat(limitLpToken.tfLPToken()).isFalse(); + assertThat(limitLpToken.tfLpToken()).isFalse(); assertThat(limitLpToken.tfSingleAsset()).isFalse(); assertThat(limitLpToken.tfTwoAsset()).isFalse(); - assertThat(limitLpToken.tfOneAssetLPToken()).isFalse(); - assertThat(limitLpToken.tfLimitLPToken()).isTrue(); + assertThat(limitLpToken.tfOneAssetLpToken()).isFalse(); + assertThat(limitLpToken.tfLimitLpToken()).isTrue(); } } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java index 873d98b9b..d0e7c6f4e 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlagsTest.java @@ -9,67 +9,67 @@ public class AmmWithdrawFlagsTest { @Test void testFlagValues() { Flags.AmmWithdrawFlags lpToken = Flags.AmmWithdrawFlags.LP_TOKEN; - assertThat(lpToken.tfLPToken()).isTrue(); + assertThat(lpToken.tfLpToken()).isTrue(); assertThat(lpToken.tfWithdrawAll()).isFalse(); assertThat(lpToken.tfOneAssetWithdrawAll()).isFalse(); assertThat(lpToken.tfSingleAsset()).isFalse(); assertThat(lpToken.tfTwoAsset()).isFalse(); - assertThat(lpToken.tfOneAssetLPToken()).isFalse(); - assertThat(lpToken.tfLimitLPToken()).isFalse(); + assertThat(lpToken.tfOneAssetLpToken()).isFalse(); + assertThat(lpToken.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags withdrawAll = Flags.AmmWithdrawFlags.WITHDRAW_ALL; - assertThat(withdrawAll.tfLPToken()).isFalse(); + assertThat(withdrawAll.tfLpToken()).isFalse(); assertThat(withdrawAll.tfWithdrawAll()).isTrue(); assertThat(withdrawAll.tfOneAssetWithdrawAll()).isFalse(); assertThat(withdrawAll.tfSingleAsset()).isFalse(); assertThat(withdrawAll.tfTwoAsset()).isFalse(); - assertThat(withdrawAll.tfOneAssetLPToken()).isFalse(); - assertThat(withdrawAll.tfLimitLPToken()).isFalse(); + assertThat(withdrawAll.tfOneAssetLpToken()).isFalse(); + assertThat(withdrawAll.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags oneAssetWithdrawAll = Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL; - assertThat(oneAssetWithdrawAll.tfLPToken()).isFalse(); + assertThat(oneAssetWithdrawAll.tfLpToken()).isFalse(); assertThat(oneAssetWithdrawAll.tfWithdrawAll()).isFalse(); assertThat(oneAssetWithdrawAll.tfOneAssetWithdrawAll()).isTrue(); assertThat(oneAssetWithdrawAll.tfSingleAsset()).isFalse(); assertThat(oneAssetWithdrawAll.tfTwoAsset()).isFalse(); - assertThat(oneAssetWithdrawAll.tfOneAssetLPToken()).isFalse(); - assertThat(oneAssetWithdrawAll.tfLimitLPToken()).isFalse(); + assertThat(oneAssetWithdrawAll.tfOneAssetLpToken()).isFalse(); + assertThat(oneAssetWithdrawAll.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags singleAsset = Flags.AmmWithdrawFlags.SINGLE_ASSET; - assertThat(singleAsset.tfLPToken()).isFalse(); + assertThat(singleAsset.tfLpToken()).isFalse(); assertThat(singleAsset.tfWithdrawAll()).isFalse(); assertThat(singleAsset.tfOneAssetWithdrawAll()).isFalse(); assertThat(singleAsset.tfSingleAsset()).isTrue(); assertThat(singleAsset.tfTwoAsset()).isFalse(); - assertThat(singleAsset.tfOneAssetLPToken()).isFalse(); - assertThat(singleAsset.tfLimitLPToken()).isFalse(); + assertThat(singleAsset.tfOneAssetLpToken()).isFalse(); + assertThat(singleAsset.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags twoAsset = Flags.AmmWithdrawFlags.TWO_ASSET; - assertThat(twoAsset.tfLPToken()).isFalse(); + assertThat(twoAsset.tfLpToken()).isFalse(); assertThat(twoAsset.tfWithdrawAll()).isFalse(); assertThat(twoAsset.tfOneAssetWithdrawAll()).isFalse(); assertThat(twoAsset.tfSingleAsset()).isFalse(); assertThat(twoAsset.tfTwoAsset()).isTrue(); - assertThat(twoAsset.tfOneAssetLPToken()).isFalse(); - assertThat(twoAsset.tfLimitLPToken()).isFalse(); + assertThat(twoAsset.tfOneAssetLpToken()).isFalse(); + assertThat(twoAsset.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags oneAssetLpToken = Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN; - assertThat(oneAssetLpToken.tfLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfLpToken()).isFalse(); assertThat(oneAssetLpToken.tfWithdrawAll()).isFalse(); assertThat(oneAssetLpToken.tfOneAssetWithdrawAll()).isFalse(); assertThat(oneAssetLpToken.tfSingleAsset()).isFalse(); assertThat(oneAssetLpToken.tfTwoAsset()).isFalse(); - assertThat(oneAssetLpToken.tfOneAssetLPToken()).isTrue(); - assertThat(oneAssetLpToken.tfLimitLPToken()).isFalse(); + assertThat(oneAssetLpToken.tfOneAssetLpToken()).isTrue(); + assertThat(oneAssetLpToken.tfLimitLpToken()).isFalse(); Flags.AmmWithdrawFlags limitLpToken = Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN; - assertThat(limitLpToken.tfLPToken()).isFalse(); + assertThat(limitLpToken.tfLpToken()).isFalse(); assertThat(limitLpToken.tfWithdrawAll()).isFalse(); assertThat(limitLpToken.tfOneAssetWithdrawAll()).isFalse(); assertThat(limitLpToken.tfSingleAsset()).isFalse(); assertThat(limitLpToken.tfTwoAsset()).isFalse(); - assertThat(limitLpToken.tfOneAssetLPToken()).isFalse(); - assertThat(limitLpToken.tfLimitLPToken()).isTrue(); + assertThat(limitLpToken.tfOneAssetLpToken()).isFalse(); + assertThat(limitLpToken.tfLimitLpToken()).isTrue(); } } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java index 3a38cd615..918ac4f83 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java @@ -18,19 +18,19 @@ class AmmObjectTest extends AbstractJsonTest { @Test void voteSlotsUnwrapped() { VoteEntry voteEntry1 = VoteEntry.builder() - .account(mock(Address.class)) + .account(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) .voteWeight(VoteWeight.of(UnsignedInteger.ONE)) .tradingFee(TradingFee.of(UnsignedInteger.ONE)) .build(); VoteEntry voteEntry2 = VoteEntry.builder() - .account(mock(Address.class)) + .account(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .voteWeight(VoteWeight.of(UnsignedInteger.valueOf(2))) .tradingFee(TradingFee.of(UnsignedInteger.valueOf(2))) .build(); AmmObject ammObject = AmmObject.builder() .asset(mock(Asset.class)) .asset2(mock(Asset.class)) - .ammAccount(mock(Address.class)) + .ammAccount(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .lpTokenBalance(mock(IssuedCurrencyAmount.class)) .tradingFee(TradingFee.of(UnsignedInteger.ONE)) .addVoteSlots( diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java index 95eb191d1..69d43570f 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java @@ -74,7 +74,7 @@ void testJson() throws JsonProcessingException, JSONException { TradingFee tradingFee = TradingFee.of(UnsignedInteger.valueOf(1000)); TradingFeeWrapper wrapper = TradingFeeWrapper.of(tradingFee); - String json = "{\"tradingFee\": \"1000\"}"; + String json = "{\"tradingFee\": 1000}"; assertSerializesAndDeserializes(wrapper, json); } diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java index 0e04b42a7..1c7180276 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/transactions/VoteWeightTest.java @@ -50,7 +50,7 @@ void testJson() throws JsonProcessingException, JSONException { VoteWeight voteWeight = VoteWeight.of(UnsignedInteger.valueOf(1000)); VoteWeightWrapper wrapper = VoteWeightWrapper.of(voteWeight); - String json = "{\"voteWeight\": \"1000\"}"; + String json = "{\"voteWeight\": 1000}"; assertSerializesAndDeserializes(wrapper, json); } From 68128b4a480691a94ad7fadd14fd50900ca37ee1 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 12:03:22 -0500 Subject: [PATCH 17/53] update data-driven-tests to current set from xrpl.js --- .../codec/binary/FieldHeaderCodecTest.java | 6 +- .../src/test/resources/data-driven-tests.json | 1351 ++--------------- 2 files changed, 155 insertions(+), 1202 deletions(-) diff --git a/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java b/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java index 82cd1927d..717c80019 100644 --- a/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java +++ b/xrpl4j-binary-codec/src/test/java/org/xrpl/xrpl4j/codec/binary/FieldHeaderCodecTest.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,7 +43,7 @@ public void loadFixtures() throws IOException { ObjectMapper objectMapper = BinaryCodecObjectMapperFactory.getObjectMapper(); fieldHeaderCodec = new FieldHeaderCodec(new DefaultDefinitionsProvider(objectMapper).get(), objectMapper); fieldTests = FixtureUtils.getDataDrivenFixtures().fieldTests(); - assertThat(fieldTests).hasSize(125); + assertThat(fieldTests).hasSize(123); } diff --git a/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json b/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json index 4eae1bfab..cd1efcd29 100644 --- a/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json +++ b/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json @@ -483,13 +483,6 @@ "type": 5, "expected_hex": "5013" }, - { - "type_name": "Hash256", - "name": "TicketID", - "nth_of_type": 20, - "type": 5, - "expected_hex": "5014" - }, { "type_name": "Hash256", "name": "Digest", @@ -721,13 +714,6 @@ "type": 8, "expected_hex": "84" }, - { - "type_name": "AccountID", - "name": "Target", - "nth_of_type": 7, - "type": 8, - "expected_hex": "87" - }, { "type_name": "AccountID", "name": "RegularKey", @@ -966,9 +952,7 @@ [ "TransactionType", { - "binary": [ - "0007" - ], + "binary": ["0007"], "json": "OfferCreate", "field_header": "12" } @@ -976,9 +960,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -986,9 +968,7 @@ [ "Sequence", { - "binary": [ - "000017B4" - ], + "binary": ["000017B4"], "json": 6068, "field_header": "24" } @@ -996,9 +976,7 @@ [ "Expiration", { - "binary": [ - "535A8CF1" - ], + "binary": ["535A8CF1"], "json": 1398443249, "field_header": "2A" } @@ -1006,9 +984,7 @@ [ "TakerPays", { - "binary": [ - "4000000006084340" - ], + "binary": ["4000000006084340"], "json": "101204800", "field_header": "64" } @@ -1032,9 +1008,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -1042,9 +1016,7 @@ [ "Account", { - "binary": [ - "AD6E583D47F90F29FD8B23225E6F905602B0292E" - ], + "binary": ["AD6E583D47F90F29FD8B23225E6F905602B0292E"], "vl_length": "14", "json": "rGFpans8aW7XZNEcNky6RHKyEdLvXPMnUn", "field_header": "81" @@ -1072,9 +1044,7 @@ [ "TransactionType", { - "binary": [ - "0007" - ], + "binary": ["0007"], "json": "OfferCreate", "field_header": "12" } @@ -1082,9 +1052,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -1092,9 +1060,7 @@ [ "Sequence", { - "binary": [ - "00005124" - ], + "binary": ["00005124"], "json": 20772, "field_header": "24" } @@ -1102,9 +1068,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EE8EC" - ], + "binary": ["005EE8EC"], "json": 6220012, "field_header": "201B" } @@ -1112,9 +1076,7 @@ [ "TakerPays", { - "binary": [ - "4000000000140251" - ], + "binary": ["4000000000140251"], "json": "1311313", "field_header": "64" } @@ -1138,9 +1100,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -1148,9 +1108,7 @@ [ "Account", { - "binary": [ - "D0B32295596E50017E246FE85FC5982A1BD89CE4" - ], + "binary": ["D0B32295596E50017E246FE85FC5982A1BD89CE4"], "vl_length": "14", "json": "rLpW9Reyn9YqZ8mxbq8nviXSp4TnHafVJQ", "field_header": "81" @@ -1164,14 +1122,10 @@ "TakerPays": "223174650", "Account": "rPk2dXr27rMw9G5Ej9ad2Tt7RJzGy8ycBp", "TransactionType": "OfferCreate", - "Memos": [ - { - "Memo": { - "MemoType": "584D4D2076616C7565", - "MemoData": "322E3230393635" - } - } - ], + "Memos": [{"Memo": { + "MemoType": "584D4D2076616C7565", + "MemoData": "322E3230393635" + }}], "Fee": "15", "OfferSequence": 1002, "TakerGets": { @@ -1187,9 +1141,7 @@ [ "TransactionType", { - "binary": [ - "0007" - ], + "binary": ["0007"], "json": "OfferCreate", "field_header": "12" } @@ -1197,9 +1149,7 @@ [ "Flags", { - "binary": [ - "00080000" - ], + "binary": ["00080000"], "json": 524288, "field_header": "22" } @@ -1207,9 +1157,7 @@ [ "Sequence", { - "binary": [ - "000003EB" - ], + "binary": ["000003EB"], "json": 1003, "field_header": "24" } @@ -1217,9 +1165,7 @@ [ "OfferSequence", { - "binary": [ - "000003EA" - ], + "binary": ["000003EA"], "json": 1002, "field_header": "2019" } @@ -1227,9 +1173,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EE967" - ], + "binary": ["005EE967"], "json": 6220135, "field_header": "201B" } @@ -1237,9 +1181,7 @@ [ "TakerPays", { - "binary": [ - "400000000D4D5FFA" - ], + "binary": ["400000000D4D5FFA"], "json": "223174650", "field_header": "64" } @@ -1263,9 +1205,7 @@ [ "Fee", { - "binary": [ - "400000000000000F" - ], + "binary": ["400000000000000F"], "json": "15", "field_header": "68" } @@ -1273,9 +1213,7 @@ [ "Account", { - "binary": [ - "F990B9E746546554A7B50A5E013BCB57095C6BB8" - ], + "binary": ["F990B9E746546554A7B50A5E013BCB57095C6BB8"], "vl_length": "14", "json": "rPk2dXr27rMw9G5Ej9ad2Tt7RJzGy8ycBp", "field_header": "81" @@ -1294,14 +1232,10 @@ "322E3230393635", "E1" ], - "json": [ - { - "Memo": { - "MemoType": "584D4D2076616C7565", - "MemoData": "322E3230393635" - } - } - ], + "json": [{"Memo": { + "MemoType": "584D4D2076616C7565", + "MemoData": "322E3230393635" + }}], "field_header": "F9" } ] @@ -1326,9 +1260,7 @@ [ "TransactionType", { - "binary": [ - "0007" - ], + "binary": ["0007"], "json": "OfferCreate", "field_header": "12" } @@ -1336,9 +1268,7 @@ [ "Sequence", { - "binary": [ - "00080917" - ], + "binary": ["00080917"], "json": 526615, "field_header": "24" } @@ -1346,9 +1276,7 @@ [ "OfferSequence", { - "binary": [ - "000808DA" - ], + "binary": ["000808DA"], "json": 526554, "field_header": "2019" } @@ -1372,9 +1300,7 @@ [ "TakerGets", { - "binary": [ - "400000003C3945C2" - ], + "binary": ["400000003C3945C2"], "json": "1010386370", "field_header": "65" } @@ -1382,9 +1308,7 @@ [ "Fee", { - "binary": [ - "4000000000000032" - ], + "binary": ["4000000000000032"], "json": "50", "field_header": "68" } @@ -1392,9 +1316,7 @@ [ "Account", { - "binary": [ - "F4141D8B4EF33BC3EE224088CA418DFCD2847193" - ], + "binary": ["F4141D8B4EF33BC3EE224088CA418DFCD2847193"], "vl_length": "14", "json": "rPEZyTnSyQyXBCwMVYyaafSVPL8oMtfG6a", "field_header": "81" @@ -1421,22 +1343,16 @@ }, "Flags": 0, "Sequence": 6, - "Paths": [ - [ - { - "account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA" - } - ] - ], + "Paths": [[{ + "account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA" + }]], "DestinationTag": 736049272 }, "fields": [ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1444,9 +1360,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -1454,9 +1368,7 @@ [ "Sequence", { - "binary": [ - "00000006" - ], + "binary": ["00000006"], "json": 6, "field_header": "24" } @@ -1464,9 +1376,7 @@ [ "DestinationTag", { - "binary": [ - "2BDF3878" - ], + "binary": ["2BDF3878"], "json": 736049272, "field_header": "2E" } @@ -1490,9 +1400,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -1516,9 +1424,7 @@ [ "Account", { - "binary": [ - "B53847FA45E828BF9A52E38F7FB39E363493CE8B" - ], + "binary": ["B53847FA45E828BF9A52E38F7FB39E363493CE8B"], "vl_length": "14", "json": "rHXUjUtk5eiPFYpg27izxHeZ1t4x835Ecn", "field_header": "81" @@ -1527,9 +1433,7 @@ [ "Destination", { - "binary": [ - "EE39E6D05CFD6A90DAB700A1D70149ECEE29DFEC" - ], + "binary": ["EE39E6D05CFD6A90DAB700A1D70149ECEE29DFEC"], "vl_length": "14", "json": "r45dBj4S3VvMMYXxr9vHX4Z4Ma6ifPMCkK", "field_header": "83" @@ -1543,13 +1447,9 @@ "41C8BE2C0A6AA17471B9F6D0AF92AAB1C94D5A25", "00" ], - "json": [ - [ - { - "account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA" - } - ] - ], + "json": [[{ + "account": "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA" + }]], "field_header": "0112" } ] @@ -1579,9 +1479,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1589,9 +1487,7 @@ [ "Flags", { - "binary": [ - "80000000" - ], + "binary": ["80000000"], "json": 2147483648, "field_header": "22" } @@ -1599,9 +1495,7 @@ [ "Sequence", { - "binary": [ - "000054C7" - ], + "binary": ["000054C7"], "json": 21703, "field_header": "24" } @@ -1625,9 +1519,7 @@ [ "Fee", { - "binary": [ - "400000000000000A" - ], + "binary": ["400000000000000A"], "json": "10", "field_header": "68" } @@ -1651,9 +1543,7 @@ [ "Account", { - "binary": [ - "F7B414E9D25EE050553D8A0BB27202F4249AD328" - ], + "binary": ["F7B414E9D25EE050553D8A0BB27202F4249AD328"], "vl_length": "14", "json": "rP2jdgJhtY1pwDJQEMLfCixesg4cw8HcrW", "field_header": "81" @@ -1662,9 +1552,7 @@ [ "Destination", { - "binary": [ - "B83EB506BBE5BCF3E89C638FDB185B1DEAC96584" - ], + "binary": ["B83EB506BBE5BCF3E89C638FDB185B1DEAC96584"], "vl_length": "14", "json": "rHoUTGMxWKbrTTF8tpAjysjpu8PWrbt1Wx", "field_header": "83" @@ -1687,9 +1575,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1697,9 +1583,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -1707,9 +1591,7 @@ [ "Sequence", { - "binary": [ - "00000002" - ], + "binary": ["00000002"], "json": 2, "field_header": "24" } @@ -1717,9 +1599,7 @@ [ "Amount", { - "binary": [ - "40000000017D7840" - ], + "binary": ["40000000017D7840"], "json": "25000000", "field_header": "61" } @@ -1727,9 +1607,7 @@ [ "Fee", { - "binary": [ - "400000000000000A" - ], + "binary": ["400000000000000A"], "json": "10", "field_header": "68" } @@ -1737,9 +1615,7 @@ [ "Account", { - "binary": [ - "5CCB151F6E9D603F394AE778ACF10D3BECE874F6" - ], + "binary": ["5CCB151F6E9D603F394AE778ACF10D3BECE874F6"], "vl_length": "14", "json": "r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb", "field_header": "81" @@ -1748,9 +1624,7 @@ [ "Destination", { - "binary": [ - "E851BBBE79E328E43D68F43445368133DF5FBA5A" - ], + "binary": ["E851BBBE79E328E43D68F43445368133DF5FBA5A"], "vl_length": "14", "json": "r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C", "field_header": "83" @@ -1774,9 +1648,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1784,9 +1656,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -1794,9 +1664,7 @@ [ "Sequence", { - "binary": [ - "00000090" - ], + "binary": ["00000090"], "json": 144, "field_header": "24" } @@ -1804,9 +1672,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EE9BA" - ], + "binary": ["005EE9BA"], "json": 6220218, "field_header": "201B" } @@ -1814,9 +1680,7 @@ [ "Amount", { - "binary": [ - "4000000000030D40" - ], + "binary": ["4000000000030D40"], "json": "200000", "field_header": "61" } @@ -1824,9 +1688,7 @@ [ "Fee", { - "binary": [ - "400000000000000F" - ], + "binary": ["400000000000000F"], "json": "15", "field_header": "68" } @@ -1834,9 +1696,7 @@ [ "Account", { - "binary": [ - "AA1BD19D9E87BE8069FDBF6843653C43837C03C6" - ], + "binary": ["AA1BD19D9E87BE8069FDBF6843653C43837C03C6"], "vl_length": "14", "json": "rGWTUVmm1fB5QUjMYn8KfnyrFNgDiD9H9e", "field_header": "81" @@ -1845,9 +1705,7 @@ [ "Destination", { - "binary": [ - "67FE6EC28E0464DD24FB2D62A492AAC697CFAD02" - ], + "binary": ["67FE6EC28E0464DD24FB2D62A492AAC697CFAD02"], "vl_length": "14", "json": "rw71Qs1UYQrSQ9hSgRohqNNQcyjCCfffkQ", "field_header": "83" @@ -1871,9 +1729,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1881,9 +1737,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -1891,9 +1745,7 @@ [ "Sequence", { - "binary": [ - "00000001" - ], + "binary": ["00000001"], "json": 1, "field_header": "24" } @@ -1901,9 +1753,7 @@ [ "DestinationTag", { - "binary": [ - "F72D50CA" - ], + "binary": ["F72D50CA"], "json": 4146942154, "field_header": "2E" } @@ -1911,9 +1761,7 @@ [ "Amount", { - "binary": [ - "40000000017D7840" - ], + "binary": ["40000000017D7840"], "json": "25000000", "field_header": "61" } @@ -1921,9 +1769,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -1931,9 +1777,7 @@ [ "Account", { - "binary": [ - "E851BBBE79E328E43D68F43445368133DF5FBA5A" - ], + "binary": ["E851BBBE79E328E43D68F43445368133DF5FBA5A"], "vl_length": "14", "json": "r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C", "field_header": "81" @@ -1942,9 +1786,7 @@ [ "Destination", { - "binary": [ - "76DAC5E814CD4AA74142C3AB45E69A900E637AA2" - ], + "binary": ["76DAC5E814CD4AA74142C3AB45E69A900E637AA2"], "vl_length": "14", "json": "rBqSFEFg2B6GBMobtxnU1eLA1zbNC9NDGM", "field_header": "83" @@ -1967,9 +1809,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -1977,9 +1817,7 @@ [ "SourceTag", { - "binary": [ - "000A34F8" - ], + "binary": ["000A34F8"], "json": 668920, "field_header": "23" } @@ -1987,9 +1825,7 @@ [ "Sequence", { - "binary": [ - "0000888A" - ], + "binary": ["0000888A"], "json": 34954, "field_header": "24" } @@ -1997,9 +1833,7 @@ [ "Amount", { - "binary": [ - "400000000007A120" - ], + "binary": ["400000000007A120"], "json": "500000", "field_header": "61" } @@ -2007,9 +1841,7 @@ [ "Fee", { - "binary": [ - "4000000000000014" - ], + "binary": ["4000000000000014"], "json": "20", "field_header": "68" } @@ -2017,9 +1849,7 @@ [ "Account", { - "binary": [ - "08F41F116A1F60D60296B16907F0A041BF106197" - ], + "binary": ["08F41F116A1F60D60296B16907F0A041BF106197"], "vl_length": "14", "json": "rFLiPGytDEwC5heoqFcFAZoqPPmKBzX1o", "field_header": "81" @@ -2028,9 +1858,7 @@ [ "Destination", { - "binary": [ - "6E2F0455C46CF5DF61A1E58419A89D45459045EA" - ], + "binary": ["6E2F0455C46CF5DF61A1E58419A89D45459045EA"], "vl_length": "14", "json": "rBsbetvMYuMkEeHZYizPMkpveCVH8EVQYd", "field_header": "83" @@ -2053,14 +1881,10 @@ "SendMax": "3267350000", "Flags": 0, "Sequence": 10, - "Paths": [ - [ - { - "currency": "BTC", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" - } - ] - ], + "Paths": [[{ + "currency": "BTC", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + }]], "InvoiceID": "342B8D16BEE494D169034AFF0908FDE35874A38E548D4CEC8DFC5C49E9A33B76", "DestinationTag": 1403334172 }, @@ -2068,9 +1892,7 @@ [ "TransactionType", { - "binary": [ - "0000" - ], + "binary": ["0000"], "json": "Payment", "field_header": "12" } @@ -2078,9 +1900,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -2088,9 +1908,7 @@ [ "Sequence", { - "binary": [ - "0000000A" - ], + "binary": ["0000000A"], "json": 10, "field_header": "24" } @@ -2098,9 +1916,7 @@ [ "DestinationTag", { - "binary": [ - "53A52E1C" - ], + "binary": ["53A52E1C"], "json": 1403334172, "field_header": "2E" } @@ -2108,9 +1924,7 @@ [ "InvoiceID", { - "binary": [ - "342B8D16BEE494D169034AFF0908FDE35874A38E548D4CEC8DFC5C49E9A33B76" - ], + "binary": ["342B8D16BEE494D169034AFF0908FDE35874A38E548D4CEC8DFC5C49E9A33B76"], "json": "342B8D16BEE494D169034AFF0908FDE35874A38E548D4CEC8DFC5C49E9A33B76", "field_header": "5011" } @@ -2134,9 +1948,7 @@ [ "Fee", { - "binary": [ - "400000000000006A" - ], + "binary": ["400000000000006A"], "json": "106", "field_header": "68" } @@ -2144,9 +1956,7 @@ [ "SendMax", { - "binary": [ - "40000000C2BFCDF0" - ], + "binary": ["40000000C2BFCDF0"], "json": "3267350000", "field_header": "69" } @@ -2154,9 +1964,7 @@ [ "Account", { - "binary": [ - "52E0F910686FB449A23BC78C3D4CE564C988C6C0" - ], + "binary": ["52E0F910686FB449A23BC78C3D4CE564C988C6C0"], "vl_length": "14", "json": "r3ZDv3hLmTKwkgAqcXtX2yaMfnhRD3Grjc", "field_header": "81" @@ -2165,9 +1973,7 @@ [ "Destination", { - "binary": [ - "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3" - ], + "binary": ["DD39C650A96EDA48334E70CC4A85B8B2E8502CD3"], "vl_length": "14", "json": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", "field_header": "83" @@ -2182,14 +1988,10 @@ "DD39C650A96EDA48334E70CC4A85B8B2E8502CD3", "00" ], - "json": [ - [ - { - "currency": "BTC", - "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" - } - ] - ], + "json": [[{ + "currency": "BTC", + "issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" + }]], "field_header": "0112" } ] @@ -2210,9 +2012,7 @@ [ "TransactionType", { - "binary": [ - "0008" - ], + "binary": ["0008"], "json": "OfferCancel", "field_header": "12" } @@ -2220,9 +2020,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -2230,9 +2028,7 @@ [ "Sequence", { - "binary": [ - "00005121" - ], + "binary": ["00005121"], "json": 20769, "field_header": "24" } @@ -2240,9 +2036,7 @@ [ "OfferSequence", { - "binary": [ - "0000511B" - ], + "binary": ["0000511B"], "json": 20763, "field_header": "2019" } @@ -2250,9 +2044,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EE8E9" - ], + "binary": ["005EE8E9"], "json": 6220009, "field_header": "201B" } @@ -2260,9 +2052,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -2270,9 +2060,7 @@ [ "Account", { - "binary": [ - "D0B32295596E50017E246FE85FC5982A1BD89CE4" - ], + "binary": ["D0B32295596E50017E246FE85FC5982A1BD89CE4"], "vl_length": "14", "json": "rLpW9Reyn9YqZ8mxbq8nviXSp4TnHafVJQ", "field_header": "81" @@ -2294,9 +2082,7 @@ [ "TransactionType", { - "binary": [ - "0005" - ], + "binary": ["0005"], "json": "SetRegularKey", "field_header": "12" } @@ -2304,9 +2090,7 @@ [ "Flags", { - "binary": [ - "80000000" - ], + "binary": ["80000000"], "json": 2147483648, "field_header": "22" } @@ -2314,9 +2098,7 @@ [ "Sequence", { - "binary": [ - "00000003" - ], + "binary": ["00000003"], "json": 3, "field_header": "24" } @@ -2324,9 +2106,7 @@ [ "Fee", { - "binary": [ - "400000000000000A" - ], + "binary": ["400000000000000A"], "json": "10", "field_header": "68" } @@ -2334,9 +2114,7 @@ [ "Account", { - "binary": [ - "48E143E2384A1B3C69A412789F2CA3FCE2F65F0B" - ], + "binary": ["48E143E2384A1B3C69A412789F2CA3FCE2F65F0B"], "vl_length": "14", "json": "rfeMWWbSaGqc6Yth2dTetLBeKeUTTfE2pG", "field_header": "81" @@ -2345,9 +2123,7 @@ [ "RegularKey", { - "binary": [ - "48E143E2384A1B3C69A412789F2CA3FCE2F65F0B" - ], + "binary": ["48E143E2384A1B3C69A412789F2CA3FCE2F65F0B"], "vl_length": "14", "json": "rfeMWWbSaGqc6Yth2dTetLBeKeUTTfE2pG", "field_header": "88" @@ -2370,9 +2146,7 @@ [ "TransactionType", { - "binary": [ - "0005" - ], + "binary": ["0005"], "json": "SetRegularKey", "field_header": "12" } @@ -2380,9 +2154,7 @@ [ "Flags", { - "binary": [ - "80000000" - ], + "binary": ["80000000"], "json": 2147483648, "field_header": "22" } @@ -2390,9 +2162,7 @@ [ "Sequence", { - "binary": [ - "000000EE" - ], + "binary": ["000000EE"], "json": 238, "field_header": "24" } @@ -2400,9 +2170,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EF94C" - ], + "binary": ["005EF94C"], "json": 6224204, "field_header": "201B" } @@ -2410,9 +2178,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -2420,9 +2186,7 @@ [ "Account", { - "binary": [ - "CB3F392892D0772FF5AD155D8D70404B1DB2ACFE" - ], + "binary": ["CB3F392892D0772FF5AD155D8D70404B1DB2ACFE"], "vl_length": "14", "json": "rKXCummUHnenhYudNb9UoJ4mGBR75vFcgz", "field_header": "81" @@ -2431,9 +2195,7 @@ [ "RegularKey", { - "binary": [ - "F2F9A54D9CEBBE64342B52DE3450FFA0738C8D00" - ], + "binary": ["F2F9A54D9CEBBE64342B52DE3450FFA0738C8D00"], "vl_length": "14", "json": "rP9jbfTepHAHWB4q9YjNkLyaZT15uvexiZ", "field_header": "88" @@ -2459,9 +2221,7 @@ [ "TransactionType", { - "binary": [ - "0014" - ], + "binary": ["0014"], "json": "TrustSet", "field_header": "12" } @@ -2469,9 +2229,7 @@ [ "Flags", { - "binary": [ - "00020000" - ], + "binary": ["00020000"], "json": 131072, "field_header": "22" } @@ -2479,9 +2237,7 @@ [ "Sequence", { - "binary": [ - "0000002C" - ], + "binary": ["0000002C"], "json": 44, "field_header": "24" } @@ -2505,9 +2261,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -2515,9 +2269,7 @@ [ "Account", { - "binary": [ - "BE6C30732AE33CF2AF3344CE8172A6B9300183E3" - ], + "binary": ["BE6C30732AE33CF2AF3344CE8172A6B9300183E3"], "vl_length": "14", "json": "rJMiz2rCMjZzEMijXNH1exNBryTQEjFd9S", "field_header": "81" @@ -2544,9 +2296,7 @@ [ "TransactionType", { - "binary": [ - "0014" - ], + "binary": ["0014"], "json": "TrustSet", "field_header": "12" } @@ -2554,9 +2304,7 @@ [ "Flags", { - "binary": [ - "80020000" - ], + "binary": ["80020000"], "json": 2147614720, "field_header": "22" } @@ -2564,9 +2312,7 @@ [ "Sequence", { - "binary": [ - "0000002B" - ], + "binary": ["0000002B"], "json": 43, "field_header": "24" } @@ -2574,9 +2320,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EEAAF" - ], + "binary": ["005EEAAF"], "json": 6220463, "field_header": "201B" } @@ -2600,9 +2344,7 @@ [ "Fee", { - "binary": [ - "400000000000000C" - ], + "binary": ["400000000000000C"], "json": "12", "field_header": "68" } @@ -2610,9 +2352,7 @@ [ "Account", { - "binary": [ - "8353C031DF5AA061A23535E6ABCEEEA23F152B1E" - ], + "binary": ["8353C031DF5AA061A23535E6ABCEEEA23F152B1E"], "vl_length": "14", "json": "rUyPiNcSFFj6uMR2gEaD8jUerQ59G1qvwN", "field_header": "81" @@ -2633,9 +2373,7 @@ [ "TransactionType", { - "binary": [ - "0003" - ], + "binary": ["0003"], "json": "AccountSet", "field_header": "12" } @@ -2643,9 +2381,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -2653,9 +2389,7 @@ [ "Sequence", { - "binary": [ - "00002966" - ], + "binary": ["00002966"], "json": 10598, "field_header": "24" } @@ -2663,9 +2397,7 @@ [ "Fee", { - "binary": [ - "400000000000000A" - ], + "binary": ["400000000000000A"], "json": "10", "field_header": "68" } @@ -2673,9 +2405,7 @@ [ "Account", { - "binary": [ - "0F3D0C7D2CFAB2EC8295451F0B3CA038E8E9CDCD" - ], + "binary": ["0F3D0C7D2CFAB2EC8295451F0B3CA038E8E9CDCD"], "vl_length": "14", "json": "rpP2GdsQwenNnFPefbXFgiTvEgJWQpq8Rw", "field_header": "81" @@ -2697,9 +2427,7 @@ [ "TransactionType", { - "binary": [ - "0003" - ], + "binary": ["0003"], "json": "AccountSet", "field_header": "12" } @@ -2707,9 +2435,7 @@ [ "Flags", { - "binary": [ - "00000000" - ], + "binary": ["00000000"], "json": 0, "field_header": "22" } @@ -2717,9 +2443,7 @@ [ "Sequence", { - "binary": [ - "00000122" - ], + "binary": ["00000122"], "json": 290, "field_header": "24" } @@ -2727,9 +2451,7 @@ [ "LastLedgerSequence", { - "binary": [ - "005EECD6" - ], + "binary": ["005EECD6"], "json": 6221014, "field_header": "201B" } @@ -2737,9 +2459,7 @@ [ "Fee", { - "binary": [ - "400000000000000F" - ], + "binary": ["400000000000000F"], "json": "15", "field_header": "68" } @@ -2747,9 +2467,7 @@ [ "Account", { - "binary": [ - "ABBD4A3AF95FDFD6D072F11421D8F107CAEA1852" - ], + "binary": ["ABBD4A3AF95FDFD6D072F11421D8F107CAEA1852"], "vl_length": "14", "json": "rGCnJuD31Kx4QGZJ2dX7xoje6T4Zr5s9EB", "field_header": "81" @@ -2776,6 +2494,14 @@ "expected_hex": "4000000000000001", "is_negative": false }, + { + "test_json": "-1", + "type_id": 6, + "is_native": true, + "type": "Amount", + "expected_hex": "0000000000000001", + "is_negative": true + }, { "test_json": { "currency": "USD", @@ -3188,779 +2914,6 @@ "type": "Amount", "error": "10000000000000000000 absolute XRP is bigger than max native value 100000000000.0", "is_negative": true - }, - { - "test_json": 0, - "canonical_json": "Payment", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0000" - }, - { - "test_json": "EscrowCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0001" - }, - { - "test_json": 1, - "canonical_json": "EscrowCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0001" - }, - { - "test_json": "EscrowFinish", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0002" - }, - { - "test_json": 2, - "canonical_json": "EscrowFinish", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0002" - }, - { - "test_json": "AccountSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0003" - }, - { - "test_json": 3, - "canonical_json": "AccountSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0003" - }, - { - "test_json": "EscrowCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0004" - }, - { - "test_json": 4, - "canonical_json": "EscrowCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0004" - }, - { - "test_json": "SetRegularKey", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0005" - }, - { - "test_json": 5, - "canonical_json": "SetRegularKey", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0005" - }, - { - "test_json": "NickNameSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0006" - }, - { - "test_json": 6, - "canonical_json": "NickNameSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0006" - }, - { - "test_json": "OfferCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0007" - }, - { - "test_json": 7, - "canonical_json": "OfferCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0007" - }, - { - "test_json": "OfferCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0008" - }, - { - "test_json": 8, - "canonical_json": "OfferCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0008" - }, - { - "test_json": "Contract", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0009" - }, - { - "test_json": 9, - "canonical_json": "Contract", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0009" - }, - { - "test_json": "TicketCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "000A" - }, - { - "test_json": 10, - "canonical_json": "TicketCreate", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "000A" - }, - { - "test_json": "TicketCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "000B" - }, - { - "test_json": 11, - "canonical_json": "TicketCancel", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "000B" - }, - { - "test_json": "TrustSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0014" - }, - { - "test_json": 20, - "canonical_json": "TrustSet", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0014" - }, - { - "test_json": "EnableAmendment", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0064" - }, - { - "test_json": 100, - "canonical_json": "EnableAmendment", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0064" - }, - { - "test_json": "SetFee", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0065" - }, - { - "test_json": 101, - "canonical_json": "SetFee", - "type_id": 1, - "type_specialisation_field": "TransactionType", - "type": "UInt16", - "expected_hex": "0065" - }, - { - "test_json": "AccountRoot", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0061" - }, - { - "test_json": 97, - "canonical_json": "AccountRoot", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0061" - }, - { - "test_json": "DirectoryNode", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0064" - }, - { - "test_json": 100, - "canonical_json": "DirectoryNode", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0064" - }, - { - "test_json": "RippleState", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0072" - }, - { - "test_json": 114, - "canonical_json": "RippleState", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0072" - }, - { - "test_json": "Offer", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "006F" - }, - { - "test_json": 111, - "canonical_json": "Offer", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "006F" - }, - { - "test_json": "Contract", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0063" - }, - { - "test_json": 99, - "canonical_json": "Contract", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0063" - }, - { - "test_json": "LedgerHashes", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0068" - }, - { - "test_json": 104, - "canonical_json": "LedgerHashes", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0068" - }, - { - "test_json": "Amendments", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0066" - }, - { - "test_json": 102, - "canonical_json": "Amendments", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0066" - }, - { - "test_json": "FeeSettings", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0073" - }, - { - "test_json": 115, - "canonical_json": "FeeSettings", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0073" - }, - { - "test_json": "Ticket", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0054" - }, - { - "test_json": 84, - "canonical_json": "Ticket", - "type_id": 1, - "type_specialisation_field": "LedgerEntryType", - "type": "UInt16", - "expected_hex": "0054" - }, - { - "test_json": "tesSUCCESS", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "00" - }, - { - "test_json": 0, - "canonical_json": "tesSUCCESS", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "00" - }, - { - "test_json": "tecCLAIM", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "64" - }, - { - "test_json": 100, - "canonical_json": "tecCLAIM", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "64" - }, - { - "test_json": "tecPATH_PARTIAL", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "65" - }, - { - "test_json": 101, - "canonical_json": "tecPATH_PARTIAL", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "65" - }, - { - "test_json": "tecUNFUNDED_ADD", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "66" - }, - { - "test_json": 102, - "canonical_json": "tecUNFUNDED_ADD", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "66" - }, - { - "test_json": "tecUNFUNDED_OFFER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "67" - }, - { - "test_json": 103, - "canonical_json": "tecUNFUNDED_OFFER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "67" - }, - { - "test_json": "tecUNFUNDED_PAYMENT", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "68" - }, - { - "test_json": 104, - "canonical_json": "tecUNFUNDED_PAYMENT", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "68" - }, - { - "test_json": "tecFAILED_PROCESSING", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "69" - }, - { - "test_json": 105, - "canonical_json": "tecFAILED_PROCESSING", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "69" - }, - { - "test_json": "tecDIR_FULL", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "79" - }, - { - "test_json": 121, - "canonical_json": "tecDIR_FULL", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "79" - }, - { - "test_json": "tecINSUF_RESERVE_LINE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7A" - }, - { - "test_json": 122, - "canonical_json": "tecINSUF_RESERVE_LINE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7A" - }, - { - "test_json": "tecINSUF_RESERVE_OFFER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7B" - }, - { - "test_json": 123, - "canonical_json": "tecINSUF_RESERVE_OFFER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7B" - }, - { - "test_json": "tecNO_DST", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7C" - }, - { - "test_json": 124, - "canonical_json": "tecNO_DST", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7C" - }, - { - "test_json": "tecNO_DST_INSUF_XRP", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7D" - }, - { - "test_json": 125, - "canonical_json": "tecNO_DST_INSUF_XRP", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7D" - }, - { - "test_json": "tecNO_LINE_INSUF_RESERVE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7E" - }, - { - "test_json": 126, - "canonical_json": "tecNO_LINE_INSUF_RESERVE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7E" - }, - { - "test_json": "tecNO_LINE_REDUNDANT", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7F" - }, - { - "test_json": 127, - "canonical_json": "tecNO_LINE_REDUNDANT", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "7F" - }, - { - "test_json": "tecPATH_DRY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "80" - }, - { - "test_json": 128, - "canonical_json": "tecPATH_DRY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "80" - }, - { - "test_json": "tecUNFUNDED", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "81" - }, - { - "test_json": 129, - "canonical_json": "tecUNFUNDED", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "81" - }, - { - "test_json": "tecNO_ALTERNATIVE_KEY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "82" - }, - { - "test_json": 130, - "canonical_json": "tecNO_ALTERNATIVE_KEY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "82" - }, - { - "test_json": "tecNO_REGULAR_KEY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "83" - }, - { - "test_json": 131, - "canonical_json": "tecNO_REGULAR_KEY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "83" - }, - { - "test_json": "tecOWNERS", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "84" - }, - { - "test_json": 132, - "canonical_json": "tecOWNERS", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "84" - }, - { - "test_json": "tecNO_ISSUER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "85" - }, - { - "test_json": 133, - "canonical_json": "tecNO_ISSUER", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "85" - }, - { - "test_json": "tecNO_AUTH", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "86" - }, - { - "test_json": 134, - "canonical_json": "tecNO_AUTH", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "86" - }, - { - "test_json": "tecNO_LINE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "87" - }, - { - "test_json": 135, - "canonical_json": "tecNO_LINE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "87" - }, - { - "test_json": "tecINSUFF_FEE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "88" - }, - { - "test_json": 136, - "canonical_json": "tecINSUFF_FEE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "88" - }, - { - "test_json": "tecFROZEN", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "89" - }, - { - "test_json": 137, - "canonical_json": "tecFROZEN", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "89" - }, - { - "test_json": "tecNO_TARGET", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8A" - }, - { - "test_json": 138, - "canonical_json": "tecNO_TARGET", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8A" - }, - { - "test_json": "tecNO_PERMISSION", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8B" - }, - { - "test_json": 139, - "canonical_json": "tecNO_PERMISSION", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8B" - }, - { - "test_json": "tecNO_ENTRY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8C" - }, - { - "test_json": 140, - "canonical_json": "tecNO_ENTRY", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8C" - }, - { - "test_json": "tecINSUFFICIENT_RESERVE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8D" - }, - { - "test_json": 141, - "canonical_json": "tecINSUFFICIENT_RESERVE", - "type_id": 16, - "type_specialisation_field": "TransactionResult", - "type": "UInt8", - "expected_hex": "8D" } ] } From b1225afdaed26448ffa67ea976ed8fcdb40e4550 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 14:19:02 -0500 Subject: [PATCH 18/53] disable AmmITs --- .../src/test/resources/data-driven-tests.json | 781 +++++++++++++++++- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 16 +- .../java/org/xrpl/xrpl4j/tests/NfTokenIT.java | 8 - .../tests/environment/RippledContainer.java | 5 +- .../src/test/resources/rippled/rippled.cfg | 5 +- 5 files changed, 792 insertions(+), 23 deletions(-) diff --git a/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json b/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json index cd1efcd29..5e82b5a00 100644 --- a/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json +++ b/xrpl4j-binary-codec/src/test/resources/data-driven-tests.json @@ -2494,14 +2494,6 @@ "expected_hex": "4000000000000001", "is_negative": false }, - { - "test_json": "-1", - "type_id": 6, - "is_native": true, - "type": "Amount", - "expected_hex": "0000000000000001", - "is_negative": true - }, { "test_json": { "currency": "USD", @@ -2914,6 +2906,779 @@ "type": "Amount", "error": "10000000000000000000 absolute XRP is bigger than max native value 100000000000.0", "is_negative": true + }, + { + "test_json": 0, + "canonical_json": "Payment", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0000" + }, + { + "test_json": "EscrowCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0001" + }, + { + "test_json": 1, + "canonical_json": "EscrowCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0001" + }, + { + "test_json": "EscrowFinish", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0002" + }, + { + "test_json": 2, + "canonical_json": "EscrowFinish", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0002" + }, + { + "test_json": "AccountSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0003" + }, + { + "test_json": 3, + "canonical_json": "AccountSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0003" + }, + { + "test_json": "EscrowCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0004" + }, + { + "test_json": 4, + "canonical_json": "EscrowCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0004" + }, + { + "test_json": "SetRegularKey", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0005" + }, + { + "test_json": 5, + "canonical_json": "SetRegularKey", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0005" + }, + { + "test_json": "NickNameSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0006" + }, + { + "test_json": 6, + "canonical_json": "NickNameSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0006" + }, + { + "test_json": "OfferCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0007" + }, + { + "test_json": 7, + "canonical_json": "OfferCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0007" + }, + { + "test_json": "OfferCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0008" + }, + { + "test_json": 8, + "canonical_json": "OfferCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0008" + }, + { + "test_json": "Contract", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0009" + }, + { + "test_json": 9, + "canonical_json": "Contract", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0009" + }, + { + "test_json": "TicketCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "000A" + }, + { + "test_json": 10, + "canonical_json": "TicketCreate", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "000A" + }, + { + "test_json": "TicketCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "000B" + }, + { + "test_json": 11, + "canonical_json": "TicketCancel", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "000B" + }, + { + "test_json": "TrustSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0014" + }, + { + "test_json": 20, + "canonical_json": "TrustSet", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0014" + }, + { + "test_json": "EnableAmendment", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0064" + }, + { + "test_json": 100, + "canonical_json": "EnableAmendment", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0064" + }, + { + "test_json": "SetFee", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0065" + }, + { + "test_json": 101, + "canonical_json": "SetFee", + "type_id": 1, + "type_specialisation_field": "TransactionType", + "type": "UInt16", + "expected_hex": "0065" + }, + { + "test_json": "AccountRoot", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0061" + }, + { + "test_json": 97, + "canonical_json": "AccountRoot", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0061" + }, + { + "test_json": "DirectoryNode", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0064" + }, + { + "test_json": 100, + "canonical_json": "DirectoryNode", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0064" + }, + { + "test_json": "RippleState", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0072" + }, + { + "test_json": 114, + "canonical_json": "RippleState", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0072" + }, + { + "test_json": "Offer", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "006F" + }, + { + "test_json": 111, + "canonical_json": "Offer", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "006F" + }, + { + "test_json": "Contract", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0063" + }, + { + "test_json": 99, + "canonical_json": "Contract", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0063" + }, + { + "test_json": "LedgerHashes", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0068" + }, + { + "test_json": 104, + "canonical_json": "LedgerHashes", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0068" + }, + { + "test_json": "Amendments", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0066" + }, + { + "test_json": 102, + "canonical_json": "Amendments", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0066" + }, + { + "test_json": "FeeSettings", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0073" + }, + { + "test_json": 115, + "canonical_json": "FeeSettings", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0073" + }, + { + "test_json": "Ticket", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0054" + }, + { + "test_json": 84, + "canonical_json": "Ticket", + "type_id": 1, + "type_specialisation_field": "LedgerEntryType", + "type": "UInt16", + "expected_hex": "0054" + }, + { + "test_json": "tesSUCCESS", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "00" + }, + { + "test_json": 0, + "canonical_json": "tesSUCCESS", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "00" + }, + { + "test_json": "tecCLAIM", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "64" + }, + { + "test_json": 100, + "canonical_json": "tecCLAIM", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "64" + }, + { + "test_json": "tecPATH_PARTIAL", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "65" + }, + { + "test_json": 101, + "canonical_json": "tecPATH_PARTIAL", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "65" + }, + { + "test_json": "tecUNFUNDED_ADD", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "66" + }, + { + "test_json": 102, + "canonical_json": "tecUNFUNDED_ADD", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "66" + }, + { + "test_json": "tecUNFUNDED_OFFER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "67" + }, + { + "test_json": 103, + "canonical_json": "tecUNFUNDED_OFFER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "67" + }, + { + "test_json": "tecUNFUNDED_PAYMENT", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "68" + }, + { + "test_json": 104, + "canonical_json": "tecUNFUNDED_PAYMENT", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "68" + }, + { + "test_json": "tecFAILED_PROCESSING", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "69" + }, + { + "test_json": 105, + "canonical_json": "tecFAILED_PROCESSING", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "69" + }, + { + "test_json": "tecDIR_FULL", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "79" + }, + { + "test_json": 121, + "canonical_json": "tecDIR_FULL", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "79" + }, + { + "test_json": "tecINSUF_RESERVE_LINE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7A" + }, + { + "test_json": 122, + "canonical_json": "tecINSUF_RESERVE_LINE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7A" + }, + { + "test_json": "tecINSUF_RESERVE_OFFER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7B" + }, + { + "test_json": 123, + "canonical_json": "tecINSUF_RESERVE_OFFER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7B" + }, + { + "test_json": "tecNO_DST", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7C" + }, + { + "test_json": 124, + "canonical_json": "tecNO_DST", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7C" + }, + { + "test_json": "tecNO_DST_INSUF_XRP", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7D" + }, + { + "test_json": 125, + "canonical_json": "tecNO_DST_INSUF_XRP", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7D" + }, + { + "test_json": "tecNO_LINE_INSUF_RESERVE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7E" + }, + { + "test_json": 126, + "canonical_json": "tecNO_LINE_INSUF_RESERVE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7E" + }, + { + "test_json": "tecNO_LINE_REDUNDANT", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7F" + }, + { + "test_json": 127, + "canonical_json": "tecNO_LINE_REDUNDANT", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "7F" + }, + { + "test_json": "tecPATH_DRY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "80" + }, + { + "test_json": 128, + "canonical_json": "tecPATH_DRY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "80" + }, + { + "test_json": "tecUNFUNDED", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "81" + }, + { + "test_json": 129, + "canonical_json": "tecUNFUNDED", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "81" + }, + { + "test_json": "tecNO_ALTERNATIVE_KEY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "82" + }, + { + "test_json": 130, + "canonical_json": "tecNO_ALTERNATIVE_KEY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "82" + }, + { + "test_json": "tecNO_REGULAR_KEY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "83" + }, + { + "test_json": 131, + "canonical_json": "tecNO_REGULAR_KEY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "83" + }, + { + "test_json": "tecOWNERS", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "84" + }, + { + "test_json": 132, + "canonical_json": "tecOWNERS", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "84" + }, + { + "test_json": "tecNO_ISSUER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "85" + }, + { + "test_json": 133, + "canonical_json": "tecNO_ISSUER", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "85" + }, + { + "test_json": "tecNO_AUTH", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "86" + }, + { + "test_json": 134, + "canonical_json": "tecNO_AUTH", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "86" + }, + { + "test_json": "tecNO_LINE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "87" + }, + { + "test_json": 135, + "canonical_json": "tecNO_LINE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "87" + }, + { + "test_json": "tecINSUFF_FEE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "88" + }, + { + "test_json": 136, + "canonical_json": "tecINSUFF_FEE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "88" + }, + { + "test_json": "tecFROZEN", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "89" + }, + { + "test_json": 137, + "canonical_json": "tecFROZEN", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "89" + }, + { + "test_json": "tecNO_TARGET", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8A" + }, + { + "test_json": 138, + "canonical_json": "tecNO_TARGET", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8A" + }, + { + "test_json": "tecNO_PERMISSION", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8B" + }, + { + "test_json": 139, + "canonical_json": "tecNO_PERMISSION", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8B" + }, + { + "test_json": "tecNO_ENTRY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8C" + }, + { + "test_json": 140, + "canonical_json": "tecNO_ENTRY", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8C" + }, + { + "test_json": "tecINSUFFICIENT_RESERVE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8D" + }, + { + "test_json": 141, + "canonical_json": "tecINSUFFICIENT_RESERVE", + "type_id": 16, + "type_specialisation_field": "TransactionResult", + "type": "UInt8", + "expected_hex": "8D" } ] } diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 4a4b320c4..7f5a18454 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -8,6 +8,7 @@ import com.google.common.primitives.UnsignedInteger; import okhttp3.HttpUrl; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.KeyMetadata; @@ -47,11 +48,18 @@ import java.math.BigDecimal; import java.util.Optional; +/** + * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and + * is available in a local standalone docker container. Running these tests as part of a maven build will + * overwrite the value of xrplEnvironment, so any ITs run after these ITs will point at the AMM devnet. This is + * obviously undesirable, and in lieu of making a broader change to enable custom environments for specific test suites, + * we choose to simply disable these tests until we can run them against the normal xrplEnvironment. + */ public class AmmIT extends AbstractIT { String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); - @BeforeAll + // @BeforeAll protected static void initXrplEnvironment() { xrplEnvironment = new CustomEnvironment( HttpUrl.parse("http://amm.devnet.rippletest.net:51234"), @@ -59,7 +67,7 @@ protected static void initXrplEnvironment() { ); } - @Test + // @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { Wallet issuerWallet = createRandomAccount(); AmmInfoResult amm = createAmm(issuerWallet); @@ -114,7 +122,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); } - @Test + // @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { Wallet issuerWallet = createRandomAccount(); AmmInfoResult amm = createAmm(issuerWallet); @@ -182,7 +190,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.classicAddress()); } - @Test + // @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { Wallet issuerWallet = createRandomAccount(); AmmInfoResult amm = createAmm(issuerWallet); diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java index a03edc18b..de1447cbb 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/NfTokenIT.java @@ -35,14 +35,6 @@ */ public class NfTokenIT extends AbstractIT { - @BeforeAll - protected static void initXrplEnvironment() { - xrplEnvironment = new CustomEnvironment( - HttpUrl.parse("http://xls20-sandbox.rippletest.net:51234"), - HttpUrl.parse("https://faucet-nft.ripple.com") - ); - } - @Test void mint() throws JsonRpcClientErrorException { Wallet wallet = createRandomAccount(); diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java index c365c884d..bc55a97a3 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java @@ -9,9 +9,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -109,6 +109,7 @@ public RippledContainer start(int acceptIntervalMillis) { } started = true; rippledContainer.start(); + // rippled is run in standalone mode which means that ledgers won't automatically close. You have to manually // advance the ledger using the "ledger_accept" method on the admin API. To mimic the behavior of a networked // rippled, run a scheduled task to trigger the "ledger_accept" method. diff --git a/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg b/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg index aa8a1596e..4efea4828 100644 --- a/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg +++ b/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg @@ -385,7 +385,7 @@ # # [ips] # 192.168.0.1 -# 192.168.0.1 2459 +# 192.168.0.1 2459 # r.ripple.com 51235 # # @@ -1275,3 +1275,6 @@ validators.txt account_reserve = 20000000 # 20 XRP owner_reserve = 5000000 # 5 XRP reference_fee = 10 # 10 drops + +[features] +NonFungibleTokensV1_1 From 1c8f5d797814b8dfcf8621630fb816be473c90d7 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 14:33:35 -0500 Subject: [PATCH 19/53] peg ubuntu version to 20.04 so build works --- .github/workflows/workflow.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index af0344cb4..3cee295a5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -6,7 +6,7 @@ on: types: [assigned] jobs: build_java8: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: # Checks-out the repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 @@ -29,7 +29,7 @@ jobs: uses: codecov/codecov-action@v1.0.15 build_android: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: # Checks-out the repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 @@ -48,7 +48,7 @@ jobs: run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -Pandroid build_other_java: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: # test against each major Java version @@ -73,7 +73,7 @@ jobs: run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true build_open_jdk_non_us: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 # Set up Adopt OpenJDK Hotspot 16 @@ -95,7 +95,7 @@ jobs: run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -DargLine="-Duser.language=de -Duser.country=DE" build_devnet_its: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: # Checks-out the repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 @@ -116,7 +116,7 @@ jobs: run: mvn dependency:go-offline install -Dmaven.javadoc.skip=true -DuseDevnet build_testnet_its: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: # Checks-out the repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 From 06be5dfac8cddf323c7a149872e6a0a8105aa9e2 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 16:48:01 -0500 Subject: [PATCH 20/53] improve test coverage --- .../org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index b52bf6361..36e07759e 100644 --- a/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-model/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -45,7 +45,6 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { .value("11080.00072727936") .build() ) - .asset2Frozen(false) .auctionSlot( AmmInfoAuctionSlot.builder() .account(Address.of("rM7xXGzMUALmEhQ2y9FW5XG69WXwQ6xtDC")) @@ -93,7 +92,6 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { ) .ledgerCurrentIndex(LedgerIndex.of(UnsignedInteger.valueOf(102))) .status("success") - .validated(false) .build(); String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + @@ -130,6 +128,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { assertThat(result.ledgerCurrentIndexSafe()).isEqualTo(result.ledgerCurrentIndex().get()); assertThatThrownBy(result::ledgerIndexSafe).isInstanceOf(IllegalStateException.class); + assertThatThrownBy(result::ledgerHashSafe).isInstanceOf(IllegalStateException.class); } @Test @@ -232,6 +231,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException assertCanSerializeAndDeserialize(result, json); assertThat(result.ledgerIndexSafe()).isEqualTo(result.ledgerIndex().get()); + assertThat(result.ledgerHashSafe()).isEqualTo(result.ledgerHash().get()); assertThatThrownBy(result::ledgerCurrentIndexSafe).isInstanceOf(IllegalStateException.class); } } \ No newline at end of file From d7c181f99489af94e864cd2dc847ce0ef6a5b099 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Thu, 19 Jan 2023 18:04:37 -0500 Subject: [PATCH 21/53] add log --- .../src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index 137ff140d..5f391c730 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -190,6 +190,7 @@ protected AccountObjectsResult getValidatedAccountObjects(Address classicAddress .build(); return xrplClient.accountObjects(params); } catch (JsonRpcClientErrorException e) { + logger.error("Error occurred getting account objects: {}", e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } } From 1c40e12dd14eb35ad49a870318cb3101e6807b3f Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 20 Jan 2023 10:07:22 -0500 Subject: [PATCH 22/53] add log --- .../src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index 5f391c730..d143facd5 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -232,6 +232,7 @@ protected AccountInfoResult getValidatedAccountInfo(Address classicAddress) { .build(); return xrplClient.accountInfo(params); } catch (Exception e) { + logger.error("Error occurred while getting account info for {}: {}", classicAddress, e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } } From 043b53cdc1ac2bd7e56521a87afd08705f96fb5c Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 20 Jan 2023 11:13:05 -0500 Subject: [PATCH 23/53] remove logs and increase finishAfter time so we don't get tec_NO_PERMISSIONs --- .../src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java | 2 -- .../src/test/java/org/xrpl/xrpl4j/tests/EscrowIT.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index d143facd5..137ff140d 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -190,7 +190,6 @@ protected AccountObjectsResult getValidatedAccountObjects(Address classicAddress .build(); return xrplClient.accountObjects(params); } catch (JsonRpcClientErrorException e) { - logger.error("Error occurred getting account objects: {}", e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } } @@ -232,7 +231,6 @@ protected AccountInfoResult getValidatedAccountInfo(Address classicAddress) { .build(); return xrplClient.accountInfo(params); } catch (Exception e) { - logger.error("Error occurred while getting account info for {}: {}", classicAddress, e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } } diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/EscrowIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/EscrowIT.java index 0208a04a9..09910fdd4 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/EscrowIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/EscrowIT.java @@ -177,8 +177,8 @@ public void createAndCancelTimeBasedEscrow() throws JsonRpcClientErrorException .fee(XrpCurrencyAmount.ofXrp(new BigDecimal(1))) .amount(XrpCurrencyAmount.ofDrops(123456)) .destination(receiverWallet.classicAddress()) - .cancelAfter(instantToXrpTimestamp(getMinExpirationTime().plus(Duration.ofSeconds(5)))) - .finishAfter(instantToXrpTimestamp(getMinExpirationTime().plus(Duration.ofSeconds(1)))) + .cancelAfter(instantToXrpTimestamp(getMinExpirationTime().plus(Duration.ofSeconds(10)))) + .finishAfter(instantToXrpTimestamp(getMinExpirationTime().plus(Duration.ofSeconds(5)))) .signingPublicKey(senderWallet.publicKey()) .build(); From 2f02504bdbb29fc8793467332e81062c180c7c0f Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Fri, 20 Jan 2023 11:40:11 -0500 Subject: [PATCH 24/53] fix PaymentChannelIT flaky test --- .../src/test/java/org/xrpl/xrpl4j/tests/PaymentChannelIT.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/PaymentChannelIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/PaymentChannelIT.java index 664f0b8ed..c464d2dde 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/PaymentChannelIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/PaymentChannelIT.java @@ -133,8 +133,7 @@ public void createPaymentChannel() throws JsonRpcClientErrorException { // Validate that the amount of the payment channel was deducted from the source // accounts XRP balance AccountInfoResult senderAccountInfoAfterCreate = this.scanForResult( - () -> this.getValidatedAccountInfo(sourceWallet.classicAddress()), - accountInfo -> accountInfo.ledgerIndexSafe().equals(senderAccountInfo.ledgerIndexSafe().plus(UnsignedInteger.ONE)) + () -> this.getValidatedAccountInfo(sourceWallet.classicAddress()) ); assertThat(senderAccountInfoAfterCreate.accountData().balance()) From 93e7f83c6ba3783fc048478828f9a64626dd2498 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 30 Jan 2023 17:03:34 -0500 Subject: [PATCH 25/53] fix build --- .../xrpl4j/model/flags/AccountRootFlags.java | 14 ++ .../xrpl4j/model/flags/AmmDepositFlags.java | 88 ++++++++- .../xrpl4j/model/flags/AmmWithdrawFlags.java | 111 +++++++++++- .../xrpl4j/model/transactions/AmmBid.java | 10 +- .../xrpl4j/model/transactions/AmmCreate.java | 10 +- .../xrpl4j/model/transactions/AmmDeposit.java | 17 +- .../xrpl4j/model/transactions/AmmVote.java | 10 +- .../model/transactions/AmmWithdraw.java | 7 +- .../model/transactions/AmmDepositTest.java | 21 +-- .../model/transactions/AmmWithdrawTest.java | 85 ++++----- .../org/xrpl/xrpl4j/tests/AbstractIT.java | 6 +- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 167 ++++++++---------- 12 files changed, 372 insertions(+), 174 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java index b4e6f8cb1..1bea9d065 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java @@ -77,6 +77,11 @@ public class AccountRootFlags extends Flags { */ public static final AccountRootFlags REQUIRE_DEST_TAG = new AccountRootFlags(0x00020000); + /** + * Constant {@link AccountRootFlags} for the {@code lsfAMM} account flag. + */ + public static final AccountRootFlags AMM = new AccountRootFlags(0x02000000); + /** * Required-args Constructor. * @@ -179,4 +184,13 @@ public boolean lsfRequireAuth() { public boolean lsfRequireDestTag() { return this.isSet(AccountRootFlags.REQUIRE_DEST_TAG); } + + /** + * This account is an Automated Market Maker instance. + * + * @return {@code true} if {@code lsfAMM} is set, otherwise {@code false}. + */ + public boolean lsfAmm() { + return this.isSet(AccountRootFlags.AMM); + } } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java index 97ffad6ed..75044ea53 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java @@ -1,2 +1,86 @@ -package org.xrpl.xrpl4j.model.flags;public class AmmDepositFlags { -} +package org.xrpl.xrpl4j.model.flags; + +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; + +/** + * A set of {@link TransactionFlags} that can be set on {@link AmmDeposit} transactions. Exactly + * one flag must be set on each {@link AmmDeposit} transaction, so this class does not allow for combination + * of multiple flags. + */ +public class AmmDepositFlags extends TransactionFlags { + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLPToken} flag. + */ + public static final AmmDepositFlags LP_TOKEN = new AmmDepositFlags(0x00010000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfSingleAsset} flag. + */ + public static final AmmDepositFlags SINGLE_ASSET = new AmmDepositFlags(0x00080000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfTwoAsset} flag. + */ + public static final AmmDepositFlags TWO_ASSET = new AmmDepositFlags(0x00100000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfOneAssetLPToken} flag. + */ + public static final AmmDepositFlags ONE_ASSET_LP_TOKEN = new AmmDepositFlags(0x00200000); + + /** + * Constant {@link AmmDepositFlags} for the {@code tfLimitLPToken} flag. + */ + public static final AmmDepositFlags LIMIT_LP_TOKEN = new AmmDepositFlags(0x00400000); + + private AmmDepositFlags(long value) { + super(value); + } + + /** + * Whether the {@code tfLPToken} flag is set. + * + * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. + */ + public boolean tfLpToken() { + return this.isSet(LP_TOKEN); + } + + /** + * Whether the {@code tfSingleAsset} flag is set. + * + * @return {@code true} if {@code tfSingleAsset} is set, otherwise {@code false}. + */ + public boolean tfSingleAsset() { + return this.isSet(SINGLE_ASSET); + } + + /** + * Whether the {@code tfTwoAsset} flag is set. + * + * @return {@code true} if {@code tfTwoAsset} is set, otherwise {@code false}. + */ + public boolean tfTwoAsset() { + return this.isSet(TWO_ASSET); + } + + /** + * Whether the {@code tfOneAssetLPToken} flag is set. + * + * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. + */ + public boolean tfOneAssetLpToken() { + return this.isSet(ONE_ASSET_LP_TOKEN); + } + + /** + * Whether the {@code tfLimitLPToken} flag is set. + * + * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. + */ + public boolean tfLimitLpToken() { + return this.isSet(LIMIT_LP_TOKEN); + } + +} \ No newline at end of file diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java index 5a902d953..9ea9ec4ae 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java @@ -1,2 +1,111 @@ -package org.xrpl.xrpl4j.model.flags;public class AmmWithdrawFlags { +package org.xrpl.xrpl4j.model.flags; + +/** + * A set of {@link TransactionFlags} that can be set on {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} + * transactions. Exactly one flag must be set on each {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} + * transaction, so this class does not allow for combination of multiple flags. + */ +public class AmmWithdrawFlags extends TransactionFlags { + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfLPToken} flag. + */ + public static final AmmWithdrawFlags LP_TOKEN = new AmmWithdrawFlags(0x00010000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfWithdrawAll} flag. + */ + public static final AmmWithdrawFlags WITHDRAW_ALL = new AmmWithdrawFlags(0x00020000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfOneAssetWithdrawAll} flag. + */ + public static final AmmWithdrawFlags ONE_ASSET_WITHDRAW_ALL = new AmmWithdrawFlags(0x00040000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfSingleAsset} flag. + */ + public static final AmmWithdrawFlags SINGLE_ASSET = new AmmWithdrawFlags(0x00080000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfTwoAsset} flag. + */ + public static final AmmWithdrawFlags TWO_ASSET = new AmmWithdrawFlags(0x00100000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfOneAssetLPToken} flag. + */ + public static final AmmWithdrawFlags ONE_ASSET_LP_TOKEN = new AmmWithdrawFlags(0x00200000); + + /** + * Constant {@link AmmWithdrawFlags} for the {@code tfLimitLPToken} flag. + */ + public static final AmmWithdrawFlags LIMIT_LP_TOKEN = new AmmWithdrawFlags(0x00400000); + + private AmmWithdrawFlags(long value) { + super(value); + } + + /** + * Whether the {@code tfLPToken} flag is set. + * + * @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. + */ + public boolean tfLpToken() { + return this.isSet(LP_TOKEN); + } + + /** + * Whether the {@code tfWithdrawAll} flag is set. + * + * @return {@code true} if {@code tfWithdrawAll} is set, otherwise {@code false}. + */ + public boolean tfWithdrawAll() { + return this.isSet(WITHDRAW_ALL); + } + + /** + * Whether the {@code tfOneAssetWithdrawAll} flag is set. + * + * @return {@code true} if {@code tfOneAssetWithdrawAll} is set, otherwise {@code false}. + */ + public boolean tfOneAssetWithdrawAll() { + return this.isSet(ONE_ASSET_WITHDRAW_ALL); + } + + /** + * Whether the {@code tfSingleAsset} flag is set. + * + * @return {@code true} if {@code tfSingleAsset} is set, otherwise {@code false}. + */ + public boolean tfSingleAsset() { + return this.isSet(SINGLE_ASSET); + } + + /** + * Whether the {@code tfTwoAsset} flag is set. + * + * @return {@code true} if {@code tfTwoAsset} is set, otherwise {@code false}. + */ + public boolean tfTwoAsset() { + return this.isSet(TWO_ASSET); + } + + /** + * Whether the {@code tfOneAssetLPToken} flag is set. + * + * @return {@code true} if {@code tfOneAssetLPToken} is set, otherwise {@code false}. + */ + public boolean tfOneAssetLpToken() { + return this.isSet(ONE_ASSET_LP_TOKEN); + } + + /** + * Whether the {@code tfLimitLPToken} flag is set. + * + * @return {@code true} if {@code tfLimitLPToken} is set, otherwise {@code false}. + */ + public boolean tfLimitLpToken() { + return this.isSet(LIMIT_LP_TOKEN); + } } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index 56521c93c..da4f3ed1a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.Asset; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; @@ -29,18 +30,17 @@ static ImmutableAmmBid.Builder builder() { } /** - * Set of {@link Flags.TransactionFlags}s for this {@link AmmBid}, which only allows the - * {@code tfFullyCanonicalSig} flag. + * Set of {@link TransactionFlags}s for this {@link AmmBid}. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. */ @JsonProperty("Flags") @Value.Derived - default Flags.TransactionFlags flags() { - return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + default TransactionFlags flags() { + return new TransactionFlags.Builder().build(); } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java index 84b6ca045..02acec071 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; /** * Object mapping for the AMMCreate transaction. @@ -24,18 +25,17 @@ static ImmutableAmmCreate.Builder builder() { } /** - * Set of {@link Flags.TransactionFlags}s for this {@link AmmCreate}, which only allows the - * {@code tfFullyCanonicalSig} flag. + * Set of {@link TransactionFlags}s for this {@link AmmCreate}. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. */ @JsonProperty("Flags") @Value.Derived - default Flags.TransactionFlags flags() { - return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + default TransactionFlags flags() { + return new TransactionFlags.Builder().build(); } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index 7fe41a5fc..7eb1c6d9a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.Asset; @@ -27,29 +28,29 @@ static ImmutableAmmDeposit.Builder builder() { } /** - * A {@link Flags.AmmDepositFlags} for this transaction. This flag will always be derived from the presence + * A {@link AmmDepositFlags} for this transaction. This flag will always be derived from the presence * of {@link #lpTokenOut()}, {@link #amount()}, {@link #amount2()} and {@link #effectivePrice()}. * - * @return A {@link Flags.AmmDepositFlags} for this transaction. + * @return A {@link AmmDepositFlags} for this transaction. */ @JsonProperty("Flags") @Value.Derived - default Flags.AmmDepositFlags flags() { + default AmmDepositFlags flags() { boolean lpTokenPresent = lpTokenOut().isPresent(); boolean amountPresent = amount().isPresent(); boolean amount2Present = amount2().isPresent(); boolean effectivePricePresent = effectivePrice().isPresent(); if (lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent) { - return Flags.AmmDepositFlags.LP_TOKEN; + return AmmDepositFlags.LP_TOKEN; } else if (!lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent) { - return Flags.AmmDepositFlags.TWO_ASSET; + return AmmDepositFlags.TWO_ASSET; } else if (!lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { - return Flags.AmmDepositFlags.SINGLE_ASSET; + return AmmDepositFlags.SINGLE_ASSET; } else if (lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { - return Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN; + return AmmDepositFlags.ONE_ASSET_LP_TOKEN; } else if (!lpTokenPresent && amountPresent && !amount2Present) { - return Flags.AmmDepositFlags.LIMIT_LP_TOKEN; + return AmmDepositFlags.LIMIT_LP_TOKEN; } else { throw new IllegalStateException("Correct AmmDepositFlag could not be determined based on set fields."); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java index 591b01fa2..887ae9a89 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.Asset; /** @@ -25,18 +26,17 @@ static ImmutableAmmVote.Builder builder() { } /** - * Set of {@link Flags.TransactionFlags}s for this {@link AmmVote}, which only allows the - * {@code tfFullyCanonicalSig} flag. + * Set of {@link TransactionFlags}s for this {@link AmmVote}. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link Flags.TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. */ @JsonProperty("Flags") @Value.Derived - default Flags.TransactionFlags flags() { - return new Flags.TransactionFlags.Builder().tfFullyCanonicalSig(true).build(); + default TransactionFlags flags() { + return new TransactionFlags.Builder().build(); } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java index 444565e4c..d91d1315c 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import org.immutables.value.Value; +import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.Asset; @@ -25,12 +26,12 @@ static ImmutableAmmWithdraw.Builder builder() { } /** - * A {@link Flags.AmmWithdrawFlags} for this transaction. + * A {@link AmmWithdrawFlags} for this transaction. * - * @return A {@link Flags.AmmWithdrawFlags} for this transaction. + * @return A {@link AmmWithdrawFlags} for this transaction. */ @JsonProperty("Flags") - Flags.AmmWithdrawFlags flags(); + AmmWithdrawFlags flags(); /** * The definition for one of the assets in the AMM's pool. diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index c763ec80a..c85715f78 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -10,6 +10,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.Asset; @@ -39,7 +40,7 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx .build() ).build(); - assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.LP_TOKEN); + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.LP_TOKEN); String json = "{\n" + " \"Account\" : \"" + deposit.account() + "\",\n" + @@ -56,7 +57,7 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx " \"currency\" : \"XRP\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmDepositFlags.LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmDepositFlags.LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -86,7 +87,7 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE .amount2(XrpCurrencyAmount.ofDrops(10)) .build(); - assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.TWO_ASSET); + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.TWO_ASSET); String json = "{\n" + " \"Account\" : \"" + deposit.account() + "\",\n" + @@ -104,7 +105,7 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE " \"currency\" : \"XRP\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmDepositFlags.TWO_ASSET + ",\n" + + " \"Flags\" : " + AmmDepositFlags.TWO_ASSET + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -133,7 +134,7 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi ) .build(); - assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.SINGLE_ASSET); + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.SINGLE_ASSET); String json = "{\n" + " \"Account\" : \"" + deposit.account() + "\",\n" + @@ -150,7 +151,7 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi " \"currency\" : \"XRP\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmDepositFlags.SINGLE_ASSET + ",\n" + + " \"Flags\" : " + AmmDepositFlags.SINGLE_ASSET + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -186,7 +187,7 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc ) .build(); - assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN); + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.ONE_ASSET_LP_TOKEN); String json = "{\n" + " \"Account\" : \"" + deposit.account() + "\",\n" + @@ -208,7 +209,7 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc " \"currency\" : \"XRP\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmDepositFlags.ONE_ASSET_LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmDepositFlags.ONE_ASSET_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -238,7 +239,7 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess .effectivePrice(XrpCurrencyAmount.ofDrops(10)) .build(); - assertThat(deposit.flags()).isEqualTo(Flags.AmmDepositFlags.LIMIT_LP_TOKEN); + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.LIMIT_LP_TOKEN); String json = "{\n" + " \"Account\" : \"" + deposit.account() + "\",\n" + @@ -256,7 +257,7 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess " \"currency\" : \"XRP\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmDepositFlags.LIMIT_LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmDepositFlags.LIMIT_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index 259562ce1..8f810af41 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -6,6 +6,7 @@ import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.ledger.Asset; @@ -14,7 +15,7 @@ class AmmWithdrawTest extends AbstractJsonTest { @Test void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) .build(); @@ -24,7 +25,7 @@ void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingE " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -35,7 +36,7 @@ void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingE @Test void constructWithdrawAllAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) .build(); String json = "{\n" + @@ -43,7 +44,7 @@ void constructWithdrawAllAndTestJson() throws JSONException, JsonProcessingExcep " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.WITHDRAW_ALL + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.WITHDRAW_ALL + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -54,7 +55,7 @@ void constructWithdrawAllAndTestJson() throws JSONException, JsonProcessingExcep @Test void constructTwoAssetAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .flags(AmmWithdrawFlags.TWO_ASSET) .amount(amount()) .amount2(XrpCurrencyAmount.ofDrops(50000000)) .build(); @@ -70,7 +71,7 @@ void constructTwoAssetAndTestJson() throws JSONException, JsonProcessingExceptio " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.TWO_ASSET + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.TWO_ASSET + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -81,7 +82,7 @@ void constructTwoAssetAndTestJson() throws JSONException, JsonProcessingExceptio @Test void constructSingleAssetAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .amount(amount()) .build(); @@ -95,7 +96,7 @@ void constructSingleAssetAndTestJson() throws JSONException, JsonProcessingExcep " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.SINGLE_ASSET + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.SINGLE_ASSET + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -106,7 +107,7 @@ void constructSingleAssetAndTestJson() throws JSONException, JsonProcessingExcep @Test void constructOneAssetWithdrawAllAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) .amount(amount()) .build(); @@ -120,7 +121,7 @@ void constructOneAssetWithdrawAllAndTestJson() throws JSONException, JsonProcess " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -131,7 +132,7 @@ void constructOneAssetWithdrawAllAndTestJson() throws JSONException, JsonProcess @Test void constructOneAssetLpTokenAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) .amount(amount()) .lpTokensIn(lpTokensIn()) .build(); @@ -147,7 +148,7 @@ void constructOneAssetLpTokenAndTestJson() throws JSONException, JsonProcessingE " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.ONE_ASSET_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -158,7 +159,7 @@ void constructOneAssetLpTokenAndTestJson() throws JSONException, JsonProcessingE @Test void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingException { AmmWithdraw withdraw = baseBuilder() - .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) .amount(amount()) .effectivePrice(amount()) .build(); @@ -174,7 +175,7 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce " \"Asset\" : " + objectMapper.writeValueAsString(withdraw.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(withdraw.asset2()) + "," + " \"Fee\" : \"10\",\n" + - " \"Flags\" : " + Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN + ",\n" + + " \"Flags\" : " + AmmWithdrawFlags.LIMIT_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -186,14 +187,14 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce void constructLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .flags(AmmWithdrawFlags.LP_TOKEN) .build() ).isInstanceOf(IllegalStateException.class) .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) .amount(amount()) .build() @@ -202,7 +203,7 @@ void constructLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) .amount2(amount()) .build() @@ -211,7 +212,7 @@ void constructLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LP_TOKEN) + .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) .effectivePrice(amount()) .build() @@ -223,7 +224,7 @@ void constructLpTokenWithWrongFieldsPresent() { void constructWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) .lpTokensIn(lpTokensIn()) .build() ).isInstanceOf(IllegalStateException.class) @@ -231,7 +232,7 @@ void constructWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) .amount(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -239,7 +240,7 @@ void constructWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) .amount2(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -247,7 +248,7 @@ void constructWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.WITHDRAW_ALL) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) .effectivePrice(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -258,7 +259,7 @@ void constructWithdrawAllWithWrongFieldsPresent() { void constructTwoAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .flags(AmmWithdrawFlags.TWO_ASSET) .lpTokensIn(lpTokensIn()) .amount(amount()) .amount2(amount()) @@ -268,7 +269,7 @@ void constructTwoAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .flags(AmmWithdrawFlags.TWO_ASSET) .amount(amount()) .amount2(amount()) .effectivePrice(amount()) @@ -278,7 +279,7 @@ void constructTwoAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .flags(AmmWithdrawFlags.TWO_ASSET) .amount2(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -286,7 +287,7 @@ void constructTwoAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.TWO_ASSET) + .flags(AmmWithdrawFlags.TWO_ASSET) .amount(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -297,7 +298,7 @@ void constructTwoAssetWithWrongFieldsPresent() { void constructSingleAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .amount(amount()) .lpTokensIn(lpTokensIn()) .build() @@ -307,7 +308,7 @@ void constructSingleAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .amount(amount()) .amount2(amount()) .build() @@ -317,7 +318,7 @@ void constructSingleAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .amount(amount()) .effectivePrice(amount()) .build() @@ -327,7 +328,7 @@ void constructSingleAssetWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .build() ).isInstanceOf(IllegalStateException.class) .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + @@ -338,7 +339,7 @@ void constructSingleAssetWithWrongFieldsPresent() { void constructOneAssetWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) .amount(amount()) .lpTokensIn(lpTokensIn()) .build() @@ -348,7 +349,7 @@ void constructOneAssetWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) .amount(amount()) .amount2(amount()) .build() @@ -358,7 +359,7 @@ void constructOneAssetWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) .amount(amount()) .effectivePrice(amount()) .build() @@ -368,7 +369,7 @@ void constructOneAssetWithdrawAllWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) + .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) .build() ).isInstanceOf(IllegalStateException.class) .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + @@ -379,7 +380,7 @@ void constructOneAssetWithdrawAllWithWrongFieldsPresent() { void constructOneAssetLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) .lpTokensIn(lpTokensIn()) .amount(amount()) .amount2(amount()) @@ -389,7 +390,7 @@ void constructOneAssetLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) .lpTokensIn(lpTokensIn()) .amount(amount()) .effectivePrice(amount()) @@ -399,7 +400,7 @@ void constructOneAssetLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) .amount(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -407,7 +408,7 @@ void constructOneAssetLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) + .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) .lpTokensIn(lpTokensIn()) .build() ).isInstanceOf(IllegalStateException.class) @@ -418,7 +419,7 @@ void constructOneAssetLpTokenWithWrongFieldsPresent() { void constructLimitLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) .lpTokensIn(lpTokensIn()) .amount(amount()) .effectivePrice(amount()) @@ -428,7 +429,7 @@ void constructLimitLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) .amount(amount()) .amount2(amount()) .effectivePrice(amount()) @@ -438,7 +439,7 @@ void constructLimitLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) .amount(amount()) .build() ).isInstanceOf(IllegalStateException.class) @@ -446,7 +447,7 @@ void constructLimitLpTokenWithWrongFieldsPresent() { assertThatThrownBy( () -> baseBuilder() - .flags(Flags.AmmWithdrawFlags.LIMIT_LP_TOKEN) + .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) .effectivePrice(amount()) .build() ).isInstanceOf(IllegalStateException.class) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index 2d1f7a314..53307bcba 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -26,16 +26,14 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.core.Is.is; -import com.google.common.primitives.UnsignedInteger; import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; import com.google.common.primitives.UnsignedLong; import org.awaitility.Durations; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.client.XrplClient; -import org.xrpl.xrpl4j.model.client.Finality; -import org.xrpl.xrpl4j.model.client.FinalityStatus; import org.xrpl.xrpl4j.codec.addresses.KeyType; import org.xrpl.xrpl4j.crypto.JavaKeystoreLoader; import org.xrpl.xrpl4j.crypto.ServerSecret; @@ -48,6 +46,8 @@ import org.xrpl.xrpl4j.crypto.signing.SingleSignedTransaction; import org.xrpl.xrpl4j.crypto.signing.bc.BcDerivedKeySignatureService; import org.xrpl.xrpl4j.crypto.signing.bc.BcSignatureService; +import org.xrpl.xrpl4j.model.client.Finality; +import org.xrpl.xrpl4j.model.client.FinalityStatus; import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsRequestParams; import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsResult; diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 7f5a18454..9a0f4650f 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -7,15 +7,11 @@ import com.google.common.io.BaseEncoding; import com.google.common.primitives.UnsignedInteger; import okhttp3.HttpUrl; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; -import org.xrpl.xrpl4j.crypto.KeyMetadata; -import org.xrpl.xrpl4j.crypto.PrivateKey; +import org.xrpl.xrpl4j.crypto.keys.KeyPair; +import org.xrpl.xrpl4j.crypto.keys.PrivateKey; import org.xrpl.xrpl4j.crypto.signing.SignatureService; -import org.xrpl.xrpl4j.crypto.signing.SignedTransaction; -import org.xrpl.xrpl4j.crypto.signing.SingleKeySignatureService; +import org.xrpl.xrpl4j.crypto.signing.SingleSignedTransaction; import org.xrpl.xrpl4j.model.client.accounts.AccountInfoRequestParams; import org.xrpl.xrpl4j.model.client.accounts.AccountInfoResult; import org.xrpl.xrpl4j.model.client.accounts.AccountLinesRequestParams; @@ -27,11 +23,10 @@ import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; -import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.ledger.Asset; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; -import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; @@ -39,14 +34,11 @@ import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; -import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; import org.xrpl.xrpl4j.tests.environment.CustomEnvironment; -import org.xrpl.xrpl4j.wallet.Wallet; import java.math.BigDecimal; -import java.util.Optional; /** * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and @@ -69,19 +61,18 @@ protected static void initXrplEnvironment() { // @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { - Wallet issuerWallet = createRandomAccount(); - AmmInfoResult amm = createAmm(issuerWallet); - Wallet traderWallet = createRandomAccount(); + KeyPair issuerKeyPair = createRandomAccountEd25519(); + AmmInfoResult amm = createAmm(issuerKeyPair); + KeyPair traderKeyPair = createRandomAccountEd25519(); FeeResult feeResult = xrplClient.fee(); - AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); - SingleKeySignatureService signatureService = new SingleKeySignatureService( - PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + AccountInfoResult traderAccount = scanForResult( + () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); AccountInfoResult traderAccountAfterDeposit = depositXrp( - issuerWallet, - traderWallet, + issuerKeyPair, + traderKeyPair, traderAccount, amm, signatureService, @@ -94,50 +85,49 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces .sequence(traderAccountAfterDeposit.accountData().sequence()) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) - .signingPublicKey(traderWallet.publicKey()) + .signingPublicKey(traderKeyPair.publicKey()) .asset2( Asset.builder() .currency(xrpl4jCoin) - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) .asset(Asset.XRP) .tradingFee(newTradingFee) .build(); - SignedTransaction signedVote = signatureService.sign(KeyMetadata.EMPTY, ammVote); + SingleSignedTransaction signedVote = signatureService.sign(traderKeyPair.privateKey(), ammVote); - SubmitResult voteSubmitResult = xrplClient.submit(signedVote); - assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + SubmitResult voteSubmitResult = xrplClient.submit(signedVote); + assertThat(voteSubmitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); scanForFinality( signedVote.hash(), traderAccount.ledgerIndexSafe(), ammVote.lastLedgerSequence().get(), ammVote.sequence(), - traderWallet.classicAddress() + traderKeyPair.publicKey().deriveAddress() ); - AmmInfoResult ammAfterVote = getAmmInfo(issuerWallet); + AmmInfoResult ammAfterVote = getAmmInfo(issuerKeyPair); assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); } // @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { - Wallet issuerWallet = createRandomAccount(); - AmmInfoResult amm = createAmm(issuerWallet); - Wallet traderWallet = createRandomAccount(); - Wallet authAccount1 = createRandomAccount(); + KeyPair issuerKeyPair = createRandomAccountEd25519(); + AmmInfoResult amm = createAmm(issuerKeyPair); + KeyPair traderKeyPair = createRandomAccountEd25519(); + KeyPair authAccount1 = createRandomAccountEd25519(); FeeResult feeResult = xrplClient.fee(); - AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); - SingleKeySignatureService signatureService = new SingleKeySignatureService( - PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + AccountInfoResult traderAccount = scanForResult( + () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); - + AccountInfoResult traderAccountAfterDeposit = depositXrp( - issuerWallet, - traderWallet, + issuerKeyPair, + traderKeyPair, traderAccount, amm, signatureService, @@ -149,16 +139,16 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .sequence(traderAccountAfterDeposit.accountData().sequence()) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) - .signingPublicKey(traderWallet.publicKey()) + .signingPublicKey(traderKeyPair.publicKey()) .asset2( Asset.builder() .currency(xrpl4jCoin) - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) .asset(Asset.XRP) .addAuthAccounts( - AuthAccountWrapper.of(AuthAccount.of(authAccount1.classicAddress())) + AuthAccountWrapper.of(AuthAccount.of(authAccount1.publicKey().deriveAddress())) ) .bidMin( IssuedCurrencyAmount.builder() @@ -168,89 +158,88 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException ) .build(); - SignedTransaction signedBid = signatureService.sign(KeyMetadata.EMPTY, bid); + SingleSignedTransaction signedBid = signatureService.sign(traderKeyPair.privateKey(), bid); - SubmitResult voteSubmitResult = xrplClient.submit(signedBid); - assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + SubmitResult voteSubmitResult = xrplClient.submit(signedBid); + assertThat(voteSubmitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); scanForFinality( signedBid.hash(), traderAccount.ledgerIndexSafe(), bid.lastLedgerSequence().get(), bid.sequence(), - traderWallet.classicAddress() + traderKeyPair.publicKey().deriveAddress() ); - AmmInfoResult ammAfterBid = getAmmInfo(issuerWallet); + AmmInfoResult ammAfterBid = getAmmInfo(issuerKeyPair); assertThat(ammAfterBid.amm().auctionSlot()).isNotEmpty(); AmmInfoAuctionSlot auctionSlot = ammAfterBid.amm().auctionSlot().get(); assertThat(auctionSlot.account()).isEqualTo(traderAccount.accountData().account()); assertThat(auctionSlot.authAccounts()).asList().extracting("account") - .containsExactly(authAccount1.classicAddress()); + .containsExactly(authAccount1.publicKey().deriveAddress()); } // @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { - Wallet issuerWallet = createRandomAccount(); - AmmInfoResult amm = createAmm(issuerWallet); - Wallet traderWallet = createRandomAccount(); + KeyPair issuerKeyPair = createRandomAccountEd25519(); + AmmInfoResult amm = createAmm(issuerKeyPair); + KeyPair traderKeyPair = createRandomAccountEd25519(); FeeResult feeResult = xrplClient.fee(); - AccountInfoResult traderAccount = scanForResult(() -> this.getValidatedAccountInfo(traderWallet.classicAddress())); - SingleKeySignatureService signatureService = new SingleKeySignatureService( - PrivateKey.fromBase16EncodedPrivateKey(traderWallet.privateKey().get()) + AccountInfoResult traderAccount = scanForResult( + () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); AccountInfoResult traderAccountAfterDeposit = depositXrp( - issuerWallet, - traderWallet, + issuerKeyPair, + traderKeyPair, traderAccount, amm, signatureService, feeResult ); - AmmInfoResult ammInfoAfterDeposit = getAmmInfo(issuerWallet); + AmmInfoResult ammInfoAfterDeposit = getAmmInfo(issuerKeyPair); AmmWithdraw withdraw = AmmWithdraw.builder() - .account(traderWallet.classicAddress()) + .account(traderKeyPair.publicKey().deriveAddress()) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .sequence(traderAccountAfterDeposit.accountData().sequence()) .lastLedgerSequence( traderAccountAfterDeposit.ledgerCurrentIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue() ) - .signingPublicKey(traderWallet.publicKey()) + .signingPublicKey(traderKeyPair.publicKey()) .asset2( Asset.builder() .currency(xrpl4jCoin) - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) .asset(Asset.XRP) .amount(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(90))) - .flags(Flags.AmmWithdrawFlags.SINGLE_ASSET) + .flags(AmmWithdrawFlags.SINGLE_ASSET) .build(); - SignedTransaction signedWithdraw = signatureService.sign(KeyMetadata.EMPTY, withdraw); + SingleSignedTransaction signedWithdraw = signatureService.sign(traderKeyPair.privateKey(), withdraw); - SubmitResult voteSubmitResult = xrplClient.submit(signedWithdraw); - assertThat(voteSubmitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + SubmitResult voteSubmitResult = xrplClient.submit(signedWithdraw); + assertThat(voteSubmitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); scanForFinality( signedWithdraw.hash(), traderAccount.ledgerIndexSafe(), withdraw.lastLedgerSequence().get(), withdraw.sequence(), - traderWallet.classicAddress() + traderKeyPair.publicKey().deriveAddress() ); - AmmInfoResult ammAfterWithdraw = getAmmInfo(issuerWallet); + AmmInfoResult ammAfterWithdraw = getAmmInfo(issuerKeyPair); assertThat(ammAfterWithdraw.amm().amount2()).isInstanceOf(XrpCurrencyAmount.class) .isEqualTo(((XrpCurrencyAmount) ammInfoAfterDeposit.amm().amount2()) .minus((XrpCurrencyAmount) withdraw.amount().get())); AccountInfoResult traderAccountAfterWithdraw = xrplClient.accountInfo( - AccountInfoRequestParams.of(traderWallet.classicAddress()) + AccountInfoRequestParams.of(traderKeyPair.publicKey().deriveAddress()) ); assertThat(traderAccountAfterWithdraw.accountData().balance()).isEqualTo( @@ -261,11 +250,11 @@ void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingExce } private AccountInfoResult depositXrp( - Wallet issuerWallet, - Wallet traderWallet, + KeyPair issuerKeyPair, + KeyPair traderKeyPair, AccountInfoResult traderAccount, AmmInfoResult amm, - SignatureService signatureService, + SignatureService signatureService, FeeResult feeResult ) throws JsonRpcClientErrorException, JsonProcessingException { XrpCurrencyAmount depositAmount = XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100)); @@ -274,27 +263,27 @@ private AccountInfoResult depositXrp( .asset2( Asset.builder() .currency(xrpl4jCoin) - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) .asset(Asset.XRP) .amount(depositAmount) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .sequence(traderAccount.accountData().sequence()) - .signingPublicKey(traderWallet.publicKey()) + .signingPublicKey(traderKeyPair.publicKey()) .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue()) .build(); - SignedTransaction signedDeposit = signatureService.sign(KeyMetadata.EMPTY, deposit); - SubmitResult submitResult = xrplClient.submit(signedDeposit); - assertThat(submitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + SingleSignedTransaction signedDeposit = signatureService.sign(traderKeyPair.privateKey(), deposit); + SubmitResult submitResult = xrplClient.submit(signedDeposit); + assertThat(submitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); scanForFinality( signedDeposit.hash(), traderAccount.ledgerIndexSafe(), deposit.lastLedgerSequence().get(), deposit.sequence(), - traderWallet.classicAddress() + traderKeyPair.publicKey().deriveAddress() ); AccountInfoResult traderAccountAfterDeposit = xrplClient.accountInfo( @@ -319,8 +308,10 @@ private AccountInfoResult depositXrp( return traderAccountAfterDeposit; } - private AmmInfoResult createAmm(Wallet issuerWallet) throws JsonRpcClientErrorException, JsonProcessingException { - AccountInfoResult issuerAccount = scanForResult(() -> this.getValidatedAccountInfo(issuerWallet.classicAddress())); + private AmmInfoResult createAmm(KeyPair issuerKeyPair) throws JsonRpcClientErrorException, JsonProcessingException { + AccountInfoResult issuerAccount = scanForResult( + () -> this.getValidatedAccountInfo(issuerKeyPair.publicKey().deriveAddress()) + ); XrpCurrencyAmount reserveAmount = xrplClient.serverInformation().info() .map( rippled -> rippled.closedLedger().orElse(rippled.validatedLedger().get()).reserveIncXrp(), @@ -328,12 +319,12 @@ private AmmInfoResult createAmm(Wallet issuerWallet) throws JsonRpcClientErrorEx reporting -> reporting.closedLedger().orElse(reporting.validatedLedger().get()).reserveIncXrp() ); AmmCreate ammCreate = AmmCreate.builder() - .account(issuerWallet.classicAddress()) + .account(issuerKeyPair.publicKey().deriveAddress()) .sequence(issuerAccount.accountData().sequence()) .fee(reserveAmount) .amount( IssuedCurrencyAmount.builder() - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .currency(xrpl4jCoin) .value("25") .build() @@ -341,34 +332,30 @@ private AmmInfoResult createAmm(Wallet issuerWallet) throws JsonRpcClientErrorEx .amount2(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(100))) .tradingFee(TradingFee.ofPercent(BigDecimal.ONE)) .lastLedgerSequence(issuerAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(4)).unsignedIntegerValue()) - .signingPublicKey(issuerWallet.publicKey()) + .signingPublicKey(issuerKeyPair.publicKey()) .build(); - SingleKeySignatureService signatureService = new SingleKeySignatureService( - PrivateKey.fromBase16EncodedPrivateKey(issuerWallet.privateKey().get()) - ); - - SignedTransaction signedCreate = signatureService.sign(KeyMetadata.EMPTY, ammCreate); - SubmitResult submitResult = xrplClient.submit(signedCreate); - assertThat(submitResult.result()).isEqualTo(TransactionResultCodes.TES_SUCCESS); + SingleSignedTransaction signedCreate = signatureService.sign(issuerKeyPair.privateKey(), ammCreate); + SubmitResult submitResult = xrplClient.submit(signedCreate); + assertThat(submitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); scanForFinality( signedCreate.hash(), issuerAccount.ledgerIndexSafe(), ammCreate.lastLedgerSequence().get(), ammCreate.sequence(), - issuerWallet.classicAddress() + issuerKeyPair.publicKey().deriveAddress() ); - return getAmmInfo(issuerWallet); + return getAmmInfo(issuerKeyPair); } - private AmmInfoResult getAmmInfo(Wallet issuerWallet) throws JsonRpcClientErrorException { + private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErrorException { return xrplClient.ammInfo( AmmInfoRequestParams.builder() .asset( Asset.builder() - .issuer(issuerWallet.classicAddress()) + .issuer(issuerKeyPair.publicKey().deriveAddress()) .currency(xrpl4jCoin) .build() ) From 3567ffe588dfb3f6ef8438e2348327c455054023 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 30 Jan 2023 17:41:16 -0500 Subject: [PATCH 26/53] fix tests and add AMM transactions to SignatureUtils --- .../xrpl4j/crypto/signing/SignatureUtils.java | 45 ++++ .../xrpl4j/model/transactions/Wrappers.java | 12 +- .../crypto/signing/SignatureUtilsTest.java | 222 ++++++++++++++++++ .../xrpl4j/model/transactions/AmmBidTest.java | 9 + .../model/transactions/AmmCreateTest.java | 5 + .../model/transactions/AmmDepositTest.java | 21 ++ .../model/transactions/AmmVoteTest.java | 5 + .../model/transactions/AmmWithdrawTest.java | 12 + .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 14 +- 9 files changed, 336 insertions(+), 9 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java index 37e2ec682..1122423e9 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java @@ -31,6 +31,11 @@ import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -271,6 +276,26 @@ public SingleSignedTransaction addSignatureToTransact transactionWithSignature = TicketCreate.builder().from((TicketCreate) transaction) .transactionSignature(signature.base16Value()) .build(); + } else if (AmmBid.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmBid.builder().from((AmmBid) transaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmCreate.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmCreate.builder().from((AmmCreate) transaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmDeposit.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmDeposit.builder().from((AmmDeposit) transaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmVote.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmVote.builder().from((AmmVote) transaction) + .transactionSignature(signature.base16Value()) + .build(); + } else if (AmmWithdraw.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmWithdraw.builder().from((AmmWithdraw) transaction) + .transactionSignature(signature.base16Value()) + .build(); } else { // Should never happen, but will in a unit test if we miss one. throw new IllegalArgumentException("Signing fields could not be added to the transaction."); @@ -405,6 +430,26 @@ public T addMultiSignaturesToTransaction(T transaction, transactionWithSignatures = TicketCreate.builder().from((TicketCreate) transaction) .signers(signers) .build(); + } else if (AmmBid.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmBid.builder().from((AmmBid) transaction) + .signers(signers) + .build(); + } else if (AmmCreate.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmCreate.builder().from((AmmCreate) transaction) + .signers(signers) + .build(); + } else if (AmmDeposit.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmDeposit.builder().from((AmmDeposit) transaction) + .signers(signers) + .build(); + } else if (AmmVote.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmVote.builder().from((AmmVote) transaction) + .signers(signers) + .build(); + } else if (AmmWithdraw.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmWithdraw.builder().from((AmmWithdraw) transaction) + .signers(signers) + .build(); } else { // Should never happen, but will in a unit test if we miss one. throw new IllegalArgumentException("Signing fields could not be added to the transaction."); diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index 264ad735e..53b1c9a86 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -40,8 +40,12 @@ import org.xrpl.xrpl4j.model.jackson.modules.NfTokenIdDeserializer; import org.xrpl.xrpl4j.model.jackson.modules.NfTokenIdSerializer; import org.xrpl.xrpl4j.model.jackson.modules.NfTokenUriSerializer; +import org.xrpl.xrpl4j.model.jackson.modules.TradingFeeDeserializer; +import org.xrpl.xrpl4j.model.jackson.modules.TradingFeeSerializer; import org.xrpl.xrpl4j.model.jackson.modules.TransferFeeDeserializer; import org.xrpl.xrpl4j.model.jackson.modules.TransferFeeSerializer; +import org.xrpl.xrpl4j.model.jackson.modules.VoteWeightDeserializer; +import org.xrpl.xrpl4j.model.jackson.modules.VoteWeightSerializer; import org.xrpl.xrpl4j.model.jackson.modules.XrpCurrencyAmountDeserializer; import org.xrpl.xrpl4j.model.jackson.modules.XrpCurrencyAmountSerializer; @@ -380,8 +384,8 @@ public void validateBounds() { */ @Value.Immutable @Wrapped - @JsonSerialize(as = TradingFee.class) - @JsonDeserialize(as = TradingFee.class) + @JsonSerialize(as = TradingFee.class, using = TradingFeeSerializer.class) + @JsonDeserialize(as = TradingFee.class, using = TradingFeeDeserializer.class) abstract static class _TradingFee extends Wrapper implements Serializable { @Override @@ -431,8 +435,8 @@ public void validateBounds() { */ @Value.Immutable @Wrapped - @JsonSerialize(as = VoteWeight.class) - @JsonDeserialize(as = VoteWeight.class) + @JsonSerialize(as = VoteWeight.class, using = VoteWeightSerializer.class) + @JsonDeserialize(as = VoteWeight.class, using = VoteWeightDeserializer.class) abstract static class _VoteWeight extends Wrapper implements Serializable { @Override diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index e11aa5f78..507e90cc2 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -50,9 +50,18 @@ import org.xrpl.xrpl4j.crypto.signing.SignatureUtils; import org.xrpl.xrpl4j.crypto.signing.SingleSignedTransaction; import org.xrpl.xrpl4j.model.client.channels.UnsignedClaim; +import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; +import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.AuthAccount; +import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.AmmBid; +import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDeposit; +import org.xrpl.xrpl4j.model.transactions.AmmVote; +import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; import org.xrpl.xrpl4j.model.transactions.CheckCancel; import org.xrpl.xrpl4j.model.transactions.CheckCash; import org.xrpl.xrpl4j.model.transactions.CheckCreate; @@ -78,6 +87,7 @@ import org.xrpl.xrpl4j.model.transactions.SignerListSet; import org.xrpl.xrpl4j.model.transactions.SignerWrapper; import org.xrpl.xrpl4j.model.transactions.TicketCreate; +import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.Transaction; import org.xrpl.xrpl4j.model.transactions.TrustSet; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; @@ -576,6 +586,115 @@ void addSignatureToTicketCreate() { addSignatureToTransactionHelper(ticketCreate); } + @Test + void addSignatureToAmmBid() { + AmmBid bid = AmmBid.builder() + .account(sourcePublicKey.deriveAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(bid); + } + + @Test + void addSignatureToAmmCreate() { + AmmCreate ammCreate = AmmCreate.builder() + .account(sourcePublicKey.deriveAddress()) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(ammCreate); + } + + @Test + void addSignatureToAmmDeposit() { + AmmDeposit deposit = AmmDeposit.builder() + .account(sourcePublicKey.deriveAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(deposit); + } + + @Test + void addSignatureToAmmVote() { + AmmVote vote = AmmVote.builder() + .account(sourcePublicKey.deriveAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(vote); + } + + @Test + void addSignatureToAmmWithdraw() { + AmmWithdraw withdraw = AmmWithdraw.builder() + .account(sourcePublicKey.deriveAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .asset2(Asset.XRP) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(withdraw); + } + + @Test public void addSignatureToTransactionUnsupported() { assertThrows(IllegalArgumentException.class, () -> addSignatureToTransactionHelper(transactionMock)); @@ -895,6 +1014,109 @@ void addMultiSignaturesToTicketCreate() { addMultiSignatureToTransactionHelper(ticketCreate); } + @Test + void addMultiSignatureToAmmBid() { + AmmBid bid = AmmBid.builder() + .account(sourcePublicKey.deriveAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .build(); + + addMultiSignatureToTransactionHelper(bid); + } + + @Test + void addMultiSignatureToAmmCreate() { + AmmCreate ammCreate = AmmCreate.builder() + .account(sourcePublicKey.deriveAddress()) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .build(); + + addMultiSignatureToTransactionHelper(ammCreate); + } + + @Test + void addMultiSignatureToAmmDeposit() { + AmmDeposit deposit = AmmDeposit.builder() + .account(sourcePublicKey.deriveAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .lpTokenOut( + IssuedCurrencyAmount.builder() + .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") + .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .value("100") + .build() + ) + .build(); + + addMultiSignatureToTransactionHelper(deposit); + } + + @Test + void addMultiSignatureToAmmVote() { + AmmVote vote = AmmVote.builder() + .account(sourcePublicKey.deriveAddress()) + .asset(Asset.XRP) + .asset2( + Asset.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .build(); + + addMultiSignatureToTransactionHelper(vote); + } + + @Test + void addMultiSignatureToAmmWithdraw() { + AmmWithdraw withdraw = AmmWithdraw.builder() + .account(sourcePublicKey.deriveAddress()) + .fee(XrpCurrencyAmount.ofDrops(10)) + .asset( + Asset.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .asset2(Asset.XRP) + .flags(AmmWithdrawFlags.WITHDRAW_ALL) + .build(); + + addMultiSignatureToTransactionHelper(withdraw); + } + @Test public void addMultiSignaturesToTransactionUnsupported() { when(transactionMock.transactionSignature()).thenReturn(Optional.empty()); diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index d58be3023..8df8311bc 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -4,6 +4,7 @@ import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.ledger.Asset; import org.xrpl.xrpl4j.model.ledger.AuthAccount; @@ -15,6 +16,9 @@ class AmmBidTest extends AbstractJsonTest { void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { AmmBid bid = AmmBid.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -54,6 +58,7 @@ void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { " \"Fee\" : \"10\",\n" + " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMBid\"\n" + "}"; @@ -64,6 +69,9 @@ void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { AmmBid bid = AmmBid.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -127,6 +135,7 @@ void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { " \"Fee\" : \"10\",\n" + " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMBid\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java index 398135f1b..0887b7afb 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java @@ -4,6 +4,7 @@ import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; class AmmCreateTest extends AbstractJsonTest { @@ -23,6 +24,9 @@ void testJson() throws JSONException, JsonProcessingException { .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(6)) .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .build(); String json = "{\n" + @@ -37,6 +41,7 @@ void testJson() throws JSONException, JsonProcessingException { " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 6,\n" + " \"TradingFee\" : 500,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMCreate\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index c85715f78..4f8f9179b 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.Flags; @@ -25,6 +26,9 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -59,6 +63,7 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmDepositFlags.LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -70,6 +75,9 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -107,6 +115,7 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmDepositFlags.TWO_ASSET + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -132,6 +141,9 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi .value("100") .build() ) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .build(); assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.SINGLE_ASSET); @@ -153,6 +165,7 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmDepositFlags.SINGLE_ASSET + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -164,6 +177,9 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -211,6 +227,7 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmDepositFlags.ONE_ASSET_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; @@ -222,6 +239,9 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .asset(Asset.XRP) .asset2( Asset.builder() @@ -259,6 +279,7 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmDepositFlags.LIMIT_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMDeposit\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java index a63cc09c5..cbe410ebd 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -4,6 +4,7 @@ import com.google.common.primitives.UnsignedInteger; import org.json.JSONException; import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.ledger.Asset; @@ -23,6 +24,9 @@ void testJson() throws JSONException, JsonProcessingException { .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(8)) .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .build(); String json = "{\n" + @@ -38,6 +42,7 @@ void testJson() throws JSONException, JsonProcessingException { " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 8,\n" + " \"TradingFee\" : 600,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMVote\"\n" + "}"; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index 8f810af41..9a3f1ad4d 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.json.JSONException; import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.flags.Flags; @@ -17,6 +18,7 @@ void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingE AmmWithdraw withdraw = baseBuilder() .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) + .build(); String json = "{\n" + @@ -27,6 +29,7 @@ void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingE " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -46,6 +49,7 @@ void constructWithdrawAllAndTestJson() throws JSONException, JsonProcessingExcep " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.WITHDRAW_ALL + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -73,6 +77,7 @@ void constructTwoAssetAndTestJson() throws JSONException, JsonProcessingExceptio " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.TWO_ASSET + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -98,6 +103,7 @@ void constructSingleAssetAndTestJson() throws JSONException, JsonProcessingExcep " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.SINGLE_ASSET + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -123,6 +129,7 @@ void constructOneAssetWithdrawAllAndTestJson() throws JSONException, JsonProcess " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -150,6 +157,7 @@ void constructOneAssetLpTokenAndTestJson() throws JSONException, JsonProcessingE " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.ONE_ASSET_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -177,6 +185,7 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce " \"Fee\" : \"10\",\n" + " \"Flags\" : " + AmmWithdrawFlags.LIMIT_LP_TOKEN + ",\n" + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMWithdraw\"\n" + "}"; @@ -473,6 +482,9 @@ private ImmutableIssuedCurrencyAmount lpTokensIn() { private ImmutableAmmWithdraw.Builder baseBuilder() { return AmmWithdraw.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) .fee(XrpCurrencyAmount.ofDrops(10)) .asset( Asset.builder() diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 9a0f4650f..3ab1e4d19 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -7,6 +7,8 @@ import com.google.common.io.BaseEncoding; import com.google.common.primitives.UnsignedInteger; import okhttp3.HttpUrl; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.keys.KeyPair; import org.xrpl.xrpl4j.crypto.keys.PrivateKey; @@ -20,6 +22,7 @@ import org.xrpl.xrpl4j.model.client.amm.AmmInfoAuctionSlot; import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; +import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; @@ -51,7 +54,7 @@ public class AmmIT extends AbstractIT { String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); - // @BeforeAll + @BeforeAll protected static void initXrplEnvironment() { xrplEnvironment = new CustomEnvironment( HttpUrl.parse("http://amm.devnet.rippletest.net:51234"), @@ -59,7 +62,7 @@ protected static void initXrplEnvironment() { ); } - // @Test + @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -113,7 +116,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); } - // @Test + @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -124,7 +127,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException AccountInfoResult traderAccount = scanForResult( () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); - + AccountInfoResult traderAccountAfterDeposit = depositXrp( issuerKeyPair, traderKeyPair, @@ -180,7 +183,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - // @Test + @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -297,6 +300,7 @@ private AccountInfoResult depositXrp( AccountLinesRequestParams.builder() .account(traderAccount.accountData().account()) .peer(amm.amm().ammAccount()) + .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ); From 7b3309afe97db565a6ee9a862f38040719474390 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 30 Jan 2023 18:18:22 -0500 Subject: [PATCH 27/53] comment out AmmITs again --- .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 3ab1e4d19..37cea3d43 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -62,7 +62,7 @@ protected static void initXrplEnvironment() { ); } - @Test + // @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -116,7 +116,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); } - @Test + // @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -183,7 +183,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - @Test + // @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); From 18550ebaa68ea4a79a231ee92743bde706deacbb Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 31 Jan 2023 13:16:37 -0500 Subject: [PATCH 28/53] fix build --- .../org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java index 13942b415..18bf6f1e6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java @@ -278,23 +278,23 @@ public SingleSignedTransaction addSignatureToTransact .build(); } else if (AmmBid.class.isAssignableFrom(transaction.getClass())) { transactionWithSignature = AmmBid.builder().from((AmmBid) transaction) - .transactionSignature(signature.base16Value()) + .transactionSignature(signature) .build(); } else if (AmmCreate.class.isAssignableFrom(transaction.getClass())) { transactionWithSignature = AmmCreate.builder().from((AmmCreate) transaction) - .transactionSignature(signature.base16Value()) + .transactionSignature(signature) .build(); } else if (AmmDeposit.class.isAssignableFrom(transaction.getClass())) { transactionWithSignature = AmmDeposit.builder().from((AmmDeposit) transaction) - .transactionSignature(signature.base16Value()) + .transactionSignature(signature) .build(); } else if (AmmVote.class.isAssignableFrom(transaction.getClass())) { transactionWithSignature = AmmVote.builder().from((AmmVote) transaction) - .transactionSignature(signature.base16Value()) + .transactionSignature(signature) .build(); } else if (AmmWithdraw.class.isAssignableFrom(transaction.getClass())) { transactionWithSignature = AmmWithdraw.builder().from((AmmWithdraw) transaction) - .transactionSignature(signature.base16Value()) + .transactionSignature(signature) .build(); } else { // Should never happen, but will in a unit test if we miss one. From df58f30f831693b39072064db085478844c991ff Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 13 Feb 2023 11:27:02 -0500 Subject: [PATCH 29/53] fix trading fee calculation in IT. Use 0x40000000 for lsfAmm flag in AccountRootFlags --- .../xrpl4j/model/flags/AccountRootFlags.java | 2 +- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 51 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java index 1bea9d065..f41bea9c7 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java @@ -80,7 +80,7 @@ public class AccountRootFlags extends Flags { /** * Constant {@link AccountRootFlags} for the {@code lsfAMM} account flag. */ - public static final AccountRootFlags AMM = new AccountRootFlags(0x02000000); + public static final AccountRootFlags AMM = new AccountRootFlags(0x40000000); /** * Required-args Constructor. diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 37cea3d43..1fb10a10f 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -42,6 +42,7 @@ import org.xrpl.xrpl4j.tests.environment.CustomEnvironment; import java.math.BigDecimal; +import java.math.RoundingMode; /** * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and @@ -62,7 +63,7 @@ protected static void initXrplEnvironment() { ); } - // @Test + @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -112,11 +113,44 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces traderKeyPair.publicKey().deriveAddress() ); + BigDecimal issuerLpTokenBalance = new BigDecimal(xrplClient.accountLines( + AccountLinesRequestParams.builder() + .account(issuerKeyPair.publicKey().deriveAddress()) + .peer(amm.amm().ammAccount()) + .ledgerSpecifier(LedgerSpecifier.CURRENT) + .build() + ).lines().stream() + .filter(trustLine -> trustLine.currency().equals(amm.amm().lpToken().currency())) + .findFirst() + .orElseThrow(RuntimeException::new) + .balance()); + + BigDecimal traderLpTokenBalance = new BigDecimal(xrplClient.accountLines( + AccountLinesRequestParams.builder() + .account(traderKeyPair.publicKey().deriveAddress()) + .peer(amm.amm().ammAccount()) + .ledgerSpecifier(LedgerSpecifier.CURRENT) + .build() + ).lines().stream() + .filter(trustLine -> trustLine.currency().equals(amm.amm().lpToken().currency())) + .findFirst() + .orElseThrow(RuntimeException::new) + .balance()); + + // Expected trading fee is the weighted average of each vote, where the weight is number of LP tokens held + // by each voter + TradingFee expectedTradingFee = TradingFee.ofPercent( + issuerLpTokenBalance.multiply(amm.amm().tradingFee().bigDecimalValue()).add( + traderLpTokenBalance.multiply(newTradingFee.bigDecimalValue()) + ).divide(issuerLpTokenBalance.add(traderLpTokenBalance), RoundingMode.FLOOR) + .setScale(3, RoundingMode.FLOOR) + ); + AmmInfoResult ammAfterVote = getAmmInfo(issuerKeyPair); - assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(newTradingFee); + assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(expectedTradingFee); } - // @Test + @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -183,7 +217,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - // @Test + @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -355,7 +389,7 @@ private AmmInfoResult createAmm(KeyPair issuerKeyPair) throws JsonRpcClientError } private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErrorException { - return xrplClient.ammInfo( + AmmInfoResult ammInfoResult = xrplClient.ammInfo( AmmInfoRequestParams.builder() .asset( Asset.builder() @@ -366,5 +400,12 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro .asset2(Asset.XRP) .build() ); + + AccountInfoResult ammAccountInfo = xrplClient.accountInfo( + AccountInfoRequestParams.of(ammInfoResult.amm().ammAccount()) + ); + assertThat(ammAccountInfo.accountData().flags().lsfAmm()).isTrue(); + + return ammInfoResult; } } From c11e101ed90f18a0f091d93c80cca8b2bf9ccd56 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 13 Feb 2023 13:06:54 -0500 Subject: [PATCH 30/53] disable tests again --- .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 1fb10a10f..4b251b7c0 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -63,7 +63,7 @@ protected static void initXrplEnvironment() { ); } - @Test + // @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -150,7 +150,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(expectedTradingFee); } - @Test + // @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -217,7 +217,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - @Test + // @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); From b3b6e69141ad4cbbac40400a9abb1e68bd71197e Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 5 Jul 2023 14:42:18 -0400 Subject: [PATCH 31/53] rename Asset to Issue --- .../client/amm/AmmInfoRequestParams.java | 10 +++--- .../xrpl/xrpl4j/model/ledger/AmmObject.java | 8 ++--- .../model/ledger/{Asset.java => Issue.java} | 6 ++-- .../xrpl4j/model/transactions/AmmBid.java | 11 +++--- .../xrpl4j/model/transactions/AmmDeposit.java | 11 +++--- .../xrpl4j/model/transactions/AmmVote.java | 11 +++--- .../model/transactions/AmmWithdraw.java | 11 +++--- .../crypto/signing/SignatureUtilsTest.java | 34 +++++++++---------- .../client/amm/AmmInfoRequestParamsTest.java | 6 ++-- .../model/client/amm/AmmInfoResultTest.java | 8 ----- .../xrpl4j/model/ledger/AmmObjectTest.java | 8 ++--- .../ledger/{AssetTest.java => IssueTest.java} | 14 ++++---- .../xrpl4j/model/transactions/AmmBidTest.java | 10 +++--- .../model/transactions/AmmDepositTest.java | 27 +++++++-------- .../model/transactions/AmmVoteTest.java | 6 ++-- .../model/transactions/AmmWithdrawTest.java | 7 ++-- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 23 ++++++------- 17 files changed, 98 insertions(+), 113 deletions(-) rename xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/{Asset.java => Issue.java} (93%) rename xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/{AssetTest.java => IssueTest.java} (78%) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java index a7d8fa796..7fdf2c0b6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplRequestParams; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; /** * Request parameters for the {@code amm_info} rippled API method. @@ -26,15 +26,15 @@ static ImmutableAmmInfoRequestParams.Builder builder() { /** * One of the assets of the AMM to look up. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ - Asset asset(); + Issue asset(); /** * The other of the assets of the AMM. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ - Asset asset2(); + Issue asset2(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java index 2274b3a62..95619581a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java @@ -56,18 +56,18 @@ default Flags flags() { /** * The definition for one of the two assets this AMM holds. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset") - Asset asset(); + Issue asset(); /** * The definition for the other asset this AMM holds. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset2") - Asset asset2(); + Issue asset2(); /** * The address of the special account that holds this AMM's assets. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java similarity index 93% rename from xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java rename to xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java index 89b9e829a..a1752e2c7 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Asset.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java @@ -33,12 +33,12 @@ @Value.Immutable @JsonSerialize(as = ImmutableAsset.class) @JsonDeserialize(as = ImmutableAsset.class) -public interface Asset { +public interface Issue { /** - * Constant {@link Asset} representing XRP. + * Constant {@link Issue} representing XRP. */ - Asset XRP = Asset.builder().currency("XRP").build(); + Issue XRP = Issue.builder().currency("XRP").build(); /** * Construct a {@code Asset} builder. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index da4f3ed1a..bae2e06f1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -4,9 +4,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; -import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.flags.TransactionFlags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import java.util.List; @@ -46,18 +45,18 @@ default TransactionFlags flags() { /** * The definition for one of the assets in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset") - Asset asset(); + Issue asset(); /** * The definition for the other asset in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset2") - Asset asset2(); + Issue asset2(); /** * Pay at least this amount for the slot. Setting this value higher makes it harder for others to outbid you. If diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index 7eb1c6d9a..fb49b3b04 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -5,8 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; -import org.xrpl.xrpl4j.model.flags.Flags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.Optional; @@ -59,18 +58,18 @@ default AmmDepositFlags flags() { /** * The definition for one of the assets in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset") - Asset asset(); + Issue asset(); /** * The definition for the other asset in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset2") - Asset asset2(); + Issue asset2(); /** * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java index 887ae9a89..db7690e55 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java @@ -4,9 +4,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; -import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.flags.TransactionFlags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; /** * Object mapping for the AMMVote transaction. @@ -42,18 +41,18 @@ default TransactionFlags flags() { /** * The definition for one of the assets in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset") - Asset asset(); + Issue asset(); /** * The definition for the other asset in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset2") - Asset asset2(); + Issue asset2(); /** * The proposed fee to vote for. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java index d91d1315c..c89cfd15d 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -6,8 +6,7 @@ import com.google.common.base.Preconditions; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.flags.Flags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.Optional; @@ -36,18 +35,18 @@ static ImmutableAmmWithdraw.Builder builder() { /** * The definition for one of the assets in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset") - Asset asset(); + Issue asset(); /** * The definition for the other asset in the AMM's pool. * - * @return An {@link Asset}. + * @return An {@link Issue}. */ @JsonProperty("Asset2") - Asset asset2(); + Issue asset2(); /** * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index a10f156b2..42ff8b1da 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -48,7 +48,7 @@ import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.client.channels.UnsignedClaim; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.AccountDelete; @@ -587,9 +587,9 @@ void addSignatureToTicketCreate() { void addSignatureToAmmBid() { AmmBid bid = AmmBid.builder() .account(sourcePublicKey.deriveAddress()) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -632,9 +632,9 @@ void addSignatureToAmmDeposit() { AmmDeposit deposit = AmmDeposit.builder() .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -656,9 +656,9 @@ void addSignatureToAmmDeposit() { void addSignatureToAmmVote() { AmmVote vote = AmmVote.builder() .account(sourcePublicKey.deriveAddress()) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .currency("TST") .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() @@ -678,12 +678,12 @@ void addSignatureToAmmWithdraw() { .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) .asset( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() ) - .asset2(Asset.XRP) + .asset2(Issue.XRP) .flags(AmmWithdrawFlags.WITHDRAW_ALL) .signingPublicKey(sourcePublicKey) .build(); @@ -1015,9 +1015,9 @@ void addMultiSignaturesToTicketCreate() { void addMultiSignatureToAmmBid() { AmmBid bid = AmmBid.builder() .account(sourcePublicKey.deriveAddress()) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -1058,9 +1058,9 @@ void addMultiSignatureToAmmDeposit() { AmmDeposit deposit = AmmDeposit.builder() .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -1081,9 +1081,9 @@ void addMultiSignatureToAmmDeposit() { void addMultiSignatureToAmmVote() { AmmVote vote = AmmVote.builder() .account(sourcePublicKey.deriveAddress()) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .currency("TST") .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() @@ -1102,12 +1102,12 @@ void addMultiSignatureToAmmWithdraw() { .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) .asset( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() ) - .asset2(Asset.XRP) + .asset2(Issue.XRP) .flags(AmmWithdrawFlags.WITHDRAW_ALL) .build(); diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java index bbe32ed90..b18ac0f05 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java @@ -4,7 +4,7 @@ import org.json.JSONException; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.transactions.Address; class AmmInfoRequestParamsTest extends AbstractJsonTest { @@ -12,9 +12,9 @@ class AmmInfoRequestParamsTest extends AbstractJsonTest { @Test void testJson() throws JSONException, JsonProcessingException { AmmInfoRequestParams params = AmmInfoRequestParams.builder() - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .currency("TST") .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index 36e07759e..abb8d081f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -9,13 +9,6 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; -import org.xrpl.xrpl4j.model.ledger.AmmObject; -import org.xrpl.xrpl4j.model.ledger.Asset; -import org.xrpl.xrpl4j.model.ledger.AuctionSlot; -import org.xrpl.xrpl4j.model.ledger.AuthAccount; -import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; -import org.xrpl.xrpl4j.model.ledger.VoteEntry; -import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.Hash256; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; @@ -23,7 +16,6 @@ import org.xrpl.xrpl4j.model.transactions.VoteWeight; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; -import java.math.BigDecimal; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java index 918ac4f83..f52b94da3 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java @@ -28,8 +28,8 @@ void voteSlotsUnwrapped() { .tradingFee(TradingFee.of(UnsignedInteger.valueOf(2))) .build(); AmmObject ammObject = AmmObject.builder() - .asset(mock(Asset.class)) - .asset2(mock(Asset.class)) + .asset(mock(Issue.class)) + .asset2(mock(Issue.class)) .ammAccount(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .lpTokenBalance(mock(IssuedCurrencyAmount.class)) .tradingFee(TradingFee.of(UnsignedInteger.ONE)) @@ -46,9 +46,9 @@ void voteSlotsUnwrapped() { @Test void testJson() throws JSONException, JsonProcessingException { AmmObject ammObject = AmmObject.builder() - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .currency("TST") .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/IssueTest.java similarity index 78% rename from xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java rename to xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/IssueTest.java index 717a0f9e7..94e897a17 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AssetTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/IssueTest.java @@ -8,19 +8,19 @@ import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.transactions.Address; -class AssetTest extends AbstractJsonTest { +class IssueTest extends AbstractJsonTest { @Test void testXrp() { - assertThat(Asset.XRP.currency()).isEqualTo("XRP"); - assertThat(Asset.XRP.issuer()).isEmpty(); + assertThat(Issue.XRP.currency()).isEqualTo("XRP"); + assertThat(Issue.XRP.issuer()).isEmpty(); } @Test void testNonXrp() { String usd = "USD"; Address issuer = Address.of("rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); - Asset asset = Asset.builder() + Issue asset = Issue.builder() .currency(usd) .issuer(issuer) .build(); @@ -35,14 +35,14 @@ void testJsonForXrp() throws JSONException, JsonProcessingException { " \"currency\": \"XRP\"" + "}"; - assertCanSerializeAndDeserialize(Asset.XRP, json, Asset.class); + assertCanSerializeAndDeserialize(Issue.XRP, json, Issue.class); } @Test void testJsonForNonXrp() throws JSONException, JsonProcessingException { String usd = "USD"; Address issuer = Address.of("rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn"); - Asset asset = Asset.builder() + Issue asset = Issue.builder() .currency(usd) .issuer(issuer) .build(); @@ -51,6 +51,6 @@ void testJsonForNonXrp() throws JSONException, JsonProcessingException { " \"issuer\": \"" + asset.issuer().get().value() + "\"" + "}"; - assertCanSerializeAndDeserialize(asset, json, Asset.class); + assertCanSerializeAndDeserialize(asset, json, Issue.class); } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index 8df8311bc..08bdb9adf 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; @@ -19,9 +19,9 @@ void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -72,9 +72,9 @@ void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index 4f8f9179b..ed05beda1 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -12,8 +12,7 @@ import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; -import org.xrpl.xrpl4j.model.flags.Flags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.ArrayList; import java.util.List; @@ -29,9 +28,9 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -78,9 +77,9 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -127,9 +126,9 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -180,9 +179,9 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -242,9 +241,9 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() @@ -298,9 +297,9 @@ void testInvalidFieldPresence( ImmutableAmmDeposit.Builder builder = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java index cbe410ebd..5bc837b36 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; class AmmVoteTest extends AbstractJsonTest { @@ -14,9 +14,9 @@ class AmmVoteTest extends AbstractJsonTest { void testJson() throws JSONException, JsonProcessingException { AmmVote vote = AmmVote.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) - .asset(Asset.XRP) + .asset(Issue.XRP) .asset2( - Asset.builder() + Issue.builder() .currency("TST") .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index 9a3f1ad4d..0146979cf 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -8,8 +8,7 @@ import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.flags.Flags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; class AmmWithdrawTest extends AbstractJsonTest { @@ -487,10 +486,10 @@ private ImmutableAmmWithdraw.Builder baseBuilder() { ) .fee(XrpCurrencyAmount.ofDrops(10)) .asset( - Asset.builder() + Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() - ).asset2(Asset.XRP); + ).asset2(Issue.XRP); } } \ No newline at end of file diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 4b251b7c0..81fe4f392 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -8,7 +8,6 @@ import com.google.common.primitives.UnsignedInteger; import okhttp3.HttpUrl; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.keys.KeyPair; import org.xrpl.xrpl4j.crypto.keys.PrivateKey; @@ -27,7 +26,7 @@ import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.ledger.Asset; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.AmmBid; @@ -91,12 +90,12 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) .signingPublicKey(traderKeyPair.publicKey()) .asset2( - Asset.builder() + Issue.builder() .currency(xrpl4jCoin) .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) - .asset(Asset.XRP) + .asset(Issue.XRP) .tradingFee(newTradingFee) .build(); @@ -178,12 +177,12 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .lastLedgerSequence(traderAccount.ledgerIndexSafe().plus(UnsignedInteger.valueOf(8)).unsignedIntegerValue()) .signingPublicKey(traderKeyPair.publicKey()) .asset2( - Asset.builder() + Issue.builder() .currency(xrpl4jCoin) .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) - .asset(Asset.XRP) + .asset(Issue.XRP) .addAuthAccounts( AuthAccountWrapper.of(AuthAccount.of(authAccount1.publicKey().deriveAddress())) ) @@ -247,12 +246,12 @@ void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingExce ) .signingPublicKey(traderKeyPair.publicKey()) .asset2( - Asset.builder() + Issue.builder() .currency(xrpl4jCoin) .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) - .asset(Asset.XRP) + .asset(Issue.XRP) .amount(XrpCurrencyAmount.ofXrp(BigDecimal.valueOf(90))) .flags(AmmWithdrawFlags.SINGLE_ASSET) .build(); @@ -298,12 +297,12 @@ private AccountInfoResult depositXrp( AmmDeposit deposit = AmmDeposit.builder() .account(traderAccount.accountData().account()) .asset2( - Asset.builder() + Issue.builder() .currency(xrpl4jCoin) .issuer(issuerKeyPair.publicKey().deriveAddress()) .build() ) - .asset(Asset.XRP) + .asset(Issue.XRP) .amount(depositAmount) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .sequence(traderAccount.accountData().sequence()) @@ -392,12 +391,12 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro AmmInfoResult ammInfoResult = xrplClient.ammInfo( AmmInfoRequestParams.builder() .asset( - Asset.builder() + Issue.builder() .issuer(issuerKeyPair.publicKey().deriveAddress()) .currency(xrpl4jCoin) .build() ) - .asset2(Asset.XRP) + .asset2(Issue.XRP) .build() ); From b6124332f3ab21a76e890ea4dc4719490dfa784f Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 5 Jul 2023 14:46:52 -0400 Subject: [PATCH 32/53] rename Asset to Issue --- .../java/org/xrpl/xrpl4j/model/ledger/Issue.java | 12 ++++++------ .../org/xrpl/xrpl4j/model/transactions/AmmBid.java | 2 +- .../xrpl4j/crypto/signing/SignatureUtilsTest.java | 2 +- .../xrpl/xrpl4j/model/transactions/AmmBidTest.java | 2 +- .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java index a1752e2c7..c6e5e9ecb 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/Issue.java @@ -28,11 +28,11 @@ import java.util.Optional; /** - * Represents an Asset held by an {@link AmmObject}. + * Represents an asset on the ledger without an amount. */ @Value.Immutable -@JsonSerialize(as = ImmutableAsset.class) -@JsonDeserialize(as = ImmutableAsset.class) +@JsonSerialize(as = ImmutableIssue.class) +@JsonDeserialize(as = ImmutableIssue.class) public interface Issue { /** @@ -43,10 +43,10 @@ public interface Issue { /** * Construct a {@code Asset} builder. * - * @return An {@link ImmutableAsset.Builder}. + * @return An {@link ImmutableIssue.Builder}. */ - static ImmutableAsset.Builder builder() { - return ImmutableAsset.builder(); + static ImmutableIssue.Builder builder() { + return ImmutableIssue.builder(); } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index bae2e06f1..9e3f121f3 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.TransactionFlags; -import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.ledger.Issue; import java.util.List; import java.util.Optional; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index 42ff8b1da..60f9ba929 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -48,9 +48,9 @@ import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.client.channels.UnsignedClaim; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.transactions.AccountDelete; import org.xrpl.xrpl4j.model.transactions.AccountSet; import org.xrpl.xrpl4j.model.transactions.Address; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index 08bdb9adf..3703a37be 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; -import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.ledger.Issue; class AmmBidTest extends AbstractJsonTest { diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 81fe4f392..d07bf0eaa 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -26,9 +26,9 @@ import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; -import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; +import org.xrpl.xrpl4j.model.ledger.Issue; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; From 96c1429a08f7720e6796fb4738fea44f6f5ff2ba Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 17 Jul 2023 12:20:49 -0400 Subject: [PATCH 33/53] update Flags fields in AMM transactions --- .../xrpl4j/model/transactions/AmmBid.java | 9 +- .../xrpl4j/model/transactions/AmmCreate.java | 9 +- .../xrpl4j/model/transactions/AmmDeposit.java | 16 +-- .../xrpl4j/model/transactions/AmmVote.java | 9 +- .../xrpl4j/model/transactions/AmmBidTest.java | 112 +++++++++++++++++- .../model/transactions/AmmCreateTest.java | 82 ++++++++++++- .../model/transactions/AmmVoteTest.java | 80 +++++++++++++ .../model/transactions/AmmWithdrawTest.java | 1 - 8 files changed, 294 insertions(+), 24 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index 9e3f121f3..07b2de6e4 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -29,17 +29,18 @@ static ImmutableAmmBid.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmBid}. + * Set of {@link TransactionFlags}s for this {@link AmmBid}, which only allows the + * {@code tfFullyCanonicalSig} flag, which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags#EMPTY}. */ @JsonProperty("Flags") - @Value.Derived + @Value.Default default TransactionFlags flags() { - return new TransactionFlags.Builder().build(); + return TransactionFlags.EMPTY; } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java index 02acec071..bf79e8122 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java @@ -25,17 +25,18 @@ static ImmutableAmmCreate.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmCreate}. + * Set of {@link TransactionFlags}s for this {@link AmmCreate}, which only allows the + * {@code tfFullyCanonicalSig} flag, which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags#EMPTY}. */ @JsonProperty("Flags") - @Value.Derived + @Value.Default default TransactionFlags flags() { - return new TransactionFlags.Builder().build(); + return TransactionFlags.EMPTY; } /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index fb49b3b04..94b616ab6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -27,28 +27,28 @@ static ImmutableAmmDeposit.Builder builder() { } /** - * A {@link AmmDepositFlags} for this transaction. This flag will always be derived from the presence + * A {@link AmmDepositFlags} for this transaction. This flag will automatically be derived from the presence * of {@link #lpTokenOut()}, {@link #amount()}, {@link #amount2()} and {@link #effectivePrice()}. * * @return A {@link AmmDepositFlags} for this transaction. */ @JsonProperty("Flags") - @Value.Derived + @Value.Default default AmmDepositFlags flags() { - boolean lpTokenPresent = lpTokenOut().isPresent(); + boolean lpTokenOutPresent = lpTokenOut().isPresent(); boolean amountPresent = amount().isPresent(); boolean amount2Present = amount2().isPresent(); boolean effectivePricePresent = effectivePrice().isPresent(); - if (lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent) { + if (lpTokenOutPresent && !amountPresent && !amount2Present && !effectivePricePresent) { return AmmDepositFlags.LP_TOKEN; - } else if (!lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent) { + } else if (!lpTokenOutPresent && amountPresent && amount2Present && !effectivePricePresent) { return AmmDepositFlags.TWO_ASSET; - } else if (!lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { + } else if (!lpTokenOutPresent && amountPresent && !amount2Present && !effectivePricePresent) { return AmmDepositFlags.SINGLE_ASSET; - } else if (lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent) { + } else if (lpTokenOutPresent && amountPresent && !amount2Present && !effectivePricePresent) { return AmmDepositFlags.ONE_ASSET_LP_TOKEN; - } else if (!lpTokenPresent && amountPresent && !amount2Present) { + } else if (!lpTokenOutPresent && amountPresent && !amount2Present) { return AmmDepositFlags.LIMIT_LP_TOKEN; } else { throw new IllegalStateException("Correct AmmDepositFlag could not be determined based on set fields."); diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java index db7690e55..60ef87858 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java @@ -25,17 +25,18 @@ static ImmutableAmmVote.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmVote}. + * Set of {@link TransactionFlags}s for this {@link AmmVote}, which only allows the + * {@code tfFullyCanonicalSig} flag, which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. * - * @return Always {@link TransactionFlags} with {@code tfFullyCanonicalSig} set. + * @return Always {@link TransactionFlags#EMPTY}. */ @JsonProperty("Flags") - @Value.Derived + @Value.Default default TransactionFlags flags() { - return new TransactionFlags.Builder().build(); + return TransactionFlags.EMPTY; } /** diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java index 3703a37be..91f51139b 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmBidTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.ledger.Issue; @@ -56,7 +57,6 @@ void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { " }\n" + " ],\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 9,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMBid\"\n" + @@ -65,6 +65,115 @@ void testJsonWithoutMinAndMax() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(bid, json); } + @Test + void testJsonWithUnsetFlags() throws JSONException, JsonProcessingException { + AmmBid bid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .flags(TransactionFlags.UNSET) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 0,\n" + + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMBid\"\n" + + "}"; + + assertCanSerializeAndDeserialize(bid, json); + } + + @Test + void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { + AmmBid bid = AmmBid.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .addAuthAccounts( + AuthAccountWrapper.of(AuthAccount.of(Address.of("rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"))), + AuthAccountWrapper.of(AuthAccount.of(Address.of("rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"))) + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .flags(TransactionFlags.FULLY_CANONICAL_SIG) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"AuthAccounts\" : [\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"AuthAccount\" : {\n" + + " \"Account\" : \"rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 0,\n" + + " \"Sequence\" : 9,\n" + + " \"Flags\" : 2147483648,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMBid\"\n" + + "}"; + + assertCanSerializeAndDeserialize(bid, json); + } + @Test void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { AmmBid bid = AmmBid.builder() @@ -133,7 +242,6 @@ void testJsonWithMinAndMax() throws JSONException, JsonProcessingException { " \"value\" : \"100\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 9,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + " \"TransactionType\" : \"AMMBid\"\n" + diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java index 0887b7afb..275582f17 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmCreateTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; class AmmCreateTest extends AbstractJsonTest { @@ -38,7 +39,6 @@ void testJson() throws JSONException, JsonProcessingException { " },\n" + " \"Amount2\" : \"250000000\",\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : 2147483648,\n" + " \"Sequence\" : 6,\n" + " \"TradingFee\" : 500,\n" + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + @@ -47,4 +47,84 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(ammCreate, json); } + + @Test + void testJsonWithUnsetFlags() throws JSONException, JsonProcessingException { + AmmCreate ammCreate = AmmCreate.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(TransactionFlags.UNSET) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"25\"\n" + + " },\n" + + " \"Amount2\" : \"250000000\",\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 6,\n" + + " \"TradingFee\" : 500,\n" + + " \"Flags\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMCreate\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammCreate, json); + } + + @Test + void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { + AmmCreate ammCreate = AmmCreate.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .amount( + IssuedCurrencyAmount.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .value("25") + .build() + ) + .amount2(XrpCurrencyAmount.ofDrops(250000000)) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(6)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(500))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(TransactionFlags.FULLY_CANONICAL_SIG) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\",\n" + + " \"value\" : \"25\"\n" + + " },\n" + + " \"Amount2\" : \"250000000\",\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 6,\n" + + " \"TradingFee\" : 500,\n" + + " \"Flags\" : 2147483648,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMCreate\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammCreate, json); + } } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java index 5bc837b36..e0fee4500 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmVoteTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.Issue; class AmmVoteTest extends AbstractJsonTest { @@ -29,6 +30,85 @@ void testJson() throws JSONException, JsonProcessingException { ) .build(); + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Sequence\" : 8,\n" + + " \"TradingFee\" : 600,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMVote\"\n" + + "}"; + + assertCanSerializeAndDeserialize(vote, json); + } + + @Test + void testJsonWithUnsetFlags() throws JSONException, JsonProcessingException { + AmmVote vote = AmmVote.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(TransactionFlags.UNSET) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 0,\n" + + " \"Sequence\" : 8,\n" + + " \"TradingFee\" : 600,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMVote\"\n" + + "}"; + + assertCanSerializeAndDeserialize(vote, json); + } + + @Test + void testJsonWithNonZeroFlags() throws JSONException, JsonProcessingException { + AmmVote vote = AmmVote.builder() + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .asset(Issue.XRP) + .asset2( + Issue.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(8)) + .tradingFee(TradingFee.of(UnsignedInteger.valueOf(600))) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(TransactionFlags.FULLY_CANONICAL_SIG) + .build(); + String json = "{\n" + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + " \"Asset\" : {\n" + diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index 0146979cf..e809e1e84 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -17,7 +17,6 @@ void constructLpTokenWithdrawAndTestJson() throws JSONException, JsonProcessingE AmmWithdraw withdraw = baseBuilder() .flags(AmmWithdrawFlags.LP_TOKEN) .lpTokensIn(lpTokensIn()) - .build(); String json = "{\n" + From 100667a13c061d9c66b198d01454728c83caa238 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 17 Jul 2023 13:03:05 -0400 Subject: [PATCH 34/53] Rename AmmResult.ammAccount to account. Make AmmInfoAuctionSlot.expiration a String for now bc Date format is different than expected on amm-devnet. Update definitions.json --- .../model/client/amm/AmmInfoAuctionSlot.java | 7 +- .../xrpl4j/model/client/amm/AmmResult.java | 4 +- .../src/main/resources/definitions.json | 100 ++++++++++++------ .../model/client/amm/AmmInfoResultTest.java | 18 ++-- 4 files changed, 86 insertions(+), 43 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index 885e1b33b..7197b4582 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -64,8 +64,11 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { * @return An {@link ZonedDateTime} */ @JsonProperty("expiration") - @JsonFormat(pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", locale = "en_US") - ZonedDateTime expiration(); +// @JsonFormat(pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", locale = "en_US") +// ZonedDateTime expiration(); + // FIXME: AMM-devnet has a different date/time format -- we should add a custom deserializer to try a bunch of + // different formats maybe. + String expiration(); /** * The amount the auction owner paid to win this slot, in LP Tokens. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java index bc1ebdd4e..89ad009c9 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java @@ -75,8 +75,8 @@ default boolean asset2Frozen() { * * @return An {@link Address}. */ - @JsonProperty("amm_account") - Address ammAccount(); + @JsonProperty("account") + Address account(); /** * Details of the current owner of the auction slot. diff --git a/xrpl4j-core/src/main/resources/definitions.json b/xrpl4j-core/src/main/resources/definitions.json index ab3bc26fa..6af60fcf3 100644 --- a/xrpl4j-core/src/main/resources/definitions.json +++ b/xrpl4j-core/src/main/resources/definitions.json @@ -283,6 +283,16 @@ "type": "UInt16" } ], + [ + "DiscountedFee", + { + "nth": 6, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt16" + } + ], [ "Version", { @@ -333,6 +343,16 @@ "type": "UInt16" } ], + [ + "NetworkID", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt32" + } + ], [ "Flags", { @@ -776,7 +796,7 @@ [ "VoteWeight", { - "nth": 47, + "nth": 48, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -784,9 +804,9 @@ } ], [ - "DiscountedFee", + "FirstNFTokenSequence", { - "nth": 48, + "nth": 50, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1493,10 +1513,40 @@ "type": "Amount" } ], + [ + "BaseFeeDrops", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "ReserveBaseDrops", + { + "nth": 23, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "ReserveIncrementDrops", + { + "nth": 24, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], [ "LPTokenOut", { - "nth": 20, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1506,7 +1556,7 @@ [ "LPTokenIn", { - "nth": 21, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1516,7 +1566,7 @@ [ "EPrice", { - "nth": 22, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1526,7 +1576,7 @@ [ "Price", { - "nth": 23, + "nth": 28, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1536,7 +1586,7 @@ [ "LPTokenBalance", { - "nth": 24, + "nth": 31, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1873,16 +1923,6 @@ "type": "AccountID" } ], - [ - "AMMAccount", - { - "nth": 11, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], [ "HookAccount", { @@ -2186,7 +2226,7 @@ [ "AuctionSlot", { - "nth": 27, + "nth": 26, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2196,7 +2236,7 @@ [ "AuthAccount", { - "nth": 28, + "nth": 27, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2296,7 +2336,7 @@ [ "VoteSlots", { - "nth": 14, + "nth": 12, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2356,7 +2396,7 @@ [ "AuthAccounts", { - "nth": 26, + "nth": 25, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2378,6 +2418,9 @@ "telCAN_NOT_QUEUE_BLOCKED": -389, "telCAN_NOT_QUEUE_FEE": -388, "telCAN_NOT_QUEUE_FULL": -387, + "telWRONG_NETWORK": -386, + "telREQUIRES_NETWORK_ID": -385, + "telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384, "temMALFORMED": -299, "temBAD_AMOUNT": -298, @@ -2417,8 +2460,7 @@ "temUNKNOWN": -264, "temSEQ_AND_TICKET": -263, "temBAD_NFTOKEN_TRANSFER_FEE": -262, - "temBAD_AMM_OPTIONS": -261, - "temBAD_AMM_TOKENS": -260, + "temBAD_AMM_TOKENS": -261, "tefFAILURE": -199, "tefALREADY": -198, @@ -2506,12 +2548,8 @@ "tecINSUFFICIENT_PAYMENT": 161, "tecUNFUNDED_AMM": 162, "tecAMM_BALANCE": 163, - "tecAMM_FAILED_DEPOSIT": 164, - "tecAMM_FAILED_WITHDRAW": 165, - "tecAMM_INVALID_TOKENS": 166, - "tecAMM_EXISTS": 167, - "tecAMM_FAILED_BID": 168, - "tecAMM_FAILED_VOTE": 169 + "tecAMM_FAILED": 164, + "tecAMM_INVALID_TOKENS": 165 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2552,4 +2590,4 @@ "SetFee": 101, "UNLModify": 102 } -} +} \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index abb8d081f..b32c4dab5 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -28,7 +28,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( AmmResult.builder() - .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -45,11 +45,12 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration( + .expiration("2023-Jan-07 23:47:21.000000000 UTC") + /*.expiration( ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) .withZoneSameLocal(ZoneId.of("UTC")) - ) + )*/ .price( IssuedCurrencyAmount.builder() .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") @@ -86,7 +87,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { .status("success") .build(); - String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + @@ -128,7 +129,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException AmmInfoResult result = AmmInfoResult.builder() .amm( AmmResult.builder() - .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -146,11 +147,12 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration( + .expiration("2023-Jan-07 23:47:21.000000000 UTC") + /*.expiration( ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) .withZoneSameLocal(ZoneId.of("UTC")) - ) + )*/ .price( IssuedCurrencyAmount.builder() .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") @@ -189,7 +191,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException .validated(true) .build(); - String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + From c3b6d3145f040fa2634cfd649b2521e48907e831 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 18 Jul 2023 11:25:33 -0400 Subject: [PATCH 35/53] Renamed AmmResult to AmmInfo. Renamed AmmObject.ammAccount to account. Remove json aliases from VoteEntry because we have AmmInfoVoteEntry. Remove bounds checks on TradingFee to avoid parsing errors. --- .../amm/{AmmResult.java => AmmInfo.java} | 30 +++++++++---------- .../model/client/amm/AmmInfoResult.java | 3 +- .../xrpl/xrpl4j/model/ledger/AmmObject.java | 4 +-- .../xrpl/xrpl4j/model/ledger/VoteEntry.java | 4 --- .../xrpl4j/model/transactions/Wrappers.java | 11 ------- .../model/client/amm/AmmInfoResultTest.java | 9 ++---- .../xrpl4j/model/ledger/AmmObjectTest.java | 6 ++-- .../model/transactions/TradingFeeTest.java | 18 +++++------ 8 files changed, 32 insertions(+), 53 deletions(-) rename xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/{AmmResult.java => AmmInfo.java} (90%) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java similarity index 90% rename from xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java rename to xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java index 89ad009c9..b20bfc559 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java @@ -19,19 +19,27 @@ * responses to {@code amm_info} RPC requests. */ @Value.Immutable -@JsonSerialize(as = ImmutableAmmResult.class) -@JsonDeserialize(as = ImmutableAmmResult.class) -public interface AmmResult extends XrplResult { +@JsonSerialize(as = ImmutableAmmInfo.class) +@JsonDeserialize(as = ImmutableAmmInfo.class) +public interface AmmInfo extends XrplResult { /** - * Construct a {@code AmmResult} builder. + * Construct a {@code AmmInfo} builder. * - * @return An {@link ImmutableAmmResult.Builder}. + * @return An {@link ImmutableAmmInfo.Builder}. */ - static ImmutableAmmResult.Builder builder() { - return ImmutableAmmResult.builder(); + static ImmutableAmmInfo.Builder builder() { + return ImmutableAmmInfo.builder(); } + /** + * The address of the special account that holds this AMM's assets. + * + * @return An {@link Address}. + */ + @JsonProperty("account") + Address account(); + /** * The definition for one of the two assets this AMM holds. * @@ -70,14 +78,6 @@ default boolean asset2Frozen() { return false; } - /** - * The address of the special account that holds this AMM's assets. - * - * @return An {@link Address}. - */ - @JsonProperty("account") - Address account(); - /** * Details of the current owner of the auction slot. * diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java index cb41f8e6b..fbfd7e239 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -7,7 +7,6 @@ import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; -import org.xrpl.xrpl4j.model.ledger.AmmObject; import org.xrpl.xrpl4j.model.transactions.Hash256; import java.util.Optional; @@ -35,7 +34,7 @@ static ImmutableAmmInfoResult.Builder builder() { * @return An {@link AmmInfoResult}. */ @JsonProperty("amm") - AmmResult amm(); + AmmInfo amm(); /** * (Omitted if ledger_current_index is provided instead) The ledger index of the ledger version used when diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java index 95619581a..14464b26a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java @@ -74,8 +74,8 @@ default Flags flags() { * * @return An {@link Address}. */ - @JsonProperty("AMMAccount") - Address ammAccount(); + @JsonProperty("Account") + Address account(); /** * Details of the current owner of the auction slot. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java index 29dbdbc47..5fbbb15a9 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java @@ -1,6 +1,5 @@ package org.xrpl.xrpl4j.model.ledger; -import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -32,7 +31,6 @@ static ImmutableVoteEntry.Builder builder() { * @return An {@link Address}. */ @JsonProperty("Account") - @JsonAlias("account") Address account(); /** @@ -41,7 +39,6 @@ static ImmutableVoteEntry.Builder builder() { * @return A {@link TradingFee}. */ @JsonProperty("TradingFee") - @JsonAlias("trading_fee") TradingFee tradingFee(); /** @@ -50,7 +47,6 @@ static ImmutableVoteEntry.Builder builder() { * @return The {@link VoteWeight}. */ @JsonProperty("VoteWeight") - @JsonAlias("vote_weight") VoteWeight voteWeight(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index 53b1c9a86..2c8beceb1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -417,17 +417,6 @@ public BigDecimal bigDecimalValue() { return BigDecimal.valueOf(value().longValue(), 3); } - /** - * Validates that a TradingFee is not more than 1%, or 1000. - */ - @Value.Check - public void validateBounds() { - Preconditions.checkArgument( - FluentCompareTo.is(value()).lessThanOrEqualTo(UnsignedInteger.valueOf(1_000)), - "TradingFee should be in the range 0 to 1000." - ); - } - } /** diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index b32c4dab5..51d80c61b 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -16,18 +16,13 @@ import org.xrpl.xrpl4j.model.transactions.VoteWeight; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - class AmmInfoResultTest extends AbstractJsonTest { @Test void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( - AmmResult.builder() + AmmInfo.builder() .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( @@ -128,7 +123,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { void testJsonForValidatedLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( - AmmResult.builder() + AmmInfo.builder() .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java index f52b94da3..d6d1bd329 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/AmmObjectTest.java @@ -30,7 +30,7 @@ void voteSlotsUnwrapped() { AmmObject ammObject = AmmObject.builder() .asset(mock(Issue.class)) .asset2(mock(Issue.class)) - .ammAccount(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .account(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .lpTokenBalance(mock(IssuedCurrencyAmount.class)) .tradingFee(TradingFee.of(UnsignedInteger.ONE)) .addVoteSlots( @@ -53,7 +53,7 @@ void testJson() throws JSONException, JsonProcessingException { .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .build() ) - .ammAccount(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) + .account(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) .lpTokenBalance( IssuedCurrencyAmount.builder() .value("71150.53584131501") @@ -100,7 +100,7 @@ void testJson() throws JSONException, JsonProcessingException { .build(); String json = "{\n" + - " \"AMMAccount\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"Account\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + " \"LedgerEntryType\" : \"AMM\",\n" + " \"Asset\" : " + objectMapper.writeValueAsString(ammObject.asset()) + "," + " \"Asset2\" : " + objectMapper.writeValueAsString(ammObject.asset2()) + "," + diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java index 69d43570f..16aa2f272 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TradingFeeTest.java @@ -37,6 +37,12 @@ void ofPercent() { fee = TradingFee.ofPercent(BigDecimal.valueOf(1.0000)); assertThat(fee.value()).isEqualTo(UnsignedInteger.valueOf(1000)); + + fee = TradingFee.ofPercent(BigDecimal.valueOf(0)); + assertThat(fee.value()).isEqualTo(UnsignedInteger.valueOf(0)); + + fee = TradingFee.ofPercent(BigDecimal.valueOf(0.00000000000)); + assertThat(fee.value()).isEqualTo(UnsignedInteger.valueOf(0)); } @Test @@ -57,16 +63,10 @@ void bigDecimalValue() { BigDecimal percent = BigDecimal.valueOf(0.001000); TradingFee fee = TradingFee.ofPercent(percent); assertThat(fee.bigDecimalValue()).isEqualTo(percent); - } - - @Test - void validateBounds() { - assertThatThrownBy( - () -> TradingFee.of(UnsignedInteger.valueOf(1001)) - ).isInstanceOf(IllegalArgumentException.class) - .hasMessage("TradingFee should be in the range 0 to 1000."); - assertDoesNotThrow(() -> TradingFee.of(UnsignedInteger.valueOf(1000))); + percent = BigDecimal.valueOf(1, 3); + fee = TradingFee.ofPercent(percent); + assertThat(fee.bigDecimalValue()).isEqualTo(percent); } @Test From f4d04bf337c1ca8b9aade5aa95bf6c180df0cf14 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 18 Jul 2023 12:23:28 -0400 Subject: [PATCH 36/53] retype AmmInfoAuctionSlot.expiration as a ZonedDateTime --- .../xrpl4j/model/client/amm/AmmInfoAuctionSlot.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index 7197b4582..ef880765d 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -1,12 +1,10 @@ package org.xrpl.xrpl4j.model.client.amm; -import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; -import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; @@ -63,12 +61,11 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { * * @return An {@link ZonedDateTime} */ + // rippled reports the expiration date/time in ISO 8601 format, which is natively supported by ZonedDateTime. + // Therefore, this field does not require a @JsonFormat annotation similar to how other ZonedDateTime fields + // are annotated in this library. @JsonProperty("expiration") -// @JsonFormat(pattern = "yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", locale = "en_US") -// ZonedDateTime expiration(); - // FIXME: AMM-devnet has a different date/time format -- we should add a custom deserializer to try a bunch of - // different formats maybe. - String expiration(); + ZonedDateTime expiration(); /** * The amount the auction owner paid to win this slot, in LP Tokens. From bd32fa0e867d2f9df20723b7a8c38b4906302e3c Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 18 Jul 2023 12:26:34 -0400 Subject: [PATCH 37/53] add en_US locale to expiration ZonedDateTime --- .../xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index ef880765d..3b21af80e 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -1,5 +1,6 @@ package org.xrpl.xrpl4j.model.client.amm; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -62,9 +63,10 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { * @return An {@link ZonedDateTime} */ // rippled reports the expiration date/time in ISO 8601 format, which is natively supported by ZonedDateTime. - // Therefore, this field does not require a @JsonFormat annotation similar to how other ZonedDateTime fields - // are annotated in this library. + // Therefore, this field does not require a @JsonFormat(pattern = ...) annotation similar to how other ZonedDateTime + // fields are annotated in this library. @JsonProperty("expiration") + @JsonFormat(locale = "en_US") ZonedDateTime expiration(); /** From 50f1e4c282609d8b6f9a15447b88cca98db62b13 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 18 Jul 2023 14:26:22 -0400 Subject: [PATCH 38/53] add AMM related transaction metadata mappings and fixtures. --- .../modules/AffectedNodeDeserializer.java | 3 + .../xrpl/xrpl4j/model/ledger/AmmObject.java | 2 +- .../transactions/metadata/MetaAmmObject.java | 111 ++++++++++++++++++ .../metadata/MetaAuctionSlot.java | 84 +++++++++++++ .../metadata/MetaAuthAccount.java | 27 +++++ .../metadata/MetaAuthAccountWrapper.java | 26 ++++ .../metadata/MetaLedgerEntryType.java | 1 + .../transactions/metadata/MetaVoteEntry.java | 47 ++++++++ .../metadata/MetaVoteEntryWrapper.java | 26 ++++ .../transactions/TransactionMetadataTest.java | 3 + .../metadata/MetaLedgerEntryTypeTest.java | 1 + .../resources/tx_metadata_fixtures.json.zip | Bin 1232809 -> 1235823 bytes 12 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AffectedNodeDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AffectedNodeDeserializer.java index 25cde0d03..da326cd40 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AffectedNodeDeserializer.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/AffectedNodeDeserializer.java @@ -31,6 +31,7 @@ import org.xrpl.xrpl4j.model.transactions.metadata.CreatedNode; import org.xrpl.xrpl4j.model.transactions.metadata.DeletedNode; import org.xrpl.xrpl4j.model.transactions.metadata.MetaAccountRootObject; +import org.xrpl.xrpl4j.model.transactions.metadata.MetaAmmObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaCheckObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaDepositPreAuthObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaEscrowObject; @@ -117,6 +118,8 @@ private Class determineLedgerObjectType(String ledge return MetaTicketObject.class; case "NFTokenPage": return MetaNfTokenPageObject.class; + case "AMM": + return MetaAmmObject.class; default: return MetaUnknownObject.class; } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java index 14464b26a..5eea812a8 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java @@ -107,7 +107,7 @@ default Flags flags() { /** * A list of vote objects, representing votes on the pool's trading fee. * - * @return A {@link List} of {@link VoteEntry}s. + * @return A {@link List} of {@link VoteEntryWrapper}s. */ @JsonProperty("VoteSlots") List voteSlots(); diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java new file mode 100644 index 000000000..1ad4aaf46 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java @@ -0,0 +1,111 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.flags.Flags; +import org.xrpl.xrpl4j.model.ledger.AuctionSlot; +import org.xrpl.xrpl4j.model.ledger.Issue; +import org.xrpl.xrpl4j.model.ledger.VoteEntryWrapper; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * Represents an AMM ledger object, which describes a single Automated Market Maker instance. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaAmmObject.class) +@JsonDeserialize(as = ImmutableMetaAmmObject.class) +public interface MetaAmmObject extends MetaLedgerObject { + + /** + * A bit-map of boolean flags. No flags are defined for {@link MetaAmmObject}, so this value is always 0. + * + * @return Always {@link Flags#UNSET}. + */ + @JsonProperty("Flags") + @Value.Derived + default Flags flags() { + return Flags.UNSET; + } + + /** + * The definition for one of the two assets this AMM holds. + * + * @return An {@link Issue}. + */ + @JsonProperty("Asset") + Optional asset(); + + /** + * The definition for the other asset this AMM holds. + * + * @return An {@link Issue}. + */ + @JsonProperty("Asset2") + Optional asset2(); + + /** + * The address of the special account that holds this AMM's assets. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Optional

account(); + + /** + * Details of the current owner of the auction slot. + * + * @return An {@link AuctionSlot}. + */ + @JsonProperty("AuctionSlot") + Optional auctionSlot(); + + /** + * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens + * can vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's + * assets which grows with the trading fees collected. + * + * @return An {@link IssuedCurrencyAmount}. + */ + @JsonProperty("LPTokenBalance") + Optional lpTokenBalance(); + + /** + * The percentage fee to be charged for trades against this AMM instance, in units of 1/10,000. The maximum value is + * 1000, for a 1% fee. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + Optional tradingFee(); + + /** + * A list of vote objects, representing votes on the pool's trading fee. + * + * @return A {@link List} of {@link MetaVoteEntryWrapper}s. + */ + @JsonProperty("VoteSlots") + List voteSlots(); + + /** + * Unwraps the {@link VoteEntryWrapper}s in {@link #voteSlots()} for easier access to {@link MetaVoteEntry}s. + * + * @return A {@link List} of {@link MetaVoteEntry}. + */ + @JsonIgnore + @Value.Derived + default List voteSlotsUnwrapped() { + return voteSlots().stream() + .map(MetaVoteEntryWrapper::voteEntry) + .collect(Collectors.toList()); + } +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java new file mode 100644 index 000000000..c718918d6 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java @@ -0,0 +1,84 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.primitives.UnsignedInteger; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.ledger.AmmObject; +import org.xrpl.xrpl4j.model.ledger.ImmutableAuctionSlot; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; +import org.xrpl.xrpl4j.model.transactions.TradingFee; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * Represents an AuctionSlot object in an {@link AmmObject}, containing details of the current owner of the auction + * slot. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaAuctionSlot.class) +@JsonDeserialize(as = ImmutableMetaAuctionSlot.class) +public interface MetaAuctionSlot { + + /** + * The current owner of this auction slot. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Optional
account(); + + /** + * A list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance. + * + * @return A {@link List} of {@link MetaAuthAccountWrapper}s. + */ + @JsonProperty("AuthAccounts") + List authAccounts(); + + /** + * Extracts all the addresses found in the {@link MetaAuthAccount}s found in {@link #authAccounts()}. + * + * @return A {@link List} of {@link Address}. + */ + @JsonIgnore + @Value.Derived + default List
authAccountsAddresses() { + return authAccounts().stream() + .map(MetaAuthAccountWrapper::authAccount) + .map(MetaAuthAccount::account) + .collect(Collectors.toList()); + } + + /** + * The trading fee to be charged to the auction owner. By default this is 0, meaning that the auction owner can trade + * at no fee instead of the standard fee for this AMM. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("DiscountedFee") + Optional discountedFee(); + + /** + * The amount the auction owner paid to win this slot, in LP Tokens. + * + * @return An {@link IssuedCurrencyAmount}. + */ + @JsonProperty("Price") + Optional price(); + + /** + * The time when this slot expires, in seconds since the Ripple Epoch. + * + * @return An {@link UnsignedInteger} + */ + @JsonProperty("Expiration") + Optional expiration(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java new file mode 100644 index 000000000..7e1b3ec7f --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java @@ -0,0 +1,27 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.ledger.ImmutableAuthAccount; +import org.xrpl.xrpl4j.model.transactions.Address; + +/** + * An account that is authorized to trade at the discounted fee for an AMM instance. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaAuthAccount.class) +@JsonDeserialize(as = ImmutableMetaAuthAccount.class) +public interface MetaAuthAccount { + + /** + * The address of the account. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Address account(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java new file mode 100644 index 000000000..98a5a5e1d --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java @@ -0,0 +1,26 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.ledger.ImmutableAuthAccountWrapper; + +/** + * A wrapper around {@link MetaAuthAccount}s. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaAuthAccountWrapper.class) +@JsonDeserialize(as = ImmutableMetaAuthAccountWrapper.class) +public interface MetaAuthAccountWrapper { + + /** + * An {@link MetaAuthAccount}. + * + * @return An {@link MetaAuthAccount}. + */ + @JsonProperty("AuthAccount") + MetaAuthAccount authAccount(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryType.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryType.java index b060db762..f1f07f9fd 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryType.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryType.java @@ -25,6 +25,7 @@ public interface MetaLedgerEntryType { MetaLedgerEntryType SIGNER_LIST = MetaLedgerEntryType.of("SignerList"); MetaLedgerEntryType TICKET = MetaLedgerEntryType.of("Ticket"); MetaLedgerEntryType NFTOKEN_PAGE = MetaLedgerEntryType.of("NFTokenPage"); + MetaLedgerEntryType AMM = MetaLedgerEntryType.of("AMM"); /** * Construct a new {@link MetaLedgerEntryType} from a {@link String}. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java new file mode 100644 index 000000000..dab162eba --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java @@ -0,0 +1,47 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntry; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.TradingFee; +import org.xrpl.xrpl4j.model.transactions.VoteWeight; + +import java.util.Optional; + +/** + * Describes a vote for the trading fee on an AMM by an LP. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaVoteEntry.class) +@JsonDeserialize(as = ImmutableMetaVoteEntry.class) +public interface MetaVoteEntry { + + /** + * The address of the LP who voted. + * + * @return An {@link Address}. + */ + @JsonProperty("Account") + Optional
account(); + + /** + * The trading fee that the LP voted for. + * + * @return A {@link TradingFee}. + */ + @JsonProperty("TradingFee") + Optional tradingFee(); + + /** + * The weight of the LP's vote. + * + * @return The {@link VoteWeight}. + */ + @JsonProperty("VoteWeight") + Optional voteWeight(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java new file mode 100644 index 000000000..7c76d55a0 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java @@ -0,0 +1,26 @@ +package org.xrpl.xrpl4j.model.transactions.metadata; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntryWrapper; + +/** + * A wrapper around a {@link MetaVoteEntry}. + */ +@Immutable +@JsonSerialize(as = ImmutableMetaVoteEntryWrapper.class) +@JsonDeserialize(as = ImmutableMetaVoteEntryWrapper.class) +public interface MetaVoteEntryWrapper { + + /** + * A {@link MetaVoteEntry}. + * + * @return A {@link MetaVoteEntry}. + */ + @JsonProperty("VoteEntry") + MetaVoteEntry voteEntry(); + +} diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java index f6567d73d..8c3e9e9c4 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionMetadataTest.java @@ -23,6 +23,7 @@ import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableMetaNfTokenOfferObject; import org.xrpl.xrpl4j.model.transactions.metadata.ImmutableModifiedNode; import org.xrpl.xrpl4j.model.transactions.metadata.MetaAccountRootObject; +import org.xrpl.xrpl4j.model.transactions.metadata.MetaAmmObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaCheckObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaDepositPreAuthObject; import org.xrpl.xrpl4j.model.transactions.metadata.MetaEscrowObject; @@ -808,6 +809,8 @@ private Class determineLedgerObjectType(String ledge return MetaTicketObject.class; case "NFTokenPage": return MetaNfTokenPageObject.class; + case "AMM": + return MetaAmmObject.class; default: return MetaUnknownObject.class; } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryTypeTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryTypeTest.java index fbabdae69..03ce8f461 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryTypeTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaLedgerEntryTypeTest.java @@ -29,6 +29,7 @@ void testConstants() { assertThat(MetaLedgerEntryType.SIGNER_LIST.value()).isEqualTo("SignerList"); assertThat(MetaLedgerEntryType.TICKET.value()).isEqualTo("Ticket"); assertThat(MetaLedgerEntryType.NFTOKEN_PAGE.value()).isEqualTo("NFTokenPage"); + assertThat(MetaLedgerEntryType.AMM.value()).isEqualTo("AMM"); } @Test diff --git a/xrpl4j-core/src/test/resources/tx_metadata_fixtures.json.zip b/xrpl4j-core/src/test/resources/tx_metadata_fixtures.json.zip index f119f16af466dcde07a1a4d0d815c18532ea6122..14d3522c74a666310af3d983f7024e6a5ebccc7c 100644 GIT binary patch delta 17322 zcmV)SK(fE7pG)tyOC3;40|XQR2mlBG3Ul&S0000000000sdAqH82})W9U352R1E+J z)Y!IU+t{{b)Y!IUb$AN^0R;8|000CO0001iH-$F=g*O6)Hv@$?1cf&Rg*OI;HwT3` z2!%HZg*OU?Hw%R~423rhg*Og`HxGq35QR4pwKo#Ckbk~xxr$`T_PxL2Sid(G9vMdfAdgrWGjYY zRJ4$I*d*58Y)}+h2coE=pI@5tp9G43xrz~%+lsZ#(qW#jma4{889AEr#aUBpS22ji zGG)pzUg5k3p4?X{A=upo%E4S8D3V+}r^7qk(}LoJrgKf8IMZ8TD+yxc@<~(%aqJ+hy~;e_ftDf4X1xZa;W-fB*6R{g*$6PLEtvw<6$Fx~)qP zWLy^KB_uCQwr~sF3q;sa8!GOs&szJFm$Z};CKZ>Nys+37KJIaase#72MR~|j9_!JU z@01cUe>5xJ{rBJm43+-*1GYxclcKaTPDz2-5WUo-CU6x>sasWgmCRWxp~U1PQ7p=O z&8&LL*+l2+$lBFv96h<#YN;oT`St$8o%C#L|Hs`=5B9&@TPZ)NX@2zK;qyJMAHPg@ z27~tw4$;RGr6=l#ck8?Fe+CW#ww`h6!jFHhJO4tzwC zTB2l&II^Z6(gojB6#Vf8oQ50+1|csV>_&$oeWBP^$y%s&iCyt?dWTEB9KHOQv#sP+ z3I;=IKyxsb)?@WtYim_Qnbv@1>QJRBheQQb4V>Hv!BNuQm`BEN^)yI(Yz~GA#hr)u zhq=OxUw`@K#+Ns{Lmc6MjMm}SiEQ~a_}_Yf45;a zcDE0ny?JI|KiuAY-q+uMT;1H-^Uu#oi}}N4&K$N3?$2DG6At?Rhp!hM^&+5gV$=hJ z#gLATb=1Cnyt}vepY7GpLUx8#wKPgEI!TEHp??Y{WLuJ#a(U57BAWwO0I3m?O{sNK z!Y!<}>^*ev5~}(tZPwo6b8mRekm#o8Y{A)b&J}p<8~YI9(VMiC&mpMTlJd>REVU3U zTzr$D6%koddDKCnaekZ+99bD|P@*4U%)lfsWv|C3Sl>FluJZq`C)Jq}NSIfuTbQUW z;D26nfxk<~Wq@_bzC%c>k^^iwD3Q%dk{TVjnrqgND0qA})p=cQtZ!_%4LoA|_#@7! zg~Z~!L30~&KQtc^Nqq%_4LXSF( z)I{SXCADQ^QmF=R%|_kWwQ7~Ikb_BQ?V2w+>w%|_E=5b)8YKxfLvgfolBXZO7=Pvm zcWHfVfA99H`S$7kqX!#YzB>E)+1;moOaBzvrnI7bTpg}}cU4!VS+LbE>j60fs*#Y3{ zoE#Eykw^d~3?KosdasU?&pvjk2S^oc>NR<*@GTAAtarxH{PCtq;{w1}zY_O3tvT`{_8 zm+1&*w?!?Sw7b^ygfV zn{045$5!aiAutoNUy~&Yntk&4En*r|S5@mAw32)y=Ncx`<9m{+Y-6fy8o)Tz(t>2P z-FWspxXd&C^G#vD#4+4bih_sFGkzTV)r9Y5YiZ(u)(u&~Gv4VkmpqyhGX{Aifi&NO zmvx#FFMr?dnopcHnGmC%NMiifg8xJ<7#F=~Hctyq*jWDBwBRX)JWle?=tDq8J91t( zox4s%nIc!4bj}jP4K2iMsaV}WPVhgl5h-iUkxMAY>j6%YIy_zZxtl@4j{@EM<; z7(6qJ-AOvx?K5u z|5p0vF4*O2K_`WrEw-a7rUne+u$NAo5+5*ToJpQVo0 zh9d?BcXN#X9G7355*L5}6|8EhHkM**SuXj51-6Qzb}+3mg|=^kj+nK~GyU@o;oVYH z?pB1CGf;L|6*sC9t_G!ol(+nM5`x3d=`w|2qO4PPQW!#kn0U&@ht_o_DQE%GQe{A) zDhpNu(p#%BxyI1E>ZK(=@bra+;4+n&FT)_Q`$^w2WTiVsRNjA&GDs=L!qQ?=Pof1= z_7RBLxSEDRsOTXpOv*J$V;Xj~Kpv(_$vQ_JoH43W@Ncqsrsm&T@V6FRUJJUZ&jcqd z%6olU(9b;+9CK?q!#h{d4At2+9kGdfjZxK7GI$1HlF6i$N^Vx$oWZ!F0tf_MEtRB4 zRpcG51*fY;K4pLEmNDIAM;b(|+8&&7863=#!PdfRld_>Z?zLrZ)O%NnxXKg(8C4vS zkauFUtoPfoZG2lZFMQN@AFsr+xw(DdN`1EeY;~iqem~#KFHvJ8b&7$CGBus#(Cypa z?*6*0!{JiG=|)YCX6?l@x3*7Sq7SfEJ6!c9xB&uxqlpT6hV?s}?er zlU_>_sH#;QDVhqRtD18)mMmSDa+J1uO!+O*Fx2W)_3F)o62mhpWGrBt}ZmV^Z)+Ug%*R^5UF7y)|CoC@1 zlx-Hk)NFqQFG&<#CZjZT9Qa950CA;4@U>^?s~$4U1YBN%yS0J8EYlh3Xi|(h!>;Go z7CLecBe)8c*rH*0*^~_zuBk}@39U+1UO5ZyTSB8;oz^9T=D`yi7s)15s>$OTQ}DPp zZ)Rlofa@u0_}ecG`-KZeVXlXtB?a5ezKW4N46NoraTut&S^3HD^p8rrfw~q zB?uUb1ak~$o0aYaMxTsiSdfF%b}dQKwyKIv*jCE7CS|uhb>s8Q^NuCpYl!8niO~V=2D;2M-aHDRBM53wHAuVT_BGo1DXl%-?|#o}|eaWW+P7 zO=i5A@;26(Vl2|}Q!4DkVffZnu!U1fSqk_`NHkMa9!{us9aKrI!x%<5I(jv-Z^{)^ zn_Pc;_w$|oNBMRRPuK4AyEmJ+A3xfCd4GTJ`Ge3`UVmO0GG*&v3Gq~^*%78}hnA9* zac)Lyu%%5|B?H2z$p*_>^_IKKVlCMh<;b+snuj0ra-kA_4XfUaF3P)VEt|GXx9Xph z;(55L^Ut>&m3l*tTg-uU4S-$t84{&Cj5qrLmRkxwr}SnVci1sYNz59Ju>pVgX{3L_ z(gnjIb65mN34zw${9#9A9SX=^=_UnN5`nH2Pr@0PS}AZJ9ShN|);1~!=CNogm&L64 z4CCh5jdlss%F{~RL}>73+levwh}PI6vNbWDkoU zAi}B%PMsET>Zd5@j(f4P!QXks?5uyidHwC-`pb{+_P?&baqIhWT6 z&IP=nO8Ncld)29G>pMi6=d7`7Cr)UXIkh{+g{_UP&8>Bs-*Eim^WE`rHP?Sq6OAZH zaOLwom-){d$ynw;`Z-fF{|hhJB}84=+Ji>r#WH&BA}EBJj7A0NB@z zzfsfBfRzYB*!F%{ZdG+laQmUDoE5&=#y+wb?m0&wKkaFWdyCiTQlqy@>fB%i0}UZg zx>Uzra@t@H)6~kv4k?<8Q5|TW;VKPFaoWtyTTfmE2axCr1_)gij1CO1pq-?@rrIu? zZ!+&@fB_l9yJl)Vm5_fc%qenejdHU-99CIQAuzZZj46g(q@!+ZF=lB3c&v%e4GpkF zQ;qexnONfN!=5n#mL;wX{7NPt+1ZGFA8&quW%hb56kv&F3y;{?HgWT$NnBX)4;tGI z5&V}PV1aL3H@tqg#K}4zm7RHNaYL9pLpB1146s5k$=o?^|9r&G$(wo?XOc4q zcXOEJm~(5XtPjID*nAatFQ~Dm5)>3&iXAFCl!o0 zr}a6%+<)?Mo#X58n-7wGR1SXV&tIRpZ{hCi-8(N{f6FH}@-b~B#7Wsj@7WDz9vCTd zHlvgG^6h`heS)r{l6upWg6=>)>zjr0iXidbRS!LuS#r6hm$_-#P&G#Kty`!wayjS9 z#ltCaC#Gb^JB~?2g}CsZK~^gqZB{h|44-47+G35S=vqvHjLh5-9{uKmD?oW2O=o2@u7mOub?l5Z#or61OR|^zW`MDFe*2B)pM@(h(X9sulOzd)(W~UM@ zG#+0+bD3w+tY6SKM(+ZfFv~ZN5_H#kTK!wj{mOFAOfBao?EiM1a?Z_@b7LC7nI4n; zqL;^~5-1MkdKV0=QDQEfJ7cK$U6=i*5*~jGdY7&;C#Pd++F_4|;;5LYEEHL9o_v3M z_eVEhKMr{gR>q8KpR13P@N@Xc^#%Z@T(-*$00iNA#c^!CRE(@*SmekV$yIQwN8kj1 z&-mS!o~RNS1fm&UM3=g#5-A(YDy`%;RM^^DKeWsp$BQ;UoN^;9ru^rMpi`Irs1g|) zfA^Lq7hbSY4F6h>7k@MSUzy?4)C_;ZBi-wlGN}?V0UDQNsS-5@UUYD>!CiWnps5lV zf0>W_ryW5oYynevuM02O<%SVhdkW0ikdUONl8x}2%~;4L%1&3GV@<$PN-ekI6;UCK z6<-L(CNm#grqrWTqRlMVaveeHr9~dWsnIQk)iaTJWcP*ZjVDZrUY8k9$PGj%HWx^{ zoH0sUN;W-Vh{0K}JMi>H;|YUFv^UruF&`m#>!+^S z+)D{5k?kp{tR!16CyNhrVEnEN9b@oR8-Z8WCy#&cT1n1fbNEq5;{@ILDR{pH-HjD= z6S_ovesgm9B6*mRc1rgSe8Ntz#;^rQxs)PAkoCUXrc`e_=;#ZFYATJWtT-j4f99g3 zMWHm?@+B0Nb>*h43#KdUO)Z2S5|uHMnC83|z2jPyEH+Dp~ zmbwpe5D1K+3U$yuoQ5vPI|eTre+Rf;p0yMxbdQAukevdB%j8*Diy}FhtZgU5ru3S6 zZ^^q{O(NqRM4FSng4|t~%=?}oK_WbewCZbPc^02*N@2Kf#!Uq|2ar?VP0X=kHQif^ zp%|s$h%JFfSY?tftI lrA@!%Udj6f6i@hZ92Vv z#%rErT2uPt#lj)h;n%SPy=_Xdn-c1N^?=x=Tfh|T|H2D4O30btLhjcT za#K_c*pQ&u`j(U9B<&VG>n9T^Ljy`Pbz5AKLn5oAvpV=B*BGGuz!(kw3O{Ir933;K zdh~H4&ia1_uBB5RHeL5w|AiOq zYG}){!;HjTW8*AATmIMyc*M?$M@(k)X9jn3jQ&Q;{xG%dpRfSfHOl@|;gC_`jT!A2 zVUgJdxqV$k-USzJ(@lfU=xlYOn^s#aodUy-@U!}xW(JeYWwN!r|+NX^WCTY<=2D3lulz~ycN71Ri9+?yiP1t ztrS>s4B+l6#Fio$e_fE;6jcKvqzhy9K2*mc=q_CuORo-K3MYE11?b%>mIB`PX9WRM95gi%^_}6Ztv?}x_#I6ea91Isr%{TJ>Fak4?OQj*`xnLyy`tXUo zCVk7Y^|Ou?FXB?kTa%nGsaY>YO$9a6 zrCz_VnYs`Sf2+TTu$fzk=B$95A#8FdMco)C&K^+eUC6p5+k!Tr@X|re?T)8Z>nQ2d2LV4VqWLVFulsL4!ZLNd$ z)k9!!f6Zq0*1Ki1S;%c~+l|wYID-_E4Q>v@adrU*F~D#@U}9`6SVB29))boW&1bJl z)wL$l;jgsxOT6BNsrBnx`w$l9xJ%AA_{-Uk`?WakHCVtD-s{2(cDWpv@fk7ns*=mB zlM2T7+%xEIZNW8(*!ZHz6dw!)QW=a_tB47sNhZA@ua@IZi8ixb%cXMMg$(#K$NloH z@yaT{$X~yGzWs_mKHT2^`qaP7=IiZ)jhDlzpkC{6%Yyg&piWf$m=xu1z#7j)xJ#Gy zuM#lvcVR&LUeyy8z``u38d;itGt>N9%AI80T`utno zd12f3%EtSbfv^%4e;(_9y#4CnKkNJVwtrgJetZ7n^|OQ5Pu4$geA;~c`Pi$`vcu`{th%MHoQoNA0a&V~ zXQgy%kUX_U{Mk%wXT`!?we!c^o14G}f4;CyJ|tyQjYbaUOUXL- zXj}1)xr?mxF#BYrq-BsccrkGg;{w7yE+Vm)UMP?>BEYGMK3CV_1a$8rKv-n_OdnjZnUpbIn_DY+cV$gXr3H)dFxFk%Mf?0yRVY@15rr1d6!i;AyATwN2>N# zDHjdUC|1tYe{5QQo)#f<5Bu7Ox7+XMK%CEPI?H)c)&OzQ?9`GfK1LWg{xb)eEJdDj zE?9AxLa|0uZ}7UB=X1Kc{pmB{M}Y0;cHT?w(Z;7QJAfMf?8log@9UjU-+p|wAEkfL zRg1~D&;VSAWz$nNfD0qX zewgqaLE`7H;-BlFuVfug3fT+4-Z`r=RWS8%w14d9pH>j3u&k3a(QM3s+Q22{0E(Nj zFKsM=e?d}8!(4)2QUmq%)J>GS_%4|opku)(bB>eBRfbmsx_WJDmM*9biym|!n8%HfOm;dK3l|*#=qQ zj4Py0;ukeKTT0NWHsWGZp^!oeHkrzXDKYFif5-uYgK-z-0_Z~muPA<$XP@dw{G@Gu ze7f~*?eY7sZ@+zTx9y{YzUH=Vcy<5wQ}g}BsSD7@=g&D0>BrWE>92#d zLsXJt>zz0F9q%N%VL{5tD_4!?0}zdgUt8S5ZTz^2g_u$3LXRlZKM;_XT z1V&?w$7WpgtnVDx@Y=q4_x;=c9k^Lp7qZfm4Ae&*Im71xkRWnPvVTdm z;5I1(on|nTMzj|LfV0ImZ0$|Ue;w-Ra%#GU3`$*NG1$2=^u!J?oFs3j6?WZrut(c` zE4E5Z`>G<^lWm828{+((JDeg+3JYw2EN7dX&ktx@DOsqkyFftu!~XWe?_bwH{LnAU zqj>+7ZX2uj-`_rXoZlV1_oqsx{T0x*0K8klv$9ys$ZqP&X93Fu!Q89Zf0*$V90c}+ zH?O8_vXb4rDp z4@Ht%8~d($0@qTWlvd8bk;*Mq15i+M^3_!dhAh4$b#j(U^xILJe@Bnl44daA`b{>t zLGv9lSD1BkJl=dU4&RtfP}SjsTel5FRXZPQVg_OLlzTSmGV4FQe*N0=UcbYB|HJL? z2L*4iV#}TNhi_KtZG83P!C=ThF1{=91fCsN9*!C40pfu@1xe+n?EX+&sT{HUun#3y zESOH2ZB8n8%rj_RfA=ENut7N_UqduOw1ra?Y?_f>J74x6O^Z<{ka=9F?`Q_b^o7VQ zu{f(t#XzG^P@y3xT}W%6Q|_fumpo{$1;f#``D9`<(O_dJS1-`Wd(tzjhuhyipH+Nk zkF(U7$y~yGPvV3HRCiZ_3Bc~=9kiqE)~Zr7Y@q-?Tq05seF}_|5+&)7RcfRbAh5epimW%l*HT?-^8xd%I=(b6nl}^6cBn^Y`i1i}n5fmwL(D;w3Kw-p!Q+ieS9z zt@}VtX)k$(P!Fs)5xDMU+$vmbw;ZR(+D2JkH9t&pk}?n7DLgW$37bNDB9l^;oPCh3 zoNY`HX|}jP#VII;1X6z!pe#~M5Eoe`a?xm8dQ7U88OfXTMZ?jo&|IJ&p$sP5;=i^s zSja?ADucwT%5_YQP33ZwTq5ry7aiG2^b|%waM@a0`u_Oo_!tH_r5&d{p8=>-Qm^OvH0D`-*)!vvxgx)9U?FR2<&2Xiv~Rh zZ^#5~bhH!JL~!sB9TK>K#l+U5^-4*@v0SySxkRnG5U64Aa3Cd`>a((jRq0sCX6zFD zQhil(H{J6Jz!1q@6zukHI>ihk@`*Cl`XpC~+YOTyvMkBSb zf;*d+m%0)%L!1<=2RZN0w>-NwZh%dlhjJr3?;U>E%#2YTt^xx0NSlN0+h1R=yj z5B7Rv>VVswruKR1}XBte`6DruBstP+8IE+vLlx> znQA1jwuplQDX!X$D2Zf)w{9Gkk8Hj(jOC6X(gVw@Up}O-cTMm7>$j`751!YLJFmAt zZQOaBzP{go72hA|?ZLBr?E>6B&yF<{1;Bh9wB4b@Y_Eb`HsP9v;2r7(`T+rL2!> z)^x24xQPkSRsh@FTd2gvODcI{N&#Q*O)jQsNI{pSGwYc9U3lxuAiidmpXt39FW-bO z`CvQ6Pn+Mi?&j6@^ojoZ=E3$>9x^O=dX}1HfR))*f8^%)^1(z2=@~ekVFCJ-?G36Z zS=AwQ;W@!Tq#hop)Mhy>?ty%aGf6}_zicDKyULCg%W{b*)J7*CUvPSElY zQiNawCR&#`c(IdgJdiOf=r&ZI9)k^+3*qP}*#n`P+890)9Z9dv2?8M>AHbtpaP?`;8OrrN+?;73N zz|YyT1mF1X+UrO9y9s^$_V)JOm9X->K6%=nzc4FzUapqeyXV+Hp1lrFCdLBlnJwIc z$x)YrSB6nIPEvD1rCwmwUD@iC@!+k#%0S8Te^6P1w{Gj*r-QZc_WSzkkMAFEf4F0w z?0)k*_WfP^=5cy>=Ewd#m)uz@iEa5HNDNI!4v-<)n<|Hja0-DMqy?MSyd+~{&w#xj zHe~_*aU~swxv~NKnYms5xTnjWLzbkGQhc*f2d)jisW!_=yCTIKp)adpuZ#wE9M<|s ze_pmPK6d0*oamnJ#Sd84C$NQ69l9uU$99Vve7V6SQ!JLDTyy}ilW9h0=X*&C09Uan z&N!dD3vlVR)jI7huB@3Y&^)vD+2+zM))rpagKVVSfS!aus$`T%jftiR<^+TCTC*JY z%~+>PIA2LHwr;6GaF%2Wu->FlT-HWQe>xV+;UR1{RqG)$eXcOT%tDYcaOM%M+(#DK zmI7U0poE1F^KS!@O)1G=mvO)n8GlOU?g#qeW_q*LAJI$V@bdku zvKn5k^!=}^58}#Q{``3mckt~>f_Nu`tOxt=PnENn2TL<5U<@lYKNtt_^2C9gWJ!3fCFiV~k$b3KY8prxjB(`B zUKzQZgDiA*K9{imQ`rZq$_ciwB~WBwyNyIMt{!um0xard9yo|5qUh{d=}71u_kiI zcg&sLSFi8yzT5qLfnhFUHe-e>W15{?d;i1Niw<@X?>T0$7}B3(-I|jK>;aQbjzi_d zG=S7gm_5pMdtW2ik?$mh)SC8&h3QEGq^d@`HignV4LtoXr12iAO53xTH)}IJ-rd{# z&wuvnXURVrCacavY%^e;e9uWrp#vo|1s4h6=ekK0$wM57GB-ZC0;TSyWFHiM9}D|` zS*Yw)ZEuQ&($9F=p9{Z?;#poOWNr$IjO9#M6I`ltwS^W6>FApBQLZZ02p0>omKnat z_{c`e6l-wr^WrH`+qnkUp!6E|(7479u7BP@R8sX?5N zae0=GYS7N5>epHic@#`r12!Rr&@_zuoOH9R#PVf#%EjO1&X>>k*MIDP*}C_9@9Etw z`t;z=-u{C%{pi_`y|P03;m|uVgGxD=Xz;fzLvCD-1GxAbKKyulolTD0UmvaTyMHHN z_r88i#H(p!`5*1n07jpKei&c?|C8+h-dNR`it@^^GlhU}1=2Tl z`6CqR)z)fmr4~w6d6;mYT`T%8^nVM?hO|C*+=}L73~z4V{rvI8i}%AI z9I#?AcOP#lYrUQiS?gO9A{MhYIn@$_SAj}*NqLBA0?XwLenS*<<*0Mio_~VZUbEIg zb7>q|#~IY)*V;CQ2e-`#=*qpdu3NxpgAXQ3b}{hXnCe?gSXPDr0QvTzTdCjLva<<* zA8VU2nTG67pybw}@asB9`RcgWVIsG80oyrqQ`ox} zTu<7UESYsp@|miadmhS5z7oV!7LT6;OUZ)nz>T7k8;05E9!GW!YJcDMcK83xF9<=( zH3Y{qec{X$oIf8+CyRxhwp$>`@MYfMw6Z5Q%IJ%{*XCwP04l0mfx)jF&ANSl?*5#U zdQ!A4(G@Lw%@t}6OA4ke`D;2Fxm}YXg)8=h%0*HMqD@?@F2*+y=dm8=)TL^?Okn$K zEd<2E=!N(@`KCn_?SBabhX2++>P2&pY4EOoP)yoPnZPMU*a1c^fKau-Spo8~0GVC0 z!OCT`ln%4$<=R_|**YwS|O@G&zV#1;;c_xk z9Y`n&R$Z&siYnIl&*3sbft?&`54puFum59|HgP~cp6~;w3K;#dC#C_p%e(5okR6;# zm#D@PA%F87eAFkC*iPGlb(+CUS{CO9ZL!NNivtu-a&fAYm;18S8;|*f5RwbfO)9y^ z=8|bfS;hhwxjz$)6tAYk9+`7b!~SSFaXw^(zYSzugd!W~qx7olDfA|neMoL~IO}__ z9fHsYEw>AGs?rTuGb9uAl80Ams!6K*C6Kbk_J6_g4nZ8F)J0x2T5!IhOqfh#LrMyB z9HlQ>iN(1hM%Wwxs`5DmDw0w>2?;(OjG#dbeWB@&zaJ} zUqX1n#%Y6*EsL(;LgKw|&mVk#c&9yj&wFc6Kkhuc6YiOv-HjL9_5HIq2XDR)!6vaa zQA%TYGeXcl*#7is{nhp#mkG!c9Ri(~mng^*D}QH~+rrW2NEDXIay*=MAfuMp#+WFs zW1};3vQYL~!)*s@p<16<3K93iE19um($dA6Bts_x*%c(em0Zo)X(6ZJSJAO7>&YB? z{T#OR#*Qwl_kOJPgI9X{^V`=O`|J6|?A{Ety z{g=|n5-$X2=l#r=1<4XNf5Y#ZeVbA-v$~oVbL(5XAA)In+s~eV|Kwl3eS7CEAZhdK z$9J#q`zL#wPX_l5S&qcBuK_P!86lEk)-yVbFMnk)u`iP4n6hHxk}MS`%UBXO_-98J z8Se4Caz(L_V`eDsoIEV@}q#tVike;k3UU=Y3H$CXXk zGzELrbueJ+wgZiGR=PIrY^sWL!LFKp;c?0P!TS7)(VGwd@4xHn+Q0wL!__DK-_IYf z`~r3xM+O|m+UHDeyx$vmc z&mNi+e5cCgdx}ZQf4h&e+e>MBn{R(y`$j#!e*b=dC7I2~PwSUJ@Af}FdiyAReZTp5 z$fDr?#eXhZ0e8rvK(r=AL6!?OS_`w(+SLZtY#VtP5nUV27*_^CVSp`(+XfNh3Lq16uepPBs^Gvye;incj864lbIHcY(I)L-3Q zd-MIvId)18PGcfFwSG#_^WC^6ra(>-M!42wVWr8sYHflnO2t4!J0`$}iQWSpjp*#? zobJmsbUm7me^J>jprH`&y-7Bifg@JbvTa>C%2boeL3OK3?X6nkZj4Hy>)sil*T~Jf zp?1FvdS zqUk;aC~e3rCAT!9kHKXfZ3RMC0OOddSf~8tdBAt!e+q|J0(=)VWxHrE>^Y`9VZEYj zGv$-pd(?hCYsv=tBV%ZQL68b3m%LNzCifVOXICK1D|g8WfG2Jd?!4i3OUFNeD%NYH ze0O#}nGfdky9YkMt6N)dU#>s@xN1MF`seoGJKrw%hSNql$_<%`PJt{>SOX$E15WLu z1ZE0(f73%uFeps7^pMD08o-4)TliDgyf(Ulr{{pB0s`q7M<^q5MGvRLjB%x=ac1%1 zF518_2V>+eTF3$39&R>AK%OFkqmQwgsXO{CCo}A=7jiXND7*yUrIh8WN={Ot zq;SgcwS{sEmiHk@=z0pDb(3zuFl10MyZ3e~;7ANsc?^sN8j!cWAW$_$?Sg>EI zs&M`w4)HS17cYpaH1RpfxH1ek8&%C-0qmxmkqPUA9mRvc& zb&izUVU?+7BLESvLMCY9Zmp?ROV$FQS7YQL&{m}xRg14mN8kVa&Zh5AUmrZokA8f) zb8p4*x_vuS|#iFHQ8z)IL9)8i@g!^QwRj2EXwBV|oGs z#D9Y|lqBs;T9rc=8GIun|dyN*&cq)2_!9_3D2XS{I)QnlE1R?w1iBhS?cH`mBhZe`m1 z*J%bb=>?aS{%q^Xn%(>U`i0&o+wUIxcYo`9ZR>5lot{3?4`03++TR1of0BwNSKI8M zT_0cLOSIba?RF?)_m@#m0xrHejgazqCNZW_r9Gam{omnBI+Iu90>20#e*W0kMpm~ucYmCV z?36L%y=Y~va|gQ!VvZT?@d`9^?vh>64j#2hM-{<|u|{o!Zi>MHU8q@tJlKd3y=(&1 z3e3@HnsbFH23yzLEu0wm>Um8?1dubezeZ?k= z(u}XeesgV2g~HVe6YuWC$6pBhh5+TS$`u3Vc$^yCUpXwhJ!;o1^@`JgyHjcaGM|3< zye(F7LXRE$+96WSSiB1u&C!#eZNs(v^!0~aVDwm}boCgnvp_6OVkbh6cfwT4u zhGUYr-k@tpNp5?Ukh$q(eTCxo`1S&R=skr_3{`c7)txVHBa;&qb&3s)aQfG1>6b)f zF8)Tpxz2d5BiSO(Lt1#1$aX8$(DY&DVY!&rF?8(OmZ+JMDmj~2 zup@`j`p-@2oil$PPtSm-OMeJ&EX0vchBq)%y(qw~n1se(zp8t<~Q z(p_aqxfXA;i7w+;%BA-T_v}=c zW-=rvgh@JXheVeVR=xlH^MQRwYcI_A&5sAW@9#f#_n*CXU)NV(nU%XM4+k@4FDa~Q z+cB(dUgpnvDe^xB-m2IxMui0NTNfbV9MDblZ(Q&ZBFWiC-UH2I-QddK#| zG&NhQEUrJeJ&#uaVh>9mHE0!qySV0{L5iBngtaevp`qc1ID!xDAht)dc2 zc7cN&f#3@r$laINrB@bL)wksSF9_{nSz)@CFzZd#ST{22ann%dW=B2dLD6LNc?5x; z=7`5->r^=G+X_^27-8*7dy{OFE7iTmp5?Z8=n*g^{pZ*#l_-Sj-K_5MztonTAnb9K zeE9b<&|g1$`hOURtZ~ZGiSN0xW1z)QbO?2B@G;QRZsPYb(A393mk?)N2!u|?J9-Jx zbg8!*d@7c7w9&(BG*eqDrr`xU!M#+~Rdbav4-T`Sx&xC9h9-@7Of#5&NSxLA3&dH^ zi!)AmQSX}Ktg}MU7l|{^=(1XU4Tom|B`4Lusxl;|VSgZV_rV%{7?IN?b&Np~2^Mk^Ksym^-zXgsrQm!Q)?YD8a7x|g;9Rlb z^_;QyQ)4RRn_QpQO{qAd2g9$<@~=aGKX3>4whz8<^ViJb)1!}1^6q}WyR*(~`C#SQ zL!XCUYJXU*{vA~IIf84EjWMofsRE{Qbe&R^n^LWJo7536YdSXTfVefq4w5GQXB=d) zl7iyWYS^mz8{>r2US!4RB`_~?4l?Mn|MC?RO!%d;;Y*z8e}p{dYs!*b4CEG-$5*R_ zmj>*=gA%?VI*g=Kr5Lc@;DNgsR+MYEwrF-_qkl~WAQ3?RLW#CHy!5Qo zyj!}Kr>mOvJ3?~fBP1h-DalbeDzD%&V0=v#4_}?7|9fz$o5V3?2acEm70IEZ)VsEk zBUDr@Bc$N*sQa_mUvGchUiim=h5xqwY~5-uabFi zjuPz5K}H#Jvqb`$J$F-Lh4BS!XbY@Wnxuy}tS=WL5r+x8y_boY$M3+?$rHT=tnYW= z>0iHa9AqJ!`TNH~BEvCWQ<}g+d+uh(L6*jk-*J#}Zc{28LWno1!lYdb8a^Fdt$!s> zxn&Jmn?li`Ny(Zlm1I?kq)aA|W^Ka=l=ue;_UrL>H%qWz-U&)=9ZI7o6&o|@-e9eP z5}cbRN)GeWAVN3ofbc9Vo>qC57TEX z>7O`p_Bq$*oAt}goId?tcW=Fn;?AC~;w^t`s+YfAe|K%^Y1_I9^7ZkR`~UxWx;G@g zuI9so$IBnS+yS=wEpOUgEwq) z>yJP6Wc&Pk)hSUo9WlebhWVe*?_0GfOVjPhF&|Vr4?Q`#%zy~(V zQ_stM_Vssde(j>Dy4U680qL!(>;JDh<#gdc(AM~Rduwer*BamOP%-C=uE_!B4_2K5 zmOk$VW?04R-Tl**dYbv1=#{RFxm{v2S(Q^3M=uOodHq7tx_jF$MKvTf7F8OFE9CT2`9UxX=P+*9U_jPpk5022+i=QYbS&wpJ z#68RtBa#zDlhYHD5j-FInjpcfE+EbLQA>gC<9h=ERvBlfrUgC|`ZOKh zG%jlqR6I9-&ivKWBLXH&UNwF8j5*9ADXA0ome}PVOVNLOSM-s$|NE$o6D+DPG6J1y z$bpQYW delta 14327 zcmY+rWl$VW@Su$o92R#7?(R;I;LZkjcXyURfZzmM+}#}(m*DPh!QI{N_rJH^y1Ska zGc{Ay)zvjM)%{HOWwSzAjslsg0xTR3)R!+`p!^NiwW0nmA^dL*rdR_I{se{sp+kW% zp+MMBAY3RAJ`{)$3PcPAehCF4g#wX7fheIs)KDN=C=fjqh!G0J30&VEvZlw8Nbi11rQHkz6c-1kFuTrqd(Daf2vTjPpk9fx zG+5vY3CJvES<-AR4WYDm9PriE&t%8nvvhW8?kCuXw#=O8mSvPPP^%wb6zbOsnSera zb6iOI(h1jo$oP-#9*@7`OWNMIT1J*^G*>LvSbHj-=qMRoXXC4cPw)Fy@5_*nH0>5& z7?;luFYn9Or7o|hy^V?&#IvzHoh^_sI4J?(jJE)7tl#)`ol|o@jMOtbD}_b*Sk(yu zOq2-V21Tj5m@|c$Xg0=sFH?v1r9q zaJq8uM>P~LR-0l*S&Sx`boBY42}5esC2QLil0qN?s?-o~Wm&J*68HfmrNc0Bm*N%z z_|KM}Mph_ku6o6L_}njbsOUWAER4tJ-H$wkicobA7x+TxvGOW@nUj6scu3V#bTgDc#pO@M02x78jV-QM-&Mdh8Nf z_H(dJ+Gkjm?DQIpl?>nn2{UcJ*YqM0Fuvd7+sEY6N!wUtCcxBD`j*KlZ8IjRx0K&8 zrZs3vMvTbj|46z|*SSw>h?rdX(^Rp*@9SEypsqrAd(m5vb!U3Ieb_mLfzh>L#3EK^ z6Zm#LGZs*l)1mBz81jgYJ~O0IM0YaucV0f*|jVrPrs>~q(<;u%$3CQQMyX#pLS9B(FD*@B@Km_W6-5vBCeh5}@L18CHT=dR~ zP5i@O5>)KS_Bb+Bw@^Yc(9LO#lhb1uf8QssZn#iM{k~P&F(mP&-OtIB{H$~9)it75 z^!54t^!9E0J#1xp?c?R&IZFGhwco9U(dU(ogPYw}cLxQ_0UKDrZJD#R+buv@;0Tet z+sJc1Drm4w4FeVLn;^%c+Uvu}=EujUeN6yXJy&IUk(%#}oILdxkQO`TT0%$CSd=ng zg`^ecd(3Zp`Km;Kqe+v+Wu6~cbz#Y-;Q`&qyWcEKiciD}WirLBy2os5Is8l9W?_*( zy2LOzYMsl-@^%`1?b2zx4Zt^!=uh2fOi5j1X>>kKM{`Jm&qBAenX&C@9u5cz=oOb$|IVqrGfthrF1 zV2vauJ)qF3kc^YVb@9KLP$4E3(Jc`VSUEVdDIY1TBDA~T9g~|wT4t~Dr$PMg(a*R@xPm@V3d!(wBXM7@kU zFvI#iJMhjHluEu{a9rE`c`3Q8<5N;G7K#d^1HkZVMe8i z35ZPK#r<9m+p{1bK>hFQA1HYOaTv>cLsGh&fHQTB?~Kdyb~oBP3Pc?`m(h98iAsrs z@If^oI&{G;ofM&EqsMfXCH}*Iq!wn|rC-ebllBvmI4$v?U(`Rz9moR(FqC$k;F--a zO2C9^0A7mZpJndRfBN|!@4QM!Csquw2Mg0VrC9Xngv5SLX2+$2ozehApntr3Fg|6R zOo|~4+@O%*FD#L4rweqyoxZ7i=-VkhIcPe=Q$!ZGZ$`H8XxZpn>9o<4Z?K=vC+!oi z`YUUmd}R?d;Apei>q~K0Y{cPfvGEI}T`Jm_6!~bKEgcYZ-FX-bokQ`I3v|EluhbNt zI+Vjd|HZO;hp!)>Vei~BqfxWC4K{Dw@O=E%N9 z$=u7D2@i_)-0N@@^ve3pDP7HboJkW#towUKy{_$N=C)WZ7K7cy9|d~4Q)uNsg2D#R zkTr?EIN0mv?n3{mXp8! z7&OStUWH1xP5;&ZQ|$$xb$P*7f-W?ZrMZBy7ymK}%nOBYsj9zqoV}$fVm660+NWc(viBY`|KBQigL-%A!cC|$YAqLbuaYbQ^-EXIY zi8zf=Hf5Z-s>$$7(8pB^srqKthWE1xA3KEJuggNU@Nn%$+PI>#&ov^w{OUor9&e41~h4>?7vt@-%!E4wJ_E zYS3`O)hY6`1&lYbi@|dXUvoG?9%HGF^;BqIwH+`fTT#(1M~v-En&eidNgr1^`A#}3 zr1UK!gQ6K@zYhyF=`6m=+Y^VYOfZq(chXhV**iLdJc_!0fa;pnmIC$9_Q9nb34#OS z(rM|+ZbzQ2-Cnhs9A-;3L?|1$1C1l4DTM)=55yZ*`iqC}x2w z1J6+6x;!*`zi}x6uG|(^HnKSQsQf@bhDKqjh@_~BOke}Yr(C+68Sx3_I8H6#x~KL} zqiNw%x+Qx{UEB28M3bsV-aV<$-(pU^(~_3qq6!qWi#HI+BX7X?q3{unS%hUFKiLQ| z3gsPU2q_AM$07rsorf6Is{oJ&kI8c`f=w?QGS>B`egEfs?_nDbw`85|5EwpR2!v()A-r zwl}SVIKtHv8H6h$+m?|;AJ-`TfjbFmsTn&~a=pA<0$vZt4Fw=ZuCxrb2249otIWFI zbnp4b2EY)EynX(Z_1~#cU6kXKM z$@$szGCdS4B$%+Ty(IlBmPJB8XXvO1@%AX13>4HGtIAEWo0D&<yCK5Uocf{}%6GXYcB_Y2$6Lfjt+V3Q(r@#aP024UL;n?K{h+2SC_Asp2 zSi_jJ3|F)T+NG_HSJ%gF7sHXA=Q+f;kMo1k#38>L@-tAkKf%k%1$co{qZvH~b1EsF z)MV7tnn8~6(6SLhZ#7AalfpmUzP3`!3DVBIm=K^AtH@O4^Tff1&$zQxdopp9-%+tx zZ!_jz@xjB89bO^$={u%Y#<$lxK=OSFYS|)(Qmw7uy8*)(Qnc+R?=RS|0a+(KI-Pp3?*Q7;*#?2`3+Xrco z#ox56vEbw;!>#Tjb%Py$D*X&TAQ=DifSZw5Of;_Scw&oLZm)oQHLR1Kct{HtudEQ1 zO4NXiu4g2297;FOq&+Ex61lmeT2$5}p@O>1fF5O;j{2PSCBC-HVyjK-!o(xGNXEIv zh#8}e9EUatTtJrCGdi!=h5Vg}g@3a*iN9i3nQiqJggat(iQq!eyE01--nc! ztuWd|Q3Vs+;}Y+$$9BfHSC3Kuh37DF8+G zY^lQ-8*v57Dt&|1{`$pa?Ntq;wZPJQ9$xIK{bWk~I&9jCPxAAvzJ%t2WiwYHW|OhZ zEd&dd`xpPYI;r1?O^AS^1{1zep*5?FN3Ks;1vm464Huu2hz~A_cs>&Wg}V;BAbUr! zXTnFiZM%EdNJj=Vf;sACdfC0EWHpGrWVnoHbmGNX(?TG$XWNp!n85WnYd=nJdR9Ygc zC%pCj<545Z@?zzmkCJdfO7Rk{CNhH;JKCI3_(kwK_e@(xIp7MDnm2l#(Ah&Evn5`|^Q8<{zB{s+}Syfq(oKrLCr)p=9AZ>B~4O<%qMcuiT2tG2NUV0#C@(&jo{ein>GiD>)??9|2jTk49Zb5sE>U?Z zZ_T$0CuRz?uJu#bWJ8=#lpP$;?AxkNjW52{djIDI47YCQ-fCWYEmM#u0}Zw~(=sDC zMn$T!?U7JMyqvqY?Lcc>9v1>+e=YCvD*pZVgs zNZ!j|X51lCHT8Vo+n{nv;svr7ReW%He$fCufAo=t`L+9b8J&|IXb?aD;syLGJj;JP zL*T-Q#u3Pv8S#7e+y{wD0M+C=ZR91qaggpDxP7$;Ox=>$79)jrOHPRL_en z^MsI0xBY)JNv#?hoV%n$)cKP7-cuA6xUswyL@;4f9BK}AG8*nI#o{tYB<%!!RrCH5XZcX#aT*73qkMYF< z-1&TU-(@G?CtW8MSq^E>K0Om%Cnpl!%!qo@$P(Xj!6zjEdh`WfeAG%cQ`Sr&v(hIW zFhwbV3|av!Rtms%I2x}IXKOSbQ+w41YnA3tud8W|@H#Evi#fDTyPO4X{GQ4YcD>+Q zQ(?PUa{4%beF=HUdH43ZwBp+mL-Rq`9*nllsZdF{LU|gVK!7UNZ>~Uvg4^*KaIx>y zjIK2Ou{TUOqUBsJyA7IpS^@W#0tny=2n}Vx8>IjS;tIy9JzmY_Rb8?AanhkEUa?G9 zD(2$1!^m7NFl8BlkofZZ97o0Be;2IH1YE;bj0G zkea)5eXoI!yK|#iW>O4>A`5TiD&;AjXz&lmuKnE?NZhN6Q1FjsnBptL|I}5WQPn=+ zq&84e$|=zh@9<^R#VaLcRf`U#2NfmhIu0=9OA;`BP!eQ}`#Yzp$0r=9vvmT6 z=w1y6I76Kr;g2pm8iDYM9X-+*Y1tj`K=` z(AI_|#)|u;^H7AEZr43=WRgzyp!WUvy;T%Qb%Tbq-ihe21OqI&MM2p&M(69K0>!ODasa?iZJISVyo*6yT}=F*iXBH9bnM)?KV)yshM(k~b; z;)-Inye4K}$3KrDbf=531$U1`T-k?@V<>XL-H9R0G%1*>87>>Qw}qbeCg{3tSQhDTBG(;fo++d((2<2WJ_aMNsYt!Td?V=o^otrquyO*j$$q< z8vVq)gNrnJL}l#c$#$YX$Smjv){Og!%sifO|3 z^?Bov+~{bm^YHy1^jH(ZkTp2yP3J9CE;_R3ll7xqm!b9_LC=QPZx(6xHi{;Oas;XG z_=6__rLo_p4ca(U3`u(k5K^l7Ew@G*Wwz635%9=!v(y>vrkc3zy-saI2fvs7@hH;e zuiEsr;!M}l;@)c63=0q(TbT?V-kPrV(BG_OfD@w zikF}z!IZIqP%@x3cVY>u1yN~p;^{MP7cD;7MHhyoHKmdw9C73$R8G(8Aa%6vIJHO2 zmQQD3wlki&vFkJQYz;pad>NNwO%BUFO!#w`(NA}ien&dCI3=jw5v@Suq~zLFXxWML z2PIFI247234fMwhVU1&*ivX)pc``-9NTW}foey_j5$t>0XL%yYUHL)UXX!|pehcFm zRy&e~<6)M{?eXL3I^IMi>ITk*>=Ye*U4ktT?;rPrTgP z1rbFdmi@b5{OjKq&1|>(^q#%G<4o=dj{Wv5if2=LFKAW1Q;1YTH-T1BwuO~XxjKCu zp6cg`Jwa}-*bBN5QOJFe$+`M|d^M0u(dNBj`cQ1#C2kh=BF^$jgr|REF1HMYpZ#6P zdb$G!o$F{5mB_r!c6BYkLs=7mztQ+_P&0oC^1XE^h_Ec4`6IY87OT6>kh)9#{)YPq zIX1M=57ermpB^RcWl_c1`^&smlvktFupEZ)(B6);v4#xV&yKgDWs@aiLekN1%`r3J zuRvj{y|WuZYy%4aZ|E>s7;H1MUchKsUGcQPlc=9oc{R@;^v}W~qn&$J#VVtv)$m&O zAp_U0UZY9S`sIL&Q_uhZkngufPyNmVf|B(uvozVe4zne^>`U0DRwwPUn)g@)n$FucJ#b zOZ{cJhNsR$!H=)G%35!!IQx#hL{n0&Or0>=73$R$dv+|0DVuK0IO&^Q3 zhm*l@%A&sMJ=X`kv+;m$qw?2h5)jiE5yDeY{rkb`XC?Xi)`x`w;`x5X2ELJ3P8De7 zspENXZ0FX=8rxYT@ylDk(|sdiyO%3j%hsLbSkCFC;4xGpJxtSlMxR z*WOSEP7XvvpqLkC8`K4PzGv%F1v=0+-|Ff*XhVz{WYkOWQr{dHZ zrp*iV$2FHdbNS(~k_Wn$t=|ffKi?{_Eb}Du>^$w#RagbRz2lxX(c-tz;s$W!?I(TV zddFCK1}6Q;0F{n^V_WgLsYmNLsJafukaLh+-5z1xeY(9bU zzvP|&BQ-=Z<*SMSekH$R-j9MZK5v7GTLA;m#>X4{6;;oJozNxSqxbG@3#oWa;Pvf! z3&#D$VSi4}8Qn4YUE$|Z1ION9BeL$*Ygc-kpGa-TZmtB?BH$iym)|!2X+x_mjW%~(GT{~%-urQ2=XU_Z(&xev)DAux#jW9 zuL&K;c(Tx5sb&d0{$1p<#3$*P$rONlc}#1nCVio5uu^foi9BjMx@*t2@wzkw>LtF1 zDUy7Dr9==Q=8%z-?L;aXaI^E;-XG^UAo{VI)8;_DDg497F|b3>4f1_rgr@Vz08AMUmA_%D5~8+>-Wo(d&9@OlZ8F!v#n zYG~^7JQu4w(T=a9(sA7HY$C1G|wYkU=vK2&+Z9!0~0Z7zI=`d#wrfMhG$d*9~&EJBN7~eD5Is zNm!DAg~f-@vw$_x<;|DN`$y0vx)(`cD*}04L&kX2t4elpi^|66!DM(Q`BpdRvPZ=K z{$=38_Ve$z*Z3am=v8r`ll&5- z3ljaEX20Xn=d;k-IIw2#{|f@ttMbAskI+<@-9!GT*uNNxPvqP(nF7ljCe)UP@zu@D81EOE!M2l&~-^LoIe32E;)D}wCO-MgOUtw(z!mw-C2L^#bzjtERdbDZ`MAIG)aAc^BMitgvL#Mbn9+Fo>kRa=-0PfwNjA+n#X)HeEp(ca#k z^7v}-074`O2KuvjhiK_tREznx%Uu4;$iYDThTwW_@RRQ9to6ouTpR-v4H}I>ann;wt9jNJ0k*t_#4DGLS{2D zTSsJ7^v%`qI!kO){gBoT=~g5L8&7q^0G<}AJ;Q4{wpp)2exf!M=E*tYyF|1(Hc1Ns z1p^^b15fj$vR^vSgmJYZA-p}=S$ei6%A^~bmh4TuOL2cckwQ}8H|?@Nxb1hsOr~l?wavRQg?9CZDspIGnCU^)G<7;q7+~l^=~VInRrrUvY&YS@dAmRsaWRFDu0b@A>)gqZ9FXY!mDxW(azJyH9)% zysFcE_izyF{Nbl*B-Z)0s@fspY+RzsQJlVt$e!rA`!DHlwt`#19bP++!;wvnMMUhz zt`z<43?1Vw9Mz7@)}KBDe>BdJvSK1BvF^V3p~Wl9rxRG#Ya@?3yE1#QRJidpwsyw5iq`@%HGAr8K6)K{ z7Cr5d1aYirV5bLpDZ@F<6z0iKTsoMg&Pct`sPmM>yB}-xV-*MCa>^P9c|xH>2s|bl z)+*-eoN}!FjnaVY4Va^vo!X}EfsX#-|FnMnSnXYmz zPv@jQIKbE-DBUOy zVP1G+(+_lnV8zaeZPH}BLp39j`^f6cW!435)^*ITV3j~-D*o}aho`)_5I!Zm4l15T zds;mrD}Y{<7CuT{=>)u6@d^-Ud(9DkLwx0U6PGjMHmESOsmxH~AOOWFskW7eQQKHS zU6011`fVSD@@UkBuH6WYRjutuSncuqoTlk70JY-Oa@*nT4NDp%o zw*dXJm1|=^V?|PgxEUysJ#~`{ztuyjEaAR7ZPZk8Wug_2bIH@=m(c8LE2Xe-;26j6 zQbq+G^0~@mU3_P3?A$7-W=M-_L=;%_=5G?rM<*X7wU`p#AZ4=B?80lOswVg;ohLBw z(WoMp)k9Ur2rBQz0K zQWlgL`}Q3x7%kP>;NSLua{aaVU}f%>KGY0L?GsE7YnKKrlZF5**+S>E`Kfr3pOVww-6x-)`&F3STLe6GboyIpUv?QXHF!-$bPIz>vlXM^ z=ehJ+;S&p3;cHL}oHGj#e#v+Cl(*L}Fzoi~1tkAW*azj+!(FZ~zD^nCeAJ39E(Lx( zHQroT`!stUd7Xv(J)9@r9j&*#2e3jKGy!Wj67dA-u_P4V>iM+Lad&WFc)p|XR{6*c z{>_H=6SEzKdD)d0M0T@)ec*CyfAdfQi-a@FQ58K|7NF}B`)fF)Bzj6m@<|$L_Zt$T zo$;67{{eN_8~L9NSMkq?Y>biDR;n1ISP8nT9mJmF@jSVP$QA!!{suXMGNzl0o}7G4 zz=5hZRm*e{^}^qtwX5)0)zjDE(#!R+Ja3pN(yL_Ys6|})4uKXy>ed{g|3ieWgf)(Y zu-{}UaFJ1`40P^FFt*=N57}lO!7=WX%WJKSNddVtr}TeYb}V1~X8EFT5|kE7VYWR^ zr3;B;uIIol&lGTNKRaa!VWnD``WhBU+arz2A=1vgP)p$c&33wiAS4328Os_<8dIMs z-4L3Ai-CQ!5Vz3hI}Ne+C@w_)5QYv{;ewJF3EH}Lj-NM-!%UkbCnOmpuZ(ID_m&>S zUToeSH24G8M=qyPv)~?2b^Xiy_klt=p*c?eR`_M^6XlHD$Zd=xC>|p#sotrd+6kJB-~Ek&hb-Os}hb`C#vokV+#A z(M$#_4vZ8_%^m`6+dy{o?U8;A#pMMKQ;*YxG^X$BwbCVy z!g~?0d?N{0x(bszJXDXWo%7uBoCLeWMV-8^0*E?CZ~m+%?^g8~n#tJqMhdyZJ)Wc< z&;wwv-v8V%KJr2x0zP54G{oVJ*YbW|4%C zM%X}=f!Y0%P9M5tYN@v5kjr?^(NN|R;l69dxI2K5i@b=uU&OxeifAS`A96S?TKd+v zbbpGi*%?uPTBlYDV$@9pdEAK5F@&NgjpOK32j!g7s!?OOP>ilW?I9<%ffE8$p8}ZA zKF#v#flZw(c=Fx+`iQ%{NvN-%Hi~5?EUbu z`RKO4{S^@-=VXX2@B*wg8yB`2L8v*}D+LPaHY0T1wI%7<-@2M9N%r6sa0G!mMlW*$ zwmv@?uxg6lV@PXqLKk}djHo*PhLM&P$UrwDa$t0Rmr+Xb0|p)b(6vu!vF5&7u|?mI zNKu$G4K0(?rL#+LWnArmW9!yx-vil|Ah5r{-1S4jKINEyJ`R=-Y9;~0vKZj}nLzPf zWn*l4-)ow+-I$tG%SZcvy`JgLeC8S%^A_Gm>|Tsveyj=J&+>#^&5^j51FmG{1)=2cEgzkiIc?twHFPz~W3H)!@Li;RbUNDu!->4mo;1{tf|Mb?WCg)ZX~~>4c-?-X_q0n^?-_kY3iEG zmrPrIzSTYb(D=Q*gdjP|7d6%RUsHDep*Nnd3*Y!c$6maY_1?WrP`= zWcMZ3>ZLD@fgdE6qKuCsWY;1dzcbd+Yh$6}kTiqu<1{{z0Hvwv1ruTg9IkjiM)Hi&kjm;{-LOr|L;c&GI| zJnDY=9Xf+@?R29QMZc=?1@*HkU_R=AY;N1&JvX&6jq|5QWG!s8K2)CV&jy%1Gic6s z%aG(TO9oPlxv{1eyataSs3TynJRjZSt5z>wTUwDHpv0>Y0sS#bbdvdGy9w%pjQ<7fIG4M-TrzhR)1lqko z`b*_7LTa*sYF1Bqz!xnmdCC%MFt{!tlP_U)W4k<2fRKhnE9pNFq!M@Z@$Q7NxEb*D z_PjC{g2?9Z_ORbyQ1$L~nj_jR3XFSdq-!Sm3Tp|C(DW`Tsj1SgDXS)$ycnwPaw2B0J9Ap8p>V*x8CF+={6Uq;}MXp`5? z+(x(yn9ZQ0*K;CdB7t*iapRB@6HrrTD*C}~0k zVrTKI{{GYdQ-H<(z)T9XFVH@%QP=NuVa$YqD2|4t|Ab-d9|@d@AZPZx1;di|j?k{P z&UwV>=Z=Tz0Z%h@9h{ty*Q?l8O#|fJ4JyY6*X3KRM(v}k-Gxvriy7Wrn#Tv14;7EM z*(5uScN=?$Q>2%iDX%|v#=?!rHXP!_u0G}tb36^#(Hu8YMel*y|i^a zYVu~@T$0nG>mP4E?-LJ3V3uJ3DU3l9SaBG@1gaZz*s*q_MjkU4Ae#`3S5vSzQ^Z-S zn@JPUq4%rWX@+f5tx{nQ{rx(VJpO~z=GaszArJfK8FIpweD%RuV?5VY#gSCXy*YYk zAd;T1nJl>JRV?SB#_8?>?A1<;cs;b+LR`}=Y#oB0mE@8l$?bB~b++Pt!cwdJ6?fs+ zJNRK3zy^1C_`VKi7yx63V~((&5@rp6yE#*r@kd-0bvRt)QX&&Am?Mba8mOXT zMqI_9a^Xx&_uG6p4VvVAwf}l|DUD@X=TrKL299vxZB$b4!uR8XVtcgMe;Zz(kJ8$w z|HpL%3D`Z>ehvyS8Dx0!Y7Ib)ffHRr+y>MMZEM+Yo*`8%=osAc$Q^N6=>xvyf^G$`~E)0Y9U8{3q2^#FCun{SBH$q zXG^4eKzssYVvKG%s!@acp!5JOXkY*0iqjq#x*;BF_Wq0l@z{^i zJPfs-F~cCH%flTY+mScTI`iu@VosThQY-H9kjG_x`z zumQF?@)iCsTCCR-|3&NJa56=m-yf3rYN^pj)>PWJwM)Zcosq}o&m8v$d4vujcB zQgZ=cR9EA5Wf^gAm;GbA+Mm=W?m)#V7`h2DN zEJsUP9!uYSHl__Wic(_@v*#Dx$NHV2x!d-c#-SL0@ z28};W&!ex8FT(I+uNl3_6o&W4HlNtOn>;x=m#K=hQN z*6H1Hh~o0c^&nVt0>BRfS3h~N^gNy&C$bEYD{XE4C~6^Q5*zON`L^NTqLWj7@0Stc z!5HT$SoW;$b*H0jxva;wXIrc4jnt*UFs7B9Stu#DleFWcvT#q_qT-&({@Ra2uU=9? zWyFuOfiteGal5EnzUsH1M;ohN+AuaM0Of2u@i%N~u2B)XbQc05D=A1M@fuZwoU&g| z+d^OIu?NrgDhLK~|A5rMKkK8GA$T~zKT03qb75%hyh)J!)5>Hs1Zdg(b4zfsAaLX> zPw!QR4yoSlkcPfq)+8-tsjfz9#*VXaa4Yu&T=-+n~kR> zy9oc<>Cu?}bY%WR@~)jjqu585u0USe1z(yO;u>^H!q8N}s4*b}_0=#`ar*Cuu0};l zCA@ge;IKq)l{{BDo)I`U@M^zPNi6#^Fd&Ki^Ud?|qkPxn{owqy>Aq8|y}PX*{BIH< z0zCz$m;&(2;G1oM-a(&YstSl-a9>h(;HLmkVVF5kstV9BI8gtmPw)Re`=36&|5yHZ a*B+j#0zAV1>_h)IWdEBL|I-Bp^}hgiSW8y` From 2b9d1139861cb9f2858948730cb030494a9a6471 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 19 Jul 2023 09:59:25 -0400 Subject: [PATCH 39/53] fix AmmIT --- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index d07bf0eaa..1a534213a 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -8,6 +8,7 @@ import com.google.common.primitives.UnsignedInteger; import okhttp3.HttpUrl; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.keys.KeyPair; import org.xrpl.xrpl4j.crypto.keys.PrivateKey; @@ -25,6 +26,7 @@ import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; +import org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; @@ -44,11 +46,11 @@ import java.math.RoundingMode; /** - * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and - * is available in a local standalone docker container. Running these tests as part of a maven build will - * overwrite the value of xrplEnvironment, so any ITs run after these ITs will point at the AMM devnet. This is - * obviously undesirable, and in lieu of making a broader change to enable custom environments for specific test suites, - * we choose to simply disable these tests until we can run them against the normal xrplEnvironment. + * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and is + * available in a local standalone docker container. Running these tests as part of a maven build will overwrite the + * value of xrplEnvironment, so any ITs run after these ITs will point at the AMM devnet. This is obviously undesirable, + * and in lieu of making a broader change to enable custom environments for specific test suites, we choose to simply + * disable these tests until we can run them against the normal xrplEnvironment. */ public class AmmIT extends AbstractIT { @@ -62,7 +64,7 @@ protected static void initXrplEnvironment() { ); } - // @Test +// @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -115,7 +117,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal issuerLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(issuerKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -127,7 +129,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal traderLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -149,7 +151,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(expectedTradingFee); } - // @Test +// @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -216,7 +218,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - // @Test +// @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -332,7 +334,7 @@ private AccountInfoResult depositXrp( AccountLinesResult traderLines = xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderAccount.accountData().account()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ); @@ -401,10 +403,10 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro ); AccountInfoResult ammAccountInfo = xrplClient.accountInfo( - AccountInfoRequestParams.of(ammInfoResult.amm().ammAccount()) + AccountInfoRequestParams.of(ammInfoResult.amm().account()) ); assertThat(ammAccountInfo.accountData().flags().lsfAmm()).isTrue(); - + return ammInfoResult; } } From 2e2aa6c98f2ca42be13526572a9e5eac28e4d8dc Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 19 Jul 2023 12:39:17 -0400 Subject: [PATCH 40/53] fix checkstyle and update codec fixtures --- .../model/client/amm/AmmInfoAuctionSlot.java | 2 +- .../transactions/metadata/MetaAmmObject.java | 4 +- .../model/client/amm/AmmInfoResultTest.java | 33 ++-- .../src/test/resources/codec-fixtures.json | 158 +++++++++--------- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 6 +- 5 files changed, 104 insertions(+), 99 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index 3b21af80e..eb777bee1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -66,7 +66,7 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { // Therefore, this field does not require a @JsonFormat(pattern = ...) annotation similar to how other ZonedDateTime // fields are annotated in this library. @JsonProperty("expiration") - @JsonFormat(locale = "en_US") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ", locale = "en_US") ZonedDateTime expiration(); /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java index 1ad4aaf46..1eed0f75f 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java @@ -64,7 +64,7 @@ default Flags flags() { /** * Details of the current owner of the auction slot. * - * @return An {@link AuctionSlot}. + * @return A {@link MetaAuctionSlot}. */ @JsonProperty("AuctionSlot") Optional auctionSlot(); @@ -97,7 +97,7 @@ default Flags flags() { List voteSlots(); /** - * Unwraps the {@link VoteEntryWrapper}s in {@link #voteSlots()} for easier access to {@link MetaVoteEntry}s. + * Unwraps the {@link MetaVoteEntryWrapper}s in {@link #voteSlots()} for easier access to {@link MetaVoteEntry}s. * * @return A {@link List} of {@link MetaVoteEntry}. */ diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index 51d80c61b..70818b568 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -16,6 +16,11 @@ import org.xrpl.xrpl4j.model.transactions.VoteWeight; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + class AmmInfoResultTest extends AbstractJsonTest { @Test @@ -40,12 +45,12 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration("2023-Jan-07 23:47:21.000000000 UTC") - /*.expiration( - ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", - DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) - .withZoneSameLocal(ZoneId.of("UTC")) - )*/ + .expiration( + ZonedDateTime.parse( + "2023-07-20T15:17:31+0000", + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US) + ).withZoneSameLocal(ZoneId.of("UTC")) + ) .price( IssuedCurrencyAmount.builder() .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") @@ -93,7 +98,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { " \"auth_accounts\": [{\"account\": \"rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi\"},\n" + " {\"account\": \"rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG\"}],\n" + " \"discounted_fee\": 0,\n" + - " \"expiration\": \"2023-Jan-07 23:47:21.000000000 UTC\",\n" + + " \"expiration\": \"2023-07-20T15:17:31+0000\",\n" + " \"price\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"value\": \"100\"},\n" + @@ -142,12 +147,12 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException AmmInfoAuthAccount.of(Address.of("rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG")) ) .discountedFee(TradingFee.of(UnsignedInteger.ZERO)) - .expiration("2023-Jan-07 23:47:21.000000000 UTC") - /*.expiration( - ZonedDateTime.parse("2023-Jan-07 23:47:21.000000000 UTC", - DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss.SSSSSSSSS z", Locale.US)) - .withZoneSameLocal(ZoneId.of("UTC")) - )*/ + .expiration( + ZonedDateTime.parse( + "2023-07-20T15:17:31+0000", + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US) + ).withZoneSameLocal(ZoneId.of("UTC")) + ) .price( IssuedCurrencyAmount.builder() .currency("03930D02208264E2E40EC1B0C09E4DB96EE197B1") @@ -197,7 +202,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException " \"auth_accounts\": [{\"account\": \"rHq1eC9TEyEPVhRvdTPLKr3z8D5BUzcHqi\"},\n" + " {\"account\": \"rNzgpEGUyEmQ1YGDMAiGGBvwtzbk78tcCG\"}],\n" + " \"discounted_fee\": 0,\n" + - " \"expiration\": \"2023-Jan-07 23:47:21.000000000 UTC\",\n" + + " \"expiration\": \"2023-07-20T15:17:31+0000\",\n" + " \"price\": {\"currency\": \"03930D02208264E2E40EC1B0C09E4DB96EE197B1\",\n" + " \"issuer\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"value\": \"100\"},\n" + diff --git a/xrpl4j-core/src/test/resources/codec-fixtures.json b/xrpl4j-core/src/test/resources/codec-fixtures.json index 61b96f192..e05cff35f 100644 --- a/xrpl4j-core/src/test/resources/codec-fixtures.json +++ b/xrpl4j-core/src/test/resources/codec-fixtures.json @@ -4450,11 +4450,11 @@ } }, { - "binary": "12002315000A220000000024000000026140000000000027106840000000000000016BD5838D7EA4C680000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E", + "binary": "12002315000A2200000000240015DAE161400000000000271068400000000000000A6BD5838D7EA4C680000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440B3154D968314FCEB58001E1B0C3A4CFB33DF9FF6C73207E5EAEB9BD07E2747672168E1A2786D950495C38BD8DEE3391BF45F3008DD36F4B12E7C07D82CA5250E8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMCreate", - "TxnSignature": "913E39EC2BA0E5BC4C5DF1222B1AE9E76758F2B8FFEF1F056076147BB0ADC8117CD0296360DA08B3D48BE9EFC8693C03A253E0D9F166C19CA8D936F9E61A1100", + "TxnSignature": "B3154D968314FCEB58001E1B0C3A4CFB33DF9FF6C73207E5EAEB9BD07E2747672168E1A2786D950495C38BD8DEE3391BF45F3008DD36F4B12E7C07D82CA5250E", "Amount": "10000", "Amount2": { "currency": "ETH", @@ -4462,198 +4462,198 @@ "value": "10000" }, "TradingFee": 10, - "Fee": "1", + "Fee": "10", "Flags": 0, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8" } }, { - "binary": "120024220001000024000000026840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074409EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200242200010000240015DAE168400000000000000A6019D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B874408073C588E7EF672DD171E414638D9AF8DBE9A1359E030DE3E1C9AA6A38A2CE9E138CB56482BB844F7228D48B1E4AD7D09BB7E9F639C115958EEEA374749CA00B8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMDeposit", - "TxnSignature": "9EEE8CF88C668B955E7EEAB1B4A1B059EDF4F51B7F1546810F87E3E48B09237F015C651E37FB40A979E00EA21361D4E18D7A33DB7DD23070CEEAB2648AB3BB0D", + "TxnSignature": "8073C588E7EF672DD171E414638D9AF8DBE9A1359E030DE3E1C9AA6A38A2CE9E138CB56482BB844F7228D48B1E4AD7D09BB7E9F639C115958EEEA374749CA00B", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, - "Fee": "1", + "Fee": "10", "Flags": 65536, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8" } }, { - "binary": "120024220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200242200080000240015DAE16140000000000003E868400000000000000A7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8744096CA066F42871C55088D2758D64148921B1ACAA5C6C648D0F7D675BBF47F87DF711F17C5BD172666D5AEC257520C587A849A6E063345609D91E121A78816EB048114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMDeposit", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", - "Fee": "1", + "Fee": "10", "Flags": 524288, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "BD18A6E2B10B451F61CFADC32B59A0243702DC5DAAE556D51CB9C79981D40C78101FFA9DE6163CFBDF6E7578DF02F2AE3B8A5AB60697E0746D65064D91E8F90A" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "96CA066F42871C55088D2758D64148921B1ACAA5C6C648D0F7D675BBF47F87DF711F17C5BD172666D5AEC257520C587A849A6E063345609D91E121A78816EB04" } }, { - "binary": "120024220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200242200100000240015DAE16140000000000003E868400000000000000A6BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440FC22B16A098C236ED7EDB3EBC983026DFD218A03C8BAA848F3E1D5389D5B8B00473C1178C5BA257BFA2DCD433C414690A430A5CFD71C1C0A7F7BF725EC1759018114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMDeposit", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"}, - "Fee": "1", + "Fee": "10", "Flags": 1048576, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "E0B1AE32A0F731BF0CEF0D019295BD7F35B22F11A5962F65FA99EE4D38993B14B53DB11C15E36D756E282812E9015D38A6F225940A157693F43F9B795C59950F" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "FC22B16A098C236ED7EDB3EBC983026DFD218A03C8BAA848F3E1D5389D5B8B00473C1178C5BA257BFA2DCD433C414690A430A5CFD71C1C0A7F7BF725EC175901" } }, { - "binary": "120024220020000024000000026140000000000003E86840000000000000016014D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200242200200000240015DAE16140000000000003E868400000000000000A6019D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440117CF90F9B113AD3BD638B6DB63562B37C287D5180F278B3CCF58FC14A5BAEE98307EA0F6DFE19E2FBA887C92955BA5D1A04F92ADAAEB309DE89C3610D074C098114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMDeposit", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "LPTokenOut": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, - "Fee": "1", + "Fee": "10", "Flags": 2097152, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "452BC59F9EE12C224EC983EFDF580F20C4A50E897105FD1FB13520D9753CFB02BD210599181574DF6AD0DB6A42C1EA48D9E48FC3D11B9008E4C76FBB163D5B00" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "117CF90F9B113AD3BD638B6DB63562B37C287D5180F278B3CCF58FC14A5BAEE98307EA0F6DFE19E2FBA887C92955BA5D1A04F92ADAAEB309DE89C3610D074C09" } }, { - "binary": "120024220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200242200400000240015DAE16140000000000003E868400000000000000A601B40000000000000197321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B874405E51EBC6B52A7C3BA5D0AE2FC8F62E779B80182009B3108A87AB6D770D68F56053C193DB0640128E4765565970625B1E2878E116AC854E6DED412202CCDE0B0D8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMDeposit", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "EPrice": "25", - "Fee": "1", + "Fee": "10", "Flags": 4194304, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "DD6685DC586FAA6AD2D50D785900122EB147D4AC09A55D7080267A9B38180F87CEC44B823359FC3F0AC0104D47B53FFC6B80415664C3C4582672420A0100F70C" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "5E51EBC6B52A7C3BA5D0AE2FC8F62E779B80182009B3108A87AB6D770D68F56053C193DB0640128E4765565970625B1E2878E116AC854E6DED412202CCDE0B0D" } }, { - "binary": "120025220001000024000000026840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744066944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200252200010000240015DAE168400000000000000A601AD5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B874409D4F41FC452526C0AD17191959D9B6D04A3C73B3A6C29E0F34C8459675A83A7A7D6E3021390EC8C9BE6C93E11C167E12016465E523F64F9EB3194B0A52E418028114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMWithdraw", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, - "Fee": "1", + "Fee": "10", "Flags": 65536, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "66944797E9F03808C9A00AAEFF786AD74FEB2E64B51A9601E89ABA820AAA15927C2E961A9CCA22C4B0D2A2B55E342BD6E297BD765B6F4D3FDCA578A3416BB505" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "9D4F41FC452526C0AD17191959D9B6D04A3C73B3A6C29E0F34C8459675A83A7A7D6E3021390EC8C9BE6C93E11C167E12016465E523F64F9EB3194B0A52E41802" } }, { - "binary": "120025220008000024000000026140000000000003E86840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200252200080000240015DAE16140000000000003E868400000000000000A7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440E2C60D56C337D6D73E4B7D53579C93C666605494E82A89DD58CFDE79E2A4866BCF52370A2146877A2EF748E98168373710001133A51B645D89491849079035018114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMWithdraw", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", - "Fee": "1", + "Fee": "10", "Flags": 524288, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "E30397CE7E99B13D35FFB5C66725B17F4F103675E10293C7B1D63C1BE3FA81B884BD3FBD31B52F6B811F99C5FBB5102D170EC379C268DF80DABF04E7F2DD4F0C" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "E2C60D56C337D6D73E4B7D53579C93C666605494E82A89DD58CFDE79E2A4866BCF52370A2146877A2EF748E98168373710001133A51B645D8949184907903501" } }, { - "binary": "120025220010000024000000026140000000000003E86840000000000000016BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D07440C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200252200100000240015DAE16140000000000003E868400000000000000A6BD511C37937E080000000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440D2FCD7D03E53358BC6188BA88A7BA4FF2519B639C3B5C0EBCBDCB704426CA2837111430E92A6003D1CD0D81C63682C74839320539EC4F89B82AA5607714952028114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMWithdraw", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "Amount2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9", "value": "500"}, - "Fee": "1", + "Fee": "10", "Flags": 1048576, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "C0818312B269A4EF16C1C7EBBB74EFD1852A288BB214A714B8BE3B5F4B2F9CFDFF4F66C931B8434244A8016035B9EC9493B7CF5E0ACF4570A88DF808D79E4300" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "D2FCD7D03E53358BC6188BA88A7BA4FF2519B639C3B5C0EBCBDCB704426CA2837111430E92A6003D1CD0D81C63682C74839320539EC4F89B82AA560771495202" } }, { - "binary": "120025220020000024000000026140000000000003E86840000000000000016015D5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744073552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200252200200000240015DAE16140000000000003E868400000000000000A601AD5438D7EA4C68000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8744042DA5620E924E2D2059BBB4E0C4F03244140ACED93B543136FEEDF802165F814D09F45C7E2A4618468442516F4712A23B1D3332D5DBDBAE830337F39F259C90F8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMWithdraw", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "LPTokenIn": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "1000"}, - "Fee": "1", + "Fee": "10", "Flags": 2097152, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "73552B3DC7AE99DDF4E4FF0D60E6D0BE4688E3474D363603FA25DA6AD8BBA8F0E4E3EA82ADB2B57F5B9A6C379969E00095546DDA0E74FF3D0F0689351C2F8C06" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "42DA5620E924E2D2059BBB4E0C4F03244140ACED93B543136FEEDF802165F814D09F45C7E2A4618468442516F4712A23B1D3332D5DBDBAE830337F39F259C90F" } }, { - "binary": "120025220040000024000000026140000000000003E8684000000000000001601640000000000000197321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744023BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200252200400000240015DAE16140000000000003E868400000000000000A601B40000000000000197321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8744045BCEE5A12E5F5F1FB085A24F2F7FD962BBCB0D89A44A5319E3F7E3799E1870341880B6F684132971DDDF2E6B15356B3F407962D6D4E8DE10989F3B16E3CB90D8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMWithdraw", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "Amount": "1000", "EPrice": "25", - "Fee": "1", + "Fee": "10", "Flags": 4194304, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "23BAFE5BFE58E7BF0B02B5875983D007C10796C8E62A190BF688EBE5D8A104DAD2DE7EDE995FE2E494883FD8140F38E22E3376A2F49C50EFCAA00C7499A4690E" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "45BCEE5A12E5F5F1FB085A24F2F7FD962BBCB0D89A44A5319E3F7E3799E1870341880B6F684132971DDDF2E6B15356B3F407962D6D4E8DE10989F3B16E3CB90D" } }, { - "binary": "120027220000000024000000026840000000000000016CD4C8E1BC9BF04000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0486DD4CC6F3B40B6C000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D074406B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A811462D4D845D20B4F09CFEA8BB4C01063D99FC9673EF01AE01C81149A91957F8F16BC57F3F200CD8C98375BF1791586E1F10318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200272200000000240015DAE168400000000000000A6CD4C8E1BC9BF04000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0486DD4CC6F3B40B6C000B3813FCAB4EE68B3D0D735D6849465A9113EE048B3813FCAB4EE68B3D0D735D6849465A9113EE0487321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440F8EAAFB5EC1A69275167589969F0B9764BACE6BC8CC81482C2FC5ACCE691EDBD0D88D141137B1253BB1B9AC90A8A52CB37F5B6F7E1028B06DD06F91BE06F5A0F8114F92F27CC5EE2F2760278FE096D0CBE32BDD3653AF019E01B81149A91957F8F16BC57F3F200CD8C98375BF1791586E1F10318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMBid", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "AuthAccounts": [{"AuthAccount": {"Account": "rEaHTti4HZsMBpxTAF4ncWxkcdqDh1h6P7"}}], "BidMax": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "35"}, "BidMin": {"currency": "B3813FCAB4EE68B3D0D735D6849465A9113EE048", "issuer": "rH438jEAzTs5PYtV6CHZqpDpwCKQmPW9Cg", "value": "25"}, - "Fee": "1", + "Fee": "10", "Flags": 0, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "6B2A1548E6DC14681356C27CCBE7072CAB2AD8C72D0D7A045916FB0E0DBE6BF71A429CC519E9200172829D3EEF79100899D3A8710C1C3C1A2B664FD64086AD0A" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "F8EAAFB5EC1A69275167589969F0B9764BACE6BC8CC81482C2FC5ACCE691EDBD0D88D141137B1253BB1B9AC90A8A52CB37F5B6F7E1028B06DD06F91BE06F5A0F" } }, { - "binary": "1200261500EA220000000024000000026840000000000000017321ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0744072767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00811462D4D845D20B4F09CFEA8BB4C01063D99FC9673E0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", + "binary": "1200261500EA2200000000240015DAE168400000000000000A7321ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B87440BC2F6E76969E3747E9BDE183C97573B086212F09D5387460E6EE2F32953E85EAEB9618FBBEF077276E30E59D619FCF7C7BDCDDDD9EB94D7CE1DD5CE9246B21078114F92F27CC5EE2F2760278FE096D0CBE32BDD3653A0318000000000000000000000000000000000000000004180000000000000000000000004554480000000000FBEF9A3A2B814E807745FA3D9C32FFD155FA2E8C", "json": { - "Account": "rwr2UWxNwoBdysPSiDDraTQjAQKZEeZAcV", + "Account": "rP5ZkB5RZQaECsSVR4DeSFK4fAw52BYtbw", "TransactionType": "AMMVote", "Asset": {"currency": "XRP"}, "Asset2": {"currency": "ETH", "issuer": "rPyfep3gcLzkosKC9XiE77Y8DZWG6iWDT9"}, "TradingFee": 234, - "Fee": "1", + "Fee": "10", "Flags": 0, - "Sequence": 2, - "SigningPubKey": "ED8A00C1D29E762266576408B08D583B987673550655F930635678B436D5CDF7D0", - "TxnSignature": "72767CF9A0F5E9C9DA6BBB6E84905B0ECDF122D3E2D730843EFD377521E8E73664AD809D0A54E8C75CD1735ACB64E310BB49FDED10913FA150B8C006D4ACEC00" + "Sequence": 1432289, + "SigningPubKey": "ED7453D2572A2104E7B266A45888C53F503CEB1F11DC4BB3710EB2995238EC65B8", + "TxnSignature": "BC2F6E76969E3747E9BDE183C97573B086212F09D5387460E6EE2F32953E85EAEB9618FBBEF077276E30E59D619FCF7C7BDCDDDD9EB94D7CE1DD5CE9246B2107" } }], "ledgerData": [{ @@ -4670,4 +4670,4 @@ "transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87" } }] -} +} \ No newline at end of file diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 1a534213a..10abb09df 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -64,7 +64,7 @@ protected static void initXrplEnvironment() { ); } -// @Test + // @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -151,7 +151,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(expectedTradingFee); } -// @Test + // @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); @@ -218,7 +218,7 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } -// @Test + // @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); AmmInfoResult amm = createAmm(issuerKeyPair); From 0c90c86a088fed5257862a27b17c7f537cb73877 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 19 Jul 2023 12:44:38 -0400 Subject: [PATCH 41/53] add javadoc to AmmDepositFlags and AmmWithdrawFlags explaining why there is no empty or unset option --- .../java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java | 4 ++++ .../java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java index 75044ea53..33dcf6c75 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java @@ -6,6 +6,10 @@ * A set of {@link TransactionFlags} that can be set on {@link AmmDeposit} transactions. Exactly * one flag must be set on each {@link AmmDeposit} transaction, so this class does not allow for combination * of multiple flags. + * + *

While most other TransactionFlags support empty flags or 0, AmmDeposit transactions must have a Flags field + * to denote the deposit mode. Therefore, AmmDepositFlags does not support empty or unset flags. + *

*/ public class AmmDepositFlags extends TransactionFlags { diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java index 9ea9ec4ae..1c835584a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java @@ -4,6 +4,10 @@ * A set of {@link TransactionFlags} that can be set on {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} * transactions. Exactly one flag must be set on each {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} * transaction, so this class does not allow for combination of multiple flags. + * + *

While most other TransactionFlags support empty flags or 0, AmmWithdraw transactions must have a Flags field + * to denote the withdraw mode. Therefore, AmmWithdrawFlags does not support empty or unset flags. + *

*/ public class AmmWithdrawFlags extends TransactionFlags { From 9ddbbdf24d7b01d4200dd19f1a89849050b22e86 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 8 Aug 2023 11:12:29 -0400 Subject: [PATCH 42/53] fix checkstyle --- .../src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java | 1 + .../main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java | 1 + 2 files changed, 2 insertions(+) diff --git a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java index 4879a4f39..25fffe8b3 100644 --- a/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java +++ b/xrpl4j-client/src/test/java/org/xrpl/xrpl4j/client/XrplClientTest.java @@ -1040,6 +1040,7 @@ void ammInfo() throws JsonRpcClientErrorException { assertThat(result).isEqualTo(mockResult); } + @Test void nftInfo() throws JsonRpcClientErrorException { NftInfoRequestParams params = NftInfoRequestParams.builder() diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index 68b1b5adf..df5fbbda9 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -416,6 +416,7 @@ public static NetworkId of(long networkId) { return NetworkId.of(UnsignedInteger.valueOf(networkId)); } } + /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. */ From 6e88d6f4adef93b94c66497c0155727051ac8e22 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 11:58:37 -0400 Subject: [PATCH 43/53] Enable AMM amendment in local rippled node and reenable AmmIT. Update existing AMM transactions with the latest formats. Remove any inference of flags based on fields because we're likely to get it wrong. Update AMM transaction flags with new values. Remove lsfAMM from AccountRootFlags and add AMMID to AccountRootObject. --- .../xrpl4j/model/flags/AccountRootFlags.java | 13 - .../xrpl4j/model/flags/AmmDepositFlags.java | 14 + .../model/ledger/AccountRootObject.java | 9 + .../xrpl4j/model/transactions/AmmDeposit.java | 33 +-- .../model/transactions/AmmWithdraw.java | 51 +--- .../model/flags/AccountRootFlagsTests.java | 12 +- .../model/transactions/AmmDepositTest.java | 111 +++---- .../model/transactions/AmmWithdrawTest.java | 271 ------------------ .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 75 +++-- .../src/test/resources/rippled/rippled.cfg | 4 + 10 files changed, 131 insertions(+), 462 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java index cb5a5c302..1a7e128af 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AccountRootFlags.java @@ -97,11 +97,6 @@ public class AccountRootFlags extends Flags { */ public static final AccountRootFlags DISALLOW_INCOMING_TRUSTLINE = new AccountRootFlags(0x20000000); - /** - * Constant {@link AccountRootFlags} for the {@code lsfAMM} account flag. - */ - public static final AccountRootFlags AMM = new AccountRootFlags(0x40000000); - /** * Required-args Constructor. * @@ -241,12 +236,4 @@ public boolean lsfDisallowIncomingTrustline() { return this.isSet(AccountRootFlags.DISALLOW_INCOMING_TRUSTLINE); } - /** - * This account is an Automated Market Maker instance. - * - * @return {@code true} if {@code lsfAMM} is set, otherwise {@code false}. - */ - public boolean lsfAmm() { - return this.isSet(AccountRootFlags.AMM); - } } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java index 33dcf6c75..a7a197815 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java @@ -38,6 +38,11 @@ public class AmmDepositFlags extends TransactionFlags { */ public static final AmmDepositFlags LIMIT_LP_TOKEN = new AmmDepositFlags(0x00400000); + /** + * Constant {@link AmmDepositFlags} for the {@code tfTwoAssetIfEmpty} flag. + */ + public static final AmmDepositFlags TWO_ASSET_IF_EMPTY = new AmmDepositFlags(0x00800000); + private AmmDepositFlags(long value) { super(value); } @@ -87,4 +92,13 @@ public boolean tfLimitLpToken() { return this.isSet(LIMIT_LP_TOKEN); } + /** + * Whether the {@code tfTwoAssetIfEmpty} flag is set. + * + * @return {@code true} if {@code tfTwoAssetIfEmpty} is set, otherwise {@code false}. + */ + public boolean tfTwoAssetIfEmpty() { + return this.isSet(TWO_ASSET_IF_EMPTY); + } + } \ No newline at end of file diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java index ba1c7e328..c212141bb 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java @@ -225,6 +225,15 @@ default LedgerEntryType ledgerEntryType() { @JsonProperty("NFTokenMinter") Optional
nfTokenMinter(); + /** + * The ledger entry ID of the corresponding AMM ledger entry. Set during account creation; cannot be modified. + * If present, indicates that this is a special AMM AccountRoot; always omitted on non-AMM accounts. + * + * @return An optionally-present {@link Hash256}. + */ + @JsonProperty("AMMID") + Optional ammId(); + /** * The unique ID of this {@link AccountRootObject} ledger object. * diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index 94b616ab6..1f872135e 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -27,33 +27,12 @@ static ImmutableAmmDeposit.Builder builder() { } /** - * A {@link AmmDepositFlags} for this transaction. This flag will automatically be derived from the presence - * of {@link #lpTokenOut()}, {@link #amount()}, {@link #amount2()} and {@link #effectivePrice()}. + * A {@link AmmDepositFlags} for this transaction. This field must be set manually. * * @return A {@link AmmDepositFlags} for this transaction. */ @JsonProperty("Flags") - @Value.Default - default AmmDepositFlags flags() { - boolean lpTokenOutPresent = lpTokenOut().isPresent(); - boolean amountPresent = amount().isPresent(); - boolean amount2Present = amount2().isPresent(); - boolean effectivePricePresent = effectivePrice().isPresent(); - - if (lpTokenOutPresent && !amountPresent && !amount2Present && !effectivePricePresent) { - return AmmDepositFlags.LP_TOKEN; - } else if (!lpTokenOutPresent && amountPresent && amount2Present && !effectivePricePresent) { - return AmmDepositFlags.TWO_ASSET; - } else if (!lpTokenOutPresent && amountPresent && !amount2Present && !effectivePricePresent) { - return AmmDepositFlags.SINGLE_ASSET; - } else if (lpTokenOutPresent && amountPresent && !amount2Present && !effectivePricePresent) { - return AmmDepositFlags.ONE_ASSET_LP_TOKEN; - } else if (!lpTokenOutPresent && amountPresent && !amount2Present) { - return AmmDepositFlags.LIMIT_LP_TOKEN; - } else { - throw new IllegalStateException("Correct AmmDepositFlag could not be determined based on set fields."); - } - } + AmmDepositFlags flags(); /** * The definition for one of the assets in the AMM's pool. @@ -105,4 +84,12 @@ default AmmDepositFlags flags() { @JsonProperty("LPTokenOut") Optional lpTokenOut(); + /** + * An optional {@link TradingFee} to set on the AMM instance. This field is only honored if the AMM's LP token balance + * is zero, and can only be set if flags is {@link AmmDepositFlags#TWO_ASSET_IF_EMPTY}. + * + * @return An {@link Optional} {@link TradingFee}. + */ + @JsonProperty("TradingFee") + Optional tradingFee(); } diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java index c89cfd15d..60c0837db 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.base.Preconditions; import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.ledger.Issue; @@ -13,6 +14,9 @@ /** * Object mapping for the AMMWithdraw transaction. */ +@Immutable +@JsonSerialize(as = ImmutableAmmWithdraw.class) +@JsonDeserialize(as = ImmutableAmmWithdraw.class) public interface AmmWithdraw extends Transaction { /** @@ -82,51 +86,4 @@ static ImmutableAmmWithdraw.Builder builder() { @JsonProperty("LPTokensIn") Optional lpTokensIn(); - @Value.Immutable - @JsonSerialize(as = ImmutableAmmWithdraw.class) - @JsonDeserialize(as = ImmutableAmmWithdraw.class) - abstract class AbstractAmmWithdraw implements AmmWithdraw { - - @Value.Check - void checkFieldPresenceBasedOnFlags() { - boolean lpTokenPresent = lpTokensIn().isPresent(); - boolean amountPresent = amount().isPresent(); - boolean amount2Present = amount2().isPresent(); - boolean effectivePricePresent = effectivePrice().isPresent(); - - if (flags().tfLpToken()) { - Preconditions.checkState( - lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent, - "If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present." - ); - } else if (flags().tfWithdrawAll()) { - Preconditions.checkState( - !lpTokenPresent && !amountPresent && !amount2Present && !effectivePricePresent, - "If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present." - ); - } else if (flags().tfTwoAsset()) { - Preconditions.checkState( - !lpTokenPresent && amountPresent && amount2Present && !effectivePricePresent, - "If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present." - ); - } else if (flags().tfSingleAsset() || flags().tfOneAssetWithdrawAll()) { - Preconditions.checkState( - !lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent, - "If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice cannot " + - "be present." - ); - } else if (flags().tfOneAssetLpToken()) { - Preconditions.checkState( - lpTokenPresent && amountPresent && !amount2Present && !effectivePricePresent, - "If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present." - ); - } else if (flags().tfLimitLpToken()) { - Preconditions.checkState( - !lpTokenPresent && amountPresent && !amount2Present && effectivePricePresent, - "If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present." - ); - } - } - - } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java index 44f2d3982..b4a7ef12b 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AccountRootFlagsTests.java @@ -34,7 +34,7 @@ public class AccountRootFlagsTests extends AbstractFlagsTest { public static Stream data() { - return getBooleanCombinations(14); + return getBooleanCombinations(13); } @ParameterizedTest @@ -53,8 +53,7 @@ public void testDeriveIndividualFlagsFromFlags( boolean lsfDisallowIncomingNFTokenOffer, boolean lsfDisallowIncomingCheck, boolean lsfDisallowIncomingPayChan, - boolean lsfDisallowIncomingTrustline, - boolean lsfAmm + boolean lsfDisallowIncomingTrustline ) { long expectedFlags = (lsfDefaultRipple ? AccountRootFlags.DEFAULT_RIPPLE.getValue() : 0L) | (lsfDepositAuth ? AccountRootFlags.DEPOSIT_AUTH.getValue() : 0L) | @@ -68,8 +67,7 @@ public void testDeriveIndividualFlagsFromFlags( (lsfDisallowIncomingNFTokenOffer ? AccountRootFlags.DISALLOW_INCOMING_NFT_OFFER.getValue() : 0L) | (lsfDisallowIncomingCheck ? AccountRootFlags.DISALLOW_INCOMING_CHECK.getValue() : 0L) | (lsfDisallowIncomingPayChan ? AccountRootFlags.DISALLOW_INCOMING_PAY_CHAN.getValue() : 0L) | - (lsfDisallowIncomingTrustline ? AccountRootFlags.DISALLOW_INCOMING_TRUSTLINE.getValue() : 0L) | - (lsfAmm ? AccountRootFlags.AMM.getValue() : 0L); + (lsfDisallowIncomingTrustline ? AccountRootFlags.DISALLOW_INCOMING_TRUSTLINE.getValue() : 0L); Flags flagsFromFlags = AccountRootFlags.of( (lsfDefaultRipple ? AccountRootFlags.DEFAULT_RIPPLE : AccountRootFlags.UNSET), (lsfDepositAuth ? AccountRootFlags.DEPOSIT_AUTH : AccountRootFlags.UNSET), @@ -83,8 +81,7 @@ public void testDeriveIndividualFlagsFromFlags( (lsfDisallowIncomingNFTokenOffer ? AccountRootFlags.DISALLOW_INCOMING_NFT_OFFER : AccountRootFlags.UNSET), (lsfDisallowIncomingCheck ? AccountRootFlags.DISALLOW_INCOMING_CHECK : AccountRootFlags.UNSET), (lsfDisallowIncomingPayChan ? AccountRootFlags.DISALLOW_INCOMING_PAY_CHAN : AccountRootFlags.UNSET), - (lsfDisallowIncomingTrustline ? AccountRootFlags.DISALLOW_INCOMING_TRUSTLINE : AccountRootFlags.UNSET), - (lsfAmm ? AccountRootFlags.AMM : AccountRootFlags.UNSET) + (lsfDisallowIncomingTrustline ? AccountRootFlags.DISALLOW_INCOMING_TRUSTLINE : AccountRootFlags.UNSET) ); assertThat(flagsFromFlags.getValue()).isEqualTo(expectedFlags); @@ -105,7 +102,6 @@ public void testDeriveIndividualFlagsFromFlags( assertThat(flagsFromLong.lsfDisallowIncomingCheck()).isEqualTo(lsfDisallowIncomingCheck); assertThat(flagsFromLong.lsfDisallowIncomingPayChan()).isEqualTo(lsfDisallowIncomingPayChan); assertThat(flagsFromLong.lsfDisallowIncomingTrustline()).isEqualTo(lsfDisallowIncomingTrustline); - assertThat(flagsFromLong.lsfAmm()).isEqualTo(lsfAmm); } @ParameterizedTest diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java index ed05beda1..9f4c5c1f9 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDepositTest.java @@ -28,6 +28,7 @@ void constructLpTokenDepositAndTestJson() throws JSONException, JsonProcessingEx .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .flags(AmmDepositFlags.LP_TOKEN) .asset(Issue.XRP) .asset2( Issue.builder() @@ -77,6 +78,7 @@ void constructTwoAssetDepositAndTestJson() throws JSONException, JsonProcessingE .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .flags(AmmDepositFlags.TWO_ASSET) .asset(Issue.XRP) .asset2( Issue.builder() @@ -126,6 +128,7 @@ void constructSingleAssetDepositAndTestJson() throws JSONException, JsonProcessi AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .flags(AmmDepositFlags.SINGLE_ASSET) .asset(Issue.XRP) .asset2( Issue.builder() @@ -179,6 +182,7 @@ void constructOneAssetLpTokenDepositAndTestJson() throws JSONException, JsonProc .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .flags(AmmDepositFlags.ONE_ASSET_LP_TOKEN) .asset(Issue.XRP) .asset2( Issue.builder() @@ -241,6 +245,7 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess .signingPublicKey( PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") ) + .flags(AmmDepositFlags.LIMIT_LP_TOKEN) .asset(Issue.XRP) .asset2( Issue.builder() @@ -285,90 +290,58 @@ void constructLimitLpTokenDepositAndTestJson() throws JSONException, JsonProcess assertCanSerializeAndDeserialize(deposit, json); } - @ParameterizedTest - @MethodSource("getBooleanCombinations") - void testInvalidFieldPresence( - boolean lpTokenPresent, - boolean amountPresent, - boolean amount2Present, - boolean effectivePricePresent - ) { - - ImmutableAmmDeposit.Builder builder = AmmDeposit.builder() + @Test + void constructTwoAssetIfEmptyDepositTestJson() throws JSONException, JsonProcessingException { + AmmDeposit deposit = AmmDeposit.builder() .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) + .signingPublicKey( + PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") + ) + .flags(AmmDepositFlags.TWO_ASSET_IF_EMPTY) .asset(Issue.XRP) .asset2( Issue.builder() .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) .currency("TST") .build() - ); - - if (lpTokenPresent) { - builder.lpTokenOut( - IssuedCurrencyAmount.builder() - .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") - .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) - .value("100") - .build() - ); - } - if (amountPresent) { - builder.amount(XrpCurrencyAmount.ofDrops(10)); - } - if (amount2Present) { - builder.amount2( + ) + .amount( IssuedCurrencyAmount.builder() .currency("039C99CD9AB0B70B32ECDA51EAAE471625608EA2") .issuer(Address.of("rE54zDvgnghAoPopCgvtiqWNq3dU5y836S")) .value("100") .build() - ); - } - if (effectivePricePresent) { - builder.effectivePrice(XrpCurrencyAmount.ofDrops(10)); - } - - assertThatThrownBy(builder::build) - .isInstanceOf(IllegalStateException.class) - .hasMessage("Correct AmmDepositFlag could not be determined based on set fields."); - } - - private static Stream getBooleanCombinations() { - // Every combination of 4 booleans - List params = new ArrayList<>(); - for (int i = 0; i < Math.pow(2, 4); i++) { - String bin = Integer.toBinaryString(i); - while (bin.length() < 4) { - bin = "0" + bin; - } + ) + .amount2(XrpCurrencyAmount.ofDrops(10)) + .effectivePrice(XrpCurrencyAmount.ofDrops(10)) + .build(); - char[] chars = bin.toCharArray(); - Boolean[] booleans = new Boolean[4]; - for (int j = 0; j < chars.length; j++) { - booleans[j] = chars[j] == '0'; - } + assertThat(deposit.flags()).isEqualTo(AmmDepositFlags.TWO_ASSET_IF_EMPTY); - if (booleans[0] && !booleans[1] && !booleans[2] && !booleans[3]) { - continue; - } - if (!booleans[0] && booleans[1] && booleans[2] && !booleans[3]) { - continue; - } - if (!booleans[0] && booleans[1] && !booleans[2] && !booleans[3]) { - continue; - } - if (booleans[0] && booleans[1] && !booleans[2] && !booleans[3]) { - continue; - } - if (!booleans[0] && booleans[1] && !booleans[2]) { - continue; - } - params.add(booleans); - } + String json = "{\n" + + " \"Account\" : \"" + deposit.account() + "\",\n" + + " \"Amount\" : {\n" + + " \"currency\" : \"039C99CD9AB0B70B32ECDA51EAAE471625608EA2\",\n" + + " \"issuer\" : \"rE54zDvgnghAoPopCgvtiqWNq3dU5y836S\",\n" + + " \"value\" : \"100\"\n" + + " },\n" + + " \"Amount2\" : \"10\",\n" + + " \"EPrice\" : \"10\",\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : " + AmmDepositFlags.TWO_ASSET_IF_EMPTY + ",\n" + + " \"Sequence\" : 0,\n" + + " \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + + " \"TransactionType\" : \"AMMDeposit\"\n" + + "}"; - return params.stream().map(Arguments::of); + assertCanSerializeAndDeserialize(deposit, json); } - } \ No newline at end of file diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java index e809e1e84..493af7fe3 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmWithdrawTest.java @@ -190,277 +190,6 @@ void constructLimitLpTokenAndTestJson() throws JSONException, JsonProcessingExce assertCanSerializeAndDeserialize(withdraw, json); } - @Test - void constructLpTokenWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LP_TOKEN) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .amount(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, amount, amount2, and effectivePrice cannot be present."); - } - - @Test - void constructWithdrawAllWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.WITHDRAW_ALL) - .lpTokensIn(lpTokensIn()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.WITHDRAW_ALL) - .amount(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.WITHDRAW_ALL) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.WITHDRAW_ALL) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLPToken flag is set, lpTokensIn, amount, amount2, and effectivePrice cannot be present."); - } - - @Test - void constructTwoAssetWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.TWO_ASSET) - .lpTokensIn(lpTokensIn()) - .amount(amount()) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.TWO_ASSET) - .amount(amount()) - .amount2(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.TWO_ASSET) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.TWO_ASSET) - .amount(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfTwoAsset flag is set, lpTokensIn and effectivePrice cannot be present."); - } - - @Test - void constructSingleAssetWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.SINGLE_ASSET) - .amount(amount()) - .lpTokensIn(lpTokensIn()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.SINGLE_ASSET) - .amount(amount()) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.SINGLE_ASSET) - .amount(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.SINGLE_ASSET) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - } - - @Test - void constructOneAssetWithdrawAllWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) - .amount(amount()) - .lpTokensIn(lpTokensIn()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) - .amount(amount()) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) - .amount(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_WITHDRAW_ALL) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfSingleAsset or tfOneAssetWithdrawAll flag is set, lpTokensIn, amount2, and effectivePrice" + - " cannot be present."); - } - - @Test - void constructOneAssetLpTokenWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .amount(amount()) - .amount2(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .amount(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) - .amount(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.ONE_ASSET_LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfOneAssetLPToken flag is set, amount2 and effectivePrice cannot be present."); - } - - @Test - void constructLimitLpTokenWithWrongFieldsPresent() { - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) - .lpTokensIn(lpTokensIn()) - .amount(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) - .amount(amount()) - .amount2(amount()) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) - .amount(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); - - assertThatThrownBy( - () -> baseBuilder() - .flags(AmmWithdrawFlags.LIMIT_LP_TOKEN) - .effectivePrice(amount()) - .build() - ).isInstanceOf(IllegalStateException.class) - .hasMessage("If the tfLimitLPToken flag is set, lpTokensIn and amount2 cannot be present."); - } - private ImmutableIssuedCurrencyAmount amount() { return IssuedCurrencyAmount.builder() .currency("TST") diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 10abb09df..76aa12a2c 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -6,8 +6,6 @@ import com.google.common.base.Strings; import com.google.common.io.BaseEncoding; import com.google.common.primitives.UnsignedInteger; -import okhttp3.HttpUrl; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.xrpl.xrpl4j.client.JsonRpcClientErrorException; import org.xrpl.xrpl4j.crypto.keys.KeyPair; @@ -26,11 +24,13 @@ import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; import org.xrpl.xrpl4j.model.client.transactions.SubmitResult; -import org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams; +import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.ledger.Issue; +import org.xrpl.xrpl4j.model.transactions.AccountSet; +import org.xrpl.xrpl4j.model.transactions.AccountSet.AccountSetFlag; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; @@ -40,37 +40,21 @@ import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes; import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; -import org.xrpl.xrpl4j.tests.environment.CustomEnvironment; import java.math.BigDecimal; import java.math.RoundingMode; -/** - * All tests in this class will be disabled until AMM functionality has been merged into the rippled codebase and is - * available in a local standalone docker container. Running these tests as part of a maven build will overwrite the - * value of xrplEnvironment, so any ITs run after these ITs will point at the AMM devnet. This is obviously undesirable, - * and in lieu of making a broader change to enable custom environments for specific test suites, we choose to simply - * disable these tests until we can run them against the normal xrplEnvironment. - */ public class AmmIT extends AbstractIT { String xrpl4jCoin = Strings.padEnd(BaseEncoding.base16().encode("xrpl4jCoin".getBytes()), 40, '0'); - @BeforeAll - protected static void initXrplEnvironment() { - xrplEnvironment = new CustomEnvironment( - HttpUrl.parse("http://amm.devnet.rippletest.net:51234"), - HttpUrl.parse("https://ammfaucet.devnet.rippletest.net") - ); - } - - // @Test + @Test void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); - AmmInfoResult amm = createAmm(issuerKeyPair); + FeeResult feeResult = xrplClient.fee(); + AmmInfoResult amm = createAmm(issuerKeyPair, feeResult); KeyPair traderKeyPair = createRandomAccountEd25519(); - FeeResult feeResult = xrplClient.fee(); AccountInfoResult traderAccount = scanForResult( () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); @@ -151,14 +135,14 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces assertThat(ammAfterVote.amm().tradingFee()).isEqualTo(expectedTradingFee); } - // @Test + @Test void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); - AmmInfoResult amm = createAmm(issuerKeyPair); + FeeResult feeResult = xrplClient.fee(); + AmmInfoResult amm = createAmm(issuerKeyPair, feeResult); KeyPair traderKeyPair = createRandomAccountEd25519(); KeyPair authAccount1 = createRandomAccountEd25519(); - FeeResult feeResult = xrplClient.fee(); AccountInfoResult traderAccount = scanForResult( () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); @@ -218,13 +202,13 @@ void depositAndBid() throws JsonRpcClientErrorException, JsonProcessingException .containsExactly(authAccount1.publicKey().deriveAddress()); } - // @Test + @Test void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingException { KeyPair issuerKeyPair = createRandomAccountEd25519(); - AmmInfoResult amm = createAmm(issuerKeyPair); + FeeResult feeResult = xrplClient.fee(); + AmmInfoResult amm = createAmm(issuerKeyPair, feeResult); KeyPair traderKeyPair = createRandomAccountEd25519(); - FeeResult feeResult = xrplClient.fee(); AccountInfoResult traderAccount = scanForResult( () -> this.getValidatedAccountInfo(traderKeyPair.publicKey().deriveAddress()) ); @@ -305,6 +289,7 @@ private AccountInfoResult depositXrp( .build() ) .asset(Issue.XRP) + .flags(AmmDepositFlags.SINGLE_ASSET) .amount(depositAmount) .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) .sequence(traderAccount.accountData().sequence()) @@ -347,10 +332,13 @@ private AccountInfoResult depositXrp( return traderAccountAfterDeposit; } - private AmmInfoResult createAmm(KeyPair issuerKeyPair) throws JsonRpcClientErrorException, JsonProcessingException { + private AmmInfoResult createAmm(KeyPair issuerKeyPair, FeeResult feeResult) throws JsonRpcClientErrorException, JsonProcessingException { AccountInfoResult issuerAccount = scanForResult( () -> this.getValidatedAccountInfo(issuerKeyPair.publicKey().deriveAddress()) ); + + enableRippling(issuerKeyPair, issuerAccount, feeResult); + XrpCurrencyAmount reserveAmount = xrplClient.serverInformation().info() .map( rippled -> rippled.closedLedger().orElse(rippled.validatedLedger().get()).reserveIncXrp(), @@ -359,7 +347,7 @@ private AmmInfoResult createAmm(KeyPair issuerKeyPair) throws JsonRpcClientError ); AmmCreate ammCreate = AmmCreate.builder() .account(issuerKeyPair.publicKey().deriveAddress()) - .sequence(issuerAccount.accountData().sequence()) + .sequence(issuerAccount.accountData().sequence().plus(UnsignedInteger.ONE)) .fee(reserveAmount) .amount( IssuedCurrencyAmount.builder() @@ -405,8 +393,33 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro AccountInfoResult ammAccountInfo = xrplClient.accountInfo( AccountInfoRequestParams.of(ammInfoResult.amm().account()) ); - assertThat(ammAccountInfo.accountData().flags().lsfAmm()).isTrue(); + + assertThat(ammAccountInfo.accountData().ammId()).isNotEmpty(); return ammInfoResult; } + + private void enableRippling(KeyPair issuerKeyPair, AccountInfoResult issuerAccount, FeeResult feeResult) + throws JsonRpcClientErrorException, JsonProcessingException { + AccountSet accountSet = AccountSet.builder() + .account(issuerKeyPair.publicKey().deriveAddress()) + .fee(FeeUtils.computeNetworkFees(feeResult).recommendedFee()) + .signingPublicKey(issuerKeyPair.publicKey()) + .sequence(issuerAccount.accountData().sequence()) + .setFlag(AccountSetFlag.DEFAULT_RIPPLE) + .build(); + + SingleSignedTransaction signed = signatureService.sign(issuerKeyPair.privateKey(), accountSet); + SubmitResult setResult = xrplClient.submit(signed); + assertThat(setResult.engineResult()).isEqualTo("tesSUCCESS"); + logger.info( + "AccountSet transaction successful: https://testnet.xrpl.org/transactions/{}", + setResult.transactionResult().hash() + ); + + scanForResult( + () -> getValidatedAccountInfo(issuerKeyPair.publicKey().deriveAddress()), + info -> info.accountData().flags().lsfDefaultRipple() + ); + } } diff --git a/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg b/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg index 5947fe6d9..8b9565494 100644 --- a/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg +++ b/xrpl4j-integration-tests/src/test/resources/rippled/rippled.cfg @@ -1284,3 +1284,7 @@ fixTrustLinesToSelf fixUniversalNumber ImmediateOfferKilled XRPFees +fixNFTokenRemint +fixReducedOffersV1 +Clawback +AMM \ No newline at end of file From c5586af4b85ef3d9bf29b011f985d215de2d1488 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 13:58:22 -0400 Subject: [PATCH 44/53] fix test --- .../org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java | 3 +++ .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index 60f9ba929..e5b028305 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -47,6 +47,7 @@ import org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec; import org.xrpl.xrpl4j.crypto.keys.PublicKey; import org.xrpl.xrpl4j.model.client.channels.UnsignedClaim; +import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; @@ -632,6 +633,7 @@ void addSignatureToAmmDeposit() { AmmDeposit deposit = AmmDeposit.builder() .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) + .flags(AmmDepositFlags.LIMIT_LP_TOKEN) .asset(Issue.XRP) .asset2( Issue.builder() @@ -1058,6 +1060,7 @@ void addMultiSignatureToAmmDeposit() { AmmDeposit deposit = AmmDeposit.builder() .account(sourcePublicKey.deriveAddress()) .fee(XrpCurrencyAmount.ofDrops(10)) + .flags(AmmDepositFlags.LIMIT_LP_TOKEN) .asset(Issue.XRP) .asset2( Issue.builder() diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 76aa12a2c..2c58b073a 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -332,7 +332,10 @@ private AccountInfoResult depositXrp( return traderAccountAfterDeposit; } - private AmmInfoResult createAmm(KeyPair issuerKeyPair, FeeResult feeResult) throws JsonRpcClientErrorException, JsonProcessingException { + private AmmInfoResult createAmm( + KeyPair issuerKeyPair, + FeeResult feeResult + ) throws JsonRpcClientErrorException, JsonProcessingException { AccountInfoResult issuerAccount = scanForResult( () -> this.getValidatedAccountInfo(issuerKeyPair.publicKey().deriveAddress()) ); From 9202aab43444ab2b14972f795e6c9c37a7098b2e Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 14:42:09 -0400 Subject: [PATCH 45/53] rename AmmInfo.account json property to amm_account --- .../java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java | 4 ++-- .../xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java | 3 --- .../xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java | 8 ++++---- .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 8 ++++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java index b20bfc559..6ad573448 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java @@ -37,8 +37,8 @@ static ImmutableAmmInfo.Builder builder() { * * @return An {@link Address}. */ - @JsonProperty("account") - Address account(); + @JsonProperty("amm_account") + Address ammAccount(); /** * The definition for one of the two assets this AMM holds. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index eb777bee1..bab1968ce 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -62,9 +62,6 @@ static ImmutableAmmInfoAuctionSlot.Builder builder() { * * @return An {@link ZonedDateTime} */ - // rippled reports the expiration date/time in ISO 8601 format, which is natively supported by ZonedDateTime. - // Therefore, this field does not require a @JsonFormat(pattern = ...) annotation similar to how other ZonedDateTime - // fields are annotated in this library. @JsonProperty("expiration") @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ", locale = "en_US") ZonedDateTime expiration(); diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index 70818b568..79568939e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -28,7 +28,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( AmmInfo.builder() - .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -87,7 +87,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { .status("success") .build(); - String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + @@ -129,7 +129,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException AmmInfoResult result = AmmInfoResult.builder() .amm( AmmInfo.builder() - .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -191,7 +191,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException .validated(true) .build(); - String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 2c58b073a..6c7c8f21a 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -101,7 +101,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal issuerLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(issuerKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().account()) + .peer(amm.amm().ammAccount()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -113,7 +113,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal traderLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().account()) + .peer(amm.amm().ammAccount()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -319,7 +319,7 @@ private AccountInfoResult depositXrp( AccountLinesResult traderLines = xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderAccount.accountData().account()) - .peer(amm.amm().account()) + .peer(amm.amm().ammAccount()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ); @@ -394,7 +394,7 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro ); AccountInfoResult ammAccountInfo = xrplClient.accountInfo( - AccountInfoRequestParams.of(ammInfoResult.amm().account()) + AccountInfoRequestParams.of(ammInfoResult.amm().ammAccount()) ); assertThat(ammAccountInfo.accountData().ammId()).isNotEmpty(); From bac0d620d58e764b92f5b0eb81d7e27f1519351b Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 15:17:31 -0400 Subject: [PATCH 46/53] revert rename --- .../java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java | 4 ++-- .../xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java | 8 ++++---- .../src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java index 6ad573448..b20bfc559 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java @@ -37,8 +37,8 @@ static ImmutableAmmInfo.Builder builder() { * * @return An {@link Address}. */ - @JsonProperty("amm_account") - Address ammAccount(); + @JsonProperty("account") + Address account(); /** * The definition for one of the two assets this AMM holds. diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java index 79568939e..70818b568 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResultTest.java @@ -28,7 +28,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { AmmInfoResult result = AmmInfoResult.builder() .amm( AmmInfo.builder() - .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -87,7 +87,7 @@ void testJsonForCurrentLedger() throws JSONException, JsonProcessingException { .status("success") .build(); - String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + @@ -129,7 +129,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException AmmInfoResult result = AmmInfoResult.builder() .amm( AmmInfo.builder() - .ammAccount(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) + .account(Address.of("rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze")) .amount(XrpCurrencyAmount.ofDrops(11080000720L)) .amount2( IssuedCurrencyAmount.builder() @@ -191,7 +191,7 @@ void testJsonForValidatedLedger() throws JSONException, JsonProcessingException .validated(true) .build(); - String json = "{\"amm\": {\"amm_account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + + String json = "{\"amm\": {\"account\": \"rU3auoTuhaPwiiod3wEXNnYogxMnYsBhze\",\n" + " \"amount\": \"11080000720\",\n" + " \"amount2\": {\"currency\": \"USD\",\n" + " \"issuer\": \"rELH2VCCkjDzvygtB4nKiqGav7h53RhDiP\",\n" + diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 6c7c8f21a..2c58b073a 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -101,7 +101,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal issuerLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(issuerKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -113,7 +113,7 @@ void depositAndVoteOnTradingFee() throws JsonRpcClientErrorException, JsonProces BigDecimal traderLpTokenBalance = new BigDecimal(xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderKeyPair.publicKey().deriveAddress()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ).lines().stream() @@ -319,7 +319,7 @@ private AccountInfoResult depositXrp( AccountLinesResult traderLines = xrplClient.accountLines( AccountLinesRequestParams.builder() .account(traderAccount.accountData().account()) - .peer(amm.amm().ammAccount()) + .peer(amm.amm().account()) .ledgerSpecifier(LedgerSpecifier.CURRENT) .build() ); @@ -394,7 +394,7 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro ); AccountInfoResult ammAccountInfo = xrplClient.accountInfo( - AccountInfoRequestParams.of(ammInfoResult.amm().ammAccount()) + AccountInfoRequestParams.of(ammInfoResult.amm().account()) ); assertThat(ammAccountInfo.accountData().ammId()).isNotEmpty(); From 62c66ebd54108570d7976276c95aeebe36f5832d Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 15:43:03 -0400 Subject: [PATCH 47/53] add amm_account option to AmmInfoRequestPArams --- .../client/amm/AmmInfoRequestParams.java | 49 ++++++++++++++++--- .../client/amm/AmmInfoRequestParamsTest.java | 31 ++++++++---- .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 27 +++++----- 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java index 7fdf2c0b6..bc9b75f0a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java @@ -1,10 +1,14 @@ package org.xrpl.xrpl4j.model.client.amm; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplRequestParams; import org.xrpl.xrpl4j.model.ledger.Issue; +import org.xrpl.xrpl4j.model.transactions.Address; + +import java.util.Optional; /** * Request parameters for the {@code amm_info} rippled API method. @@ -15,26 +19,59 @@ public interface AmmInfoRequestParams extends XrplRequestParams { /** - * Construct a {@code AmmInfoRequestParams} builder. + * Construct a new {@link AmmInfoRequestParams} that specifies the AMM account to query. + * + * @param ammAccount The {@link Address} of the AMM account. + * + * @return An {@link AmmInfoRequestParams}. + */ + static AmmInfoRequestParams from(Address ammAccount) { + return ImmutableAmmInfoRequestParams.builder() + .ammAccount(ammAccount) + .build(); + } + + /** + * Construct a new {@link AmmInfoRequestParams} that specifies {@code asset} and {@code asset2}. + * + * @param asset The first asset of the AMM, as an {@link Issue}. + * @param asset2 The second asset of the AMM, as an {@link Issue}. * - * @return An {@link ImmutableAmmInfoRequestParams.Builder}. + * @return An {@link AmmInfoRequestParams}. */ - static ImmutableAmmInfoRequestParams.Builder builder() { - return ImmutableAmmInfoRequestParams.builder(); + static AmmInfoRequestParams from(Issue asset, Issue asset2) { + return ImmutableAmmInfoRequestParams.builder() + .asset(asset) + .asset2(asset2) + .build(); } + /** + * The address of the AMM's special AccountRoot. (This is the issuer of the AMM's LP Tokens). + * + *

If this field is specified, {@link #asset()} and {@link #asset2()} must be empty.

+ * + * @return An {@link Optional} {@link Address}. + */ + @JsonProperty("amm_account") + Optional
ammAccount(); + /** * One of the assets of the AMM to look up. * + *

If this field is specified, {@link #asset2()} must be present, and {@link #ammAccount()} must be empty.

+ * * @return An {@link Issue}. */ - Issue asset(); + Optional asset(); /** * The other of the assets of the AMM. * + *

If this field is specified, {@link #asset()} must be present, and {@link #ammAccount()} must be empty.

+ * * @return An {@link Issue}. */ - Issue asset2(); + Optional asset2(); } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java index b18ac0f05..a06cbaece 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParamsTest.java @@ -10,16 +10,14 @@ class AmmInfoRequestParamsTest extends AbstractJsonTest { @Test - void testJson() throws JSONException, JsonProcessingException { - AmmInfoRequestParams params = AmmInfoRequestParams.builder() - .asset(Issue.XRP) - .asset2( - Issue.builder() - .currency("TST") - .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) - .build() - ) - .build(); + void testAssetAsset2Json() throws JSONException, JsonProcessingException { + AmmInfoRequestParams params = AmmInfoRequestParams.from( + Issue.XRP, + Issue.builder() + .currency("TST") + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .build() + ); String json = "{\n" + " \"asset\": {\n" + " \"currency\": \"XRP\"\n" + @@ -32,4 +30,17 @@ void testJson() throws JSONException, JsonProcessingException { assertCanSerializeAndDeserialize(params, json); } + + @Test + void testAmmAccountJson() throws JSONException, JsonProcessingException { + AmmInfoRequestParams params = AmmInfoRequestParams.from( + Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd") + ); + + String json = "{\n" + + " \"amm_account\": \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " }"; + + assertCanSerializeAndDeserialize(params, json); + } } \ No newline at end of file diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 2c58b073a..1789e11af 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -256,8 +256,8 @@ void depositAndWithdraw() throws JsonRpcClientErrorException, JsonProcessingExce ); AmmInfoResult ammAfterWithdraw = getAmmInfo(issuerKeyPair); - assertThat(ammAfterWithdraw.amm().amount2()).isInstanceOf(XrpCurrencyAmount.class) - .isEqualTo(((XrpCurrencyAmount) ammInfoAfterDeposit.amm().amount2()) + assertThat(ammAfterWithdraw.amm().amount()).isInstanceOf(XrpCurrencyAmount.class) + .isEqualTo(((XrpCurrencyAmount) ammInfoAfterDeposit.amm().amount()) .minus((XrpCurrencyAmount) withdraw.amount().get())); AccountInfoResult traderAccountAfterWithdraw = xrplClient.accountInfo( @@ -382,16 +382,13 @@ private AmmInfoResult createAmm( private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErrorException { AmmInfoResult ammInfoResult = xrplClient.ammInfo( - AmmInfoRequestParams.builder() - .asset( - Issue.builder() - .issuer(issuerKeyPair.publicKey().deriveAddress()) - .currency(xrpl4jCoin) - .build() - ) - .asset2(Issue.XRP) - .build() - ); + AmmInfoRequestParams.from( + Issue.XRP, + Issue.builder() + .issuer(issuerKeyPair.publicKey().deriveAddress()) + .currency(xrpl4jCoin) + .build() + )); AccountInfoResult ammAccountInfo = xrplClient.accountInfo( AccountInfoRequestParams.of(ammInfoResult.amm().account()) @@ -399,6 +396,12 @@ private AmmInfoResult getAmmInfo(KeyPair issuerKeyPair) throws JsonRpcClientErro assertThat(ammAccountInfo.accountData().ammId()).isNotEmpty(); + AmmInfoResult ammInfoByAccount = xrplClient.ammInfo( + AmmInfoRequestParams.from(ammAccountInfo.accountData().account()) + ); + + assertThat(ammInfoByAccount).isEqualTo(ammInfoResult); + return ammInfoResult; } From df3489124fc44729fd352a774c745c7629a8ca1e Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Mon, 18 Sep 2023 16:31:50 -0400 Subject: [PATCH 48/53] add AmmDelete transaction --- .../xrpl4j/crypto/signing/SignatureUtils.java | 9 + .../xrpl4j/model/transactions/AmmDelete.java | 56 ++++ .../model/transactions/Transaction.java | 1 + .../model/transactions/TransactionType.java | 7 +- .../src/main/resources/definitions.json | 256 +++++++++++++++++- .../crypto/signing/SignatureUtilsTest.java | 40 +++ .../model/transactions/AmmDeleteTest.java | 49 ++++ .../java/org/xrpl/xrpl4j/tests/AmmIT.java | 3 + 8 files changed, 418 insertions(+), 3 deletions(-) create mode 100644 xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java create mode 100644 xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java index 18bf6f1e6..a9c5cdb0a 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java @@ -33,6 +33,7 @@ import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDelete; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; import org.xrpl.xrpl4j.model.transactions.AmmVote; import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; @@ -296,6 +297,10 @@ public SingleSignedTransaction addSignatureToTransact transactionWithSignature = AmmWithdraw.builder().from((AmmWithdraw) transaction) .transactionSignature(signature) .build(); + } else if (AmmDelete.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignature = AmmDelete.builder().from((AmmDelete) transaction) + .transactionSignature(signature) + .build(); } else { // Should never happen, but will in a unit test if we miss one. throw new IllegalArgumentException("Signing fields could not be added to the transaction."); @@ -450,6 +455,10 @@ public T addMultiSignaturesToTransaction(T transaction, transactionWithSignatures = AmmWithdraw.builder().from((AmmWithdraw) transaction) .signers(signers) .build(); + } else if (AmmDelete.class.isAssignableFrom(transaction.getClass())) { + transactionWithSignatures = AmmDelete.builder().from((AmmDelete) transaction) + .signers(signers) + .build(); } else { // Should never happen, but will in a unit test if we miss one. throw new IllegalArgumentException("Signing fields could not be added to the transaction."); diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java new file mode 100644 index 000000000..06cef28f2 --- /dev/null +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java @@ -0,0 +1,56 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.immutables.value.Value; +import org.immutables.value.Value.Immutable; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; +import org.xrpl.xrpl4j.model.ledger.Issue; + +/** + * Object mapping for the AMMDelete transaction. + */ +@Immutable +@JsonSerialize(as = ImmutableAmmDelete.class) +@JsonDeserialize(as = ImmutableAmmDelete.class) +public interface AmmDelete extends Transaction { + + /** + * Construct a {@code AmmDelete} builder. + * + * @return An {@link ImmutableAmmDelete.Builder}. + */ + static ImmutableAmmDelete.Builder builder() { + return ImmutableAmmDelete.builder(); + } + + /** + * Set of {@link TransactionFlags}s for this {@link AmmDelete}, which only allows the + * {@code tfFullyCanonicalSig} flag, which is deprecated. + * + * @return Always {@link TransactionFlags#EMPTY}. + */ + @JsonProperty("Flags") + @Value.Default + default TransactionFlags flags() { + return TransactionFlags.EMPTY; + } + + /** + * The definition for one of the assets in the AMM's pool. + * + * @return An {@link Issue}. + */ + @JsonProperty("Asset") + Issue asset(); + + /** + * The definition for the other asset in the AMM's pool. + * + * @return An {@link Issue}. + */ + @JsonProperty("Asset2") + Issue asset2(); + +} diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java index d3e9416b2..8d4603fc2 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Transaction.java @@ -76,6 +76,7 @@ public interface Transaction { .put(ImmutableAmmDeposit.class, TransactionType.AMM_DEPOSIT) .put(ImmutableAmmVote.class, TransactionType.AMM_VOTE) .put(ImmutableAmmWithdraw.class, TransactionType.AMM_WITHDRAW) + .put(ImmutableAmmDelete.class, TransactionType.AMM_DELETE) .build(); /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index 7afd5b724..71c2d41b4 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -185,7 +185,12 @@ public enum TransactionType { /** * The {@link TransactionType} for the {@link AmmWithdraw} transaction. */ - AMM_WITHDRAW("AMMWithdraw"); + AMM_WITHDRAW("AMMWithdraw"), + + /** + * The {@link TransactionType} for the {@link AmmDelete} transaction. + */ + AMM_DELETE("AMMDelete"); private final String value; diff --git a/xrpl4j-core/src/main/resources/definitions.json b/xrpl4j-core/src/main/resources/definitions.json index 4165f19e2..b6b48f440 100644 --- a/xrpl4j-core/src/main/resources/definitions.json +++ b/xrpl4j-core/src/main/resources/definitions.json @@ -22,6 +22,7 @@ "UInt384": 22, "UInt512": 23, "Issue": 24, + "XChainBridge": 25, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -35,8 +36,11 @@ "Ticket": 84, "SignerList": 83, "Offer": 111, + "Bridge": 105, "LedgerHashes": 104, "Amendments": 102, + "XChainOwnedClaimID": 113, + "XChainOwnedCreateAccountClaimID": 116, "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, @@ -233,6 +237,16 @@ "type": "UInt8" } ], + [ + "WasLockingChainSend", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], [ "LedgerEntryType", { @@ -983,6 +997,36 @@ "type": "UInt64" } ], + [ + "XChainClaimID", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "XChainAccountCreateCount", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "XChainAccountClaimCount", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], [ "EmailHash", { @@ -1583,6 +1627,26 @@ "type": "Amount" } ], + [ + "SignatureReward", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "MinAccountCreateAmount", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], [ "LPTokenBalance", { @@ -1933,6 +1997,66 @@ "type": "AccountID" } ], + [ + "OtherChainSource", + { + "nth": 18, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "OtherChainDestination", + { + "nth": 19, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "AttestationSignerAccount", + { + "nth": 20, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "AttestationRewardAccount", + { + "nth": 21, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "LockingChainDoor", + { + "nth": 22, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "IssuingChainDoor", + { + "nth": 23, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], [ "Indexes", { @@ -1983,6 +2107,26 @@ "type": "PathSet" } ], + [ + "LockingChainIssue", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Issue" + } + ], + [ + "IssuingChainIssue", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Issue" + } + ], [ "Asset", { @@ -2003,6 +2147,16 @@ "type": "Issue" } ], + [ + "XChainBridge", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "XChainBridge" + } + ], [ "TransactionMetaData", { @@ -2243,6 +2397,46 @@ "type": "STObject" } ], + [ + "XChainClaimProofSig", + { + "nth": 28, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainCreateAccountProofSig", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainClaimAttestationCollectionElement", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainCreateAccountAttestationCollectionElement", + { + "nth": 31, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], [ "Signers", { @@ -2393,6 +2587,26 @@ "type": "STArray" } ], + [ + "XChainClaimAttestations", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "XChainCreateAccountAttestations", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], [ "AuthAccounts", { @@ -2461,6 +2675,12 @@ "temSEQ_AND_TICKET": -263, "temBAD_NFTOKEN_TRANSFER_FEE": -262, "temBAD_AMM_TOKENS": -261, + "temXCHAIN_EQUAL_DOOR_ACCOUNTS": -260, + "temXCHAIN_BAD_PROOF": -259, + "temXCHAIN_BRIDGE_BAD_ISSUES": -258, + "temXCHAIN_BRIDGE_NONDOOR_OWNER": -257, + "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256, + "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255, "tefFAILURE": -199, "tefALREADY": -198, @@ -2497,6 +2717,7 @@ "terQUEUED": -89, "terPRE_TICKET": -88, "terNO_AMM": -87, + "terSUBMITTED": -86, "tesSUCCESS": 0, @@ -2538,6 +2759,7 @@ "tecKILLED": 150, "tecHAS_OBLIGATIONS": 151, "tecTOO_SOON": 152, + "tecHOOK_ERROR": 153, "tecMAX_SEQUENCE_REACHED": 154, "tecNO_SUITABLE_NFTOKEN_PAGE": 155, "tecNFTOKEN_BUY_SELL_MISMATCH": 156, @@ -2549,7 +2771,28 @@ "tecUNFUNDED_AMM": 162, "tecAMM_BALANCE": 163, "tecAMM_FAILED": 164, - "tecAMM_INVALID_TOKENS": 165 + "tecAMM_INVALID_TOKENS": 165, + "tecAMM_EMPTY": 166, + "tecAMM_NOT_EMPTY": 167, + "tecAMM_ACCOUNT": 168, + "tecINCOMPLETE": 169, + "tecXCHAIN_BAD_TRANSFER_ISSUE": 170, + "tecXCHAIN_NO_CLAIM_ID": 171, + "tecXCHAIN_BAD_CLAIM_ID": 172, + "tecXCHAIN_CLAIM_NO_QUORUM": 173, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 174, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 175, + "tecXCHAIN_WRONG_CHAIN": 176, + "tecXCHAIN_REWARD_MISMATCH": 177, + "tecXCHAIN_NO_SIGNERS_LIST": 178, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 179, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 180, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 181, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182, + "tecXCHAIN_PAYMENT_FAILED": 183, + "tecXCHAIN_SELF_COMMIT": 184, + "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 185, + "tecXCHAIN_CREATE_ACCOUNT_DISABLED": 186 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2587,8 +2830,17 @@ "AMMWithdraw": 37, "AMMVote": 38, "AMMBid": 39, + "AMMDelete": 40, + "XChainCreateClaimID": 41, + "XChainCommit": 42, + "XChainClaim": 43, + "XChainAccountCreateCommit": 44, + "XChainAddClaimAttestation": 45, + "XChainAddAccountCreateAttestation": 46, + "XChainModifyBridge": 47, + "XChainCreateBridge": 48, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 } -} \ No newline at end of file +} diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java index e5b028305..b8da48a94 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java @@ -49,6 +49,7 @@ import org.xrpl.xrpl4j.model.client.channels.UnsignedClaim; import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.flags.AmmWithdrawFlags; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccount; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; import org.xrpl.xrpl4j.model.ledger.Issue; @@ -57,6 +58,7 @@ import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDelete; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; import org.xrpl.xrpl4j.model.transactions.AmmVote; import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; @@ -693,6 +695,25 @@ void addSignatureToAmmWithdraw() { addSignatureToTransactionHelper(withdraw); } + @Test + void addSignatureToAmmDelete() { + AmmDelete ammDelete = AmmDelete.builder() + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .flags(TransactionFlags.UNSET) + .signingPublicKey(sourcePublicKey) + .build(); + + addSignatureToTransactionHelper(ammDelete); + } @Test public void addSignatureToTransactionUnsupported() { @@ -1117,6 +1138,25 @@ void addMultiSignatureToAmmWithdraw() { addMultiSignatureToTransactionHelper(withdraw); } + @Test + void addMultiSignatureToAmmDelete() { + AmmDelete ammDelete = AmmDelete.builder() + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .flags(TransactionFlags.UNSET) + .build(); + + addMultiSignatureToTransactionHelper(ammDelete); + } + @Test public void addMultiSignaturesToTransactionUnsupported() { when(transactionMock.transactionSignature()).thenReturn(Optional.empty()); diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java new file mode 100644 index 000000000..cf6a814de --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java @@ -0,0 +1,49 @@ +package org.xrpl.xrpl4j.model.transactions; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.crypto.keys.PublicKey; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.TransactionFlags; +import org.xrpl.xrpl4j.model.ledger.Issue; + +class AmmDeleteTest extends AbstractJsonTest { + + @Test + void testJson() throws JSONException, JsonProcessingException { + AmmDelete ammDelete = AmmDelete.builder() + .asset(Issue.XRP) + .asset2( + Issue.builder() + .issuer(Address.of("rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd")) + .currency("TST") + .build() + ) + .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) + .fee(XrpCurrencyAmount.ofDrops(10)) + .sequence(UnsignedInteger.valueOf(9)) + .flags(TransactionFlags.UNSET) + .signingPublicKey(PublicKey.fromBase16EncodedPublicKey("EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156")) + .build(); + + String json = "{\n" + + " \"Account\" : \"rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm\",\n" + + " \"Asset\" : {\n" + + " \"currency\" : \"XRP\"\n" + + " },\n" + + " \"Asset2\" : {\n" + + " \"currency\" : \"TST\",\n" + + " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + + " },\n" + + " \"Fee\" : \"10\",\n" + + " \"Flags\" : 0,\n" + + " \"Sequence\" : 9,\n" + + " \"SigningPubKey\" : \"EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156\",\n" + + " \"TransactionType\" : \"AMMDelete\"\n" + + "}"; + + assertCanSerializeAndDeserialize(ammDelete, json); + } +} \ No newline at end of file diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java index 1789e11af..861930403 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java @@ -20,6 +20,7 @@ import org.xrpl.xrpl4j.model.client.amm.AmmInfoAuctionSlot; import org.xrpl.xrpl4j.model.client.amm.AmmInfoRequestParams; import org.xrpl.xrpl4j.model.client.amm.AmmInfoResult; +import org.xrpl.xrpl4j.model.client.common.LedgerIndex; import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier; import org.xrpl.xrpl4j.model.client.fees.FeeResult; import org.xrpl.xrpl4j.model.client.fees.FeeUtils; @@ -33,9 +34,11 @@ import org.xrpl.xrpl4j.model.transactions.AccountSet.AccountSetFlag; import org.xrpl.xrpl4j.model.transactions.AmmBid; import org.xrpl.xrpl4j.model.transactions.AmmCreate; +import org.xrpl.xrpl4j.model.transactions.AmmDelete; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; import org.xrpl.xrpl4j.model.transactions.AmmVote; import org.xrpl.xrpl4j.model.transactions.AmmWithdraw; +import org.xrpl.xrpl4j.model.transactions.ImmutableAmmWithdraw; import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount; import org.xrpl.xrpl4j.model.transactions.TradingFee; import org.xrpl.xrpl4j.model.transactions.TransactionResultCodes; From c1de7aad2094d7fffba1cd96abaaf0de08614197 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 19 Sep 2023 08:48:25 -0400 Subject: [PATCH 49/53] checkstyle --- .../org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java index cf6a814de..ddf50f70f 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java @@ -25,7 +25,9 @@ void testJson() throws JSONException, JsonProcessingException { .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(9)) .flags(TransactionFlags.UNSET) - .signingPublicKey(PublicKey.fromBase16EncodedPublicKey("EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156")) + .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( + "EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156" + )) .build(); String json = "{\n" + From c9d15be418823acb615a7d9d9497ccefa3bdff71 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 19 Sep 2023 12:01:22 -0400 Subject: [PATCH 50/53] add more coverage --- .../xrpl4j/model/flags/AmmDepositFlagsTest.java | 13 +++++++++++++ .../xrpl4j/model/transactions/AmmDeleteTest.java | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java index e6c9d2e57..f011c82a4 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlagsTest.java @@ -14,6 +14,7 @@ void testFlagValues() { assertThat(lpToken.tfTwoAsset()).isFalse(); assertThat(lpToken.tfOneAssetLpToken()).isFalse(); assertThat(lpToken.tfLimitLpToken()).isFalse(); + assertThat(lpToken.tfTwoAssetIfEmpty()).isFalse(); AmmDepositFlags singleAsset = AmmDepositFlags.SINGLE_ASSET; assertThat(singleAsset.tfLpToken()).isFalse(); @@ -21,6 +22,7 @@ void testFlagValues() { assertThat(singleAsset.tfTwoAsset()).isFalse(); assertThat(singleAsset.tfOneAssetLpToken()).isFalse(); assertThat(singleAsset.tfLimitLpToken()).isFalse(); + assertThat(singleAsset.tfTwoAssetIfEmpty()).isFalse(); AmmDepositFlags twoAsset = AmmDepositFlags.TWO_ASSET; assertThat(twoAsset.tfLpToken()).isFalse(); @@ -28,6 +30,7 @@ void testFlagValues() { assertThat(twoAsset.tfTwoAsset()).isTrue(); assertThat(twoAsset.tfOneAssetLpToken()).isFalse(); assertThat(twoAsset.tfLimitLpToken()).isFalse(); + assertThat(twoAsset.tfTwoAssetIfEmpty()).isFalse(); AmmDepositFlags oneAssetLpToken = AmmDepositFlags.ONE_ASSET_LP_TOKEN; assertThat(oneAssetLpToken.tfLpToken()).isFalse(); @@ -35,6 +38,7 @@ void testFlagValues() { assertThat(oneAssetLpToken.tfTwoAsset()).isFalse(); assertThat(oneAssetLpToken.tfOneAssetLpToken()).isTrue(); assertThat(oneAssetLpToken.tfLimitLpToken()).isFalse(); + assertThat(oneAssetLpToken.tfTwoAssetIfEmpty()).isFalse(); AmmDepositFlags limitLpToken = AmmDepositFlags.LIMIT_LP_TOKEN; assertThat(limitLpToken.tfLpToken()).isFalse(); @@ -42,5 +46,14 @@ void testFlagValues() { assertThat(limitLpToken.tfTwoAsset()).isFalse(); assertThat(limitLpToken.tfOneAssetLpToken()).isFalse(); assertThat(limitLpToken.tfLimitLpToken()).isTrue(); + assertThat(limitLpToken.tfTwoAssetIfEmpty()).isFalse(); + + AmmDepositFlags twoAssetIfEmpty = AmmDepositFlags.TWO_ASSET_IF_EMPTY; + assertThat(twoAssetIfEmpty.tfLpToken()).isFalse(); + assertThat(twoAssetIfEmpty.tfSingleAsset()).isFalse(); + assertThat(twoAssetIfEmpty.tfTwoAsset()).isFalse(); + assertThat(twoAssetIfEmpty.tfOneAssetLpToken()).isFalse(); + assertThat(twoAssetIfEmpty.tfLimitLpToken()).isFalse(); + assertThat(twoAssetIfEmpty.tfTwoAssetIfEmpty()).isTrue(); } } diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java index ddf50f70f..2889e572e 100644 --- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmDeleteTest.java @@ -24,7 +24,6 @@ void testJson() throws JSONException, JsonProcessingException { .account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) .fee(XrpCurrencyAmount.ofDrops(10)) .sequence(UnsignedInteger.valueOf(9)) - .flags(TransactionFlags.UNSET) .signingPublicKey(PublicKey.fromBase16EncodedPublicKey( "EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156" )) @@ -40,7 +39,6 @@ void testJson() throws JSONException, JsonProcessingException { " \"issuer\" : \"rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd\"\n" + " },\n" + " \"Fee\" : \"10\",\n" + - " \"Flags\" : 0,\n" + " \"Sequence\" : 9,\n" + " \"SigningPubKey\" : \"EDD299D60BCE7980F6082945B5597FFFD35223F1950673BFA4D4AED6FDE5097156\",\n" + " \"TransactionType\" : \"AMMDelete\"\n" + From 97aa77df4213d0292584926989c13f0260ab4179 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 19 Sep 2023 14:12:28 -0400 Subject: [PATCH 51/53] make all AMM code @Beta --- .../org/xrpl/xrpl4j/client/XrplClient.java | 1 + .../xrpl/xrpl4j/model/client/XrplMethods.java | 3 +++ .../xrpl/xrpl4j/model/client/amm/AmmInfo.java | 5 ++++ .../model/client/amm/AmmInfoAuctionSlot.java | 5 ++++ .../model/client/amm/AmmInfoAuthAccount.java | 5 ++++ .../client/amm/AmmInfoRequestParams.java | 5 ++++ .../model/client/amm/AmmInfoResult.java | 5 ++++ .../model/client/amm/AmmInfoVoteEntry.java | 5 ++++ .../xrpl4j/model/flags/AmmDepositFlags.java | 10 +++++--- .../xrpl4j/model/flags/AmmWithdrawFlags.java | 6 +++++ .../model/ledger/AccountRootObject.java | 5 ++++ .../xrpl/xrpl4j/model/ledger/AmmObject.java | 5 ++++ .../xrpl/xrpl4j/model/ledger/AuctionSlot.java | 5 ++++ .../xrpl/xrpl4j/model/ledger/AuthAccount.java | 5 ++++ .../model/ledger/AuthAccountWrapper.java | 5 ++++ .../xrpl4j/model/ledger/LedgerObject.java | 5 ++++ .../xrpl/xrpl4j/model/ledger/VoteEntry.java | 5 ++++ .../xrpl4j/model/ledger/VoteEntryWrapper.java | 5 ++++ .../xrpl4j/model/transactions/AmmBid.java | 9 +++++-- .../xrpl4j/model/transactions/AmmCreate.java | 9 +++++-- .../xrpl4j/model/transactions/AmmDelete.java | 9 +++++-- .../xrpl4j/model/transactions/AmmDeposit.java | 13 +++++++--- .../xrpl4j/model/transactions/AmmVote.java | 9 +++++-- .../model/transactions/AmmWithdraw.java | 13 +++++++--- .../model/transactions/TransactionType.java | 25 +++++++++++++++++++ .../xrpl4j/model/transactions/Wrappers.java | 13 ++++++++-- .../transactions/metadata/MetaAmmObject.java | 11 +++++--- .../metadata/MetaAuctionSlot.java | 5 ++++ .../metadata/MetaAuthAccount.java | 5 ++++ .../metadata/MetaAuthAccountWrapper.java | 5 ++++ .../transactions/metadata/MetaVoteEntry.java | 5 ++++ .../metadata/MetaVoteEntryWrapper.java | 5 ++++ 32 files changed, 202 insertions(+), 24 deletions(-) diff --git a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java index 5e3f77b32..7767c97c1 100644 --- a/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java +++ b/xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java @@ -772,6 +772,7 @@ public GatewayBalancesResult gatewayBalances( * @return A {@link AmmInfoResult}. * @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error. */ + @Beta public AmmInfoResult ammInfo( AmmInfoRequestParams params ) throws JsonRpcClientErrorException { diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java index dc7dd3663..13e765602 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/XrplMethods.java @@ -20,6 +20,8 @@ * =========================LICENSE_END================================== */ +import com.google.common.annotations.Beta; + /** * A definition class for all rippled method name constants. */ @@ -179,6 +181,7 @@ public class XrplMethods { /** * Constant for the ripple_path_find rippled API method. */ + @Beta public static final String AMM_INFO = "amm_info"; // Payment Channel methods diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java index b20bfc559..94a81b4cd 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfo.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.transactions.Address; @@ -17,10 +18,14 @@ * Information about the requested AMM ledger entry. This response is very closely related to * {@link org.xrpl.xrpl4j.model.ledger.AmmObject}, however rippled returns the object in a different format in * responses to {@code amm_info} RPC requests. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfo.class) @JsonDeserialize(as = ImmutableAmmInfo.class) +@Beta public interface AmmInfo extends XrplResult { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java index bab1968ce..5583a68e1 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuctionSlot.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; @@ -17,10 +18,14 @@ * Object mapping for an AMM auction slot returned in response to an {@code amm_info} RPC call. The structure * of the response object is similar but has a slightly different format from * {@link org.xrpl.xrpl4j.model.ledger.AuctionSlot}. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoAuctionSlot.class) @JsonDeserialize(as = ImmutableAmmInfoAuctionSlot.class) +@Beta public interface AmmInfoAuctionSlot { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java index f9a11decf..6df3907dc 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoAuthAccount.java @@ -2,15 +2,20 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; /** * An account that is authorized to trade at the discounted fee for an AMM instance. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoAuthAccount.class) @JsonDeserialize(as = ImmutableAmmInfoAuthAccount.class) +@Beta public interface AmmInfoAuthAccount { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java index bc9b75f0a..622af735e 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoRequestParams.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplRequestParams; import org.xrpl.xrpl4j.model.ledger.Issue; @@ -12,10 +13,14 @@ /** * Request parameters for the {@code amm_info} rippled API method. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoRequestParams.class) @JsonDeserialize(as = ImmutableAmmInfoRequestParams.class) +@Beta public interface AmmInfoRequestParams extends XrplRequestParams { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java index fbfd7e239..b7edbfd40 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoResult.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.client.XrplResult; import org.xrpl.xrpl4j.model.client.common.LedgerIndex; @@ -13,10 +14,14 @@ /** * The result of an "amm_info" rippled API method call. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoResult.class) @JsonDeserialize(as = ImmutableAmmInfoResult.class) +@Beta public interface AmmInfoResult extends XrplResult { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java index 86e61c697..020de79e8 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/amm/AmmInfoVoteEntry.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntry; import org.xrpl.xrpl4j.model.transactions.Address; @@ -11,10 +12,14 @@ /** * Describes a vote for the trading fee on an AMM by an LP. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmInfoVoteEntry.class) @JsonDeserialize(as = ImmutableAmmInfoVoteEntry.class) +@Beta public interface AmmInfoVoteEntry { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java index a7a197815..570c2b903 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmDepositFlags.java @@ -1,16 +1,20 @@ package org.xrpl.xrpl4j.model.flags; +import com.google.common.annotations.Beta; import org.xrpl.xrpl4j.model.transactions.AmmDeposit; /** - * A set of {@link TransactionFlags} that can be set on {@link AmmDeposit} transactions. Exactly - * one flag must be set on each {@link AmmDeposit} transaction, so this class does not allow for combination - * of multiple flags. + * A set of {@link TransactionFlags} that can be set on {@link AmmDeposit} transactions. Exactly one flag must be set on + * each {@link AmmDeposit} transaction, so this class does not allow for combination of multiple flags. * *

While most other TransactionFlags support empty flags or 0, AmmDeposit transactions must have a Flags field * to denote the deposit mode. Therefore, AmmDepositFlags does not support empty or unset flags. *

+ * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ +@Beta public class AmmDepositFlags extends TransactionFlags { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java index 1c835584a..dfdc55bb7 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmWithdrawFlags.java @@ -1,5 +1,7 @@ package org.xrpl.xrpl4j.model.flags; +import com.google.common.annotations.Beta; + /** * A set of {@link TransactionFlags} that can be set on {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} * transactions. Exactly one flag must be set on each {@link org.xrpl.xrpl4j.model.transactions.AmmWithdraw} @@ -8,7 +10,11 @@ *

While most other TransactionFlags support empty flags or 0, AmmWithdraw transactions must have a Flags field * to denote the withdraw mode. Therefore, AmmWithdrawFlags does not support empty or unset flags. *

+ * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ +@Beta public class AmmWithdrawFlags extends TransactionFlags { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java index c212141bb..7df5d67df 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.AccountRootFlags; @@ -229,8 +230,12 @@ default LedgerEntryType ledgerEntryType() { * The ledger entry ID of the corresponding AMM ledger entry. Set during account creation; cannot be modified. * If present, indicates that this is a special AMM AccountRoot; always omitted on non-AMM accounts. * + *

This method will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

+ * * @return An optionally-present {@link Hash256}. */ + @Beta @JsonProperty("AMMID") Optional ammId(); diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java index 5eea812a8..dd696fe18 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AmmObject.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.transactions.Address; @@ -16,10 +17,14 @@ /** * Represents an AMM ledger object, which describes a single Automated Market Maker instance. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmObject.class) @JsonDeserialize(as = ImmutableAmmObject.class) +@Beta public interface AmmObject extends LedgerObject { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java index e5ab7954c..0deb2c1f2 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuctionSlot.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; @@ -16,10 +17,14 @@ /** * Represents an AuctionSlot object in an {@link AmmObject}, containing details of the current owner of the auction * slot. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAuctionSlot.class) @JsonDeserialize(as = ImmutableAuctionSlot.class) +@Beta public interface AuctionSlot { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java index a826adfe3..402d9d9d0 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccount.java @@ -3,15 +3,20 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; /** * An account that is authorized to trade at the discounted fee for an AMM instance. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAuthAccount.class) @JsonDeserialize(as = ImmutableAuthAccount.class) +@Beta public interface AuthAccount { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java index c7a5bc19b..e9fc3ea63 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AuthAccountWrapper.java @@ -3,14 +3,19 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; /** * A wrapper around {@link AuthAccount}s. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAuthAccountWrapper.class) @JsonDeserialize(as = ImmutableAuthAccountWrapper.class) +@Beta public interface AuthAccountWrapper { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java index 420a141f4..b6b7e1b2f 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/LedgerObject.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; /** * Market interface for XRP Ledger Objects. @@ -144,7 +145,11 @@ enum LedgerEntryType { /** * The {@link LedgerEntryType} for {@code AmmObject} ledger objects. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM("AMM"); private final String value; diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java index 5fbbb15a9..3bb2fd063 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntry.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.transactions.Address; import org.xrpl.xrpl4j.model.transactions.TradingFee; @@ -10,10 +11,14 @@ /** * Describes a vote for the trading fee on an AMM by an LP. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableVoteEntry.class) @JsonDeserialize(as = ImmutableVoteEntry.class) +@Beta public interface VoteEntry { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java index 560a328b0..70a058775 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/VoteEntryWrapper.java @@ -3,14 +3,19 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; /** * A wrapper around a {@link VoteEntry}. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableVoteEntryWrapper.class) @JsonDeserialize(as = ImmutableVoteEntryWrapper.class) +@Beta public interface VoteEntryWrapper { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java index 07b2de6e4..24872f827 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.AuthAccountWrapper; @@ -13,10 +14,14 @@ /** * Object mapping for the AMMBid transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmBid.class) @JsonDeserialize(as = ImmutableAmmBid.class) +@Beta public interface AmmBid extends Transaction { /** @@ -29,8 +34,8 @@ static ImmutableAmmBid.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmBid}, which only allows the - * {@code tfFullyCanonicalSig} flag, which is deprecated. + * Set of {@link TransactionFlags}s for this {@link AmmBid}, which only allows the {@code tfFullyCanonicalSig} flag, + * which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java index bf79e8122..dab53fa96 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmCreate.java @@ -3,16 +3,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.Flags; import org.xrpl.xrpl4j.model.flags.TransactionFlags; /** * Object mapping for the AMMCreate transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmCreate.class) @JsonDeserialize(as = ImmutableAmmCreate.class) +@Beta public interface AmmCreate extends Transaction { /** @@ -25,8 +30,8 @@ static ImmutableAmmCreate.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmCreate}, which only allows the - * {@code tfFullyCanonicalSig} flag, which is deprecated. + * Set of {@link TransactionFlags}s for this {@link AmmCreate}, which only allows the {@code tfFullyCanonicalSig} + * flag, which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java index 06cef28f2..6af820fb3 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDelete.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.flags.TransactionFlags; @@ -10,10 +11,14 @@ /** * Object mapping for the AMMDelete transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableAmmDelete.class) @JsonDeserialize(as = ImmutableAmmDelete.class) +@Beta public interface AmmDelete extends Transaction { /** @@ -26,8 +31,8 @@ static ImmutableAmmDelete.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmDelete}, which only allows the - * {@code tfFullyCanonicalSig} flag, which is deprecated. + * Set of {@link TransactionFlags}s for this {@link AmmDelete}, which only allows the {@code tfFullyCanonicalSig} + * flag, which is deprecated. * * @return Always {@link TransactionFlags#EMPTY}. */ diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java index 1f872135e..1336e27a6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmDeposit.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.AmmDepositFlags; import org.xrpl.xrpl4j.model.ledger.Issue; @@ -11,10 +12,14 @@ /** * Object mapping for the AMMDeposit transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmDeposit.class) @JsonDeserialize(as = ImmutableAmmDeposit.class) +@Beta public interface AmmDeposit extends Transaction { /** @@ -51,8 +56,8 @@ static ImmutableAmmDeposit.Builder builder() { Issue asset2(); /** - * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets - * (tokens or XRP) in the AMM's pool. + * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets (tokens or + * XRP) in the AMM's pool. * * @return An optionally present {@link CurrencyAmount}. */ @@ -60,8 +65,8 @@ static ImmutableAmmDeposit.Builder builder() { Optional amount(); /** - * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the - * AMM's pool and cannot be the same asset as Amount. + * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the AMM's + * pool and cannot be the same asset as Amount. * * @return An optionally present {@link CurrencyAmount}. */ diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java index 60ef87858..9742cfefb 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmVote.java @@ -3,16 +3,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.xrpl.xrpl4j.model.flags.TransactionFlags; import org.xrpl.xrpl4j.model.ledger.Issue; /** * Object mapping for the AMMVote transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @JsonSerialize(as = ImmutableAmmVote.class) @JsonDeserialize(as = ImmutableAmmVote.class) +@Beta public interface AmmVote extends Transaction { /** @@ -25,8 +30,8 @@ static ImmutableAmmVote.Builder builder() { } /** - * Set of {@link TransactionFlags}s for this {@link AmmVote}, which only allows the - * {@code tfFullyCanonicalSig} flag, which is deprecated. + * Set of {@link TransactionFlags}s for this {@link AmmVote}, which only allows the {@code tfFullyCanonicalSig} flag, + * which is deprecated. * *

The value of the flags cannot be set manually, but exists for JSON serialization/deserialization only and for * proper signature computation in rippled. diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java index 60c0837db..3e0998fde 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmWithdraw.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; @@ -13,10 +14,14 @@ /** * Object mapping for the AMMWithdraw transaction. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableAmmWithdraw.class) @JsonDeserialize(as = ImmutableAmmWithdraw.class) +@Beta public interface AmmWithdraw extends Transaction { /** @@ -53,8 +58,8 @@ static ImmutableAmmWithdraw.Builder builder() { Issue asset2(); /** - * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets - * (tokens or XRP) in the AMM's pool. + * The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets (tokens or + * XRP) in the AMM's pool. * * @return An optionally present {@link CurrencyAmount}. */ @@ -62,8 +67,8 @@ static ImmutableAmmWithdraw.Builder builder() { Optional amount(); /** - * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the - * AMM's pool and cannot be the same asset as Amount. + * The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the AMM's + * pool and cannot be the same asset as Amount. * * @return An optionally present {@link CurrencyAmount}. */ diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java index 71c2d41b4..3819483da 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java @@ -21,6 +21,7 @@ */ import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; /** * Enumeration of the types of Transactions on the XRP Ledger. @@ -164,32 +165,56 @@ public enum TransactionType { /** * The {@link TransactionType} for the {@link AmmBid} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_BID("AMMBid"), /** * The {@link TransactionType} for the {@link AmmCreate} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_CREATE("AMMCreate"), /** * The {@link TransactionType} for the {@link AmmDeposit} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_DEPOSIT("AMMDeposit"), /** * The {@link TransactionType} for the {@link AmmVote} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_VOTE("AMMVote"), /** * The {@link TransactionType} for the {@link AmmWithdraw} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_WITHDRAW("AMMWithdraw"), /** * The {@link TransactionType} for the {@link AmmDelete} transaction. + * + *

This constant will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ + @Beta AMM_DELETE("AMMDelete"); private final String value; diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index df5fbbda9..a82793074 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; import com.google.common.primitives.UnsignedInteger; @@ -343,8 +344,8 @@ public boolean equals(Object obj) { * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. * *

Valid values for this field are between 0 and 50000 inclusive, allowing transfer rates of between 0.00% and - * 50.00% in increments of 0.001. If this field is provided in a {@link NfTokenMint} transaction, the transaction - * MUST have the {@code tfTransferable} flag enabled. + * 50.00% in increments of 0.001. If this field is provided in a {@link NfTokenMint} transaction, the transaction MUST + * have the {@code tfTransferable} flag enabled. */ @Value.Immutable @Wrapped @@ -419,11 +420,15 @@ public static NetworkId of(long networkId) { /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @Wrapped @JsonSerialize(as = TradingFee.class, using = TradingFeeSerializer.class) @JsonDeserialize(as = TradingFee.class, using = TradingFeeDeserializer.class) + @Beta abstract static class _TradingFee extends Wrapper implements Serializable { @Override @@ -459,11 +464,15 @@ public BigDecimal bigDecimalValue() { /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the VoteWeight. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Value.Immutable @Wrapped @JsonSerialize(as = VoteWeight.class, using = VoteWeightSerializer.class) @JsonDeserialize(as = VoteWeight.class, using = VoteWeightDeserializer.class) + @Beta abstract static class _VoteWeight extends Wrapper implements Serializable { @Override diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java index 1eed0f75f..0274920f5 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAmmObject.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.flags.Flags; @@ -20,10 +21,14 @@ /** * Represents an AMM ledger object, which describes a single Automated Market Maker instance. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaAmmObject.class) @JsonDeserialize(as = ImmutableMetaAmmObject.class) +@Beta public interface MetaAmmObject extends MetaLedgerObject { /** @@ -70,9 +75,9 @@ default Flags flags() { Optional auctionSlot(); /** - * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens - * can vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's - * assets which grows with the trading fees collected. + * The total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens can + * vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's assets + * which grows with the trading fees collected. * * @return An {@link IssuedCurrencyAmount}. */ diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java index c718918d6..f61c74c66 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuctionSlot.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import com.google.common.primitives.UnsignedInteger; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; @@ -20,10 +21,14 @@ /** * Represents an AuctionSlot object in an {@link AmmObject}, containing details of the current owner of the auction * slot. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaAuctionSlot.class) @JsonDeserialize(as = ImmutableMetaAuctionSlot.class) +@Beta public interface MetaAuctionSlot { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java index 7e1b3ec7f..5f997cad4 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccount.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.ledger.ImmutableAuthAccount; @@ -10,10 +11,14 @@ /** * An account that is authorized to trade at the discounted fee for an AMM instance. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaAuthAccount.class) @JsonDeserialize(as = ImmutableMetaAuthAccount.class) +@Beta public interface MetaAuthAccount { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java index 98a5a5e1d..fe1c190f6 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaAuthAccountWrapper.java @@ -3,16 +3,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.ledger.ImmutableAuthAccountWrapper; /** * A wrapper around {@link MetaAuthAccount}s. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaAuthAccountWrapper.class) @JsonDeserialize(as = ImmutableMetaAuthAccountWrapper.class) +@Beta public interface MetaAuthAccountWrapper { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java index dab162eba..4e529e71d 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntry.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntry; @@ -14,10 +15,14 @@ /** * Describes a vote for the trading fee on an AMM by an LP. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaVoteEntry.class) @JsonDeserialize(as = ImmutableMetaVoteEntry.class) +@Beta public interface MetaVoteEntry { /** diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java index 7c76d55a0..b92551f0c 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaVoteEntryWrapper.java @@ -3,16 +3,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.annotations.Beta; import org.immutables.value.Value; import org.immutables.value.Value.Immutable; import org.xrpl.xrpl4j.model.ledger.ImmutableVoteEntryWrapper; /** * A wrapper around a {@link MetaVoteEntry}. + * + *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to + * change.

*/ @Immutable @JsonSerialize(as = ImmutableMetaVoteEntryWrapper.class) @JsonDeserialize(as = ImmutableMetaVoteEntryWrapper.class) +@Beta public interface MetaVoteEntryWrapper { /** From 9a120f81e46532cbcb846299cfd52b9ecfb6be32 Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Tue, 19 Sep 2023 14:15:58 -0400 Subject: [PATCH 52/53] fix javadoc errors --- .../org/xrpl/xrpl4j/model/ledger/AccountRootObject.java | 4 ++-- .../java/org/xrpl/xrpl4j/model/transactions/Wrappers.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java index 7df5d67df..3639c6562 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/AccountRootObject.java @@ -230,8 +230,8 @@ default LedgerEntryType ledgerEntryType() { * The ledger entry ID of the corresponding AMM ledger entry. Set during account creation; cannot be modified. * If present, indicates that this is a special AMM AccountRoot; always omitted on non-AMM accounts. * - *

This method will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to - * change.

+ *

This method will be marked {@link com.google.common.annotations.Beta} until the AMM amendment is enabled on + * mainnet. Its API is subject to change.

* * @return An optionally-present {@link Hash256}. */ diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java index a82793074..d746b27f7 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/Wrappers.java @@ -421,8 +421,8 @@ public static NetworkId of(long networkId) { /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee. * - *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to - * change.

+ *

This class will be marked {@link com.google.common.annotations.Beta} until the AMM amendment is enabled on + * mainnet. Its API is subject to change.

*/ @Value.Immutable @Wrapped @@ -465,8 +465,8 @@ public BigDecimal bigDecimalValue() { /** * A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the VoteWeight. * - *

This class will be marked {@link Beta} until the AMM amendment is enabled on mainnet. Its API is subject to - * change.

+ *

This class will be marked {@link com.google.common.annotations.Beta} until the AMM amendment is enabled on + * mainnet. Its API is subject to change.

*/ @Value.Immutable @Wrapped From 804fa586433fdd03912d342eb8f78ccc86c9ecfc Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Wed, 20 Sep 2023 16:18:12 -0400 Subject: [PATCH 53/53] fix build --- .../src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java index a054bc7cf..53307bcba 100644 --- a/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java +++ b/xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AbstractIT.java @@ -24,7 +24,6 @@ import static org.awaitility.Awaitility.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.core.Is.is; import com.fasterxml.jackson.core.JsonProcessingException;