refactor(server)!: remove duplicate bech32 prefix endpoint (#18909)
This commit is contained in:
parent
e1e8c46c21
commit
b720cc7302
@ -187,6 +187,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/auth) [#18351](https://github.com/cosmos/cosmos-sdk/pull/18351) Auth module was moved to its own go.mod `cosmossdk.io/x/auth`
|
||||
* (types) [#18372](https://github.com/cosmos/cosmos-sdk/pull/18372) Removed global configuration for coin type and purpose. Setters and getters should be removed and access directly to defined types.
|
||||
* (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder.
|
||||
* (server) [#18909](https://github.com/cosmos/cosmos-sdk/pull/18909) Remove configuration endpoint on grpc reflection endpoint in favour of auth module bech32prefix endpoint already exposed.
|
||||
|
||||
### CLI Breaking Changes
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package v2alpha1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
@ -15,7 +16,6 @@ import (
|
||||
type Config struct {
|
||||
SigningModes map[string]int32
|
||||
ChainID string
|
||||
SdkConfig *sdk.Config
|
||||
InterfaceRegistry codectypes.InterfaceRegistry
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ func (r reflectionServiceServer) GetCodecDescriptor(_ context.Context, _ *GetCod
|
||||
}
|
||||
|
||||
func (r reflectionServiceServer) GetConfigurationDescriptor(_ context.Context, _ *GetConfigurationDescriptorRequest) (*GetConfigurationDescriptorResponse, error) {
|
||||
return &GetConfigurationDescriptorResponse{Config: r.desc.Configuration}, nil
|
||||
return nil, errors.New("this endpoint has been depreacted, please see auth/Bech32Prefix for the data you are seeking")
|
||||
}
|
||||
|
||||
func (r reflectionServiceServer) GetQueryServicesDescriptor(_ context.Context, _ *GetQueryServicesDescriptorRequest) (*GetQueryServicesDescriptorResponse, error) {
|
||||
@ -61,10 +61,7 @@ func (r reflectionServiceServer) GetTxDescriptor(_ context.Context, _ *GetTxDesc
|
||||
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 {
|
||||
@ -82,7 +79,6 @@ func newReflectionServiceServer(grpcSrv *grpc.Server, conf Config) (reflectionSe
|
||||
Authn: authnDescriptor,
|
||||
Chain: chainDescriptor,
|
||||
Codec: codecDescriptor,
|
||||
Configuration: configurationDescriptor,
|
||||
QueryServices: queryServiceDescriptor,
|
||||
Tx: txDescriptor,
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ import (
|
||||
"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"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino" // Import amino.proto file for reflection
|
||||
)
|
||||
|
||||
@ -54,7 +53,6 @@ func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.G
|
||||
return modes
|
||||
}(),
|
||||
ChainID: clientCtx.ChainID,
|
||||
SdkConfig: sdk.GetConfig(),
|
||||
InterfaceRegistry: clientCtx.InterfaceRegistry,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@ -17,8 +17,8 @@ import (
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
|
||||
authv1betav1 "cosmossdk.io/api/cosmos/auth/v1beta1"
|
||||
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
|
||||
reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1"
|
||||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
|
||||
"cosmossdk.io/tools/hubl/internal/config"
|
||||
)
|
||||
@ -188,15 +188,15 @@ func (c *ChainInfo) OpenClient() (*grpc.ClientConn, error) {
|
||||
|
||||
// getAddressPrefix returns the address prefix of the chain.
|
||||
func getAddressPrefix(ctx context.Context, conn grpc.ClientConnInterface) (string, error) {
|
||||
reflectionClient := reflectionv2alpha1.NewReflectionServiceClient(conn)
|
||||
resp, err := reflectionClient.GetConfigurationDescriptor(ctx, &reflectionv2alpha1.GetConfigurationDescriptorRequest{})
|
||||
authClient := authv1betav1.NewQueryClient(conn)
|
||||
resp, err := authClient.Bech32Prefix(ctx, &authv1betav1.Bech32PrefixRequest{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if resp == nil || resp.Config == nil || resp.Config.Bech32AccountAddressPrefix == "" {
|
||||
if resp == nil || resp.Bech32Prefix == "" {
|
||||
return "", cockroachdberrors.New("bech32 account address prefix is not set")
|
||||
}
|
||||
|
||||
return resp.Config.Bech32AccountAddressPrefix, nil
|
||||
return resp.Bech32Prefix, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user