forked from XRPLF/clio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account tx v1 api support (XRPLF#874)
* Don't fail on ledger params for v1 * Different error on invalid ledger indexes for v1 * Allow forward and binary to be not bool for v1 * Minor fixes * Fix tests * Don't fail if input ledger index is out of range for v1 * Restore deleted test * Fix comparison of integers with different signedness * Updated default api version in README and example config
- Loading branch information
Showing
7 changed files
with
375 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <boost/json/value_to.hpp> | ||
namespace rpc { | ||
|
||
/** | ||
* @brief A wrapper around bool that allows to convert from any JSON value | ||
*/ | ||
struct JsonBool | ||
{ | ||
bool value = false; | ||
|
||
operator bool() const | ||
{ | ||
return value; | ||
} | ||
}; | ||
|
||
inline JsonBool | ||
tag_invoke(boost::json::value_to_tag<JsonBool> const&, boost::json::value const& jsonValue) | ||
{ | ||
switch (jsonValue.kind()) | ||
{ | ||
case boost::json::kind::null: | ||
return JsonBool{false}; | ||
case boost::json::kind::bool_: | ||
return JsonBool{jsonValue.as_bool()}; | ||
case boost::json::kind::uint64: | ||
[[fallthrough]]; | ||
case boost::json::kind::int64: | ||
return JsonBool{jsonValue.as_int64() != 0}; | ||
case boost::json::kind::double_: | ||
return JsonBool{jsonValue.as_double() != 0.0}; | ||
case boost::json::kind::string: | ||
// Also should be `jsonValue.as_string() != "false"` but rippled doesn't do that. Anyway for v2 api we have | ||
// bool validation | ||
return JsonBool{!jsonValue.as_string().empty() && jsonValue.as_string()[0] != 0}; | ||
case boost::json::kind::array: | ||
return JsonBool{!jsonValue.as_array().empty()}; | ||
case boost::json::kind::object: | ||
return JsonBool{!jsonValue.as_object().empty()}; | ||
} | ||
throw std::runtime_error("Invalid json value"); | ||
} | ||
|
||
} // namespace rpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.