From 0ca32caec6eefd1f68f7adf1f23848bad0289fb1 Mon Sep 17 00:00:00 2001 From: Cory Date: Wed, 1 Sep 2021 06:50:20 -0700 Subject: [PATCH] fix: remove legacy REST endpoints for broadcast & encode (v0.44.x) (#10041) * fix: remove legacy REST endpoints for broadcast & encode * add changelog * update changelog * fix amino tx marshaling test * try to fix x/auth/client/rest tests * changing tx broadcast request type * remove auth client/rest_test.go Co-authored-by: Robert Zaremba --- CHANGELOG.md | 5 ++++- x/auth/client/rest/rest.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 x/auth/client/rest/rest.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ed21119f5ac61..aaf6c79069d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes * (client/tx) [\#9421](https://github.com/cosmos/cosmos-sdk/pull/9421/) `BuildUnsignedTx`, `BuildSimTx`, `PrintUnsignedStdTx` functions are moved to the Tx Factory as methods. - + +### Client Breaking Changes +* [\#10041](https://github.com/cosmos/cosmos-sdk/pull/10041) Remove broadcast & encode legacy REST endpoints. Please see the [REST Endpoints Migration guide](https://docs.cosmos.network/master/migrations/rest.html) to migrate to the new REST endpoints. + ## [v0.43.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) - 2021-08-10 ### Features diff --git a/x/auth/client/rest/rest.go b/x/auth/client/rest/rest.go new file mode 100644 index 0000000000000..03b7564acef00 --- /dev/null +++ b/x/auth/client/rest/rest.go @@ -0,0 +1,34 @@ +package rest + +import ( + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/rest" +) + +// REST query and parameter values +const ( + MethodGet = "GET" +) + +// RegisterRoutes registers the auth module REST routes. +func RegisterRoutes(clientCtx client.Context, rtr *mux.Router, storeName string) { + r := rest.WithHTTPDeprecationHeaders(rtr) + r.HandleFunc( + "/auth/accounts/{address}", QueryAccountRequestHandlerFn(storeName, clientCtx), + ).Methods(MethodGet) + + r.HandleFunc( + "/auth/params", + queryParamsHandler(clientCtx), + ).Methods(MethodGet) +} + +// RegisterTxRoutes registers all transaction routes on the provided router. +func RegisterTxRoutes(clientCtx client.Context, rtr *mux.Router) { + r := rest.WithHTTPDeprecationHeaders(rtr) + r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(clientCtx)).Methods("GET") + r.HandleFunc("/txs", QueryTxsRequestHandlerFn(clientCtx)).Methods("GET") + r.HandleFunc("/txs/decode", DecodeTxRequestHandlerFn(clientCtx)).Methods("POST") +}