Skip to content

Commit e4a49c8

Browse files
fix for LCD calls
1 parent 8fcf934 commit e4a49c8

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

app/app.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
context "context"
88
"fmt"
99
"io"
10+
"net/http"
1011
"os"
12+
"strings"
1113

1214
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
1315
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
@@ -544,6 +546,12 @@ func NewArkeoApp(
544546
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
545547
})
546548

549+
// general v1.0.17.1 upgrade handler
550+
app.Keepers.UpgradeKeeper.SetUpgradeHandler("general-v1.0.17.1", func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
551+
app.Logger().Info("running general-v1.0.17.1 upgrade")
552+
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
553+
})
554+
547555
groupConfig := group.DefaultConfig()
548556
/*
549557
Example of setting group params:
@@ -1044,6 +1052,23 @@ func (app *ArkeoApp) GetSubspace(moduleName string) paramstypes.Subspace {
10441052
// RegisterAPIRoutes registers all application module routes with the provided
10451053
// API server.
10461054
func (app *ArkeoApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
1055+
// Legacy LCD compat: map ?events=... to ?query=...
1056+
apiSvr.Router.Use(func(next http.Handler) http.Handler {
1057+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1058+
if r.URL.Path == "/cosmos/tx/v1beta1/txs" {
1059+
q := r.URL.Query()
1060+
if q.Get("query") == "" {
1061+
if evs, ok := q["events"]; ok && len(evs) > 0 {
1062+
q.Set("query", strings.Join(evs, " AND "))
1063+
q.Del("events")
1064+
r.URL.RawQuery = q.Encode()
1065+
}
1066+
}
1067+
}
1068+
next.ServeHTTP(w, r)
1069+
})
1070+
})
1071+
10471072
clientCtx := apiSvr.ClientCtx
10481073
// Register new tx routes from grpc-gateway.
10491074
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

app/app_regtest.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"net/http"
10+
"strings"
1011

1112
clienthelpers "cosmossdk.io/client/v2/helpers"
1213
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
@@ -918,6 +919,23 @@ func (app *ArkeoApp) GetSubspace(moduleName string) paramstypes.Subspace {
918919
// RegisterAPIRoutes registers all application module routes with the provided
919920
// API server.
920921
func (app *ArkeoApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
922+
// Legacy LCD compat: map ?events=... to ?query=...
923+
apiSvr.Router.Use(func(next http.Handler) http.Handler {
924+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
925+
if r.URL.Path == "/cosmos/tx/v1beta1/txs" {
926+
q := r.URL.Query()
927+
if q.Get("query") == "" {
928+
if evs, ok := q["events"]; ok && len(evs) > 0 {
929+
q.Set("query", strings.Join(evs, " AND "))
930+
q.Del("events")
931+
r.URL.RawQuery = q.Encode()
932+
}
933+
}
934+
}
935+
next.ServeHTTP(w, r)
936+
})
937+
})
938+
921939
clientCtx := apiSvr.ClientCtx
922940
// Register new tx routes from grpc-gateway.
923941
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

0 commit comments

Comments
 (0)