From fd22965fca66a013cf0a1125c71c639ca97b8dcf Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 8 Jul 2024 17:18:35 +0300 Subject: [PATCH] chore: remove single implementation name, address from API v2 response (#10390) --- .../views/api/v2/address_view.ex | 17 ----------------- .../lib/block_scout_web/views/api/v2/helper.ex | 17 ++++------------- .../account/api/v2/user_controller_test.exs | 6 ------ .../api/v2/address_controller_test.exs | 5 ----- 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/address_view.ex index 5d131ce7fb..22841d3059 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/address_view.ex @@ -113,9 +113,6 @@ defmodule BlockScoutWeb.API.V2.AddressView do creation_tx = creator_hash && AddressView.transaction_hash(address) token = address.token && TokenView.render("token.json", %{token: address.token}) - # todo: added for backward compatibility, remove when frontend unbound from these props - {implementation_address, implementation_name} = single_implementation(implementations) - extended_info = Map.merge(base_info, %{ "creator_address_hash" => creator_hash && Address.checksum(creator_hash), @@ -137,25 +134,11 @@ defmodule BlockScoutWeb.API.V2.AddressView do extended_info else Map.merge(extended_info, %{ - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => implementation_address, - "implementation_name" => implementation_name, "implementations" => implementations }) end end - defp single_implementation(implementations) do - %{"address" => implementation_address, "name" => implementation_name} = - if Enum.empty?(implementations) do - %{"address" => nil, "name" => nil} - else - implementations |> Enum.at(0) - end - - {implementation_address, implementation_name} - end - @spec prepare_token_balance(Chain.Address.TokenBalance.t(), boolean()) :: map() defp prepare_token_balance(token_balance, fetch_token_instance? \\ false) do %{ diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex b/apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex index 2ad947c041..e9d1f963db 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex @@ -64,31 +64,25 @@ defmodule BlockScoutWeb.API.V2.Helper do def address_with_info(%Address{} = address, _address_hash) do smart_contract? = Address.smart_contract?(address) - {proxy_implementations, implementation_address_hashes, implementation_names, implementation_address, - implementation_name} = + {proxy_implementations, implementation_address_hashes, implementation_names} = case address.proxy_implementations do %NotLoaded{} -> - {nil, [], [], nil, nil} + {nil, [], []} nil -> - {nil, [], [], nil, nil} + {nil, [], []} proxy_implementations -> address_hashes = proxy_implementations.address_hashes names = proxy_implementations.names - address_hash = Enum.at(address_hashes, 0) && address_hashes |> Enum.at(0) |> Address.checksum() - - {proxy_implementations, address_hashes, names, address_hash, Enum.at(names, 0)} + {proxy_implementations, address_hashes, names} end %{ "hash" => Address.checksum(address), "is_contract" => smart_contract?, "name" => address_name(address), - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => implementation_address, - "implementation_name" => implementation_name, "implementations" => proxy_object_info(implementation_address_hashes, implementation_names), "is_verified" => verified?(address) || verified_minimal_proxy?(proxy_implementations), "ens_domain_name" => address.ens_domain_name, @@ -116,9 +110,6 @@ defmodule BlockScoutWeb.API.V2.Helper do "hash" => Address.checksum(address_hash), "is_contract" => false, "name" => nil, - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => nil, - "implementation_name" => nil, "implementations" => [], "is_verified" => nil, "ens_domain_name" => nil, diff --git a/apps/block_scout_web/test/block_scout_web/controllers/account/api/v2/user_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/account/api/v2/user_controller_test.exs index a5efaeb98d..0bdb1d1ef8 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/account/api/v2/user_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/account/api/v2/user_controller_test.exs @@ -151,9 +151,6 @@ defmodule BlockScoutWeb.Account.Api.V2.UserControllerTest do "name" => name, "address" => %{ "hash" => Address.checksum(addr), - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => nil, - "implementation_name" => nil, "implementations" => [], "is_contract" => false, "is_verified" => false, @@ -210,9 +207,6 @@ defmodule BlockScoutWeb.Account.Api.V2.UserControllerTest do "name" => name, "address" => %{ "hash" => Address.checksum(addr), - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => nil, - "implementation_name" => nil, "implementations" => [], "is_contract" => false, "is_verified" => false, diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs index 951095d6ee..cf894b61f0 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs @@ -71,9 +71,6 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do "creation_tx_hash" => nil, "token" => nil, "coin_balance" => nil, - # todo: added for backward compatibility, remove when frontend unbound from these props - "implementation_address" => nil, - "implementation_name" => nil, "implementations" => [], "block_number_balance_updated_at" => nil, "has_decompiled_code" => false, @@ -209,7 +206,6 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do "watchlist_names" => [], "creator_address_hash" => ^from, "creation_tx_hash" => ^tx_hash, - "implementation_address" => ^checksummed_implementation_contract_address_hash, "implementations" => [ %{"address" => ^checksummed_implementation_contract_address_hash, "name" => ^name} ] @@ -255,7 +251,6 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do "watchlist_names" => [], "creator_address_hash" => ^from, "creation_tx_hash" => ^tx_hash, - "implementation_address" => ^implementation_address_hash_string, "implementations" => [%{"address" => ^implementation_address_hash_string, "name" => nil}] } = json_response(request, 200) end