mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -164,7 +164,9 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
||||
}
|
||||
|
||||
boost::json::object obj;
|
||||
if (!input.binary) {
|
||||
|
||||
// if binary is true or transactionType is specified, we need to expand the transaction
|
||||
if (!input.binary || input.transactionType.has_value()) {
|
||||
auto [txn, meta] = toExpandedJson(txnPlusMeta, ctx.apiVersion, NFTokenjson::ENABLE);
|
||||
|
||||
if (txn.contains(JS(TransactionType))) {
|
||||
@@ -177,35 +179,38 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const txKey = ctx.apiVersion < 2u ? JS(tx) : JS(tx_json);
|
||||
obj[JS(meta)] = std::move(meta);
|
||||
obj[txKey] = std::move(txn);
|
||||
obj[txKey].as_object()[JS(date)] = txnPlusMeta.date;
|
||||
obj[txKey].as_object()[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
if (!input.binary) {
|
||||
auto const txKey = ctx.apiVersion < 2u ? JS(tx) : JS(tx_json);
|
||||
obj[JS(meta)] = std::move(meta);
|
||||
obj[txKey] = std::move(txn);
|
||||
obj[txKey].as_object()[JS(date)] = txnPlusMeta.date;
|
||||
obj[txKey].as_object()[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
|
||||
if (ctx.apiVersion < 2u) {
|
||||
obj[txKey].as_object()[JS(inLedger)] = txnPlusMeta.ledgerSequence;
|
||||
} else {
|
||||
obj[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
if (obj[txKey].as_object().contains(JS(hash))) {
|
||||
obj[JS(hash)] = obj[txKey].as_object()[JS(hash)];
|
||||
obj[txKey].as_object().erase(JS(hash));
|
||||
}
|
||||
if (auto const ledgerInfo =
|
||||
sharedPtrBackend_->fetchLedgerBySequence(txnPlusMeta.ledgerSequence, ctx.yield);
|
||||
ledgerInfo) {
|
||||
obj[JS(ledger_hash)] = ripple::strHex(ledgerInfo->hash);
|
||||
obj[JS(close_time_iso)] = ripple::to_string_iso(ledgerInfo->closeTime);
|
||||
if (ctx.apiVersion < 2u) {
|
||||
obj[txKey].as_object()[JS(inLedger)] = txnPlusMeta.ledgerSequence;
|
||||
} else {
|
||||
obj[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
if (obj[txKey].as_object().contains(JS(hash))) {
|
||||
obj[JS(hash)] = obj[txKey].as_object()[JS(hash)];
|
||||
obj[txKey].as_object().erase(JS(hash));
|
||||
}
|
||||
if (auto const ledgerInfo =
|
||||
sharedPtrBackend_->fetchLedgerBySequence(txnPlusMeta.ledgerSequence, ctx.yield);
|
||||
ledgerInfo) {
|
||||
obj[JS(ledger_hash)] = ripple::strHex(ledgerInfo->hash);
|
||||
obj[JS(close_time_iso)] = ripple::to_string_iso(ledgerInfo->closeTime);
|
||||
}
|
||||
}
|
||||
obj[JS(validated)] = true;
|
||||
response.transactions.push_back(std::move(obj));
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
obj = toJsonWithBinaryTx(txnPlusMeta, ctx.apiVersion);
|
||||
obj[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
}
|
||||
|
||||
// binary is true
|
||||
obj = toJsonWithBinaryTx(txnPlusMeta, ctx.apiVersion);
|
||||
obj[JS(validated)] = true;
|
||||
|
||||
response.transactions.push_back(obj);
|
||||
obj[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
|
||||
response.transactions.push_back(std::move(obj));
|
||||
}
|
||||
|
||||
response.limit = input.limit;
|
||||
|
||||
@@ -1854,8 +1854,32 @@ generateTransactionTypeTestValues()
|
||||
}
|
||||
])",
|
||||
2u},
|
||||
AccountTxTransactionBundle{
|
||||
"FilterWhenBinaryTrue",
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"ledger_index": "validated",
|
||||
"tx_type": "Payment",
|
||||
"binary": true
|
||||
})",
|
||||
R"([{
|
||||
"meta": "201C00000000F8E5110061E762400000000000001681144B4E9C06F24296074F7BC48F92A97916C6DC5EA9E1E1E5110061E76240000000000000178114D31252CF902EF8DD8451243869B38667CBD89DF3E1E1F1031000",
|
||||
"tx_blob": "120000240000002061400000000000000168400000000000000173047465737481144B4E9C06F24296074F7BC48F92A97916C6DC5EA98314D31252CF902EF8DD8451243869B38667CBD89DF3",
|
||||
"ledger_index": 30,
|
||||
"validated": true
|
||||
}])",
|
||||
1u},
|
||||
AccountTxTransactionBundle{
|
||||
"PaymentChannelClaim",
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"ledger_index": "validated",
|
||||
"tx_type": "PaymentChannelClaim",
|
||||
"binary": true
|
||||
})",
|
||||
"[]"},
|
||||
AccountTxTransactionBundle{
|
||||
"FilterWhenBinaryTrueEmptyResult",
|
||||
R"({
|
||||
"account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"ledger_index": "validated",
|
||||
|
||||
Reference in New Issue
Block a user