-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support PermissionDelegation Amendment XLS-74d XLS-75d #5354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
49ca2b8
Support AccountPermission
yinyiqian1 4e62a34
Resolve comments
yinyiqian1 ce15383
Resolve more comments
yinyiqian1 2da1590
Add uint32 to string parse
yinyiqian1 31f4051
change feature name to PermissionDelegation
yinyiqian1 5624385
resolve comments and code coverage
yinyiqian1 45999cb
resolve comment and typo
yinyiqian1 7b20a39
resolve comments
yinyiqian1 f7f7478
remove redundant code
yinyiqian1 0d5e148
resolve comment
yinyiqian1 cb2d2cd
Merge branch 'develop' into account_permission_new
yinyiqian1 8f48a4e
whitelist delegatable tx and resolve comments
yinyiqian1 c39d061
resolve unity build namimg conflicts
yinyiqian1 237d09f
Merge remote-tracking branch 'origin/develop' into account_permission…
yinyiqian1 6f4ae53
Resolve unused warning for Release build
yinyiqian1 d8373e9
void(enforce) to avoid warning
yinyiqian1 3d245c8
fix (void)enforce
yinyiqian1 647ae72
resolve comments
yinyiqian1 5210035
Merge branch 'develop' into account_permission_new
yinyiqian1 3d5aef6
Merge branch 'develop' into account_permission_new
yinyiqian1 0d80686
add rpcDELEGATE_ACT_NOT_FOUND
yinyiqian1 82f64d1
Add sequence test case
yinyiqian1 7c853ec
modify trustset granular unit test
yinyiqian1 a6f7e0c
Merge branch 'develop' into account_permission_new
yinyiqian1 6110424
Fix flag default value for AccountSet
yinyiqian1 3839f1f
clean up unit test feature passing
yinyiqian1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,97 @@ | ||
| //------------------------------------------------------------------------------ | ||
| /* | ||
| This file is part of rippled: https://github.com/ripple/rippled | ||
| Copyright (c) 2025 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 <xrpl/protocol/TxFormats.h> | ||
|
|
||
| #include <optional> | ||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <unordered_set> | ||
|
|
||
| namespace ripple { | ||
| /** | ||
| * We have both transaction type permissions and granular type permissions. | ||
| * Since we will reuse the TransactionFormats to parse the Transaction | ||
| * Permissions, only the GranularPermissionType is defined here. To prevent | ||
| * conflicts with TxType, the GranularPermissionType is always set to a value | ||
| * greater than the maximum value of uint16. | ||
| */ | ||
| enum GranularPermissionType : std::uint32_t { | ||
| #pragma push_macro("PERMISSION") | ||
| #undef PERMISSION | ||
|
|
||
| #define PERMISSION(type, txType, value) type = value, | ||
|
|
||
| #include <xrpl/protocol/detail/permissions.macro> | ||
|
|
||
| #undef PERMISSION | ||
| #pragma pop_macro("PERMISSION") | ||
| }; | ||
|
|
||
| enum delegatable { enabled, disabled }; | ||
|
|
||
| class Permission | ||
| { | ||
| private: | ||
| Permission(); | ||
|
|
||
| std::unordered_map<std::uint16_t, delegatable> delegatableTx; | ||
|
|
||
| std::unordered_map<std::string, GranularPermissionType> | ||
| granularPermissionMap; | ||
|
|
||
| std::unordered_map<GranularPermissionType, std::string> granularNameMap; | ||
|
|
||
| std::unordered_map<GranularPermissionType, TxType> granularTxTypeMap; | ||
|
|
||
| public: | ||
| static Permission const& | ||
| getInstance(); | ||
|
|
||
| Permission(const Permission&) = delete; | ||
| Permission& | ||
| operator=(const Permission&) = delete; | ||
|
|
||
| std::optional<std::uint32_t> | ||
| getGranularValue(std::string const& name) const; | ||
|
|
||
| std::optional<std::string> | ||
| getGranularName(GranularPermissionType const& value) const; | ||
|
|
||
| std::optional<TxType> | ||
| getGranularTxType(GranularPermissionType const& gpType) const; | ||
|
|
||
| bool | ||
| isDelegatable(std::uint32_t const& permissionValue) const; | ||
|
|
||
| // for tx level permission, permission value is equal to tx type plus one | ||
| uint32_t | ||
| txToPermissionType(const TxType& type) const; | ||
|
|
||
| // tx type value is permission value minus one | ||
| TxType | ||
| permissionToTxType(uint32_t const& value) const; | ||
| }; | ||
|
|
||
| } // namespace ripple | ||
|
|
||
| #endif | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| //------------------------------------------------------------------------------ | ||
| /* | ||
| This file is part of rippled: https://github.com/ripple/rippled | ||
| Copyright (c) 2025 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. | ||
| */ | ||
| //============================================================================== | ||
|
|
||
| #if !defined(PERMISSION) | ||
| #error "undefined macro: PERMISSION" | ||
| #endif | ||
|
|
||
| /** | ||
| * PERMISSION(name, type, txType, value) | ||
| * | ||
| * This macro defines a permission: | ||
| * name: the name of the permission. | ||
| * type: the GranularPermissionType enum. | ||
| * txType: the corresponding TxType for this permission. | ||
| * value: the uint32 numeric value for the enum type. | ||
| */ | ||
|
|
||
| /** This permission grants the delegated account the ability to authorize a trustline. */ | ||
| PERMISSION(TrustlineAuthorize, ttTRUST_SET, 65537) | ||
|
|
||
| /** This permission grants the delegated account the ability to freeze a trustline. */ | ||
| PERMISSION(TrustlineFreeze, ttTRUST_SET, 65538) | ||
|
|
||
| /** This permission grants the delegated account the ability to unfreeze a trustline. */ | ||
| PERMISSION(TrustlineUnfreeze, ttTRUST_SET, 65539) | ||
|
|
||
| /** This permission grants the delegated account the ability to set Domain. */ | ||
| PERMISSION(AccountDomainSet, ttACCOUNT_SET, 65540) | ||
|
|
||
| /** This permission grants the delegated account the ability to set EmailHashSet. */ | ||
| PERMISSION(AccountEmailHashSet, ttACCOUNT_SET, 65541) | ||
|
|
||
| /** This permission grants the delegated account the ability to set MessageKey. */ | ||
| PERMISSION(AccountMessageKeySet, ttACCOUNT_SET, 65542) | ||
|
|
||
| /** This permission grants the delegated account the ability to set TransferRate. */ | ||
| PERMISSION(AccountTransferRateSet, ttACCOUNT_SET, 65543) | ||
|
|
||
| /** This permission grants the delegated account the ability to set TickSize. */ | ||
| PERMISSION(AccountTickSizeSet, ttACCOUNT_SET, 65544) | ||
|
|
||
| /** This permission grants the delegated account the ability to mint payment, which means sending a payment for a currency where the sending account is the issuer. */ | ||
| PERMISSION(PaymentMint, ttPAYMENT, 65545) | ||
|
|
||
| /** This permission grants the delegated account the ability to burn payment, which means sending a payment for a currency where the destination account is the issuer */ | ||
| PERMISSION(PaymentBurn, ttPAYMENT, 65546) | ||
|
|
||
| /** This permission grants the delegated account the ability to lock MPToken. */ | ||
| PERMISSION(MPTokenIssuanceLock, ttMPTOKEN_ISSUANCE_SET, 65547) | ||
|
|
||
| /** This permission grants the delegated account the ability to unlock MPToken. */ | ||
| PERMISSION(MPTokenIssuanceUnlock, ttMPTOKEN_ISSUANCE_SET, 65548) |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.