22#include "data/BackendInterface.hpp" 
   25#include "rpc/common/MetaProcessors.hpp" 
   26#include "rpc/common/Modifiers.hpp" 
   27#include "rpc/common/Specs.hpp" 
   28#include "rpc/common/Types.hpp" 
   29#include "rpc/common/Validators.hpp" 
   31#include <boost/asio/spawn.hpp> 
   32#include <boost/json/array.hpp> 
   33#include <boost/json/conversion.hpp> 
   34#include <xrpl/basics/Number.h> 
   35#include <xrpl/protocol/AccountID.h> 
   36#include <xrpl/protocol/STAmount.h> 
   37#include <xrpl/protocol/STObject.h> 
   38#include <xrpl/protocol/jss.h> 
   54    std::shared_ptr<BackendInterface> sharedPtrBackend_;
 
   61        ripple::STAmount avg{};  
 
 
   73        std::optional<Stats> trimStats;
 
   74        std::string ledgerHash;
 
   77        bool validated = 
true;
 
 
   84        std::uint32_t documentId{0};
 
   85        ripple::AccountID account;
 
 
   92        std::optional<std::string> ledgerHash;
 
   93        std::optional<std::uint32_t> ledgerIndex;
 
   94        std::vector<Oracle> oracles;  
 
   95        std::string baseAsset;
 
   96        std::string quoteAsset;
 
   97        std::optional<std::uint32_t> timeThreshold;
 
   98        std::optional<std::uint8_t> trim;  
 
 
  109        : sharedPtrBackend_(sharedPtrBackend)
 
 
  120    spec([[maybe_unused]] uint32_t apiVersion)
 
  122        static constexpr auto kORACLES_MAX = 200;
 
  124        static auto const kORACLES_VALIDATOR =
 
  126                if (!value.is_array() or value.as_array().empty() or value.as_array().size() > kORACLES_MAX)
 
  127                    return Error{
Status{RippledError::rpcORACLE_MALFORMED}};
 
  129                for (
auto& oracle : value.as_array()) {
 
  130                    if (!oracle.is_object() or !oracle.as_object().contains(JS(oracle_document_id)) or
 
  131                        !oracle.as_object().contains(JS(account)))
 
  132                        return Error{
Status{RippledError::rpcORACLE_MALFORMED}};
 
  146                        return Error{
Status{RippledError::rpcINVALID_PARAMS}};
 
  152        static auto const kRPC_SPEC = 
RpcSpec{
 
 
  198    tracebackOracleObject(
 
  199        boost::asio::yield_context yield,
 
  200        ripple::STObject 
const& oracleObject,
 
  201        std::function<
bool(ripple::STObject 
const&)> 
const& callback
 
  211    tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output 
const& output);
 
  220    tag_invoke(boost::json::value_to_tag<Input>, boost::json::value 
const& jv);
 
 
static RpcSpecConstRef spec(uint32_t apiVersion)
Returns the API specification for the command.
Definition GetAggregatePrice.hpp:120
GetAggregatePriceHandler(std::shared_ptr< BackendInterface > const &sharedPtrBackend)
Construct a new GetAggregatePrice handler object.
Definition GetAggregatePrice.hpp:108
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition GetAggregatePrice.cpp:297
Result process(Input const &input, Context const &ctx) const
Process the GetAggregatePrice command.
Definition GetAggregatePrice.cpp:62
Customised modifier allowing user define how to modify input in provided callable.
Definition Modifiers.hpp:145
Validate that value is between specified min and max.
Definition Validators.hpp:172
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37
RpcSpec const  & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:145
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:81
std::expected< void, Status > MaybeError
Return type used for Validators that can return error but don't have specific value to return.
Definition Types.hpp:55
std::unexpected< Status > Error
The type that represents just the error part of MaybeError.
Definition Types.hpp:75
Context of an RPC call.
Definition Types.hpp:118
A struct to hold the input oracle data.
Definition GetAggregatePrice.hpp:83
A struct to hold the output data of the command.
Definition GetAggregatePrice.hpp:70
A struct to hold the statistics.
Definition GetAggregatePrice.hpp:60
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:129
Represents a Specification of an entire RPC command.
Definition Specs.hpp:98
A status returned from any RPC handler.
Definition Errors.hpp:83
static MaybeError modify(boost::json::value &value, std::string_view key)
Update the input string to integer if it can be converted to integer by stoi.
Definition Modifiers.hpp:121
static CustomValidator currencyValidator
Provides a commonly used validator for currency, including standard currency code and token code.
Definition Validators.hpp:556
static CustomValidator ledgerIndexValidator
Provides a commonly used validator for ledger index.
Definition Validators.hpp:489
static CustomValidator uint256HexStringValidator
Provides a commonly used validator for uint256 hex string.
Definition Validators.hpp:551
static CustomValidator accountBase58Validator
Provides a commonly used validator for accounts.
Definition Validators.hpp:511
A validator that simply requires a field to be present.
Definition Validators.hpp:47
Validates that the type of the value is one of the given types.
Definition Validators.hpp:142
MaybeError verify(boost::json::value &value, std::string_view key) const
Verify that the JSON value is (one) of specified type(s).
Definition Validators.hpp:153