-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: Add synthetic NFT fields to ledger RPC, refactor to have common helper function
#5706
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,12 @@ | |
| #include <xrpld/app/misc/DeliverMax.h> | ||
| #include <xrpld/app/misc/TxQ.h> | ||
| #include <xrpld/rpc/Context.h> | ||
| #include <xrpld/rpc/DeliveredAmount.h> | ||
| #include <xrpld/rpc/MPTokenIssuanceID.h> | ||
| #include <xrpld/rpc/detail/SyntheticFields.h> | ||
|
|
||
| #include <xrpl/basics/base_uint.h> | ||
| #include <xrpl/ledger/helpers/TokenHelpers.h> | ||
| #include <xrpl/protocol/ApiVersion.h> | ||
| #include <xrpl/protocol/NFTSyntheticSerializer.h> | ||
| #include <xrpl/protocol/jss.h> | ||
|
|
||
| namespace xrpl { | ||
|
|
@@ -121,19 +121,12 @@ fillJsonTx( | |
| { | ||
| txJson[jss::meta] = stMeta->getJson(JsonOptions::none); | ||
|
|
||
| // If applicable, insert delivered amount | ||
| if (txnType == ttPAYMENT || txnType == ttCHECK_CASH) | ||
| { | ||
| RPC::insertDeliveredAmount( | ||
| txJson[jss::meta], | ||
| fill.ledger, | ||
| txn, | ||
| {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| } | ||
|
|
||
| // If applicable, insert mpt issuance id | ||
| RPC::insertMPTokenIssuanceID( | ||
| txJson[jss::meta], txn, {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| // Insert all synthetic fields | ||
| RPC::insertAllSyntheticInJson( | ||
| txJson[jss::meta], | ||
| fill.ledger, | ||
| txn, | ||
| {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| } | ||
|
|
||
| if (!fill.ledger.open()) | ||
|
|
@@ -157,19 +150,12 @@ fillJsonTx( | |
| { | ||
| txJson[jss::metaData] = stMeta->getJson(JsonOptions::none); | ||
|
|
||
| // If applicable, insert delivered amount | ||
| if (txnType == ttPAYMENT || txnType == ttCHECK_CASH) | ||
| { | ||
| RPC::insertDeliveredAmount( | ||
| txJson[jss::metaData], | ||
| fill.ledger, | ||
| txn, | ||
| {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| } | ||
|
|
||
| // If applicable, insert mpt issuance id | ||
| RPC::insertMPTokenIssuanceID( | ||
| txJson[jss::metaData], txn, {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| // Insert all synthetic fields | ||
| RPC::insertAllSyntheticInJson( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a change in behaviour. We'll insert delivered amount for ttACCOUNT_DELETE after the change, as per
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that a problem? That seems like a fix to me
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is an intentional behavioral change. The old |
||
| txJson[jss::metaData], | ||
| fill.ledger, | ||
| txn, | ||
| {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #include <xrpld/rpc/DeliveredAmount.h> | ||
| #include <xrpld/rpc/MPTokenIssuanceID.h> | ||
| #include <xrpld/rpc/detail/SyntheticFields.h> | ||
|
|
||
| #include <xrpl/json/json_value.h> | ||
| #include <xrpl/protocol/NFTSyntheticSerializer.h> | ||
| #include <xrpl/protocol/jss.h> | ||
|
|
||
| namespace xrpl { | ||
| namespace RPC { | ||
|
|
||
| void | ||
| insertAllSyntheticInJson( | ||
| Json::Value& metadata, | ||
| ReadView const& ledger, | ||
| std::shared_ptr<STTx const> const& transaction, | ||
| TxMeta const& transactionMeta) | ||
| { | ||
| insertDeliveredAmount(metadata, ledger, transaction, transactionMeta); | ||
| insertNFTSyntheticInJson(metadata, transaction, transactionMeta); | ||
| insertMPTokenIssuanceID(metadata, transaction, transactionMeta); | ||
| } | ||
|
|
||
| void | ||
| insertAllSyntheticInJson( | ||
| Json::Value& metadata, | ||
| JsonContext const& context, | ||
| std::shared_ptr<STTx const> const& transaction, | ||
| TxMeta const& transactionMeta) | ||
| { | ||
| insertDeliveredAmount(metadata, context, transaction, transactionMeta); | ||
| insertNFTSyntheticInJson(metadata, transaction, transactionMeta); | ||
| insertMPTokenIssuanceID(metadata, transaction, transactionMeta); | ||
| } | ||
|
|
||
| } // namespace RPC | ||
| } // namespace xrpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above — the
ttACCOUNT_DELETEdelivered amount behavior change is intentional, makingledgerRPC consistent withtxandaccount_txendpoints.