Skip to content

Commit 2bccf59

Browse files
committed
remove more fields from evm logs
1 parent 0270410 commit 2bccf59

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

cmd/query/eth_getTransactionReceipt.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ func GetQueryEvmRpcEthGetTransactionReceiptCommand() *cobra.Command {
1818
cmd := &cobra.Command{
1919
Use: "eth_getTransactionReceipt [0xhash]",
2020
Aliases: []string{"evm-receipt"},
21-
Short: "Query `eth_getTransactionReceipt` from EVM RPC",
22-
Args: cobra.ExactArgs(1),
21+
Short: "Query `eth_getTransactionReceipt` from EVM RPC.",
22+
Long: `Query "eth_getTransactionReceipt" from EVM RPC.
23+
Some fields of log like block/tx number/hash, which already available at receipt, will be removed for shorter and better readability.`,
24+
Args: cobra.ExactArgs(1),
2325
Run: func(cmd *cobra.Command, args []string) {
2426
ethClient, _ := flags.MustGetEthClient(cmd)
2527

cmd/utils/tx_util.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func MarshalPrettyJsonEvmTxReceipt(receipt *ethtypes.Receipt, option *PrettyMars
115115

116116
if logs, found := _map["logs"]; found && logs != nil {
117117
if logsArray, ok := logs.([]interface{}); ok {
118-
removeDeprecatedFieldsFromEvmTxLogs(logsArray)
118+
removeUnnecessaryFieldsOfEvmTxLogs(logsArray)
119119
}
120120
}
121121

@@ -187,10 +187,14 @@ func TryInjectTranslatedFieldForEvmRpcObjects(originalObject any, _map map[strin
187187
TryInjectTranslationValueByKey(_map, key, keyTransform, valueTransform)
188188
}
189189

190-
func removeDeprecatedFieldsFromEvmTxLogs(logs []interface{}) {
190+
func removeUnnecessaryFieldsOfEvmTxLogs(logs []interface{}) {
191191
if len(logs) > 0 {
192192
for _, log := range logs {
193193
if logMap, ok := log.(map[string]interface{}); ok && logMap != nil {
194+
delete(logMap, "blockHash")
195+
delete(logMap, "blockNumber")
196+
delete(logMap, "transactionHash")
197+
delete(logMap, "transactionIndex")
194198
delete(logMap, "removed")
195199
}
196200
}

0 commit comments

Comments
 (0)