Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Problem: tx log attribtue value not parsable by some client #615

Merged
merged 3 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Problem: tx log attribtue value not parsable by some client
Closes: #614

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

Apply suggestions from code review
  • Loading branch information
yihuang committed Oct 3, 2021
commit c53ebc8bbdaff416ced87144ba67b4ec4367fce6
5 changes: 4 additions & 1 deletion rpc/ethereum/backend/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package backend

import (
"bytes"
"encoding/json"
"errors"
"math/big"

Expand Down Expand Up @@ -147,7 +148,9 @@ func TxLogsFromEvents(codec codec.Codec, events []abci.Event) []*ethtypes.Log {
}

var log evmtypes.Log
codec.MustUnmarshal(attr.Value, &log)
if err := json.Unmarshal(attr.Value, &log); err != nil {
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
panic(err)
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}
logs = append(logs, &log)
}
}
Expand Down
8 changes: 6 additions & 2 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"encoding/json"
"fmt"

"github.com/palantir/stacktrace"
Expand Down Expand Up @@ -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
Expand Down