Implement gRPC Simulate endpoint (#7035)
* Implement simulate endpoint * Add GetProtoTx() * Add signing in test * Add txBuilderFromProto * Remove stray println * Update to master * Merge master * Fix tests * Make tests pass * Integrate in router * Make proto-gen * Fix lint * Really fix lint * Refactor to fix import cycles * Rename builder -> wrapper * Update proto/cosmos/base/reflection/v1beta1/reflection.proto * Fix after merge * t->w Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Alexander Bezobchuk
parent
b6760ff1a9
commit
3d969a1ffd
+21
-6
@@ -10,7 +10,9 @@ import (
|
||||
"google.golang.org/grpc/encoding/proto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/reflection"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@@ -19,7 +21,7 @@ var protoCodec = encoding.GetCodec(proto.Name)
|
||||
// GRPCQueryRouter routes ABCI Query requests to GRPC handlers
|
||||
type GRPCQueryRouter struct {
|
||||
routes map[string]GRPCQueryHandler
|
||||
interfaceRegistry types.InterfaceRegistry
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
serviceData []serviceData
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf
|
||||
return err
|
||||
}
|
||||
if qrt.interfaceRegistry != nil {
|
||||
return types.UnpackInterfaces(i, qrt.interfaceRegistry)
|
||||
return codectypes.UnpackInterfaces(i, qrt.interfaceRegistry)
|
||||
}
|
||||
return nil
|
||||
}, nil)
|
||||
@@ -97,14 +99,27 @@ func (qrt *GRPCQueryRouter) RegisterService(sd *grpc.ServiceDesc, handler interf
|
||||
})
|
||||
}
|
||||
|
||||
// SetInterfaceRegistry sets the interface registry for the router.
|
||||
func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry types.InterfaceRegistry) {
|
||||
// SetInterfaceRegistry sets the interface registry for the router. This will
|
||||
// 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(
|
||||
qrt,
|
||||
reflection.NewReflectionServiceServer(qrt.interfaceRegistry),
|
||||
reflection.NewReflectionServiceServer(interfaceRegistry),
|
||||
)
|
||||
}
|
||||
|
||||
// RegisterSimulateService registers the simulate service on the gRPC router.
|
||||
func (qrt *GRPCQueryRouter) RegisterSimulateService(
|
||||
simulateFn simulate.BaseAppSimulateFn,
|
||||
interfaceRegistry codectypes.InterfaceRegistry,
|
||||
pubkeyCodec cryptotypes.PublicKeyCodec,
|
||||
) {
|
||||
simulate.RegisterSimulateServiceServer(
|
||||
qrt,
|
||||
simulate.NewSimulateServer(simulateFn, qrt.interfaceRegistry, pubkeyCodec),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user