Skip to content

Commit

Permalink
Fix issue with wrong updated token balances (#506)
Browse files Browse the repository at this point in the history
* Fix issue with wrong updated token balances

* Update mistake

* Only update balances
  • Loading branch information
Enrique Ruiz committed Dec 10, 2021
1 parent fbbe83a commit a4b80bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions apps/indexer/lib/indexer/fetcher/internal_transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,13 @@ defmodule Indexer.Fetcher.InternalTransaction do
_ -> []
end

token_transfers_addresses_params =
Addresses.extract_addresses(%{
token_transfers: token_transfers
})

address_hash_to_block_number =
Enum.into(addresses_params, %{}, fn %{fetched_coin_balance_block_number: block_number, hash: hash} ->
Enum.into(token_transfers_addresses_params, %{}, fn %{fetched_coin_balance_block_number: block_number, hash: hash} ->
{hash, block_number}
end)

Expand All @@ -293,10 +298,10 @@ defmodule Indexer.Fetcher.InternalTransaction do

case imports do
{:ok, imported} ->
Accounts.drop(imported[:addreses])
Accounts.drop(imported[:addresses])
Blocks.drop_nonconsensus(imported[:remove_consensus_of_missing_transactions_blocks])

async_import_coin_balances(imported, %{
async_import_coin_balances(token_transfers_addresses_params, %{
address_hash_to_fetched_balance_block_number: address_hash_to_block_number
})

Expand Down
6 changes: 3 additions & 3 deletions apps/indexer/test/indexer/block/fetcher_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ defmodule Indexer.Block.FetcherTest do
unprefixed_celo_token_address_hash,
event_first_topic,
event_data,
22
18
)

variant ->
Expand Down Expand Up @@ -544,7 +544,7 @@ defmodule Indexer.Block.FetcherTest do
unprefixed_celo_token_address_hash,
event_first_topic,
event_data,
22
18
)

variant ->
Expand Down Expand Up @@ -658,7 +658,7 @@ defmodule Indexer.Block.FetcherTest do
unprefixed_celo_token_address_hash,
event_first_topic,
event_data,
22
18
)

variant ->
Expand Down

0 comments on commit a4b80bd

Please sign in to comment.