1212from hiero_sdk_python .transaction .transaction_response import TransactionResponse
1313
1414
15- if TYPE_CHECKING :
16- pass
17-
18-
1915class ChunkedTransaction (Transaction , ABC ):
2016 """
2117 Abstract base class for transactions that support chunking.
@@ -43,17 +39,6 @@ def __init__(self) -> None:
4339 self .chunk_size : int = 1024
4440 self .max_chunks : int = 20
4541
46- @abstractmethod
47- def get_required_chunks (self ) -> int :
48- """
49- Returns the number of chunks required for the current content.
50-
51- Subclasses must implement this based on their content type.
52-
53- Returns:
54- int: Number of chunks required.
55- """
56- pass
5742
5843 @abstractmethod
5944 def _build_proto_body (self ):
@@ -148,10 +133,9 @@ def freeze_with(self, client: Client) -> ChunkedTransaction:
148133 if self ._transaction_body_bytes :
149134 return self
150135
151- self ._validate_chunking ()
152136 self ._resolve_transaction_id (client )
153137
154- if self .transaction_id is None or self . transaction_id .valid_start is None :
138+ if self .transaction_id .valid_start is None :
155139 raise ValueError ("Transaction ID with valid_start must be set before freezing chunked transaction." )
156140
157141 # Generate transaction IDs for all chunks if not already done
@@ -265,11 +249,10 @@ def execute_all(
265249 List[TransactionReceipt]: If wait_for_receipt is True (default)
266250 List[TransactionResponse]: If wait_for_receipt is False
267251 """
268- self ._validate_chunking ()
269-
270- required_chunks = self .get_required_chunks ()
252+ self ._validate_chunking () # Moved here
271253
272- if required_chunks == 1 :
254+ # For single-chunk transactions, delegate to the standard execution flow.
255+ if self .get_required_chunks () == 1 :
273256 return [
274257 super ().execute (
275258 client ,
@@ -279,13 +262,14 @@ def execute_all(
279262 )
280263 ]
281264
282- # Ensure the initial transaction ID and chunk transaction IDs exist .
283- if not self ._transaction_ids :
265+ # For multi-chunk transactions, ensure we are frozen before proceeding .
266+ if not self ._transaction_body_bytes :
284267 self .freeze_with (client )
285268
286269 responses = []
270+ required_chunks = self .get_required_chunks ()
287271
288- for chunk_index in range (required_chunks ):
272+ for chunk_index in range (self . get_required_chunks () ):
289273 self ._current_chunk_index = chunk_index
290274
291275 if chunk_index < len (self ._transaction_ids ):
0 commit comments