rippled
Loading...
Searching...
No Matches
CreateOffer.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TX_CREATEOFFER_H_INCLUDED
21#define RIPPLE_TX_CREATEOFFER_H_INCLUDED
22
23#include <xrpld/app/tx/detail/Transactor.h>
24
25#include <xrpl/protocol/Quality.h>
26
27namespace ripple {
28
29class PaymentSandbox;
30class Sandbox;
31
33class CreateOffer : public Transactor
34{
35public:
37
39 explicit CreateOffer(ApplyContext& ctx) : Transactor(ctx)
40 {
41 }
42
43 static TxConsequences
45
46 static bool
48
49 static std::uint32_t
51
53 static NotTEC
54 preflight(PreflightContext const& ctx);
55
57 static TER
58 preclaim(PreclaimContext const& ctx);
59
61 TER
62 doApply() override;
63
64private:
66 applyGuts(Sandbox& view, Sandbox& view_cancel);
67
68 // Determine if we are authorized to hold the asset we want to get.
69 static TER
71 ReadView const& view,
72 ApplyFlags const flags,
73 AccountID const id,
74 beast::Journal const j,
75 Issue const& issue);
76
77 // Use the payment flow code to perform offer crossing.
80 PaymentSandbox& psb,
81 PaymentSandbox& psbCancel,
82 Amounts const& takerAmount,
83 std::optional<uint256> const& domainID);
84
85 static std::string
86 format_amount(STAmount const& amount);
87
88 TER
90 Sandbox& sb,
92 Keylet const& offer_index,
93 STAmount const& saTakerPays,
94 STAmount const& saTakerGets,
95 std::function<void(SLE::ref, std::optional<uint256>)> const& setDir);
96};
97
99
100} // namespace ripple
101
102#endif
A generic endpoint for log messages.
Definition Journal.h:60
State information when applying a tx.
Transactor specialized for creating offers in the ledger.
Definition CreateOffer.h:34
std::pair< TER, Amounts > flowCross(PaymentSandbox &psb, PaymentSandbox &psbCancel, Amounts const &takerAmount, std::optional< uint256 > const &domainID)
static TER checkAcceptAsset(ReadView const &view, ApplyFlags const flags, AccountID const id, beast::Journal const j, Issue const &issue)
CreateOffer(ApplyContext &ctx)
Construct a Transactor subclass that creates an offer in the ledger.
Definition CreateOffer.h:39
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static std::string format_amount(STAmount const &amount)
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition CreateOffer.h:36
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
TER applyHybrid(Sandbox &sb, std::shared_ptr< STLedgerEntry > sleOffer, Keylet const &offer_index, STAmount const &saTakerPays, STAmount const &saTakerGets, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
TER doApply() override
Precondition: fee collection is likely.
static bool checkExtraFeatures(PreflightContext const &ctx)
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &view_cancel)
A currency issued by an account.
Definition Issue.h:33
A wrapper which makes credits unavailable to balances.
A view into a ledger.
Definition ReadView.h:51
Discardable, editable view to a ledger.
Definition Sandbox.h:35
ApplyView & view()
Definition Transactor.h:163
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:58
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:39
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:80
State information when preflighting a tx.
Definition Transactor.h:35