xrpld
Loading...
Searching...
No Matches
fee.h
1#pragma once
2
3#include <test/jtx/Env.h>
4#include <test/jtx/JTx.h>
5#include <test/jtx/tags.h>
6
7#include <xrpl/basics/contract.h>
8#include <xrpl/protocol/STAmount.h>
9
10#include <cstdint>
11#include <optional>
12#include <stdexcept>
13
14namespace xrpl::test::jtx {
15
19class Fee
20{
21private:
22 bool manual_ = true;
23 bool increment_ = false;
25
26public:
27 explicit Fee(AutofillT) : manual_(false)
28 {
29 }
30
31 explicit Fee(IncrementT) : increment_(true)
32 {
33 }
34
35 explicit Fee(NoneT)
36 {
37 }
38
39 explicit Fee(STAmount const& amount) : amount_(amount)
40 {
41 if (!isXRP(*amount_))
42 Throw<std::runtime_error>("fee: not XRP");
43 }
44
45 explicit Fee(std::uint64_t amount, bool negative = false) : Fee{STAmount{amount, negative}}
46 {
47 }
48
49 void
50 operator()(Env&, JTx& jt) const;
51};
52
53} // namespace xrpl::test::jtx
A transaction testing environment.
Definition Env.h:161
Fee(IncrementT)
Definition fee.h:31
void operator()(Env &, JTx &jt) const
Definition fee.cpp:13
Fee(std::uint64_t amount, bool negative=false)
Definition fee.h:45
Fee(AutofillT)
Definition fee.h:27
std::optional< STAmount > amount_
Definition fee.h:24
Fee(STAmount const &amount)
Definition fee.h:39
bool isXRP(AccountID const &c)
Definition AccountID.h:84
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:52
Used for Fee() calls that use an owner reserve increment.
Definition tags.h:27
Execution context for applying a JSON transaction.
Definition JTx.h:27