Merge remote-tracking branch 'origin/develop' into rigel/fee-distribution
This commit is contained in:
commit
43e4396bec
|
@ -44,7 +44,7 @@ BREAKING CHANGES
|
||||||
* [simulation] \#2162 Added back correct supply invariants
|
* [simulation] \#2162 Added back correct supply invariants
|
||||||
* [x/slashing] \#2430 Simulate more slashes, check if validator is jailed before jailing
|
* [x/slashing] \#2430 Simulate more slashes, check if validator is jailed before jailing
|
||||||
* [x/stake] \#2393 Removed `CompleteUnbonding` and `CompleteRedelegation` Msg types, and instead added unbonding/redelegation queues to endblocker
|
* [x/stake] \#2393 Removed `CompleteUnbonding` and `CompleteRedelegation` Msg types, and instead added unbonding/redelegation queues to endblocker
|
||||||
|
|
||||||
* SDK
|
* SDK
|
||||||
* [core] \#2219 Update to Tendermint 0.24.0
|
* [core] \#2219 Update to Tendermint 0.24.0
|
||||||
* Validator set updates delayed by one block
|
* Validator set updates delayed by one block
|
||||||
|
@ -76,7 +76,7 @@ BREAKING CHANGES
|
||||||
* Mempool now won't build too large blocks, or too computationally expensive blocks
|
* Mempool now won't build too large blocks, or too computationally expensive blocks
|
||||||
* Maximum tx sizes and gas are now removed, and are implicitly the blocks maximums
|
* Maximum tx sizes and gas are now removed, and are implicitly the blocks maximums
|
||||||
* ABCI validators no longer send the pubkey. The pubkey is only sent in validator updates
|
* ABCI validators no longer send the pubkey. The pubkey is only sent in validator updates
|
||||||
* Validator set changes are now delayed by one block
|
* Validator set changes are now delayed by one block
|
||||||
* Block header now includes the next validator sets hash
|
* Block header now includes the next validator sets hash
|
||||||
* BFT time is implemented
|
* BFT time is implemented
|
||||||
* Secp256k1 signature format has changed
|
* Secp256k1 signature format has changed
|
||||||
|
@ -92,6 +92,7 @@ FEATURES
|
||||||
* [gaia-lite] [\#1953](https://github.com/cosmos/cosmos-sdk/issues/1953) Add /sign endpoint to sign transactions generated with `generate_only=true`.
|
* [gaia-lite] [\#1953](https://github.com/cosmos/cosmos-sdk/issues/1953) Add /sign endpoint to sign transactions generated with `generate_only=true`.
|
||||||
* [gaia-lite] [\#1954](https://github.com/cosmos/cosmos-sdk/issues/1954) Add /broadcast endpoint to broadcast transactions signed by the /sign endpoint.
|
* [gaia-lite] [\#1954](https://github.com/cosmos/cosmos-sdk/issues/1954) Add /broadcast endpoint to broadcast transactions signed by the /sign endpoint.
|
||||||
* [gaia-lite] [\#2113](https://github.com/cosmos/cosmos-sdk/issues/2113) Rename `/accounts/{address}/send` to `/bank/accounts/{address}/transfers`, rename `/accounts/{address}` to `/auth/accounts/{address}`
|
* [gaia-lite] [\#2113](https://github.com/cosmos/cosmos-sdk/issues/2113) Rename `/accounts/{address}/send` to `/bank/accounts/{address}/transfers`, rename `/accounts/{address}` to `/auth/accounts/{address}`
|
||||||
|
* [gaia-lite] [\#2478](https://github.com/cosmos/cosmos-sdk/issues/2478) Add query gov proposal's deposits endpoint
|
||||||
|
|
||||||
* Gaia CLI (`gaiacli`)
|
* Gaia CLI (`gaiacli`)
|
||||||
* [cli] Cmds to query staking pool and params
|
* [cli] Cmds to query staking pool and params
|
||||||
|
|
|
@ -10,19 +10,19 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
p2p "github.com/tendermint/tendermint/p2p"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
cryptoKeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
cryptoKeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
p2p "github.com/tendermint/tendermint/p2p"
|
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
|
|
||||||
client "github.com/cosmos/cosmos-sdk/client"
|
client "github.com/cosmos/cosmos-sdk/client"
|
||||||
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
keys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
rpc "github.com/cosmos/cosmos-sdk/client/rpc"
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
tests "github.com/cosmos/cosmos-sdk/tests"
|
tests "github.com/cosmos/cosmos-sdk/tests"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
@ -613,7 +613,7 @@ func TestSubmitProposal(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
resultTx := doSubmitProposal(t, port, seed, name, password, addr)
|
resultTx := doSubmitProposal(t, port, seed, name, password, addr, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
|
@ -635,7 +635,7 @@ func TestDeposit(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
resultTx := doSubmitProposal(t, port, seed, name, password, addr)
|
resultTx := doSubmitProposal(t, port, seed, name, password, addr, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
|
@ -650,7 +650,7 @@ func TestDeposit(t *testing.T) {
|
||||||
require.Equal(t, "Test", proposal.GetTitle())
|
require.Equal(t, "Test", proposal.GetTitle())
|
||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
resultTx = doDeposit(t, port, seed, name, password, addr, proposalID)
|
resultTx = doDeposit(t, port, seed, name, password, addr, proposalID, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// query proposal
|
// query proposal
|
||||||
|
@ -669,7 +669,7 @@ func TestVote(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
resultTx := doSubmitProposal(t, port, seed, name, password, addr)
|
resultTx := doSubmitProposal(t, port, seed, name, password, addr, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
|
@ -684,7 +684,7 @@ func TestVote(t *testing.T) {
|
||||||
require.Equal(t, "Test", proposal.GetTitle())
|
require.Equal(t, "Test", proposal.GetTitle())
|
||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
resultTx = doDeposit(t, port, seed, name, password, addr, proposalID)
|
resultTx = doDeposit(t, port, seed, name, password, addr, proposalID, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// query proposal
|
// query proposal
|
||||||
|
@ -725,27 +725,52 @@ func TestProposalsQuery(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// Addr1 proposes (and deposits) proposals #1 and #2
|
// Addr1 proposes (and deposits) proposals #1 and #2
|
||||||
resultTx := doSubmitProposal(t, port, seed, name, password1, addr)
|
resultTx := doSubmitProposal(t, port, seed, name, password1, addr, 5)
|
||||||
var proposalID1 int64
|
var proposalID1 int64
|
||||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID1)
|
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID1)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
resultTx = doSubmitProposal(t, port, seed, name, password1, addr)
|
resultTx = doSubmitProposal(t, port, seed, name, password1, addr, 5)
|
||||||
var proposalID2 int64
|
var proposalID2 int64
|
||||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID2)
|
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID2)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Addr2 proposes (and deposits) proposals #3
|
// Addr2 proposes (and deposits) proposals #3
|
||||||
resultTx = doSubmitProposal(t, port, seed2, name2, password2, addr2)
|
resultTx = doSubmitProposal(t, port, seed2, name2, password2, addr2, 5)
|
||||||
var proposalID3 int64
|
var proposalID3 int64
|
||||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID3)
|
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID3)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Addr2 deposits on proposals #2 & #3
|
// Addr2 deposits on proposals #2 & #3
|
||||||
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID2)
|
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID2, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID3)
|
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID3, 5)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
|
// check deposits match proposal and individual deposits
|
||||||
|
deposits := getDeposits(t, port, proposalID1)
|
||||||
|
require.Len(t, deposits, 1)
|
||||||
|
deposit := getDeposit(t, port, proposalID1, addr)
|
||||||
|
require.Equal(t, deposit, deposits[0])
|
||||||
|
|
||||||
|
deposits = getDeposits(t, port, proposalID2)
|
||||||
|
require.Len(t, deposits, 2)
|
||||||
|
deposit = getDeposit(t, port, proposalID2, addr)
|
||||||
|
require.Equal(t, deposit, deposits[0])
|
||||||
|
deposit = getDeposit(t, port, proposalID2, addr2)
|
||||||
|
require.Equal(t, deposit, deposits[1])
|
||||||
|
|
||||||
|
deposits = getDeposits(t, port, proposalID3)
|
||||||
|
require.Len(t, deposits, 1)
|
||||||
|
deposit = getDeposit(t, port, proposalID3, addr2)
|
||||||
|
require.Equal(t, deposit, deposits[0])
|
||||||
|
|
||||||
|
// increasing the amount of the deposit should update the existing one
|
||||||
|
resultTx = doDeposit(t, port, seed, name, password1, addr, proposalID1, 1)
|
||||||
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
|
deposits = getDeposits(t, port, proposalID1)
|
||||||
|
require.Len(t, deposits, 1)
|
||||||
|
|
||||||
// Only proposals #1 should be in Deposit Period
|
// Only proposals #1 should be in Deposit Period
|
||||||
proposals := getProposalsFilterStatus(t, port, gov.StatusDepositPeriod)
|
proposals := getProposalsFilterStatus(t, port, gov.StatusDepositPeriod)
|
||||||
require.Len(t, proposals, 1)
|
require.Len(t, proposals, 1)
|
||||||
|
@ -1168,6 +1193,15 @@ func getProposal(t *testing.T, port string, proposalID int64) gov.Proposal {
|
||||||
return proposal
|
return proposal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDeposits(t *testing.T, port string, proposalID int64) []gov.Deposit {
|
||||||
|
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), nil)
|
||||||
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
var deposits []gov.Deposit
|
||||||
|
err := cdc.UnmarshalJSON([]byte(body), &deposits)
|
||||||
|
require.Nil(t, err)
|
||||||
|
return deposits
|
||||||
|
}
|
||||||
|
|
||||||
func getDeposit(t *testing.T, port string, proposalID int64, depositerAddr sdk.AccAddress) gov.Deposit {
|
func getDeposit(t *testing.T, port string, proposalID int64, depositerAddr sdk.AccAddress) gov.Deposit {
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositerAddr), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositerAddr), nil)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
@ -1245,7 +1279,7 @@ func getProposalsFilterStatus(t *testing.T, port string, status gov.ProposalStat
|
||||||
return proposals
|
return proposals
|
||||||
}
|
}
|
||||||
|
|
||||||
func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress) (resultTx ctypes.ResultBroadcastTxCommit) {
|
func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress, amount int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
|
@ -1259,7 +1293,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
|
||||||
"description": "test",
|
"description": "test",
|
||||||
"proposal_type": "Text",
|
"proposal_type": "Text",
|
||||||
"proposer": "%s",
|
"proposer": "%s",
|
||||||
"initial_deposit": [{ "denom": "steak", "amount": "5" }],
|
"initial_deposit": [{ "denom": "steak", "amount": "%d" }],
|
||||||
"base_req": {
|
"base_req": {
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"password": "%s",
|
"password": "%s",
|
||||||
|
@ -1267,7 +1301,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
|
||||||
"account_number":"%d",
|
"account_number":"%d",
|
||||||
"sequence":"%d"
|
"sequence":"%d"
|
||||||
}
|
}
|
||||||
}`, proposerAddr, name, password, chainID, accnum, sequence))
|
}`, proposerAddr, amount, name, password, chainID, accnum, sequence))
|
||||||
res, body := Request(t, port, "POST", "/gov/proposals", jsonStr)
|
res, body := Request(t, port, "POST", "/gov/proposals", jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
@ -1278,7 +1312,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress, proposalID int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk.AccAddress, proposalID int64, amount int64) (resultTx ctypes.ResultBroadcastTxCommit) {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
accnum := acc.GetAccountNumber()
|
accnum := acc.GetAccountNumber()
|
||||||
|
@ -1289,7 +1323,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
|
||||||
// deposit on proposal
|
// deposit on proposal
|
||||||
jsonStr := []byte(fmt.Sprintf(`{
|
jsonStr := []byte(fmt.Sprintf(`{
|
||||||
"depositer": "%s",
|
"depositer": "%s",
|
||||||
"amount": [{ "denom": "steak", "amount": "5" }],
|
"amount": [{ "denom": "steak", "amount": "%d" }],
|
||||||
"base_req": {
|
"base_req": {
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"password": "%s",
|
"password": "%s",
|
||||||
|
@ -1297,7 +1331,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk
|
||||||
"account_number":"%d",
|
"account_number":"%d",
|
||||||
"sequence": "%d"
|
"sequence": "%d"
|
||||||
}
|
}
|
||||||
}`, proposerAddr, name, password, chainID, accnum, sequence))
|
}`, proposerAddr, amount, name, password, chainID, accnum, sequence))
|
||||||
res, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), jsonStr)
|
res, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), jsonStr)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,12 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec)
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), depositHandlerFn(cdc, cliCtx)).Methods("POST")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), depositHandlerFn(cdc, cliCtx)).Methods("POST")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), voteHandlerFn(cdc, cliCtx)).Methods("POST")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), voteHandlerFn(cdc, cliCtx)).Methods("POST")
|
||||||
|
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}", RestProposalID), queryProposalHandlerFn(cdc)).Methods("GET")
|
r.HandleFunc("/gov/proposals", queryProposalsWithParameterFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits/{%s}", RestProposalID, RestDepositer), queryDepositHandlerFn(cdc)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}", RestProposalID), queryProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes/{%s}", RestProposalID, RestVoter), queryVoteHandlerFn(cdc)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), queryDepositsHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits/{%s}", RestProposalID, RestDepositer), queryDepositHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), queryVotesOnProposalHandlerFn(cdc)).Methods("GET")
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), queryVotesOnProposalHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
|
r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes/{%s}", RestProposalID, RestVoter), queryVoteHandlerFn(cdc, cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/gov/proposals", queryProposalsWithParameterFn(cdc)).Methods("GET")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type postProposalReq struct {
|
type postProposalReq struct {
|
||||||
|
@ -164,7 +163,7 @@ func voteHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
|
@ -180,8 +179,6 @@ func queryProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
params := gov.QueryProposalParams{
|
params := gov.QueryProposalParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
}
|
}
|
||||||
|
@ -198,11 +195,41 @@ func queryProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryDepositHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryDepositsHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
strProposalID := vars[RestProposalID]
|
||||||
|
|
||||||
|
proposalID, ok := utils.ParseInt64OrReturnBadRequest(w, strProposalID)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
params := gov.QueryDepositsParams{
|
||||||
|
ProposalID: proposalID,
|
||||||
|
}
|
||||||
|
|
||||||
|
bz, err := cdc.MarshalJSON(params)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := cliCtx.QueryWithData("custom/gov/deposits", bz)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func queryDepositHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
|
@ -232,8 +259,6 @@ func queryDepositHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
params := gov.QueryDepositParams{
|
params := gov.QueryDepositParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
Depositer: depositerAddr,
|
Depositer: depositerAddr,
|
||||||
|
@ -265,11 +290,11 @@ func queryDepositHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryVoteHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryVoteHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
|
@ -299,8 +324,6 @@ func queryVoteHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
params := gov.QueryVoteParams{
|
params := gov.QueryVoteParams{
|
||||||
Voter: voterAddr,
|
Voter: voterAddr,
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
|
@ -335,12 +358,12 @@ func queryVoteHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
utils.WriteErrorResponse(w, http.StatusNotFound, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: Split this functionality into helper functions to remove the above
|
// todo: Split this functionality into helper functions to remove the above
|
||||||
func queryVotesOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryVotesOnProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
|
@ -356,8 +379,6 @@ func queryVotesOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
params := gov.QueryVotesParams{
|
params := gov.QueryVotesParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
}
|
}
|
||||||
|
@ -373,12 +394,12 @@ func queryVotesOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: Split this functionality into helper functions to remove the above
|
// todo: Split this functionality into helper functions to remove the above
|
||||||
func queryProposalsWithParameterFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryProposalsWithParameterFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
bechVoterAddr := r.URL.Query().Get(RestVoter)
|
bechVoterAddr := r.URL.Query().Get(RestVoter)
|
||||||
bechDepositerAddr := r.URL.Query().Get(RestDepositer)
|
bechDepositerAddr := r.URL.Query().Get(RestDepositer)
|
||||||
|
@ -430,20 +451,18 @@ func queryProposalsWithParameterFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
res, err := cliCtx.QueryWithData("custom/gov/proposals", bz)
|
res, err := cliCtx.QueryWithData("custom/gov/proposals", bz)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: Split this functionality into helper functions to remove the above
|
// todo: Split this functionality into helper functions to remove the above
|
||||||
func queryTallyOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
func queryTallyOnProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
strProposalID := vars[RestProposalID]
|
strProposalID := vars[RestProposalID]
|
||||||
|
@ -461,8 +480,6 @@ func queryTallyOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
|
||||||
|
|
||||||
params := gov.QueryTallyParams{
|
params := gov.QueryTallyParams{
|
||||||
ProposalID: proposalID,
|
ProposalID: proposalID,
|
||||||
}
|
}
|
||||||
|
@ -480,6 +497,6 @@ func queryTallyOnProposalHandlerFn(cdc *codec.Codec) http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Write(res)
|
utils.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ type QueryDepositsParams struct {
|
||||||
|
|
||||||
// nolint: unparam
|
// nolint: unparam
|
||||||
func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
|
func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper Keeper) (res []byte, err sdk.Error) {
|
||||||
var params QueryDepositParams
|
var params QueryDepositsParams
|
||||||
err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms)
|
err2 := keeper.cdc.UnmarshalJSON(req.Data, ¶ms)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return []byte{}, sdk.ErrUnknownRequest(fmt.Sprintf("incorrectly formatted request data - %s", err2.Error()))
|
return []byte{}, sdk.ErrUnknownRequest(fmt.Sprintf("incorrectly formatted request data - %s", err2.Error()))
|
||||||
|
|
Loading…
Reference in New Issue