From a0ff9a8a74a4eb4ee16a7a2e5084e25e6df3a57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Coatelen?= <91121759+jcoatelen-ledger@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:47:06 +0200 Subject: [PATCH] Fix ripple explorer (de)serialization issues (#938) --- .../explorers/NodeRippleLikeBlockchainExplorer.cpp | 3 ++- .../explorers/NodeRippleLikeBlockchainExplorer.h | 10 ++++++++++ .../explorers/api/RippleLikeTransactionParser.cpp | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.cpp b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.cpp index 9ef15c76af..6f43bba9cb 100644 --- a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.cpp +++ b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.cpp @@ -215,7 +215,8 @@ namespace ledger { bodyRequest.pushParameter("account", addresses[0]); bodyRequest.pushParameterBool("forward", true); if (fromBlockHash.hasValue() && _paginationMarker.empty()) { - bodyRequest.pushParameter("ledger_index_min", fromBlockHash.getValue()); + BigInt blockHash{fromBlockHash.getValue()}; + bodyRequest.pushParameter("ledger_index_min", blockHash.toUint64()); } // handle transaction pagination in the case we have a pagination marker, which happens diff --git a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h index 0304d187d0..72db991f1b 100644 --- a/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h +++ b/core/src/wallet/ripple/explorers/NodeRippleLikeBlockchainExplorer.h @@ -86,6 +86,16 @@ namespace ledger { return *this; }; + NodeRippleLikeBodyRequest &pushParameter(const std::string &key, uint64_t value) { + rapidjson::Document::AllocatorType &allocator = _document.GetAllocator(); + rapidjson::Value vKeyParam(rapidjson::kStringType); + vKeyParam.SetString(key.c_str(), static_cast(key.length()), allocator); + rapidjson::Value vParam(rapidjson::kNumberType); + vParam.SetUint64(value); + _params.AddMember(vKeyParam, vParam, allocator); + return *this; + }; + NodeRippleLikeBodyRequest &pushParameterBool(const std::string &key, bool value) { // TODO: C++17 group all 3 pushParameter in a single one with a if constexpr () rapidjson::Document::AllocatorType &allocator = _document.GetAllocator(); diff --git a/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp b/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp index 2ae45942d5..e88276a4ed 100644 --- a/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp +++ b/core/src/wallet/ripple/explorers/api/RippleLikeTransactionParser.cpp @@ -161,7 +161,7 @@ namespace ledger { _transaction->sender = value; } else if (_lastKey == "Destination") { _transaction->receiver = value; - } else if (_lastKey == "Amount") { + } else if (_lastKey == "Amount" || _lastKey == "DeliveredAmount") { BigInt valueBigInt = BigInt::fromString(value); _transaction->value = valueBigInt; } else if (_lastKey == "Fee") {