Skip to content

Commit e2cce47

Browse files
chore: remove hardcoded testnet messages (#670)
Signed-off-by: ekarvou <[email protected]> Signed-off-by: exploreriii <[email protected]> Co-authored-by: exploreriii <[email protected]>
1 parent 8d592d7 commit e2cce47

File tree

83 files changed

+527
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+527
-311
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2929
- docs: Add `docs/sdk_developers/project_structure.md` to explain repository layout and import paths.
3030

3131
### Changed
32+
- chore: replaced hardcoded 'testnet' messages with environment network name
3233
- chore: validate that token airdrop transactions require an available token service on the channel (#632)
3334
- chore: update local environment configuration in env.example (#649)
3435
- chore: Update env.example NETWORK to encourage testnet or local usage (#659)

examples/account_allowance_hbar.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
from hiero_sdk_python.transaction.transfer_transaction import TransferTransaction
1717

1818
load_dotenv()
19-
19+
network_name = os.getenv('NETWORK', 'testnet').lower()
2020

2121
def setup_client():
2222
"""Initialize and set up the client with operator account"""
23-
network = Network(os.getenv('NETWORK'))
23+
network = Network(network_name)
24+
print(f"Connecting to Hedera {network_name} network!")
2425
client = Client(network)
2526

26-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
27-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
27+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID",""))
28+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY",""))
2829
client.set_operator(operator_id, operator_key)
30+
print(f"Client set up with operator id {client.operator_account_id}")
2931

3032
return client
3133

examples/account_allowance_nft.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@
2727

2828
load_dotenv()
2929

30+
network_name = os.getenv('NETWORK', 'testnet').lower()
3031

3132
def setup_client():
3233
"""Initialize and set up the client with operator account"""
33-
network = Network(os.getenv('NETWORK'))
34+
network = Network(network_name)
35+
print(f"Connecting to Hedera {network_name} network!")
3436
client = Client(network)
3537

36-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
37-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
38+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID",""))
39+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY",""))
3840
client.set_operator(operator_id, operator_key)
41+
print(f"Client set up with operator id {client.operator_account_id}")
3942

4043
return client
4144

examples/account_create.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838

3939
load_dotenv()
40+
network_name = os.getenv('NETWORK', 'testnet').lower()
4041

4142
def setup_client() -> Tuple[Client, PrivateKey]:
4243
"""
@@ -59,11 +60,13 @@ def setup_client() -> Tuple[Client, PrivateKey]:
5960
OPERATOR_ID (str): The account ID of the operator (format: "0.0.xxxxx")
6061
OPERATOR_KEY (str): The private key of the operator account
6162
"""
62-
network = Network(os.getenv('NETWORK'))
63+
64+
network = Network(network_name)
65+
print(f"Connecting to Hedera {network_name} network!")
6366
client = Client(network)
6467

65-
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
66-
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
68+
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID',''))
69+
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY',''))
6770
client.set_operator(operator_id, operator_key)
6871

6972
return client, operator_key

examples/account_delete.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717

1818
load_dotenv()
1919

20+
network_name = os.getenv('NETWORK', 'testnet').lower()
2021

2122
def setup_client():
2223
"""Initialize and set up the client with operator account"""
23-
network = Network(os.getenv('NETWORK'))
24+
network = Network(network_name)
25+
print(f"Connecting to Hedera {network_name} network!")
2426
client = Client(network)
2527

26-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
27-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
28+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
29+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
2830
client.set_operator(operator_id, operator_key)
31+
print(f"Client set up with operator id {client.operator_account_id}")
2932

3033
return client
3134

32-
3335
def create_account(client):
3436
"""Create a test account"""
3537
account_private_key = PrivateKey.generate_ed25519()

examples/account_update.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@
2020

2121
load_dotenv()
2222

23+
network_name = os.getenv('NETWORK', 'testnet').lower()
2324

2425
def setup_client():
2526
"""Initialize and set up the client with operator account"""
26-
network = Network(os.getenv('NETWORK'))
27+
network = Network(network_name)
28+
print(f"Connecting to Hedera {network_name} network!")
2729
client = Client(network)
2830

29-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
30-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
31+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
32+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
3133
client.set_operator(operator_id, operator_key)
34+
print(f"Client set up with operator id {client.operator_account_id}")
3235

3336
return client
3437

examples/contract_create.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@
3333

3434
load_dotenv()
3535

36+
network_name = os.getenv('NETWORK', 'testnet').lower()
3637

3738
def setup_client():
3839
"""Initialize and set up the client with operator account"""
39-
network = Network(os.getenv('NETWORK'))
40+
network = Network(network_name)
41+
print(f"Connecting to Hedera {network_name} network!")
4042
client = Client(network)
4143

42-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
43-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
44+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
45+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
4446
client.set_operator(operator_id, operator_key)
47+
print(f"Client set up with operator id {client.operator_account_id}")
4548

4649
return client
4750

examples/contract_create_constructor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@
3737

3838
load_dotenv()
3939

40+
network_name = os.getenv('NETWORK', 'testnet').lower()
4041

4142
def setup_client():
4243
"""Initialize and set up the client with operator account"""
43-
network = Network(os.getenv('NETWORK'))
44+
network = Network(network_name)
45+
print(f"Connecting to Hedera {network_name} network!")
4446
client = Client(network)
4547

46-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
47-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
48+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
49+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
4850
client.set_operator(operator_id, operator_key)
51+
print(f"Client set up with operator id {client.operator_account_id}")
4952

5053
return client
5154

examples/contract_create_with_bytecode.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@
3232

3333
load_dotenv()
3434

35+
network_name = os.getenv('NETWORK', 'testnet').lower()
3536

3637
def setup_client():
3738
"""Initialize and set up the client with operator account"""
38-
network = Network(os.getenv('NETWORK'))
39+
network = Network(network_name)
40+
print(f"Connecting to Hedera {network_name} network!")
3941
client = Client(network)
4042

41-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
42-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
43+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
44+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
4345
client.set_operator(operator_id, operator_key)
46+
print(f"Client set up with operator id {client.operator_account_id}")
4447

4548
return client
4649

examples/contract_delete.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@
4242

4343
load_dotenv()
4444

45+
network_name = os.getenv('NETWORK', 'testnet').lower()
4546

4647
def setup_client():
4748
"""Initialize and set up the client with operator account"""
48-
network = Network(os.getenv('NETWORK'))
49+
network = Network(network_name)
50+
print(f"Connecting to Hedera {network_name} network!")
4951
client = Client(network)
5052

51-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
52-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
53+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
54+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
5355
client.set_operator(operator_id, operator_key)
56+
print(f"Client set up with operator id {client.operator_account_id}")
5457

5558
return client
5659

0 commit comments

Comments
 (0)