Skip to content

Commit a427380

Browse files
authored
fix: Split custom_fee.py into three separate examples (#674)
Signed-off-by: Adityarya11 <arya050411@gmail.com>
1 parent 28a7bb6 commit a427380

File tree

5 files changed

+102
-94
lines changed

5 files changed

+102
-94
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
2525
- chore: Refactored the script of examples/custom_fee.py into modular functions
2626

2727
- fix: Replaced `collections.namedtuple` with `typing.NamedTuple` in `client.py` for improved type checking.
28+
- chore: Refactored examples/custom_fee.py into three separate example files.
2829

2930

3031
### Fixed

examples/custom_fee.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

examples/custom_fee_fixed.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Run with:
3+
uv run examples/custom_fixed_fee.py
4+
python examples/custom_fixed_fee.py
5+
"""
6+
from hiero_sdk_python.tokens.custom_fixed_fee import CustomFixedFee
7+
from hiero_sdk_python.account.account_id import AccountId
8+
from hiero_sdk_python.tokens.token_id import TokenId
9+
10+
def custom_fixed_fee():
11+
fixed_fee = CustomFixedFee(
12+
amount=100,
13+
denominating_token_id=TokenId(0, 0, 123),
14+
fee_collector_account_id=AccountId(0, 0, 456),
15+
all_collectors_are_exempt=False,
16+
)
17+
print("CustomFixedFee:")
18+
print(f"Amount: {fixed_fee.amount}")
19+
print(f"Denominating Token ID: {fixed_fee.denominating_token_id}")
20+
print(f"Fee Collector Account ID: {fixed_fee.fee_collector_account_id}")
21+
print(f"All Collectors Exempt: {fixed_fee.all_collectors_are_exempt}")
22+
# Convert to protobuf
23+
fixed_fee_proto = fixed_fee._to_proto()
24+
25+
print("Fixed Fee Protobuf:", fixed_fee_proto)
26+
27+
28+
if __name__ == "__main__":
29+
custom_fixed_fee()

examples/custom_fee_fractional.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Run with:
3+
uv run examples/custom_fractional_fee.py
4+
python examples/custom_fractional_fee.py
5+
"""
6+
from hiero_sdk_python.tokens.custom_fractional_fee import CustomFractionalFee
7+
from hiero_sdk_python.tokens.fee_assessment_method import FeeAssessmentMethod
8+
from hiero_sdk_python.account.account_id import AccountId
9+
10+
def custom_fractional_fee() :
11+
fractional_fee = CustomFractionalFee(
12+
numerator=1,
13+
denominator=10,
14+
min_amount=1,
15+
max_amount=100,
16+
assessment_method=FeeAssessmentMethod.EXCLUSIVE,
17+
fee_collector_account_id=AccountId(0, 0, 456),
18+
all_collectors_are_exempt=False,
19+
)
20+
print("\nCustomFractionalFee:")
21+
print(f"Numerator: {fractional_fee.numerator}")
22+
print(f"Denominator: {fractional_fee.denominator}")
23+
print(f"Min Amount: {fractional_fee.min_amount}")
24+
print(f"Max Amount: {fractional_fee.max_amount}")
25+
print(f"Assessment Method: {fractional_fee.assessment_method}")
26+
print(f"Fee Collector Account ID: {fractional_fee.fee_collector_account_id}")
27+
print(f"All Collectors Exempt: {fractional_fee.all_collectors_are_exempt}")
28+
29+
# Convert to protobuf
30+
fractional_fee_proto = fractional_fee._to_proto()
31+
32+
print("Fractional Fee Protobuf:", fractional_fee_proto)
33+
34+
if __name__ == "__main__":
35+
custom_fractional_fee()

examples/custom_fee_royalty.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Run with:
3+
uv run examples/custom_royalty_fee.py
4+
python examples/custom_royalty_fee.py
5+
"""
6+
from hiero_sdk_python.tokens.custom_fixed_fee import CustomFixedFee
7+
from hiero_sdk_python.tokens.custom_royalty_fee import CustomRoyaltyFee
8+
from hiero_sdk_python.account.account_id import AccountId
9+
from hiero_sdk_python.tokens.token_id import TokenId
10+
11+
def custom_royalty_fee():
12+
fallback_fee = CustomFixedFee(
13+
amount=50,
14+
denominating_token_id=TokenId(0, 0, 789),
15+
)
16+
royalty_fee = CustomRoyaltyFee(
17+
numerator=5,
18+
denominator=100,
19+
fallback_fee=fallback_fee,
20+
fee_collector_account_id=AccountId(0, 0, 456),
21+
all_collectors_are_exempt=True,
22+
)
23+
print("\nCustomRoyaltyFee:")
24+
print(f"Numerator: {royalty_fee.numerator}")
25+
print(f"Denominator: {royalty_fee.denominator}")
26+
print(f"Fallback Fee Amount: {royalty_fee.fallback_fee.amount if royalty_fee.fallback_fee is not None else 'None'}")
27+
print(f"Fallback Fee Denominating Token ID: {royalty_fee.fallback_fee.denominating_token_id if royalty_fee.fallback_fee is not None else 'None'}")
28+
print(f"Fee Collector Account ID: {royalty_fee.fee_collector_account_id}")
29+
print(f"All Collectors Exempt: {royalty_fee.all_collectors_are_exempt}")
30+
31+
# Convert to protobuf
32+
royalty_fee_proto = royalty_fee._to_proto()
33+
34+
print("Royalty Fee Protobuf:", royalty_fee_proto)
35+
36+
if __name__ == "__main__":
37+
custom_royalty_fee()

0 commit comments

Comments
 (0)