Skip to content

Commit

Permalink
Move QueryTx functions to x/auth/tx
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Mar 1, 2021
1 parent e905f61 commit 2495dbd
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 174 deletions.
3 changes: 1 addition & 2 deletions server/rosetta/client_online.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -254,7 +253,7 @@ func (c *Client) TxOperationsAndSignersAccountIdentifiers(signed bool, txBytes [

// GetTx returns a transaction given its hash
func (c *Client) GetTx(_ context.Context, hash string) (*types.Transaction, error) {
txResp, err := authclient.QueryTx(c.clientCtx, hash)
txResp, err := authtx.QueryTx(c.clientCtx, hash)
if err != nil {
return nil, crgerrs.WrapError(crgerrs.ErrUnknown, err.Error())
}
Expand Down
6 changes: 3 additions & 3 deletions x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)

Expand Down Expand Up @@ -189,7 +189,7 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
page, _ := cmd.Flags().GetInt(flags.FlagPage)
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)

txs, err := authclient.QueryTxsByEvents(clientCtx, tmEvents, page, limit, "")
txs, err := authtx.QueryTxsByEvents(clientCtx, tmEvents, page, limit, "")
if err != nil {
return err
}
Expand Down Expand Up @@ -219,7 +219,7 @@ func QueryTxCmd() *cobra.Command {
if err != nil {
return err
}
output, err := authclient.QueryTx(clientCtx, args[0])
output, err := authtx.QueryTx(clientCtx, args[0])
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions x/auth/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/auth/types"
genutilrest "github.com/cosmos/cosmos-sdk/x/genutil/client/rest"
)
Expand Down Expand Up @@ -99,7 +99,7 @@ func QueryTxsRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
return
}

searchResult, err := authclient.QueryTxsByEvents(clientCtx, events, page, limit, "")
searchResult, err := authtx.QueryTxsByEvents(clientCtx, events, page, limit, "")
if rest.CheckInternalServerError(w, err) {
return
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func QueryTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
return
}

output, err := authclient.QueryTx(clientCtx, hashHexStr)
output, err := authtx.QueryTx(clientCtx, hashHexStr)
if err != nil {
if strings.Contains(err.Error(), hashHexStr) {
rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/query.go → x/auth/tx/query.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client
package tx

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions x/auth/tx/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s txServer) GetTxsEvent(ctx context.Context, req *txtypes.GetTxsEventReque
}
}

result, err := queryTxsByEvents(s.clientCtx, req.Events, page, limit, "")
result, err := QueryTxsByEvents(s.clientCtx, req.Events, page, limit, "")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -123,7 +123,7 @@ func (s txServer) GetTx(ctx context.Context, req *txtypes.GetTxRequest) (*txtype

// TODO We should also check the proof flag in gRPC header.
// https://github.com/cosmos/cosmos-sdk/issues/7036.
result, err := queryTx(s.clientCtx, req.Hash)
result, err := QueryTx(s.clientCtx, req.Hash)
if err != nil {
return nil, err
}
Expand Down
159 changes: 0 additions & 159 deletions x/auth/tx/xauthclient.go

This file was deleted.

4 changes: 2 additions & 2 deletions x/gov/client/utils/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/gov/types"
)

Expand Down Expand Up @@ -374,7 +374,7 @@ func combineEvents(clientCtx client.Context, page int, eventGroups ...[]string)
// Only the Txs field will be populated in the final SearchTxsResult.
allTxs := []*sdk.TxResponse{}
for _, events := range eventGroups {
res, err := authclient.QueryTxsByEvents(clientCtx, events, page, defaultLimit, "")
res, err := authtx.QueryTxsByEvents(clientCtx, events, page, defaultLimit, "")
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions x/staking/client/rest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -33,7 +33,7 @@ func queryTxs(clientCtx client.Context, action string, delegatorAddr string) (*s
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, delegatorAddr),
}

return authclient.QueryTxsByEvents(clientCtx, events, page, limit, "")
return authtx.QueryTxsByEvents(clientCtx, events, page, limit, "")
}

func queryBonds(clientCtx client.Context, endpoint string) http.HandlerFunc {
Expand Down

0 comments on commit 2495dbd

Please sign in to comment.