Skip to content
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

Merged
merged 15 commits into from
Jan 31, 2024

Conversation

freak12techno
Copy link
Contributor

@freak12techno freak12techno commented Jan 19, 2024

  • 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()) {
Copy link
Contributor Author

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"

Copy link
Contributor

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().

Copy link
Contributor

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).

Copy link
Contributor Author

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?

Copy link
Contributor Author

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)

rest/src/main.rs Outdated Show resolved Hide resolved
rest/src/main.rs Outdated
.map(|validator| -> Value {
json!({
"address": validator.address,
"voting_power": (i64::from(validator.power) / 1_000_000).to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line 912.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also reverted

rest/src/main.rs Show resolved Hide resolved
@freak12techno
Copy link
Contributor Author

@mappum okay I fixed your comments, can you check once more?

@mappum mappum enabled auto-merge January 31, 2024 23:20
@mappum
Copy link
Contributor

mappum commented Jan 31, 2024

Looks good, thanks!

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (eb4bd08) 33.36% compared to head (1789d5a) 33.36%.

❗ 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.
📢 Have feedback on the report? Share it here.

@mappum mappum merged commit 5dd80a6 into nomic-io:develop Jan 31, 2024
8 checks passed
@freak12techno freak12techno deleted the add-various-endpoints branch January 31, 2024 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants