Skip to content

Commit d018355

Browse files
fix: unexpected field "authorizationList" (#99)
1 parent 2add299 commit d018355

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

evmspec/structs/transaction.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ def storageKeys(self) -> List[HexBytes32]:
7878
).decode
7979

8080

81+
@final
82+
class AuthorizationListEntry(LazyDictStruct, frozen=True, forbid_unknown_fields=True): # type: ignore [call-arg]
83+
chainId: ChainId
84+
address: Address
85+
nonce: Nonce
86+
gas: Wei
87+
yParity: uint
88+
r: HexBytes
89+
s: HexBytes
90+
91+
92+
_decode_authorization_list: Final[Callable[[Raw], List[AuthorizationListEntry]]] = (
93+
Decoder(type=List[AuthorizationListEntry]).decode
94+
)
95+
96+
8197
class _TransactionBase(LazyDictStruct, frozen=True, kw_only=True, forbid_unknown_fields=True, omit_defaults=True, repr_omit_defaults=True): # type: ignore [call-arg]
8298
"""
8399
Base class for Ethereum transactions.
@@ -259,6 +275,25 @@ class Transaction7702(Transaction1559, tag="0x4", frozen=True, kw_only=True, for
259275
"""
260276

261277
type: ClassVar[HexBytes] = HexBytes("4")
278+
_authorizationList: Raw = field(name="authorizationList") # type: ignore [assignment]
279+
280+
@cached_property
281+
def authorizationList(self) -> List[AuthorizationListEntry]:
282+
"""
283+
Decodes the authorization list from raw format to a list of AuthorizationListEntry.
284+
285+
Example:
286+
>>> transaction = _TransactionBase(...)
287+
>>> access_list = transaction.accessList
288+
>>> isinstance(access_list, list)
289+
True
290+
>>> isinstance(access_list[0], AccessListEntry)
291+
True
292+
293+
See Also:
294+
- :class:`AccessListEntry`
295+
"""
296+
return _decode_authorization_list(self._authorizationList)
262297

263298

264299
Transaction = Union[

0 commit comments

Comments
 (0)