Skip to content

Commit

Permalink
Merge pull request #50 from terra-money/feat/url/params
Browse files Browse the repository at this point in the history
feat: change the way URL params are setup
  • Loading branch information
emidev98 authored Aug 10, 2023
2 parents 73dec5f + 756ae6f commit 95dc50b
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit 95dc50b

Please sign in to comment.