feat: Integrate tendermint Block endpoints into the cli (#14659)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
parent
cb23af6d97
commit
86eca4c72b
@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Features
|
||||
|
||||
* (cli) [#14659](https://github.com/cosmos/cosmos-sdk/pull/14659) Added ability to query blocks by events with queries directly passed to Tendermint, which will allow for full query operator support, e.g. `>`.
|
||||
* [#14897](https://github.com/cosmos/cosmos-sdk/pull/14897) Migrate the Cosmos SDK to CometBFT.
|
||||
* (x/gov) [#14720](https://github.com/cosmos/cosmos-sdk/pull/14720) Upstream expedited proposals from Osmosis.
|
||||
* (x/auth) [#14650](https://github.com/cosmos/cosmos-sdk/pull/14650) Add Textual SignModeHandler. It is however **NOT** enabled by default, and should only be used for **TESTING** purposes until `SIGN_MODE_TEXTUAL` is fully released.
|
||||
@ -78,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
* (cli) [#14659](https://github.com/cosmos/cosmos-sdk/pull/14659) Added ability to query blocks by either height/hash `simd q block --type=height|hash <height|hash>`.
|
||||
* (store) [#14410](https://github.com/cosmos/cosmos-sdk/pull/14410) `rootmulti.Store.loadVersion` has validation to check if all the module stores' height is correct, it will error if any module store has incorrect height.
|
||||
* (x/evidence) [#14757](https://github.com/cosmos/cosmos-sdk/pull/14757) Evidence messages do not need to implement a `.Type()` anymore.
|
||||
* (x/auth/tx) [#14751](https://github.com/cosmos/cosmos-sdk/pull/14751) Remove `.Type()` and `Route()` methods from all msgs and `legacytx.LegacyMsg` interface.
|
||||
@ -258,6 +260,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
|
||||
|
||||
### CLI Breaking Changes
|
||||
|
||||
* (cli) [#14659](https://github.com/cosmos/cosmos-sdk/pull/14659) `simd q block <height>` is removed as it just output json. The new command allows either height/hash and is `simd q block --type=height|hash <height|hash>`.
|
||||
* (x/gov) [#14880](https://github.com/cosmos/cosmos-sdk/pull/14880) Remove `simd tx gov submit-legacy-proposal cancel-software-upgrade` and `software-upgrade` commands. These commands are now in the `x/upgrade` module and using gov v1. Use `tx upgrade software-upgrade` instead.
|
||||
* (grpc-web) [#14652](https://github.com/cosmos/cosmos-sdk/pull/14652) Remove `grpc-web.address` flag.
|
||||
* (client) [#14342](https://github.com/cosmos/cosmos-sdk/pull/14342) `simd config` command is now a sub-command. Use `simd config --help` to learn more.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7125,7 +7125,8 @@ type MsgCreateValidator struct {
|
||||
Commission *CommissionRates `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission,omitempty"`
|
||||
MinSelfDelegation string `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"`
|
||||
// Deprecated: Use of Delegator Address in MsgCreateValidator is deprecated.
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer only in bech32 notation).
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer
|
||||
// only in bech32 notation).
|
||||
//
|
||||
// Deprecated: Do not use.
|
||||
DelegatorAddress string `protobuf:"bytes,4,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"`
|
||||
|
||||
@ -15,6 +15,7 @@ type CometRPC interface {
|
||||
Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error)
|
||||
Status(context.Context) (*coretypes.ResultStatus, error)
|
||||
Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error)
|
||||
BlockByHash(ctx context.Context, hash []byte) (*coretypes.ResultBlock, error)
|
||||
BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error)
|
||||
Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error)
|
||||
Tx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error)
|
||||
@ -25,4 +26,10 @@ type CometRPC interface {
|
||||
page, perPage *int,
|
||||
orderBy string,
|
||||
) (*coretypes.ResultTxSearch, error)
|
||||
BlockSearch(
|
||||
ctx context.Context,
|
||||
query string,
|
||||
page, perPage *int,
|
||||
orderBy string,
|
||||
) (*coretypes.ResultBlockSearch, error)
|
||||
}
|
||||
|
||||
@ -2,75 +2,18 @@ package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
|
||||
cmt "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
coretypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// BlockCommand returns the verified block data for a given heights
|
||||
func BlockCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "block [height]",
|
||||
Short: "Get verified data for the block at given height",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var height *int64
|
||||
|
||||
// optional height
|
||||
if len(args) > 0 {
|
||||
h, err := strconv.Atoi(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if h > 0 {
|
||||
tmp := int64(h)
|
||||
height = &tmp
|
||||
}
|
||||
}
|
||||
|
||||
output, err := getBlock(clientCtx, height)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(string(output))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringP(flags.FlagNode, "n", "tcp://localhost:26657", "Node to connect to")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func getBlock(clientCtx client.Context, height *int64) ([]byte, error) {
|
||||
// get the node
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// header -> BlockchainInfo
|
||||
// header, tx -> Block
|
||||
// results -> BlockResults
|
||||
res, err := node.Block(context.Background(), height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return legacy.Cdc.MarshalJSON(res)
|
||||
}
|
||||
|
||||
// get the current blockchain height
|
||||
// GetChainHeight returns the current blockchain height.
|
||||
func GetChainHeight(clientCtx client.Context) (int64, error) {
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
@ -85,3 +28,107 @@ func GetChainHeight(clientCtx client.Context) (int64, error) {
|
||||
height := status.SyncInfo.LatestBlockHeight
|
||||
return height, nil
|
||||
}
|
||||
|
||||
// QueryBlocks performs a search for blocks based on BeginBlock and EndBlock
|
||||
// events via the CometBFT RPC. A custom query may be passed as described below:
|
||||
//
|
||||
// To tell which events you want, you need to provide a query. query is a
|
||||
// string, which has a form: "condition AND condition ..." (no OR at the
|
||||
// moment). condition has a form: "key operation operand". key is a string with
|
||||
// a restricted set of possible symbols ( \t\n\r\\()"'=>< are not allowed).
|
||||
// operation can be "=", "<", "<=", ">", ">=", "CONTAINS" AND "EXISTS". operand
|
||||
// can be a string (escaped with single quotes), number, date or time.
|
||||
|
||||
// Examples:
|
||||
// tm.event = 'NewBlock' # new blocks
|
||||
// tm.event = 'CompleteProposal' # node got a complete proposal
|
||||
// tm.event = 'Tx' AND tx.hash = 'XYZ' # single transaction
|
||||
// tm.event = 'Tx' AND tx.height = 5 # all txs of the fifth block
|
||||
// tx.height = 5 # all txs of the fifth block
|
||||
//
|
||||
// For more information, see the /subscribe CometBFT RPC endpoint documentation
|
||||
func QueryBlocks(clientCtx client.Context, page, limit int, query string, orderBy string) (*sdk.SearchBlocksResult, error) {
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resBlocks, err := node.BlockSearch(context.Background(), query, &page, &limit, orderBy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blocks, err := formatBlockResults(resBlocks.Blocks)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := sdk.NewSearchBlocksResult(int64(resBlocks.TotalCount), int64(len(blocks)), int64(page), int64(limit), blocks)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// get block by height
|
||||
func GetBlockByHeight(clientCtx client.Context, height *int64) (*cmt.Block, error) {
|
||||
// get the node
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// header -> BlockchainInfo
|
||||
// header, tx -> Block
|
||||
// results -> BlockResults
|
||||
resBlock, err := node.Block(context.Background(), height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := sdk.NewResponseResultBlock(resBlock, resBlock.Block.Time.Format(time.RFC3339))
|
||||
if out == nil {
|
||||
return nil, fmt.Errorf("unable to create response block from comet result block: %v", resBlock)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func GetBlockByHash(clientCtx client.Context, hashHexString string) (*cmt.Block, error) {
|
||||
hash, err := hex.DecodeString(hashHexString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// get the node
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resBlock, err := node.BlockByHash(context.Background(), hash)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if resBlock.Block == nil {
|
||||
return nil, fmt.Errorf("block not found with hash: %s", hashHexString)
|
||||
}
|
||||
|
||||
out := sdk.NewResponseResultBlock(resBlock, resBlock.Block.Time.Format(time.RFC3339))
|
||||
if out == nil {
|
||||
return nil, fmt.Errorf("unable to create response block from comet result block: %v", resBlock)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// formatBlockResults parses the indexed blocks into a slice of BlockResponse objects.
|
||||
func formatBlockResults(resBlocks []*coretypes.ResultBlock) ([]*cmt.Block, error) {
|
||||
out := make([]*cmt.Block, len(resBlocks))
|
||||
for i := range resBlocks {
|
||||
out[i] = sdk.NewResponseResultBlock(resBlocks[i], resBlocks[i].Block.Time.Format(time.RFC3339))
|
||||
if out[i] == nil {
|
||||
return nil, fmt.Errorf("unable to create response block from comet result block: %v", resBlocks[i])
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@ -219,7 +219,6 @@ message QuerySpendableBalanceByDenomResponse {
|
||||
cosmos.base.v1beta1.Coin balance = 1;
|
||||
}
|
||||
|
||||
|
||||
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
|
||||
// method.
|
||||
message QueryTotalSupplyRequest {
|
||||
|
||||
@ -3,6 +3,7 @@ package cosmos.base.abci.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "tendermint/abci/types.proto";
|
||||
import "tendermint/types/block.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/types";
|
||||
@ -156,3 +157,21 @@ message SearchTxsResult {
|
||||
// List of txs in current page
|
||||
repeated TxResponse txs = 6;
|
||||
}
|
||||
|
||||
// SearchBlocksResult defines a structure for querying blocks pageable
|
||||
message SearchBlocksResult {
|
||||
option (gogoproto.stringer) = true;
|
||||
|
||||
// Count of all blocks
|
||||
int64 total_count = 1;
|
||||
// Count of blocks in current page
|
||||
int64 count = 2;
|
||||
// Index of current page, start from 1
|
||||
int64 page_number = 3;
|
||||
// Count of total pages
|
||||
int64 page_total = 4;
|
||||
// Max count blocks per page
|
||||
int64 limit = 5;
|
||||
// List of blocks in current page
|
||||
repeated tendermint.types.Block blocks = 6;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
syntax = "proto3";
|
||||
package cosmos.distribution.v1beta1;
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
@ -17,23 +17,19 @@ service Msg {
|
||||
|
||||
// SetWithdrawAddress defines a method to change the withdraw address
|
||||
// for a delegator (or validator self-delegation).
|
||||
rpc SetWithdrawAddress(MsgSetWithdrawAddress)
|
||||
returns (MsgSetWithdrawAddressResponse);
|
||||
rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse);
|
||||
|
||||
// WithdrawDelegatorReward defines a method to withdraw rewards of delegator
|
||||
// from a single validator.
|
||||
rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward)
|
||||
returns (MsgWithdrawDelegatorRewardResponse);
|
||||
rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse);
|
||||
|
||||
// WithdrawValidatorCommission defines a method to withdraw the
|
||||
// full commission to the validator address.
|
||||
rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission)
|
||||
returns (MsgWithdrawValidatorCommissionResponse);
|
||||
rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse);
|
||||
|
||||
// FundCommunityPool defines a method to allow an account to directly
|
||||
// fund the community pool.
|
||||
rpc FundCommunityPool(MsgFundCommunityPool)
|
||||
returns (MsgFundCommunityPoolResponse);
|
||||
rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse);
|
||||
|
||||
// UpdateParams defines a governance operation for updating the x/distribution
|
||||
// module parameters. The authority is defined in the keeper.
|
||||
@ -47,15 +43,13 @@ service Msg {
|
||||
// keeper.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
rpc CommunityPoolSpend(MsgCommunityPoolSpend)
|
||||
returns (MsgCommunityPoolSpendResponse);
|
||||
rpc CommunityPoolSpend(MsgCommunityPoolSpend) returns (MsgCommunityPoolSpendResponse);
|
||||
|
||||
// DepositValidatorRewardsPool defines a method to provide additional rewards
|
||||
// to delegators to a specific validator.
|
||||
//
|
||||
// Since: cosmos-sdk 0.48
|
||||
rpc DepositValidatorRewardsPool(MsgDepositValidatorRewardsPool)
|
||||
returns (MsgDepositValidatorRewardsPoolResponse);
|
||||
rpc DepositValidatorRewardsPool(MsgDepositValidatorRewardsPool) returns (MsgDepositValidatorRewardsPoolResponse);
|
||||
}
|
||||
|
||||
// MsgSetWithdrawAddress sets the withdraw address for
|
||||
@ -155,8 +149,7 @@ message MsgUpdateParams {
|
||||
// params defines the x/distribution parameters to update.
|
||||
//
|
||||
// NOTE: All parameters must be supplied.
|
||||
Params params = 2
|
||||
[(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
@ -175,8 +168,8 @@ message MsgCommunityPoolSpend {
|
||||
option (amino.name) = "cosmos-sdk/distr/MsgCommunityPoolSpend";
|
||||
|
||||
// authority is the address that controls the module (defaults to x/gov unless overwritten).
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string recipient = 2;
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string recipient = 2;
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(amino.dont_omitempty) = true,
|
||||
@ -200,12 +193,10 @@ message MsgDepositValidatorRewardsPool {
|
||||
option (gogoproto.equal) = false;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
|
||||
];
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
repeated cosmos.base.v1beta1.Coin amount = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// MsgDepositValidatorRewardsPoolResponse defines the response to executing a
|
||||
|
||||
@ -224,7 +224,7 @@ message Params {
|
||||
//
|
||||
// Since: cosmos-sdk 0.48
|
||||
string proposal_cancel_ratio = 8 [(cosmos_proto.scalar) = "cosmos.Dec"];
|
||||
|
||||
|
||||
// The address which will receive (proposal_cancel_ratio * deposit) proposal deposits.
|
||||
// If empty, the (proposal_cancel_ratio * deposit) proposal deposits will be burned.
|
||||
//
|
||||
|
||||
@ -63,7 +63,8 @@ message MsgCreateValidator {
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// Deprecated: Use of Delegator Address in MsgCreateValidator is deprecated.
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer only in bech32 notation).
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer
|
||||
// only in bech32 notation).
|
||||
string delegator_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString", deprecated = true];
|
||||
string validator_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"];
|
||||
|
||||
@ -54,13 +54,13 @@ message SoftwareUpgradeProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
// title of the proposal
|
||||
string title = 1;
|
||||
string title = 1;
|
||||
|
||||
// description of the proposal
|
||||
string description = 2;
|
||||
|
||||
// plan of the proposal
|
||||
Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
|
||||
}
|
||||
|
||||
// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software
|
||||
@ -74,7 +74,7 @@ message CancelSoftwareUpgradeProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
// title of the proposal
|
||||
string title = 1;
|
||||
string title = 1;
|
||||
|
||||
// description of the proposal
|
||||
string description = 2;
|
||||
|
||||
@ -2,6 +2,8 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cometbft/cometbft/p2p"
|
||||
pvm "github.com/cometbft/cometbft/privval"
|
||||
@ -10,8 +12,13 @@ import (
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
rpc "github.com/cosmos/cosmos-sdk/client/rpc"
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
)
|
||||
|
||||
// ShowNodeIDCmd - ported from CometBFT, dump node ID to stdout
|
||||
@ -115,3 +122,130 @@ func VersionCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// QueryBlocksCmd returns a command to search through blocks by events.
|
||||
func QueryBlocksCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "blocks",
|
||||
Short: "Query for paginated blocks that match a set of events",
|
||||
Long: `Search for blocks that match the exact given events where results are paginated.
|
||||
The events query is directly passed to CometBFT's RPC BlockSearch method and must
|
||||
conform to CometBFT's query syntax.
|
||||
Please refer to each module's documentation for the full set of events to query
|
||||
for. Each module documents its respective events under 'xx_events.md'.
|
||||
`,
|
||||
Example: fmt.Sprintf(
|
||||
"$ %s query blocks --query \"message.sender='cosmos1...' AND block.height > 7\" --page 1 --limit 30 --order-by ASC",
|
||||
version.AppName,
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
query, _ := cmd.Flags().GetString(auth.FlagQuery)
|
||||
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
orderBy, _ := cmd.Flags().GetString(auth.FlagOrderBy)
|
||||
|
||||
blocks, err := rpc.QueryBlocks(clientCtx, page, limit, query, orderBy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(blocks)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
cmd.Flags().Int(flags.FlagPage, query.DefaultPage, "Query a specific page of paginated results")
|
||||
cmd.Flags().Int(flags.FlagLimit, query.DefaultLimit, "Query number of transactions results per page returned")
|
||||
cmd.Flags().String(auth.FlagQuery, "", "The blocks events query per CometBFT's query semantics")
|
||||
cmd.Flags().String(auth.FlagOrderBy, "", "The ordering semantics (asc|dsc)")
|
||||
_ = cmd.MarkFlagRequired(auth.FlagQuery)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// QueryBlockCmd implements the default command for a Block query.
|
||||
func QueryBlockCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "block --type=[height|hash] [height|hash]",
|
||||
Short: "Query for a committed block by height, hash, or event(s)",
|
||||
Long: "Query for a specific committed block using the CometBFT RPC `block` and `block_by_hash` method",
|
||||
Example: strings.TrimSpace(fmt.Sprintf(`
|
||||
$ %s query block --%s=%s <height>
|
||||
$ %s query block --%s=%s <hash>
|
||||
`,
|
||||
version.AppName, auth.FlagType, auth.TypeHeight,
|
||||
version.AppName, auth.FlagType, auth.TypeHash)),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
typ, _ := cmd.Flags().GetString(auth.FlagType)
|
||||
|
||||
switch typ {
|
||||
case auth.TypeHeight:
|
||||
|
||||
if args[0] == "" {
|
||||
return fmt.Errorf("argument should be a block height")
|
||||
}
|
||||
|
||||
var height *int64
|
||||
|
||||
// optional height
|
||||
if len(args) > 0 {
|
||||
h, err := strconv.Atoi(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if h > 0 {
|
||||
tmp := int64(h)
|
||||
height = &tmp
|
||||
}
|
||||
}
|
||||
|
||||
output, err := rpc.GetBlockByHeight(clientCtx, height)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if output.Header.Height == 0 {
|
||||
return fmt.Errorf("no block found with height %s", args[0])
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(output)
|
||||
|
||||
case auth.TypeHash:
|
||||
|
||||
if args[0] == "" {
|
||||
return fmt.Errorf("argument should be a tx hash")
|
||||
}
|
||||
|
||||
// If hash is given, then query the tx by hash.
|
||||
output, err := rpc.GetBlockByHash(clientCtx, args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if output.Header.AppHash == nil {
|
||||
return fmt.Errorf("no block found with hash %s", args[0])
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(output)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unknown --%s value %s", auth.FlagType, typ)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
cmd.Flags().String(auth.FlagType, auth.TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\"", auth.TypeHeight, auth.TypeHash))
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -235,8 +235,9 @@ func queryCommand() *cobra.Command {
|
||||
cmd.AddCommand(
|
||||
authcmd.GetAccountCmd(),
|
||||
rpc.ValidatorCommand(),
|
||||
rpc.BlockCommand(),
|
||||
server.QueryBlockCmd(),
|
||||
authcmd.QueryTxsByEventsCmd(),
|
||||
server.QueryBlocksCmd(),
|
||||
authcmd.QueryTxCmd(),
|
||||
)
|
||||
|
||||
|
||||
503
types/abci.pb.go
503
types/abci.pb.go
@ -6,6 +6,7 @@ package types
|
||||
import (
|
||||
fmt "fmt"
|
||||
types1 "github.com/cometbft/cometbft/abci/types"
|
||||
types2 "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
types "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
@ -619,6 +620,96 @@ func (m *SearchTxsResult) GetTxs() []*TxResponse {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SearchBlocksResult defines a structure for querying blocks pageable
|
||||
type SearchBlocksResult struct {
|
||||
// Count of all blocks
|
||||
TotalCount int64 `protobuf:"varint,1,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
|
||||
// Count of blocks in current page
|
||||
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
|
||||
// Index of current page, start from 1
|
||||
PageNumber int64 `protobuf:"varint,3,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"`
|
||||
// Count of total pages
|
||||
PageTotal int64 `protobuf:"varint,4,opt,name=page_total,json=pageTotal,proto3" json:"page_total,omitempty"`
|
||||
// Max count blocks per page
|
||||
Limit int64 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
// List of blocks in current page
|
||||
Blocks []*types2.Block `protobuf:"bytes,6,rep,name=blocks,proto3" json:"blocks,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) Reset() { *m = SearchBlocksResult{} }
|
||||
func (*SearchBlocksResult) ProtoMessage() {}
|
||||
func (*SearchBlocksResult) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_4e37629bc7eb0df8, []int{10}
|
||||
}
|
||||
func (m *SearchBlocksResult) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SearchBlocksResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SearchBlocksResult.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SearchBlocksResult) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SearchBlocksResult.Merge(m, src)
|
||||
}
|
||||
func (m *SearchBlocksResult) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SearchBlocksResult) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SearchBlocksResult.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SearchBlocksResult proto.InternalMessageInfo
|
||||
|
||||
func (m *SearchBlocksResult) GetTotalCount() int64 {
|
||||
if m != nil {
|
||||
return m.TotalCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) GetCount() int64 {
|
||||
if m != nil {
|
||||
return m.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) GetPageNumber() int64 {
|
||||
if m != nil {
|
||||
return m.PageNumber
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) GetPageTotal() int64 {
|
||||
if m != nil {
|
||||
return m.PageTotal
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) GetLimit() int64 {
|
||||
if m != nil {
|
||||
return m.Limit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) GetBlocks() []*types2.Block {
|
||||
if m != nil {
|
||||
return m.Blocks
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*TxResponse)(nil), "cosmos.base.abci.v1beta1.TxResponse")
|
||||
proto.RegisterType((*ABCIMessageLog)(nil), "cosmos.base.abci.v1beta1.ABCIMessageLog")
|
||||
@ -630,6 +721,7 @@ func init() {
|
||||
proto.RegisterType((*MsgData)(nil), "cosmos.base.abci.v1beta1.MsgData")
|
||||
proto.RegisterType((*TxMsgData)(nil), "cosmos.base.abci.v1beta1.TxMsgData")
|
||||
proto.RegisterType((*SearchTxsResult)(nil), "cosmos.base.abci.v1beta1.SearchTxsResult")
|
||||
proto.RegisterType((*SearchBlocksResult)(nil), "cosmos.base.abci.v1beta1.SearchBlocksResult")
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -637,64 +729,68 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_4e37629bc7eb0df8 = []byte{
|
||||
// 909 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcd, 0x6f, 0x1b, 0x45,
|
||||
0x14, 0xf7, 0xda, 0xdb, 0x75, 0x3c, 0x8e, 0x29, 0x1a, 0x45, 0xe9, 0xa4, 0x80, 0x6d, 0xdc, 0x22,
|
||||
0x59, 0x48, 0xac, 0xd5, 0xb4, 0x42, 0xb4, 0xa7, 0xd6, 0xe1, 0x2b, 0x52, 0xcb, 0x61, 0xe3, 0x0a,
|
||||
0x89, 0x8b, 0x35, 0xb6, 0xa7, 0xe3, 0x55, 0xbd, 0x3b, 0xd6, 0xce, 0x6c, 0xb2, 0xb9, 0x71, 0x83,
|
||||
0x23, 0x27, 0xce, 0x5c, 0xe1, 0x2f, 0xe9, 0x81, 0x43, 0x8e, 0x3d, 0x54, 0x01, 0x92, 0x1b, 0x7f,
|
||||
0x05, 0x7a, 0x6f, 0xc6, 0x1f, 0x25, 0x75, 0xd5, 0x93, 0xdf, 0xfc, 0xde, 0x87, 0xdf, 0xfb, 0xbd,
|
||||
0xdf, 0xce, 0x90, 0x5b, 0x63, 0xa5, 0x13, 0xa5, 0x7b, 0x23, 0xae, 0x45, 0x8f, 0x8f, 0xc6, 0x71,
|
||||
0xef, 0xf8, 0xce, 0x48, 0x18, 0x7e, 0x07, 0x0f, 0xe1, 0x3c, 0x53, 0x46, 0x51, 0x66, 0x83, 0x42,
|
||||
0x08, 0x0a, 0x11, 0x77, 0x41, 0x37, 0x77, 0xa4, 0x92, 0x0a, 0x83, 0x7a, 0x60, 0xd9, 0xf8, 0x9b,
|
||||
0x1f, 0x18, 0x91, 0x4e, 0x44, 0x96, 0xc4, 0xa9, 0xb1, 0x35, 0xcd, 0xe9, 0x5c, 0x68, 0xe7, 0xdc,
|
||||
0x93, 0x4a, 0xc9, 0x99, 0xe8, 0xe1, 0x69, 0x94, 0x3f, 0xeb, 0xf1, 0xf4, 0xd4, 0xba, 0x3a, 0x7f,
|
||||
0x56, 0x08, 0x19, 0x14, 0x91, 0xd0, 0x73, 0x95, 0x6a, 0x41, 0x77, 0x49, 0x30, 0x15, 0xb1, 0x9c,
|
||||
0x1a, 0xe6, 0xb5, 0xbd, 0x6e, 0x25, 0x72, 0x27, 0xda, 0x21, 0x81, 0x29, 0xa6, 0x5c, 0x4f, 0x59,
|
||||
0xb9, 0xed, 0x75, 0x6b, 0x7d, 0x72, 0x71, 0xde, 0x0a, 0x06, 0xc5, 0xb7, 0x5c, 0x4f, 0x23, 0xe7,
|
||||
0xa1, 0x1f, 0x92, 0xda, 0x58, 0x4d, 0x84, 0x9e, 0xf3, 0xb1, 0x60, 0x15, 0x08, 0x8b, 0x56, 0x00,
|
||||
0xa5, 0xc4, 0x87, 0x03, 0xf3, 0xdb, 0x5e, 0xb7, 0x11, 0xa1, 0x0d, 0xd8, 0x84, 0x1b, 0xce, 0xae,
|
||||
0x61, 0x30, 0xda, 0xf4, 0x06, 0xa9, 0x66, 0xfc, 0x64, 0x38, 0x53, 0x92, 0x05, 0x08, 0x07, 0x19,
|
||||
0x3f, 0x79, 0xac, 0x24, 0x7d, 0x4a, 0xfc, 0x99, 0x92, 0x9a, 0x55, 0xdb, 0x95, 0x6e, 0x7d, 0xbf,
|
||||
0x1b, 0x6e, 0x22, 0x28, 0x7c, 0xd4, 0x3f, 0x38, 0x7c, 0x22, 0xb4, 0xe6, 0x52, 0x3c, 0x56, 0xb2,
|
||||
0x7f, 0xe3, 0xc5, 0x79, 0xab, 0xf4, 0xc7, 0x5f, 0xad, 0xeb, 0xaf, 0xe3, 0x3a, 0xc2, 0x72, 0xd0,
|
||||
0x43, 0x9c, 0x3e, 0x53, 0x6c, 0xcb, 0xf6, 0x00, 0x36, 0xfd, 0x88, 0x10, 0xc9, 0xf5, 0xf0, 0x84,
|
||||
0xa7, 0x46, 0x4c, 0x58, 0x0d, 0x99, 0xa8, 0x49, 0xae, 0xbf, 0x47, 0x80, 0xee, 0x91, 0x2d, 0x70,
|
||||
0xe7, 0x5a, 0x4c, 0x18, 0x41, 0x67, 0x55, 0x72, 0xfd, 0x54, 0x8b, 0x09, 0xbd, 0x4d, 0xca, 0xa6,
|
||||
0x60, 0xf5, 0xb6, 0xd7, 0xad, 0xef, 0xef, 0x84, 0x96, 0xf6, 0x70, 0x41, 0x7b, 0xf8, 0x28, 0x3d,
|
||||
0x8d, 0xca, 0xa6, 0x00, 0xa6, 0x4c, 0x9c, 0x08, 0x6d, 0x78, 0x32, 0x67, 0xdb, 0x96, 0xa9, 0x25,
|
||||
0x40, 0xef, 0x91, 0x40, 0x1c, 0x8b, 0xd4, 0x68, 0xd6, 0xc0, 0x51, 0x77, 0xc3, 0xd5, 0x6e, 0xed,
|
||||
0xa4, 0x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0x3c, 0x35,
|
||||
0x4e, 0x5f, 0x04, 0xa1, 0x03, 0x40, 0x40, 0xa0, 0xd6, 0x65, 0xd5, 0x65, 0x0f, 0x90, 0x36, 0xe7,
|
||||
0x52, 0x0c, 0xd3, 0x3c, 0x19, 0x89, 0x0c, 0xef, 0x5e, 0x3f, 0x22, 0x00, 0x7d, 0x87, 0x08, 0xc8,
|
||||
0x16, 0x03, 0xb0, 0x12, 0x5e, 0xc1, 0x7e, 0x54, 0x03, 0x64, 0x00, 0x00, 0x54, 0x9d, 0xc5, 0x49,
|
||||
0x6c, 0xf0, 0x22, 0xf6, 0x23, 0x7b, 0xa0, 0x9f, 0x93, 0x8a, 0x29, 0x34, 0x0b, 0x70, 0xae, 0xdb,
|
||||
0x9b, 0xb9, 0x59, 0x3d, 0x1f, 0x11, 0x24, 0xd8, 0xf1, 0xfa, 0x0f, 0x5f, 0xfe, 0xd3, 0x2c, 0xbd,
|
||||
0xb8, 0x68, 0x7a, 0x67, 0x17, 0x4d, 0xef, 0xef, 0x8b, 0xa6, 0xf7, 0xcb, 0x65, 0xb3, 0x74, 0x76,
|
||||
0xd9, 0x2c, 0xbd, 0xbc, 0x6c, 0x96, 0x7e, 0xe8, 0xc8, 0xd8, 0x4c, 0xf3, 0x51, 0x38, 0x56, 0x49,
|
||||
0xcf, 0x3d, 0x87, 0xf6, 0xe7, 0x33, 0x3d, 0x79, 0x6e, 0xdf, 0xae, 0x51, 0x80, 0x14, 0xde, 0xfd,
|
||||
0x2f, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xf1, 0x8e, 0x98, 0x30, 0x07, 0x00, 0x00,
|
||||
// 968 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0x4f, 0x6f, 0x1b, 0xb7,
|
||||
0x13, 0xd5, 0x6a, 0x37, 0x2b, 0x8b, 0xb2, 0x7e, 0xf9, 0x81, 0x30, 0x6c, 0x3a, 0x4d, 0x25, 0x55,
|
||||
0x49, 0x01, 0xa1, 0x40, 0x57, 0x88, 0x13, 0x14, 0x4d, 0x4e, 0x89, 0xdc, 0x7f, 0x06, 0x92, 0x1e,
|
||||
0xd6, 0x0a, 0x0a, 0xf4, 0x22, 0x50, 0x12, 0x43, 0x2d, 0xac, 0x5d, 0x0a, 0x4b, 0xca, 0x96, 0x6f,
|
||||
0xbd, 0xb5, 0xc7, 0x9e, 0x7a, 0xee, 0xb5, 0xfd, 0x24, 0x39, 0xf4, 0xe0, 0xa3, 0x0f, 0x81, 0xdb,
|
||||
0xda, 0xb7, 0x7e, 0x8a, 0x62, 0x86, 0xd4, 0x9f, 0xd4, 0x95, 0x9b, 0x93, 0x87, 0x6f, 0x86, 0xd4,
|
||||
0xbc, 0x37, 0x6f, 0x49, 0x93, 0x7b, 0x03, 0xa5, 0x53, 0xa5, 0xdb, 0x7d, 0xae, 0x45, 0x9b, 0xf7,
|
||||
0x07, 0x49, 0xfb, 0xf8, 0x41, 0x5f, 0x18, 0xfe, 0x00, 0x17, 0xd1, 0x24, 0x57, 0x46, 0x51, 0x66,
|
||||
0x8b, 0x22, 0x28, 0x8a, 0x10, 0x77, 0x45, 0x77, 0xb6, 0xa4, 0x92, 0x0a, 0x8b, 0xda, 0x10, 0xd9,
|
||||
0xfa, 0x3b, 0xef, 0x19, 0x91, 0x0d, 0x45, 0x9e, 0x26, 0x99, 0xb1, 0x67, 0x9a, 0xd3, 0x89, 0xd0,
|
||||
0x2e, 0x79, 0x77, 0x25, 0x89, 0x78, 0xbb, 0x3f, 0x56, 0x83, 0x23, 0x97, 0xdd, 0x95, 0x4a, 0xc9,
|
||||
0xb1, 0x68, 0xe3, 0xaa, 0x3f, 0x7d, 0xd5, 0xe6, 0xd9, 0xa9, 0x4d, 0x35, 0x7f, 0xf3, 0x09, 0xe9,
|
||||
0xce, 0x62, 0xa1, 0x27, 0x2a, 0xd3, 0x82, 0x6e, 0x93, 0x70, 0x24,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0xab, 0xed, 0x93, 0x10, 0xc6, 0xcf, 0xbc, 0xe6, 0xf7, 0x1e, 0x29,
|
||||
0x77, 0x67, 0xf3, 0x43, 0x1e, 0x2f, 0x26, 0xe1, 0xdf, 0xcc, 0xc6, 0x6d, 0x58, 0x19, 0xd6, 0x35,
|
||||
0x91, 0x8b, 0xef, 0x2e, 0x32, 0x5a, 0xf1, 0x8d, 0x47, 0x6e, 0x1f, 0x0a, 0x9e, 0x0f, 0x46, 0xdd,
|
||||
0x99, 0x76, 0xce, 0xa8, 0x93, 0x8a, 0x51, 0x86, 0x8f, 0x7b, 0x03, 0x35, 0xcd, 0x8c, 0xf3, 0x17,
|
||||
0x41, 0x68, 0x1f, 0x10, 0x30, 0xa8, 0x4d, 0x59, 0x77, 0xd9, 0x05, 0x6c, 0x9b, 0x70, 0x29, 0x7a,
|
||||
0xd9, 0x34, 0xed, 0x8b, 0x1c, 0xef, 0xde, 0x20, 0x26, 0x00, 0x7d, 0x8d, 0x08, 0xd8, 0x16, 0x0b,
|
||||
0xf0, 0x24, 0xbc, 0x82, 0x83, 0xb8, 0x0c, 0x48, 0x17, 0x00, 0x38, 0x75, 0x9c, 0xa4, 0x89, 0xc1,
|
||||
0x8b, 0x38, 0x88, 0xed, 0x82, 0x7e, 0x42, 0x7c, 0x33, 0xd3, 0x2c, 0x44, 0x5e, 0xf7, 0xd7, 0x6b,
|
||||
0xb3, 0x7c, 0x3e, 0x62, 0xd8, 0xe0, 0xe8, 0x9d, 0x83, 0x87, 0x90, 0x5e, 0x07, 0x5e, 0xa2, 0x1b,
|
||||
0x18, 0xfa, 0xeb, 0x19, 0xfa, 0x37, 0x30, 0xf4, 0xff, 0x83, 0xa1, 0xbf, 0x96, 0xa1, 0x3f, 0x67,
|
||||
0xd8, 0x26, 0x21, 0x3e, 0x93, 0x73, 0x92, 0x3b, 0xab, 0x9f, 0x97, 0x7d, 0x5e, 0xb1, 0xf9, 0xd8,
|
||||
0x95, 0x59, 0x6a, 0x9d, 0xa7, 0xe7, 0x7f, 0xd6, 0x0a, 0xaf, 0x2f, 0x6b, 0xde, 0xd9, 0x65, 0xcd,
|
||||
0xfb, 0xe3, 0xb2, 0xe6, 0xfd, 0x78, 0x55, 0x2b, 0x9c, 0x5d, 0xd5, 0x0a, 0xe7, 0x57, 0xb5, 0xc2,
|
||||
0xb7, 0x4d, 0x99, 0x98, 0xd1, 0xb4, 0x1f, 0x0d, 0x54, 0xda, 0x76, 0xff, 0x07, 0xd8, 0x3f, 0x1f,
|
||||
0xeb, 0xe1, 0x91, 0x7d, 0x9c, 0xfb, 0x21, 0xba, 0xe3, 0xe1, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff,
|
||||
0x4d, 0x51, 0x55, 0xd9, 0x29, 0x08, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *TxResponse) Marshal() (dAtA []byte, err error) {
|
||||
@ -1245,6 +1341,68 @@ func (m *SearchTxsResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Blocks) > 0 {
|
||||
for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Blocks[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintAbci(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
}
|
||||
if m.Limit != 0 {
|
||||
i = encodeVarintAbci(dAtA, i, uint64(m.Limit))
|
||||
i--
|
||||
dAtA[i] = 0x28
|
||||
}
|
||||
if m.PageTotal != 0 {
|
||||
i = encodeVarintAbci(dAtA, i, uint64(m.PageTotal))
|
||||
i--
|
||||
dAtA[i] = 0x20
|
||||
}
|
||||
if m.PageNumber != 0 {
|
||||
i = encodeVarintAbci(dAtA, i, uint64(m.PageNumber))
|
||||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
if m.Count != 0 {
|
||||
i = encodeVarintAbci(dAtA, i, uint64(m.Count))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
}
|
||||
if m.TotalCount != 0 {
|
||||
i = encodeVarintAbci(dAtA, i, uint64(m.TotalCount))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintAbci(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovAbci(v)
|
||||
base := offset
|
||||
@ -1502,6 +1660,36 @@ func (m *SearchTxsResult) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SearchBlocksResult) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.TotalCount != 0 {
|
||||
n += 1 + sovAbci(uint64(m.TotalCount))
|
||||
}
|
||||
if m.Count != 0 {
|
||||
n += 1 + sovAbci(uint64(m.Count))
|
||||
}
|
||||
if m.PageNumber != 0 {
|
||||
n += 1 + sovAbci(uint64(m.PageNumber))
|
||||
}
|
||||
if m.PageTotal != 0 {
|
||||
n += 1 + sovAbci(uint64(m.PageTotal))
|
||||
}
|
||||
if m.Limit != 0 {
|
||||
n += 1 + sovAbci(uint64(m.Limit))
|
||||
}
|
||||
if len(m.Blocks) > 0 {
|
||||
for _, e := range m.Blocks {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovAbci(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovAbci(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@ -1593,6 +1781,26 @@ func (this *SearchTxsResult) String() string {
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func (this *SearchBlocksResult) String() string {
|
||||
if this == nil {
|
||||
return "nil"
|
||||
}
|
||||
repeatedStringForBlocks := "[]*Block{"
|
||||
for _, f := range this.Blocks {
|
||||
repeatedStringForBlocks += strings.Replace(fmt.Sprintf("%v", f), "Block", "types2.Block", 1) + ","
|
||||
}
|
||||
repeatedStringForBlocks += "}"
|
||||
s := strings.Join([]string{`&SearchBlocksResult{`,
|
||||
`TotalCount:` + fmt.Sprintf("%v", this.TotalCount) + `,`,
|
||||
`Count:` + fmt.Sprintf("%v", this.Count) + `,`,
|
||||
`PageNumber:` + fmt.Sprintf("%v", this.PageNumber) + `,`,
|
||||
`PageTotal:` + fmt.Sprintf("%v", this.PageTotal) + `,`,
|
||||
`Limit:` + fmt.Sprintf("%v", this.Limit) + `,`,
|
||||
`Blocks:` + repeatedStringForBlocks + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
}
|
||||
func valueToStringAbci(v interface{}) string {
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsNil() {
|
||||
@ -3192,6 +3400,185 @@ func (m *SearchTxsResult) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SearchBlocksResult) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: SearchBlocksResult: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SearchBlocksResult: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field TotalCount", wireType)
|
||||
}
|
||||
m.TotalCount = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.TotalCount |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType)
|
||||
}
|
||||
m.Count = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Count |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PageNumber", wireType)
|
||||
}
|
||||
m.PageNumber = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.PageNumber |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 4:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PageTotal", wireType)
|
||||
}
|
||||
m.PageTotal = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.PageTotal |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 5:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType)
|
||||
}
|
||||
m.Limit = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Limit |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAbci
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthAbci
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAbci
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Blocks = append(m.Blocks, &types2.Block{})
|
||||
if err := m.Blocks[len(m.Blocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAbci(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAbci
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipAbci(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@ -3,13 +3,13 @@ package types
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
coretypes "github.com/cometbft/cometbft/rpc/core/types"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
@ -83,6 +83,25 @@ func NewResponseResultTx(res *coretypes.ResultTx, anyTx *codectypes.Any, timesta
|
||||
}
|
||||
}
|
||||
|
||||
// NewResponseResultBlock returns a BlockResponse given a ResultBlock from CometBFT
|
||||
func NewResponseResultBlock(res *coretypes.ResultBlock, timestamp string) *cmtproto.Block {
|
||||
if res == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
blk, err := res.Block.ToProto()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &cmtproto.Block{
|
||||
Header: blk.Header,
|
||||
Data: blk.Data,
|
||||
Evidence: blk.Evidence,
|
||||
LastCommit: blk.LastCommit,
|
||||
}
|
||||
}
|
||||
|
||||
// NewResponseFormatBroadcastTx returns a TxResponse given a ResultBroadcastTx from tendermint
|
||||
func NewResponseFormatBroadcastTx(res *coretypes.ResultBroadcastTx) *TxResponse {
|
||||
if res == nil {
|
||||
@ -112,16 +131,31 @@ func (r TxResponse) Empty() bool {
|
||||
}
|
||||
|
||||
func NewSearchTxsResult(totalCount, count, page, limit uint64, txs []*TxResponse) *SearchTxsResult {
|
||||
totalPages := calcTotalPages(int64(totalCount), int64(limit))
|
||||
|
||||
return &SearchTxsResult{
|
||||
TotalCount: totalCount,
|
||||
Count: count,
|
||||
PageNumber: page,
|
||||
PageTotal: uint64(math.Ceil(float64(totalCount) / float64(limit))),
|
||||
PageTotal: uint64(totalPages),
|
||||
Limit: limit,
|
||||
Txs: txs,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSearchBlocksResult(totalCount, count, page, limit int64, blocks []*cmtproto.Block) *SearchBlocksResult {
|
||||
totalPages := calcTotalPages(totalCount, limit)
|
||||
|
||||
return &SearchBlocksResult{
|
||||
TotalCount: totalCount,
|
||||
Count: count,
|
||||
PageNumber: page,
|
||||
PageTotal: totalPages,
|
||||
Limit: limit,
|
||||
Blocks: blocks,
|
||||
}
|
||||
}
|
||||
|
||||
// ParseABCILogs attempts to parse a stringified ABCI tx log into a slice of
|
||||
// ABCIMessageLog types. It returns an error upon JSON decoding failure.
|
||||
func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) {
|
||||
@ -194,3 +228,16 @@ func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, erro
|
||||
MsgResponses: []*codectypes.Any{any},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// calculate total pages in an overflow safe manner
|
||||
func calcTotalPages(totalCount int64, limit int64) int64 {
|
||||
totalPages := int64(0)
|
||||
if totalCount != 0 && limit != 0 {
|
||||
if totalCount%limit > 0 {
|
||||
totalPages = totalCount/limit + 1
|
||||
} else {
|
||||
totalPages = totalCount / limit
|
||||
}
|
||||
}
|
||||
return totalPages
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/libs/bytes"
|
||||
@ -13,6 +14,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
cmtt "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
cmt "github.com/cometbft/cometbft/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -139,6 +142,44 @@ txhash: "74657374"
|
||||
s.Require().Equal((*sdk.TxResponse)(nil), sdk.NewResponseFormatBroadcastTx(nil))
|
||||
}
|
||||
|
||||
func (s *resultTestSuite) TestNewSearchBlocksResult() {
|
||||
got := sdk.NewSearchBlocksResult(150, 20, 2, 20, []*cmtt.Block{})
|
||||
s.Require().Equal(&sdk.SearchBlocksResult{
|
||||
TotalCount: 150,
|
||||
Count: 20,
|
||||
PageNumber: 2,
|
||||
PageTotal: 8,
|
||||
Limit: 20,
|
||||
Blocks: []*cmtt.Block{},
|
||||
}, got)
|
||||
}
|
||||
|
||||
func (s *resultTestSuite) TestResponseResultBlock() {
|
||||
timestamp := time.Now()
|
||||
timestampStr := timestamp.UTC().Format(time.RFC3339)
|
||||
|
||||
// create a block
|
||||
resultBlock := &coretypes.ResultBlock{Block: &cmt.Block{
|
||||
Header: cmt.Header{
|
||||
Height: 10,
|
||||
Time: timestamp,
|
||||
},
|
||||
Evidence: cmt.EvidenceData{
|
||||
Evidence: make(cmt.EvidenceList, 0),
|
||||
},
|
||||
}}
|
||||
|
||||
blk, err := resultBlock.Block.ToProto()
|
||||
s.Require().NoError(err)
|
||||
|
||||
want := &cmtt.Block{
|
||||
Header: blk.Header,
|
||||
Evidence: blk.Evidence,
|
||||
}
|
||||
|
||||
s.Require().Equal(want, sdk.NewResponseResultBlock(resultBlock, timestampStr))
|
||||
}
|
||||
|
||||
func TestWrapServiceResult(t *testing.T) {
|
||||
ctx := sdk.Context{}
|
||||
|
||||
|
||||
@ -20,14 +20,17 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
flagEvents = "events"
|
||||
flagType = "type"
|
||||
FlagEvents = "events" // TODO: Remove when #14758 is merged
|
||||
FlagQuery = "query"
|
||||
FlagType = "type"
|
||||
FlagOrderBy = "order_by"
|
||||
|
||||
typeHash = "hash"
|
||||
typeAccSeq = "acc_seq"
|
||||
typeSig = "signature"
|
||||
TypeHash = "hash"
|
||||
TypeAccSeq = "acc_seq"
|
||||
TypeSig = "signature"
|
||||
TypeHeight = "height"
|
||||
|
||||
eventFormat = "{eventType}.{eventAttribute}={value}"
|
||||
EventFormat = "{eventType}.{eventAttribute}={value}"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the transaction commands for this module
|
||||
@ -270,14 +273,14 @@ documents its respective events under 'xx_events.md'.
|
||||
|
||||
Example:
|
||||
$ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator_reward' --page 1 --limit 30
|
||||
`, eventFormat, version.AppName, flagEvents),
|
||||
`, EventFormat, version.AppName, FlagEvents),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
eventsRaw, _ := cmd.Flags().GetString(flagEvents)
|
||||
eventsRaw, _ := cmd.Flags().GetString(FlagEvents)
|
||||
eventsStr := strings.Trim(eventsRaw, "'")
|
||||
|
||||
var events []string
|
||||
@ -291,9 +294,9 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
|
||||
|
||||
for _, event := range events {
|
||||
if !strings.Contains(event, "=") {
|
||||
return fmt.Errorf("invalid event; event %s should be of the format: %s", event, eventFormat)
|
||||
return fmt.Errorf("invalid event; event %s should be of the format: %s", event, EventFormat)
|
||||
} else if strings.Count(event, "=") > 1 {
|
||||
return fmt.Errorf("invalid event; event %s should be of the format: %s", event, eventFormat)
|
||||
return fmt.Errorf("invalid event; event %s should be of the format: %s", event, EventFormat)
|
||||
}
|
||||
|
||||
tokens := strings.Split(event, "=")
|
||||
@ -321,8 +324,8 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
cmd.Flags().Int(flags.FlagPage, query.DefaultPage, "Query a specific page of paginated results")
|
||||
cmd.Flags().Int(flags.FlagLimit, query.DefaultLimit, "Query number of transactions results per page returned")
|
||||
cmd.Flags().String(flagEvents, "", fmt.Sprintf("list of transaction events in the form of %s", eventFormat))
|
||||
cmd.MarkFlagRequired(flagEvents)
|
||||
cmd.Flags().String(FlagEvents, "", fmt.Sprintf("list of transaction events in the form of %s", EventFormat))
|
||||
cmd.MarkFlagRequired(FlagEvents)
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -339,8 +342,8 @@ $ %s query tx --%s=%s <addr>/<sequence>
|
||||
$ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
|
||||
`,
|
||||
version.AppName,
|
||||
version.AppName, flagType, typeAccSeq,
|
||||
version.AppName, flagType, typeSig)),
|
||||
version.AppName, FlagType, TypeAccSeq,
|
||||
version.AppName, FlagType, TypeSig)),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
@ -348,10 +351,10 @@ $ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
|
||||
return err
|
||||
}
|
||||
|
||||
typ, _ := cmd.Flags().GetString(flagType)
|
||||
typ, _ := cmd.Flags().GetString(FlagType)
|
||||
|
||||
switch typ {
|
||||
case typeHash:
|
||||
case TypeHash:
|
||||
{
|
||||
if args[0] == "" {
|
||||
return fmt.Errorf("argument should be a tx hash")
|
||||
@ -369,7 +372,7 @@ $ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
|
||||
|
||||
return clientCtx.PrintProto(output)
|
||||
}
|
||||
case typeSig:
|
||||
case TypeSig:
|
||||
{
|
||||
sigParts, err := ParseSigArgs(args)
|
||||
if err != nil {
|
||||
@ -394,7 +397,7 @@ $ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
|
||||
|
||||
return clientCtx.PrintProto(txs.Txs[0])
|
||||
}
|
||||
case typeAccSeq:
|
||||
case TypeAccSeq:
|
||||
{
|
||||
if args[0] == "" {
|
||||
return fmt.Errorf("`acc_seq` type takes an argument '<addr>/<seq>'")
|
||||
@ -418,13 +421,13 @@ $ %s query tx --%s=%s <sig1_base64>,<sig2_base64...>
|
||||
return clientCtx.PrintProto(txs.Txs[0])
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown --%s value %s", flagType, typ)
|
||||
return fmt.Errorf("unknown --%s value %s", FlagType, typ)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
cmd.Flags().String(flagType, typeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\", \"%s\"", typeHash, typeAccSeq, typeSig))
|
||||
cmd.Flags().String(FlagType, TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\", \"%s\"", TypeHash, TypeAccSeq, TypeSig))
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -85,6 +85,32 @@ When querying a transaction given its signature, use the `--type=signature` flag
|
||||
simd query tx --type=signature Ofjvgrqi8twZfqVDmYIhqwRLQjZZ40XbxEamk/veH3gQpRF0hL2PH4ejRaDzAX+2WChnaWNQJQ41ekToIi5Wqw==
|
||||
```
|
||||
|
||||
When querying a transaction given its events, use the `--type=events` flag:
|
||||
|
||||
```shell
|
||||
simd query txs --events 'message.sender=cosmos...' --page 1 --limit 30
|
||||
```
|
||||
|
||||
The `x/auth/block` module provides a CLI command to query any block, given its hash, height, or events.
|
||||
|
||||
When querying a block by its hash, use the `--type=hash` flag:
|
||||
|
||||
```shell
|
||||
simd query block --type=hash DFE87B78A630C0EFDF76C80CD24C997E252792E0317502AE1A02B9809F0D8685
|
||||
```
|
||||
|
||||
When querying a block by its height, use the `--type=height` flag:
|
||||
|
||||
```shell
|
||||
simd query block --type=height 1357
|
||||
```
|
||||
|
||||
When querying a block by its events, use the `--query` flag:
|
||||
|
||||
```shell
|
||||
simd query blocks --query 'message.sender=cosmos...' --page 1 --limit 30
|
||||
```
|
||||
|
||||
#### Transactions
|
||||
|
||||
The `x/auth/tx` module provides a convinient CLI command for decoding and encoding transactions.
|
||||
|
||||
@ -44,7 +44,8 @@ type MsgCreateValidator struct {
|
||||
Commission CommissionRates `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission"`
|
||||
MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"`
|
||||
// Deprecated: Use of Delegator Address in MsgCreateValidator is deprecated.
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer only in bech32 notation).
|
||||
// The validator address bytes and delegator address bytes refer to the same account while creating validator (defer
|
||||
// only in bech32 notation).
|
||||
DelegatorAddress string `protobuf:"bytes,4,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` // Deprecated: Do not use.
|
||||
ValidatorAddress string `protobuf:"bytes,5,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"`
|
||||
Pubkey *types.Any `protobuf:"bytes,6,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
|
||||
|
||||
@ -58,7 +58,7 @@ message SignerData {
|
||||
}
|
||||
|
||||
// Envelope is an internal data structure used to generate the tx envelope
|
||||
// screens. It is derived from the TextualData struct (also internal) which
|
||||
// screens. It is derived from the TextualData struct (also internal) which
|
||||
// contains the three following fields:
|
||||
// - body_bytes (from the original tx),
|
||||
// - auth_info_bytes (from the original tx),
|
||||
@ -67,23 +67,22 @@ message SignerData {
|
||||
// If any of the three structs above is modified, then this Envelope message
|
||||
// also needs to be updated.
|
||||
message Envelope {
|
||||
string chain_id = 1;
|
||||
uint64 account_number = 2;
|
||||
uint64 sequence = 3;
|
||||
string address = 4;
|
||||
google.protobuf.Any public_key = 5;
|
||||
repeated google.protobuf.Any message = 6;
|
||||
string memo = 7;
|
||||
repeated cosmos.base.v1beta1.Coin fees = 8;
|
||||
string fee_payer = 9;
|
||||
string fee_granter = 10;
|
||||
repeated cosmos.base.v1beta1.Coin tip = 11;
|
||||
string tipper = 12;
|
||||
uint64 gas_limit = 13;
|
||||
uint64 timeout_height = 14;
|
||||
repeated cosmos.tx.v1beta1.SignerInfo other_signer = 15;
|
||||
repeated google.protobuf.Any extension_options = 16;
|
||||
string chain_id = 1;
|
||||
uint64 account_number = 2;
|
||||
uint64 sequence = 3;
|
||||
string address = 4;
|
||||
google.protobuf.Any public_key = 5;
|
||||
repeated google.protobuf.Any message = 6;
|
||||
string memo = 7;
|
||||
repeated cosmos.base.v1beta1.Coin fees = 8;
|
||||
string fee_payer = 9;
|
||||
string fee_granter = 10;
|
||||
repeated cosmos.base.v1beta1.Coin tip = 11;
|
||||
string tipper = 12;
|
||||
uint64 gas_limit = 13;
|
||||
uint64 timeout_height = 14;
|
||||
repeated cosmos.tx.v1beta1.SignerInfo other_signer = 15;
|
||||
repeated google.protobuf.Any extension_options = 16;
|
||||
repeated google.protobuf.Any non_critical_extension_options = 17;
|
||||
string hash_of_raw_bytes = 18;
|
||||
string hash_of_raw_bytes = 18;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user