|
| 1 | +//------------------------------------------------------------------------------ |
| 2 | +/* |
| 3 | + This file is part of rippled: https://github.com/ripple/rippled |
| 4 | + Copyright (c) 2024 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 | +#include <xrpl/protocol/Permissions.h> |
| 21 | +#include <xrpl/protocol/SField.h> |
| 22 | +#include <xrpl/protocol/SOTemplate.h> |
| 23 | +#include <xrpl/protocol/jss.h> |
| 24 | + |
| 25 | +namespace ripple { |
| 26 | + |
| 27 | +GranularPermission::GranularPermission() |
| 28 | +{ |
| 29 | + // add(jss::TrustlineAuthorize, gpTrustlineAuthorize, {}); |
| 30 | + granularPermissionMap = { |
| 31 | + {"TrustlineAuthorize", gpTrustlineAuthorize}, |
| 32 | + {"TrustlineFreeze", gpTrustlineFreeze}, |
| 33 | + {"TrustlineUnfreeze", gpTrustlineUnfreeze}, |
| 34 | + {"AccountDomainSet", gpAccountDomainSet}, |
| 35 | + {"AccountEmailHashSet", gpAccountEmailHashSet}, |
| 36 | + {"AccountMessageKeySet", gpAccountMessageKeySet}, |
| 37 | + {"AccountTransferRateSet", gpAccountTransferRateSet}, |
| 38 | + {"AccountTickSizeSet", gpAccountTickSizeSet}, |
| 39 | + {"PaymentMint", gpPaymentMint}, |
| 40 | + {"PaymentBurn", gpPaymentBurn}, |
| 41 | + {"MPTokenIssuanceLock", gpMPTokenIssuanceLock}, |
| 42 | + {"MPTokenIssuanceUnlock", gpMPTokenIssuanceUnlock}}; |
| 43 | +} |
| 44 | + |
| 45 | +GranularPermission const& |
| 46 | +GranularPermission::getInstance() |
| 47 | +{ |
| 48 | + static GranularPermission const instance; |
| 49 | + return instance; |
| 50 | +} |
| 51 | + |
| 52 | +std::optional<std::uint32_t> |
| 53 | +GranularPermission::getValue(const std::string& name) const |
| 54 | +{ |
| 55 | + auto const it = granularPermissionMap.find(name); |
| 56 | + if (it != granularPermissionMap.end()) |
| 57 | + return static_cast<uint32_t>(it->second); |
| 58 | + |
| 59 | + return std::nullopt; |
| 60 | +} |
| 61 | + |
| 62 | +} // namespace ripple |
0 commit comments