forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 142
/
gen_taiko_l1_origin.go
60 lines (54 loc) 路 1.85 KB
/
gen_taiko_l1_origin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package rawdb
import (
"encoding/json"
"errors"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
)
var _ = (*l1OriginMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (l L1Origin) MarshalJSON() ([]byte, error) {
type L1Origin struct {
BlockID *math.HexOrDecimal256 `json:"blockID" gencodec:"required"`
L2BlockHash common.Hash `json:"l2BlockHash"`
L1BlockHeight *math.HexOrDecimal256 `json:"l1BlockHeight" gencodec:"required"`
L1BlockHash common.Hash `json:"l1BlockHash" gencodec:"required"`
}
var enc L1Origin
enc.BlockID = (*math.HexOrDecimal256)(l.BlockID)
enc.L2BlockHash = l.L2BlockHash
enc.L1BlockHeight = (*math.HexOrDecimal256)(l.L1BlockHeight)
enc.L1BlockHash = l.L1BlockHash
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (l *L1Origin) UnmarshalJSON(input []byte) error {
type L1Origin struct {
BlockID *math.HexOrDecimal256 `json:"blockID" gencodec:"required"`
L2BlockHash *common.Hash `json:"l2BlockHash"`
L1BlockHeight *math.HexOrDecimal256 `json:"l1BlockHeight" gencodec:"required"`
L1BlockHash *common.Hash `json:"l1BlockHash" gencodec:"required"`
}
var dec L1Origin
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.BlockID == nil {
return errors.New("missing required field 'blockID' for L1Origin")
}
l.BlockID = (*big.Int)(dec.BlockID)
if dec.L2BlockHash != nil {
l.L2BlockHash = *dec.L2BlockHash
}
if dec.L1BlockHeight == nil {
return errors.New("missing required field 'l1BlockHeight' for L1Origin")
}
l.L1BlockHeight = (*big.Int)(dec.L1BlockHeight)
if dec.L1BlockHash == nil {
return errors.New("missing required field 'l1BlockHash' for L1Origin")
}
l.L1BlockHash = *dec.L1BlockHash
return nil
}