From bef7c2f42f60214b2c44af929e0d62d9be678f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=9F=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=BD=D1=8F=D0=BA=D0=BE=D0=B2?= Date: Tue, 31 May 2022 15:16:50 +0300 Subject: [PATCH] Fix empty coin balance for empty address --- CHANGELOG.md | 1 + .../controllers/address_coin_balance_controller.ex | 10 ++++++++-- .../address_internal_transaction_controller.ex | 10 ++++++++-- .../controllers/address_transaction_controller.ex | 11 +++++++++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b01347dfa..8cf251d1f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#5540](https://github.com/blockscout/blockscout/pull/5540) - Tx page: scroll to selected tab's data ### Fixes +- [#5629](https://github.com/blockscout/blockscout/pull/5629) - Fix empty coin balance for empty address - [#5626](https://github.com/blockscout/blockscout/pull/5626) - Fix vyper compiler versions order - [#5603](https://github.com/blockscout/blockscout/pull/5603) - Fix failing verification attempts - [#5598](https://github.com/blockscout/blockscout/pull/5598) - Fix token dropdown diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex index f7cf3401e2..b024c102a0 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex @@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do alias BlockScoutWeb.{AccessHelpers, AddressCoinBalanceView, Controller} alias Explorer.{Chain, Market} - alias Explorer.Chain.Address + alias Explorer.Chain.{Address, Wei} alias Explorer.ExchangeRates.Token alias Indexer.Fetcher.CoinBalanceOnDemand alias Phoenix.View @@ -84,7 +84,13 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do {:error, :not_found} -> {:ok, address_hash} = Chain.string_to_address_hash(address_hash_string) - address = %Chain.Address{hash: address_hash, smart_contract: nil, token: nil} + + address = %Chain.Address{ + hash: address_hash, + smart_contract: nil, + token: nil, + fetched_coin_balance: %Wei{value: Decimal.new(0)} + } case Chain.Hash.Address.validate(address_hash_string) do {:ok, _} -> diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_internal_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_internal_transaction_controller.ex index b037a251cc..a72ba8e256 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_internal_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_internal_transaction_controller.ex @@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionController do alias BlockScoutWeb.{AccessHelpers, Controller, InternalTransactionView} alias Explorer.{Chain, Market} - alias Explorer.Chain.Address + alias Explorer.Chain.{Address, Wei} alias Explorer.ExchangeRates.Token alias Indexer.Fetcher.CoinBalanceOnDemand alias Phoenix.View @@ -94,7 +94,13 @@ defmodule BlockScoutWeb.AddressInternalTransactionController do {:error, :not_found} -> {:ok, address_hash} = Chain.string_to_address_hash(address_hash_string) - address = %Chain.Address{hash: address_hash, smart_contract: nil, token: nil} + + address = %Chain.Address{ + hash: address_hash, + smart_contract: nil, + token: nil, + fetched_coin_balance: %Wei{value: Decimal.new(0)} + } case Chain.Hash.Address.validate(address_hash_string) do {:ok, _} -> diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex index fd8765cc25..fed2fe2da8 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex @@ -14,7 +14,8 @@ defmodule BlockScoutWeb.AddressTransactionController do AddressInternalTransactionCsvExporter, AddressLogCsvExporter, AddressTokenTransferCsvExporter, - AddressTransactionCsvExporter + AddressTransactionCsvExporter, + Wei } alias Explorer.ExchangeRates.Token @@ -130,7 +131,13 @@ defmodule BlockScoutWeb.AddressTransactionController do {:error, :not_found} -> {:ok, address_hash} = Chain.string_to_address_hash(address_hash_string) - address = %Chain.Address{hash: address_hash, smart_contract: nil, token: nil} + + address = %Chain.Address{ + hash: address_hash, + smart_contract: nil, + token: nil, + fetched_coin_balance: %Wei{value: Decimal.new(0)} + } case Chain.Hash.Address.validate(address_hash_string) do {:ok, _} ->