Merged
Conversation
…and removed locked authorities recalculation
…nces, including authorities
5b69658 to
e4efac8
Compare
andreabadesso
commented
Sep 17, 2025
Comment on lines
-402
to
-417
| const entry = { | ||
| address, | ||
| token_id: token, | ||
| // totalAmountSent is the sum of the value of all outputs of this token on the tx being sent to this address | ||
| // which means it is the "total_received" for this address | ||
| total_received: tokenBalance.totalAmountSent, | ||
| // if it's < 0, there must be an entry already, so it will execute "ON DUPLICATE KEY UPDATE" instead of setting it to 0 | ||
| unlocked_balance: (tokenBalance.unlockedAmount < 0 ? 0 : tokenBalance.unlockedAmount), | ||
| // this is never less than 0, as locked balance only changes when a tx is unlocked | ||
| locked_balance: tokenBalance.lockedAmount, | ||
| unlocked_authorities: tokenBalance.unlockedAuthorities.toUnsignedInteger(), | ||
| locked_authorities: tokenBalance.lockedAuthorities.toUnsignedInteger(), | ||
| timelock_expires: tokenBalance.lockExpires, | ||
| transactions: 1, | ||
| }; | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
This should have been removed in the last PR
| outputs: EventTxOutput[], | ||
| tokens: string[], | ||
| headers: EventTxHeader[], | ||
| version?: number, |
|
|
||
| // If this is a token creation transaction, we must remove the address_balance | ||
| // row for that token as it has ceased to exist | ||
| if (isCreateTokenTx) { |
Member
There was a problem hiding this comment.
As we discussed, we need to handle this case even for non token creation tx. The tx might be the only one that added balance to the address and must also be deleted.
| } | ||
|
|
||
| // If this is a token creation transaction, clean up zeroed entries | ||
| if (isCreateTokenTx) { |
…s the only one for the address_balance
andreabadesso
commented
Sep 18, 2025
pedroferreira1
approved these changes
Sep 18, 2025
r4mmer
approved these changes
Sep 18, 2025
This was referenced Nov 17, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When an address is involved in a token creation transaction that is later on voided and this transaction is the only one this address has received so far, the
initWalletBalancemethod (that is called when initializing a new wallet) throws because of a mismatch in the rows fromaddress_balanceandaddress_tx_historyThis happens because when a transaction is voided, we remove it from the
address_tx_historybut the address_balance is set to0and never removed again.Acceptance Criteria
address_balancetable in case the only row for that token is zerowallet_balancein case the only row for that token is zeroChecklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged