From 44cd19a178fa3bcc054d702a0c8a795db2ea5cfb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 11:23:54 +0300 Subject: [PATCH 1/4] fix not existing keys in transaction json rpc --- .../lib/ethereum_jsonrpc/transaction.ex | 7 ++++++- .../test/ethereum_jsonrpc/transaction_test.exs | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex index f021bfa153..8bcaedf1b4 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex @@ -14,7 +14,8 @@ defmodule EthereumJSONRPC.Transaction do alias EthereumJSONRPC @type elixir :: %{ - String.t() => EthereumJSONRPC.address() | EthereumJSONRPC.hash() | String.t() | non_neg_integer() | nil + String.t() + | nil => EthereumJSONRPC.address() | EthereumJSONRPC.hash() | String.t() | non_neg_integer() | nil } @typedoc """ @@ -353,4 +354,8 @@ defmodule EthereumJSONRPC.Transaction do _ -> {key, quantity_to_integer(chain_id)} end end + + defp entry_to_elixir(_) do + {nil, nil} + end end diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/transaction_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/transaction_test.exs index ad7780181d..a8a8fcdfd2 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/transaction_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/transaction_test.exs @@ -2,4 +2,14 @@ defmodule EthereumJSONRPC.TransactionTest do use ExUnit.Case, async: true doctest EthereumJSONRPC.Transaction + + alias EthereumJSONRPC.Transaction + + describe "to_elixir/1" do + test "skips unsupported keys" do + map = %{"key" => "value", "key1" => "value1"} + + assert %{nil: nil} = Transaction.to_elixir(map) + end + end end From dbbd81b60592d458201cdc83c30f437ffc7570b0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 11:25:39 +0300 Subject: [PATCH 2/4] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c8934f3d..783de20494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes +- [#2387](https://github.com/poanetwork/blockscout/pull/2387) - fix not existing keys in transaction json rpc - [#2378](https://github.com/poanetwork/blockscout/pull/2378) - Page performance: exclude moment.js localization files except EN, remove unused css - [#2368](https://github.com/poanetwork/blockscout/pull/2368) - add two columns of smart contract info - [#2375](https://github.com/poanetwork/blockscout/pull/2375) - Update created_contract_code_indexed_at on transaction import conflict From 9fb6bf1521d7a103bd040236b9321620902d916c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 11:34:18 +0300 Subject: [PATCH 3/4] fix build --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex index 8bcaedf1b4..7992c0e63c 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex @@ -14,8 +14,7 @@ defmodule EthereumJSONRPC.Transaction do alias EthereumJSONRPC @type elixir :: %{ - String.t() - | nil => EthereumJSONRPC.address() | EthereumJSONRPC.hash() | String.t() | non_neg_integer() | nil + String.t() => EthereumJSONRPC.address() | EthereumJSONRPC.hash() | String.t() | non_neg_integer() | nil } @typedoc """ From 30474994ae5c00cfdc229cb1cc17673cab9f8623 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 23 Jul 2019 15:23:11 +0300 Subject: [PATCH 4/4] Fix router page not found path --- CHANGELOG.md | 1 + .../block_scout_web/controllers/address_logs_controller.ex | 2 ++ .../controllers/address_transaction_controller.ex | 4 ++++ .../lib/block_scout_web/controllers/chain_controller.ex | 2 ++ .../block_scout_web/controllers/smart_contract_controller.ex | 2 ++ apps/block_scout_web/lib/block_scout_web/router.ex | 2 +- 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b333ba4ef9..85f1241c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2416](https://github.com/poanetwork/blockscout/pull/2416) - Fix "page not found" handling in the router - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2398](https://github.com/poanetwork/blockscout/pull/2398) - show only one decoded candidate - [#2395](https://github.com/poanetwork/blockscout/pull/2395) - new block loading animation diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex index e349ecd9ef..04c37badb5 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex @@ -115,4 +115,6 @@ defmodule BlockScoutWeb.AddressLogsController do not_found(conn) end end + + def search_logs(conn, _), do: not_found(conn) end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex index f6d9b8a30f..ba29c766c1 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex @@ -130,6 +130,8 @@ defmodule BlockScoutWeb.AddressTransactionController do end end + def token_transfers_csv(conn, _), do: not_found(conn) + def transactions_csv(conn, %{"address_id" => address_hash_string}) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), {:ok, address} <- Chain.hash_to_address(address_hash) do @@ -149,4 +151,6 @@ defmodule BlockScoutWeb.AddressTransactionController do not_found(conn) end end + + def transactions_csv(conn, _), do: not_found(conn) end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index 40a0fd3bbb..520fe8ea29 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -52,6 +52,8 @@ defmodule BlockScoutWeb.ChainController do end end + def search(conn, _), do: not_found(conn) + def token_autocomplete(conn, %{"q" => term}) when is_binary(term) do if term == "" do json(conn, "{}") diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex index 70ec6219f3..58fb4c4432 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex @@ -30,6 +30,8 @@ defmodule BlockScoutWeb.SmartContractController do end end + def index(conn, _), do: not_found(conn) + def show(conn, params) do with true <- ajax?(conn), {:ok, address_hash} <- Chain.string_to_address_hash(params["id"]), diff --git a/apps/block_scout_web/lib/block_scout_web/router.ex b/apps/block_scout_web/lib/block_scout_web/router.ex index 4f5a8e1bed..7a1f5b3ed9 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -261,6 +261,6 @@ defmodule BlockScoutWeb.Router do get("/api_docs", APIDocsController, :index) get("/eth_rpc_api_docs", APIDocsController, :eth_rpc) - get("/:page", PageNotFoundController, :index) + get("/*path", PageNotFoundController, :index) end end