Skip to content

Commit 7045f6e

Browse files
authored
Merge branch 'main' into fix/refactor-workflows-deterministic
2 parents a5a1792 + 74a947a commit 7045f6e

5 files changed

Lines changed: 186 additions & 3 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
name: "Approve Issues"
4+
5+
on:
6+
issues:
7+
types:
8+
- labeled
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
permissions:
15+
issues: write
16+
17+
concurrency:
18+
group: approve-issues-${{ github.event.issue.number }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
approve:
23+
if: github.event.label.name == 'approved'
24+
name: Approve Issue
25+
runs-on: hl-sdk-py-lin-md
26+
27+
steps:
28+
- name: Harden Runner
29+
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
30+
with:
31+
egress-policy: audit
32+
33+
- name: Remove pending-review label
34+
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
labels: pending-review
38+
39+
- name: Unlock issue
40+
run: |
41+
gh api \
42+
-X DELETE \
43+
repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/lock
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Approval comment
48+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
49+
with:
50+
issue-number: ${{ github.event.issue.number }}
51+
body: |
52+
Approved by @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
name: "Moderate New Issues"
4+
5+
on:
6+
issues:
7+
types:
8+
- opened
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
permissions:
15+
issues: write
16+
17+
concurrency:
18+
group: moderate-issues-${{ github.event.issue.number }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
moderate:
23+
name: Moderate Issue
24+
runs-on: hl-sdk-py-lin-md
25+
26+
steps:
27+
- name: Harden Runner
28+
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
29+
with:
30+
egress-policy: audit
31+
32+
- name: Add pending-review label
33+
uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8 # v1.1.0
34+
with:
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
labels: pending-review
37+
38+
- name: Comment on issue
39+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
40+
with:
41+
issue-number: ${{ github.event.issue.number }}
42+
body: |
43+
Thanks for your submission.
44+
45+
This issue is awaiting approval from @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
46+
47+
- name: Lock issue (IMPORTANT FIX)
48+
run: |
49+
gh api \
50+
-X PUT \
51+
repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/lock \
52+
-f lock_reason=off-topic
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/hiero_sdk_python/consensus/topic_create_transaction.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from __future__ import annotations
1111

12+
from typing import TYPE_CHECKING
13+
1214
from hiero_sdk_python.account.account_id import AccountId
1315
from hiero_sdk_python.channels import _Channel
1416
from hiero_sdk_python.crypto.key import Key
@@ -23,6 +25,10 @@
2325
from hiero_sdk_python.utils.key_utils import key_to_proto
2426

2527

28+
if TYPE_CHECKING:
29+
from hiero_sdk_python.client.client import Client
30+
31+
2632
class TopicCreateTransaction(Transaction):
2733
"""
2834
Represents a transaction to create a new topic in the Hedera
@@ -187,6 +193,27 @@ def set_fee_exempt_keys(self, keys: list[Key]) -> TopicCreateTransaction:
187193
self.fee_exempt_keys = keys
188194
return self
189195

196+
def freeze_with(self, client: Client) -> TopicCreateTransaction:
197+
"""
198+
Freeze the transaction with the given client.
199+
200+
If `auto_renew_account` was not explicitly set, automatically assigns it:
201+
- If `transaction_id` is already set, use its `account_id`.
202+
- Otherwise, fall back to the client's `operator_account_id`.
203+
204+
Args:
205+
client (Client): The client instance to use for setting defaults.
206+
207+
Returns:
208+
TopicCreateTransaction: The current transaction instance for method chaining.
209+
"""
210+
if client is not None and client.operator_account_id is not None and self.auto_renew_account is None:
211+
self.auto_renew_account = (
212+
self.transaction_id.account_id if self.transaction_id is not None else client.operator_account_id
213+
)
214+
215+
return super().freeze_with(client)
216+
190217
def _to_proto_key(self, key: Key | None):
191218
"""
192219
Backwards-compatible wrapper around `key_to_proto` for converting SDK keys

tck/handlers/topic.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ def create_topic(params: CreateTopicParams) -> CreateTopicResponse:
7373

7474
transaction = _build_create_topic_transaction(params)
7575

76-
if params.autoRenewAccountId is None and client is not None and client.operator_account_id is not None:
77-
transaction.set_auto_renew_account(client.operator_account_id)
78-
7976
if params.commonTransactionParams is not None:
8077
params.commonTransactionParams.apply_common_params(transaction, client)
8178

tests/unit/topic_create_transaction_test.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from hiero_sdk_python.response_code import ResponseCode
2424
from hiero_sdk_python.tokens.custom_fixed_fee import CustomFixedFee
2525
from hiero_sdk_python.tokens.token_id import TokenId
26+
from hiero_sdk_python.transaction.transaction_id import TransactionId
2627
from tests.unit.mock_server import mock_hedera_servers
2728

2829

@@ -574,3 +575,55 @@ def test_mixed_key_types_in_constructor(mock_account_ids):
574575
assert transaction_body.consensusCreateTopic.submitKey.ed25519 == ed25519_public.to_bytes_raw()
575576
assert transaction_body.consensusCreateTopic.fee_schedule_key.HasField("ECDSA_secp256k1")
576577
assert len(transaction_body.consensusCreateTopic.fee_exempt_key_list) == 2
578+
579+
580+
def test_freeze_with_defaults_auto_renew_account_to_operator(mock_client):
581+
"""Test that freeze_with sets auto_renew_account to operator when not explicitly set."""
582+
tx = TopicCreateTransaction(memo="test topic")
583+
frozen_tx = tx.freeze_with(mock_client)
584+
body = frozen_tx.build_transaction_body()
585+
586+
assert body.consensusCreateTopic.autoRenewAccount == mock_client.operator_account_id._to_proto()
587+
588+
589+
def test_freeze_with_preserves_explicit_auto_renew_account(mock_client):
590+
"""Test that freeze_with does not override an explicitly set auto_renew_account."""
591+
explicit_account = AccountId(0, 0, 9999)
592+
tx = TopicCreateTransaction(memo="test topic", auto_renew_account=explicit_account)
593+
frozen_tx = tx.freeze_with(mock_client)
594+
body = frozen_tx.build_transaction_body()
595+
596+
assert body.consensusCreateTopic.autoRenewAccount == explicit_account._to_proto()
597+
598+
599+
def test_freeze_with_uses_transaction_id_account_when_set(mock_client):
600+
"""Test that freeze_with uses transaction_id.account_id when transaction_id is set."""
601+
tx_account = AccountId(0, 0, 5555)
602+
tx = TopicCreateTransaction(memo="test topic")
603+
tx.transaction_id = TransactionId.generate(tx_account)
604+
frozen_tx = tx.freeze_with(mock_client)
605+
body = frozen_tx.build_transaction_body()
606+
607+
assert body.consensusCreateTopic.autoRenewAccount == tx_account._to_proto()
608+
609+
610+
def test_freeze_with_auto_renew_account_set_via_setter(mock_client):
611+
"""Test that freeze_with preserves auto_renew_account set via set_auto_renew_account."""
612+
explicit_account = AccountId(0, 0, 7777)
613+
tx = TopicCreateTransaction(memo="test topic")
614+
tx.set_auto_renew_account(explicit_account)
615+
frozen_tx = tx.freeze_with(mock_client)
616+
body = frozen_tx.build_transaction_body()
617+
618+
assert body.consensusCreateTopic.autoRenewAccount == explicit_account._to_proto()
619+
620+
621+
def test_freeze_with_leaves_auto_renew_account_unset_without_operator(mock_client):
622+
"""Test that freeze_with leaves auto_renew_account unset when operator_account_id is None."""
623+
mock_client.operator_account_id = None
624+
tx = TopicCreateTransaction(memo="test topic")
625+
tx.transaction_id = TransactionId.generate(AccountId(0, 0, 1234))
626+
frozen_tx = tx.freeze_with(mock_client)
627+
body = frozen_tx.build_transaction_body()
628+
629+
assert not body.consensusCreateTopic.HasField("autoRenewAccount")

0 commit comments

Comments
 (0)