Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aleem1314 authored and mergify-bot committed Jun 17, 2021
1 parent 59c017c commit 38d4385
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 131 deletions.
14 changes: 4 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,24 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features


* [\#9383](https://github.com/cosmos/cosmos-sdk/pull/9383) New CLI command `query ibc-transfer escrow-address <port> <channel id>` to get the escrow address for a channel; can be used to then query balance of escrowed tokens

### Bug Fixes

* (x/gov) [\#8813](https://github.com/cosmos/cosmos-sdk/pull/8813) fix `GET /cosmos/gov/v1beta1/proposals/{proposal_id}/deposits` to include initial deposit


## [v0.42.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.5) - 2021-05-18

### Bug Fixes

<<<<<<< HEAD
* [\#9235](https://github.com/cosmos/cosmos-sdk/pull/9235) CreateMembershipProof/CreateNonMembershipProof now returns an error
if input key is empty, or input data contains empty key.
* [\#9108](https://github.com/cosmos/cosmos-sdk/pull/9108) Fixed the bug with querying multisig account, which is not showing threshold and public_keys.
* [\#9345](https://github.com/cosmos/cosmos-sdk/pull/9345) Fix ARM support.
* [\#9040](https://github.com/cosmos/cosmos-sdk/pull/9040) Fix ENV variables binding to CLI flags for client config.

### Features
=======
* (x/gov) [\#8813](https://github.com/cosmos/cosmos-sdk/pull/8813) fix `GET /cosmos/gov/v1beta1/proposals/{proposal_id}/deposits` to include initial deposit
* (gRPC) [\#8945](https://github.com/cosmos/cosmos-sdk/pull/8945) gRPC reflection now works correctly.
* (keyring) [#\8635](https://github.com/cosmos/cosmos-sdk/issues/8635) Remove hardcoded default passphrase value on `NewMnemonic`
* (x/bank) [\#8434](https://github.com/cosmos/cosmos-sdk/pull/8434) Fix legacy REST API `GET /bank/total` and `GET /bank/total/{denom}` in swagger
* (x/slashing) [\#8427](https://github.com/cosmos/cosmos-sdk/pull/8427) Fix query signing infos command
* (x/bank) [\#9229](https://github.com/cosmos/cosmos-sdk/pull/9229) Now zero coin balances cannot be added to balances & supply stores. If any denom becomes zero corresponding key gets deleted from store.
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))

* [\#8953](https://github.com/cosmos/cosmos-sdk/pull/8953) Add the `config` CLI subcommand back to the SDK, which saves client-side configuration in a `client.toml` file.

Expand Down
22 changes: 0 additions & 22 deletions x/gov/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,9 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}

// check to see if the proposal is in the store
<<<<<<< HEAD
_, err = queryClient.Proposal(
context.Background(),
=======
ctx := cmd.Context()
proposalRes, err := queryClient.Proposal(
ctx,
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
Expand All @@ -383,31 +378,15 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
return err
}

<<<<<<< HEAD
res, err := queryClient.Deposit(
context.Background(),
&types.QueryDepositRequest{ProposalId: proposalID, Depositor: args[1]},
)
if err != nil {
return err
}

deposit := res.GetDeposit()
if deposit.Empty() {
=======
var deposit types.Deposit
propStatus := proposalRes.Proposal.Status
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
params := types.NewQueryDepositParams(proposalID, depositorAddr)
resByTxQuery, err := gcutils.QueryDepositByTxQuery(clientCtx, params)
if err != nil {
return err
}
<<<<<<< HEAD
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &deposit)
=======
clientCtx.JSONCodec.MustUnmarshalJSON(resByTxQuery, &deposit)
return clientCtx.PrintProto(&deposit)
}

Expand All @@ -417,7 +396,6 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
)
if err != nil {
return err
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
}

return clientCtx.PrintProto(&res.Deposit)
Expand Down
2 changes: 0 additions & 2 deletions x/gov/client/testutil/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
func TestIntegrationTestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg.NumValidators = 1
suite.Run(t, NewIntegrationTestSuite(cfg))

genesisState := types.DefaultGenesisState()
genesisState.DepositParams = types.NewDepositParams(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, types.DefaultMinDepositTokens)), time.Duration(15)*time.Second)
genesisState.VotingParams = types.NewVotingParams(time.Duration(5) * time.Second)
Expand Down
123 changes: 26 additions & 97 deletions x/gov/client/utils/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import (

"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
<<<<<<< HEAD
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
=======
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/gov/types"
)

Expand Down Expand Up @@ -42,16 +38,6 @@ func (p Proposer) String() string {
// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposalParams) ([]byte, error) {
<<<<<<< HEAD
events := []string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
}

// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, defaultPage, defaultLimit, "")
=======
var deposits []types.Deposit

// initial deposit was submitted with proposal, so must be queried separately
Expand All @@ -64,20 +50,14 @@ func QueryDepositsByTxQuery(clientCtx client.Context, params types.QueryProposal
deposits = append(deposits, initialDeposit)
}

searchResult, err := combineEvents(
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeposit{})),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
},
)
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
events := []string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
}

// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, defaultPage, defaultLimit, "")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -198,49 +178,30 @@ func QueryVoteByTxQuery(clientCtx client.Context, params types.QueryVoteParams)
// QueryDepositByTxQuery will query for a single deposit via a direct txs tags
// query.
func QueryDepositByTxQuery(clientCtx client.Context, params types.QueryDepositParams) ([]byte, error) {
<<<<<<< HEAD
events := []string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, []byte(params.Depositor.String())),
}

// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, defaultPage, defaultLimit, "")
=======

// initial deposit was submitted with proposal, so must be queried separately
initialDeposit, err := queryInitialDepositByTxQuery(clientCtx, params.ProposalID)
if err != nil {
return nil, err
}

if !initialDeposit.Amount.IsZero() {
bz, err := clientCtx.JSONCodec.MarshalJSON(&initialDeposit)
bz, err := clientCtx.JSONMarshaler.MarshalJSON(&initialDeposit)
if err != nil {
return nil, err
}

return bz, nil
}

searchResult, err := combineEvents(
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, []byte(params.Depositor.String())),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeposit{})),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, []byte(params.Depositor.String())),
},
)
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))
events := []string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgDeposit),
fmt.Sprintf("%s.%s='%s'", types.EventTypeProposalDeposit, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", params.ProposalID))),
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, []byte(params.Depositor.String())),
}

// NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination.
searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, defaultPage, defaultLimit, "")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -313,47 +274,16 @@ func QueryProposalByID(proposalID uint64, clientCtx client.Context, queryRoute s

return res, err
}
<<<<<<< HEAD
=======

// combineEvents queries txs by events with all events from each event group,
// and combines all those events together.
//
// Tx are indexed in tendermint via their Msgs `Type()`, which can be:
// - via legacy Msgs (amino or proto), their `Type()` is a custom string,
// - via ADR-031 proto msgs, their `Type()` is the protobuf FQ method name.
// In searching for events, we search for both `Type()`s, and we use the
// `combineEvents` function here to merge events.
func combineEvents(clientCtx client.Context, page int, eventGroups ...[]string) (*sdk.SearchTxsResult, error) {
// Only the Txs field will be populated in the final SearchTxsResult.
allTxs := []*sdk.TxResponse{}
for _, events := range eventGroups {
res, err := authtx.QueryTxsByEvents(clientCtx, events, page, defaultLimit, "")
if err != nil {
return nil, err
}
allTxs = append(allTxs, res.Txs...)
}

return &sdk.SearchTxsResult{Txs: allTxs}, nil
}

// queryInitialDepositByTxQuery will query for a initial deposit of a governance proposal by
// ID.
func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) (types.Deposit, error) {
searchResult, err := combineEvents(
clientCtx, defaultPage,
// Query legacy Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%s'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", proposalID))),
},
// Query proto Msgs event action
[]string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgSubmitProposal{})),
fmt.Sprintf("%s.%s='%s'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", proposalID))),
},
)
// Query legacy Msgs event action
events := []string{
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeyAction, types.TypeMsgSubmitProposal),
fmt.Sprintf("%s.%s='%s'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, []byte(fmt.Sprintf("%d", proposalID))),
}
searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, defaultPage, defaultLimit, "")

if err != nil {
return types.Deposit{}, err
Expand All @@ -372,6 +302,5 @@ func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) (
}
}

return types.Deposit{}, sdkerrors.ErrNotFound.Wrapf("failed to find the initial deposit for proposalID %d", proposalID)
return types.Deposit{}, sdkerrors.Wrapf(sdkerrors.ErrKeyNotFound, "failed to find the initial deposit for proposalID %d", proposalID)
}
>>>>>>> 66ee994ce (fix: x/gov deposits querier (Initial Deposit) (#9288))

0 comments on commit 38d4385

Please sign in to comment.