Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.

### Added

- Add `__repr__` method to CustomFee base class for better debugging by displaying fee_collector_account_id and all_collectors_are_exempt.
- Add comprehensive Google-style docstrings to examples/account_create.py
- add revenue generating topic tests/example
- add fee_schedule_key, fee_exempt_keys, custom_fees fields in TopicCreateTransaction, TopicUpdateTransaction, TopicInfo classes
Expand Down
16 changes: 15 additions & 1 deletion src/hiero_sdk_python/tokens/custom_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@ def _validate_checksums(self, client: Client) -> None:
self.fee_collector_account_id.validate_checksum(client)

def __eq__(self, other: "CustomFee") -> bool:
return self.fee_collector_account_id == other.fee_collector_account_id and self.all_collectors_are_exempt == other.all_collectors_are_exempt
return self.fee_collector_account_id == other.fee_collector_account_id and self.all_collectors_are_exempt == other.all_collectors_are_exempt

def __repr__(self) -> str:
"""Return a string representation of the CustomFee instance.

Returns:
str: A string containing the class name, fee_collector_account_id,
and all_collectors_are_exempt.
"""
return (
f"{self.__class__.__name__}("
f"fee_collector_account_id={self.fee_collector_account_id}, "
f"all_collectors_are_exempt={self.all_collectors_are_exempt}"
f")"
)
18 changes: 17 additions & 1 deletion tests/unit/test_custom_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,20 @@ def test_custom_royalty_fee():
assert new_fee.all_collectors_are_exempt is True
assert isinstance(new_fee.fallback_fee, CustomFixedFee)
assert new_fee.fallback_fee.amount == 50
assert new_fee.fallback_fee.denominating_token_id == TokenId(0, 0, 789)
assert new_fee.fallback_fee.denominating_token_id == TokenId(0, 0, 789)


def test_custom_fee_repr():
"""Test the __repr__ method of CustomFee base class"""
fee = CustomFixedFee(
amount=100,
denominating_token_id=TokenId(0, 0, 123),
fee_collector_account_id=AccountId(0, 0, 456),
all_collectors_are_exempt=True,
)

repr_str = repr(fee)

assert "CustomFixedFee" in repr_str
assert "fee_collector_account_id=0.0.456" in repr_str
assert "all_collectors_are_exempt=True" in repr_str