diff --git a/core/beacon/gen_edv2.go b/core/beacon/gen_edv2.go new file mode 100644 index 000000000000..4b3115871397 --- /dev/null +++ b/core/beacon/gen_edv2.go @@ -0,0 +1,46 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package beacon + +import ( + "encoding/json" + "errors" + "math/big" + + "github.com/ethereum/go-ethereum/common/hexutil" +) + +var _ = (*executableDataV2Marshaling)(nil) + +// MarshalJSON marshals as JSON. +func (e ExecutableDataV2) MarshalJSON() ([]byte, error) { + type ExecutableDataV2 struct { + ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` + BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + } + var enc ExecutableDataV2 + enc.ExecutionPayload = e.ExecutionPayload + enc.BlockValue = (*hexutil.Big)(e.BlockValue) + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (e *ExecutableDataV2) UnmarshalJSON(input []byte) error { + type ExecutableDataV2 struct { + ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` + BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` + } + var dec ExecutableDataV2 + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.ExecutionPayload == nil { + return errors.New("missing required field 'executionPayload' for ExecutableDataV2") + } + e.ExecutionPayload = dec.ExecutionPayload + if dec.BlockValue == nil { + return errors.New("missing required field 'blockValue' for ExecutableDataV2") + } + e.BlockValue = (*big.Int)(dec.BlockValue) + return nil +} diff --git a/core/beacon/types.go b/core/beacon/types.go index 69b2e1c3b030..166072c2c1d9 100644 --- a/core/beacon/types.go +++ b/core/beacon/types.go @@ -85,11 +85,18 @@ type executableDataMarshaling struct { Transactions []hexutil.Bytes } +//go:generate go run github.com/fjl/gencodec -type ExecutableDataV2 -field-override executableDataV2Marshaling -out gen_edv2.go + type ExecutableDataV2 struct { ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` BlockValue *big.Int `json:"blockValue" gencodec:"required"` } +// JSON type overrides for ExecutableDataV2. +type executableDataV2Marshaling struct { + BlockValue *hexutil.Big +} + type PayloadStatusV1 struct { Status string `json:"status"` LatestValidHash *common.Hash `json:"latestValidHash"`