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