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

feat: change the way URL params are setup #50

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions internal/provider/alliance/alliance_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"sort"
"strconv"
Expand Down Expand Up @@ -479,13 +480,11 @@ func (p *allianceValidatorsProvider) queryValidatorsData(ctx context.Context) (
}

func (p *allianceValidatorsProvider) getProposals(ctx context.Context) (stationProposals []types.StationVote, err error) {
passedProposalsUrl := "/cosmos/gov/v1/proposals?proposal_status=3&pagination.limit=2&pagination.reverse=true"
rejectedProposalsUrl := "/cosmos/gov/v1/proposals?proposal_status=4&pagination.limit=2&pagination.reverse=true"
passedProposalsIDs, err := p.queryProposalIDs(passedProposalsUrl)
passedProposalsIDs, err := p.queryProposalIDs("3")
if err != nil {
return stationProposals, err
}
rejectedProposalsIDs, err := p.queryProposalIDs(rejectedProposalsUrl)
rejectedProposalsIDs, err := p.queryProposalIDs("4")
if err != nil {
return stationProposals, err
}
Expand All @@ -509,8 +508,13 @@ func (p *allianceValidatorsProvider) getProposals(ctx context.Context) (stationP
return stationProposals, err
}

func (p allianceValidatorsProvider) queryProposalIDs(urlSuffix string) (proposalIDs []int64, err error) {
url := p.terraLcdUrl + urlSuffix
func (p allianceValidatorsProvider) queryProposalIDs(proposalStatus string) (proposalIDs []int64, err error) {
queryParams := url.Values{}
queryParams.Add("proposal_status", proposalStatus)
queryParams.Add("pagination.limit", "2")
queryParams.Add("pagination.reverse", "true")

url := p.terraLcdUrl + "/cosmos/gov/v1/proposals?" + queryParams.Encode()

// Send GET request
res, err := http.Get(url)
Expand Down
Loading