-
Notifications
You must be signed in to change notification settings - Fork 107
feat: support hbar transfer #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
|
Hi, this is MergeConflictBot. Please resolve these conflicts locally and push the changes. To assist you, please read: Thank you for contributing! From the Hiero Python SDK Team |
|
Hi, this is WorkflowBot.
|
|
Requet review if available @MonaaEid @Adityarya11 |
Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
826177d to
0b1e7ac
Compare
Signed-off-by: prajeeta <96904203+prajeeta15@users.noreply.github.com>
exploreriii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @prajeeta15 please rebase and also add your changelog check correctly :)
thank you
hi @prajeeta15 if the ChangeLog is messed up you may try git checkout main -- CHANGELOG.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes agree, you can just copy in the main's changelog code then add your change on top and commit that.
Signed-off-by: prajeeta <96904203+prajeeta15@users.noreply.github.com>
|
updated changelog |
Hi @prajeeta15 |
Signed-off-by: prajeeta pal <prajeetapal@gmail.com>
|
@Adityarya11 yeah I was having an issue during rebase so I had just copy-pasted the current changelog.md from main to this. but cool. i pulled and updated changelog with just my lines of work. |
|
Request review if available @hiero-ledger/hiero-sdk-python-triage |
|
|
||
| for transfer in self.hbar_transfers: | ||
| if transfer.account_id == account_id: | ||
| transfer.amount += amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what could happen if the amount is equal to 0 here?
| if not isinstance(amount, int) or amount == 0: | ||
| raise ValueError("Amount must be a non-zero integer.") | ||
| raise ValueError("Amount must be a integer.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep the previous version, is a bit cleaner and also here you have two if with quite te same condition:
if not isinstance(amount, int) or amount == 0(look after the or)if amount == 0
Add Hbar object support to TransferTransaction and add tests
Allow
_add_hbar_transfer,add_hbar_transfer, andadd_approved_hbar_transferto acceptHbarobjects in addition to raw integer tinybar amounts. NormalizeHbarinputs to tinybars immediately (viaHbar.to_tinybars()), store the resulting tinybar integer inHbarTransfer, and keep existing integer behavior intact. Add comprehensive unit tests covering the new behavior and edge cases.Union[int, Hbar]for_add_hbar_transfer,add_hbar_transfer, andadd_approved_hbar_transfer.TypeErrorfor invalidaccount_id,amount, oris_approvedtypes.Hbarto tinybars viaHbar.to_tinybars()and store the tinybar integer inHbarTransfer.ValueErrorfor zero tinybar amounts).account_idby adding tinybars.tests/unit/transaction/test_transfer_transaction.py) that cover:Hbarobjects (HBAR and TINYBAR units),Hbarobjects,Hbarand int inputs,Hbar(0),amount,Hbarunits to tinybars,Addedentry describing the feature and tests.Related issue(s):
Fixes #917
Notes for reviewer:
Hbarinputs are normalized immediately to tinybars; theHbarobject is not stored—only the tinybar integer is stored inHbarTransfer.account_idmust be anAccountIdinstance (TypeErrorotherwise).amountmust be anintorHbar(TypeErrorotherwise).is_approvedmust bebool(TypeErrorotherwise).ValueError("Amount must be a non-zero value.").HbarTransfer(ensure they expect tinybar integers) and toHbar.to_tinybars()behavior.Checklist