-
Notifications
You must be signed in to change notification settings - Fork 283
fix: update is_approved in _add_token_transfer accumulation branch #2290
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?
Changes from all commits
34cedca
98b2ca3
fc23cbc
e6bc36d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,7 @@ def _add_token_transfer( | |
| raise TypeError("is_approved must be a boolean.") | ||
|
|
||
| for transfer in self.token_transfers[token_id]: | ||
| if transfer.account_id == account_id: | ||
| if transfer.account_id == account_id and transfer.is_approved == is_approved: | ||
| transfer.amount += amount | ||
| transfer.expected_decimals = expected_decimals | ||
| return | ||
|
Comment on lines
154
to
158
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win Document the last-call-wins semantics for The aggregation logic now requires both Consider adding a docstring note or inline comment explaining this behavior, since callers might expect either:
📝 Suggested inline comment for transfer in self.token_transfers[token_id]:
if transfer.account_id == account_id and transfer.is_approved == is_approved:
+ # Accumulate amount; overwrite expected_decimals with latest value (last-call-wins)
transfer.amount += amount
transfer.expected_decimals = expected_decimals
return |
||
|
|
||
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.
Previously, these changes caused the
e2e test tests/integration/transfer_transaction_e2e_test.py::test_integration_transfer_transaction_approved_token_transferto fail withACCOUNT_REPEATED_IN_ACCOUNT_AMOUNTS.This happens cause fro single token within one
TransferTransactionyou cannot have both a standard transfer entry and an approved transfer entry for the same (tokenId, accountId) pair they are treated as separate entries and are not merged.One workaround is to keep the previous behavior, where both transfers are merged into a single entry (either fully standard or fully approved). Since the approval flag is only set once, the later value is effectively ignored.
The other option is to update the e2e test to completely use the standard transfer instead.
Would like to get an opinion from @exploreriii on which direction makes more sense.
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.
Left question in DM
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.
@aceppaluni @manishdait what change i have to do in this ??