@@ -652,58 +652,54 @@ class NetworkWrappedTransaction(CamelModel, RLPSerializable):
652652 """
653653 Network wrapped transaction as defined in
654654 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#networking).
655- """
656-
657- tx : Transaction
658- wrapper_version : Union [Bytes | None ] = None
659- blobs : Sequence [Blob ]
660655
661- @computed_field # type: ignore[prop-decorator]
662- @property
663- def blob_wrapper_version (self ) -> bytes | None :
664- """Return the wrapper version (byte 1 for Osaka, None pre-Osaka)."""
665- # TODO: it could be a mix of blobs from different forks, then what would be the wrapper version?
666- if len (self .blobs ) == 0 :
667- return None
656+ < Osaka:
657+ rlp([tx_payload_body, blobs, commitments, proofs])
668658
669- fork = self .blobs [0 ].fork
670- amount_cell_proofs = fork .get_blob_constant ("AMOUNT_CELL_PROOFS" )
671- assert isinstance (amount_cell_proofs , int ), (
672- f"Expected AMOUNT_CELL_PROOFS of fork { fork } to be an int but this is not the case!"
673- )
674- if amount_cell_proofs > 0 :
675- return bytes ([1 ])
659+ >= Osaka:
660+ rlp([tx_payload_body, wrapper_version, blobs, commitments, cell_proofs])
661+ """
676662
677- return None
663+ tx : Transaction
664+ blob_objects : Sequence [Blob ]
665+ wrapper_version : Union [Bytes | None ] = None # only exists in >= osaka
678666
679667 @computed_field # type: ignore[prop-decorator]
680668 @property
681- def blob_data (self ) -> Sequence [Bytes ]:
682- """Return a list of blobs as bytes."""
683- return [blob .data for blob in self .blobs ]
669+ def blobs (self ) -> Sequence [Bytes ]:
670+ """Return a list of blob data as bytes."""
671+ return [blob .data for blob in self .blob_objects ]
684672
685673 @computed_field # type: ignore[prop-decorator]
686674 @property
687- def blob_kzg_commitments (self ) -> Sequence [Bytes ]:
675+ def commitments (self ) -> Sequence [Bytes ]:
688676 """Return a list of kzg commitments."""
689- return [blob .commitment for blob in self .blobs ]
677+ return [blob .commitment for blob in self .blob_objects ]
690678
691679 @computed_field # type: ignore[prop-decorator]
692680 @property
693- def blob_kzg_proofs (self ) -> Sequence [Bytes | Sequence [Bytes ]]:
694- """Return a list of kzg proofs."""
695- proofs : list [Bytes | list [Bytes ]] = []
696- for blob in self .blobs :
681+ def proofs (self ) -> Sequence [Bytes ] | None :
682+ """Return a list of kzg proofs (returns None >= Osaka)."""
683+ if self .wrapper_version is not None :
684+ return None
685+
686+ proofs : list [Bytes ] = []
687+ for blob in self .blob_objects :
688+ assert isinstance (blob .proof , Bytes )
697689 proofs .append (blob .proof )
698690
699691 return proofs
700692
701693 @computed_field # type: ignore[prop-decorator]
702694 @property
703- def blob_cells (self ) -> Sequence [Sequence [Bytes ] | None ]:
704- """Return a list of cells."""
705- cells : list [list [Bytes ] | None ] = []
706- for blob in self .blobs :
695+ def cell_proofs (self ) -> Sequence [Sequence [Bytes ]] | None :
696+ """Return a list of cells (returns None < Osaka)."""
697+ if self .wrapper_version is None :
698+ return None
699+
700+ cells : list [list [Bytes ]] = []
701+ for blob in self .blob_objects :
702+ assert isinstance (blob .cells , list )
707703 cells .append (blob .cells )
708704
709705 return cells
@@ -718,13 +714,26 @@ def get_rlp_fields(self) -> List[str]:
718714
719715 The list can be nested list up to one extra level to represent nested fields.
720716 """
717+ # only put a wrapper_version field for >=osaka (value 1), otherwise omit field
718+ wrapper = []
719+ if self .wrapper_version is not None :
720+ wrapper = ["wrapper_version" ]
721+
722+ proofs : list [str ] = []
723+ if len (proofs ) > 0 :
724+ proofs = ["proofs" ]
725+
726+ cell_proofs : list [str ] = []
727+ if len (cell_proofs ) > 0 :
728+ cell_proofs = ["cell_proofs" ]
729+
721730 return [ # structure explained in https://eips.ethereum.org/EIPS/eip-7594#Networking
722731 "tx" , # tx_payload_body
723- "blob_wrapper_version" , # wrapper_version, which is always 1 for osaka (was it non-existing before? )
724- "blob_data " , # blobs
725- "blob_kzg_commitments" , # commitments
726- "blob_kzg_proofs" , # cell_proofs
727- "blob_cells" ,
732+ * wrapper , # wrapper_version, which is always 1 for osaka (was non-existing before)
733+ "blobs " , # Blob.data
734+ "commitments" ,
735+ * proofs , # only included < osaka
736+ * cell_proofs , # only included >= osaka
728737 ]
729738
730739 def get_rlp_prefix (self ) -> bytes :
0 commit comments