Merge pull request #1614 from poanetwork/ab-do-not-fetch-burn-address-balance

do not fetch burn address balance
pull/1627/head
Victor Baranov 6 years ago committed by GitHub
commit 03e2bcd0d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 26
      apps/indexer/lib/indexer/address/token_balances.ex
  3. 5
      apps/indexer/test/indexer/address/token_balances_test.exs

@ -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
- [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert

@ -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

@ -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,

Loading…
Cancel
Save