Skip to content

Commit

Permalink
Add GetTx gRPC endpoint (cosmos#7688)
Browse files Browse the repository at this point in the history
* Add empty TxByHash

* Fix search & replace

* Renname to GetTx

* Make getTx grpc work

* Hash as string

* Add todo comment

* /tx

* Make tests pass

* Put into function

* Add changelog

* Fix lint

* RegisterTxService in server

* Remove comment

* Update proto/cosmos/tx/v1beta1/service.proto

Co-authored-by: Cory <cjlevinson@gmail.com>

* Create new protoCdc

* Move tx service to x/auth

* Small tweaks

* Link gh issue

* Fix lint

* Update x/auth/tx/service.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

Co-authored-by: Cory <cjlevinson@gmail.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
  • Loading branch information
5 people authored Oct 30, 2020
1 parent 80f5c94 commit e051213
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -32,6 +33,7 @@ import (
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
Expand Down Expand Up @@ -134,7 +136,10 @@ var (
}
)

var _ App = (*SimApp)(nil)
var (
_ App = (*SimApp)(nil)
_ servertypes.Application = (*SimApp)(nil)
)

// SimApp extends an ABCI application, but with most of its parameters exported.
// They are exported for convenience in creating helper functions, as object
Expand Down Expand Up @@ -204,7 +209,6 @@ func NewSimApp(
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetAppVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
bApp.GRPCQueryRouter().RegisterSimulateService(bApp.Simulate, interfaceRegistry)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
Expand Down Expand Up @@ -544,17 +548,26 @@ func (app *SimApp) SimulationManager() *module.SimulationManager {
func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(apiSvr.ClientCtx, apiSvr.GRPCRouter)
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
RegisterSwaggerAPI(clientCtx, apiSvr.Router)
}
}

// RegisterTxService implements the Application.RegisterTxService method.
func (app *SimApp) RegisterTxService(clientCtx client.Context) {
authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry)
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
Expand Down

0 comments on commit e051213

Please sign in to comment.