From 4b87fe7c51846c1749674261d8d7fe19dd073593 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Apr 2019 13:07:42 -0400 Subject: [PATCH 1/3] Minor cleanup in tx tags and response format --- baseapp/baseapp.go | 2 +- types/result.go | 10 +++++----- types/tags.go | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 87cd86b0cdba..119450dc5b91 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -698,7 +698,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re tags = append(tags, sdk.MakeTag(sdk.TagAction, msg.Type())) tags = append(tags, msgResult.Tags...) - idxLog := sdk.ABCIMessageLog{MsgIndex: msgIdx, Log: msgResult.Log} + idxLog := sdk.ABCIMessageLog{MsgIndex: uint16(msgIdx), Log: msgResult.Log} // stop execution and return on first failed message if !msgResult.IsOK() { diff --git a/types/result.go b/types/result.go index 7f0590241f65..613cd141f55b 100644 --- a/types/result.go +++ b/types/result.go @@ -45,7 +45,7 @@ type ABCIMessageLogs []ABCIMessageLog // ABCIMessageLog defines a structure containing an indexed tx ABCI message log. type ABCIMessageLog struct { - MsgIndex int `json:"msg_index"` + MsgIndex uint16 `json:"msg_index"` Success bool `json:"success"` Log string `json:"log"` } @@ -229,10 +229,6 @@ func (r TxResponse) String() string { sb.WriteString(fmt.Sprintf(" GasUsed: %d\n", r.GasUsed)) } - if len(r.Tags) > 0 { - sb.WriteString(fmt.Sprintf(" Tags: \n%s\n", r.Tags.String())) - } - if r.Codespace != "" { sb.WriteString(fmt.Sprintf(" Codespace: %s\n", r.Codespace)) } @@ -241,6 +237,10 @@ func (r TxResponse) String() string { sb.WriteString(fmt.Sprintf(" Timestamp: %s\n", r.Timestamp)) } + if len(r.Tags) > 0 { + sb.WriteString(fmt.Sprintf(" Tags: \n%s\n", r.Tags.String())) + } + return strings.TrimSpace(sb.String()) } diff --git a/types/tags.go b/types/tags.go index c203f53ac73d..ebfdfc8f27d9 100644 --- a/types/tags.go +++ b/types/tags.go @@ -96,7 +96,8 @@ func (st StringTags) String() string { for _, t := range st { sb.WriteString(fmt.Sprintf(" - %s\n", t.String())) } - return sb.String() + + return strings.TrimRight(sb.String(), "\n") } // Conversion function from a []byte tag to a string tag From b781ca65c5e67f2cc5273beb48b7c056b441e1cd Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Apr 2019 13:10:59 -0400 Subject: [PATCH 2/3] Add pending log(s) --- .pending/breaking/sdk/4230-Change-the-type | 1 + .pending/bugfixes/sdk/4230-Properly-set-an | 1 + 2 files changed, 2 insertions(+) create mode 100644 .pending/breaking/sdk/4230-Change-the-type create mode 100644 .pending/bugfixes/sdk/4230-Properly-set-an diff --git a/.pending/breaking/sdk/4230-Change-the-type b/.pending/breaking/sdk/4230-Change-the-type new file mode 100644 index 000000000000..f43fe781d4b3 --- /dev/null +++ b/.pending/breaking/sdk/4230-Change-the-type @@ -0,0 +1 @@ +#4230 Change the type of ABCIMessageLog#MsgIndex to uint16 for proper serialization. diff --git a/.pending/bugfixes/sdk/4230-Properly-set-an b/.pending/bugfixes/sdk/4230-Properly-set-an new file mode 100644 index 000000000000..26e75462196f --- /dev/null +++ b/.pending/bugfixes/sdk/4230-Properly-set-an @@ -0,0 +1 @@ +#4230 Properly set and display the message index through the TxResponse. From fb5fc71b743e5b95ed49bbab9ea4f9eadbbcfa2f Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 29 Apr 2019 13:27:35 -0400 Subject: [PATCH 3/3] Update TestParseABCILog --- types/result_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/result_test.go b/types/result_test.go index 0b126bbd788e..6a020d47455b 100644 --- a/types/result_test.go +++ b/types/result_test.go @@ -24,6 +24,6 @@ func TestParseABCILog(t *testing.T) { require.NoError(t, err) require.Len(t, res, 1) require.Equal(t, res[0].Log, "") - require.Equal(t, res[0].MsgIndex, 1) + require.Equal(t, res[0].MsgIndex, uint16(1)) require.True(t, res[0].Success) }