mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-09 06:24:27 +00:00
Co-authored-by: cui <cuiweixie@gmail.com>
This commit is contained in:
parent
1b09e585ab
commit
d2859ecb9c
2 changed files with 9 additions and 11 deletions
|
|
@ -28,11 +28,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
bytesT = reflect.TypeOf(Bytes(nil))
|
bytesT = reflect.TypeFor[Bytes]()
|
||||||
bigT = reflect.TypeOf((*Big)(nil))
|
bigT = reflect.TypeFor[*Big]()
|
||||||
uintT = reflect.TypeOf(Uint(0))
|
uintT = reflect.TypeFor[Uint]()
|
||||||
uint64T = reflect.TypeOf(Uint64(0))
|
uint64T = reflect.TypeFor[Uint64]()
|
||||||
u256T = reflect.TypeOf((*uint256.Int)(nil))
|
u256T = reflect.TypeFor[*uint256.Int]()
|
||||||
)
|
)
|
||||||
|
|
||||||
// Bytes marshals/unmarshals as a JSON string with 0x prefix.
|
// Bytes marshals/unmarshals as a JSON string with 0x prefix.
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
hashT = reflect.TypeFor[Hash]()
|
||||||
|
addressT = reflect.TypeFor[Address]()
|
||||||
|
|
||||||
// MaxHash represents the maximum possible hash value.
|
// MaxHash represents the maximum possible hash value.
|
||||||
MaxHash = HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
MaxHash = HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||||
|
|
||||||
|
|
@ -71,11 +74,6 @@ var (
|
||||||
MintedRecordAddressBinary = HexToAddress("0x000000000000000000000000000000000000009a")
|
MintedRecordAddressBinary = HexToAddress("0x000000000000000000000000000000000000009a")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
hashT = reflect.TypeOf(Hash{})
|
|
||||||
addressT = reflect.TypeOf(Address{})
|
|
||||||
)
|
|
||||||
|
|
||||||
// Hash represents the 32 byte Keccak256 hash of arbitrary data.
|
// Hash represents the 32 byte Keccak256 hash of arbitrary data.
|
||||||
type Hash [HashLength]byte
|
type Hash [HashLength]byte
|
||||||
|
|
||||||
|
|
@ -438,7 +436,7 @@ func isString(input []byte) bool {
|
||||||
// UnmarshalJSON parses a hash in hex syntax.
|
// UnmarshalJSON parses a hash in hex syntax.
|
||||||
func (d *Decimal) UnmarshalJSON(input []byte) error {
|
func (d *Decimal) UnmarshalJSON(input []byte) error {
|
||||||
if !isString(input) {
|
if !isString(input) {
|
||||||
return &json.UnmarshalTypeError{Value: "non-string", Type: reflect.TypeOf(uint64(0))}
|
return &json.UnmarshalTypeError{Value: "non-string", Type: reflect.TypeFor[uint64]()}
|
||||||
}
|
}
|
||||||
if i, err := strconv.ParseUint(string(input[1:len(input)-1]), 10, 64); err == nil {
|
if i, err := strconv.ParseUint(string(input[1:len(input)-1]), 10, 64); err == nil {
|
||||||
*d = Decimal(i)
|
*d = Decimal(i)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue