-
Notifications
You must be signed in to change notification settings - Fork 59
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
Implement JSON-RPC method queryStakes #2437
Merged
Tommytrg
merged 2 commits into
witnet:2.0-master
from
Tommytrg:feat/2.0/jsonrpc/query-stakes
Mar 21, 2024
Merged
Implement JSON-RPC method queryStakes #2437
Tommytrg
merged 2 commits into
witnet:2.0-master
from
Tommytrg:feat/2.0/jsonrpc/query-stakes
Mar 21, 2024
Conversation
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
8aa111e
to
694acaf
Compare
694acaf
to
bdc5fe7
Compare
aesedepece
requested changes
Mar 12, 2024
aesedepece
requested changes
Mar 12, 2024
Tommytrg
commented
Mar 15, 2024
Tommytrg
commented
Mar 15, 2024
aesedepece
requested changes
Mar 18, 2024
node/src/actors/json_rpc/api.rs
Outdated
Comment on lines
2119
to
2133
match address { | ||
QueryStakesArgument::Validator(k) => QueryStakesParams::Validator( | ||
PublicKeyHash::from_bech32(get_environment(), &k).map_err(internal_error)?, | ||
), | ||
QueryStakesArgument::Withdrawer(k) => QueryStakesParams::Withdrawer( | ||
PublicKeyHash::from_bech32(get_environment(), &k).map_err(internal_error)?, | ||
), | ||
QueryStakesArgument::Key((v, w)) => QueryStakesParams::Key(( | ||
PublicKeyHash::from_bech32(get_environment(), &v).map_err(internal_error)?, | ||
PublicKeyHash::from_bech32(get_environment(), &w).map_err(internal_error)?, | ||
)), | ||
} |
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 can imagine that you can remove all the map_err
in each branch, and rather have it once in line 2130.
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.
Something like the following?
match address {
QueryStakesArgument::Validator(validator) => QueryStakesParams::Validator(
PublicKeyHash::from_bech32(get_environment(), &validator)
),
QueryStakesArgument::Withdrawer(withdrawer) => QueryStakesParams::Withdrawer(
PublicKeyHash::from_bech32(get_environment(), &withdrawer)
),
QueryStakesArgument::Key((validator, withdrawer)) => QueryStakesParams::Key((
PublicKeyHash::from_bech32(get_environment(), &validator),
PublicKeyHash::from_bech32(get_environment(), &withdrawer)
)),
}.map_err(internal_error)?
error[E0308]: mismatched types
--> node/src/actors/json_rpc/api.rs:2120:17
|
2119 | QueryStakesArgument::Validator(validator) => QueryStakesParams::Validator(
| ---------------------------- arguments to this enum variant are incorrect
2120 | PublicKeyHash::from_bech32(get_environment(), &validator)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `PublicKeyHash`, found `Result<PublicKeyHash, ...>`
|
= note: expected struct `witnet_data_structures::chain::PublicKeyHash`
found enum `Result<witnet_data_structures::chain::PublicKeyHash, PublicKeyHashParseError>`
note: tuple variant defined here
--> node/src/actors/messages.rs:314:5
```
1f25d7a
to
977b4e8
Compare
This method allows to query the stakes of the specified argument. The argument can contain: - A validator and a withdrawer - A validator - A withdrawer - Empty argument, uses the node's address as validator. The type of the argument is an address as a string.
Please enter the commit message for your changes. Lines starting
977b4e8
to
ef7bf95
Compare
aesedepece
approved these changes
Mar 21, 2024
This was referenced Mar 21, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implement JSON-RPC and CLI methods that allow querying the stakes of the specified address/addresses argument.
The argument can contain:
close #2424
close #2423