github.com/calmw/ethereum@v0.1.1/beacon/engine/gen_epe.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/calmw/ethereum/common/hexutil" 11 ) 12 13 var _ = (*executionPayloadEnvelopeMarshaling)(nil) 14 15 // MarshalJSON marshals as JSON. 16 func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) { 17 type ExecutionPayloadEnvelope struct { 18 ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` 19 BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` 20 } 21 var enc ExecutionPayloadEnvelope 22 enc.ExecutionPayload = e.ExecutionPayload 23 enc.BlockValue = (*hexutil.Big)(e.BlockValue) 24 return json.Marshal(&enc) 25 } 26 27 // UnmarshalJSON unmarshals from JSON. 28 func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error { 29 type ExecutionPayloadEnvelope struct { 30 ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` 31 BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` 32 } 33 var dec ExecutionPayloadEnvelope 34 if err := json.Unmarshal(input, &dec); err != nil { 35 return err 36 } 37 if dec.ExecutionPayload == nil { 38 return errors.New("missing required field 'executionPayload' for ExecutionPayloadEnvelope") 39 } 40 e.ExecutionPayload = dec.ExecutionPayload 41 if dec.BlockValue == nil { 42 return errors.New("missing required field 'blockValue' for ExecutionPayloadEnvelope") 43 } 44 e.BlockValue = (*big.Int)(dec.BlockValue) 45 return nil 46 }