mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-03 06:13:31 +00:00
Add deserialize fn
This commit is contained in:
parent
1a2ff476d9
commit
a3153a53ca
@ -10,7 +10,7 @@ class ElectraSpecBuilder(BaseSpecBuilder):
|
||||
def imports(cls, preset_name: str):
|
||||
return f'''
|
||||
from eth2spec.deneb import {preset_name} as deneb
|
||||
from eth2spec.utils.ssz.ssz_impl import serialize
|
||||
from eth2spec.utils.ssz.ssz_impl import serialize, deserialize
|
||||
'''
|
||||
|
||||
@classmethod
|
||||
|
@ -189,13 +189,11 @@ in [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685). The index of each elemen
|
||||
|
||||
```python
|
||||
def get_execution_requests(execution_requests: list[bytes]) -> ExecutionRequests:
|
||||
requests = ExecutionRequests()
|
||||
deposits = deserialize(DepositRequest, execution_requests[0])
|
||||
withdrawals = deserialize(WithdrawalRequest, execution_requests[1])
|
||||
consolidations = deserialize(ConsolidationRequest, execution_requests[2])
|
||||
|
||||
requests.deposits = deserialize(execution_requests[0], DepositRequest)
|
||||
requests.withdrawals = deserialize(execution_requests[1], WithdrawalRequest)
|
||||
requests.consolidations = deserialize(execution_requests[2], ConsolidationRequest)
|
||||
|
||||
return requests
|
||||
return ExecutionRequests(deposits, withdrawals, consolidations)
|
||||
```
|
||||
|
||||
## Attesting
|
||||
|
@ -8,6 +8,8 @@ from remerkleable.byte_arrays import Bytes32
|
||||
def serialize(obj: View) -> bytes:
|
||||
return obj.encode_bytes()
|
||||
|
||||
def deserialize(cls: View, data: bytes) -> object:
|
||||
return cls.decode_bytes(data)
|
||||
|
||||
def hash_tree_root(obj: View) -> Bytes32:
|
||||
return Bytes32(obj.get_backing().merkle_root())
|
||||
|
Loading…
x
Reference in New Issue
Block a user