From 456c5549a5adc9a43e45b7e33f5fb0890c317cea Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 20 Mar 2019 14:33:42 +0300 Subject: [PATCH 1/2] do not fetch burn address balance --- .../lib/indexer/address/token_balances.ex | 26 +++++++++++-------- .../indexer/address/token_balances_test.exs | 5 ---- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/indexer/lib/indexer/address/token_balances.ex b/apps/indexer/lib/indexer/address/token_balances.ex index faab41ecfd..f75c8ab197 100644 --- a/apps/indexer/lib/indexer/address/token_balances.ex +++ b/apps/indexer/lib/indexer/address/token_balances.ex @@ -3,6 +3,8 @@ defmodule Indexer.Address.TokenBalances do Extracts `Explorer.Address.TokenBalance` params from other schema's params. """ + @burn_address "0x0000000000000000000000000000000000000000" + def params_set(%{} = import_options) do Enum.reduce(import_options, MapSet.new(), &reducer/2) end @@ -20,16 +22,8 @@ defmodule Indexer.Address.TokenBalances do when is_integer(block_number) and is_binary(from_address_hash) and is_binary(to_address_hash) and is_binary(token_contract_address_hash) -> acc - |> MapSet.put(%{ - address_hash: from_address_hash, - token_contract_address_hash: token_contract_address_hash, - block_number: block_number - }) - |> MapSet.put(%{ - address_hash: to_address_hash, - token_contract_address_hash: token_contract_address_hash, - block_number: block_number - }) + |> add_token_balance_address(from_address_hash, token_contract_address_hash, block_number) + |> add_token_balance_address(to_address_hash, token_contract_address_hash, block_number) end) end @@ -37,7 +31,17 @@ defmodule Indexer.Address.TokenBalances do Enum.filter(token_transfers_params, &do_filter_burn_address/1) end - def do_filter_burn_address(%{to_address_hash: "0x0000000000000000000000000000000000000000", token_type: "ERC-721"}) do + defp add_token_balance_address(map_set, unquote(@burn_address), _, _), do: map_set + + defp add_token_balance_address(map_set, address, token_contract_address, block_number) do + MapSet.put(map_set, %{ + address_hash: address, + token_contract_address_hash: token_contract_address, + block_number: block_number + }) + end + + def do_filter_burn_address(%{to_address_hash: unquote(@burn_address), token_type: "ERC-721"}) do false end diff --git a/apps/indexer/test/indexer/address/token_balances_test.exs b/apps/indexer/test/indexer/address/token_balances_test.exs index 46258643a0..4328e1a9bb 100644 --- a/apps/indexer/test/indexer/address/token_balances_test.exs +++ b/apps/indexer/test/indexer/address/token_balances_test.exs @@ -53,11 +53,6 @@ defmodule Indexer.Address.TokenBalancesTest do assert params_set == MapSet.new([ - %{ - address_hash: "0x0000000000000000000000000000000000000000", - block_number: 1, - token_contract_address_hash: "0xe18035bf8712672935fdb4e5e431b1a0183d2dfc" - }, %{ address_hash: "0x5b8410f67eb8040bb1cd1e8a4ff9d5f6ce678a15", block_number: 1, From 6411ab84f6a0811bfc4c5b339c0a6addabc5a2c0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 21 Mar 2019 12:24:03 +0300 Subject: [PATCH 2/2] add CHANGELOG entry --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e101cc7c7b..6e743e3d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes + - [1614](https://github.com/poanetwork/blockscout/pull/1614) - Do not fetch burn address token balance + ### Chore @@ -85,4 +87,4 @@ ### Chore - [https://github.com/poanetwork/blockscout/pull/1532](https://github.com/poanetwork/blockscout/pull/1532) - Upgrade elixir to 1.8.1 - [https://github.com/poanetwork/blockscout/pull/1553](https://github.com/poanetwork/blockscout/pull/1553) - Dockerfile: remove 1.7.1 version pin FROM bitwalker/alpine-elixir-phoenix - - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert \ No newline at end of file + - [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert