Skip to content

Conversation

@AubreyDDD
Copy link
Contributor

@AubreyDDD AubreyDDD commented Dec 11, 2025

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

  • Token association information is now correct
  • Example still run successfully
  • No other functional behaviour should be altered
  • Add a changelog entry (see docs/sdk_developers/changelog_entry.md).
  • Commit using verified GPG-signed commits

Signed-off-by: Aubrey Du <duk110293@gmail.com>
Copilot AI review requested due to automatic review settings December 11, 2025 16:14
Copy link
Contributor

Copilot AI left a 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_balances dictionary 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.

@exploreriii exploreriii marked this pull request as draft December 11, 2025 22:05
@AubreyDDD AubreyDDD marked this pull request as ready for review December 12, 2025 02:13
@exploreriii exploreriii marked this pull request as draft December 12, 2025 09:36
@AubreyDDD AubreyDDD marked this pull request as ready for review December 12, 2025 18:44
@exploreriii
Copy link
Contributor

Request review if available @hiero-ledger/hiero-sdk-python-triage

Copy link
Contributor

@exploreriii exploreriii left a 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}
Copy link
Contributor

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?

@exploreriii exploreriii marked this pull request as draft December 13, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix logging in example/token_airdrop.py

2 participants