Inserting by index looks extremely brittle. Could we do something like:
from dataclass import fields
@dataclass
class Foobar:
nonce: Optional[Uint]
gasLimit: Optional[Uint]
# ...
def to_list(self) -> List[?]:
parameters = []
for name in fields(self):
value = getattr(self, name)
if value is None:
continue
parameters.append(value)
Or is that overkill?
_Originally posted by @SamWilsn in https://github.com/ethereum/execution-specs/pull/867#discussion_r1475180953_