imp: clean up the block fetch logic in json-rpc (#1081)

* clean up the block fetch logic in json-rpc

deduplicate some codes

fix EthBlockFromTm

fix latest block height

* add bug fix changelog
This commit is contained in:
yihuang
2022-05-23 18:36:31 +02:00
committed by GitHub
parent 2cfa8730c9
commit f06df8c265
6 changed files with 76 additions and 214 deletions
-32
View File
@@ -3,7 +3,6 @@ package types
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"math/big"
"strconv"
@@ -132,37 +131,6 @@ func FormatBlock(
return result
}
type DataError interface {
Error() string // returns the message
ErrorData() interface{} // returns the error data
}
type dataError struct {
msg string
data string
}
func (d *dataError) Error() string {
return d.msg
}
func (d *dataError) ErrorData() interface{} {
return d.data
}
type SDKTxLogs struct {
Log string `json:"log"`
}
const LogRevertedFlag = "transaction reverted"
func ErrRevertedWith(data []byte) DataError {
return &dataError{
msg: "VM execution error.",
data: fmt.Sprintf("0x%s", hex.EncodeToString(data)),
}
}
// NewTransactionFromMsg returns a transaction that will serialize to the RPC
// representation, with the given location metadata set (if available).
func NewTransactionFromMsg(