diff --git a/apps/block_scout_web/lib/block_scout_web/etherscan.ex b/apps/block_scout_web/lib/block_scout_web/etherscan.ex index 6afc2206f5..29ca78d45d 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -867,8 +867,20 @@ defmodule BlockScoutWeb.Etherscan do definition: "The transferred amount.", example: ~s("663046792267785498951364") }, + values: %{ + type: "array", + array_type: %{ + type: "integer", + definition: "The transferred amount of particular token instance." + }, + definition: "Transferred amounts of token instances in ERC-1155 batch transfer corresponding to tokenIDs field." + }, tokenName: @token_name_type, tokenID: @token_id_type, + tokenIDs: %{ + type: "array", + array_type: @token_id_type + }, tokenSymbol: @token_symbol_type, tokenDecimal: @token_decimal_type, transactionIndex: @transaction_index_type, diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex index 1d407c45fb..2d9deed6ef 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex @@ -171,13 +171,20 @@ defmodule BlockScoutWeb.API.RPC.AddressView do defp prepare_token_transfer(%{token_type: "ERC-721"} = token_transfer) do token_transfer |> prepare_common_token_transfer() - |> Map.put_new(:tokenID, token_transfer.token_id) + |> Map.put_new(:tokenID, List.first(token_transfer.token_ids)) + end + + defp prepare_token_transfer(%{token_type: "ERC-1155", token_ids: [token_id]} = token_transfer) do + token_transfer + |> prepare_common_token_transfer() + |> Map.put_new(:tokenID, token_id) end defp prepare_token_transfer(%{token_type: "ERC-1155"} = token_transfer) do token_transfer |> prepare_common_token_transfer() - |> Map.put_new(:tokenID, token_transfer.token_id) + |> Map.put_new(:tokenIDs, token_transfer.token_ids) + |> Map.put_new(:values, token_transfer.amounts) end defp prepare_token_transfer(%{token_type: "ERC-20"} = token_transfer) do diff --git a/apps/explorer/lib/explorer/etherscan.ex b/apps/explorer/lib/explorer/etherscan.ex index bafbc8d1ad..fa3a411880 100644 --- a/apps/explorer/lib/explorer/etherscan.ex +++ b/apps/explorer/lib/explorer/etherscan.ex @@ -439,6 +439,7 @@ defmodule Explorer.Etherscan do from_address_hash to_address_hash amount + amounts )a defp list_token_transfers(address_hash, contract_address_hash, block_height, options) do @@ -453,7 +454,7 @@ defmodule Explorer.Etherscan do offset: ^offset(options), select: merge(map(tt, ^@token_transfer_fields), %{ - token_id: tt.token_id, + token_ids: tt.token_ids, token_name: tkn.name, token_symbol: tkn.symbol, token_decimals: tkn.decimals, @@ -479,6 +480,7 @@ defmodule Explorer.Etherscan do from_address_hash: tt.from_address_hash, to_address_hash: tt.to_address_hash, amount: tt.amount, + amounts: tt.amounts, transaction_nonce: t.nonce, transaction_index: t.index, transaction_gas: t.gas, @@ -490,7 +492,7 @@ defmodule Explorer.Etherscan do block_number: b.number, block_timestamp: b.timestamp, confirmations: fragment("? - ?", ^block_height, t.block_number), - token_id: tt.token_id, + token_ids: tt.token_ids, token_name: tt.token_name, token_symbol: tt.token_symbol, token_decimals: tt.token_decimals,