-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 bd7150e
Showing
19 changed files
with
485 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,82 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
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_PERMISSION_H_INCLUDED | ||
#define RIPPLE_PROTOCOL_PERMISSION_H_INCLUDED | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace ripple { | ||
|
||
/** | ||
* We have transaction type permissions and granular type | ||
* 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 Permission | ||
{ | ||
private: | ||
Permission(); | ||
|
||
std::unordered_map<std::string, GranularPermissionType> | ||
granularPermissionMap; | ||
|
||
public: | ||
static Permission const& | ||
getInstance(); | ||
|
||
std::optional<std::uint32_t> | ||
getGranularValue(const std::string& name) const; | ||
|
||
bool | ||
isProhibited(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
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,73 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
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 { | ||
|
||
Permission::Permission() | ||
{ | ||
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}}; | ||
} | ||
|
||
Permission const& | ||
Permission::getInstance() | ||
{ | ||
static Permission const instance; | ||
return instance; | ||
} | ||
|
||
std::optional<std::uint32_t> | ||
Permission::getGranularValue(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; | ||
} | ||
|
||
bool | ||
Permission::isProhibited(const std::string& name) const | ||
{ | ||
// We do not allow delegating the following transaction permissions to other | ||
// accounts for security reason. | ||
if (name == "AccountSet" || name == "SetRegularKey" || | ||
name == "SignerListSet") | ||
return true; | ||
|
||
return false; | ||
} | ||
|
||
} // 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.