-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feature: Add delegate filter param for account_tx RPC #6126
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6126 +/- ##
=========================================
+ Coverage 78.6% 79.1% +0.5%
=========================================
Files 818 839 +21
Lines 68938 71425 +2487
Branches 8240 8346 +106
=========================================
+ Hits 54177 56469 +2292
- Misses 14761 14956 +195
🚀 New features to boost your workflow:
|
|
A few suggestions to the new API:
|
| auto const& filter = options.delegate.value(); | ||
| auto const& contextAccount = options.account; | ||
|
|
||
| if (filter.type == DelegateType::Delegatee) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use switch case for enum
| if (params.isMember("delegate")) | ||
| { | ||
| auto const& delegateNode = params["delegate"]; | ||
|
|
||
| if (!delegateNode.isObject() || | ||
| !delegateNode.isMember(jss::delegate_filter)) | ||
| return RPC::invalid_field_error("delegate"); | ||
|
|
||
| DelegateFilter filter; | ||
|
|
||
| if (!delegateNode[jss::delegate_filter].isString()) | ||
| return RPC::invalid_field_error(jss::delegate_filter); | ||
|
|
||
| auto const& delegateFilterStr = | ||
| delegateNode[jss::delegate_filter].asString(); | ||
|
|
||
| if (delegateFilterStr == "delegatee") | ||
| filter.type = DelegateType::Delegatee; | ||
| else if (delegateFilterStr == "delegator") | ||
| filter.type = DelegateType::Delegator; | ||
| else | ||
| return RPC::invalid_field_error(jss::delegate_filter); | ||
|
|
||
| if (delegateNode.isMember(jss::counterparty)) | ||
| { | ||
| if (!delegateNode[jss::counterparty].isString()) | ||
| return RPC::invalid_field_error(jss::counterparty); | ||
|
|
||
| auto const counterparty = parseBase58<AccountID>( | ||
| delegateNode[jss::counterparty].asString()); | ||
| if (!counterparty) | ||
| return rpcError(rpcACT_MALFORMED); | ||
|
|
||
| filter.counterparty = *counterparty; | ||
| } | ||
|
|
||
| args.delegate = filter; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe all of this could be moved to a static method of DelegateFilter?
std::expected<std::optional<DelegateFilter>, RpcError> create(params);The the usage will be much simpler:
if (auto const filter = DelegateFilter::create(params); filter.has_value()) {
args.filter = *filter;
} else {
return filter.error();
}
High Level Overview of Change
This PR adds the ability to filter account_tx results based on transaction delegation. This is useful for scenarios where one account (the delegatee) signs and submits a transaction on behalf of another account (the delegator).
Context of Change
New Request Parameter:
"delegate": {
"delegate_filter": "delegatee" or "delegator",
"counter_party": "account_address"
}
Example: If User A submits a transaction to C on behalf of B:
User B (The account holder) can query with delegate_filter: "delegatee" to find transactions signed by others (like User A).
User A (The signer) can query with delegate_filter: "delegator" to find transactions they signed for others (like User B).
The counter_party field can be used in either case to filter by a specific valid address
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)