cosmos-reflection: extend to support writing by reflection clients (#8965)

Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
This commit is contained in:
Frojdi Dymylja 2021-04-07 01:33:54 +02:00 committed by GitHub
parent 7f9bc057e1
commit 29ff333007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 8068 additions and 668 deletions

View File

@ -37,14 +37,13 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]
## Features
* [\#8965](https://github.com/cosmos/cosmos-sdk/pull/8965) cosmos reflection now provides more information on the application such as: deliverable msgs, sdk.Config info etc (still in alpha stage).
* [\#8559](https://github.com/cosmos/cosmos-sdk/pull/8559) Added Protobuf compatible secp256r1 ECDSA signatures.
* [\#8786](https://github.com/cosmos/cosmos-sdk/pull/8786) Enabled secp256r1 in x/auth.
* (rosetta) [\#8729](https://github.com/cosmos/cosmos-sdk/pull/8729) Data API fully supports balance tracking. Construction API can now construct any message supported by the application.
* [\#8754](https://github.com/cosmos/cosmos-sdk/pull/8875) Added support for reverse iteration to pagination.
### Client Breaking Changes
* [\#8363](https://github.com/cosmos/cosmos-sdk/pull/8363) Addresses no longer have a fixed 20-byte length. From the SDK modules' point of view, any 1-255 bytes-long byte array is a valid address.
* [\#8346](https://github.com/cosmos/cosmos-sdk/pull/8346) All CLI `tx` commands generate ServiceMsgs by default. Graceful Amino support has been added to ServiceMsgs to support signing legacy Msgs.
* (crypto/ed25519) [\#8690] Adopt zip1215 ed2559 verification rules.

View File

@ -4,13 +4,14 @@ import (
"fmt"
"reflect"
"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
gogogrpc "github.com/gogo/protobuf/grpc"
abci "github.com/tendermint/tendermint/abci/types"
"google.golang.org/grpc"
"google.golang.org/grpc/encoding"
"google.golang.org/grpc/encoding/proto"
"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -136,7 +137,6 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf
// also register the interface reflection gRPC service.
func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry) {
qrt.interfaceRegistry = interfaceRegistry
// Once we have an interface registry, we can register the interface
// registry reflection gRPC service.
reflection.RegisterReflectionServiceServer(

View File

@ -1,55 +0,0 @@
package reflection_test
import (
"context"
"testing"
"github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
"github.com/cosmos/cosmos-sdk/simapp"
)
type IntegrationTestSuite struct {
suite.Suite
queryClient reflection.ReflectionServiceClient
}
func (s *IntegrationTestSuite) SetupSuite() {
app := simapp.Setup(false)
sdkCtx := app.BaseApp.NewContext(false, tmproto.Header{})
queryHelper := baseapp.NewQueryServerTestHelper(sdkCtx, app.InterfaceRegistry())
queryClient := reflection.NewReflectionServiceClient(queryHelper)
s.queryClient = queryClient
}
func (s IntegrationTestSuite) TestSimulateService() {
// We will test the following interface for testing.
var iface = "cosmos.evidence.v1beta1.Evidence"
// Test that "cosmos.evidence.v1beta1.Evidence" is included in the
// interfaces.
resIface, err := s.queryClient.ListAllInterfaces(
context.Background(),
&reflection.ListAllInterfacesRequest{},
)
s.Require().NoError(err)
s.Require().Contains(resIface.GetInterfaceNames(), iface)
// Test that "cosmos.evidence.v1beta1.Evidence" has at least the
// Equivocation implementations.
resImpl, err := s.queryClient.ListImplementations(
context.Background(),
&reflection.ListImplementationsRequest{InterfaceName: iface},
)
s.Require().NoError(err)
s.Require().Contains(resImpl.GetImplementationMessageNames(), "/cosmos.evidence.v1beta1.Equivocation")
}
func TestSimulateTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

View File

@ -38,7 +38,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
case flags.SignModeDirect:
signMode = signing.SignMode_SIGN_MODE_DIRECT
case flags.SignModeLegacyAminoJSON:
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON //nolint:staticcheck
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
}
accNum, _ := flagSet.GetUint64(flags.FlagAccountNumber)

View File

@ -1,7 +1,7 @@
[
{
"account_identifier": {
"address":"cosmos1trf09zvqeuc722zyeg34pra8qaqll9ddw0qy8q"
"address":"cosmos1tqpwnlx558r36pmf5h8xxct94qcq00h2p5evag"
},
"currency":{
"symbol":"stake",

Binary file not shown.

View File

@ -80,6 +80,7 @@
- [Output](#cosmos.bank.v1beta1.Output)
- [Params](#cosmos.bank.v1beta1.Params)
- [SendEnabled](#cosmos.bank.v1beta1.SendEnabled)
- [Supply](#cosmos.bank.v1beta1.Supply)
- [cosmos/bank/v1beta1/genesis.proto](#cosmos/bank/v1beta1/genesis.proto)
- [Balance](#cosmos.bank.v1beta1.Balance)
@ -123,6 +124,37 @@
- [ReflectionService](#cosmos.base.reflection.v1beta1.ReflectionService)
- [cosmos/base/reflection/v2alpha1/reflection.proto](#cosmos/base/reflection/v2alpha1/reflection.proto)
- [AppDescriptor](#cosmos.base.reflection.v2alpha1.AppDescriptor)
- [AuthnDescriptor](#cosmos.base.reflection.v2alpha1.AuthnDescriptor)
- [ChainDescriptor](#cosmos.base.reflection.v2alpha1.ChainDescriptor)
- [CodecDescriptor](#cosmos.base.reflection.v2alpha1.CodecDescriptor)
- [ConfigurationDescriptor](#cosmos.base.reflection.v2alpha1.ConfigurationDescriptor)
- [GetAuthnDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest)
- [GetAuthnDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse)
- [GetChainDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest)
- [GetChainDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse)
- [GetCodecDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest)
- [GetCodecDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse)
- [GetConfigurationDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest)
- [GetConfigurationDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse)
- [GetQueryServicesDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest)
- [GetQueryServicesDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse)
- [GetTxDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest)
- [GetTxDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse)
- [InterfaceAcceptingMessageDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor)
- [InterfaceDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceDescriptor)
- [InterfaceImplementerDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor)
- [MsgDescriptor](#cosmos.base.reflection.v2alpha1.MsgDescriptor)
- [QueryMethodDescriptor](#cosmos.base.reflection.v2alpha1.QueryMethodDescriptor)
- [QueryServiceDescriptor](#cosmos.base.reflection.v2alpha1.QueryServiceDescriptor)
- [QueryServicesDescriptor](#cosmos.base.reflection.v2alpha1.QueryServicesDescriptor)
- [ServiceMsgDescriptor](#cosmos.base.reflection.v2alpha1.ServiceMsgDescriptor)
- [SigningModeDescriptor](#cosmos.base.reflection.v2alpha1.SigningModeDescriptor)
- [TxDescriptor](#cosmos.base.reflection.v2alpha1.TxDescriptor)
- [ReflectionService](#cosmos.base.reflection.v2alpha1.ReflectionService)
- [cosmos/base/snapshots/v1beta1/snapshot.proto](#cosmos/base/snapshots/v1beta1/snapshot.proto)
- [Metadata](#cosmos.base.snapshots.v1beta1.Metadata)
- [Snapshot](#cosmos.base.snapshots.v1beta1.Snapshot)
@ -1565,6 +1597,23 @@ sendable).
<a name="cosmos.bank.v1beta1.Supply"></a>
### Supply
Supply represents a struct that passively keeps track of the total supply
amounts in the network.
This message is deprecated now that supply is indexed by denom.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `total` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |
<!-- end messages -->
<!-- end enums -->
@ -1609,7 +1658,7 @@ GenesisState defines the bank module's genesis state.
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#cosmos.bank.v1beta1.Params) | | params defines all the paramaters of the module. |
| `balances` | [Balance](#cosmos.bank.v1beta1.Balance) | repeated | balances is an array containing the balances of all the accounts. |
| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply represents the total supply. |
| `supply` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | supply represents the total supply. If it is left empty, then supply will be calculated based on the provided balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. |
| `denom_metadata` | [Metadata](#cosmos.bank.v1beta1.Metadata) | repeated | denom_metadata defines the metadata of the differents coins. |
@ -2078,6 +2127,437 @@ ReflectionService defines a service for interface reflection.
<a name="cosmos/base/reflection/v2alpha1/reflection.proto"></a>
<p align="right"><a href="#top">Top</a></p>
## cosmos/base/reflection/v2alpha1/reflection.proto
<a name="cosmos.base.reflection.v2alpha1.AppDescriptor"></a>
### AppDescriptor
AppDescriptor describes a cosmos-sdk based application
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `authn` | [AuthnDescriptor](#cosmos.base.reflection.v2alpha1.AuthnDescriptor) | | AuthnDescriptor provides information on how to authenticate transactions on the application NOTE: experimental and subject to change in future releases. |
| `chain` | [ChainDescriptor](#cosmos.base.reflection.v2alpha1.ChainDescriptor) | | chain provides the chain descriptor |
| `codec` | [CodecDescriptor](#cosmos.base.reflection.v2alpha1.CodecDescriptor) | | codec provides metadata information regarding codec related types |
| `configuration` | [ConfigurationDescriptor](#cosmos.base.reflection.v2alpha1.ConfigurationDescriptor) | | configuration provides metadata information regarding the sdk.Config type |
| `query_services` | [QueryServicesDescriptor](#cosmos.base.reflection.v2alpha1.QueryServicesDescriptor) | | query_services provides metadata information regarding the available queriable endpoints |
| `tx` | [TxDescriptor](#cosmos.base.reflection.v2alpha1.TxDescriptor) | | tx provides metadata information regarding how to send transactions to the given application |
<a name="cosmos.base.reflection.v2alpha1.AuthnDescriptor"></a>
### AuthnDescriptor
AuthnDescriptor provides information on how to sign transactions without relying
on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `sign_modes` | [SigningModeDescriptor](#cosmos.base.reflection.v2alpha1.SigningModeDescriptor) | repeated | sign_modes defines the supported signature algorithm |
<a name="cosmos.base.reflection.v2alpha1.ChainDescriptor"></a>
### ChainDescriptor
ChainDescriptor describes chain information of the application
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [string](#string) | | id is the chain id |
<a name="cosmos.base.reflection.v2alpha1.CodecDescriptor"></a>
### CodecDescriptor
CodecDescriptor describes the registered interfaces and provides metadata information on the types
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `interfaces` | [InterfaceDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceDescriptor) | repeated | interfaces is a list of the registerted interfaces descriptors |
<a name="cosmos.base.reflection.v2alpha1.ConfigurationDescriptor"></a>
### ConfigurationDescriptor
ConfigurationDescriptor contains metadata information on the sdk.Config
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `bech32_account_address_prefix` | [string](#string) | | bech32_account_address_prefix is the account address prefix |
<a name="cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest"></a>
### GetAuthnDescriptorRequest
GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse"></a>
### GetAuthnDescriptorResponse
GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `authn` | [AuthnDescriptor](#cosmos.base.reflection.v2alpha1.AuthnDescriptor) | | authn describes how to authenticate to the application when sending transactions |
<a name="cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest"></a>
### GetChainDescriptorRequest
GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse"></a>
### GetChainDescriptorResponse
GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `chain` | [ChainDescriptor](#cosmos.base.reflection.v2alpha1.ChainDescriptor) | | chain describes application chain information |
<a name="cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest"></a>
### GetCodecDescriptorRequest
GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse"></a>
### GetCodecDescriptorResponse
GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `codec` | [CodecDescriptor](#cosmos.base.reflection.v2alpha1.CodecDescriptor) | | codec describes the application codec such as registered interfaces and implementations |
<a name="cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest"></a>
### GetConfigurationDescriptorRequest
GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse"></a>
### GetConfigurationDescriptorResponse
GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `config` | [ConfigurationDescriptor](#cosmos.base.reflection.v2alpha1.ConfigurationDescriptor) | | config describes the application's sdk.Config |
<a name="cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest"></a>
### GetQueryServicesDescriptorRequest
GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse"></a>
### GetQueryServicesDescriptorResponse
GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `queries` | [QueryServicesDescriptor](#cosmos.base.reflection.v2alpha1.QueryServicesDescriptor) | | queries provides information on the available queryable services |
<a name="cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest"></a>
### GetTxDescriptorRequest
GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC
<a name="cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse"></a>
### GetTxDescriptorResponse
GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `tx` | [TxDescriptor](#cosmos.base.reflection.v2alpha1.TxDescriptor) | | tx provides information on msgs that can be forwarded to the application alongside the accepted transaction protobuf type |
<a name="cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor"></a>
### InterfaceAcceptingMessageDescriptor
InterfaceAcceptingMessageDescriptor describes a protobuf message which contains
an interface represented as a google.protobuf.Any
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fullname` | [string](#string) | | fullname is the protobuf fullname of the type containing the interface |
| `field_descriptor_names` | [string](#string) | repeated | field_descriptor_names is a list of the protobuf name (not fullname) of the field which contains the interface as google.protobuf.Any (the interface is the same, but it can be in multiple fields of the same proto message) |
<a name="cosmos.base.reflection.v2alpha1.InterfaceDescriptor"></a>
### InterfaceDescriptor
InterfaceDescriptor describes the implementation of an interface
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fullname` | [string](#string) | | fullname is the name of the interface |
| `interface_accepting_messages` | [InterfaceAcceptingMessageDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor) | repeated | interface_accepting_messages contains information regarding the proto messages which contain the interface as google.protobuf.Any field |
| `interface_implementers` | [InterfaceImplementerDescriptor](#cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor) | repeated | interface_implementers is a list of the descriptors of the interface implementers |
<a name="cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor"></a>
### InterfaceImplementerDescriptor
InterfaceImplementerDescriptor describes an interface implementer
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fullname` | [string](#string) | | fullname is the protobuf queryable name of the interface implementer |
| `type_url` | [string](#string) | | type_url defines the type URL used when marshalling the type as any this is required so we can provide type safe google.protobuf.Any marshalling and unmarshalling, making sure that we don't accept just 'any' type in our interface fields |
<a name="cosmos.base.reflection.v2alpha1.MsgDescriptor"></a>
### MsgDescriptor
MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `service_msg` | [ServiceMsgDescriptor](#cosmos.base.reflection.v2alpha1.ServiceMsgDescriptor) | | service_msg is used when the message is an sdk.ServiceMsg type |
<a name="cosmos.base.reflection.v2alpha1.QueryMethodDescriptor"></a>
### QueryMethodDescriptor
QueryMethodDescriptor describes a queryable method of a query service
no other info is provided beside method name and tendermint queryable path
because it would be redundant with the grpc reflection service
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | name is the protobuf name (not fullname) of the method |
| `full_query_path` | [string](#string) | | full_query_path is the path that can be used to query this method via tendermint abci.Query |
<a name="cosmos.base.reflection.v2alpha1.QueryServiceDescriptor"></a>
### QueryServiceDescriptor
QueryServiceDescriptor describes a cosmos-sdk queryable service
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fullname` | [string](#string) | | fullname is the protobuf fullname of the service descriptor |
| `is_module` | [bool](#bool) | | is_module describes if this service is actually exposed by an application's module |
| `methods` | [QueryMethodDescriptor](#cosmos.base.reflection.v2alpha1.QueryMethodDescriptor) | repeated | methods provides a list of query service methods |
<a name="cosmos.base.reflection.v2alpha1.QueryServicesDescriptor"></a>
### QueryServicesDescriptor
QueryServicesDescriptor contains the list of cosmos-sdk queriable services
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `query_services` | [QueryServiceDescriptor](#cosmos.base.reflection.v2alpha1.QueryServiceDescriptor) | repeated | query_services is a list of cosmos-sdk QueryServiceDescriptor |
<a name="cosmos.base.reflection.v2alpha1.ServiceMsgDescriptor"></a>
### ServiceMsgDescriptor
ServiceMsgDescriptor describes an sdk.ServiceMsg type
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `request_fullname` | [string](#string) | | request_fullname is the protobuf fullname of the given sdk.ServiceMsg request this is the protobuf message type which should be used as google.protobuf.Any.value when delivering the msg to the DeliverTx endpoint |
| `request_route` | [string](#string) | | request_route is the sdk.ServiceMsg route, it is equal to type_url |
| `request_type_url` | [string](#string) | | request_type_url is the identifier that should be used as google.protobuf.Any.type_url when delivering the msg to the DeliverTx endpoint |
| `response_fullname` | [string](#string) | | response_fullname is the protobuf fullname of the given sdk.ServiceMsg response |
<a name="cosmos.base.reflection.v2alpha1.SigningModeDescriptor"></a>
### SigningModeDescriptor
SigningModeDescriptor provides information on a signing flow of the application
NOTE(fdymylja): here we could go as far as providing an entire flow on how
to sign a message given a SigningModeDescriptor, but it's better to think about
this another time
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `name` | [string](#string) | | name defines the unique name of the signing mode |
| `number` | [int32](#int32) | | number is the unique int32 identifier for the sign_mode enum |
| `authn_info_provider_method_fullname` | [string](#string) | | authn_info_provider_method_fullname defines the fullname of the method to call to get the metadata required to authenticate using the provided sign_modes |
<a name="cosmos.base.reflection.v2alpha1.TxDescriptor"></a>
### TxDescriptor
TxDescriptor describes the accepted transaction type
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fullname` | [string](#string) | | fullname is the protobuf fullname of the raw transaction type (for instance the tx.Tx type) it is not meant to support polymorphism of transaction types, it is supposed to be used by reflection clients to understand if they can handle a specific transaction type in an application. |
| `msgs` | [MsgDescriptor](#cosmos.base.reflection.v2alpha1.MsgDescriptor) | repeated | msgs lists the accepted application messages (sdk.ServiceMsg, sdk.Msg) NOTE: not to be confused with proto.Message types |
<!-- end messages -->
<!-- end enums -->
<!-- end HasExtensions -->
<a name="cosmos.base.reflection.v2alpha1.ReflectionService"></a>
### ReflectionService
ReflectionService defines a service for application reflection.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `GetAuthnDescriptor` | [GetAuthnDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest) | [GetAuthnDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse) | GetAuthnDescriptor returns information on how to authenticate transactions in the application NOTE: this RPC is still experimental and might be subject to breaking changes or removal in future releases of the cosmos-sdk. | GET|/cosmos/base/reflection/v1beta1/app_descriptor/authn|
| `GetChainDescriptor` | [GetChainDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest) | [GetChainDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse) | GetChainDescriptor returns the description of the chain | GET|/cosmos/base/reflection/v1beta1/app_descriptor/chain|
| `GetCodecDescriptor` | [GetCodecDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest) | [GetCodecDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse) | GetCodecDescriptor returns the descriptor of the codec of the application | GET|/cosmos/base/reflection/v1beta1/app_descriptor/codec|
| `GetConfigurationDescriptor` | [GetConfigurationDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest) | [GetConfigurationDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse) | GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application | GET|/cosmos/base/reflection/v1beta1/app_descriptor/configuration|
| `GetQueryServicesDescriptor` | [GetQueryServicesDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest) | [GetQueryServicesDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse) | GetQueryServicesDescriptor returns the available gRPC queryable services of the application | GET|/cosmos/base/reflection/v1beta1/app_descriptor/query_services|
| `GetTxDescriptor` | [GetTxDescriptorRequest](#cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest) | [GetTxDescriptorResponse](#cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse) | GetTxDescriptor returns information on the used transaction object and available msgs that can be used | GET|/cosmos/base/reflection/v1beta1/app_descriptor/tx_descriptor|
<!-- end services -->
<a name="cosmos/base/snapshots/v1beta1/snapshot.proto"></a>
<p align="right"><a href="#top">Top</a></p>

View File

@ -17,7 +17,7 @@ service ReflectionService {
// interface.
rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/"
"{interface_name}/implementations";
"{interface_name}/implementations";
};
}
@ -41,4 +41,4 @@ message ListImplementationsRequest {
// RPC.
message ListImplementationsResponse {
repeated string implementation_message_names = 1;
}
}

View File

@ -0,0 +1,238 @@
syntax = "proto3";
package cosmos.base.reflection.v2alpha1;
import "google/api/annotations.proto";
option go_package = "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1";
// AppDescriptor describes a cosmos-sdk based application
message AppDescriptor {
// AuthnDescriptor provides information on how to authenticate transactions on the application
// NOTE: experimental and subject to change in future releases.
AuthnDescriptor authn = 1;
// chain provides the chain descriptor
ChainDescriptor chain = 2;
// codec provides metadata information regarding codec related types
CodecDescriptor codec = 3;
// configuration provides metadata information regarding the sdk.Config type
ConfigurationDescriptor configuration = 4;
// query_services provides metadata information regarding the available queriable endpoints
QueryServicesDescriptor query_services = 5;
// tx provides metadata information regarding how to send transactions to the given application
TxDescriptor tx = 6;
}
// TxDescriptor describes the accepted transaction type
message TxDescriptor {
// fullname is the protobuf fullname of the raw transaction type (for instance the tx.Tx type)
// it is not meant to support polymorphism of transaction types, it is supposed to be used by
// reflection clients to understand if they can handle a specific transaction type in an application.
string fullname = 1;
// msgs lists the accepted application messages (sdk.ServiceMsg, sdk.Msg)
// NOTE: not to be confused with proto.Message types
repeated MsgDescriptor msgs = 2;
}
// AuthnDescriptor provides information on how to sign transactions without relying
// on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures
message AuthnDescriptor {
// sign_modes defines the supported signature algorithm
repeated SigningModeDescriptor sign_modes = 1;
}
// SigningModeDescriptor provides information on a signing flow of the application
// NOTE(fdymylja): here we could go as far as providing an entire flow on how
// to sign a message given a SigningModeDescriptor, but it's better to think about
// this another time
message SigningModeDescriptor {
// name defines the unique name of the signing mode
string name = 1;
// number is the unique int32 identifier for the sign_mode enum
int32 number = 2;
// authn_info_provider_method_fullname defines the fullname of the method to call to get
// the metadata required to authenticate using the provided sign_modes
string authn_info_provider_method_fullname = 3;
}
// ChainDescriptor describes chain information of the application
message ChainDescriptor {
// id is the chain id
string id = 1;
}
// CodecDescriptor describes the registered interfaces and provides metadata information on the types
message CodecDescriptor {
// interfaces is a list of the registerted interfaces descriptors
repeated InterfaceDescriptor interfaces = 1;
}
// InterfaceDescriptor describes the implementation of an interface
message InterfaceDescriptor {
// fullname is the name of the interface
string fullname = 1;
// interface_accepting_messages contains information regarding the proto messages which contain the interface as google.protobuf.Any field
repeated InterfaceAcceptingMessageDescriptor interface_accepting_messages = 2;
// interface_implementers is a list of the descriptors of the interface implementers
repeated InterfaceImplementerDescriptor interface_implementers = 3;
}
// InterfaceImplementerDescriptor describes an interface implementer
message InterfaceImplementerDescriptor {
// fullname is the protobuf queryable name of the interface implementer
string fullname = 1;
// type_url defines the type URL used when marshalling the type as any
// this is required so we can provide type safe google.protobuf.Any marshalling and
// unmarshalling, making sure that we don't accept just 'any' type
// in our interface fields
string type_url = 2;
}
// InterfaceAcceptingMessageDescriptor describes a protobuf message which contains
// an interface represented as a google.protobuf.Any
message InterfaceAcceptingMessageDescriptor {
// fullname is the protobuf fullname of the type containing the interface
string fullname = 1;
// field_descriptor_names is a list of the protobuf name (not fullname) of the field
// which contains the interface as google.protobuf.Any (the interface is the same, but
// it can be in multiple fields of the same proto message)
repeated string field_descriptor_names = 2;
}
// ConfigurationDescriptor contains metadata information on the sdk.Config
message ConfigurationDescriptor {
// bech32_account_address_prefix is the account address prefix
string bech32_account_address_prefix = 1;
}
// MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction
message MsgDescriptor {
// msg contains a descriptor of sdk.ServiceMsg, note: sdk.Msg is not supported
// as every sdk.Msg is already an sdk.ServiceMsg. It is defined as a oneof in case
// different representation of a msg will be implemented.
oneof msg {
// service_msg is used when the message is an sdk.ServiceMsg type
ServiceMsgDescriptor service_msg = 1;
}
}
// ServiceMsgDescriptor describes an sdk.ServiceMsg type
message ServiceMsgDescriptor {
// request_fullname is the protobuf fullname of the given sdk.ServiceMsg request
// this is the protobuf message type which should be used as google.protobuf.Any.value
// when delivering the msg to the DeliverTx endpoint
string request_fullname = 1;
// request_route is the sdk.ServiceMsg route, it is equal to type_url
string request_route = 2;
// request_type_url is the identifier that should be used as google.protobuf.Any.type_url
// when delivering the msg to the DeliverTx endpoint
string request_type_url = 3;
// response_fullname is the protobuf fullname of the given sdk.ServiceMsg response
string response_fullname = 4;
}
// ReflectionService defines a service for application reflection.
service ReflectionService {
// GetAuthnDescriptor returns information on how to authenticate transactions in the application
// NOTE: this RPC is still experimental and might be subject to breaking changes or removal in
// future releases of the cosmos-sdk.
rpc GetAuthnDescriptor(GetAuthnDescriptorRequest) returns (GetAuthnDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/authn";
}
// GetChainDescriptor returns the description of the chain
rpc GetChainDescriptor(GetChainDescriptorRequest) returns (GetChainDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/chain";
};
// GetCodecDescriptor returns the descriptor of the codec of the application
rpc GetCodecDescriptor(GetCodecDescriptorRequest) returns (GetCodecDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/codec";
}
// GetConfigurationDescriptor returns the descriptor for the sdk.Config of the application
rpc GetConfigurationDescriptor(GetConfigurationDescriptorRequest) returns (GetConfigurationDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/configuration";
}
// GetQueryServicesDescriptor returns the available gRPC queryable services of the application
rpc GetQueryServicesDescriptor(GetQueryServicesDescriptorRequest) returns (GetQueryServicesDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/query_services";
}
// GetTxDescriptor returns information on the used transaction object and available msgs that can be used
rpc GetTxDescriptor(GetTxDescriptorRequest) returns (GetTxDescriptorResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/app_descriptor/tx_descriptor";
}
}
// GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC
message GetAuthnDescriptorRequest {}
// GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC
message GetAuthnDescriptorResponse {
// authn describes how to authenticate to the application when sending transactions
AuthnDescriptor authn = 1;
}
// GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC
message GetChainDescriptorRequest {}
// GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC
message GetChainDescriptorResponse {
// chain describes application chain information
ChainDescriptor chain = 1;
}
// GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC
message GetCodecDescriptorRequest {}
// GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC
message GetCodecDescriptorResponse {
// codec describes the application codec such as registered interfaces and implementations
CodecDescriptor codec = 1;
}
// GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC
message GetConfigurationDescriptorRequest {}
// GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC
message GetConfigurationDescriptorResponse {
// config describes the application's sdk.Config
ConfigurationDescriptor config = 1;
}
// GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC
message GetQueryServicesDescriptorRequest {}
// GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC
message GetQueryServicesDescriptorResponse {
// queries provides information on the available queryable services
QueryServicesDescriptor queries = 1;
}
// GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC
message GetTxDescriptorRequest {}
// GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC
message GetTxDescriptorResponse {
// tx provides information on msgs that can be forwarded to the application
// alongside the accepted transaction protobuf type
TxDescriptor tx = 1;
}
// QueryServicesDescriptor contains the list of cosmos-sdk queriable services
message QueryServicesDescriptor {
// query_services is a list of cosmos-sdk QueryServiceDescriptor
repeated QueryServiceDescriptor query_services = 1;
}
// QueryServiceDescriptor describes a cosmos-sdk queryable service
message QueryServiceDescriptor {
// fullname is the protobuf fullname of the service descriptor
string fullname = 1;
// is_module describes if this service is actually exposed by an application's module
bool is_module = 2;
// methods provides a list of query service methods
repeated QueryMethodDescriptor methods = 3;
}
// QueryMethodDescriptor describes a queryable method of a query service
// no other info is provided beside method name and tendermint queryable path
// because it would be redundant with the grpc reflection service
message QueryMethodDescriptor {
// name is the protobuf name (not fullname) of the method
string name = 1;
// full_query_path is the path that can be used to query
// this method via tendermint abci.Query
string full_query_path = 2;
}

View File

@ -0,0 +1,217 @@
package v2alpha1
import (
"context"
"fmt"
"github.com/gogo/protobuf/proto"
"google.golang.org/grpc"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
)
type Config struct {
SigningModes map[string]int32
ChainID string
SdkConfig *sdk.Config
InterfaceRegistry codectypes.InterfaceRegistry
}
// Register registers the cosmos sdk reflection service
// to the provided *grpc.Server given a Config
func Register(srv *grpc.Server, conf Config) error {
reflectionServer, err := newReflectionServiceServer(srv, conf)
if err != nil {
return err
}
RegisterReflectionServiceServer(srv, reflectionServer)
return nil
}
type reflectionServiceServer struct {
desc *AppDescriptor
}
func (r reflectionServiceServer) GetAuthnDescriptor(_ context.Context, _ *GetAuthnDescriptorRequest) (*GetAuthnDescriptorResponse, error) {
return &GetAuthnDescriptorResponse{Authn: r.desc.Authn}, nil
}
func (r reflectionServiceServer) GetChainDescriptor(_ context.Context, _ *GetChainDescriptorRequest) (*GetChainDescriptorResponse, error) {
return &GetChainDescriptorResponse{Chain: r.desc.Chain}, nil
}
func (r reflectionServiceServer) GetCodecDescriptor(_ context.Context, _ *GetCodecDescriptorRequest) (*GetCodecDescriptorResponse, error) {
return &GetCodecDescriptorResponse{Codec: r.desc.Codec}, nil
}
func (r reflectionServiceServer) GetConfigurationDescriptor(_ context.Context, _ *GetConfigurationDescriptorRequest) (*GetConfigurationDescriptorResponse, error) {
return &GetConfigurationDescriptorResponse{Config: r.desc.Configuration}, nil
}
func (r reflectionServiceServer) GetQueryServicesDescriptor(_ context.Context, _ *GetQueryServicesDescriptorRequest) (*GetQueryServicesDescriptorResponse, error) {
return &GetQueryServicesDescriptorResponse{Queries: r.desc.QueryServices}, nil
}
func (r reflectionServiceServer) GetTxDescriptor(_ context.Context, _ *GetTxDescriptorRequest) (*GetTxDescriptorResponse, error) {
return &GetTxDescriptorResponse{Tx: r.desc.Tx}, nil
}
func newReflectionServiceServer(grpcSrv *grpc.Server, conf Config) (reflectionServiceServer, error) {
// set chain descriptor
chainDescriptor := &ChainDescriptor{Id: conf.ChainID}
// set configuration descriptor
configurationDescriptor := &ConfigurationDescriptor{
Bech32AccountAddressPrefix: conf.SdkConfig.GetBech32AccountAddrPrefix(),
}
// set codec descriptor
codecDescriptor, err := newCodecDescriptor(conf.InterfaceRegistry)
if err != nil {
return reflectionServiceServer{}, fmt.Errorf("unable to create codec descriptor: %w", err)
}
// set query service descriptor
queryServiceDescriptor := newQueryServiceDescriptor(grpcSrv)
// set deliver descriptor
txDescriptor, err := newTxDescriptor(conf.InterfaceRegistry)
if err != nil {
return reflectionServiceServer{}, fmt.Errorf("unable to create deliver descriptor: %w", err)
}
authnDescriptor := newAuthnDescriptor(conf.SigningModes)
desc := &AppDescriptor{
Authn: authnDescriptor,
Chain: chainDescriptor,
Codec: codecDescriptor,
Configuration: configurationDescriptor,
QueryServices: queryServiceDescriptor,
Tx: txDescriptor,
}
ifaceList := make([]string, len(desc.Codec.Interfaces))
ifaceImplementers := make(map[string][]string, len(desc.Codec.Interfaces))
for i, iface := range desc.Codec.Interfaces {
ifaceList[i] = iface.Fullname
impls := make([]string, len(iface.InterfaceImplementers))
for j, impl := range iface.InterfaceImplementers {
impls[j] = impl.TypeUrl
}
ifaceImplementers[iface.Fullname] = impls
}
return reflectionServiceServer{
desc: desc,
}, nil
}
// newCodecDescriptor describes the codec given the codectypes.InterfaceRegistry
func newCodecDescriptor(ir codectypes.InterfaceRegistry) (*CodecDescriptor, error) {
registeredInterfaces := ir.ListAllInterfaces()
interfaceDescriptors := make([]*InterfaceDescriptor, len(registeredInterfaces))
for i, iface := range registeredInterfaces {
implementers := ir.ListImplementations(iface)
interfaceImplementers := make([]*InterfaceImplementerDescriptor, len(implementers))
for j, implementer := range implementers {
pb, err := ir.Resolve(implementer)
if err != nil {
return nil, fmt.Errorf("unable to resolve implementing type %s for interface %s", implementer, iface)
}
pbName := proto.MessageName(pb)
if pbName == "" {
return nil, fmt.Errorf("unable to get proto name for implementing type %s for interface %s", implementer, iface)
}
interfaceImplementers[j] = &InterfaceImplementerDescriptor{
Fullname: pbName,
TypeUrl: implementer,
}
}
interfaceDescriptors[i] = &InterfaceDescriptor{
Fullname: iface,
// NOTE(fdymylja): this could be filled, but it won't be filled as of now
// doing this would require us to fully rebuild in a (dependency) transitive way the proto
// registry of the supported proto.Messages for the application, this could be easily
// done if we weren't relying on gogoproto which does not allow us to iterate over the
// registry. Achieving this right now would mean to start slowly building descriptors
// getting their files dependencies, building those dependencies then rebuilding the
// descriptor builder. It's too much work as of now.
InterfaceAcceptingMessages: nil,
InterfaceImplementers: interfaceImplementers,
}
}
return &CodecDescriptor{
Interfaces: interfaceDescriptors,
}, nil
}
func newQueryServiceDescriptor(srv *grpc.Server) *QueryServicesDescriptor {
svcInfo := srv.GetServiceInfo()
queryServices := make([]*QueryServiceDescriptor, 0, len(svcInfo))
for name, info := range svcInfo {
methods := make([]*QueryMethodDescriptor, len(info.Methods))
for i, svcMethod := range info.Methods {
methods[i] = &QueryMethodDescriptor{
Name: svcMethod.Name,
FullQueryPath: fmt.Sprintf("/%s/%s", name, svcMethod.Name),
}
}
queryServices = append(queryServices, &QueryServiceDescriptor{
Fullname: name,
Methods: methods,
})
}
return &QueryServicesDescriptor{QueryServices: queryServices}
}
func newTxDescriptor(ir codectypes.InterfaceRegistry) (*TxDescriptor, error) {
// get base tx type name
txPbName := proto.MessageName(&tx.Tx{})
if txPbName == "" {
return nil, fmt.Errorf("unable to get *tx.Tx protobuf name")
}
// get msgs
svcMsgImplementers := ir.ListImplementations(sdk.ServiceMsgInterfaceProtoName)
msgsDesc := make([]*MsgDescriptor, 0, len(svcMsgImplementers))
// process sdk.ServiceMsg
for _, svcMsg := range svcMsgImplementers {
resolved, err := ir.Resolve(svcMsg)
if err != nil {
return nil, fmt.Errorf("unable to resolve sdk.ServiceMsg %s: %w", svcMsg, err)
}
pbName := proto.MessageName(resolved)
if pbName == "" {
return nil, fmt.Errorf("unable to get proto name for sdk.ServiceMsg %s", svcMsg)
}
msgsDesc = append(msgsDesc, &MsgDescriptor{Msg: &MsgDescriptor_ServiceMsg{
ServiceMsg: &ServiceMsgDescriptor{
RequestFullname: pbName,
RequestRoute: svcMsg,
RequestTypeUrl: svcMsg,
// NOTE(fdymylja): this cannot be filled as of now, the Configurator is not held inside the *BaseApp type
// but is local to specific applications, hence we have no way of getting the MsgServer's descriptors
// which contain response information.
ResponseFullname: "",
},
}})
}
return &TxDescriptor{
Fullname: txPbName,
Msgs: msgsDesc,
}, nil
}
func newAuthnDescriptor(signingModes map[string]int32) *AuthnDescriptor {
signModesDesc := make([]*SigningModeDescriptor, 0, len(signingModes))
for i, m := range signingModes {
signModesDesc = append(signModesDesc, &SigningModeDescriptor{
Name: i,
Number: m,
// NOTE(fdymylja): this cannot be filled as of now, auth and the sdk itself don't support as of now
// a service which allows to get authentication metadata for the provided sign mode.
AuthnInfoProviderMethodFullname: "",
})
}
return &AuthnDescriptor{SignModes: signModesDesc}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,458 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: cosmos/base/reflection/v2alpha1/reflection.proto
/*
Package v2alpha1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package v2alpha1
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
func request_ReflectionService_GetAuthnDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetAuthnDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetAuthnDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetAuthnDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetAuthnDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetAuthnDescriptor(ctx, &protoReq)
return msg, metadata, err
}
func request_ReflectionService_GetChainDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetChainDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetChainDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetChainDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetChainDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetChainDescriptor(ctx, &protoReq)
return msg, metadata, err
}
func request_ReflectionService_GetCodecDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetCodecDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetCodecDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetCodecDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetCodecDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetCodecDescriptor(ctx, &protoReq)
return msg, metadata, err
}
func request_ReflectionService_GetConfigurationDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetConfigurationDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetConfigurationDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetConfigurationDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetConfigurationDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetConfigurationDescriptor(ctx, &protoReq)
return msg, metadata, err
}
func request_ReflectionService_GetQueryServicesDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetQueryServicesDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetQueryServicesDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetQueryServicesDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetQueryServicesDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetQueryServicesDescriptor(ctx, &protoReq)
return msg, metadata, err
}
func request_ReflectionService_GetTxDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, client ReflectionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetTxDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := client.GetTxDescriptor(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_ReflectionService_GetTxDescriptor_0(ctx context.Context, marshaler runtime.Marshaler, server ReflectionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetTxDescriptorRequest
var metadata runtime.ServerMetadata
msg, err := server.GetTxDescriptor(ctx, &protoReq)
return msg, metadata, err
}
// RegisterReflectionServiceHandlerServer registers the http handlers for service ReflectionService to "mux".
// UnaryRPC :call ReflectionServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterReflectionServiceHandlerFromEndpoint instead.
func RegisterReflectionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ReflectionServiceServer) error {
mux.Handle("GET", pattern_ReflectionService_GetAuthnDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetAuthnDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetAuthnDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetChainDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetChainDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetChainDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetCodecDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetCodecDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetCodecDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetConfigurationDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetConfigurationDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetConfigurationDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetQueryServicesDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetQueryServicesDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetQueryServicesDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetTxDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_ReflectionService_GetTxDescriptor_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetTxDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterReflectionServiceHandlerFromEndpoint is same as RegisterReflectionServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterReflectionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterReflectionServiceHandler(ctx, mux, conn)
}
// RegisterReflectionServiceHandler registers the http handlers for service ReflectionService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterReflectionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterReflectionServiceHandlerClient(ctx, mux, NewReflectionServiceClient(conn))
}
// RegisterReflectionServiceHandlerClient registers the http handlers for service ReflectionService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ReflectionServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ReflectionServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "ReflectionServiceClient" to call the correct interceptors.
func RegisterReflectionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ReflectionServiceClient) error {
mux.Handle("GET", pattern_ReflectionService_GetAuthnDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetAuthnDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetAuthnDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetChainDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetChainDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetChainDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetCodecDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetCodecDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetCodecDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetConfigurationDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetConfigurationDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetConfigurationDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetQueryServicesDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetQueryServicesDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetQueryServicesDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_ReflectionService_GetTxDescriptor_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_ReflectionService_GetTxDescriptor_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_ReflectionService_GetTxDescriptor_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_ReflectionService_GetAuthnDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "authn"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_ReflectionService_GetChainDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "chain"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_ReflectionService_GetCodecDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "codec"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_ReflectionService_GetConfigurationDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "configuration"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_ReflectionService_GetQueryServicesDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "query_services"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_ReflectionService_GetTxDescriptor_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "reflection", "v1beta1", "app_descriptor", "tx_descriptor"}, "", runtime.AssumeColonVerbOpt(false)))
)
var (
forward_ReflectionService_GetAuthnDescriptor_0 = runtime.ForwardResponseMessage
forward_ReflectionService_GetChainDescriptor_0 = runtime.ForwardResponseMessage
forward_ReflectionService_GetCodecDescriptor_0 = runtime.ForwardResponseMessage
forward_ReflectionService_GetConfigurationDescriptor_0 = runtime.ForwardResponseMessage
forward_ReflectionService_GetQueryServicesDescriptor_0 = runtime.ForwardResponseMessage
forward_ReflectionService_GetTxDescriptor_0 = runtime.ForwardResponseMessage
)

View File

@ -9,18 +9,35 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server/grpc/gogoreflection"
reflection "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1"
"github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// StartGRPCServer starts a gRPC server on the given address.
func StartGRPCServer(clientCtx client.Context, app types.Application, address string) (*grpc.Server, error) {
grpcSrv := grpc.NewServer()
app.RegisterGRPCServer(clientCtx, grpcSrv)
// reflection allows consumers to build dynamic clients that can write
// to any cosmos-sdk application without relying on application packages at compile time
err := reflection.Register(grpcSrv, reflection.Config{
SigningModes: func() map[string]int32 {
modes := make(map[string]int32, len(clientCtx.TxConfig.SignModeHandler().Modes()))
for _, m := range clientCtx.TxConfig.SignModeHandler().Modes() {
modes[m.String()] = (int32)(m)
}
return modes
}(),
ChainID: clientCtx.ChainID,
SdkConfig: sdk.GetConfig(),
InterfaceRegistry: clientCtx.InterfaceRegistry,
})
if err != nil {
return nil, err
}
// Reflection allows external clients to see what services and methods
// the gRPC server exposes.
gogoreflection.Register(grpcSrv)
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, err

View File

@ -16,6 +16,8 @@ import (
"google.golang.org/grpc/metadata"
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
reflectionv1 "github.com/cosmos/cosmos-sdk/client/grpc/reflection"
reflectionv2 "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1"
"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -120,6 +122,29 @@ func (s *IntegrationTestSuite) TestGRPCServer_Reflection() {
}
}
func (s *IntegrationTestSuite) TestGRPCServer_InterfaceReflection() {
// this tests the application reflection capabilities and compatibility between v1 and v2
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
clientV2 := reflectionv2.NewReflectionServiceClient(s.conn)
clientV1 := reflectionv1.NewReflectionServiceClient(s.conn)
codecDesc, err := clientV2.GetCodecDescriptor(ctx, nil)
s.Require().NoError(err)
interfaces, err := clientV1.ListAllInterfaces(ctx, nil)
s.Require().NoError(err)
s.Require().Equal(len(codecDesc.Codec.Interfaces), len(interfaces.InterfaceNames))
s.Require().Equal(len(s.cfg.InterfaceRegistry.ListAllInterfaces()), len(codecDesc.Codec.Interfaces))
for _, iface := range interfaces.InterfaceNames {
impls, err := clientV1.ListImplementations(ctx, &reflectionv1.ListImplementationsRequest{InterfaceName: iface})
s.Require().NoError(err)
s.Require().ElementsMatch(impls.ImplementationMessageNames, s.cfg.InterfaceRegistry.ListImplementations(iface))
}
}
func (s *IntegrationTestSuite) TestGRPCServer_GetTxsEvent() {
// Query the tx via gRPC without pagination. This used to panic, see
// https://github.com/cosmos/cosmos-sdk/issues/8038.

View File

@ -118,7 +118,7 @@ func NewConverter(cdc *codec.ProtoCodec, ir codectypes.InterfaceRegistry, cfg sd
txDecode: cfg.TxDecoder(),
txEncode: cfg.TxEncoder(),
bytesToSign: func(tx authsigning.Tx, signerData authsigning.SignerData) (b []byte, err error) {
bytesToSign, err := cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx) //nolint:staticcheck
bytesToSign, err := cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
if err != nil {
return nil, err
}
@ -662,7 +662,7 @@ func (c converter) SignedTx(txBytes []byte, signatures []*rosettatypes.Signature
signedSigs[i] = signing.SignatureV2{
PubKey: notSignedSigs[i].PubKey,
Data: &signing.SingleSignatureData{
SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, //nolint:staticcheck
SignMode: signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
Signature: signature.Bytes,
},
Sequence: notSignedSigs[i].Sequence,

View File

@ -11,12 +11,13 @@ import (
yaml "gopkg.in/yaml.v2"
"github.com/hashicorp/golang-lru/simplelru"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/internal/conv"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/bech32"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/hashicorp/golang-lru/simplelru"
)
const (

View File

@ -6,8 +6,9 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/types"
)
// generates AccAddress with `prefix` and calls String method

View File

@ -5,13 +5,12 @@ package signing
import (
fmt "fmt"
io "io"
math "math"
math_bits "math/bits"
types "github.com/cosmos/cosmos-sdk/codec/types"
types1 "github.com/cosmos/cosmos-sdk/crypto/types"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
@ -39,7 +38,7 @@ const (
// human-readable textual representation on top of the binary representation
// from SIGN_MODE_DIRECT
SignMode_SIGN_MODE_TEXTUAL SignMode = 2
// Deprecated: SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses
// Amino JSON and will be removed in the future
SignMode_SIGN_MODE_LEGACY_AMINO_JSON SignMode = 127
)

View File

@ -186,7 +186,7 @@ func NewSigVerificationDecorator(ak AccountKeeper, signModeHandler authsigning.S
func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool {
switch v := sigData.(type) {
case *signing.SingleSignatureData:
return v.SignMode == signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON //nolint:staticcheck
return v.SignMode == signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
case *signing.MultiSignatureData:
for _, s := range v.Signatures {
if !OnlyLegacyAminoSigners(s) {

View File

@ -77,7 +77,7 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags())
if txFactory.SignMode() == signingtypes.SignMode_SIGN_MODE_UNSPECIFIED {
txFactory = txFactory.WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) //nolint:staticcheck
txFactory = txFactory.WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
}
txCfg := clientCtx.TxConfig
@ -235,7 +235,7 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error {
txCfg := clientCtx.TxConfig
txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags())
if txFactory.SignMode() == signingtypes.SignMode_SIGN_MODE_UNSPECIFIED {
txFactory = txFactory.WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) //nolint:staticcheck
txFactory = txFactory.WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
}
var infile = os.Stdin

View File

@ -48,7 +48,7 @@ func SignTx(txFactory tx.Factory, clientCtx client.Context, name string, txBuild
// Ledger and Multisigs only support LEGACY_AMINO_JSON signing.
if txFactory.SignMode() == signing.SignMode_SIGN_MODE_UNSPECIFIED &&
(info.GetType() == keyring.TypeLedger || info.GetType() == keyring.TypeMulti) {
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) //nolint:staticcheck
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
}
addr := sdk.AccAddress(info.GetPubKey().Address())
@ -74,7 +74,7 @@ func SignTxWithSignerAddress(txFactory tx.Factory, clientCtx client.Context, add
name string, txBuilder client.TxBuilder, offline, overwrite bool) (err error) {
// Multisigs only support LEGACY_AMINO_JSON signing.
if txFactory.SignMode() == signing.SignMode_SIGN_MODE_UNSPECIFIED {
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) //nolint:staticcheck
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
}
// check whether the address is a signer

View File

@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"gopkg.in/yaml.v2"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -12,7 +14,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"gopkg.in/yaml.v2"
)
// StdSignDoc is replay-prevention structure.

View File

@ -226,7 +226,7 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() {
sig := signingtypes.SignatureV2{
PubKey: pubkey,
Data: &signingtypes.SingleSignatureData{
SignMode: signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, //nolint:staticcheck
SignMode: signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
Signature: dummySig,
},
}

View File

@ -10,7 +10,7 @@ import (
// DefaultSignModes are the default sign modes enabled for protobuf transactions.
var DefaultSignModes = []signingtypes.SignMode{
signingtypes.SignMode_SIGN_MODE_DIRECT,
signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, //nolint:staticcheck
signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON,
}
// makeSignModeHandler returns the default protobuf SignModeHandler supporting
@ -26,7 +26,7 @@ func makeSignModeHandler(modes []signingtypes.SignMode) signing.SignModeHandler
switch mode {
case signingtypes.SignMode_SIGN_MODE_DIRECT:
handlers[i] = signModeDirectHandler{}
case signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON: //nolint:staticcheck
case signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON:
handlers[i] = signModeLegacyAminoJSONHandler{}
default:
panic(fmt.Errorf("unsupported sign mode %+v", mode))

View File

@ -31,7 +31,8 @@ type GenesisState struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// balances is an array containing the balances of all the accounts.
Balances []Balance `protobuf:"bytes,2,rep,name=balances,proto3" json:"balances"`
// supply represents the total supply.
// supply represents the total supply. If it is left empty, then supply will be calculated based on the provided
// balances. Otherwise, it will be used to validate that the sum of the balances equals this amount.
Supply github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=supply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"supply"`
// denom_metadata defines the metadata of the differents coins.
DenomMetadata []Metadata `protobuf:"bytes,4,rep,name=denom_metadata,json=denomMetadata,proto3" json:"denom_metadata" yaml:"denom_metadata"`

File diff suppressed because it is too large Load Diff