Description
When _add_token_transfer() is called multiple times for the same (token_id, account_id) pair, the transfer amount is accumulated correctly, but the is_approved flag is never updated in the accumulation branch.
This causes approved transfers to silently lose their approval state depending on call order.
Example:
tx.add_token_transfer(token_a, sender, 500)
# is_approved=False (default)
tx.add_approved_token_transfer(token_a, sender, 200)
# expected accumulated transfer to become approved
### Steps to reproduce
1. Create a transaction.
2. Add a normal token transfer for a `(token_id, account_id)` pair.
3. Add an approved token transfer for the same `(token_id, account_id)` pair.
4. Inspect the accumulated transfer object.
Example:
```python
tx.add_token_transfer(token_a, sender, 500)
tx.add_approved_token_transfer(token_a, sender, 200)
Observed result:
Expected result:
Additional context
Root cause appears to be inside _add_token_transfer() where the accumulation branch updates amount and expected_decimals, but never updates is_approved.
Current logic:
for transfer in self.token_transfers[token_id]:
if transfer.account_id == account_id:
transfer.amount += amount
transfer.expected_decimals = expected_decimals
return
Suggested fix:
transfer.is_approved = is_approved
before returning from the accumulation branch.
This can affect allowance-based transfer flows where regular and approved transfers are combined in the same transaction.
Hedera network
No response
Version
v0.2.5
Operating system
None
Description
When
_add_token_transfer()is called multiple times for the same(token_id, account_id)pair, the transfer amount is accumulated correctly, but theis_approvedflag is never updated in the accumulation branch.This causes approved transfers to silently lose their approval state depending on call order.
Example:
Observed result:
Expected result:
Additional context
Root cause appears to be inside
_add_token_transfer()where the accumulation branch updatesamountandexpected_decimals, but never updatesis_approved.Current logic:
Suggested fix:
before returning from the accumulation branch.
This can affect allowance-based transfer flows where regular and approved transfers are combined in the same transaction.
Hedera network
No response
Version
v0.2.5
Operating system
None