Date: Sat, 2 Nov 2024 17:51:42 -0400
Subject: [PATCH 2/6] Revert "Revert "javadoc""
This reverts commit 2c7c292c0716ed23af88bf6ef2998fd55052c17e.
---
.../transactions/UnknownTransaction.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java
index 1c8f1dbdc..7a54f0122 100644
--- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java
+++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/UnknownTransaction.java
@@ -8,6 +8,9 @@
import org.immutables.value.Value.Immutable;
import org.xrpl.xrpl4j.model.flags.TransactionFlags;
+/**
+ * Mapping for any transaction type that is unrecognized/unsupported by xrpl4j.
+ */
@Immutable
@JsonSerialize(as = ImmutableUnknownTransaction.class)
@JsonDeserialize(as = ImmutableUnknownTransaction.class)
@@ -23,7 +26,9 @@ static ImmutableUnknownTransaction.Builder builder() {
}
/**
- * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType},
+ * The actual transaction type found in the {@code "TransactionType"} field of the transaction JSON.
+ *
+ * This has to be a {@link String} because {@link Transaction#transactionType()} is a {@link TransactionType},
* which only has an UNKNOWN variant. Because this method is also annotated with {@link JsonProperty} of
* "TransactionType", this essentially overrides the "TransactionType" field in JSON, but {@link #transactionType()}
* will always be {@link TransactionType#UNKNOWN} and this field will contain the actual "TransactionType" field.
@@ -33,12 +38,24 @@ static ImmutableUnknownTransaction.Builder builder() {
@JsonProperty("TransactionType")
String unknownTransactionType();
+ /**
+ * The {@link TransactionType} of this UnknownTransaction, which will always be {@link TransactionType#UNKNOWN}.
+ * {@link #unknownTransactionType()} contains the actual transaction type value.
+ *
+ * @return {@link TransactionType#UNKNOWN}.
+ */
@Override
@JsonIgnore
+ @Value.Derived
default TransactionType transactionType() {
return Transaction.super.transactionType();
}
+ /**
+ * A set of {@link TransactionFlags}.
+ *
+ * @return A {@link TransactionFlags}.
+ */
@JsonProperty("Flags")
@Value.Default
default TransactionFlags flags() {
From c8cfa50de653098d9a55e09779814c21e9915a7f Mon Sep 17 00:00:00 2001
From: nkramer44
Date: Sat, 2 Nov 2024 17:57:19 -0400
Subject: [PATCH 3/6] cleanup
---
.../TransactionResultDeserializer.java | 4 +++
.../xrpl4j/model/transactions/AmmBid.java | 3 ---
.../model/transactions/Transaction.java | 1 -
.../transactions/json/UnlModifyJsonTests.java | 25 +++++++++++++++++++
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java
index 932a9f277..9bf99d3be 100644
--- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java
+++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionResultDeserializer.java
@@ -75,7 +75,11 @@ public TransactionResult deserialize(JsonParser jsonParser, DeserializationCo
Optional metadata = getTransactionMetadata(objectMapper, objectNode);
UnsignedLong closeDate = objectNode.has("date") ? UnsignedLong.valueOf(objectNode.get("date").asLong()) : null;
+ // The Transaction is @JsonUnwrapped in TransactionResult, which means these fields
+ // get added to the Transaction.unknownFields Map. To prevent that, we simply remove them from the JSON, because
+ // they should only show up in AccountTransactionsTransaction
objectNode.remove(EXTRA_TRANSACTION_FIELDS);
+
JavaType javaType = objectMapper.getTypeFactory().constructType(new TypeReference() {
});
T transaction = objectMapper.convertValue(objectNode, javaType);
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 3bc9261d1..4f3e539fe 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
@@ -110,7 +110,4 @@ default TransactionFlags flags() {
@JsonProperty("AuthAccounts")
List authAccounts();
- /*@Override
- @JsonAnyGetter
- Map unknownFields();*/
}
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 fb96cd14a..ef0f43e38 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
@@ -227,7 +227,6 @@ default PublicKey signingPublicKey() {
Optional networkId();
@JsonAnyGetter
- @JsonInclude(Include.NON_ABSENT)
Map unknownFields();
}
diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
index 3226642b2..367abc7b8 100644
--- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
+++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
@@ -56,4 +56,29 @@ public void testJson() throws JsonProcessingException, JSONException {
assertCanSerializeAndDeserialize(unlModify, json);
}
+
+ @Test
+ public void testJsonWithUnknownFields() throws JsonProcessingException, JSONException {
+ UnlModify unlModify = UnlModify.builder()
+ .fee(XrpCurrencyAmount.ofDrops(12))
+ .sequence(UnsignedInteger.valueOf(2470665))
+ .ledgerSequence(LedgerIndex.of(UnsignedInteger.valueOf(67850752)))
+ .unlModifyValidator("EDB6FC8E803EE8EDC2793F1EC917B2EE41D35255618DEB91D3F9B1FC89B75D4539")
+ .unlModifyDisabling(UnsignedInteger.valueOf(1))
+ .putUnknownFields("Foo", "Bar")
+ .build();
+
+ String json = "{" +
+ " \"Foo\" : \"Bar\",\n" +
+ "\"Account\":\"" + UnlModify.ACCOUNT_ZERO + "\"," +
+ "\"Fee\":\"12\"," +
+ "\"LedgerSequence\":67850752," +
+ "\"Sequence\":2470665," +
+ "\"SigningPubKey\":\"\"," +
+ "\"TransactionType\":\"UNLModify\"," +
+ "\"UNLModifyDisabling\":1," +
+ "\"UNLModifyValidator\":\"EDB6FC8E803EE8EDC2793F1EC917B2EE41D35255618DEB91D3F9B1FC89B75D4539\"}";
+
+ assertCanSerializeAndDeserialize(unlModify, json);
+ }
}
From 29e3f04637e3c57abbf2d104cd46562ca60fcf01 Mon Sep 17 00:00:00 2001
From: nkramer44
Date: Sun, 3 Nov 2024 09:06:37 -0500
Subject: [PATCH 4/6] add NON_ABSENT back
---
.../xrpl/xrpl4j/model/transactions/Transaction.java | 1 +
.../model/transactions/UnknownTransactionTest.java | 10 ----------
2 files changed, 1 insertion(+), 10 deletions(-)
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 ef0f43e38..fb96cd14a 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
@@ -227,6 +227,7 @@ default PublicKey signingPublicKey() {
Optional networkId();
@JsonAnyGetter
+ @JsonInclude(Include.NON_ABSENT)
Map unknownFields();
}
diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
index aeacb2a42..bcb521596 100644
--- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
+++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
@@ -1,26 +1,16 @@
package org.xrpl.xrpl4j.model.transactions;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.common.primitives.UnsignedInteger;
-import org.immutables.value.Value.Immutable;
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.transactions.AccountSet.AccountSetFlag;
import java.util.HashMap;
-import java.util.Optional;
class UnknownTransactionTest extends AbstractJsonTest {
From ea26ff043282a2f7768938956f685629ff255178 Mon Sep 17 00:00:00 2001
From: nkramer44
Date: Mon, 4 Nov 2024 09:08:35 -0500
Subject: [PATCH 5/6] add flags test
---
.../model/transactions/UnknownTransactionTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
index bcb521596..b1707896c 100644
--- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
+++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/UnknownTransactionTest.java
@@ -1,5 +1,7 @@
package org.xrpl.xrpl4j.model.transactions;
+import static org.assertj.core.api.Assertions.assertThat;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
@@ -26,12 +28,13 @@ void testJson() throws JSONException, JsonProcessingException {
unknownFields.put("NFTokenMinter", "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn");
unknownFields.put("WalletLocator", Strings.repeat("0", 64));
unknownFields.put("EmailHash", Strings.repeat("0", 32));
- Transaction transaction = UnknownTransaction.builder()
+ TransactionFlags flags = TransactionFlags.of(2147483648L);
+ UnknownTransaction transaction = UnknownTransaction.builder()
.unknownTransactionType("AccountSet2")
.account(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"))
.fee(XrpCurrencyAmount.ofDrops(12))
.sequence(UnsignedInteger.valueOf(5))
- .flags(TransactionFlags.of(2147483648L))
+ .flags(flags)
.signingPublicKey(
PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC"))
.unknownFields(
@@ -40,6 +43,8 @@ void testJson() throws JSONException, JsonProcessingException {
.networkId(NetworkId.of(UnsignedInteger.valueOf(1024)))
.build();
+ assertThat(transaction.flags()).isEqualTo(flags);
+
// Same properties as AccountSet, but TransactionType is AccountSet2
String json = "{\n" +
" \"TransactionType\":\"AccountSet2\",\n" +
From 304191241af00687ef581973f13bd92a01b189f2 Mon Sep 17 00:00:00 2001
From: nkramer44
Date: Sat, 9 Nov 2024 09:58:54 -0500
Subject: [PATCH 6/6] cleanup
---
.../model/jackson/modules/TransactionDeserializer.java | 1 -
.../main/java/org/xrpl/xrpl4j/model/transactions/AmmBid.java | 3 ---
.../java/org/xrpl/xrpl4j/model/transactions/Transaction.java | 1 -
.../org/xrpl/xrpl4j/model/transactions/TransactionType.java | 3 +++
.../xrpl/xrpl4j/model/transactions/TransactionTypeTests.java | 5 -----
.../xrpl4j/model/transactions/json/UnlModifyJsonTests.java | 3 ---
6 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java
index 1eccf82a6..c4cb3a483 100644
--- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java
+++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java
@@ -27,7 +27,6 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.xrpl.xrpl4j.model.transactions.Transaction;
import org.xrpl.xrpl4j.model.transactions.TransactionType;
-import org.xrpl.xrpl4j.model.transactions.UnknownTransaction;
import java.io.IOException;
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 4f3e539fe..b52da0635 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
@@ -1,7 +1,5 @@
package org.xrpl.xrpl4j.model.transactions;
-import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -12,7 +10,6 @@
import org.xrpl.xrpl4j.model.ledger.Issue;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
/**
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 fb96cd14a..b8fd678ae 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
@@ -21,7 +21,6 @@
*/
import com.fasterxml.jackson.annotation.JsonAnyGetter;
-import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
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 92cd912f1..0beefb089 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
@@ -338,6 +338,9 @@ public enum TransactionType {
@Beta
ORACLE_DELETE("OracleDelete"),
+ /**
+ * The {@link TransactionType} for any transaction that is unrecognized/unsupported by xrpl4j.
+ */
UNKNOWN("Unknown");
private final String value;
diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java
index af5e049c2..ed5fd8377 100644
--- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java
+++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/TransactionTypeTests.java
@@ -22,15 +22,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-import org.junit.jupiter.params.provider.ArgumentsSource;
import org.junit.jupiter.params.provider.EmptySource;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.NullSource;
diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
index 367abc7b8..7c295ade6 100644
--- a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
+++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/json/UnlModifyJsonTests.java
@@ -20,15 +20,12 @@
* =========================LICENSE_END==================================
*/
-import static org.assertj.core.api.Assertions.assertThat;
-
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.transactions.Transaction;
import org.xrpl.xrpl4j.model.transactions.UnlModify;
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;