Skip to content

Commit 04c4496

Browse files
committed
Create ChunkedTransaction class
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
1 parent 5961cce commit 04c4496

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import math
4+
35
from hiero_sdk_python.channels import _Channel
46
from hiero_sdk_python.consensus.topic_id import TopicId
57
from hiero_sdk_python.crypto.private_key import PrivateKey
@@ -63,7 +65,6 @@ def _message_as_bytes(self) -> bytes:
6365

6466
return self.message.encode("utf-8") if isinstance(self.message, str) else self.message
6567

66-
6768
def get_required_chunks(self) -> int:
6869
"""
6970
Returns the number of chunks required for the current message.
@@ -75,7 +76,6 @@ def get_required_chunks(self) -> int:
7576
return 1
7677

7778
content = self._message_as_bytes()
78-
import math
7979
return math.ceil(len(content) / self.chunk_size)
8080

8181
def set_topic_id(self, topic_id: TopicId) -> TopicMessageSubmitTransaction:

src/hiero_sdk_python/file/file_append_transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Inherits from the base Transaction class and implements the required methods
1111
to build and execute a file append transaction.
1212
"""
13+
1314
from __future__ import annotations
1415

1516
import math

src/hiero_sdk_python/transaction/chunked_transaction.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def _validate_chunking(self) -> int:
132132
)
133133
return required
134134

135-
136135
def freeze_with(self, client: Client) -> ChunkedTransaction:
137136
"""
138137
Freezes the transaction by building transaction bodies for all chunks.
@@ -189,8 +188,7 @@ def execute(
189188
timeout: int | float | None = None,
190189
wait_for_receipt: Literal[True] = True,
191190
validate_status: bool = False,
192-
) -> TransactionReceipt:
193-
...
191+
) -> TransactionReceipt: ...
194192

195193
@overload
196194
def execute(
@@ -199,8 +197,7 @@ def execute(
199197
timeout: int | float | None = None,
200198
wait_for_receipt: Literal[False] = False,
201199
validate_status: bool = False,
202-
) -> TransactionResponse:
203-
...
200+
) -> TransactionResponse: ...
204201

205202
def execute(
206203
self,
@@ -235,8 +232,7 @@ def execute_all(
235232
timeout: int | float | None = None,
236233
wait_for_receipt: Literal[True] = True,
237234
validate_status: bool = False,
238-
) -> list[TransactionReceipt]:
239-
...
235+
) -> list[TransactionReceipt]: ...
240236

241237
@overload
242238
def execute_all(
@@ -245,8 +241,7 @@ def execute_all(
245241
timeout: int | float | None = None,
246242
wait_for_receipt: Literal[False] = False,
247243
validate_status: bool = False,
248-
) -> list[TransactionResponse]:
249-
...
244+
) -> list[TransactionResponse]: ...
250245

251246
def execute_all(
252247
self,

tests/unit/chunked_transaction_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_constructor_sets_default_chunk_configuration():
5252
@pytest.mark.parametrize(
5353
"setter_name, value, message",
5454
[("set_chunk_size", 0, "chunk_size must be positive"), ("set_max_chunks", 0, "max_chunks must be positive")],
55-
)
55+
)
5656
def test_setters_reject_non_positive_values(mock_client, setter_name, value, message):
5757
tx = DummyChunkedTransaction()
5858

0 commit comments

Comments
 (0)