Merge branch 'develop' into svaishnavy/cosmos-sdk-cli
This commit is contained in:
commit
7d1f8d2997
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -5,6 +5,16 @@
|
|||
Features
|
||||
* [cosmos-sdk-cli] Added support for cosmos-sdk-cli under cosmos-sdk/cmd
|
||||
This allows SDK users to init a new project repository with a single command.
|
||||
=======
|
||||
BREAKING CHANGES
|
||||
|
||||
FEATURES
|
||||
* [lcd] Can now query governance proposals by ProposalStatus
|
||||
|
||||
IMPROVEMENTS
|
||||
* [baseapp] Allow any alphanumeric character in route
|
||||
|
||||
BUG FIXES
|
||||
|
||||
## 0.22.0
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs }
|
|||
|
||||
const (
|
||||
typeMsgCounter = "msgCounter"
|
||||
typeMsgCounter2 = "msgCounterTwo" // NOTE: no numerics (?)
|
||||
typeMsgCounter2 = "msgCounter2"
|
||||
)
|
||||
|
||||
// ValidateBasic() fails on negative counters.
|
||||
|
|
|
@ -31,12 +31,12 @@ func NewRouter() *router {
|
|||
}
|
||||
}
|
||||
|
||||
var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString
|
||||
var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString
|
||||
|
||||
// AddRoute - TODO add description
|
||||
func (rtr *router) AddRoute(r string, h sdk.Handler) Router {
|
||||
if !isAlpha(r) {
|
||||
panic("route expressions can only contain alphabet characters")
|
||||
if !isAlphaNumeric(r) {
|
||||
panic("route expressions can only contain alphanumeric characters")
|
||||
}
|
||||
rtr.routes = append(rtr.routes, route{r, h})
|
||||
|
||||
|
|
|
@ -569,6 +569,16 @@ func TestProposalsQuery(t *testing.T) {
|
|||
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Only proposals #1 should be in Deposit Period
|
||||
proposals := getProposalsFilterStatus(t, port, gov.StatusDepositPeriod)
|
||||
require.Len(t, proposals, 1)
|
||||
require.Equal(t, proposalID1, proposals[0].GetProposalID())
|
||||
// Only proposals #2 and #3 should be in Voting Period
|
||||
proposals = getProposalsFilterStatus(t, port, gov.StatusVotingPeriod)
|
||||
require.Len(t, proposals, 2)
|
||||
require.Equal(t, proposalID2, proposals[0].GetProposalID())
|
||||
require.Equal(t, proposalID3, proposals[1].GetProposalID())
|
||||
|
||||
// Addr1 votes on proposals #2 & #3
|
||||
resultTx = doVote(t, port, seed, name, password1, addr, proposalID2)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
@ -580,7 +590,7 @@ func TestProposalsQuery(t *testing.T) {
|
|||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Test query all proposals
|
||||
proposals := getProposalsAll(t, port)
|
||||
proposals = getProposalsAll(t, port)
|
||||
require.Equal(t, proposalID1, (proposals[0]).GetProposalID())
|
||||
require.Equal(t, proposalID2, (proposals[1]).GetProposalID())
|
||||
require.Equal(t, proposalID3, (proposals[2]).GetProposalID())
|
||||
|
@ -910,6 +920,16 @@ func getProposalsFilterVoterDepositer(t *testing.T, port string, voterAddr, depo
|
|||
return proposals
|
||||
}
|
||||
|
||||
func getProposalsFilterStatus(t *testing.T, port string, status gov.ProposalStatus) []gov.Proposal {
|
||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?status=%s", status), nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
var proposals []gov.Proposal
|
||||
err := cdc.UnmarshalJSON([]byte(body), &proposals)
|
||||
require.Nil(t, err)
|
||||
return proposals
|
||||
}
|
||||
|
||||
func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||
// get the account to get the sequence
|
||||
acc := getAccount(t, port, proposerAddr)
|
||||
|
|
|
@ -16,10 +16,11 @@ import (
|
|||
// REST Variable names
|
||||
// nolint
|
||||
const (
|
||||
RestProposalID = "proposalID"
|
||||
RestDepositer = "depositer"
|
||||
RestVoter = "voter"
|
||||
storeName = "gov"
|
||||
RestProposalID = "proposalID"
|
||||
RestDepositer = "depositer"
|
||||
RestVoter = "voter"
|
||||
RestProposalStatus = "status"
|
||||
storeName = "gov"
|
||||
)
|
||||
|
||||
// RegisterRoutes - Central function to define routes that get registered by the main application
|
||||
|
@ -340,10 +341,12 @@ func queryProposalsWithParameterFn(cdc *wire.Codec) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
bechVoterAddr := r.URL.Query().Get(RestVoter)
|
||||
bechDepositerAddr := r.URL.Query().Get(RestDepositer)
|
||||
strProposalStatus := r.URL.Query().Get(RestProposalStatus)
|
||||
|
||||
var err error
|
||||
var voterAddr sdk.AccAddress
|
||||
var depositerAddr sdk.AccAddress
|
||||
var proposalStatus gov.ProposalStatus
|
||||
|
||||
if len(bechVoterAddr) != 0 {
|
||||
voterAddr, err = sdk.AccAddressFromBech32(bechVoterAddr)
|
||||
|
@ -365,6 +368,16 @@ func queryProposalsWithParameterFn(cdc *wire.Codec) http.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
if len(strProposalStatus) != 0 {
|
||||
proposalStatus, err = gov.ProposalStatusFromString(strProposalStatus)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
err := errors.Errorf("'%s' is not a valid Proposal Status", strProposalStatus)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx := context.NewCoreContextFromViper()
|
||||
|
||||
res, err := ctx.QueryStore(gov.KeyNextProposalID, storeName)
|
||||
|
@ -397,9 +410,16 @@ func queryProposalsWithParameterFn(cdc *wire.Codec) http.HandlerFunc {
|
|||
if err != nil || len(res) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
var proposal gov.Proposal
|
||||
cdc.MustUnmarshalBinary(res, &proposal)
|
||||
|
||||
if len(strProposalStatus) != 0 {
|
||||
if proposal.GetStatus() != proposalStatus {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
matchingProposals = append(matchingProposals, proposal)
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ var (
|
|||
// TODO Temporarily set to 10 minutes for testnets
|
||||
defaultDowntimeUnbondDuration int64 = 60 * 10
|
||||
|
||||
defaultMinSignedPerWindow sdk.Rat = sdk.NewRat(1, 2)
|
||||
defaultMinSignedPerWindow = sdk.NewRat(1, 2)
|
||||
|
||||
defaultSlashFractionDoubleSign = sdk.NewRat(1).Quo(sdk.NewRat(20))
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ var (
|
|||
sdk.AccAddress(pks[1].Address()),
|
||||
sdk.AccAddress(pks[2].Address()),
|
||||
}
|
||||
initCoins sdk.Int = sdk.NewInt(200)
|
||||
initCoins = sdk.NewInt(200)
|
||||
)
|
||||
|
||||
func createTestCodec() *wire.Codec {
|
||||
|
|
|
@ -21,7 +21,7 @@ var _, _ sdk.Msg = &MsgBeginUnbonding{}, &MsgCompleteUnbonding{}
|
|||
var _, _ sdk.Msg = &MsgBeginRedelegate{}, &MsgCompleteRedelegate{}
|
||||
|
||||
// Initialize Int for the denominator
|
||||
var maximumBondingRationalDenominator sdk.Int = sdk.NewInt(int64(math.Pow10(MaxBondDenominatorPrecision)))
|
||||
var maximumBondingRationalDenominator = sdk.NewInt(int64(math.Pow10(MaxBondDenominatorPrecision)))
|
||||
|
||||
//______________________________________________________________________
|
||||
|
||||
|
|
Loading…
Reference in New Issue