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
47 static NotTEC
48 preflight(PreflightContext const& ctx);
49
51 static TER
52 preclaim(PreclaimContext const& ctx);
53
55 TER
56 doApply() override;
57
58private:
60 applyGuts(Sandbox& view, Sandbox& view_cancel);
61
62 // Determine if we are authorized to hold the asset we want to get.
63 static TER
65 ReadView const& view,
66 ApplyFlags const flags,
67 AccountID const id,
68 beast::Journal const j,
69 Issue const& issue);
70
71 // Use the payment flow code to perform offer crossing.
74 PaymentSandbox& psb,
75 PaymentSandbox& psbCancel,
76 Amounts const& takerAmount,
77 std::optional<uint256> const& domainID);
78
79 static std::string
80 format_amount(STAmount const& amount);
81
82 TER
84 Sandbox& sb,
86 Keylet const& offer_index,
87 STAmount const& saTakerPays,
88 STAmount const& saTakerGets,
89 std::function<void(SLE::ref, std::optional<uint256>)> const& setDir);
90};
91
93
94} // namespace ripple
95
96#endif
A generic endpoint for log messages.
Definition: Journal.h:60
State information when applying a tx.
Definition: ApplyContext.h:37
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 NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
Definition: CreateOffer.cpp:47
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition: CreateOffer.cpp:36
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.
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:52
Discardable, editable view to a ledger.
Definition: Sandbox.h:35
ApplyView & view()
Definition: Transactor.h:159
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition: applySteps.h:59
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:25
ApplyFlags
Definition: ApplyView.h:31
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:79
State information when preflighting a tx.
Definition: Transactor.h:34