Skip to content

Commit

Permalink
Merge PR #4230: Minor cleanup in tx tags and response format
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Apr 30, 2019
1 parent 5344e8d commit f0f7b7d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .pending/breaking/sdk/4230-Change-the-type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4230 Change the type of ABCIMessageLog#MsgIndex to uint16 for proper serialization.
1 change: 1 addition & 0 deletions .pending/bugfixes/sdk/4230-Properly-set-an
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4230 Properly set and display the message index through the TxResponse.
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions types/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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))
}
Expand All @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion types/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion types/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0f7b7d

Please sign in to comment.