Skip to content

Commit 74065cc

Browse files
committed
Merge branch 'main' of github.com:XRPLF/xrpl4j into df/enhance-transaction-serde
# Conflicts: # xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java
2 parents 7f7e86f + 4a01fd4 commit 74065cc

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/jackson/modules/TransactionDeserializer.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import com.fasterxml.jackson.core.JsonParser;
2424
import com.fasterxml.jackson.databind.DeserializationContext;
25-
import com.fasterxml.jackson.databind.JsonNode;
2625
import com.fasterxml.jackson.databind.ObjectMapper;
2726
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
2827
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -50,16 +49,16 @@ public Transaction deserialize(JsonParser jsonParser, DeserializationContext ctx
5049
final ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();
5150
final ObjectNode objectNode = objectMapper.readTree(jsonParser);
5251

53-
final JsonNode transactionTypeJsonNode = objectNode.get("TransactionType");
54-
final TransactionType transactionType = TransactionType.forValue(transactionTypeJsonNode.asText());
52+
TransactionType transactionType = TransactionType.forValue(objectNode.get("TransactionType").asText());
5553
final Class<? extends Transaction> transactionTypeClass = Transaction.typeMap.inverse().get(transactionType);
5654

57-
// Remove the `Account` property from any incoming `UnlModify` JSON about to be deserialized. This is because the
58-
// JSON returned by the rippled/clio API v1 has a bug where the account value in `UnlModify` transactions is an
59-
// empty string. In this case, the Java value for the `Account` property is always set to ACCOUNT_ZERO via a default
60-
// method, so this property is removed from incoming JSON before deserialization because it's not needed (the
61-
// default method handles population in Java) and if not removed, this field will end up in the `unknownFields`
62-
// map of the ultimate Java object, which is incorrect.
55+
// Fixes #590 by removing the `Account` property from any incoming `UnlModify` JSON about to be deserialized.
56+
// This fixes #590 because the JSON returned by the rippled/clio API v1 has a bug where the account value in
57+
// `UnlModify` transactions is an empty string. When this value is deserialized, an exception is thrown because
58+
// the empty string value is not a valid `Address`. By removing the property from incoming JSON, the Java value
59+
// for the `Account` property is always set to ACCOUNT_ZERO via a default method. One other side effect of this
60+
// fix is that `Account` property will not be errantly added to `unknownFields` map of the ultimate Java object,
61+
// which is incorrect.
6362
if (UnlModify.class.isAssignableFrom(transactionTypeClass)) {
6463
objectNode.remove("Account");
6564
}

0 commit comments

Comments
 (0)