Skip to content

Commit 2b91e3b

Browse files
committed
chore: fix merge conflicts
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent b94b5e6 commit 2b91e3b

5 files changed

Lines changed: 63 additions & 551 deletions

File tree

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 0 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from hiero_sdk_python.consensus.topic_id import TopicId
77
from hiero_sdk_python.executable import _Method
88
from hiero_sdk_python.hapi.services import consensus_submit_message_pb2, transaction_pb2
9-
from hiero_sdk_python.hapi.services import consensus_submit_message_pb2, transaction_pb2
109
from hiero_sdk_python.hapi.services.schedulable_transaction_body_pb2 import (
1110
SchedulableTransactionBody,
1211
)
@@ -51,10 +50,6 @@ def __init__(
5150
if max_chunks is not None:
5251
self.set_max_chunks(max_chunks)
5352

54-
self.message: str | None = message
55-
self.chunk_size: int = chunk_size or 1024
56-
self.max_chunks: int = max_chunks or 20
57-
5853
self._total_chunks = self.get_required_chunks()
5954

6055
def _message_as_bytes(self) -> bytes:
@@ -68,8 +63,6 @@ def _message_as_bytes(self) -> bytes:
6863
return b""
6964

7065
return self.message.encode("utf-8") if isinstance(self.message, str) else self.message
71-
self._initial_transaction_id: TransactionId | None = None
72-
self._current_chunk_index: int | None = None
7366

7467
def get_required_chunks(self) -> int:
7568
"""
@@ -113,33 +106,6 @@ def set_message(self, message: bytes | str) -> TopicMessageSubmitTransaction:
113106
self._total_chunks = self.get_required_chunks()
114107
return self
115108

116-
def set_chunk_size(self, chunk_size: int) -> TopicMessageSubmitTransaction:
117-
"""
118-
Set maximum chunk size in bytes.
119-
120-
Args:
121-
chunk_size (int): The size of each chunk in bytes.
122-
123-
Returns:
124-
TopicMessageSubmitTransaction: This transaction instance (for chaining).
125-
"""
126-
super().set_chunk_size(chunk_size)
127-
self._total_chunks = self.get_required_chunks()
128-
return self
129-
130-
def set_max_chunks(self, max_chunks: int) -> TopicMessageSubmitTransaction:
131-
"""
132-
Set maximum allowed chunks.
133-
134-
Args:
135-
max_chunks (int): The maximum number of chunks allowed.
136-
137-
Returns:
138-
TopicMessageSubmitTransaction: This transaction instance (for chaining).
139-
"""
140-
super().set_max_chunks(max_chunks)
141-
return self
142-
143109
def set_custom_fee_limits(self, custom_fee_limits: list[CustomFeeLimit]) -> TopicMessageSubmitTransaction:
144110
"""
145111
Sets the maximum custom fees that the user is willing to pay for the message.
@@ -242,176 +208,6 @@ def _get_method(self, channel: _Channel) -> _Method:
242208
"""
243209
return _Method(transaction_func=channel.topic.submitMessage, query_func=None)
244210

245-
def sign(self, private_key: PrivateKey) -> TopicMessageSubmitTransaction:
246-
"""
247-
Signs the transaction using the provided private key.
248-
249-
Args:
250-
private_key (PrivateKey): The private key to sign the transaction with.
251-
252-
Returns:
253-
TopicMessageSubmitTransaction: This transaction instance (for chaining).
254-
"""
255-
super().sign(private_key)
256-
return self
257-
def freeze_with(self, client: Client) -> TopicMessageSubmitTransaction:
258-
if self._transaction_body_bytes:
259-
return self
260-
261-
self._resolve_transaction_id(client)
262-
self._resolve_node_ids(client)
263-
264-
required_chunks = self.get_required_chunks()
265-
self._generate_transaction_ids(self._transaction_ids[0], required_chunks)
266-
267-
self._initial_transaction_id = self._transaction_ids[0]
268-
269-
for chunk in range(self.get_required_chunks()):
270-
self._current_transaction_id_index = chunk
271-
self._current_chunk_index = chunk
272-
273-
node_bytes = {}
274-
275-
for node_account_id in self.node_account_ids:
276-
self._node_account_id = node_account_id
277-
278-
transaction_body = self.build_transaction_body()
279-
transaction_body.transactionID.CopyFrom(self._transaction_ids[chunk]._to_proto())
280-
transaction_body.nodeAccountID.CopyFrom(node_account_id._to_proto())
281-
282-
node_bytes[node_account_id] = transaction_body.SerializeToString()
283-
284-
self._transaction_body_bytes[self._transaction_ids[chunk]] = node_bytes
285-
286-
return super().freeze_with(client)
287-
288-
@overload
289-
def execute(
290-
self,
291-
client: Client,
292-
timeout: int | float | None = None,
293-
wait_for_receipt: Literal[True] = True,
294-
validate_status: bool = False,
295-
) -> TransactionReceipt: ...
296-
297-
@overload
298-
def execute(
299-
self,
300-
client: Client,
301-
timeout: int | float | None = None,
302-
wait_for_receipt: Literal[False] = False,
303-
validate_status: bool = False,
304-
) -> TransactionResponse: ...
305-
306-
def execute(
307-
self,
308-
client: Client,
309-
timeout: int | float | None = None,
310-
wait_for_receipt: bool = True,
311-
validate_status: bool = False,
312-
) -> TransactionReceipt | TransactionResponse:
313-
"""
314-
Executes the topic message submit transaction.
315-
316-
For multi-chunk transactions, this method will execute all chunks sequentially and return first response.
317-
318-
Args:
319-
client: The client to execute the transaction with.
320-
timeout (int | float | None, optional): The total execution timeout (in seconds) for this execution.
321-
wait_for_receipt (bool, optional): Whether to wait for consensus and return the receipt.
322-
If False, the method returns a TransactionResponse immediately after submission.
323-
validate_status: (bool): Whether the query should automatically validate the transaction status (default False).
324-
325-
Returns:
326-
TransactionReceipt: If wait_for_receipt is True (default)
327-
TransactionResponse: If wait_for_receipt is False
328-
"""
329-
# Return the first response as the JS SDK does
330-
return self.execute_all(client, timeout, wait_for_receipt, validate_status)[0]
331-
332-
@overload
333-
def execute_all(
334-
self,
335-
client: Client,
336-
timeout: int | float | None = None,
337-
wait_for_receipt: Literal[True] = True,
338-
validate_status: bool = False,
339-
) -> list[TransactionReceipt]: ...
340-
341-
@overload
342-
def execute_all(
343-
self,
344-
client: Client,
345-
timeout: int | float | None = None,
346-
wait_for_receipt: Literal[False] = False,
347-
validate_status: bool = False,
348-
) -> list[TransactionResponse]: ...
349-
350-
def execute_all(
351-
self,
352-
client: Client,
353-
timeout: int | float | None = None,
354-
wait_for_receipt: bool = True,
355-
validate_status: bool = False,
356-
) -> list[TransactionReceipt] | list[TransactionResponse]:
357-
"""
358-
Executes the topic message submit transaction.
359-
360-
This method will execute all chunks sequentially and return list of all responses.
361-
362-
Args:
363-
client: The client to execute the transaction with.
364-
timeout (int | float | None, optional): The total execution timeout (in seconds) for this execution.
365-
wait_for_receipt (bool, optional): Whether to wait for consensus and return the receipt.
366-
If False, the method returns a TransactionResponse immediately after submission.
367-
validate_status: (bool): Whether the query should automatically validate the transaction status (default False).
368-
369-
Returns:
370-
List[TransactionReceipt]: If wait_for_receipt is True (default)
371-
List[TransactionResponse]: If wait_for_receipt is False
372-
"""
373-
self._validate_chunking()
374-
375-
if not self._transaction_body_bytes:
376-
self.freeze_with(client)
377-
378-
if len(self._transaction_ids) == 1:
379-
return [super().execute(client, timeout, wait_for_receipt, validate_status)]
380-
381-
# Multi-chunk transaction - execute all chunks
382-
responses = []
383-
self._current_transaction_id_index = 0
384-
for index in range(len(self._transaction_ids)):
385-
self._current_transaction_id_index = index
386-
response = super().execute(client, timeout, wait_for_receipt, validate_status)
387-
responses.append(response)
388-
389-
return responses
390-
391-
@property
392-
def body_size_all_chunks(self) -> list[int]:
393-
"""Returns an array of body sizes for transactions with multiple chunks."""
394-
self._require_frozen()
395-
sizes = []
396-
397-
original_transaction_index = self._current_transaction_id_index
398-
399-
try:
400-
for i, _ in enumerate(self._transaction_ids):
401-
self._current_chunk_index = i
402-
self._current_transaction_id_index = i
403-
404-
self._chunk_info = consensus_submit_message_pb2.ConsensusMessageChunkInfo(
405-
initialTransactionID=self._initial_transaction_id._to_proto(),
406-
total=self._total_chunks,
407-
number=i + 1,
408-
)
409-
sizes.append(self.body_size)
410-
finally:
411-
self._current_transaction_id_index = original_transaction_index
412-
413-
return sizes
414-
415211
@classmethod
416212
def _from_protobuf(cls, transaction_body):
417213
transaction = super()._from_protobuf(transaction_body)

0 commit comments

Comments
 (0)