xrpld
Loading...
Searching...
No Matches
include
xrpl
tx
invariants
InvariantCheckPrivilege.h
1
#pragma once
2
3
#include <xrpl/protocol/STTx.h>
4
5
#include <
type_traits
>
6
7
namespace
xrpl
{
8
9
/*
10
assert(enforce)
11
12
There are several asserts (or XRPL_ASSERTs) in invariant check files that check
13
a variable named `enforce` when an invariant fails. At first glance, those
14
asserts may look incorrect, but they are not.
15
16
Those asserts take advantage of two facts:
17
1. `asserts` are not (normally) executed in release builds.
18
2. Invariants should *never* fail, except in tests that specifically modify
19
the open ledger to break them.
20
21
This makes `assert(enforce)` sort of a second-layer of invariant enforcement
22
aimed at _developers_. It's designed to fire if a developer writes code that
23
violates an invariant, and runs it in unit tests or a develop build that _does
24
not have the relevant amendments enabled_. It's intentionally a pain in the neck
25
so that bad code gets caught and fixed as early as possible.
26
*/
27
28
// Bitwise flags, 86 files, used in macros files
29
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
30
enum
Privilege
{
31
NoPriv
= 0x0000,
// The transaction can not do any of the enumerated operations
32
CreateAcct
= 0x0001,
// The transaction can create a new ACCOUNT_ROOT object.
33
CreatePseudoAcct
= 0x0002,
// The transaction can create a pseudo account,
34
// which implies createAcct
35
MustDeleteAcct
= 0x0004,
// The transaction must delete an ACCOUNT_ROOT object
36
MayDeleteAcct
= 0x0008,
// The transaction may delete an ACCOUNT_ROOT
37
// object, but does not have to
38
OverrideFreeze
= 0x0010,
// The transaction can override some freeze rules
39
ChangeNftCounts
= 0x0020,
// The transaction can mint or burn an NFT
40
CreateMptIssuance
= 0x0040,
// The transaction can create a new MPT issuance
41
DestroyMptIssuance
= 0x0080,
// The transaction can destroy an MPT issuance
42
MustAuthorizeMpt
= 0x0100,
// The transaction MUST create or delete an MPT
43
// object (except by issuer)
44
MayAuthorizeMpt
= 0x0200,
// The transaction MAY create or delete an MPT
45
// object (except by issuer)
46
MayDeleteMpt
= 0x0400,
// The transaction MAY delete an MPT object. May not create.
47
MustModifyVault
= 0x0800,
// The transaction must modify, delete or create, a vault
48
MayModifyVault
= 0x1000,
// The transaction MAY modify, delete or create, a vault
49
MayCreateMpt
= 0x2000,
// The transaction MAY create an MPT object, except for issuer.
50
};
51
52
constexpr
Privilege
53
operator|
(
Privilege
lhs,
Privilege
rhs)
54
{
55
return
safeCast<Privilege>
(
56
safeCast
<
std::underlying_type_t<Privilege>
>(lhs) |
57
safeCast
<
std::underlying_type_t<Privilege>
>(rhs));
58
}
59
60
bool
61
hasPrivilege
(STTx
const
& tx,
Privilege
priv);
62
63
}
// namespace xrpl
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::operator|
constexpr BaseUInt< Bits, Tag > operator|(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
Definition
base_uint.h:618
xrpl::safeCast
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safeCast(Src s) noexcept
Definition
safe_cast.h:21
xrpl::Privilege
Privilege
Definition
InvariantCheckPrivilege.h:30
xrpl::MustDeleteAcct
@ MustDeleteAcct
Definition
InvariantCheckPrivilege.h:35
xrpl::MayDeleteMpt
@ MayDeleteMpt
Definition
InvariantCheckPrivilege.h:46
xrpl::NoPriv
@ NoPriv
Definition
InvariantCheckPrivilege.h:31
xrpl::MayAuthorizeMpt
@ MayAuthorizeMpt
Definition
InvariantCheckPrivilege.h:44
xrpl::ChangeNftCounts
@ ChangeNftCounts
Definition
InvariantCheckPrivilege.h:39
xrpl::MayCreateMpt
@ MayCreateMpt
Definition
InvariantCheckPrivilege.h:49
xrpl::DestroyMptIssuance
@ DestroyMptIssuance
Definition
InvariantCheckPrivilege.h:41
xrpl::MustAuthorizeMpt
@ MustAuthorizeMpt
Definition
InvariantCheckPrivilege.h:42
xrpl::MustModifyVault
@ MustModifyVault
Definition
InvariantCheckPrivilege.h:47
xrpl::MayDeleteAcct
@ MayDeleteAcct
Definition
InvariantCheckPrivilege.h:36
xrpl::CreateAcct
@ CreateAcct
Definition
InvariantCheckPrivilege.h:32
xrpl::CreatePseudoAcct
@ CreatePseudoAcct
Definition
InvariantCheckPrivilege.h:33
xrpl::MayModifyVault
@ MayModifyVault
Definition
InvariantCheckPrivilege.h:48
xrpl::OverrideFreeze
@ OverrideFreeze
Definition
InvariantCheckPrivilege.h:38
xrpl::CreateMptIssuance
@ CreateMptIssuance
Definition
InvariantCheckPrivilege.h:40
xrpl::hasPrivilege
bool hasPrivilege(STTx const &tx, Privilege priv)
Definition
InvariantCheck.cpp:51
type_traits
std::underlying_type_t
Generated by
1.16.1