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