From c7bc8680c941ed5835e5c26af921ca55eb8248c4 Mon Sep 17 00:00:00 2001 From: avalonche Date: Tue, 25 Jun 2024 20:33:47 +1000 Subject: [PATCH] fix json marshalling --- eth/block-validation/api.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/eth/block-validation/api.go b/eth/block-validation/api.go index 28f209eda..1a163f8b2 100644 --- a/eth/block-validation/api.go +++ b/eth/block-validation/api.go @@ -204,10 +204,6 @@ type BuilderBlockValidationRequestV3 struct { RegisteredGasLimit uint64 `json:"registered_gas_limit,string"` } -type BuilderBlockValidationResponse struct { - BlockValue *uint256.Int `json:"block_value"` -} - func (r *BuilderBlockValidationRequestV3) UnmarshalJSON(data []byte) error { params := &struct { ParentBeaconBlockRoot common.Hash `json:"parent_beacon_block_root"` @@ -229,6 +225,19 @@ func (r *BuilderBlockValidationRequestV3) UnmarshalJSON(data []byte) error { return nil } +type BuilderBlockValidationResponse struct { + BlockValue *uint256.Int +} + +func (r *BuilderBlockValidationResponse) MarshalJSON() ([]byte, error) { + type validationResponseJSON struct { + BlockValue string `json:"block_value"` + } + return json.Marshal(&validationResponseJSON{ + BlockValue: fmt.Sprintf("%d", r.BlockValue), + }) +} + func (api *BlockValidationAPI) ValidateBuilderSubmissionV3(params *BuilderBlockValidationRequestV3) (*BuilderBlockValidationResponse, error) { // TODO: fuzztest, make sure the validation is sound payload := params.ExecutionPayload