From bcf27c2364b9a235151474e7cd650e881f484495 Mon Sep 17 00:00:00 2001 From: Yongwoo Lee Date: Tue, 31 Mar 2020 16:49:28 +0900 Subject: [PATCH] rpc: add codespace to ResultBroadcastTx (#4611) Closes: #4606 --- CHANGELOG_PENDING.md | 2 ++ rpc/client/mock/abci.go | 16 ++++++++++++++-- rpc/core/mempool.go | 9 +++++---- rpc/core/types/responses.go | 7 ++++--- rpc/swagger/swagger.yaml | 3 +++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 4ec4db785..6aeb1007a 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -16,6 +16,8 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi ### FEATURES: +- [rpc] [\#4611](https://github.com/tendermint/tendermint/pull/4611) Add `codespace` to `ResultBroadcastTx` (@whylee259) + ### IMPROVEMENTS: - [p2p] [\#4548](https://github.com/tendermint/tendermint/pull/4548) Add ban list to address book (@cmwaters) diff --git a/rpc/client/mock/abci.go b/rpc/client/mock/abci.go index d1f84f2b1..ebee8b4e8 100644 --- a/rpc/client/mock/abci.go +++ b/rpc/client/mock/abci.go @@ -63,7 +63,13 @@ func (a ABCIApp) BroadcastTxAsync(tx types.Tx) (*ctypes.ResultBroadcastTx, error if !c.IsErr() { go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }() // nolint: errcheck } - return &ctypes.ResultBroadcastTx{Code: c.Code, Data: c.Data, Log: c.Log, Hash: tx.Hash()}, nil + return &ctypes.ResultBroadcastTx{ + Code: c.Code, + Data: c.Data, + Log: c.Log, + Codespace: c.Codespace, + Hash: tx.Hash(), + }, nil } func (a ABCIApp) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) { @@ -72,7 +78,13 @@ func (a ABCIApp) BroadcastTxSync(tx types.Tx) (*ctypes.ResultBroadcastTx, error) if !c.IsErr() { go func() { a.App.DeliverTx(abci.RequestDeliverTx{Tx: tx}) }() // nolint: errcheck } - return &ctypes.ResultBroadcastTx{Code: c.Code, Data: c.Data, Log: c.Log, Hash: tx.Hash()}, nil + return &ctypes.ResultBroadcastTx{ + Code: c.Code, + Data: c.Data, + Log: c.Log, + Codespace: c.Codespace, + Hash: tx.Hash(), + }, nil } // ABCIMock will send all abci related request to the named app, diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 28b73ab33..0e6ce7a2c 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -43,10 +43,11 @@ func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcas res := <-resCh r := res.GetCheckTx() return &ctypes.ResultBroadcastTx{ - Code: r.Code, - Data: r.Data, - Log: r.Log, - Hash: tx.Hash(), + Code: r.Code, + Data: r.Data, + Log: r.Log, + Codespace: r.Codespace, + Hash: tx.Hash(), }, nil } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 9aee485e9..ed435bbe0 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -148,9 +148,10 @@ type ResultConsensusState struct { // CheckTx result type ResultBroadcastTx struct { - Code uint32 `json:"code"` - Data bytes.HexBytes `json:"data"` - Log string `json:"log"` + Code uint32 `json:"code"` + Data bytes.HexBytes `json:"data"` + Log string `json:"log"` + Codespace string `json:"codespace"` Hash bytes.HexBytes `json:"hash"` } diff --git a/rpc/swagger/swagger.yaml b/rpc/swagger/swagger.yaml index 40b6e0169..00b137bf0 100644 --- a/rpc/swagger/swagger.yaml +++ b/rpc/swagger/swagger.yaml @@ -2947,6 +2947,9 @@ components: log: type: "string" example: "" + codespace: + type: "string" + example: "ibc" hash: type: "string" example: "0D33F2F03A5234F38706E43004489E061AC40A2E"