2022-12-06 05:55:40 +00:00
|
|
|
# Nimbus
|
2024-08-07 15:35:17 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-12-06 05:55:40 +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
|
2024-10-16 01:34:12 +00:00
|
|
|
eth/common/blocks
|
2022-12-06 05:55:40 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
CasperRef* = ref object
|
2024-10-16 01:34:12 +00:00
|
|
|
feeRecipient: Address
|
2023-10-19 00:50:07 +00:00
|
|
|
timestamp : EthTime
|
2024-10-02 16:22:35 +00:00
|
|
|
prevRandao : Bytes32
|
2023-10-19 00:50:07 +00:00
|
|
|
withdrawals : seq[Withdrawal] ## EIP-4895
|
2024-10-16 01:34:12 +00:00
|
|
|
beaconRoot : Hash32 ## EIP-4788
|
2022-12-06 05:55:40 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Getters
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-10-16 01:34:12 +00:00
|
|
|
func feeRecipient*(ctx: CasperRef): Address =
|
2022-12-06 05:55:40 +00:00
|
|
|
ctx.feeRecipient
|
|
|
|
|
|
|
|
func timestamp*(ctx: CasperRef): EthTime =
|
|
|
|
ctx.timestamp
|
|
|
|
|
2024-10-02 16:22:35 +00:00
|
|
|
func prevRandao*(ctx: CasperRef): Bytes32 =
|
2022-12-06 05:55:40 +00:00
|
|
|
ctx.prevRandao
|
|
|
|
|
2023-10-19 00:50:07 +00:00
|
|
|
proc withdrawals*(ctx: CasperRef): seq[Withdrawal] =
|
|
|
|
ctx.withdrawals
|
|
|
|
|
2024-10-16 01:34:12 +00:00
|
|
|
func parentBeaconBlockRoot*(ctx: CasperRef): Hash32 =
|
2023-10-19 00:50:07 +00:00
|
|
|
ctx.beaconRoot
|
2023-08-30 16:29:48 +00:00
|
|
|
|
2022-12-06 05:55:40 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Setters
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-10-16 01:34:12 +00:00
|
|
|
proc `feeRecipient=`*(ctx: CasperRef, val: Address) =
|
2022-12-06 05:55:40 +00:00
|
|
|
ctx.feeRecipient = val
|
|
|
|
|
|
|
|
proc `timestamp=`*(ctx: CasperRef, val: EthTime) =
|
|
|
|
ctx.timestamp = val
|
|
|
|
|
2024-10-02 16:22:35 +00:00
|
|
|
proc `prevRandao=`*(ctx: CasperRef, val: Bytes32) =
|
2022-12-06 05:55:40 +00:00
|
|
|
ctx.prevRandao = val
|
2023-08-30 16:29:48 +00:00
|
|
|
|
2023-10-19 00:50:07 +00:00
|
|
|
proc `withdrawals=`*(ctx: CasperRef, val: sink seq[Withdrawal]) =
|
|
|
|
ctx.withdrawals = system.move(val)
|
|
|
|
|
2024-10-16 01:34:12 +00:00
|
|
|
proc `parentBeaconBlockRoot=`*(ctx: CasperRef, val: Hash32) =
|
2023-10-19 00:50:07 +00:00
|
|
|
ctx.beaconRoot = val
|