Skip to content

Commit 201e1c3

Browse files
committed
unmarshal magic
1 parent 789610b commit 201e1c3

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

cmd/ecrecover/ecrecover.go

+3-22
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/ethereum/go-ethereum/core/types"
1212
"github.com/ethereum/go-ethereum/ethclient"
1313
ethrpc "github.com/ethereum/go-ethereum/rpc"
14-
"github.com/maticnetwork/polygon-cli/rpctypes"
1514
"github.com/maticnetwork/polygon-cli/util"
1615
"github.com/rs/zerolog/log"
1716
"github.com/spf13/cobra"
@@ -57,31 +56,13 @@ var EcRecoverCmd = &cobra.Command{
5756
}
5857
}
5958

60-
var rawBlock rpctypes.RawBlockResponse
61-
if err = json.Unmarshal(blockJSON, &rawBlock); err != nil {
59+
var header types.Header
60+
if err = json.Unmarshal(blockJSON, &header); err != nil {
6261
log.Error().Err(err).Msg("Unable to unmarshal JSON")
6362
return
6463
}
6564

66-
header := new(types.Header)
67-
pb := rpctypes.NewPolyBlock(&rawBlock)
68-
header.Extra = pb.Extra()
69-
header.ParentHash = pb.ParentHash()
70-
header.UncleHash = pb.UncleHash()
71-
header.Coinbase = pb.Coinbase()
72-
header.Root = pb.Root()
73-
header.TxHash = pb.TxHash()
74-
header.ReceiptHash = pb.ReceiptsRoot()
75-
header.Bloom = types.Bloom(pb.LogsBloom())
76-
header.Difficulty = pb.Difficulty()
77-
header.Number = pb.Number()
78-
header.GasLimit = pb.GasLimit()
79-
header.GasUsed = pb.GasUsed()
80-
header.Time = pb.Time()
81-
header.MixDigest = pb.MixHash()
82-
copy(header.Nonce[:], rawBlock.Nonce)
83-
84-
block = types.NewBlockWithHeader(header)
65+
block = types.NewBlockWithHeader(&header)
8566
blockNumber = header.Number.Uint64()
8667
} else {
8768
var rpc *ethrpc.Client

0 commit comments

Comments
 (0)