github.com/ethereum/go-ethereum@v1.16.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/ethereum/go-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 BlobsBundle *BlobsBundleV1 `json:"blobsBundle"` 21 Requests []hexutil.Bytes `json:"executionRequests"` 22 Override bool `json:"shouldOverrideBuilder"` 23 Witness *hexutil.Bytes `json:"witness,omitempty"` 24 } 25 var enc ExecutionPayloadEnvelope 26 enc.ExecutionPayload = e.ExecutionPayload 27 enc.BlockValue = (*hexutil.Big)(e.BlockValue) 28 enc.BlobsBundle = e.BlobsBundle 29 if e.Requests != nil { 30 enc.Requests = make([]hexutil.Bytes, len(e.Requests)) 31 for k, v := range e.Requests { 32 enc.Requests[k] = v 33 } 34 } 35 enc.Override = e.Override 36 enc.Witness = e.Witness 37 return json.Marshal(&enc) 38 } 39 40 // UnmarshalJSON unmarshals from JSON. 41 func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error { 42 type ExecutionPayloadEnvelope struct { 43 ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` 44 BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` 45 BlobsBundle *BlobsBundleV1 `json:"blobsBundle"` 46 Requests []hexutil.Bytes `json:"executionRequests"` 47 Override *bool `json:"shouldOverrideBuilder"` 48 Witness *hexutil.Bytes `json:"witness,omitempty"` 49 } 50 var dec ExecutionPayloadEnvelope 51 if err := json.Unmarshal(input, &dec); err != nil { 52 return err 53 } 54 if dec.ExecutionPayload == nil { 55 return errors.New("missing required field 'executionPayload' for ExecutionPayloadEnvelope") 56 } 57 e.ExecutionPayload = dec.ExecutionPayload 58 if dec.BlockValue == nil { 59 return errors.New("missing required field 'blockValue' for ExecutionPayloadEnvelope") 60 } 61 e.BlockValue = (*big.Int)(dec.BlockValue) 62 if dec.BlobsBundle != nil { 63 e.BlobsBundle = dec.BlobsBundle 64 } 65 if dec.Requests != nil { 66 e.Requests = make([][]byte, len(dec.Requests)) 67 for k, v := range dec.Requests { 68 e.Requests[k] = v 69 } 70 } 71 if dec.Override != nil { 72 e.Override = *dec.Override 73 } 74 if dec.Witness != nil { 75 e.Witness = dec.Witness 76 } 77 return nil 78 }