rippled
Loading...
Searching...
No Matches
Permissions.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2025 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_PROTOCOL_PERMISSION_H_INCLUDED
21#define RIPPLE_PROTOCOL_PERMISSION_H_INCLUDED
22
23#include <xrpl/protocol/Rules.h>
24#include <xrpl/protocol/TER.h>
25#include <xrpl/protocol/TxFormats.h>
26
27#include <optional>
28#include <string>
29#include <unordered_map>
30
31namespace ripple {
40#pragma push_macro("PERMISSION")
41#undef PERMISSION
42
43#define PERMISSION(type, txType, value) type = value,
44
45#include <xrpl/protocol/detail/permissions.macro>
46
47#undef PERMISSION
48#pragma pop_macro("PERMISSION")
49};
50
52
54{
55private:
56 Permission();
57
59
61
64
66
68
69public:
70 static Permission const&
72
73 Permission(Permission const&) = delete;
75 operator=(Permission const&) = delete;
76
78 getGranularValue(std::string const& name) const;
79
81 getGranularName(GranularPermissionType const& value) const;
82
84 getGranularTxType(GranularPermissionType const& gpType) const;
85
86 bool
87 isDelegatable(std::uint32_t const& permissionValue, Rules const& rules)
88 const;
89
90 // for tx level permission, permission value is equal to tx type plus one
91 uint32_t
92 txToPermissionType(TxType const& type) const;
93
94 // tx type value is permission value minus one
95 TxType
96 permissionToTxType(uint32_t const& value) const;
97};
98
99} // namespace ripple
100
101#endif
std::unordered_map< std::uint16_t, Delegation > delegatableTx_
Definition Permissions.h:60
TxType permissionToTxType(uint32_t const &value) const
std::optional< std::string > getGranularName(GranularPermissionType const &value) const
Permission(Permission const &)=delete
std::unordered_map< std::uint16_t, uint256 > txFeatureMap_
Definition Permissions.h:58
std::unordered_map< GranularPermissionType, std::string > granularNameMap_
Definition Permissions.h:65
std::unordered_map< std::string, GranularPermissionType > granularPermissionMap_
Definition Permissions.h:63
std::optional< std::uint32_t > getGranularValue(std::string const &name) const
std::optional< TxType > getGranularTxType(GranularPermissionType const &gpType) const
uint32_t txToPermissionType(TxType const &type) const
Permission & operator=(Permission const &)=delete
static Permission const & getInstance()
std::unordered_map< GranularPermissionType, TxType > granularTxTypeMap_
Definition Permissions.h:67
bool isDelegatable(std::uint32_t const &permissionValue, Rules const &rules) const
Rules controlling protocol behavior.
Definition Rules.h:38
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
TxType
Transaction type identifiers.
Definition TxFormats.h:57
@ delegatable
Definition Permissions.h:51
@ notDelegatable
Definition Permissions.h:51
GranularPermissionType
We have both transaction type permissions and granular type permissions.
Definition Permissions.h:39