evm, rpc: fix tx log attribute value is not parsable by some client (#615)

* Problem: tx log attribute value not parsable by some client

Closes: #614

Solution:
- encode the value to json string rather than bytes

Apply suggestions from code review

* rm cdc and changelog

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>
This commit is contained in:
yihuang
2021-10-05 10:26:31 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer Federico Kunze
parent d6423f0c3f
commit cda968bddd
4 changed files with 22 additions and 8 deletions
+6 -2
View File
@@ -2,6 +2,7 @@ package keeper
import (
"context"
"encoding/json"
"fmt"
"github.com/palantir/stacktrace"
@@ -54,8 +55,11 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
txLogAttrs := make([]sdk.Attribute, 0)
for _, log := range response.Logs {
bz := k.cdc.MustMarshal(log)
txLogAttrs = append(txLogAttrs, sdk.NewAttribute(types.AttributeKeyTxLog, string(bz)))
value, err := json.Marshal(log)
if err != nil {
return nil, stacktrace.Propagate(err, "failed to encode log")
}
txLogAttrs = append(txLogAttrs, sdk.NewAttribute(types.AttributeKeyTxLog, string(value)))
}
// emit events