rippled
Loading...
Searching...
No Matches
DelegateUtils.cpp
1#include <xrpld/app/misc/DelegateUtils.h>
2
3#include <xrpl/protocol/STArray.h>
4
5namespace ripple {
8{
9 if (!delegate)
10 return terNO_DELEGATE_PERMISSION; // LCOV_EXCL_LINE
11
12 auto const permissionArray = delegate->getFieldArray(sfPermissions);
13 auto const txPermission = tx.getTxnType() + 1;
14
15 for (auto const& permission : permissionArray)
16 {
17 auto const permissionValue = permission[sfPermissionValue];
18 if (permissionValue == txPermission)
19 return tesSUCCESS;
20 }
21
23}
24
25void
27 std::shared_ptr<SLE const> const& delegate,
28 TxType const& txType,
30{
31 if (!delegate)
32 return; // LCOV_EXCL_LINE
33
34 auto const permissionArray = delegate->getFieldArray(sfPermissions);
35 for (auto const& permission : permissionArray)
36 {
37 auto const permissionValue = permission[sfPermissionValue];
38 auto const granularValue =
39 static_cast<GranularPermissionType>(permissionValue);
40 auto const& type =
42 if (type && *type == txType)
43 granularPermissions.insert(granularValue);
44 }
45}
46
47} // namespace ripple
std::optional< TxType > getGranularTxType(GranularPermissionType const &gpType) const
static Permission const & getInstance()
TxType getTxnType() const
Definition STTx.h:209
T insert(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
NotTEC checkTxPermission(std::shared_ptr< SLE const > const &delegate, STTx const &tx)
Check if the delegate account has permission to execute the transaction.
TxType
Transaction type identifiers.
Definition TxFormats.h:38
void loadGranularPermission(std::shared_ptr< SLE const > const &delegate, TxType const &type, std::unordered_set< GranularPermissionType > &granularPermissions)
Load the granular permissions granted to the delegate account for the specified transaction type.
@ tesSUCCESS
Definition TER.h:226
GranularPermissionType
We have both transaction type permissions and granular type permissions.
Definition Permissions.h:20
@ terNO_DELEGATE_PERMISSION
Definition TER.h:211
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:590