-
Notifications
You must be signed in to change notification settings - Fork 108
fix: correct token association check #1044
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: Aubrey Du <duk110293@gmail.com>
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.
Pull request overview
This PR fixes the token association verification logic in the token airdrop example. The previous implementation incorrectly displayed token balances (which are always 0 after association) instead of properly checking whether tokens were associated with an account.
Key Changes:
- Refactored the token association verification to check for token presence in
token_balancesdictionary rather than displaying balance values - Updated the output format to clearly indicate whether tokens are "Associated" or "NOT Associated"
- Added a corresponding changelog entry documenting the fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
examples/tokens/token_airdrop_transaction.py |
Corrects the logic to check if tokens exist in the token_balances dictionary instead of displaying misleading zero balance values |
CHANGELOG.md |
Documents the fix for token association verification in the changelog |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Aubrey Du <duk110293@gmail.com>
Signed-off-by: Aubrey Du <duk110293@gmail.com>
|
Request review if available @hiero-ledger/hiero-sdk-python-triage |
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 @AubreyDDD
We just need to improve the association check, but actual balance checks can be desirable to help the user understand how the airdrop actually moves tokens around
| recipient_info = AccountInfoQuery(account_id=recipient_id).execute(client) | ||
|
|
||
| # Build dictionaries for balances from token_relationships (more robust than balance query) | ||
| sender_balances_before = {rel.token_id: rel.balance for rel in sender_info.token_relationships} |
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.
No no
for the token airdrop, we do want to confirm the balance is zero before the airdrop
that way when we complete the airdrop example, we can compare the before/after token balance
so i don't think you need to change
def _log_balances_before(client, operator_id, recipient_id, token_id, nft_id):
what do you think?
Description:
Corrects the token association verification logic in ·token_airdrop_transaction.py·. The previous implementation incorrectly displayed token balances (which are always 0 after association) instead of properly checking whether tokens were associated.
Related issue(s):
Fixes #815
Notes for reviewer:
Checklist