Skip to content

Commit

Permalink
Use /txs/{hash}
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 2, 2020
1 parent 64d4719 commit 7c3ad41
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion docs/migrations/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Some modules expose legacy `POST` endpoints to generate unsigned transactions fo

| Legacy REST Endpoint | Description | New gGPC-gateway REST Endpoint |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `GET /txs/{hash}` | Query tx by hash | `GET /cosmos/tx/v1beta1/tx/{hash}` |
| `GET /txs/{hash}` | Query tx by hash | `GET /cosmos/tx/v1beta1/txs/{hash}` |
| `GET /txs` | Query tx by events | `GET /cosmos/tx/v1beta1/txs` |
| `POST /txs` | Broadcast tx | `POST /cosmos/tx/v1beta1/txs` |
| `POST /txs/encode` | Encodes an Amino JSON tx to an Amino binary tx | N/A, use Protobuf directly |
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ service Service {
}
// GetTx fetches a tx by hash.
rpc GetTx(GetTxRequest) returns (GetTxResponse) {
option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}";
option (google.api.http).get = "/cosmos/tx/v1beta1/txs/{hash}";
}
// BroadcastTx broadcast transaction.
rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) {
Expand Down
96 changes: 48 additions & 48 deletions types/tx/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/tx/service.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/auth/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func QueryTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
rest.WriteErrorResponse(w, http.StatusNotFound, fmt.Sprintf("no transaction found with hash %s", hashHexStr))
}

err = checkSignModeError(clientCtx, output, "/cosmos/tx/v1beta1/tx/{txhash}")
err = checkSignModeError(clientCtx, output, "/cosmos/tx/v1beta1/txs/{txhash}")
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())

Expand Down
4 changes: 2 additions & 2 deletions x/auth/client/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (s *IntegrationTestSuite) broadcastReq(stdTx legacytx.StdTx, mode string) (
// testQueryIBCTx is a helper function to test querying txs which:
// - show an error message on legacy REST endpoints
// - succeed using gRPC
// In practise, we call this function on IBC txs.
// In practice, we call this function on IBC txs.
func (s *IntegrationTestSuite) testQueryIBCTx(txRes sdk.TxResponse, cmd *cobra.Command, args []string) {
val := s.network.Validators[0]

Expand Down Expand Up @@ -381,7 +381,7 @@ func (s *IntegrationTestSuite) testQueryIBCTx(txRes sdk.TxResponse, cmd *cobra.C
}

// try fetching the txn using gRPC req, it will fetch info since it has proto codec.
grpcJSON, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/%s", val.APIAddress, txRes.TxHash))
grpcJSON, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", val.APIAddress, txRes.TxHash))
s.Require().NoError(err)

var getTxRes txtypes.GetTxResponse
Expand Down
6 changes: 3 additions & 3 deletions x/auth/tx/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,17 @@ func (s IntegrationTestSuite) TestGetTx_GRPCGateway() {
}{
{
"empty params",
fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/", val.APIAddress),
fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/", val.APIAddress),
true, "transaction hash cannot be empty",
},
{
"dummy hash",
fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/%s", val.APIAddress, "deadbeef"),
fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", val.APIAddress, "deadbeef"),
true, "tx (DEADBEEF) not found",
},
{
"good hash",
fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/%s", val.APIAddress, s.txRes.TxHash),
fmt.Sprintf("%s/cosmos/tx/v1beta1/txs/%s", val.APIAddress, s.txRes.TxHash),
false, "",
},
}
Expand Down

0 comments on commit 7c3ad41

Please sign in to comment.