fix(substreams-sdk): fix a bug in aggregate_balances_changes that was causing some balance changes loss.

The `aggregate_balances_changes` was keeping a map of token -> balance_change per transaction. Therefore, if a transaction was causing a balance change for the same token but on differents components we would only keep the update for the last component updated and drop the others.
This commit is contained in:
zizou
2024-10-25 15:56:53 +02:00
parent 3013cd9bfd
commit e064ea7aae
3 changed files with 55 additions and 35 deletions

View File

@@ -208,7 +208,11 @@ pub fn map_protocol_changes(
.or_insert_with(|| TransactionChangesBuilder::new(&tx));
balances
.values()
.for_each(|bc| builder.add_balance_change(bc));
.for_each(|token_bc_map| {
token_bc_map
.values()
.for_each(|bc| builder.add_balance_change(bc))
});
});
// Extract and insert any storage changes that happened for any of the components.