2023-12-06 12:59:24 +00:00
|
|
|
# nim-web3
|
2024-03-26 00:08:04 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-12-06 12:59:24 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
|
|
|
import
|
|
|
|
stint,
|
|
|
|
./engine_api_types
|
|
|
|
|
|
|
|
export
|
|
|
|
stint,
|
|
|
|
engine_api_types
|
|
|
|
|
|
|
|
type
|
|
|
|
ExecutionPayload* = object
|
|
|
|
parentHash*: Hash256
|
|
|
|
feeRecipient*: Address
|
|
|
|
stateRoot*: Hash256
|
|
|
|
receiptsRoot*: Hash256
|
|
|
|
logsBloom*: FixedBytes[256]
|
|
|
|
prevRandao*: FixedBytes[32]
|
|
|
|
blockNumber*: Quantity
|
|
|
|
gasLimit*: Quantity
|
|
|
|
gasUsed*: Quantity
|
|
|
|
timestamp*: Quantity
|
|
|
|
extraData*: DynamicBytes[0, 32]
|
|
|
|
baseFeePerGas*: UInt256
|
|
|
|
blockHash*: Hash256
|
|
|
|
transactions*: seq[TypedTransaction]
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals*: Opt[seq[WithdrawalV1]]
|
|
|
|
blobGasUsed*: Opt[Quantity]
|
|
|
|
excessBlobGas*: Opt[Quantity]
|
2024-06-17 11:28:06 +00:00
|
|
|
depositRequests*: Opt[seq[DepositRequestV1]]
|
2024-06-18 15:34:27 +00:00
|
|
|
withdrawalRequests*: Opt[seq[WithdrawalRequestV1]]
|
|
|
|
consolidationRequests*:Opt[seq[ConsolidationRequestV1]]
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
PayloadAttributes* = object
|
|
|
|
timestamp*: Quantity
|
|
|
|
prevRandao*: FixedBytes[32]
|
|
|
|
suggestedFeeRecipient*: Address
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals*: Opt[seq[WithdrawalV1]]
|
|
|
|
parentBeaconBlockRoot*: Opt[FixedBytes[32]]
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
SomeOptionalPayloadAttributes* =
|
2024-06-11 23:32:06 +00:00
|
|
|
Opt[PayloadAttributesV1] |
|
|
|
|
Opt[PayloadAttributesV2] |
|
|
|
|
Opt[PayloadAttributesV3]
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
GetPayloadResponse* = object
|
|
|
|
executionPayload*: ExecutionPayload
|
2024-06-11 23:32:06 +00:00
|
|
|
blockValue*: Opt[UInt256]
|
|
|
|
blobsBundle*: Opt[BlobsBundleV1]
|
|
|
|
shouldOverrideBuilder*: Opt[bool]
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
Version* {.pure.} = enum
|
|
|
|
V1
|
|
|
|
V2
|
|
|
|
V3
|
2024-03-27 15:59:33 +00:00
|
|
|
V4
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
func version*(payload: ExecutionPayload): Version =
|
2024-06-18 15:34:27 +00:00
|
|
|
if payload.depositRequests.isSome or
|
|
|
|
payload.withdrawalRequests.isSome or
|
|
|
|
payload.consolidationRequests.isSome:
|
2024-03-27 15:59:33 +00:00
|
|
|
Version.V4
|
|
|
|
elif payload.blobGasUsed.isSome or payload.excessBlobGas.isSome:
|
2023-12-06 12:59:24 +00:00
|
|
|
Version.V3
|
|
|
|
elif payload.withdrawals.isSome:
|
|
|
|
Version.V2
|
|
|
|
else:
|
|
|
|
Version.V1
|
|
|
|
|
|
|
|
func version*(attr: PayloadAttributes): Version =
|
|
|
|
if attr.parentBeaconBlockRoot.isSome:
|
|
|
|
Version.V3
|
|
|
|
elif attr.withdrawals.isSome:
|
|
|
|
Version.V2
|
|
|
|
else:
|
|
|
|
Version.V1
|
|
|
|
|
|
|
|
func version*(res: GetPayloadResponse): Version =
|
2024-03-27 15:59:33 +00:00
|
|
|
# TODO: should this return whatever version of
|
|
|
|
# executionPayload.version?
|
|
|
|
if res.executionPayload.version == Version.V4:
|
|
|
|
Version.V4
|
|
|
|
elif res.blobsBundle.isSome or res.shouldOverrideBuilder.isSome:
|
2023-12-06 12:59:24 +00:00
|
|
|
Version.V3
|
|
|
|
elif res.blockValue.isSome:
|
|
|
|
Version.V2
|
|
|
|
else:
|
|
|
|
Version.V1
|
|
|
|
|
|
|
|
func V1V2*(attr: PayloadAttributes): PayloadAttributesV1OrV2 =
|
|
|
|
PayloadAttributesV1OrV2(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient,
|
|
|
|
withdrawals: attr.withdrawals
|
|
|
|
)
|
|
|
|
|
|
|
|
func V1*(attr: PayloadAttributes): PayloadAttributesV1 =
|
|
|
|
PayloadAttributesV1(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient
|
|
|
|
)
|
|
|
|
|
|
|
|
func V2*(attr: PayloadAttributes): PayloadAttributesV2 =
|
|
|
|
PayloadAttributesV2(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient,
|
|
|
|
withdrawals: attr.withdrawals.get
|
|
|
|
)
|
|
|
|
|
|
|
|
func V3*(attr: PayloadAttributes): PayloadAttributesV3 =
|
|
|
|
PayloadAttributesV3(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient,
|
|
|
|
withdrawals: attr.withdrawals.get(newSeq[WithdrawalV1]()),
|
|
|
|
parentBeaconBlockRoot: attr.parentBeaconBlockRoot.get
|
|
|
|
)
|
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func V1*(attr: Opt[PayloadAttributes]): Opt[PayloadAttributesV1] =
|
2023-12-06 12:59:24 +00:00
|
|
|
if attr.isNone:
|
2024-06-11 23:32:06 +00:00
|
|
|
return Opt.none(PayloadAttributesV1)
|
|
|
|
Opt.some(attr.get.V1)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func V2*(attr: Opt[PayloadAttributes]): Opt[PayloadAttributesV2] =
|
2023-12-06 12:59:24 +00:00
|
|
|
if attr.isNone:
|
2024-06-11 23:32:06 +00:00
|
|
|
return Opt.none(PayloadAttributesV2)
|
|
|
|
Opt.some(attr.get.V2)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func V3*(attr: Opt[PayloadAttributes]): Opt[PayloadAttributesV3] =
|
2023-12-06 12:59:24 +00:00
|
|
|
if attr.isNone:
|
2024-06-11 23:32:06 +00:00
|
|
|
return Opt.none(PayloadAttributesV3)
|
|
|
|
Opt.some(attr.get.V3)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
func payloadAttributes*(attr: PayloadAttributesV1): PayloadAttributes =
|
|
|
|
PayloadAttributes(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient
|
|
|
|
)
|
|
|
|
|
|
|
|
func payloadAttributes*(attr: PayloadAttributesV2): PayloadAttributes =
|
|
|
|
PayloadAttributes(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient,
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals: Opt.some(attr.withdrawals)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func payloadAttributes*(attr: PayloadAttributesV3): PayloadAttributes =
|
|
|
|
PayloadAttributes(
|
|
|
|
timestamp: attr.timestamp,
|
|
|
|
prevRandao: attr.prevRandao,
|
|
|
|
suggestedFeeRecipient: attr.suggestedFeeRecipient,
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals: Opt.some(attr.withdrawals),
|
|
|
|
parentBeaconBlockRoot: Opt.some(attr.parentBeaconBlockRoot)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func payloadAttributes*(x: Opt[PayloadAttributesV1]): Opt[PayloadAttributes] =
|
|
|
|
if x.isNone: Opt.none(PayloadAttributes)
|
|
|
|
else: Opt.some(payloadAttributes x.get)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func payloadAttributes*(x: Opt[PayloadAttributesV2]): Opt[PayloadAttributes] =
|
|
|
|
if x.isNone: Opt.none(PayloadAttributes)
|
|
|
|
else: Opt.some(payloadAttributes x.get)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
2024-06-11 23:32:06 +00:00
|
|
|
func payloadAttributes*(x: Opt[PayloadAttributesV3]): Opt[PayloadAttributes] =
|
|
|
|
if x.isNone: Opt.none(PayloadAttributes)
|
|
|
|
else: Opt.some(payloadAttributes x.get)
|
2023-12-06 12:59:24 +00:00
|
|
|
|
|
|
|
func V1V2*(p: ExecutionPayload): ExecutionPayloadV1OrV2 =
|
|
|
|
ExecutionPayloadV1OrV2(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals
|
|
|
|
)
|
|
|
|
|
|
|
|
func V1*(p: ExecutionPayload): ExecutionPayloadV1 =
|
|
|
|
ExecutionPayloadV1(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions
|
|
|
|
)
|
|
|
|
|
|
|
|
func V2*(p: ExecutionPayload): ExecutionPayloadV2 =
|
|
|
|
ExecutionPayloadV2(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals.get
|
|
|
|
)
|
|
|
|
|
|
|
|
func V3*(p: ExecutionPayload): ExecutionPayloadV3 =
|
|
|
|
ExecutionPayloadV3(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals.get,
|
2024-03-26 00:08:04 +00:00
|
|
|
blobGasUsed: p.blobGasUsed.get(0.Quantity),
|
|
|
|
excessBlobGas: p.excessBlobGas.get(0.Quantity)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
2024-03-27 15:59:33 +00:00
|
|
|
func V4*(p: ExecutionPayload): ExecutionPayloadV4 =
|
|
|
|
ExecutionPayloadV4(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals.get,
|
|
|
|
blobGasUsed: p.blobGasUsed.get(0.Quantity),
|
|
|
|
excessBlobGas: p.excessBlobGas.get(0.Quantity),
|
2024-06-17 11:28:06 +00:00
|
|
|
depositRequests: p.depositRequests.get(newSeq[DepositRequestV1]()),
|
2024-06-18 15:34:27 +00:00
|
|
|
withdrawalRequests: p.withdrawalRequests.get(newSeq[WithdrawalRequestV1]()),
|
|
|
|
consolidationRequests: p.consolidationRequests.get(newSeq[ConsolidationRequestV1]()),
|
2024-03-27 15:59:33 +00:00
|
|
|
)
|
|
|
|
|
2023-12-06 12:59:24 +00:00
|
|
|
func V1*(p: ExecutionPayloadV1OrV2): ExecutionPayloadV1 =
|
|
|
|
ExecutionPayloadV1(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions
|
|
|
|
)
|
|
|
|
|
|
|
|
func V2*(p: ExecutionPayloadV1OrV2): ExecutionPayloadV2 =
|
|
|
|
ExecutionPayloadV2(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals.get
|
|
|
|
)
|
|
|
|
|
|
|
|
func executionPayload*(p: ExecutionPayloadV1): ExecutionPayload =
|
|
|
|
ExecutionPayload(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions
|
|
|
|
)
|
|
|
|
|
|
|
|
func executionPayload*(p: ExecutionPayloadV2): ExecutionPayload =
|
|
|
|
ExecutionPayload(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals: Opt.some(p.withdrawals)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func executionPayload*(p: ExecutionPayloadV3): ExecutionPayload =
|
|
|
|
ExecutionPayload(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals: Opt.some(p.withdrawals),
|
|
|
|
blobGasUsed: Opt.some(p.blobGasUsed),
|
|
|
|
excessBlobGas: Opt.some(p.excessBlobGas)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
2024-03-27 15:59:33 +00:00
|
|
|
func executionPayload*(p: ExecutionPayloadV4): ExecutionPayload =
|
|
|
|
ExecutionPayload(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
2024-06-11 23:32:06 +00:00
|
|
|
withdrawals: Opt.some(p.withdrawals),
|
|
|
|
blobGasUsed: Opt.some(p.blobGasUsed),
|
|
|
|
excessBlobGas: Opt.some(p.excessBlobGas),
|
2024-06-17 11:28:06 +00:00
|
|
|
depositRequests: Opt.some(p.depositRequests),
|
2024-06-18 15:34:27 +00:00
|
|
|
withdrawalRequests: Opt.some(p.withdrawalRequests),
|
|
|
|
consolidationRequests: Opt.some(p.consolidationRequests),
|
2024-03-27 15:59:33 +00:00
|
|
|
)
|
|
|
|
|
2023-12-06 12:59:24 +00:00
|
|
|
func executionPayload*(p: ExecutionPayloadV1OrV2): ExecutionPayload =
|
|
|
|
ExecutionPayload(
|
|
|
|
parentHash: p.parentHash,
|
|
|
|
feeRecipient: p.feeRecipient,
|
|
|
|
stateRoot: p.stateRoot,
|
|
|
|
receiptsRoot: p.receiptsRoot,
|
|
|
|
logsBloom: p.logsBloom,
|
|
|
|
prevRandao: p.prevRandao,
|
|
|
|
blockNumber: p.blockNumber,
|
|
|
|
gasLimit: p.gasLimit,
|
|
|
|
gasUsed: p.gasUsed,
|
|
|
|
timestamp: p.timestamp,
|
|
|
|
extraData: p.extraData,
|
|
|
|
baseFeePerGas: p.baseFeePerGas,
|
|
|
|
blockHash: p.blockHash,
|
|
|
|
transactions: p.transactions,
|
|
|
|
withdrawals: p.withdrawals
|
|
|
|
)
|
|
|
|
|
|
|
|
func V1*(res: GetPayloadResponse): ExecutionPayloadV1 =
|
|
|
|
res.executionPayload.V1
|
|
|
|
|
|
|
|
func V2*(res: GetPayloadResponse): GetPayloadV2Response =
|
|
|
|
GetPayloadV2Response(
|
|
|
|
executionPayload: res.executionPayload.V1V2,
|
|
|
|
blockValue: res.blockValue.get
|
|
|
|
)
|
|
|
|
|
|
|
|
func V3*(res: GetPayloadResponse): GetPayloadV3Response =
|
|
|
|
GetPayloadV3Response(
|
|
|
|
executionPayload: res.executionPayload.V3,
|
|
|
|
blockValue: res.blockValue.get,
|
2024-03-26 00:08:04 +00:00
|
|
|
blobsBundle: res.blobsBundle.get(BlobsBundleV1()),
|
|
|
|
shouldOverrideBuilder: res.shouldOverrideBuilder.get(false)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
2024-03-27 15:59:33 +00:00
|
|
|
func V4*(res: GetPayloadResponse): GetPayloadV4Response =
|
|
|
|
GetPayloadV4Response(
|
|
|
|
executionPayload: res.executionPayload.V4,
|
|
|
|
blockValue: res.blockValue.get,
|
|
|
|
blobsBundle: res.blobsBundle.get(BlobsBundleV1()),
|
|
|
|
shouldOverrideBuilder: res.shouldOverrideBuilder.get(false)
|
|
|
|
)
|
|
|
|
|
2023-12-06 12:59:24 +00:00
|
|
|
func getPayloadResponse*(x: ExecutionPayloadV1): GetPayloadResponse =
|
|
|
|
GetPayloadResponse(executionPayload: x.executionPayload)
|
|
|
|
|
|
|
|
func getPayloadResponse*(x: GetPayloadV2Response): GetPayloadResponse =
|
|
|
|
GetPayloadResponse(
|
|
|
|
executionPayload: x.executionPayload.executionPayload,
|
2024-06-11 23:32:06 +00:00
|
|
|
blockValue: Opt.some(x.blockValue)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func getPayloadResponse*(x: GetPayloadV3Response): GetPayloadResponse =
|
|
|
|
GetPayloadResponse(
|
|
|
|
executionPayload: x.executionPayload.executionPayload,
|
2024-06-11 23:32:06 +00:00
|
|
|
blockValue: Opt.some(x.blockValue),
|
|
|
|
blobsBundle: Opt.some(x.blobsBundle),
|
|
|
|
shouldOverrideBuilder: Opt.some(x.shouldOverrideBuilder)
|
2023-12-06 12:59:24 +00:00
|
|
|
)
|
2024-03-27 15:59:33 +00:00
|
|
|
|
|
|
|
func getPayloadResponse*(x: GetPayloadV4Response): GetPayloadResponse =
|
|
|
|
GetPayloadResponse(
|
|
|
|
executionPayload: x.executionPayload.executionPayload,
|
2024-06-11 23:32:06 +00:00
|
|
|
blockValue: Opt.some(x.blockValue),
|
|
|
|
blobsBundle: Opt.some(x.blobsBundle),
|
|
|
|
shouldOverrideBuilder: Opt.some(x.shouldOverrideBuilder)
|
2024-05-15 01:12:34 +00:00
|
|
|
)
|