|
|
|
@ -12,7 +12,6 @@ defmodule BlockScoutWeb.AddressTokenBalanceController do |
|
|
|
|
token_balances = |
|
|
|
|
address_hash |
|
|
|
|
|> Chain.fetch_last_token_balances() |
|
|
|
|
|> Market.add_price() |
|
|
|
|
|
|
|
|
|
Task.start_link(fn -> |
|
|
|
|
TokenBalanceOnDemand.trigger_fetch(address_hash, token_balances) |
|
|
|
@ -20,15 +19,25 @@ defmodule BlockScoutWeb.AddressTokenBalanceController do |
|
|
|
|
|
|
|
|
|
circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) |
|
|
|
|
|
|
|
|
|
token_balances_with_price = |
|
|
|
|
token_balances |
|
|
|
|
|> Market.add_price() |
|
|
|
|
|
|
|
|
|
token_balances_except_bridged = |
|
|
|
|
token_balances |
|
|
|
|
|> Enum.filter(fn token_balance -> !token_balance.token.bridged end) |
|
|
|
|
|
|
|
|
|
circles_total_balance = |
|
|
|
|
if Enum.count(circles_addresses_list) > 0 do |
|
|
|
|
token_balances |
|
|
|
|
token_balances_except_bridged |
|
|
|
|
|> Enum.reduce(Decimal.new(0), fn token_balance, acc_balance -> |
|
|
|
|
{:ok, token_address} = Chain.hash_to_address(token_balance.address_hash) |
|
|
|
|
|
|
|
|
|
from_address = from_address_hash(token_address) |
|
|
|
|
|
|
|
|
|
created_from_address_hash = |
|
|
|
|
if from_address_hash(token_address), |
|
|
|
|
do: "0x" <> Base.encode16(from_address_hash(token_address).bytes, case: :lower), |
|
|
|
|
if from_address, |
|
|
|
|
do: "0x" <> Base.encode16(from_address.bytes, case: :lower), |
|
|
|
|
else: nil |
|
|
|
|
|
|
|
|
|
if Enum.member?(circles_addresses_list, created_from_address_hash) && token_balance.token.name == "Circles" && |
|
|
|
@ -49,7 +58,7 @@ defmodule BlockScoutWeb.AddressTokenBalanceController do |
|
|
|
|
|> put_layout(false) |
|
|
|
|
|> render("_token_balances.html", |
|
|
|
|
address_hash: address_hash, |
|
|
|
|
token_balances: token_balances, |
|
|
|
|
token_balances: token_balances_with_price, |
|
|
|
|
circles_total_balance: circles_total_balance |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|