/
gen_receipt_json.go
164 lines (158 loc) · 6.23 KB
/
gen_receipt_json.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package types
import (
"encoding/json"
"errors"
"math/big"
"github.com/chainupcloud/op-geth-scroll/common"
"github.com/chainupcloud/op-geth-scroll/common/hexutil"
)
var _ = (*receiptMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (r Receipt) MarshalJSON() ([]byte, error) {
type Receipt struct {
Type hexutil.Uint64 `json:"type,omitempty"`
PostState hexutil.Bytes `json:"root"`
Status hexutil.Uint64 `json:"status"`
CumulativeGasUsed hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"`
Bloom Bloom `json:"logsBloom" gencodec:"required"`
Logs []*Log `json:"logs" gencodec:"required"`
TxHash common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress common.Address `json:"contractAddress"`
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlobGasUsed hexutil.Uint64 `json:"blobGasUsed,omitempty"`
BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"`
DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"`
DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"`
BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex hexutil.Uint `json:"transactionIndex"`
L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"`
L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"`
L1Fee *hexutil.Big `json:"l1Fee,omitempty"`
FeeScalar *big.Float `json:"l1FeeScalar,omitempty"`
}
var enc Receipt
enc.Type = hexutil.Uint64(r.Type)
enc.PostState = r.PostState
enc.Status = hexutil.Uint64(r.Status)
enc.CumulativeGasUsed = hexutil.Uint64(r.CumulativeGasUsed)
enc.Bloom = r.Bloom
enc.Logs = r.Logs
enc.TxHash = r.TxHash
enc.ContractAddress = r.ContractAddress
enc.GasUsed = hexutil.Uint64(r.GasUsed)
enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice)
enc.BlobGasUsed = hexutil.Uint64(r.BlobGasUsed)
enc.BlobGasPrice = (*hexutil.Big)(r.BlobGasPrice)
enc.DepositNonce = (*hexutil.Uint64)(r.DepositNonce)
enc.DepositReceiptVersion = (*hexutil.Uint64)(r.DepositReceiptVersion)
enc.BlockHash = r.BlockHash
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
enc.L1GasPrice = (*hexutil.Big)(r.L1GasPrice)
enc.L1GasUsed = (*hexutil.Big)(r.L1GasUsed)
enc.L1Fee = (*hexutil.Big)(r.L1Fee)
enc.FeeScalar = r.FeeScalar
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (r *Receipt) UnmarshalJSON(input []byte) error {
type Receipt struct {
Type *hexutil.Uint64 `json:"type,omitempty"`
PostState *hexutil.Bytes `json:"root"`
Status *hexutil.Uint64 `json:"status"`
CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed" gencodec:"required"`
Bloom *Bloom `json:"logsBloom" gencodec:"required"`
Logs []*Log `json:"logs" gencodec:"required"`
TxHash *common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress *common.Address `json:"contractAddress"`
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed,omitempty"`
BlobGasPrice *hexutil.Big `json:"blobGasPrice,omitempty"`
DepositNonce *hexutil.Uint64 `json:"depositNonce,omitempty"`
DepositReceiptVersion *hexutil.Uint64 `json:"depositReceiptVersion,omitempty"`
BlockHash *common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
L1GasPrice *hexutil.Big `json:"l1GasPrice,omitempty"`
L1GasUsed *hexutil.Big `json:"l1GasUsed,omitempty"`
L1Fee *hexutil.Big `json:"l1Fee,omitempty"`
FeeScalar *big.Float `json:"l1FeeScalar,omitempty"`
}
var dec Receipt
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Type != nil {
r.Type = uint8(*dec.Type)
}
if dec.PostState != nil {
r.PostState = *dec.PostState
}
if dec.Status != nil {
r.Status = uint64(*dec.Status)
}
if dec.CumulativeGasUsed == nil {
return errors.New("missing required field 'cumulativeGasUsed' for Receipt")
}
r.CumulativeGasUsed = uint64(*dec.CumulativeGasUsed)
if dec.Bloom == nil {
return errors.New("missing required field 'logsBloom' for Receipt")
}
r.Bloom = *dec.Bloom
if dec.Logs == nil {
return errors.New("missing required field 'logs' for Receipt")
}
r.Logs = dec.Logs
if dec.TxHash == nil {
return errors.New("missing required field 'transactionHash' for Receipt")
}
r.TxHash = *dec.TxHash
if dec.ContractAddress != nil {
r.ContractAddress = *dec.ContractAddress
}
if dec.GasUsed == nil {
return errors.New("missing required field 'gasUsed' for Receipt")
}
r.GasUsed = uint64(*dec.GasUsed)
if dec.EffectiveGasPrice != nil {
r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice)
}
if dec.BlobGasUsed != nil {
r.BlobGasUsed = uint64(*dec.BlobGasUsed)
}
if dec.BlobGasPrice != nil {
r.BlobGasPrice = (*big.Int)(dec.BlobGasPrice)
}
if dec.DepositNonce != nil {
r.DepositNonce = (*uint64)(dec.DepositNonce)
}
if dec.DepositReceiptVersion != nil {
r.DepositReceiptVersion = (*uint64)(dec.DepositReceiptVersion)
}
if dec.BlockHash != nil {
r.BlockHash = *dec.BlockHash
}
if dec.BlockNumber != nil {
r.BlockNumber = (*big.Int)(dec.BlockNumber)
}
if dec.TransactionIndex != nil {
r.TransactionIndex = uint(*dec.TransactionIndex)
}
if dec.L1GasPrice != nil {
r.L1GasPrice = (*big.Int)(dec.L1GasPrice)
}
if dec.L1GasUsed != nil {
r.L1GasUsed = (*big.Int)(dec.L1GasUsed)
}
if dec.L1Fee != nil {
r.L1Fee = (*big.Int)(dec.L1Fee)
}
if dec.FeeScalar != nil {
r.FeeScalar = dec.FeeScalar
}
return nil
}