github.com/theQRL/go-zond@v0.1.1/beacon/engine/gen_ed.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package engine 4 5 import ( 6 "encoding/json" 7 "errors" 8 "math/big" 9 10 "github.com/theQRL/go-zond/common" 11 "github.com/theQRL/go-zond/common/hexutil" 12 "github.com/theQRL/go-zond/core/types" 13 ) 14 15 var _ = (*executableDataMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (e ExecutableData) MarshalJSON() ([]byte, error) { 19 type ExecutableData struct { 20 ParentHash common.Hash `json:"parentHash" gencodec:"required"` 21 FeeRecipient common.Address `json:"feeRecipient" gencodec:"required"` 22 StateRoot common.Hash `json:"stateRoot" gencodec:"required"` 23 ReceiptsRoot common.Hash `json:"receiptsRoot" gencodec:"required"` 24 LogsBloom hexutil.Bytes `json:"logsBloom" gencodec:"required"` 25 Random common.Hash `json:"prevRandao" gencodec:"required"` 26 Number hexutil.Uint64 `json:"blockNumber" gencodec:"required"` 27 GasLimit hexutil.Uint64 `json:"gasLimit" gencodec:"required"` 28 GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"` 29 Timestamp hexutil.Uint64 `json:"timestamp" gencodec:"required"` 30 ExtraData hexutil.Bytes `json:"extraData" gencodec:"required"` 31 BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` 32 BlockHash common.Hash `json:"blockHash" gencodec:"required"` 33 Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` 34 Withdrawals []*types.Withdrawal `json:"withdrawals"` 35 BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` 36 ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` 37 } 38 var enc ExecutableData 39 enc.ParentHash = e.ParentHash 40 enc.FeeRecipient = e.FeeRecipient 41 enc.StateRoot = e.StateRoot 42 enc.ReceiptsRoot = e.ReceiptsRoot 43 enc.LogsBloom = e.LogsBloom 44 enc.Random = e.Random 45 enc.Number = hexutil.Uint64(e.Number) 46 enc.GasLimit = hexutil.Uint64(e.GasLimit) 47 enc.GasUsed = hexutil.Uint64(e.GasUsed) 48 enc.Timestamp = hexutil.Uint64(e.Timestamp) 49 enc.ExtraData = e.ExtraData 50 enc.BaseFeePerGas = (*hexutil.Big)(e.BaseFeePerGas) 51 enc.BlockHash = e.BlockHash 52 if e.Transactions != nil { 53 enc.Transactions = make([]hexutil.Bytes, len(e.Transactions)) 54 for k, v := range e.Transactions { 55 enc.Transactions[k] = v 56 } 57 } 58 enc.Withdrawals = e.Withdrawals 59 enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed) 60 enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas) 61 return json.Marshal(&enc) 62 } 63 64 // UnmarshalJSON unmarshals from JSON. 65 func (e *ExecutableData) UnmarshalJSON(input []byte) error { 66 type ExecutableData struct { 67 ParentHash *common.Hash `json:"parentHash" gencodec:"required"` 68 FeeRecipient *common.Address `json:"feeRecipient" gencodec:"required"` 69 StateRoot *common.Hash `json:"stateRoot" gencodec:"required"` 70 ReceiptsRoot *common.Hash `json:"receiptsRoot" gencodec:"required"` 71 LogsBloom *hexutil.Bytes `json:"logsBloom" gencodec:"required"` 72 Random *common.Hash `json:"prevRandao" gencodec:"required"` 73 Number *hexutil.Uint64 `json:"blockNumber" gencodec:"required"` 74 GasLimit *hexutil.Uint64 `json:"gasLimit" gencodec:"required"` 75 GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"` 76 Timestamp *hexutil.Uint64 `json:"timestamp" gencodec:"required"` 77 ExtraData *hexutil.Bytes `json:"extraData" gencodec:"required"` 78 BaseFeePerGas *hexutil.Big `json:"baseFeePerGas" gencodec:"required"` 79 BlockHash *common.Hash `json:"blockHash" gencodec:"required"` 80 Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"` 81 Withdrawals []*types.Withdrawal `json:"withdrawals"` 82 BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` 83 ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` 84 } 85 var dec ExecutableData 86 if err := json.Unmarshal(input, &dec); err != nil { 87 return err 88 } 89 if dec.ParentHash == nil { 90 return errors.New("missing required field 'parentHash' for ExecutableData") 91 } 92 e.ParentHash = *dec.ParentHash 93 if dec.FeeRecipient == nil { 94 return errors.New("missing required field 'feeRecipient' for ExecutableData") 95 } 96 e.FeeRecipient = *dec.FeeRecipient 97 if dec.StateRoot == nil { 98 return errors.New("missing required field 'stateRoot' for ExecutableData") 99 } 100 e.StateRoot = *dec.StateRoot 101 if dec.ReceiptsRoot == nil { 102 return errors.New("missing required field 'receiptsRoot' for ExecutableData") 103 } 104 e.ReceiptsRoot = *dec.ReceiptsRoot 105 if dec.LogsBloom == nil { 106 return errors.New("missing required field 'logsBloom' for ExecutableData") 107 } 108 e.LogsBloom = *dec.LogsBloom 109 if dec.Random == nil { 110 return errors.New("missing required field 'prevRandao' for ExecutableData") 111 } 112 e.Random = *dec.Random 113 if dec.Number == nil { 114 return errors.New("missing required field 'blockNumber' for ExecutableData") 115 } 116 e.Number = uint64(*dec.Number) 117 if dec.GasLimit == nil { 118 return errors.New("missing required field 'gasLimit' for ExecutableData") 119 } 120 e.GasLimit = uint64(*dec.GasLimit) 121 if dec.GasUsed == nil { 122 return errors.New("missing required field 'gasUsed' for ExecutableData") 123 } 124 e.GasUsed = uint64(*dec.GasUsed) 125 if dec.Timestamp == nil { 126 return errors.New("missing required field 'timestamp' for ExecutableData") 127 } 128 e.Timestamp = uint64(*dec.Timestamp) 129 if dec.ExtraData == nil { 130 return errors.New("missing required field 'extraData' for ExecutableData") 131 } 132 e.ExtraData = *dec.ExtraData 133 if dec.BaseFeePerGas == nil { 134 return errors.New("missing required field 'baseFeePerGas' for ExecutableData") 135 } 136 e.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) 137 if dec.BlockHash == nil { 138 return errors.New("missing required field 'blockHash' for ExecutableData") 139 } 140 e.BlockHash = *dec.BlockHash 141 if dec.Transactions == nil { 142 return errors.New("missing required field 'transactions' for ExecutableData") 143 } 144 e.Transactions = make([][]byte, len(dec.Transactions)) 145 for k, v := range dec.Transactions { 146 e.Transactions[k] = v 147 } 148 if dec.Withdrawals != nil { 149 e.Withdrawals = dec.Withdrawals 150 } 151 if dec.BlobGasUsed != nil { 152 e.BlobGasUsed = (*uint64)(dec.BlobGasUsed) 153 } 154 if dec.ExcessBlobGas != nil { 155 e.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas) 156 } 157 return nil 158 }