Skip to content

Commit

Permalink
fix: remove legacy REST endpoints for broadcast & encode (v0.44.x) (#…
Browse files Browse the repository at this point in the history
…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 <robert@zaremba.ch>
  • Loading branch information
clevinson and robert-zaremba authored Sep 1, 2021
1 parent 0155244 commit c1fc2a3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 676 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
)

Expand Down Expand Up @@ -132,7 +132,7 @@ func TestAminoCodecFullDecodeAndEncode(t *testing.T) {
require.Equal(t, string(marshaledTx), txSigned)

// Marshalling/unmarshalling the tx wrapped in a struct should work.
txRequest := &rest.BroadcastReq{
txRequest := &cli.BroadcastReq{
Mode: "block",
Tx: tx,
}
Expand Down
12 changes: 9 additions & 3 deletions x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ import (
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)

// BroadcastReq defines a tx broadcasting request.
type BroadcastReq struct {
Tx legacytx.StdTx `json:"tx" yaml:"tx"`
Mode string `json:"mode" yaml:"mode"`
}

// GetSignCommand returns the sign command
func GetMultiSignCommand() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -155,7 +161,7 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
return err
}

req := rest.BroadcastReq{
req := BroadcastReq{
Tx: stdTx,
Mode: "block|sync|async",
}
Expand Down Expand Up @@ -338,7 +344,7 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error {
return err
}

req := rest.BroadcastReq{
req := BroadcastReq{
Tx: stdTx,
Mode: "block|sync|async",
}
Expand Down
3 changes: 1 addition & 2 deletions x/auth/client/cli/tx_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/client/rest"
)

const (
Expand Down Expand Up @@ -263,7 +262,7 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
req := rest.BroadcastReq{
req := BroadcastReq{
Tx: stdTx,
Mode: "block|sync|async",
}
Expand Down
67 changes: 0 additions & 67 deletions x/auth/client/rest/broadcast.go

This file was deleted.

63 changes: 0 additions & 63 deletions x/auth/client/rest/encode.go

This file was deleted.

2 changes: 0 additions & 2 deletions x/auth/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,5 @@ 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", BroadcastTxRequest(clientCtx)).Methods("POST")
r.HandleFunc("/txs/encode", EncodeTxRequestHandlerFn(clientCtx)).Methods("POST")
r.HandleFunc("/txs/decode", DecodeTxRequestHandlerFn(clientCtx)).Methods("POST")
}
Loading

0 comments on commit c1fc2a3

Please sign in to comment.