Skip to content

Commit a3cfa1a

Browse files
authored
fix: Type hints for topic-related transactions (#599)
Signed-off-by: Manish Dait <[email protected]>
1 parent d64f11f commit a3cfa1a

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
4848

4949
- Add type hints to `setup_client()` and `create_new_account()` functions in `examples/account_create.py` (#418)
5050
- Added explicit read and write permissions to test.yml
51+
- Type hinting for `Topic` related transactions.
5152

5253
### Removed
5354
- Remove deprecated camelCase alias support and `_DeprecatedAliasesMixin`; SDK now only exposes snake_case attributes for `NftId`, `TokenInfo`, and `TransactionReceipt`. (Issue #428)

src/hiero_sdk_python/consensus/topic_delete_transaction.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"""
88

99
from typing import Optional
10+
from hiero_sdk_python.consensus.topic_id import TopicId
1011
from hiero_sdk_python.transaction.transaction import Transaction
1112
from hiero_sdk_python.hapi.services import (
1213
consensus_delete_topic_pb2,
13-
transaction_pb2,
14-
basic_types_pb2
14+
transaction_pb2
1515
)
1616
from hiero_sdk_python.hapi.services.schedulable_transaction_body_pb2 import (
1717
SchedulableTransactionBody,
@@ -27,12 +27,12 @@ class TopicDeleteTransaction(Transaction):
2727
2828
"""
2929

30-
def __init__(self, topic_id: Optional[basic_types_pb2.TopicID] = None) -> None:
30+
def __init__(self, topic_id: Optional[TopicId] = None) -> None:
3131
super().__init__()
32-
self.topic_id: Optional[basic_types_pb2.TopicID] = topic_id
32+
self.topic_id: Optional[TopicId] = topic_id
3333
self.transaction_fee: int = 10_000_000
3434

35-
def set_topic_id(self, topic_id: basic_types_pb2.TopicID ) -> "TopicDeleteTransaction":
35+
def set_topic_id(self, topic_id:TopicId ) -> "TopicDeleteTransaction":
3636
"""
3737
Sets the topic ID for the transaction.
3838

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"""
55
from typing import Optional
66

7+
from hiero_sdk_python.consensus.topic_id import TopicId
78
from hiero_sdk_python.transaction.transaction import Transaction
89
from hiero_sdk_python.transaction.custom_fee_limit import CustomFeeLimit
9-
from hiero_sdk_python.hapi.services import consensus_submit_message_pb2, basic_types_pb2
10+
from hiero_sdk_python.hapi.services import consensus_submit_message_pb2
1011
from hiero_sdk_python.hapi.services import transaction_pb2
1112
from hiero_sdk_python.hapi.services.schedulable_transaction_body_pb2 import (
1213
SchedulableTransactionBody,
@@ -25,27 +26,27 @@ class TopicMessageSubmitTransaction(Transaction):
2526

2627
def __init__(
2728
self,
28-
topic_id: Optional[basic_types_pb2.TopicID] = None,
29+
topic_id: Optional[TopicId] = None,
2930
message: Optional[str] = None,
3031
) -> None:
3132
"""
3233
Initializes a new TopicMessageSubmitTransaction instance.
3334
Args:
34-
topic_id (Optional[TopicID]): The ID of the topic.
35+
topic_id (Optional[TopicId]): The ID of the topic.
3536
message (Optional[str]): The message to submit.
3637
"""
3738
super().__init__()
38-
self.topic_id: Optional[basic_types_pb2.TopicID] = topic_id
39+
self.topic_id: Optional[TopicId] = topic_id
3940
self.message: Optional[str] = message
4041

4142
def set_topic_id(
42-
self, topic_id: basic_types_pb2.TopicID
43+
self, topic_id: TopicId
4344
) -> "TopicMessageSubmitTransaction":
4445
"""
4546
Sets the topic ID for the message submission.
4647
4748
Args:
48-
topic_id (TopicID): The ID of the topic to which the message is submitted.
49+
topic_id (TopicId): The ID of the topic to which the message is submitted.
4950
5051
Returns:
5152
TopicMessageSubmitTransaction: This transaction instance (for chaining).

src/hiero_sdk_python/consensus/topic_update_transaction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
from google.protobuf import wrappers_pb2 as _wrappers_pb2
77
from hiero_sdk_python.Duration import Duration
88
from hiero_sdk_python.channels import _Channel
9+
from hiero_sdk_python.consensus.topic_id import TopicId
910
from hiero_sdk_python.executable import _Method
1011
from hiero_sdk_python.hapi.services.custom_fees_pb2 import FeeExemptKeyList
1112
from hiero_sdk_python.hapi.services.custom_fees_pb2 import FixedCustomFeeList
1213
from hiero_sdk_python.timestamp import Timestamp
1314
from hiero_sdk_python.transaction.transaction import Transaction
1415
from hiero_sdk_python.hapi.services import (
15-
basic_types_pb2,
1616
consensus_update_topic_pb2,
1717
duration_pb2,
1818
timestamp_pb2,
@@ -29,7 +29,7 @@ class TopicUpdateTransaction(Transaction):
2929
"""Represents a transaction to update a consensus topic."""
3030
def __init__(
3131
self,
32-
topic_id: Optional[basic_types_pb2.TopicID] = None,
32+
topic_id: Optional[TopicId] = None,
3333
memo: Optional[str] = None,
3434
admin_key: Optional[PublicKey] = None,
3535
submit_key: Optional[PublicKey] = None,
@@ -43,16 +43,16 @@ def __init__(
4343
"""
4444
Initializes a new instance of the TopicUpdateTransaction class.
4545
Args:
46-
topic_id (basic_types_pb2.TopicID): The ID of the topic to update.
46+
topic_id (TopicId): The ID of the topic to update.
4747
memo (str): The memo associated with the topic.
4848
admin_key (PublicKey): The admin key for the topic.
4949
submit_key (PublicKey): The submit key for the topic.
5050
auto_renew_period (Duration): The auto-renew period for the topic.
5151
auto_renew_account (AccountId): The account ID for auto-renewal.
52-
expiration_time (timestamp_pb2.Timestamp): The expiration time of the topic.
52+
expiration_time (Timestamp): The expiration time of the topic.
5353
"""
5454
super().__init__()
55-
self.topic_id: Optional[basic_types_pb2.TopicID] = topic_id
55+
self.topic_id: Optional[TopicId] = topic_id
5656
self.memo: str = memo or ""
5757
self.admin_key: Optional[PublicKey] = admin_key
5858
self.submit_key: Optional[PublicKey] = submit_key
@@ -64,7 +64,7 @@ def __init__(
6464
self.fee_schedule_key: Optional[PublicKey] = fee_schedule_key
6565
self.fee_exempt_keys: Optional[List[PublicKey]] = fee_exempt_keys
6666

67-
def set_topic_id(self, topic_id: basic_types_pb2.TopicID) -> "TopicUpdateTransaction":
67+
def set_topic_id(self, topic_id: TopicId) -> "TopicUpdateTransaction":
6868
"""
6969
Sets the topic ID for the transaction.
7070

0 commit comments

Comments
 (0)