Files
rippled/src/ripple/rpc/impl/GRPCHelpers.h
Scott Schurr 7724cca384 Implement enhanced Ticket support:
Tickets are a mechanism to allow for the "out-of-order" execution of
transactions on the XRP Ledger.

This commit, if merged, reworks the existing support for tickets and
introduces support for 'ticket batching', completing the feature set
needed for tickets.

The code is gated under the newly-introduced `TicketBatch` amendment
and the `Tickets` amendment, which is not presently active on the
network, is being removed.

The specification for this change can be found at:
https://github.com/xrp-community/standards-drafts/issues/16
2020-09-01 08:58:57 -07:00

91 lines
2.8 KiB
C++

//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2020 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_RPC_GRPCHELPERS_H_INCLUDED
#define RIPPLE_RPC_GRPCHELPERS_H_INCLUDED
#include "org/xrpl/rpc/v1/get_account_info.pb.h"
#include "org/xrpl/rpc/v1/ledger_objects.pb.h"
#include "org/xrpl/rpc/v1/meta.pb.h"
#include "org/xrpl/rpc/v1/transaction.pb.h"
#include <ripple/app/misc/TxQ.h>
#include <ripple/ledger/TxMeta.h>
#include <ripple/protocol/Protocol.h>
#include <ripple/protocol/STAmount.h>
#include <ripple/protocol/STTx.h>
#include <functional>
namespace ripple {
namespace RPC {
void
convert(org::xrpl::rpc::v1::Meta& to, std::shared_ptr<TxMeta> const& from);
void
convert(
org::xrpl::rpc::v1::QueueData& to,
std::vector<TxQ::TxDetails> const& from);
void
convert(
org::xrpl::rpc::v1::Transaction& to,
std::shared_ptr<STTx const> const& from);
void
convert(org::xrpl::rpc::v1::TransactionResult& to, TER from);
void
convert(org::xrpl::rpc::v1::AccountRoot& to, STObject const& from);
void
convert(org::xrpl::rpc::v1::SignerList& to, STObject const& from);
void
convert(org::xrpl::rpc::v1::NegativeUNL& to, STObject const& from);
template <class T>
void
convert(T& to, STAmount const& from)
{
if (from.native())
{
to.mutable_value()->mutable_xrp_amount()->set_drops(from.xrp().drops());
}
else
{
Issue const& issue = from.issue();
org::xrpl::rpc::v1::IssuedCurrencyAmount* issued =
to.mutable_value()->mutable_issued_currency_amount();
issued->mutable_currency()->set_name(to_string(issue.currency));
issued->mutable_currency()->set_code(
issue.currency.data(), Currency::size());
issued->mutable_issuer()->set_address(toBase58(issue.account));
issued->set_value(to_string(from.iou()));
}
}
} // namespace RPC
} // namespace ripple
#endif