Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for unknown transactions #569

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nkramer44
Copy link
Collaborator

Adds a new field to Transaction called unknownFields, which is annotated with @JsonAnySetter. This tells Jackson to populate unknownFields with any JSON fields that are unmapped in the immutable.

This allow for two things:

  1. Out of the box support for any new transaction fields that the current version/an old version of xrpl4j doesn't support
  2. The introduction of UnknownTransaction, which only has common fields + unknownFields, which allows any version of xrpl4j that contains UnknownTransaction to deserialize an unsupported transaction type from JSON

Comment on lines +65 to +67
// FIXME: Have to make this Default, otherwise JsonAnySetter adds this field to unknownFields. Other option
// is that's totally fine, which i think it is -- we should let the JSON set this field if it's there
@Value.Default
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sappenin we should discuss this change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if we wanted to keep the @Derived could make a special carve-out in the Deserializer to add Account into EXTRA_TRANSACTION_FIELDS.

However, that's ugly, and makes it so nobody can create a UnlModify with an account that's not account-zero. That's a non-goal ATM, but I think I prefer making this @Default just in case someone every wants to do that (e.g., for testing, or whatever).

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.04%. Comparing base (18f9dab) to head (3041912).

Files with missing lines Patch % Lines
.../xrpl4j/model/transactions/UnknownTransaction.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #569      +/-   ##
============================================
- Coverage     92.04%   92.04%   -0.01%     
- Complexity     1842     1847       +5     
============================================
  Files           382      383       +1     
  Lines          5106     5116      +10     
  Branches        433      433              
============================================
+ Hits           4700     4709       +9     
- Misses          271      272       +1     
  Partials        135      135              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@sappenin sappenin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- mostly cleanup and docs suggestions, but otherwise good to go. Thanks for adding support here!

Comment on lines +65 to +67
// FIXME: Have to make this Default, otherwise JsonAnySetter adds this field to unknownFields. Other option
// is that's totally fine, which i think it is -- we should let the JSON set this field if it's there
@Value.Default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if we wanted to keep the @Derived could make a special carve-out in the Deserializer to add Account into EXTRA_TRANSACTION_FIELDS.

However, that's ugly, and makes it so nobody can create a UnlModify with an account that's not account-zero. That's a non-goal ATM, but I think I prefer making this @Default just in case someone every wants to do that (e.g., for testing, or whatever).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants