-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add various endpoints for REST server #265
Add various endpoints for REST server #265
Conversation
freak12techno
commented
Jan 19, 2024
•
edited
Loading
edited
- in validators endpoint, filter validators by status
- updated staking pool endpoint response to be compatible with cosmos-sdk one
- return real values on staking pool endpoint
- added endpoint to return latest/specific block
- added endpoint to return validator set on latest/specific block
- added endpoint to return community pool
"BOND_STATUS_UNBONDING" | ||
} else if validator.in_active_set { | ||
"BOND_STATUS_BONDED" | ||
} else { | ||
"BOND_STATUS_UNBONDED" | ||
}; | ||
|
||
if !status.is_none() && status != Some(validator_status.to_owned()) { |
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.
this part looks ugly but I am unsure if there's a better way to say "if it's either not set or doesn't equal to whatever status validator has"
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.
This isn't a bad way to express that, the only way I can see to simplify would be changing !status.is_none()
to status.is_some()
.
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.
Just noting that this check is case-sensitive. I'm not sure if the SDK equivalent is or not but if not, it's worth changing to maintain compatibility (can come in a later PR).
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.
honestly not sure about that, I only added this as ping.pub expects this endpoint to return only active validators on /validators?status=BOND_STATUS_BONDED
anyways, I guess this one is anyways better than not supporting this param at all right?
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.
Just noting that this check is case-sensitive. I'm not sure if the SDK equivalent is or not
actually somewhat neither lol
"rpc error: code = InvalidArgument desc = invalid validator status bond_status_bonded: invalid request"
(this is when I query my own node on Cosmos Hub with status as a valid status but in lowercase: https://api.cosmos.quokkastake.io/cosmos/staking/v1beta1/validators?status=bond_status_bonded)
0e8b1cc
to
216dd44
Compare
rest/src/main.rs
Outdated
.map(|validator| -> Value { | ||
json!({ | ||
"address": validator.address, | ||
"voting_power": (i64::from(validator.power) / 1_000_000).to_string(), |
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.
See line 912.
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.
also reverted
30cd861
to
a8668f9
Compare
@mappum okay I fixed your comments, can you check once more? |
Looks good, thanks! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #265 +/- ##
========================================
Coverage 33.36% 33.36%
========================================
Files 24 24
Lines 8260 8260
========================================
Hits 2756 2756
Misses 5504 5504 ☔ View full report in Codecov by Sentry. |