forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63209c2
commit e478bed
Showing
18 changed files
with
473 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2024 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#ifndef RIPPLE_PROTOCOL_PERMISSIONFORMATS_H_INCLUDED | ||
#define RIPPLE_PROTOCOL_PERMISSIONFORMATS_H_INCLUDED | ||
|
||
#include <xrpl/protocol/KnownFormats.h> | ||
|
||
namespace ripple { | ||
|
||
/** | ||
* We have transaction type account permissions and granular account | ||
* permissions. Since we will reuse the TransactionFormats to parse the | ||
* Transaction Permissions, we only define the GranularPermissionType here. | ||
*/ | ||
|
||
enum GranularPermissionType : std::uint32_t { | ||
gpTrustlineAuthorize = 65537, | ||
|
||
gpTrustlineFreeze = 65538, | ||
|
||
gpTrustlineUnfreeze = 65539, | ||
|
||
gpAccountDomainSet = 65540, | ||
|
||
gpAccountEmailHashSet = 65541, | ||
|
||
gpAccountMessageKeySet = 65542, | ||
|
||
gpAccountTransferRateSet = 65543, | ||
|
||
gpAccountTickSizeSet = 65544, | ||
|
||
gpPaymentMint = 65545, | ||
|
||
gpPaymentBurn = 65546, | ||
|
||
gpMPTokenIssuanceLock = 65547, | ||
|
||
gpMPTokenIssuanceUnlock = 65548, | ||
}; | ||
|
||
class GranularPermission | ||
{ | ||
private: | ||
GranularPermission(); | ||
|
||
std::unordered_map<std::string, GranularPermissionType> | ||
granularPermissionMap; | ||
|
||
public: | ||
static GranularPermission const& | ||
getInstance(); | ||
|
||
std::optional<std::uint32_t> | ||
getValue(const std::string& name) const; | ||
}; | ||
|
||
} // namespace ripple | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2024 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#include <xrpl/protocol/Permissions.h> | ||
#include <xrpl/protocol/SField.h> | ||
#include <xrpl/protocol/SOTemplate.h> | ||
#include <xrpl/protocol/jss.h> | ||
|
||
namespace ripple { | ||
|
||
GranularPermission::GranularPermission() | ||
{ | ||
// add(jss::TrustlineAuthorize, gpTrustlineAuthorize, {}); | ||
granularPermissionMap = { | ||
{"TrustlineAuthorize", gpTrustlineAuthorize}, | ||
{"TrustlineFreeze", gpTrustlineFreeze}, | ||
{"TrustlineUnfreeze", gpTrustlineUnfreeze}, | ||
{"AccountDomainSet", gpAccountDomainSet}, | ||
{"AccountEmailHashSet", gpAccountEmailHashSet}, | ||
{"AccountMessageKeySet", gpAccountMessageKeySet}, | ||
{"AccountTransferRateSet", gpAccountTransferRateSet}, | ||
{"AccountTickSizeSet", gpAccountTickSizeSet}, | ||
{"PaymentMint", gpPaymentMint}, | ||
{"PaymentBurn", gpPaymentBurn}, | ||
{"MPTokenIssuanceLock", gpMPTokenIssuanceLock}, | ||
{"MPTokenIssuanceUnlock", gpMPTokenIssuanceUnlock}}; | ||
} | ||
|
||
GranularPermission const& | ||
GranularPermission::getInstance() | ||
{ | ||
static GranularPermission const instance; | ||
return instance; | ||
} | ||
|
||
std::optional<std::uint32_t> | ||
GranularPermission::getValue(const std::string& name) const | ||
{ | ||
auto const it = granularPermissionMap.find(name); | ||
if (it != granularPermissionMap.end()) | ||
return static_cast<uint32_t>(it->second); | ||
|
||
return std::nullopt; | ||
} | ||
|
||
} // namespace ripple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.