5
5
these are simple data classes that can be composed together.
6
6
"""
7
7
8
- from typing import Any , ClassVar , Dict , List , Optional
8
+ from typing import Any , ClassVar , Dict , List
9
9
10
10
from pydantic import Field
11
11
14
14
Bytes ,
15
15
CamelModel ,
16
16
HexNumber ,
17
+ Number ,
17
18
RLPSerializable ,
18
19
StorageKey ,
19
20
)
23
24
class BalNonceChange (CamelModel , RLPSerializable ):
24
25
"""Represents a nonce change in the block access list."""
25
26
26
- tx_index : int = Field (..., description = "Transaction index where the change occurred" )
27
- post_nonce : int = Field (..., description = "Nonce value after the transaction" )
27
+ tx_index : Number = Field (..., description = "Transaction index where the change occurred" )
28
+ post_nonce : Number = Field (..., description = "Nonce value after the transaction" )
28
29
29
30
rlp_fields : ClassVar [List [str ]] = ["tx_index" , "post_nonce" ]
30
31
31
32
32
33
class BalBalanceChange (CamelModel , RLPSerializable ):
33
34
"""Represents a balance change in the block access list."""
34
35
35
- tx_index : int = Field (..., description = "Transaction index where the change occurred" )
36
+ tx_index : Number = Field (..., description = "Transaction index where the change occurred" )
36
37
post_balance : HexNumber = Field (..., description = "Balance after the transaction" )
37
38
38
39
rlp_fields : ClassVar [List [str ]] = ["tx_index" , "post_balance" ]
@@ -41,7 +42,7 @@ class BalBalanceChange(CamelModel, RLPSerializable):
41
42
class BalCodeChange (CamelModel , RLPSerializable ):
42
43
"""Represents a code change in the block access list."""
43
44
44
- tx_index : int = Field (..., description = "Transaction index where the change occurred" )
45
+ tx_index : Number = Field (..., description = "Transaction index where the change occurred" )
45
46
new_code : Bytes = Field (..., description = "New code bytes" )
46
47
47
48
rlp_fields : ClassVar [List [str ]] = ["tx_index" , "new_code" ]
@@ -50,7 +51,7 @@ class BalCodeChange(CamelModel, RLPSerializable):
50
51
class BalStorageChange (CamelModel , RLPSerializable ):
51
52
"""Represents a change to a specific storage slot."""
52
53
53
- tx_index : int = Field (..., description = "Transaction index where the change occurred" )
54
+ tx_index : Number = Field (..., description = "Transaction index where the change occurred" )
54
55
post_value : StorageKey = Field (..., description = "Value after the transaction" )
55
56
56
57
rlp_fields : ClassVar [List [str ]] = ["tx_index" , "post_value" ]
@@ -71,18 +72,20 @@ class BalAccountChange(CamelModel, RLPSerializable):
71
72
"""Represents all changes to a specific account in a block."""
72
73
73
74
address : Address = Field (..., description = "Account address" )
74
- nonce_changes : Optional [ List [BalNonceChange ] ] = Field (
75
- None , description = "List of nonce changes"
75
+ nonce_changes : List [BalNonceChange ] = Field (
76
+ default_factory = list , description = "List of nonce changes"
76
77
)
77
- balance_changes : Optional [ List [BalBalanceChange ] ] = Field (
78
- None , description = "List of balance changes"
78
+ balance_changes : List [BalBalanceChange ] = Field (
79
+ default_factory = list , description = "List of balance changes"
79
80
)
80
- code_changes : Optional [List [BalCodeChange ]] = Field (None , description = "List of code changes" )
81
- storage_changes : Optional [List [BalStorageSlot ]] = Field (
82
- None , description = "List of storage changes"
81
+ code_changes : List [BalCodeChange ] = Field (
82
+ default_factory = list , description = "List of code changes"
83
83
)
84
- storage_reads : Optional [List [StorageKey ]] = Field (
85
- None , description = "List of storage slots that were read"
84
+ storage_changes : List [BalStorageSlot ] = Field (
85
+ default_factory = list , description = "List of storage changes"
86
+ )
87
+ storage_reads : List [StorageKey ] = Field (
88
+ default_factory = list , description = "List of storage slots that were read"
86
89
)
87
90
88
91
rlp_fields : ClassVar [List [str ]] = [
@@ -94,31 +97,6 @@ class BalAccountChange(CamelModel, RLPSerializable):
94
97
"code_changes" ,
95
98
]
96
99
97
- def to_list (self , signing : bool = False ) -> List [Any ]:
98
- """
99
- Override to handle None list fields properly.
100
- None list fields should serialize as empty lists, not empty bytes.
101
- """
102
- from ethereum_test_base_types .serialization import to_serializable_element
103
-
104
- result : list [Any ] = []
105
- for field_name in self .rlp_fields :
106
- value = getattr (self , field_name )
107
-
108
- # Special handling for None list fields - they should be empty lists
109
- if value is None and field_name in [
110
- "storage_changes" ,
111
- "storage_reads" ,
112
- "balance_changes" ,
113
- "nonce_changes" ,
114
- "code_changes" ,
115
- ]:
116
- result .append ([])
117
- else :
118
- result .append (to_serializable_element (value ))
119
-
120
- return result
121
-
122
100
123
101
class BlockAccessList (CamelModel , RLPSerializable ):
124
102
"""
0 commit comments