Add method_id to write methods in API v2 response

pull/8146/head
Nikita Pozdniakov 1 year ago
parent f54369a18a
commit 3b2d7570b3
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 10
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/smart_contract_controller.ex
  2. 7
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs

@ -82,7 +82,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
{:not_found, true} <- {:not_found, AddressView.check_custom_abi_for_having_write_functions(custom_abi)} do {:not_found, true} <- {:not_found, AddressView.check_custom_abi_for_having_write_functions(custom_abi)} do
conn conn
|> put_status(200) |> put_status(200)
|> json(Writer.filter_write_functions(custom_abi.abi)) |> json(custom_abi.abi |> Writer.filter_write_functions() |> Reader.get_abi_with_method_id())
end end
end end
@ -95,7 +95,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
{:not_found, false} <- {:not_found, is_nil(smart_contract)} do {:not_found, false} <- {:not_found, is_nil(smart_contract)} do
conn conn
|> put_status(200) |> put_status(200)
|> json(Writer.write_functions(smart_contract)) |> json(smart_contract |> Writer.write_functions() |> Reader.get_abi_with_method_id())
end end
end end
@ -135,7 +135,11 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
conn conn
|> put_status(200) |> put_status(200)
|> json(Writer.write_functions_proxy(implementation_address_hash_string, @api_true)) |> json(
implementation_address_hash_string
|> Writer.write_functions_proxy(@api_true)
|> Reader.get_abi_with_method_id()
)
end end
end end

@ -1205,6 +1205,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
assert [ assert [
%{ %{
"method_id" => "49ba1b49",
"type" => "function", "type" => "function",
"stateMutability" => "nonpayable", "stateMutability" => "nonpayable",
"outputs" => [], "outputs" => [],
@ -1271,7 +1272,8 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"stateMutability" => "nonpayable", "stateMutability" => "nonpayable",
"outputs" => [], "outputs" => [],
"name" => "disableWhitelist", "name" => "disableWhitelist",
"inputs" => [%{"type" => "bool", "name" => "disable", "internalType" => "bool"}] "inputs" => [%{"type" => "bool", "name" => "disable", "internalType" => "bool"}],
"method_id" => "49ba1b49"
} }
] == response ] == response
end end
@ -1912,7 +1914,8 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"stateMutability" => "nonpayable", "stateMutability" => "nonpayable",
"outputs" => [], "outputs" => [],
"name" => "disableWhitelist", "name" => "disableWhitelist",
"inputs" => [%{"type" => "bool", "name" => "disable", "internalType" => "bool"}] "inputs" => [%{"type" => "bool", "name" => "disable", "internalType" => "bool"}],
"method_id" => "49ba1b49"
} }
] == response ] == response
end end

Loading…
Cancel
Save