Handle nil token_ids in token transfers on render (#9143)

pull/9197/head
Qwerty5Uiop 10 months ago committed by GitHub
parent f63668cd58
commit d3209f0e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 15
      apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex
  3. 4
      apps/explorer/lib/explorer/account/notifier/summary.ex

@ -15,6 +15,7 @@
### Fixes
- [#9229](https://github.com/blockscout/blockscout/pull/9229) - Add missing filter to txlist query
- [#9143](https://github.com/blockscout/blockscout/pull/9143) - Handle nil token_ids in token transfers on render
- [#9139](https://github.com/blockscout/blockscout/pull/9139) - TokenBalanceOnDemand fixes
- [#9178](https://github.com/blockscout/blockscout/pull/9178) - Change internal txs tracer type to opcode for Hardhat node
- [#9125](https://github.com/blockscout/blockscout/pull/9125) - Fix Explorer.Chain.Cache.GasPriceOracle.merge_fees

@ -246,16 +246,25 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
}
end
# credo:disable-for-next-line /Complexity/
def prepare_token_transfer_total(token_transfer) do
case TokensHelper.token_transfer_amount_for_api(token_transfer) do
{:ok, :erc721_instance} ->
%{"token_id" => List.first(token_transfer.token_ids)}
%{"token_id" => token_transfer.token_ids && List.first(token_transfer.token_ids)}
{:ok, :erc1155_instance, value, decimals} ->
%{"token_id" => List.first(token_transfer.token_ids), "value" => value, "decimals" => decimals}
%{
"token_id" => token_transfer.token_ids && List.first(token_transfer.token_ids),
"value" => value,
"decimals" => decimals
}
{:ok, :erc1155_instance, values, token_ids, decimals} ->
%{"token_id" => List.first(token_ids), "value" => List.first(values), "decimals" => decimals}
%{
"token_id" => token_ids && List.first(token_ids),
"value" => values && List.first(values),
"decimals" => decimals
}
{:ok, value, decimals} ->
%{"value" => value, "decimals" => decimals}

@ -132,7 +132,7 @@ defmodule Explorer.Account.Notifier.Summary do
from_address_hash: transfer.from_address_hash,
to_address_hash: transfer.to_address_hash,
block_number: transfer.block_number,
subject: to_string(List.first(transfer.token_ids)),
subject: to_string(transfer.token_ids && List.first(transfer.token_ids)),
tx_fee: fee(transaction),
name: transfer.token.name,
type: transfer.token.type
@ -191,6 +191,8 @@ defmodule Explorer.Account.Notifier.Summary do
)
end
def token_ids(%Chain.TokenTransfer{token_ids: nil}), do: ""
def token_ids(%Chain.TokenTransfer{token_ids: token_ids}) do
Enum.map_join(token_ids, ", ", fn id -> to_string(id) end)
end

Loading…
Cancel
Save