Skip to content

Commit

Permalink
Merge pull request #19 from DefiantLabs/feat/validator-bond-status-op…
Browse files Browse the repository at this point in the history
…tional

patch/Update validator RPC to allow skipping bond status param
  • Loading branch information
pharr117 authored May 8, 2024
2 parents 38932cb + 7c294d8 commit d0410f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions query/staking/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import (
stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

func ValidatorsRPC(q *probeQueryTypes.Query, status stakingTypes.BondStatus, paginationKey []byte) (*stakingTypes.QueryValidatorsResponse, error) {
req := stakingTypes.QueryValidatorsRequest{
Status: status.String(),
func ValidatorsRPC(q *probeQueryTypes.Query, status *stakingTypes.BondStatus, paginationKey []byte) (*stakingTypes.QueryValidatorsResponse, error) {
req := stakingTypes.QueryValidatorsRequest{}

// Set the status if it is not nil
// This can prevent errors since you can't use BondStatusUnspecified (at least on Cosmoshub)
if status != nil {
req.Status = status.String()
}

if paginationKey != nil {
Expand All @@ -27,7 +31,7 @@ func ValidatorsRPC(q *probeQueryTypes.Query, status stakingTypes.BondStatus, pag
return res, nil
}

func Validators(q *probeQueryTypes.Query, status stakingTypes.BondStatus) (*stakingTypes.QueryValidatorsResponse, error) {
func Validators(q *probeQueryTypes.Query, status *stakingTypes.BondStatus) (*stakingTypes.QueryValidatorsResponse, error) {
var paginationKey []byte

if q.Options.Pagination != nil && q.Options.Pagination.Key != nil {
Expand Down

0 comments on commit d0410f3

Please sign in to comment.