From e3b485771deb9e3eb44723ca2494592462b32aa6 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 14:54:47 +0300 Subject: [PATCH 001/290] Split API's endpoints into separate router --- apps/block_scout_web/config/config.exs | 2 + .../lib/block_scout_web/api_router.ex | 72 +++++++++++++++++++ .../lib/block_scout_web/router.ex | 56 +++------------ 3 files changed, 85 insertions(+), 45 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/api_router.ex diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 836a21ba02..f99647694d 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -86,6 +86,8 @@ config :wobserver, discovery: :none, mode: :plug +config :block_scout_web, BlockScoutWeb.ApiRouter, enabled: System.get_env("DISABLE_API") != "true" + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/apps/block_scout_web/lib/block_scout_web/api_router.ex b/apps/block_scout_web/lib/block_scout_web/api_router.ex new file mode 100644 index 0000000000..c40bd69e73 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/api_router.ex @@ -0,0 +1,72 @@ +defmodule BlockScoutWeb.ApiRouter do + @moduledoc """ + Router for API + """ + use BlockScoutWeb, :router + + alias BlockScoutWeb.API.RPC + alias BlockScoutWeb.Plug.GraphQL + + pipeline :api do + plug(:accepts, ["json"]) + end + + scope "/v1", BlockScoutWeb.API.V1, as: :api_v1 do + pipe_through(:api) + + get("/supply", SupplyController, :supply) + + get("/health", HealthController, :health) + + post("/decompiled_smart_contract", DecompiledSmartContractController, :create) + post("/verified_smart_contracts", VerifiedSmartContractController, :create) + post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) + + post("/eth_rpc", EthController, :eth_request) + + forward("/", RPCTranslator, %{ + "block" => RPC.BlockController, + "account" => RPC.AddressController, + "logs" => RPC.LogsController, + "token" => RPC.TokenController, + "stats" => RPC.StatsController, + "contract" => RPC.ContractController, + "transaction" => RPC.TransactionController + }) + end + + # Needs to be 200 to support the schema introspection for graphiql + @max_complexity 200 + + forward("/graphql", Absinthe.Plug, + schema: BlockScoutWeb.Schema, + analyze_complexity: true, + max_complexity: @max_complexity + ) + + forward("/graphiql", Absinthe.Plug.GraphiQL, + schema: BlockScoutWeb.Schema, + interface: :advanced, + default_query: GraphQL.default_query(), + socket: BlockScoutWeb.UserSocket, + analyze_complexity: true, + max_complexity: @max_complexity + ) + + # For backward compatibility. Should be removed + scope "/", BlockScoutWeb.API.RPC do + pipe_through(:api) + + post("/eth_rpc", EthController, :eth_request) + + forward("/", RPCTranslator, %{ + "block" => RPC.BlockController, + "account" => RPC.AddressController, + "logs" => RPC.LogsController, + "token" => RPC.TokenController, + "stats" => RPC.StatsController, + "contract" => RPC.ContractController, + "transaction" => RPC.TransactionController + }) + end +end 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..f52493d25c 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -6,53 +6,11 @@ defmodule BlockScoutWeb.Router do forward("/wobserver", Wobserver.Web.Router) forward("/admin", BlockScoutWeb.AdminRouter) - pipeline :browser do - plug(:accepts, ["html"]) - plug(:fetch_session) - plug(:fetch_flash) - plug(:protect_from_forgery) - plug(BlockScoutWeb.CSPHeader) - end - - pipeline :api do - plug(:accepts, ["json"]) - end - - scope "/api/v1", BlockScoutWeb.API.V1, as: :api_v1 do - pipe_through(:api) - - get("/supply", SupplyController, :supply) - - get("/health", HealthController, :health) - - resources("/decompiled_smart_contract", DecompiledSmartContractController, only: [:create]) - resources("/verified_smart_contracts", VerifiedSmartContractController, only: [:create]) - end - - scope "/verify_smart_contract" do - pipe_through(:api) - - post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) - end - - scope "/api", BlockScoutWeb.API.RPC do - pipe_through(:api) - - alias BlockScoutWeb.API.RPC - - post("/eth_rpc", EthController, :eth_request) - - forward("/", RPCTranslator, %{ - "block" => RPC.BlockController, - "account" => RPC.AddressController, - "logs" => RPC.LogsController, - "token" => RPC.TokenController, - "stats" => RPC.StatsController, - "contract" => RPC.ContractController, - "transaction" => RPC.TransactionController - }) + if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter, :enabled) do + forward("/api", BlockScoutWeb.ApiRouter) end + # For backward compatibility. Should be removed # Needs to be 200 to support the schema introspection for graphiql @max_complexity 200 @@ -71,6 +29,14 @@ defmodule BlockScoutWeb.Router do max_complexity: @max_complexity ) + pipeline :browser do + plug(:accepts, ["html"]) + plug(:fetch_session) + plug(:fetch_flash) + plug(:protect_from_forgery) + plug(BlockScoutWeb.CSPHeader) + end + # Disallows Iframes (write routes) scope "/", BlockScoutWeb do pipe_through(:browser) From 6bb49e01303f04b2b661d7822c61dd2ddca4f74d Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 14:59:10 +0300 Subject: [PATCH 002/290] Update tests to work with new routes path --- .../templates/address_contract_verification/new.html.eex | 2 +- .../views/address_contract_verification_view.ex | 5 +++++ .../api/v1/decompiled_smart_contract_controller_test.exs | 5 +++++ .../controllers/api/v1/health_controller_test.exs | 6 ++++++ .../controllers/api/v1/supply_controller_test.exs | 5 +++++ .../api/v1/verified_smart_contract_controller_test.exs | 5 +++++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex index fd93b0af2b..a1a715a734 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex @@ -9,7 +9,7 @@

<%= gettext "New Smart Contract Verification" %>

<%= form_for @changeset, - address_contract_verification_path(@conn, :create), + api_v1_address_contract_verification_path(@conn, :create), [], fn f -> %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex index 874b470406..b8e39ab547 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex @@ -1,3 +1,8 @@ defmodule BlockScoutWeb.AddressContractVerificationView do use BlockScoutWeb, :view + alias BlockScoutWeb.ApiRouter.Helpers + + def api_v1_address_contract_verification_path(conn, action) do + "/api" <> Helpers.api_v1_address_contract_verification_path(conn, action) + end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs index d6b52c8490..b39d6688e0 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/decompiled_smart_contract_controller_test.exs @@ -1,6 +1,7 @@ defmodule BlockScoutWeb.API.V1.DecompiledControllerTest do use BlockScoutWeb.ConnCase + alias BlockScoutWeb.ApiRouter.Helpers alias Explorer.Repo alias Explorer.Chain.{Address, DecompiledSmartContract} @@ -114,4 +115,8 @@ defmodule BlockScoutWeb.API.V1.DecompiledControllerTest do assert request.status == 403 end end + + def api_v1_decompiled_smart_contract_path(conn, action) do + "/api" <> Helpers.api_v1_decompiled_smart_contract_path(conn, action) + end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs index 41735f685a..53abd8b880 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs @@ -1,6 +1,8 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do use BlockScoutWeb.ConnCase + alias BlockScoutWeb.ApiRouter.Helpers + describe "GET last_block_status/0" do test "returns error when there are no blocks in db", %{conn: conn} do request = get(conn, api_v1_health_path(conn, :health)) @@ -47,4 +49,8 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do } = Poison.decode!(request.resp_body) end end + + def api_v1_health_path(conn, action) do + "/api" <> Helpers.api_v1_health_path(conn, action) + end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/supply_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/supply_controller_test.exs index 268169a21c..2ad2f41758 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/supply_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/supply_controller_test.exs @@ -1,6 +1,7 @@ defmodule BlockScoutWeb.API.V1.SupplyControllerTest do use BlockScoutWeb.ConnCase + alias BlockScoutWeb.ApiRouter.Helpers alias Explorer.Chain test "supply", %{conn: conn} do @@ -10,4 +11,8 @@ defmodule BlockScoutWeb.API.V1.SupplyControllerTest do assert response["total_supply"] == Chain.total_supply() assert response["circulating_supply"] == Chain.circulating_supply() end + + def api_v1_supply_path(conn, action) do + "/api" <> Helpers.api_v1_supply_path(conn, action) + end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/verified_smart_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/verified_smart_contract_controller_test.exs index 2e51f42467..d11844e933 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/verified_smart_contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/verified_smart_contract_controller_test.exs @@ -1,6 +1,7 @@ defmodule BlockScoutWeb.API.V1.VerifiedControllerTest do use BlockScoutWeb.ConnCase + alias BlockScoutWeb.ApiRouter.Helpers alias Explorer.Factory # alias Explorer.Chain.DecompiledSmartContract @@ -69,4 +70,8 @@ defmodule BlockScoutWeb.API.V1.VerifiedControllerTest do assert response.status == 201 assert Jason.decode!(response.resp_body) == %{"status" => "success"} end + + def api_v1_verified_smart_contract_path(conn, action) do + "/api" <> Helpers.api_v1_verified_smart_contract_path(conn, action) + end end From a883d248ae60a0569e45990b0449c09c79c68e7b Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 15:43:49 +0300 Subject: [PATCH 003/290] Split web app's endpoints into a new router --- apps/block_scout_web/config/config.exs | 1 + apps/block_scout_web/lib/block_scout_web.ex | 2 + .../lib/block_scout_web/router.ex | 232 ++---------------- .../lib/block_scout_web/web_router.ex | 207 ++++++++++++++++ 4 files changed, 232 insertions(+), 210 deletions(-) create mode 100644 apps/block_scout_web/lib/block_scout_web/web_router.ex diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index f99647694d..84f60a2842 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -87,6 +87,7 @@ config :wobserver, mode: :plug config :block_scout_web, BlockScoutWeb.ApiRouter, enabled: System.get_env("DISABLE_API") != "true" +config :block_scout_web, BlockScoutWeb.WebRouter, enabled: System.get_env("DISABLE_WEBAPP") != "true" # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/apps/block_scout_web/lib/block_scout_web.ex b/apps/block_scout_web/lib/block_scout_web.ex index 4e1f857526..7cbe856f5f 100644 --- a/apps/block_scout_web/lib/block_scout_web.ex +++ b/apps/block_scout_web/lib/block_scout_web.ex @@ -24,6 +24,7 @@ defmodule BlockScoutWeb do import BlockScoutWeb.Controller import BlockScoutWeb.Router.Helpers + import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2] import BlockScoutWeb.Gettext import BlockScoutWeb.ErrorHelpers import Plug.Conn @@ -54,6 +55,7 @@ defmodule BlockScoutWeb do Views.ScriptHelpers, WeiHelpers } + import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2] import PhoenixFormAwesomplete end 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 f52493d25c..e522ce842e 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -3,32 +3,6 @@ defmodule BlockScoutWeb.Router do alias BlockScoutWeb.Plug.GraphQL - forward("/wobserver", Wobserver.Web.Router) - forward("/admin", BlockScoutWeb.AdminRouter) - - if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter, :enabled) do - forward("/api", BlockScoutWeb.ApiRouter) - end - - # For backward compatibility. Should be removed - # Needs to be 200 to support the schema introspection for graphiql - @max_complexity 200 - - forward("/graphql", Absinthe.Plug, - schema: BlockScoutWeb.Schema, - analyze_complexity: true, - max_complexity: @max_complexity - ) - - forward("/graphiql", Absinthe.Plug.GraphiQL, - schema: BlockScoutWeb.Schema, - interface: :advanced, - default_query: GraphQL.default_query(), - socket: BlockScoutWeb.UserSocket, - analyze_complexity: true, - max_complexity: @max_complexity - ) - pipeline :browser do plug(:accepts, ["html"]) plug(:fetch_session) @@ -37,196 +11,34 @@ defmodule BlockScoutWeb.Router do plug(BlockScoutWeb.CSPHeader) end - # Disallows Iframes (write routes) - scope "/", BlockScoutWeb do - pipe_through(:browser) - end + forward("/wobserver", Wobserver.Web.Router) + forward("/admin", BlockScoutWeb.AdminRouter) - # Allows Iframes (read-only routes) - scope "/", BlockScoutWeb do - pipe_through([:browser, BlockScoutWeb.Plug.AllowIframe]) + if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter, :enabled) do + forward("/api", BlockScoutWeb.ApiRouter) - resources("/", ChainController, only: [:show], singleton: true, as: :chain) + # For backward compatibility. Should be removed + # Needs to be 200 to support the schema introspection for graphiql + @max_complexity 200 - resources("/market_history_chart", Chain.MarketHistoryChartController, - only: [:show], - singleton: true + forward("/graphql", Absinthe.Plug, + schema: BlockScoutWeb.Schema, + analyze_complexity: true, + max_complexity: @max_complexity ) - resources "/blocks", BlockController, only: [:index, :show], param: "hash_or_number" do - resources("/transactions", BlockTransactionController, only: [:index], as: :transaction) - end - - get("/reorgs", BlockController, :reorg, as: :reorg) - - get("/uncles", BlockController, :uncle, as: :uncle) - - resources("/pending_transactions", PendingTransactionController, only: [:index]) - - resources("/recent_transactions", RecentTransactionsController, only: [:index]) - - get("/txs", TransactionController, :index) - - resources "/tx", TransactionController, only: [:show] do - resources( - "/internal_transactions", - TransactionInternalTransactionController, - only: [:index], - as: :internal_transaction - ) - - resources( - "/raw_trace", - TransactionRawTraceController, - only: [:index], - as: :raw_trace - ) - - resources("/logs", TransactionLogController, only: [:index], as: :log) - - resources("/token_transfers", TransactionTokenTransferController, - only: [:index], - as: :token_transfer - ) - end - - resources("/accounts", AddressController, only: [:index]) - - resources "/address", AddressController, only: [:show] do - resources("/transactions", AddressTransactionController, only: [:index], as: :transaction) - - resources( - "/internal_transactions", - AddressInternalTransactionController, - only: [:index], - as: :internal_transaction - ) - - resources( - "/validations", - AddressValidationController, - only: [:index], - as: :validation - ) - - resources( - "/contracts", - AddressContractController, - only: [:index], - as: :contract - ) - - resources( - "/decompiled_contracts", - AddressDecompiledContractController, - only: [:index], - as: :decompiled_contract - ) - - resources( - "/logs", - AddressLogsController, - only: [:index], - as: :logs - ) - - resources( - "/contract_verifications", - AddressContractVerificationController, - only: [:new], - as: :verify_contract - ) - - resources( - "/read_contract", - AddressReadContractController, - only: [:index, :show], - as: :read_contract - ) - - resources("/tokens", AddressTokenController, only: [:index], as: :token) do - resources( - "/token_transfers", - AddressTokenTransferController, - only: [:index], - as: :transfers - ) - end - - resources( - "/token_balances", - AddressTokenBalanceController, - only: [:index], - as: :token_balance - ) - - resources( - "/coin_balances", - AddressCoinBalanceController, - only: [:index], - as: :coin_balance - ) - - resources( - "/coin_balances/by_day", - AddressCoinBalanceByDayController, - only: [:index], - as: :coin_balance_by_day - ) - end - - resources "/tokens", Tokens.TokenController, only: [:show], as: :token do - resources( - "/token_transfers", - Tokens.TransferController, - only: [:index], - as: :transfer - ) - - resources( - "/read_contract", - Tokens.ReadContractController, - only: [:index], - as: :read_contract - ) - - resources( - "/token_holders", - Tokens.HolderController, - only: [:index], - as: :holder - ) - - resources( - "/inventory", - Tokens.InventoryController, - only: [:index], - as: :inventory - ) - end - - resources( - "/smart_contracts", - SmartContractController, - only: [:index, :show], - as: :smart_contract + forward("/graphiql", Absinthe.Plug.GraphiQL, + schema: BlockScoutWeb.Schema, + interface: :advanced, + default_query: GraphQL.default_query(), + socket: BlockScoutWeb.UserSocket, + analyze_complexity: true, + max_complexity: @max_complexity ) + end - get("/search", ChainController, :search) - - get("/search_logs", AddressLogsController, :search_logs) - - get("/transactions_csv", AddressTransactionController, :transactions_csv) - - get("/token_autocomplete", ChainController, :token_autocomplete) - - get("/token_transfers_csv", AddressTransactionController, :token_transfers_csv) - - get("/chain_blocks", ChainController, :chain_blocks, as: :chain_blocks) - - get("/api_docs", APIDocsController, :index) - get("/eth_rpc_api_docs", APIDocsController, :eth_rpc) - - get("/:page", PageNotFoundController, :index) + if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter, :enabled) do + forward("/", BlockScoutWeb.WebRouter) end + end diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex new file mode 100644 index 0000000000..9b250332db --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -0,0 +1,207 @@ +defmodule BlockScoutWeb.WebRouter do + @moduledoc """ + Router for web app + """ + use BlockScoutWeb, :router + + pipeline :browser do + plug(:accepts, ["html"]) + plug(:fetch_session) + plug(:fetch_flash) + plug(:protect_from_forgery) + plug(BlockScoutWeb.CSPHeader) + end + + # Disallows Iframes (write routes) + scope "/", BlockScoutWeb do + pipe_through(:browser) + end + + # Allows Iframes (read-only routes) + scope "/", BlockScoutWeb do + pipe_through([:browser, BlockScoutWeb.Plug.AllowIframe]) + + resources("/", ChainController, only: [:show], singleton: true, as: :chain) + + resources("/market_history_chart", Chain.MarketHistoryChartController, + only: [:show], + singleton: true + ) + + resources "/blocks", BlockController, only: [:index, :show], param: "hash_or_number" do + resources("/transactions", BlockTransactionController, only: [:index], as: :transaction) + end + + get("/reorgs", BlockController, :reorg, as: :reorg) + + get("/uncles", BlockController, :uncle, as: :uncle) + + resources("/pending_transactions", PendingTransactionController, only: [:index]) + + resources("/recent_transactions", RecentTransactionsController, only: [:index]) + + get("/txs", TransactionController, :index) + + resources "/tx", TransactionController, only: [:show] do + resources( + "/internal_transactions", + TransactionInternalTransactionController, + only: [:index], + as: :internal_transaction + ) + + resources( + "/raw_trace", + TransactionRawTraceController, + only: [:index], + as: :raw_trace + ) + + resources("/logs", TransactionLogController, only: [:index], as: :log) + + resources("/token_transfers", TransactionTokenTransferController, + only: [:index], + as: :token_transfer + ) + end + + resources("/accounts", AddressController, only: [:index]) + + resources "/address", AddressController, only: [:show] do + resources("/transactions", AddressTransactionController, only: [:index], as: :transaction) + + resources( + "/internal_transactions", + AddressInternalTransactionController, + only: [:index], + as: :internal_transaction + ) + + resources( + "/validations", + AddressValidationController, + only: [:index], + as: :validation + ) + + resources( + "/contracts", + AddressContractController, + only: [:index], + as: :contract + ) + + resources( + "/decompiled_contracts", + AddressDecompiledContractController, + only: [:index], + as: :decompiled_contract + ) + + resources( + "/logs", + AddressLogsController, + only: [:index], + as: :logs + ) + + resources( + "/contract_verifications", + AddressContractVerificationController, + only: [:new], + as: :verify_contract + ) + + resources( + "/read_contract", + AddressReadContractController, + only: [:index, :show], + as: :read_contract + ) + + resources("/tokens", AddressTokenController, only: [:index], as: :token) do + resources( + "/token_transfers", + AddressTokenTransferController, + only: [:index], + as: :transfers + ) + end + + resources( + "/token_balances", + AddressTokenBalanceController, + only: [:index], + as: :token_balance + ) + + resources( + "/coin_balances", + AddressCoinBalanceController, + only: [:index], + as: :coin_balance + ) + + resources( + "/coin_balances/by_day", + AddressCoinBalanceByDayController, + only: [:index], + as: :coin_balance_by_day + ) + end + + resources "/tokens", Tokens.TokenController, only: [:show], as: :token do + resources( + "/token_transfers", + Tokens.TransferController, + only: [:index], + as: :transfer + ) + + resources( + "/read_contract", + Tokens.ReadContractController, + only: [:index], + as: :read_contract + ) + + resources( + "/token_holders", + Tokens.HolderController, + only: [:index], + as: :holder + ) + + resources( + "/inventory", + Tokens.InventoryController, + only: [:index], + as: :inventory + ) + end + + resources( + "/smart_contracts", + SmartContractController, + only: [:index, :show], + as: :smart_contract + ) + + get("/search", ChainController, :search) + + get("/search_logs", AddressLogsController, :search_logs) + + get("/transactions_csv", AddressTransactionController, :transactions_csv) + + get("/token_autocomplete", ChainController, :token_autocomplete) + + get("/token_transfers_csv", AddressTransactionController, :token_transfers_csv) + + get("/chain_blocks", ChainController, :chain_blocks, as: :chain_blocks) + + get("/api_docs", APIDocsController, :index) + get("/eth_rpc_api_docs", APIDocsController, :eth_rpc) + + get("/:page", PageNotFoundController, :index) + end +end From d3c60b0ec5fd7accac278c685124f1ea5c8ddef3 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 15:44:50 +0300 Subject: [PATCH 004/290] Update test to work with a new web app's router --- .../controllers/address_contract_controller_test.exs | 2 +- .../address_internal_transaction_controller_test.exs | 2 +- .../controllers/address_token_controller_test.exs | 2 +- .../controllers/address_token_transfer_controller_test.exs | 2 +- .../controllers/address_transaction_controller_test.exs | 2 +- .../block_scout_web/controllers/api_docs_controller_test.exs | 2 +- .../controllers/block_transaction_controller_test.exs | 2 +- .../test/block_scout_web/controllers/chain_controller_test.exs | 2 +- .../controllers/pending_transaction_controller_test.exs | 2 +- .../controllers/recent_transactions_controller_test.exs | 2 +- .../block_scout_web/controllers/transaction_controller_test.exs | 2 +- .../transaction_internal_transaction_controller_test.exs | 2 +- .../controllers/transaction_log_controller_test.exs | 2 +- .../controllers/transaction_token_transfer_controller_test.exs | 2 +- .../block_scout_web/features/pages/transaction_logs_page.ex | 2 +- apps/block_scout_web/test/support/conn_case.ex | 1 + 16 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs index 3e3c92cb7f..3b62a40bd5 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.AddressContractControllerTest do use BlockScoutWeb.ConnCase, async: true - import BlockScoutWeb.Router.Helpers, only: [address_contract_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [address_contract_path: 3] alias Explorer.Chain.Hash alias Explorer.ExchangeRates.Token diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs index 8f5bc9a667..90b0c6500f 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do use BlockScoutWeb.ConnCase, async: true - import BlockScoutWeb.Router.Helpers, + import BlockScoutWeb.WebRouter.Helpers, only: [address_internal_transaction_path: 3, address_internal_transaction_path: 4] alias Explorer.Chain.{Block, InternalTransaction, Transaction} diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_token_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_token_controller_test.exs index 31a1c2c5cf..16df97b9fc 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_token_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_token_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.AddressTokenControllerTest do use BlockScoutWeb.ConnCase, async: true - import BlockScoutWeb.Router.Helpers, only: [address_token_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [address_token_path: 3] alias Explorer.Chain.{Token} diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_token_transfer_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_token_transfer_controller_test.exs index a7e29efd10..70a362b109 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_token_transfer_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_token_transfer_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.AddressTokenTransferControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, + import BlockScoutWeb.WebRouter.Helpers, only: [address_token_transfers_path: 4, address_token_transfers_path: 5] alias Explorer.Chain.{Address, Token} diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs index a29d6b9be6..6476432e91 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do use BlockScoutWeb.ConnCase, async: true - import BlockScoutWeb.Router.Helpers, only: [address_transaction_path: 3, address_transaction_path: 4] + import BlockScoutWeb.WebRouter.Helpers, only: [address_transaction_path: 3, address_transaction_path: 4] alias Explorer.Chain.Transaction alias Explorer.ExchangeRates.Token diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs index 3b2cb99ff0..4db9eccd6d 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.APIDocsControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [api_docs_path: 2] + import BlockScoutWeb.WebRouter.Helpers, only: [api_docs_path: 2] describe "GET index/2" do test "renders documentation tiles for each API module#action", %{conn: conn} do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs index da159b6e6e..d76a2fcd1c 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [block_transaction_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [block_transaction_path: 3] describe "GET index/2" do test "with invalid block number", %{conn: conn} do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs index f902f15ad4..00a53689c8 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs @@ -3,7 +3,7 @@ defmodule BlockScoutWeb.ChainControllerTest do # ETS table is shared in `Explorer.Counters.AddressesWithBalanceCounter` async: false - import BlockScoutWeb.Router.Helpers, only: [chain_path: 2, block_path: 3, transaction_path: 3, address_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [chain_path: 2, block_path: 3, transaction_path: 3, address_path: 3] alias Explorer.Chain.Block alias Explorer.Counters.AddressesWithBalanceCounter diff --git a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs index d632154294..b19bec2520 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs @@ -2,7 +2,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do use BlockScoutWeb.ConnCase alias Explorer.Chain.{Hash, Transaction} - import BlockScoutWeb.Router.Helpers, only: [pending_transaction_path: 2, pending_transaction_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [pending_transaction_path: 2, pending_transaction_path: 3] describe "GET index/2" do test "returns no transactions that are in a block", %{conn: conn} do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/recent_transactions_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/recent_transactions_controller_test.exs index a35ea19491..0a2267f18c 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/recent_transactions_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/recent_transactions_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.RecentTransactionsControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [recent_transactions_path: 2] + import BlockScoutWeb.WebRouter.Helpers, only: [recent_transactions_path: 2] alias Explorer.Chain.Hash diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs index cd2e557f93..80e8b12b70 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, + import BlockScoutWeb.WebRouter.Helpers, only: [transaction_path: 3, transaction_internal_transaction_path: 3, transaction_token_transfer_path: 3] alias Explorer.Chain.Transaction diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs index 6b9a32d280..773b51a36c 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [transaction_internal_transaction_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [transaction_internal_transaction_path: 3] alias Explorer.Chain.InternalTransaction alias Explorer.ExchangeRates.Token diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs index 05c7638d52..65142dd0ce 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [transaction_log_path: 3] alias Explorer.ExchangeRates.Token diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs index ca183f5289..6d3c83980b 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.Router.Helpers, only: [transaction_token_transfer_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [transaction_token_transfer_path: 3] alias Explorer.ExchangeRates.Token diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex index bbb0c7c311..3969cd559c 100644 --- a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex +++ b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex @@ -4,7 +4,7 @@ defmodule BlockScoutWeb.TransactionLogsPage do use Wallaby.DSL import Wallaby.Query, only: [css: 1, css: 2] - import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 3] + import BlockScoutWeb.WebRouter.Helpers, only: [transaction_log_path: 3] alias Explorer.Chain.Transaction alias BlockScoutWeb.Endpoint diff --git a/apps/block_scout_web/test/support/conn_case.ex b/apps/block_scout_web/test/support/conn_case.ex index ca486b33c2..19b125e40a 100644 --- a/apps/block_scout_web/test/support/conn_case.ex +++ b/apps/block_scout_web/test/support/conn_case.ex @@ -20,6 +20,7 @@ defmodule BlockScoutWeb.ConnCase do # Import conveniences for testing with connections use Phoenix.ConnTest import BlockScoutWeb.Router.Helpers + import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2] # The default endpoint for testing @endpoint BlockScoutWeb.Endpoint From b717c37c0ba110960a9343b50754333b720c58b6 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 17 Jul 2019 16:10:17 +0300 Subject: [PATCH 005/290] Fix failed contract verifications test --- apps/block_scout_web/lib/block_scout_web.ex | 1 + .../lib/block_scout_web/api_router.ex | 35 ++++++++++--------- .../lib/block_scout_web/router.ex | 5 ++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web.ex b/apps/block_scout_web/lib/block_scout_web.ex index 7cbe856f5f..20ca4351df 100644 --- a/apps/block_scout_web/lib/block_scout_web.ex +++ b/apps/block_scout_web/lib/block_scout_web.ex @@ -55,6 +55,7 @@ defmodule BlockScoutWeb do Views.ScriptHelpers, WeiHelpers } + import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2] import PhoenixFormAwesomplete diff --git a/apps/block_scout_web/lib/block_scout_web/api_router.ex b/apps/block_scout_web/lib/block_scout_web/api_router.ex index c40bd69e73..650188b6a2 100644 --- a/apps/block_scout_web/lib/block_scout_web/api_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/api_router.ex @@ -11,28 +11,31 @@ defmodule BlockScoutWeb.ApiRouter do plug(:accepts, ["json"]) end - scope "/v1", BlockScoutWeb.API.V1, as: :api_v1 do + scope "/v1", as: :api_v1 do pipe_through(:api) - get("/supply", SupplyController, :supply) + post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) - get("/health", HealthController, :health) + scope "/", BlockScoutWeb.API.V1 do + get("/supply", SupplyController, :supply) - post("/decompiled_smart_contract", DecompiledSmartContractController, :create) - post("/verified_smart_contracts", VerifiedSmartContractController, :create) - post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) + get("/health", HealthController, :health) - post("/eth_rpc", EthController, :eth_request) + post("/decompiled_smart_contract", DecompiledSmartContractController, :create) + post("/verified_smart_contracts", VerifiedSmartContractController, :create) - forward("/", RPCTranslator, %{ - "block" => RPC.BlockController, - "account" => RPC.AddressController, - "logs" => RPC.LogsController, - "token" => RPC.TokenController, - "stats" => RPC.StatsController, - "contract" => RPC.ContractController, - "transaction" => RPC.TransactionController - }) + post("/eth_rpc", EthController, :eth_request) + + forward("/", RPCTranslator, %{ + "block" => RPC.BlockController, + "account" => RPC.AddressController, + "logs" => RPC.LogsController, + "token" => RPC.TokenController, + "stats" => RPC.StatsController, + "contract" => RPC.ContractController, + "transaction" => RPC.TransactionController + }) + end end # Needs to be 200 to support the schema introspection for graphiql 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 e522ce842e..1354c57d56 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -14,7 +14,7 @@ defmodule BlockScoutWeb.Router do forward("/wobserver", Wobserver.Web.Router) forward("/admin", BlockScoutWeb.AdminRouter) - if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter, :enabled) do + if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] do forward("/api", BlockScoutWeb.ApiRouter) # For backward compatibility. Should be removed @@ -37,8 +37,7 @@ defmodule BlockScoutWeb.Router do ) end - if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter, :enabled) do + if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter)[:enabled] do forward("/", BlockScoutWeb.WebRouter) end - end From 9a7629765194cc8ce5c19462d22a7ab103e153e7 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 18 Jul 2019 16:59:13 +0300 Subject: [PATCH 006/290] Update routers to hide and show api's docs --- .../lib/block_scout_web/api_router.ex | 21 -- .../lib/block_scout_web/router.ex | 46 +++- .../new.html.eex | 2 +- .../templates/layout/_topnav.html.eex | 204 +++++++++--------- .../address_contract_verification_view.ex | 5 - .../lib/block_scout_web/web_router.ex | 3 - .../api/v1/health_controller_test.exs | 6 - .../controllers/api_docs_controller_test.exs | 2 +- 8 files changed, 147 insertions(+), 142 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/api_router.ex b/apps/block_scout_web/lib/block_scout_web/api_router.ex index 650188b6a2..73386dd4fa 100644 --- a/apps/block_scout_web/lib/block_scout_web/api_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/api_router.ex @@ -5,7 +5,6 @@ defmodule BlockScoutWeb.ApiRouter do use BlockScoutWeb, :router alias BlockScoutWeb.API.RPC - alias BlockScoutWeb.Plug.GraphQL pipeline :api do plug(:accepts, ["json"]) @@ -19,8 +18,6 @@ defmodule BlockScoutWeb.ApiRouter do scope "/", BlockScoutWeb.API.V1 do get("/supply", SupplyController, :supply) - get("/health", HealthController, :health) - post("/decompiled_smart_contract", DecompiledSmartContractController, :create) post("/verified_smart_contracts", VerifiedSmartContractController, :create) @@ -38,24 +35,6 @@ defmodule BlockScoutWeb.ApiRouter do end end - # Needs to be 200 to support the schema introspection for graphiql - @max_complexity 200 - - forward("/graphql", Absinthe.Plug, - schema: BlockScoutWeb.Schema, - analyze_complexity: true, - max_complexity: @max_complexity - ) - - forward("/graphiql", Absinthe.Plug.GraphiQL, - schema: BlockScoutWeb.Schema, - interface: :advanced, - default_query: GraphQL.default_query(), - socket: BlockScoutWeb.UserSocket, - analyze_complexity: true, - max_complexity: @max_complexity - ) - # For backward compatibility. Should be removed scope "/", BlockScoutWeb.API.RPC do pipe_through(:api) 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 1354c57d56..62c6e09d91 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -2,6 +2,10 @@ defmodule BlockScoutWeb.Router do use BlockScoutWeb, :router alias BlockScoutWeb.Plug.GraphQL + alias BlockScoutWeb.{ApiRouter, WebRouter} + + forward("/wobserver", Wobserver.Web.Router) + forward("/admin", BlockScoutWeb.AdminRouter) pipeline :browser do plug(:accepts, ["html"]) @@ -11,13 +15,24 @@ defmodule BlockScoutWeb.Router do plug(BlockScoutWeb.CSPHeader) end - forward("/wobserver", Wobserver.Web.Router) - forward("/admin", BlockScoutWeb.AdminRouter) + pipeline :api do + plug(:accepts, ["json"]) + end + + scope "/", BlockScoutWeb.API.V1, as: :api_v1 do + pipe_through(:api) + get("/api/v1/health", HealthController, :health) + end - if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] do - forward("/api", BlockScoutWeb.ApiRouter) + scope "/verify_smart_contract" do + pipe_through(:api) + + post("/contract_verifications", BlockScoutWeb.AddressContractVerificationController, :create) + end + + if Application.get_env(:block_scout_web, ApiRouter)[:enabled] do + forward("/api", ApiRouter) - # For backward compatibility. Should be removed # Needs to be 200 to support the schema introspection for graphiql @max_complexity 200 @@ -35,9 +50,28 @@ defmodule BlockScoutWeb.Router do analyze_complexity: true, max_complexity: @max_complexity ) + else + scope "/", BlockScoutWeb do + pipe_through(:browser) + get("/api_docs", PageNotFoundController, :index) + get("/eth_rpc_api_docs", PageNotFoundController, :index) + end end - if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter)[:enabled] do + scope "/", BlockScoutWeb do + pipe_through(:browser) + + get("/api_docs", APIDocsController, :index) + get("/eth_rpc_api_docs", APIDocsController, :eth_rpc) + end + + if Application.get_env(:block_scout_web, WebRouter)[:enabled] do forward("/", BlockScoutWeb.WebRouter) + else + scope "/", BlockScoutWeb do + pipe_through(:browser) + + forward("/", APIDocsController, :index) + end end end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex index a1a715a734..fd93b0af2b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex @@ -9,7 +9,7 @@

<%= gettext "New Smart Contract Verification" %>

<%= form_for @changeset, - api_v1_address_contract_verification_path(@conn, :create), + address_contract_verification_path(@conn, :create), [], fn f -> %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index f152ec6bf9..3ae4779284 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -8,79 +8,83 @@ - - - - + + <% end %> + <%= if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:enabled] do %> + + <% end %> -
- <%= form_for @conn, chain_path(@conn, :search), [class: "form-inline my-2 my-lg-0", method: :get, enforce_utf8: false], fn f -> %> -
- <%= awesomplete(f, :q, - [ - class: "form-control me auto", - placeholder: gettext("Search by address, token symbol name, transaction hash, or block number"), - "aria-describedby": "search-icon", - "aria-label": gettext("Search"), - "data-test": "search_input" - ], - [ url: "#{chain_path(@conn, :token_autocomplete)}?q=", - limit: 0, - minChars: 2, - value: "contract_address_hash", - label: "contract_address_hash", - descrSearch: true, - descr: "symbol" - ]) %> -
- -
-
- - <% end %> -
+ <%= if Application.get_env(:block_scout_web, BlockScoutWeb.WebRouter)[:enabled] do %> +
+ <%= form_for @conn, chain_path(@conn, :search), [class: "form-inline my-2 my-lg-0", method: :get, enforce_utf8: false], fn f -> %> +
+ <%= awesomplete(f, :q, + [ + class: "form-control me auto", + placeholder: gettext("Search by address, token symbol name, transaction hash, or block number"), + "aria-describedby": "search-icon", + "aria-label": gettext("Search"), + "data-test": "search_input" + ], + [ url: "#{chain_path(@conn, :token_autocomplete)}?q=", + limit: 0, + minChars: 2, + value: "contract_address_hash", + label: "contract_address_hash", + descrSearch: true, + descr: "symbol" + ]) %> +
+ +
+
+ + <% end %> +
+ <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex index b8e39ab547..874b470406 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/address_contract_verification_view.ex @@ -1,8 +1,3 @@ defmodule BlockScoutWeb.AddressContractVerificationView do use BlockScoutWeb, :view - alias BlockScoutWeb.ApiRouter.Helpers - - def api_v1_address_contract_verification_path(conn, action) do - "/api" <> Helpers.api_v1_address_contract_verification_path(conn, action) - end end diff --git a/apps/block_scout_web/lib/block_scout_web/web_router.ex b/apps/block_scout_web/lib/block_scout_web/web_router.ex index 9b250332db..6b445a7b41 100644 --- a/apps/block_scout_web/lib/block_scout_web/web_router.ex +++ b/apps/block_scout_web/lib/block_scout_web/web_router.ex @@ -199,9 +199,6 @@ defmodule BlockScoutWeb.WebRouter do get("/chain_blocks", ChainController, :chain_blocks, as: :chain_blocks) - get("/api_docs", APIDocsController, :index) - get("/eth_rpc_api_docs", APIDocsController, :eth_rpc) - get("/:page", PageNotFoundController, :index) end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs index 53abd8b880..41735f685a 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs @@ -1,8 +1,6 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do use BlockScoutWeb.ConnCase - alias BlockScoutWeb.ApiRouter.Helpers - describe "GET last_block_status/0" do test "returns error when there are no blocks in db", %{conn: conn} do request = get(conn, api_v1_health_path(conn, :health)) @@ -49,8 +47,4 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do } = Poison.decode!(request.resp_body) end end - - def api_v1_health_path(conn, action) do - "/api" <> Helpers.api_v1_health_path(conn, action) - end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs index 4db9eccd6d..3b2cb99ff0 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.APIDocsControllerTest do use BlockScoutWeb.ConnCase - import BlockScoutWeb.WebRouter.Helpers, only: [api_docs_path: 2] + import BlockScoutWeb.Router.Helpers, only: [api_docs_path: 2] describe "GET index/2" do test "renders documentation tiles for each API module#action", %{conn: conn} do From 3652aa2a46549a43ae2bab290506e467eefe349d Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 18 Jul 2019 17:03:57 +0300 Subject: [PATCH 007/290] Update gettext --- .../lib/block_scout_web/router.ex | 4 +-- apps/block_scout_web/priv/gettext/default.pot | 32 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 32 +++++++++---------- 3 files changed, 34 insertions(+), 34 deletions(-) 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 62c6e09d91..3cbb8dd3bf 100644 --- a/apps/block_scout_web/lib/block_scout_web/router.ex +++ b/apps/block_scout_web/lib/block_scout_web/router.ex @@ -19,9 +19,9 @@ defmodule BlockScoutWeb.Router do plug(:accepts, ["json"]) end - scope "/", BlockScoutWeb.API.V1, as: :api_v1 do + scope "/api/v1", BlockScoutWeb.API.V1, as: :api_v1 do pipe_through(:api) - get("/api/v1/health", HealthController, :health) + get("/health", HealthController, :health) end scope "/verify_smart_contract" do diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 8217a39d9c..021b81144e 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -87,7 +87,7 @@ msgid "API for the %{subnetwork} - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:56 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:57 msgid "Accounts" msgstr "" @@ -178,8 +178,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:87 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:16 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:20 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:17 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:21 msgid "Blocks" msgstr "" @@ -400,7 +400,7 @@ msgid "Fetching tokens..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:26 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:27 msgid "Forked Blocks (Reorgs)" msgstr "" @@ -602,7 +602,7 @@ msgid "Parent Hash" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:44 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:45 #: lib/block_scout_web/views/transaction_view.ex:143 #: lib/block_scout_web/views/transaction_view.ex:177 msgid "Pending" @@ -667,8 +667,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/index.html.eex:14 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:102 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:119 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:107 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:124 msgid "Search" msgstr "" @@ -871,7 +871,7 @@ msgstr "" #: lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/block_transaction/index.html.eex:18 #: lib/block_scout_web/templates/chain/show.html.eex:108 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:35 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:36 #: lib/block_scout_web/views/address_view.ex:305 msgid "Transactions" msgstr "" @@ -898,7 +898,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:80 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:23 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:24 msgid "Uncles" msgstr "" @@ -913,7 +913,7 @@ msgid "Used" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:39 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:40 msgid "Validated" msgstr "" @@ -1067,12 +1067,12 @@ msgid "Loading...." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:64 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:67 msgid "APIs" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:68 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:71 msgid "GraphQL" msgstr "" @@ -1082,7 +1082,7 @@ msgid "Loading" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:73 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:76 msgid "RPC" msgstr "" @@ -1481,8 +1481,8 @@ msgid "Error: Could not determine contract creator." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:96 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:100 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:101 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:105 msgid "Search by address, token symbol name, transaction hash, or block number" msgstr "" @@ -1708,7 +1708,7 @@ msgid "ETH RPC API Documentation" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:78 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:81 msgid "Eth RPC" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index b58c06af59..abd5fcd3a3 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -87,7 +87,7 @@ msgid "API for the %{subnetwork} - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:56 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:57 msgid "Accounts" msgstr "" @@ -178,8 +178,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:87 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:16 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:20 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:17 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:21 msgid "Blocks" msgstr "" @@ -400,7 +400,7 @@ msgid "Fetching tokens..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:26 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:27 msgid "Forked Blocks (Reorgs)" msgstr "" @@ -602,7 +602,7 @@ msgid "Parent Hash" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:44 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:45 #: lib/block_scout_web/views/transaction_view.ex:143 #: lib/block_scout_web/views/transaction_view.ex:177 msgid "Pending" @@ -667,8 +667,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/index.html.eex:14 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:102 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:119 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:107 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:124 msgid "Search" msgstr "" @@ -871,7 +871,7 @@ msgstr "" #: lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/block_transaction/index.html.eex:18 #: lib/block_scout_web/templates/chain/show.html.eex:108 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:35 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:36 #: lib/block_scout_web/views/address_view.ex:305 msgid "Transactions" msgstr "" @@ -898,7 +898,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:80 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:23 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:24 msgid "Uncles" msgstr "" @@ -913,7 +913,7 @@ msgid "Used" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:39 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:40 msgid "Validated" msgstr "" @@ -1067,12 +1067,12 @@ msgid "Loading...." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:64 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:67 msgid "APIs" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:68 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:71 msgid "GraphQL" msgstr "" @@ -1082,7 +1082,7 @@ msgid "Loading" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:73 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:76 msgid "RPC" msgstr "" @@ -1481,8 +1481,8 @@ msgid "Error: Could not determine contract creator." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:96 -#: lib/block_scout_web/templates/layout/_topnav.html.eex:100 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:101 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:105 msgid "Search by address, token symbol name, transaction hash, or block number" msgstr "" @@ -1708,7 +1708,7 @@ msgid "ETH RPC API Documentation" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/_topnav.html.eex:78 +#: lib/block_scout_web/templates/layout/_topnav.html.eex:81 msgid "Eth RPC" msgstr "" From 16a280f7c5af7731bb39a23150efa320b57c4fee Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 22 Jul 2019 10:36:14 +0300 Subject: [PATCH 008/290] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c8934f3d..aed0547a76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2376](https://github.com/poanetwork/blockscout/pull/2376) - Split API and WebApp routes - [#2379](https://github.com/poanetwork/blockscout/pull/2379) - Disable network selector when is empty - [#2360](https://github.com/poanetwork/blockscout/pull/2360) - add default evm version to smart contract verification - [#2352](https://github.com/poanetwork/blockscout/pull/2352) - Fetch rewards in parallel with transactions From c7e835178165fffadb3155c68139397940c9ce4c Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 22 Jul 2019 15:26:57 +0300 Subject: [PATCH 009/290] Return gasPrice at gettxinfo API's method --- apps/block_scout_web/lib/block_scout_web/etherscan.ex | 2 ++ .../lib/block_scout_web/views/api/rpc/transaction_view.ex | 1 + .../controllers/api/rpc/transaction_controller_test.exs | 1 + 3 files changed, 4 insertions(+) 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 2191a86fa2..73f1967900 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -440,6 +440,7 @@ defmodule BlockScoutWeb.Etherscan do "from" => "0x000000000000000000000000000000000000000c", "gasLimit" => "91966", "gasUsed" => "95123", + "gasPrice" => "100000", "hash" => "0x0000000000000000000000000000000000000000000000000000000000000004", "input" => "0x04", "logs" => [ @@ -986,6 +987,7 @@ defmodule BlockScoutWeb.Etherscan do input: @input_type, gasLimit: @wei_type, gasUsed: @gas_type, + gasPrice: @wei_type, logs: %{ type: "array", array_type: @logs_details diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/transaction_view.ex index e792be8f40..b9e8f7430d 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/transaction_view.ex @@ -68,6 +68,7 @@ defmodule BlockScoutWeb.API.RPC.TransactionView do "input" => "#{transaction.input}", "gasLimit" => "#{transaction.gas}", "gasUsed" => "#{transaction.gas_used}", + "gasPrice" => "#{transaction.gas_price.value}", "logs" => Enum.map(logs, &prepare_log/1), "next_page_params" => next_page_params } diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs index 9d151e382c..1ac026bc3c 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs @@ -456,6 +456,7 @@ defmodule BlockScoutWeb.API.RPC.TransactionControllerTest do "input" => "#{transaction.input}", "gasLimit" => "#{transaction.gas}", "gasUsed" => "#{transaction.gas_used}", + "gasPrice" => "#{transaction.gas_price.value}", "logs" => [ %{ "address" => "#{address.hash}", From 04c72f71d792c9f692461e0f79b6d232734a121f Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 22 Jul 2019 15:32:40 +0300 Subject: [PATCH 010/290] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c8934f3d..75a5e56e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2403](https://github.com/poanetwork/blockscout/pull/2403) - Return gasPrice field at the result of gettxinfo method - [#2379](https://github.com/poanetwork/blockscout/pull/2379) - Disable network selector when is empty - [#2360](https://github.com/poanetwork/blockscout/pull/2360) - add default evm version to smart contract verification - [#2352](https://github.com/poanetwork/blockscout/pull/2352) - Fetch rewards in parallel with transactions From 1e4de6e41e2936dd4629f70e72f5dde95972698c Mon Sep 17 00:00:00 2001 From: saneery Date: Tue, 23 Jul 2019 12:07:09 +0300 Subject: [PATCH 011/290] Add env to disable indexer supervisor --- apps/indexer/config/config.exs | 2 ++ apps/indexer/lib/indexer/application.ex | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index 4e84e9bcfe..b01a09c450 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -41,6 +41,8 @@ config :indexer, # config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: true config :indexer, Indexer.Fetcher.StakingPools.Supervisor, disabled?: true +config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true" + config :indexer, Indexer.Tracer, service: :indexer, adapter: SpandexDatadog.Adapter, diff --git a/apps/indexer/lib/indexer/application.ex b/apps/indexer/lib/indexer/application.ex index cb696567b7..f261ba8057 100644 --- a/apps/indexer/lib/indexer/application.ex +++ b/apps/indexer/lib/indexer/application.ex @@ -17,11 +17,17 @@ defmodule Indexer.Application do memory_monitor_name = Memory.Monitor - children = [ - {Memory.Monitor, [memory_monitor_options, [name: memory_monitor_name]]}, - {Indexer.Supervisor, [%{memory_monitor: memory_monitor_name}]} + base_children = [ + {Memory.Monitor, [memory_monitor_options, [name: memory_monitor_name]]} ] + children = + if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do + Enum.reverse([{Indexer.Supervisor, [%{memory_monitor: memory_monitor_name}]} | base_children]) + else + base_children + end + opts = [ # If the `Memory.Monitor` dies, it needs all the `Shrinkable`s to re-register, so restart them. strategy: :rest_for_one, From c9250b6991b978a2d2d5814ec4fbb5e136f24f66 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 25 Jul 2019 13:31:13 +0300 Subject: [PATCH 012/290] Add functionality to try eth_rpc methods in documentation --- apps/block_scout_web/assets/js/app.js | 1 + .../assets/js/lib/try_eth_api.js | 70 ++++++++ .../templates/api_docs/_eth_rpc_item.html.eex | 166 ++++++++++++++++++ .../templates/api_docs/eth_rpc.html.eex | 18 +- apps/explorer/lib/explorer/eth_rpc.ex | 28 ++- 5 files changed, 268 insertions(+), 15 deletions(-) create mode 100644 apps/block_scout_web/assets/js/lib/try_eth_api.js create mode 100644 apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex diff --git a/apps/block_scout_web/assets/js/app.js b/apps/block_scout_web/assets/js/app.js index 25de7b2688..a800597331 100644 --- a/apps/block_scout_web/assets/js/app.js +++ b/apps/block_scout_web/assets/js/app.js @@ -58,5 +58,6 @@ import './lib/async_listing_load' import './lib/tooltip' import './lib/modals' import './lib/try_api' +import './lib/try_eth_api' import './lib/card_tabs' import './lib/network_selector' diff --git a/apps/block_scout_web/assets/js/lib/try_eth_api.js b/apps/block_scout_web/assets/js/lib/try_eth_api.js new file mode 100644 index 0000000000..a3dd7b6f4e --- /dev/null +++ b/apps/block_scout_web/assets/js/lib/try_eth_api.js @@ -0,0 +1,70 @@ +import $ from 'jquery' + +function composeCurlCommand (data) { + return `curl -H "content-type: application/json" -X POST --data '${JSON.stringify(data)}'` +} + +function handleResponse (data, xhr, clickedButton) { + const module = clickedButton.attr('data-module') + const action = clickedButton.attr('data-action') + const curl = $(`[data-selector="${module}-${action}-curl"]`)[0] + const code = $(`[data-selector="${module}-${action}-server-response-code"]`)[0] + const body = $(`[data-selector="${module}-${action}-server-response-body"]`)[0] + + curl.innerHTML = composeCurlCommand(data) + code.innerHTML = xhr.status + body.innerHTML = JSON.stringify(xhr.responseJSON, undefined, 2) + $(`[data-selector="${module}-${action}-try-api-ui-result"]`).show() + $(`[data-selector="${module}-${action}-btn-try-api-clear"]`).show() + clickedButton.html(clickedButton.data('original-text')) + clickedButton.prop('disabled', false) +} + +function wrapJsonRpc (method, params) { + return { + id: 0, + jsonrpc: '2.0', + method: method, + params: params + } +} + +function parseInput (input) { + const type = $(input).attr('data-parameter-type') + const value = $(input).val() + + switch (type) { + case 'string': + return value + case 'json': + return JSON.parse(value) + default: + return value + } +} + +$('button[data-try-eth-api-ui-button-type="execute"]').click(event => { + const clickedButton = $(event.target) + const module = clickedButton.attr('data-module') + const action = clickedButton.attr('data-action') + const inputs = $(`input[data-selector="${module}-${action}-try-api-ui"]`) + const params = $.map(inputs, parseInput) + const formData = wrapJsonRpc(action, params) + console.log(formData) + const loadingText = ' Loading...' + + clickedButton.prop('disabled', true) + clickedButton.data('original-text', clickedButton.html()) + + if (clickedButton.html() !== loadingText) { + clickedButton.html(loadingText) + } + + $.ajax({ + url: '/api/eth_rpc', + type: 'POST', + data: JSON.stringify(formData), + dataType: 'json', + contentType: 'application/json; charset=utf-8' + }).then((_data, _status, xhr) => handleResponse(formData, xhr, clickedButton)) +}) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex new file mode 100644 index 0000000000..14e69b95f5 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex @@ -0,0 +1,166 @@ +
\ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/eth_rpc.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/eth_rpc.html.eex index 134b3e13e1..2c2c453841 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/eth_rpc.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/eth_rpc.html.eex @@ -18,19 +18,9 @@
- - - - - - - <%= for {method, info} <- Map.to_list(@documentation) do %> - - - - - - <% end %> -
Supported MethodNotesParameters example
<%= method %> <%= Map.get(info, :notes, "N/A") %> <%= Map.get(info, :example, "N/A") %>
+ <%= for {method, info} <- Map.to_list(@documentation) do %> + <%= render "_eth_rpc_item.html", action: method, info: info %> + <% end %> +
diff --git a/apps/explorer/lib/explorer/eth_rpc.ex b/apps/explorer/lib/explorer/eth_rpc.ex index e0864ac279..3901248938 100644 --- a/apps/explorer/lib/explorer/eth_rpc.ex +++ b/apps/explorer/lib/explorer/eth_rpc.ex @@ -16,7 +16,14 @@ defmodule Explorer.EthRPC do are not currently imported """, example: """ - {"id": 0, "jsonrpc": "2.0", "method": "eth_getBalance", "params": ["0x0000000000000000000000000000000000000007", "2"]} + {"id": 0, "jsonrpc": "2.0", "method": "eth_getBalance", "params": ["0x0000000000000000000000000000000000000007", "latest"]} + """, + params: [ + {"DATA", "20 Bytes - address to check for balance", "string"}, + {"QUANTITY|TAG", "integer block number, or the string \"latest\", \"earliest\" or \"pending\"", "string"} + ], + result: """ + {"id": 0, "jsonrpc": "2.0", "result": "0x0234c8a3397aab58"} """ }, "eth_getLogs" => %{ @@ -33,6 +40,25 @@ defmodule Explorer.EthRPC do "fromBlock": "earliest", "toBlock": "latest", "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]} + """, + params: [ + {"Object", "The filter options", "json"} + ], + result: """ + { + "id":0, + "jsonrpc":"2.0", + "result": [{ + "logIndex": "0x1", + "blockNumber":"0x1b4", + "blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d", + "transactionHash": "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf", + "transactionIndex": "0x0", + "address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d", + "data":"0x0000000000000000000000000000000000000000000000000000000000000000", + "topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"] + }] + } """ } } From 33a769e8904279f3560618c1eb4fbd88baa1bbd7 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 25 Jul 2019 13:39:41 +0300 Subject: [PATCH 013/290] Update gettext --- apps/block_scout_web/priv/gettext/default.pot | 17 +++++++++++++++++ .../priv/gettext/en/LC_MESSAGES/default.po | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index bf490e4091..a96252e762 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -199,11 +199,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:253 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:45 msgid "Cancel" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:137 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:90 msgid "Clear" msgstr "" @@ -220,6 +222,8 @@ msgstr "" #: lib/block_scout_web/templates/address/_tabs.html.eex:42 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:111 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:133 #: lib/block_scout_web/views/address_view.ex:307 msgid "Code" msgstr "" @@ -325,6 +329,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:146 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:101 msgid "Curl" msgstr "" @@ -339,12 +344,15 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:53 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:188 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:51 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:134 msgid "Description" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:8 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:166 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:112 msgid "Details" msgstr "" @@ -386,11 +394,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:211 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:148 msgid "Example Value" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:128 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:81 msgid "Execute" msgstr "" @@ -556,6 +566,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:50 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:45 msgid "Name" @@ -590,11 +601,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:19 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:17 msgid "POST" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:33 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:31 msgid "Parameters" msgstr "" @@ -659,11 +672,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:173 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:119 msgid "Response Body" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:185 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:131 msgid "Responses" msgstr "" @@ -682,6 +697,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:163 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:109 msgid "Server Response" msgstr "" @@ -890,6 +906,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:40 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:38 msgid "Try it out" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 107563ea66..367d2a3973 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -199,11 +199,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:253 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:47 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:45 msgid "Cancel" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:137 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:90 msgid "Clear" msgstr "" @@ -220,6 +222,8 @@ msgstr "" #: lib/block_scout_web/templates/address/_tabs.html.eex:42 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:165 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:187 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:111 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:133 #: lib/block_scout_web/views/address_view.ex:307 msgid "Code" msgstr "" @@ -325,6 +329,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:146 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:101 msgid "Curl" msgstr "" @@ -339,12 +344,15 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:53 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:188 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:51 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:134 msgid "Description" msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/overview.html.eex:8 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:166 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:112 msgid "Details" msgstr "" @@ -386,11 +394,13 @@ msgstr "POA" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:211 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:148 msgid "Example Value" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:128 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:81 msgid "Execute" msgstr "" @@ -556,6 +566,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:50 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:45 msgid "Name" @@ -590,11 +601,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:19 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:17 msgid "POST" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:33 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:31 msgid "Parameters" msgstr "" @@ -659,11 +672,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:173 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:119 msgid "Response Body" msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:185 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:131 msgid "Responses" msgstr "" @@ -682,6 +697,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:163 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:109 msgid "Server Response" msgstr "" @@ -890,6 +906,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:40 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:38 msgid "Try it out" msgstr "" From 63531a4d723e932ddfb63c571d33f91c6480be58 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 25 Jul 2019 13:41:31 +0300 Subject: [PATCH 014/290] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b621bd681..5dd084b3f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2433](https://github.com/poanetwork/blockscout/pull/2433) - Add a functionality to try Eth RPC methods in the documentation - [#2391](https://github.com/poanetwork/blockscout/pull/2391) - Controllers Improvements - [#2379](https://github.com/poanetwork/blockscout/pull/2379) - Disable network selector when is empty - [#2374](https://github.com/poanetwork/blockscout/pull/2374) - decode constructor arguments for verified smart contracts From 8584a7fc28e84e19d18de9b11933c14d1532697f Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 29 Jul 2019 10:49:10 +0300 Subject: [PATCH 015/290] Disable market history cataloger with indexer --- apps/explorer/config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index fed5124a2a..f20d704135 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -51,7 +51,7 @@ config :explorer, Explorer.KnownTokens, enabled: true, store: :ets config :explorer, Explorer.Integrations.EctoLogger, query_time_ms_threshold: :timer.seconds(2) -config :explorer, Explorer.Market.History.Cataloger, enabled: true +config :explorer, Explorer.Market.History.Cataloger, enabled: System.get_env("DISABLE_INDEXER") != "true" config :explorer, Explorer.Repo, migration_timestamps: [type: :utc_datetime_usec] From c09766e7922be147022c4770bb0c50dd31f6b680 Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 29 Jul 2019 11:09:23 +0300 Subject: [PATCH 016/290] Disable MetadataProcessor with indexer --- apps/explorer/config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index f20d704135..1ceed7c387 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -65,7 +65,7 @@ if System.get_env("METADATA_CONTRACT") && System.get_env("VALIDATORS_CONTRACT") metadata_contract_address: System.get_env("METADATA_CONTRACT"), validators_contract_address: System.get_env("VALIDATORS_CONTRACT") - config :explorer, Explorer.Validator.MetadataProcessor, enabled: true + config :explorer, Explorer.Validator.MetadataProcessor, enabled: System.get_env("DISABLE_INDEXER") != "true" else config :explorer, Explorer.Validator.MetadataProcessor, enabled: false end From 60be9a8a5fc3acf82bc03d914747bd14ea989cbe Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 29 Jul 2019 11:48:12 +0300 Subject: [PATCH 017/290] Add WEBAPP_URL var --- apps/block_scout_web/config/config.exs | 3 ++- .../templates/layout/_footer.html.eex | 2 +- .../templates/layout/_topnav.html.eex | 2 +- .../lib/block_scout_web/views/layout_view.ex | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 84f60a2842..ff842fd294 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -28,7 +28,8 @@ config :block_scout_web, "EtherChain" => "https://www.etherchain.org/", "Bloxy" => "https://bloxy.info/" }, - other_networks: System.get_env("SUPPORTED_CHAINS") + other_networks: System.get_env("SUPPORTED_CHAINS"), + webapp_url: System.get_env("WEBAPP_URL") config :block_scout_web, BlockScoutWeb.Counters.BlocksIndexedCounter, enabled: true diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex index 9d84836a5a..999a39ed11 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex @@ -3,7 +3,7 @@ + <% {:error, :contract_not_verified, results} -> %> + <%= for {:ok, method_id, text, mapping} <- results do %> +
<%= gettext "Decoded" %>
+
+ + + + + + + + + +
Method Id0x<%= method_id %>
Call<%= text %>
+
+ " class="table thead-light table-bordered"> + + + + + + + + <%= for {name, type, indexed?, value} <- mapping do %> + + + + + + + + <% end %> +
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Indexed?" %><%= gettext "Data" %>
+ <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + + + + + <% end %> + <%= name %><%= type %><%= indexed? %> +
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+
+
+ <% end %> <% _ -> %> <%= nil %> <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex index b0afe771c1..a0922454a9 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex @@ -27,19 +27,7 @@ ) %>
- <%= case decode(@log, @transaction) do %> - <% {:error, :contract_not_verified} -> %> -
<%= gettext "Decoded" %>
-
-
- <%= gettext "To see decoded input data, the contract must be verified." %> - <%= case @transaction do %> - <% %{to_address: %{hash: hash}} -> %> - <%= gettext "Verify the contract " %><%= gettext "here" %> - <% _ -> %> - <%= nil %> - <% end %> -
+ <%= case decoded_result do %> <% {:error, :could_not_decode} -> %>
<%= gettext "Decoded" %>
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index d9998f00fe..520dc1d1ed 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -558,12 +558,13 @@ msgid "Must be set to:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:106 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:68 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:109 msgid "Name" msgstr "" @@ -852,7 +853,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:18 #: lib/block_scout_web/views/transaction_view.ex:262 msgid "Transaction" msgstr "" @@ -1129,13 +1130,12 @@ msgid "Static Call" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:16 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:28 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:37 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:90 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:44 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:40 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:93 msgid "Decoded" msgstr "" @@ -1144,12 +1144,6 @@ msgstr "" msgid "Method Id" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 -msgid "To see decoded input data, the contract must be verified." -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 @@ -1157,18 +1151,16 @@ msgid "Transaction Inputs" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:10 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "Verify the contract " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:10 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "here" msgstr "" @@ -1322,6 +1314,7 @@ msgid "To have guaranteed accuracy, use the link above to verify the contract's msgstr "" #, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:7 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6 msgid "To see accurate decoded input data, the contract must be verified." @@ -1782,10 +1775,11 @@ msgid "Constructor Arguments" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:63 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:66 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:119 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:81 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:134 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 msgid "Copy Value" msgstr "" @@ -1795,32 +1789,35 @@ msgid "Create2" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:118 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:56 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:109 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:175 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:71 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:124 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:191 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:112 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:179 msgid "Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:70 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:123 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:55 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:108 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:111 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:103 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106 msgid "Log Data" msgstr "" @@ -1832,15 +1829,16 @@ msgid "Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:88 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:161 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:149 msgid "Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:51 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:54 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:107 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:110 msgid "Type" msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 585b389bc0..1626e8b6a7 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -558,12 +558,13 @@ msgid "Must be set to:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:106 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:59 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:68 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:121 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:56 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:109 msgid "Name" msgstr "" @@ -852,7 +853,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:3 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:18 #: lib/block_scout_web/views/transaction_view.ex:262 msgid "Transaction" msgstr "" @@ -1129,13 +1130,12 @@ msgid "Static Call" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:16 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:28 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:37 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:90 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:32 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:44 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:105 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:40 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:93 msgid "Decoded" msgstr "" @@ -1144,12 +1144,6 @@ msgstr "" msgid "Method Id" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 -msgid "To see decoded input data, the contract must be verified." -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 @@ -1157,18 +1151,16 @@ msgid "Transaction Inputs" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:10 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "Verify the contract " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:22 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:10 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:9 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:38 msgid "here" msgstr "" @@ -1323,6 +1315,7 @@ msgid "To have guaranteed accuracy, use the link above to verify the contract's msgstr "" #, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:7 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:8 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:6 msgid "To see accurate decoded input data, the contract must be verified." @@ -1783,10 +1776,11 @@ msgid "Constructor Arguments" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:63 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:66 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:119 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:81 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:134 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 msgid "Copy Value" msgstr "" @@ -1796,32 +1790,35 @@ msgid "Create2" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:53 -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:118 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:56 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:109 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:175 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:71 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:124 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:191 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:112 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:179 msgid "Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:31 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:34 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:35 msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:52 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:70 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:123 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:55 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:108 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:111 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:65 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:118 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:50 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:103 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:53 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:106 msgid "Log Data" msgstr "" @@ -1833,15 +1830,16 @@ msgid "Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:88 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:161 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:145 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:149 msgid "Topics" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:51 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:54 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:107 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:69 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:122 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:57 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:110 msgid "Type" msgstr "" From 1aa9c39305862ce58a5c5da7112094fe0705b6fb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 16 Aug 2019 11:48:05 +0300 Subject: [PATCH 195/290] fix tests --- apps/explorer/test/explorer/chain/log_test.exs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/apps/explorer/test/explorer/chain/log_test.exs b/apps/explorer/test/explorer/chain/log_test.exs index f27cdc4e04..e4ce0695bc 100644 --- a/apps/explorer/test/explorer/chain/log_test.exs +++ b/apps/explorer/test/explorer/chain/log_test.exs @@ -48,7 +48,7 @@ defmodule Explorer.Chain.LogTest do log = insert(:log, transaction: transaction) - assert Log.decode(log, transaction) == {:error, :contract_not_verified} + assert Log.decode(log, transaction) == {:error, :could_not_decode} end test "that a contract call transaction that has a verified contract returns the decoded input data" do @@ -144,16 +144,7 @@ defmodule Explorer.Chain.LogTest do assert Log.decode(log, transaction) == {:error, :contract_not_verified, [ - {:ok, - %ABI.FunctionSelector{ - function: "WantsPets", - input_names: ["_from_human", "_number", "_belly"], - inputs_indexed: [true, false, true], - method_id: <<235, 155, 60, 76>>, - returns: [], - type: :event, - types: [:string, {:uint, 256}, :bool] - }, + {:ok, "eb9b3c4c", "WantsPets(string indexed _from_human, uint256 _number, bool indexed _belly)", [ {"_from_human", "string", true, {:dynamic, From 5c333fa6549cf6a4e946ea9985e86dc90d02fb0d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 16 Aug 2019 11:48:57 +0300 Subject: [PATCH 196/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f006769dbf..9e256eb6f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2555](https://github.com/poanetwork/blockscout/pull/2555) - find and show decoding candidates for logs - [#2561](https://github.com/poanetwork/blockscout/pull/2561) - Add token's type to the response of tokenlist method - [#2499](https://github.com/poanetwork/blockscout/pull/2499) - import emission reward ranges - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation From d36ecd667dd562ebb866704ffcadca5d32c600a2 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Sat, 17 Aug 2019 09:43:57 +0300 Subject: [PATCH 197/290] hotfix: missing vars for non-critical styles --- .../assets/css/theme/_dai_variables-non-critical.scss | 1 + .../css/theme/_ethereum_classic_variables-non-critical.scss | 1 + .../assets/css/theme/_ethereum_variables-non-critical.scss | 1 + .../assets/css/theme/_goerli_variables-non-critical.scss | 1 + .../assets/css/theme/_kovan_variables-non-critical.scss | 1 + .../assets/css/theme/_lukso_variables-non-critical.scss | 1 + .../assets/css/theme/_neutral_variables-non-critical.scss | 1 + .../assets/css/theme/_poa_variables-non-critical.scss | 1 + .../assets/css/theme/_rinkeby_variables-non-critical.scss | 1 + .../assets/css/theme/_ropsten_variables-non-critical.scss | 1 + .../assets/css/theme/_rsk_variables-non-critical.scss | 1 + .../assets/css/theme/_sokol_variables-non-critical.scss | 1 + 12 files changed, 12 insertions(+) diff --git a/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss index 69231f5098..aae48f978a 100644 --- a/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss @@ -1 +1,2 @@ +$secondary: #15bba6; $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss index 3d488a6f1e..91c691af40 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss @@ -1 +1,2 @@ +$tertiary: #5959d8; $btn-line-color: $tertiary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss index 69231f5098..d8f0d6ecd0 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss @@ -1 +1,2 @@ +$secondary: #49a2ee; $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss index 6c80828f14..59fe6f3977 100644 --- a/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss @@ -1 +1,2 @@ +$sub-accent-color: #a46f30; $btn-line-color: $sub-accent-color; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss index db0e486e0c..c96d76af00 100644 --- a/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss @@ -1 +1,2 @@ +$tertiary: #1f857f; $btn-line-color: $tertiary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss index 4d0836af14..40182f2a26 100644 --- a/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss @@ -1 +1,2 @@ +$primary: #1d3154; $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss index 4d0836af14..b05591c10e 100644 --- a/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss @@ -1 +1,2 @@ +$primary: #5c34a2; $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss index 4d0836af14..b05591c10e 100644 --- a/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss @@ -1 +1,2 @@ +$primary: #5c34a2; $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss index 69231f5098..e2644143ea 100644 --- a/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss @@ -1 +1,2 @@ +$secondary: #38a9f5; $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss index 69231f5098..e2644143ea 100644 --- a/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss @@ -1 +1,2 @@ +$secondary: #38a9f5; $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss index 69231f5098..24c90dc7fa 100644 --- a/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss @@ -1 +1,2 @@ +$secondary: #27ac8d; $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss index 6c80828f14..7e8ad54355 100644 --- a/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss @@ -1 +1,2 @@ +$sub-accent-color: #1c9f90; $btn-line-color: $sub-accent-color; // button border and font color && hover bg color \ No newline at end of file From e707c2ae8f5cd535f2ef15fcc72194ea1d3380be Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Sat, 17 Aug 2019 11:11:44 +0300 Subject: [PATCH 198/290] Hotfix all general variables for non-critical css --- .../assets/css/theme/_dai_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_ether1_variables-non-critical.scss | 6 ++++++ .../css/theme/_ethereum_classic_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_ethereum_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_goerli_variables-non-critical.scss | 6 ++++++ .../assets/css/theme/_kovan_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_lukso_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_neutral_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_poa_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_rinkeby_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_ropsten_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_rsk_variables-non-critical.scss | 5 +++++ .../assets/css/theme/_sokol_variables-non-critical.scss | 6 ++++++ 13 files changed, 68 insertions(+) diff --git a/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss index aae48f978a..d9f670f980 100644 --- a/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_dai_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #17314f; $secondary: #15bba6; +$tertiary: #93d7ff; +$additional-font: #fff; + $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ether1_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ether1_variables-non-critical.scss index c7689bfb97..f7bf90f4fd 100644 --- a/apps/block_scout_web/assets/css/theme/_ether1_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ether1_variables-non-critical.scss @@ -1 +1,7 @@ +// general +$primary: #840032; +$secondary: #343434; +$tertiary: #7f7f7f; +$additional-font: #ff95db; + $btn-line-color: #4b021e; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss index 91c691af40..bc716596bf 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #1c1c3d; +$secondary: #4ad7a7; $tertiary: #5959d8; +$additional-font: #bdbdff; + $btn-line-color: $tertiary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss index d8f0d6ecd0..160c0cb684 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #153550; $secondary: #49a2ee; +$tertiary: #4ad7a7; +$additional-font: #89cae6; + $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss index 59fe6f3977..70cfaddd73 100644 --- a/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_goerli_variables-non-critical.scss @@ -1,2 +1,8 @@ +// general +$primary: #2b2b2b; +$secondary: #eac247; +$tertiary: #929292; +$additional-font: #ffffff; $sub-accent-color: #a46f30; + $btn-line-color: $sub-accent-color; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss index c96d76af00..ab4568e14f 100644 --- a/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_kovan_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #101f25; +$secondary: #35e3d8; $tertiary: #1f857f; +$additional-font: #99fff9; + $btn-line-color: $tertiary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss index 40182f2a26..8a8d7e5eaf 100644 --- a/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_lukso_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general $primary: #1d3154; +$secondary: #fdcec4; +$tertiary: #a96c55; +$additional-font: #a1ded1; + $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss index b05591c10e..3d85713af9 100644 --- a/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_neutral_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general $primary: #5c34a2; +$secondary: #87e1a9; +$tertiary: #bf9cff; +$additional-font: #fff; + $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss index b05591c10e..3d85713af9 100644 --- a/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_poa_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general $primary: #5c34a2; +$secondary: #87e1a9; +$tertiary: #bf9cff; +$additional-font: #fff; + $btn-line-color: $primary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss index e2644143ea..823da9f2d6 100644 --- a/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_rinkeby_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #153550; $secondary: #38a9f5; +$tertiary: #76f1ff; +$additional-font: #89cae6; + $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss index e2644143ea..823da9f2d6 100644 --- a/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_ropsten_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #153550; $secondary: #38a9f5; +$tertiary: #76f1ff; +$additional-font: #89cae6; + $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss index 24c90dc7fa..c874423aa6 100644 --- a/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_rsk_variables-non-critical.scss @@ -1,2 +1,7 @@ +// general +$primary: #101f25; $secondary: #27ac8d; +$tertiary: #e39a54; +$additional-font: #a1ded1; + $btn-line-color: $secondary; // button border and font color && hover bg color \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss index 7e8ad54355..64fd3c9f9c 100644 --- a/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_sokol_variables-non-critical.scss @@ -1,2 +1,8 @@ +// general +$primary: #093731; +$secondary: #40bfb2; +$tertiary: #25c9ff; +$additional-font: #93e8dd; $sub-accent-color: #1c9f90; + $btn-line-color: $sub-accent-color; // button border and font color && hover bg color \ No newline at end of file From 0df066bb3215340d6d345d6597de7b759ddd5ec3 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Sat, 17 Aug 2019 11:42:58 +0300 Subject: [PATCH 199/290] Hotfix: ethereum-mainnet network icon preload --- apps/block_scout_web/assets/css/_images-preload.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/block_scout_web/assets/css/_images-preload.scss b/apps/block_scout_web/assets/css/_images-preload.scss index ee25dbd966..8356a8f90e 100644 --- a/apps/block_scout_web/assets/css/_images-preload.scss +++ b/apps/block_scout_web/assets/css/_images-preload.scss @@ -2,6 +2,7 @@ body:after { position:absolute; width:0; height:0; overflow:hidden; z-index:-1; content: url(/images/network-selector-icons/callisto-mainnet.png) + url(/images/network-selector-icons/ethereum-mainnet.png) url(/images/network-selector-icons/ethereum-classic.png) url(/images/network-selector-icons/goerli-testnet.png) url(/images/network-selector-icons/kovan-testnet.png) From 0879b060ffe820060449037f5dffe95d83a9a10d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Sat, 17 Aug 2019 12:04:23 +0300 Subject: [PATCH 200/290] hotfix: missing ethereum-mainnet.png for networks selector --- .../assets/css/components/_network-selector.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/block_scout_web/assets/css/components/_network-selector.scss b/apps/block_scout_web/assets/css/components/_network-selector.scss index 65e5437641..7f2a4c020d 100644 --- a/apps/block_scout_web/assets/css/components/_network-selector.scss +++ b/apps/block_scout_web/assets/css/components/_network-selector.scss @@ -247,6 +247,9 @@ $network-selector-item-icon-dimensions: 30px !default; &-callisto-mainnet { background-image: url(/images/network-selector-icons/callisto-mainnet.png) } + &-ethereum-mainnet { + background-image: url(/images/network-selector-icons/ethereum-mainnet.png) + } &-ethereum-classic { background-image: url(/images/network-selector-icons/ethereum-classic.png) } From 6c7bf6b75897ab7812341156fe283ae29d8a4ec3 Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 11:00:44 +0300 Subject: [PATCH 201/290] Add json schema tests to block controller --- .../api/rpc/block_controller_test.exs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs index bda89fe49a..50ab2f18f3 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs @@ -14,6 +14,8 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + schema = resolve_schema() + assert :ok = ExJsonSchema.Validator.validate(schema, response) end test "with an invalid block number", %{conn: conn} do @@ -26,6 +28,8 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + schema = resolve_schema() + assert :ok = ExJsonSchema.Validator.validate(schema, response) end test "with a block that doesn't exist", %{conn: conn} do @@ -38,6 +42,8 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + schema = resolve_schema() + assert :ok = ExJsonSchema.Validator.validate(schema, response) end test "with a valid block", %{conn: conn} do @@ -71,6 +77,29 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + schema = resolve_schema() + assert :ok = ExJsonSchema.Validator.validate(schema, response) end end + + defp resolve_schema() do + ExJsonSchema.Schema.resolve(%{ + "type" => "object", + "properties" => %{ + "message" => %{"type" => "string"}, + "status" => %{"type" => "string"}, + "result" => %{ + "type" => ["object", "null"], + "properties" => %{ + "blockNumber" => %{"type" => "string"}, + "timeStamp" => %{"type" => "number"}, + "blockMiner" => %{"type" => "string"}, + "blockReward" => %{"type" => "string"}, + "uncles" => %{"type" => "null"}, + "uncleInclusionReward" => %{"type" => "null"} + } + } + } + }) + end end From 7c0faaee7fb0edb96bc0e29dcc9b17fcbb6041df Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 12:18:12 +0300 Subject: [PATCH 202/290] Add json schema tests to contract controller --- .../api/rpc/contract_controller_test.exs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs index e070cf8e57..22b711d9d3 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs @@ -17,6 +17,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "invalid is not a valid value for `filter`. Please use one of: verified, decompiled, unverified, not_decompiled, 1, 2, 3, 4." assert response["status"] == "0" + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "with no contracts", %{conn: conn, params: params} do @@ -28,6 +29,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["message"] == "OK" assert response["status"] == "1" assert response["result"] == [] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "with a verified smart contract, all contract information is shown", %{conn: conn, params: params} do @@ -50,6 +52,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => if(contract.optimization, do: "1", else: "0") } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "with an unverified contract address, only basic information is shown", %{conn: conn, params: params} do @@ -72,6 +75,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only unverified contracts shows only unverified contracts", %{params: params, conn: conn} do @@ -95,6 +99,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only unverified contracts does not show self destructed contracts", %{ @@ -122,6 +127,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only verified contracts shows only verified contracts", %{params: params, conn: conn} do @@ -145,6 +151,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => if(contract.optimization, do: "1", else: "0") } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only decompiled contracts shows only decompiled contracts", %{params: params, conn: conn} do @@ -168,6 +175,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only decompiled contracts, with a decompiled with version filter", %{params: params, conn: conn} do @@ -191,6 +199,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only decompiled contracts, with a decompiled with version filter, where another decompiled version exists", @@ -216,6 +225,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do } in response["result"] refute to_string(non_match.address_hash) in Enum.map(response["result"], &Map.get(&1, "Address")) + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only not_decompiled (and by extension not verified contracts)", %{params: params, conn: conn} do @@ -240,6 +250,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end test "filtering for only not_decompiled (and by extension not verified contracts) does not show empty contracts", %{ @@ -268,6 +279,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end end @@ -287,6 +299,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getabi_schema(), response) end test "with an invalid address hash", %{conn: conn} do @@ -305,6 +318,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getabi_schema(), response) end test "with an address that doesn't exist", %{conn: conn} do @@ -322,6 +336,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["result"] == nil assert response["status"] == "0" assert response["message"] == "Contract source code not verified" + assert :ok = ExJsonSchema.Validator.validate(getabi_schema(), response) end test "with a verified contract address", %{conn: conn} do @@ -341,6 +356,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["result"] == Jason.encode!(contract.abi) assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getabi_schema(), response) end end @@ -360,6 +376,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getsourcecode_schema(), response) end test "with an invalid address hash", %{conn: conn} do @@ -378,6 +395,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getsourcecode_schema(), response) end test "with an address that doesn't exist", %{conn: conn} do @@ -408,6 +426,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getsourcecode_schema(), response) end test "with a verified contract address", %{conn: conn} do @@ -443,6 +462,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getsourcecode_schema(), response) end end @@ -481,6 +501,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert response["status"] == "1" assert response["result"] == expected_result assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(verify_schema(), response) end test "with external libraries", %{conn: conn} do @@ -539,6 +560,76 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do assert result["DecompiledSourceCode"] == "Contract source code not decompiled." assert result["DecompilerVersion"] == "" assert result["OptimizationUsed"] == "1" + assert :ok = ExJsonSchema.Validator.validate(verify_schema(), response) end end + + defp listcontracts_schema do + resolve_schema(%{ + "type" => ["array", "null"], + "items" => %{ + "type" => "object", + "properties" => %{ + "Address" => %{"type" => "string"}, + "ABI" => %{"type" => "string"}, + "ContractName" => %{"type" => "string"}, + "CompilerVersion" => %{"type" => "string"}, + "OptimizationUsed" => %{"type" => "string"} + } + } + }) + end + + defp getabi_schema do + resolve_schema(%{ + "type" => ["string", "null"] + }) + end + + defp getsourcecode_schema do + resolve_schema(%{ + "type" => ["array", "null"], + "items" => %{ + "type" => "object", + "properties" => %{ + "Address" => %{"type" => "string"}, + "SourceCode" => %{"type" => "string"}, + "ABI" => %{"type" => "string"}, + "ContractName" => %{"type" => "string"}, + "CompilerVersion" => %{"type" => "string"}, + "OptimizationUsed" => %{"type" => "string"}, + "DecompiledSourceCode" => %{"type" => "string"}, + "DecompilerVersion" => %{"type" => "string"} + } + } + }) + end + + defp verify_schema do + resolve_schema(%{ + "type" => "object", + "properties" => %{ + "Address" => %{"type" => "string"}, + "SourceCode" => %{"type" => "string"}, + "ABI" => %{"type" => "string"}, + "ContractName" => %{"type" => "string"}, + "CompilerVersion" => %{"type" => "string"}, + "DecompiledSourceCode" => %{"type" => "string"}, + "DecompilerVersion" => %{"type" => "string"}, + "OptimizationUsed" => %{"type" => "string"} + } + }) + end + + defp resolve_schema(result \\ %{}) do + %{ + "type" => "object", + "properties" => %{ + "message" => %{"type" => "string"}, + "status" => %{"type" => "string"} + } + } + |> put_in(["properties", "result"], result) + |> ExJsonSchema.Schema.resolve() + end end From abb7f2693f60ea12dae24150acd952e0ac4b27a7 Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 12:18:29 +0300 Subject: [PATCH 203/290] add json schema tests to logs controller --- .../api/rpc/logs_controller_test.exs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/logs_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/logs_controller_test.exs index 454db88e86..0b129939b8 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/logs_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/logs_controller_test.exs @@ -22,6 +22,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "without fromBlock", %{conn: conn} do @@ -43,6 +44,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "without toBlock", %{conn: conn} do @@ -64,6 +66,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "without address and topic{x}", %{conn: conn} do @@ -85,6 +88,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "without topic{x}_{x}_opr", %{conn: conn} do @@ -118,6 +122,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end end @@ -146,6 +151,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with invalid fromBlock", %{conn: conn} do @@ -166,6 +172,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with invalid toBlock", %{conn: conn} do @@ -186,6 +193,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with an invalid address hash", %{conn: conn} do @@ -206,6 +214,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with invalid topic{x}_{x}_opr", %{conn: conn} do @@ -238,6 +247,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end end @@ -258,6 +268,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["result"] == [] assert response["status"] == "0" assert response["message"] == "No logs found" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with a valid contract address", %{conn: conn} do @@ -302,6 +313,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "ignores logs with block below fromBlock", %{conn: conn} do @@ -340,6 +352,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) [found_log] = response["result"] @@ -383,6 +396,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) [found_log] = response["result"] @@ -445,6 +459,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with a topic{x} AND another", %{conn: conn} do @@ -493,6 +508,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert found_log["topics"] == get_topics(log1) assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with a topic{x} OR another", %{conn: conn} do @@ -540,6 +556,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert length(result) == 2 assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end test "with all available 'topic{x}'s and 'topic{x}_{x}_opr's", %{conn: conn} do @@ -598,6 +615,7 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do assert length(result) == 2 assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(getlogs_schema(), response) end end @@ -771,4 +789,32 @@ defmodule BlockScoutWeb.API.RPC.LogsControllerTest do |> DateTime.to_unix() |> integer_to_hex() end + + defp getlogs_schema do + ExJsonSchema.Schema.resolve(%{ + "type" => "object", + "properties" => %{ + "message" => %{"type" => "string"}, + "status" => %{"type" => "string"}, + "result" => %{ + "type" => ["array", "null"], + "items" => %{ + "type" => "object", + "properties" => %{ + "address" => %{"type" => "string"}, + "topics" => %{"type" => "array", "items" => %{"type" => ["string", "null"]}}, + "data" => %{"type" => "string"}, + "blockNumber" => %{"type" => "string"}, + "timeStamp" => %{"type" => "string"}, + "gasPrice" => %{"type" => "string"}, + "gasUsed" => %{"type" => "string"}, + "logIndex" => %{"type" => "string"}, + "transactionHash" => %{"type" => "string"}, + "transactionIndex" => %{"type" => "string"} + } + } + } + } + }) + end end From d0b59997e76e331c0698c53800b535ddb94609a7 Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 12:18:41 +0300 Subject: [PATCH 204/290] add json schema tests to stats controller --- .../api/rpc/stats_controller_test.exs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/stats_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/stats_controller_test.exs index 9a7c26e9ee..bf3b82a3cb 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/stats_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/stats_controller_test.exs @@ -23,6 +23,7 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(tokensupply_schema(), response) end test "with an invalid contractaddress hash", %{conn: conn} do @@ -41,6 +42,7 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(tokensupply_schema(), response) end test "with a contractaddress that doesn't exist", %{conn: conn} do @@ -59,6 +61,7 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["status"] == "0" assert Map.has_key?(response, "result") refute response["result"] + assert :ok = ExJsonSchema.Validator.validate(tokensupply_schema(), response) end test "with valid contractaddress", %{conn: conn} do @@ -78,6 +81,7 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["result"] == to_string(token.total_supply) assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(tokensupply_schema(), response) end end @@ -96,6 +100,7 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["result"] == "252460800000000000000000000" assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(ethsupply_schema(), response) end end @@ -158,6 +163,43 @@ defmodule BlockScoutWeb.API.RPC.StatsControllerTest do assert response["result"] == expected_result assert response["status"] == "1" assert response["message"] == "OK" + assert :ok = ExJsonSchema.Validator.validate(ethprice_schema(), response) end end + + defp tokensupply_schema do + resolve_schema(%{ + "type" => ["string", "null"] + }) + end + + defp ethsupply_schema do + resolve_schema(%{ + "type" => ["string", "null"] + }) + end + + defp ethprice_schema do + resolve_schema(%{ + "type" => "object", + "properties" => %{ + "ethbtc" => %{"type" => "string"}, + "ethbtc_timestamp" => %{"type" => "string"}, + "ethusd" => %{"type" => "string"}, + "ethusd_timestamp" => %{"type" => "string"} + } + }) + end + + defp resolve_schema(result \\ %{}) do + %{ + "type" => "object", + "properties" => %{ + "message" => %{"type" => "string"}, + "status" => %{"type" => "string"} + } + } + |> put_in(["properties", "result"], result) + |> ExJsonSchema.Schema.resolve() + end end From a753e1467b475789e51a875ca79283fd24163b21 Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 12:18:54 +0300 Subject: [PATCH 205/290] add json schema tests to token controller --- .../api/rpc/token_controller_test.exs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/token_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/token_controller_test.exs index 88196b8e40..a640a87441 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/token_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/token_controller_test.exs @@ -84,4 +84,26 @@ defmodule BlockScoutWeb.API.RPC.TokenControllerTest do assert response["message"] == "OK" end end + + defp gettoken_schema do + ExJsonSchema.Schema.resolve(%{ + "type" => "object", + "properties" => %{ + "message" => %{"type" => "string"}, + "status" => %{"type" => "string"}, + "result" => %{ + "type" => "object", + "properties" => %{ + "name" => %{"type" => "string"}, + "symbol" => %{"type" => "string"}, + "totalSupply" => %{"type" => "string"}, + "decimals" => %{"type" => "string"}, + "type" => %{"type" => "string"}, + "cataloged" => %{"type" => "string"}, + "contractAddress" => %{"type" => "string"} + } + } + } + }) + end end From c76b7525da37a4830ff6ebb48f3fe35d8f710f08 Mon Sep 17 00:00:00 2001 From: saneery Date: Sun, 18 Aug 2019 12:23:38 +0300 Subject: [PATCH 206/290] mix format --- .../controllers/api/rpc/contract_controller_test.exs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs index 22b711d9d3..3fbd1713bb 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/contract_controller_test.exs @@ -52,6 +52,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => if(contract.optimization, do: "1", else: "0") } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -75,6 +76,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -99,6 +101,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -127,6 +130,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -151,6 +155,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => if(contract.optimization, do: "1", else: "0") } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -175,6 +180,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -199,6 +205,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -250,6 +257,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end @@ -279,6 +287,7 @@ defmodule BlockScoutWeb.API.RPC.ContractControllerTest do "OptimizationUsed" => "" } ] + assert :ok = ExJsonSchema.Validator.validate(listcontracts_schema(), response) end end From fac326502500c90fa0db30f151ef77d663be80d0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 19 Aug 2019 11:19:19 +0300 Subject: [PATCH 207/290] change branch for absinthe phoenix In the PR (https://github.com/poanetwork/blockscout/pull/2516) we broke backward compatability with old blockscout releases. Now, we will use new fork branches for absinthe deps forks in current releases and return old forks to the old state to maintain backward compatability. --- apps/block_scout_web/mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index 27a1e6aa74..e3aef926cf 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -62,7 +62,7 @@ defmodule BlockScoutWeb.Mixfile do # GraphQL toolkit {:absinthe, "~> 1.4"}, # Integrates Absinthe subscriptions with Phoenix - {:absinthe_phoenix, git: "https://github.com/ayrat555/absinthe_phoenix.git", branch: "master"}, + {:absinthe_phoenix, git: "https://github.com/ayrat555/absinthe_phoenix.git", branch: "ab-update-plug"}, # Plug support for Absinthe {:absinthe_plug, git: "https://github.com/ayrat555/absinthe_plug.git", branch: "ab-enable-default-query"}, # Absinthe support for the Relay framework diff --git a/mix.lock b/mix.lock index c85605b868..4f63710ad5 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,6 @@ %{ "absinthe": {:hex, :absinthe, "1.4.16", "0933e4d9f12652b12115d5709c0293a1bf78a22578032e9ad0dad4efee6b9eb1", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, - "absinthe_phoenix": {:git, "https://github.com/ayrat555/absinthe_phoenix.git", "4dbb73a25a0935a4d292e63876698e18534d835f", [branch: "master"]}, + "absinthe_phoenix": {:git, "https://github.com/ayrat555/absinthe_phoenix.git", "4dbb73a25a0935a4d292e63876698e18534d835f", [branch: "ab-update-plug"]}, "absinthe_plug": {:git, "https://github.com/ayrat555/absinthe_plug.git", "cbe1c170e11e60b3b0146b925a1ce6ec562840ce", [branch: "ab-enable-default-query"]}, "absinthe_relay": {:hex, :absinthe_relay, "1.4.6", "ec0e2288994b388556247cf9601245abec785cdf206d6e844f2992d29de21624", [:mix], [{:absinthe, "~> 1.4.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"}, "accept": {:hex, :accept, "0.3.5", "b33b127abca7cc948bbe6caa4c263369abf1347cfa9d8e699c6d214660f10cd1", [:rebar3], [], "hexpm"}, From c4ca6ba2b5d45f333f33712081dc03af07b4eb55 Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 19 Aug 2019 11:34:04 +0300 Subject: [PATCH 208/290] Fix error of url in API page --- apps/block_scout_web/assets/js/lib/try_api.js | 2 +- apps/block_scout_web/assets/js/lib/try_eth_api.js | 5 +++-- .../lib/block_scout_web/views/api_docs_view.ex | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/assets/js/lib/try_api.js b/apps/block_scout_web/assets/js/lib/try_api.js index c0eb8cd5e3..e6460f6c6b 100644 --- a/apps/block_scout_web/assets/js/lib/try_api.js +++ b/apps/block_scout_web/assets/js/lib/try_api.js @@ -124,7 +124,7 @@ $('button[data-try-api-ui-button-type="execute"]').click(event => { } $.ajax({ - url: `/api${query}`, + url: composeRequestUrl(query), success: (_data, _status, xhr) => { handleSuccess(query, xhr, clickedButton) }, diff --git a/apps/block_scout_web/assets/js/lib/try_eth_api.js b/apps/block_scout_web/assets/js/lib/try_eth_api.js index a3dd7b6f4e..f6e1adffae 100644 --- a/apps/block_scout_web/assets/js/lib/try_eth_api.js +++ b/apps/block_scout_web/assets/js/lib/try_eth_api.js @@ -50,7 +50,6 @@ $('button[data-try-eth-api-ui-button-type="execute"]').click(event => { const inputs = $(`input[data-selector="${module}-${action}-try-api-ui"]`) const params = $.map(inputs, parseInput) const formData = wrapJsonRpc(action, params) - console.log(formData) const loadingText = ' Loading...' clickedButton.prop('disabled', true) @@ -60,8 +59,10 @@ $('button[data-try-eth-api-ui-button-type="execute"]').click(event => { clickedButton.html(loadingText) } + const url = $('[data-endpoint-url]').attr('data-endpoint-url') + $.ajax({ - url: '/api/eth_rpc', + url: url, type: 'POST', data: JSON.stringify(formData), dataType: 'json', diff --git a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex index ac7d4d55ee..895fad79c2 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.APIDocsView do use BlockScoutWeb, :view - alias BlockScoutWeb.{Endpoint, LayoutView} + alias BlockScoutWeb.LayoutView def action_tile_id(module, action) do "#{module}-#{action}" @@ -41,9 +41,10 @@ defmodule BlockScoutWeb.APIDocsView do scheme = url_params[:scheme] if host != "localhost" do - scheme <> "://" <> host <> path + "#{scheme}://#{host}#{path}" else - Endpoint.url() + port = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:http][:port] + "#{scheme}://#{host}:#{to_string(port)}#{path}" end end From 7270b32ffb959ade1480a945b6a578bf3eeb251e Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 19 Aug 2019 11:43:56 +0300 Subject: [PATCH 209/290] Add double quotes to example of API call --- .../block_scout_web/templates/api_docs/_eth_rpc_item.html.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex index 7f342b4a16..57f96e42e0 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex @@ -6,7 +6,7 @@ - curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "<%= @action %>", params: []}' + curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "<%= @action %>", "params": []}'

From 13058bea30d7afc79f9303bcd4f72b57b8a20166 Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 19 Aug 2019 11:47:51 +0300 Subject: [PATCH 210/290] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f006769dbf..649b476ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2591](https://github.com/poanetwork/blockscout/pull/2591) - Fix url error in API page - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload - [#2569](https://github.com/poanetwork/blockscout/pull/2569) - do not fetch emission rewards for transactions csv exporter From c363cf4f1eaf1ebeba28e87de987d38bec78c8c0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 19 Aug 2019 11:54:44 +0300 Subject: [PATCH 211/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f006769dbf..53748f3cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records ### Chore +- [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases - [#2566](https://github.com/poanetwork/blockscout/pull/2566) - upgrade absinthe phoenix From 642cfd01cd1bfcb157fb4a3646208c4fbf2e0a45 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 19 Aug 2019 14:10:13 +0300 Subject: [PATCH 212/290] process new metadata format for whisper Solidity >= 0.5.11 has new whisper metadata format Metadata: Update the swarm hash to the current specification, changes bzzr0 to bzzr1 and urls to use bzz-raw:// https://github.com/ethereum/solidity/blob/develop/Changelog.md#0511-2019-08-12 --- .../lib/explorer/smart_contract/verifier.ex | 8 ++++++ .../verifier/constructor_arguments.ex | 10 +++++++ .../explorer/smart_contract/verifier_test.exs | 27 +++++++++++++++++++ .../solidity_5.11_new_whisper_metadata.json | 7 +++++ 4 files changed, 52 insertions(+) create mode 100644 apps/explorer/test/support/fixture/smart_contract/solidity_5.11_new_whisper_metadata.json diff --git a/apps/explorer/lib/explorer/smart_contract/verifier.ex b/apps/explorer/lib/explorer/smart_contract/verifier.ex index 7aa9957bab..4c2daa680c 100644 --- a/apps/explorer/lib/explorer/smart_contract/verifier.ex +++ b/apps/explorer/lib/explorer/smart_contract/verifier.ex @@ -115,6 +115,14 @@ defmodule Explorer.SmartContract.Verifier do |> Enum.reverse() |> :binary.list_to_bin() + # Solidity >= 0.5.11 https://github.com/ethereum/solidity/blob/develop/Changelog.md#0511-2019-08-12 + # Metadata: Update the swarm hash to the current specification, changes bzzr0 to bzzr1 and urls to use bzz-raw:// + "a265627a7a72315820" <> + <<_::binary-size(64)>> <> "64736f6c6343" <> <<_::binary-size(6)>> <> "0032" <> _constructor_arguments -> + extracted + |> Enum.reverse() + |> :binary.list_to_bin() + <> <> rest -> do_extract_bytecode([next | extracted], rest) end diff --git a/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex b/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex index 61167a4559..6e25b3cc52 100644 --- a/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex +++ b/apps/explorer/lib/explorer/smart_contract/verifier/constructor_arguments.ex @@ -48,6 +48,16 @@ defmodule Explorer.SmartContract.Verifier.ConstructorArguments do extract_constructor_arguments(constructor_arguments, passed_constructor_arguments) end + # Solidity >= 0.5.11 https://github.com/ethereum/solidity/blob/develop/Changelog.md#0511-2019-08-12 + # Metadata: Update the swarm hash to the current specification, changes bzzr0 to bzzr1 and urls to use bzz-raw:// + "a265627a7a72315820" <> + <<_::binary-size(64)>> <> "64736f6c6343" <> <<_::binary-size(6)>> <> "0032" <> constructor_arguments -> + if passed_constructor_arguments == constructor_arguments do + true + else + extract_constructor_arguments(constructor_arguments, passed_constructor_arguments) + end + <<>> -> passed_constructor_arguments == "" diff --git a/apps/explorer/test/explorer/smart_contract/verifier_test.exs b/apps/explorer/test/explorer/smart_contract/verifier_test.exs index 9633804c60..fba0622964 100644 --- a/apps/explorer/test/explorer/smart_contract/verifier_test.exs +++ b/apps/explorer/test/explorer/smart_contract/verifier_test.exs @@ -56,6 +56,33 @@ defmodule Explorer.SmartContract.VerifierTest do assert abi != nil end + test "verifies smart contract with new `whisper` metadata (bzz0 => bzz1) in solidity 0.5.11" do + contract_data = + "#{File.cwd!()}/test/support/fixture/smart_contract/solidity_5.11_new_whisper_metadata.json" + |> File.read!() + |> Jason.decode!() + + compiler_version = contract_data["compiler_version"] + name = contract_data["name"] + optimize = false + contract = contract_data["contract"] + expected_bytecode = contract_data["bytecode"] + evm_version = contract_data["evm_version"] + + contract_address = insert(:contract_address, contract_code: "0x" <> expected_bytecode) + + params = %{ + "contract_source_code" => contract, + "compiler_version" => compiler_version, + "evm_version" => evm_version, + "name" => name, + "optimization" => optimize + } + + assert {:ok, %{abi: abi}} = Verifier.evaluate_authenticity(contract_address.hash, params) + assert abi != nil + end + test "verifies smart contract with constructor arguments", %{ contract_code_info: contract_code_info } do diff --git a/apps/explorer/test/support/fixture/smart_contract/solidity_5.11_new_whisper_metadata.json b/apps/explorer/test/support/fixture/smart_contract/solidity_5.11_new_whisper_metadata.json new file mode 100644 index 0000000000..bd0301ef78 --- /dev/null +++ b/apps/explorer/test/support/fixture/smart_contract/solidity_5.11_new_whisper_metadata.json @@ -0,0 +1,7 @@ +{ + "bytecode": "608060405260043610610105576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100a7578063d4ee1d9011610076578063d4ee1d90146105dc578063dc39d06d14610633578063dd62ed3e146106a6578063f2fde38b1461072b57610105565b80638da5cb5b1461037857806395d89b41146103cf578063a9059cbb1461045f578063cae9ca51146104d257610105565b806323b872dd116100e357806323b872dd14610238578063313ce567146102cb57806370a08231146102fc57806379ba50971461036157610105565b806306fdde031461010a578063095ea7b31461019a57806318160ddd1461020d575b600080fd5b34801561011657600080fd5b5061011f61077c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015f578082015181840152602081019050610144565b50505050905090810190601f16801561018c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101a657600080fd5b506101f3600480360360408110156101bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081a565b604051808215151515815260200191505060405180910390f35b34801561021957600080fd5b5061022261090c565b6040518082815260200191505060405180910390f35b34801561024457600080fd5b506102b16004803603606081101561025b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610967565b604051808215151515815260200191505060405180910390f35b3480156102d757600080fd5b506102e0610c12565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030857600080fd5b5061034b6004803603602081101561031f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c25565b6040518082815260200191505060405180910390f35b34801561036d57600080fd5b50610376610c6e565b005b34801561038457600080fd5b5061038d610e0b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103db57600080fd5b506103e4610e30565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610424578082015181840152602081019050610409565b50505050905090810190601f1680156104515780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561046b57600080fd5b506104b86004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ece565b604051808215151515815260200191505060405180910390f35b3480156104de57600080fd5b506105c2600480360360608110156104f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561053c57600080fd5b82018360208201111561054e57600080fd5b8035906020019184600183028401116401000000008311171561057057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611069565b604051808215151515815260200191505060405180910390f35b3480156105e857600080fd5b506105f16112b8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561063f57600080fd5b5061068c6004803603604081101561065657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112de565b604051808215151515815260200191505060405180910390f35b3480156106b257600080fd5b50610715600480360360408110156106c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611440565b6040518082815260200191505060405180910390f35b34801561073757600080fd5b5061077a6004803603602081101561074e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114c7565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108125780601f106107e757610100808354040283529160200191610812565b820191906000526020600020905b8154815290600101906020018083116107f557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000610962600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055461156490919063ffffffff16565b905090565b60006109bb82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156490919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a8d82600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156490919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b5f82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461157e90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610cc857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ec65780601f10610e9b57610100808354040283529160200191610ec6565b820191906000526020600020905b815481529060010190602001808311610ea957829003601f168201915b505050505081565b6000610f2282600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156490919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fb782600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461157e90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561124657808201518184015260208101905061122b565b50505050905090810190601f1680156112735780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561129557600080fd5b505af11580156112a9573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461133957600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156113fd57600080fd5b505af1158015611411573d6000803e3d6000fd5b505050506040513d602081101561142757600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461152057600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111561157357600080fd5b818303905092915050565b600081830190508281101561159257600080fd5b9291505056fea265627a7a7231582073fbadbc806cc1f3349b3f98d58b62f7fa417e82d98f41bafd3dd9f9be4e4fa764736f6c634300050b0032", + "compiler_version": "v0.5.11+commit.c082d0b4", + "contract": "/**\r\n *Submitted for verification at Etherscan.io on 2019-08-16\r\n*/\r\n\r\npragma solidity ^0.5.0;\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// 'FIXED' 'Example Fixed Supply Token' token contract\r\n\r\n//\r\n\r\n// Symbol : FIXED\r\n\r\n// Name : Example Fixed Supply Token\r\n\r\n// Total supply: 1,000,000.000000000000000000\r\n\r\n// Decimals : 18\r\n\r\n//\r\n\r\n// Enjoy.\r\n\r\n//\r\n\r\n// (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence.\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// Safe maths\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\nlibrary SafeMath {\r\n\r\n function add(uint a, uint b) internal pure returns (uint c) {\r\n\r\n c = a + b;\r\n\r\n require(c >= a);\r\n\r\n }\r\n\r\n function sub(uint a, uint b) internal pure returns (uint c) {\r\n\r\n require(b <= a);\r\n\r\n c = a - b;\r\n\r\n }\r\n\r\n function mul(uint a, uint b) internal pure returns (uint c) {\r\n\r\n c = a * b;\r\n\r\n require(a == 0 || c / a == b);\r\n\r\n }\r\n\r\n function div(uint a, uint b) internal pure returns (uint c) {\r\n\r\n require(b > 0);\r\n\r\n c = a / b;\r\n\r\n }\r\n\r\n}\r\n\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// ERC Token Standard #20 Interface\r\n\r\n// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\ncontract ERC20Interface {\r\n\r\n function totalSupply() public view returns (uint);\r\n\r\n function balanceOf(address tokenOwner) public view returns (uint balance);\r\n\r\n function allowance(address tokenOwner, address spender) public view returns (uint remaining);\r\n\r\n function transfer(address to, uint tokens) public returns (bool success);\r\n\r\n function approve(address spender, uint tokens) public returns (bool success);\r\n\r\n function transferFrom(address from, address to, uint tokens) public returns (bool success);\r\n\r\n\r\n event Transfer(address indexed from, address indexed to, uint tokens);\r\n\r\n event Approval(address indexed tokenOwner, address indexed spender, uint tokens);\r\n\r\n}\r\n\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// Contract function to receive approval and execute function in one call\r\n\r\n//\r\n\r\n// Borrowed from MiniMeToken\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\ncontract ApproveAndCallFallBack {\r\n\r\n function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public;\r\n\r\n}\r\n\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// Owned contract\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\ncontract Owned {\r\n\r\n address public owner;\r\n\r\n address public newOwner;\r\n\r\n\r\n event OwnershipTransferred(address indexed _from, address indexed _to);\r\n\r\n\r\n constructor() public {\r\n\r\n owner = msg.sender;\r\n\r\n }\r\n\r\n\r\n modifier onlyOwner {\r\n\r\n require(msg.sender == owner);\r\n\r\n _;\r\n\r\n }\r\n\r\n\r\n function transferOwnership(address _newOwner) public onlyOwner {\r\n\r\n newOwner = _newOwner;\r\n\r\n }\r\n\r\n function acceptOwnership() public {\r\n\r\n require(msg.sender == newOwner);\r\n\r\n emit OwnershipTransferred(owner, newOwner);\r\n\r\n owner = newOwner;\r\n\r\n newOwner = address(0);\r\n\r\n }\r\n\r\n}\r\n\r\n\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\n// ERC20 Token, with the addition of symbol, name and decimals and a\r\n\r\n// fixed supply\r\n\r\n// ----------------------------------------------------------------------------\r\n\r\ncontract FixedSupplyToken is ERC20Interface, Owned {\r\n\r\n using SafeMath for uint;\r\n\r\n\r\n string public symbol;\r\n\r\n string public name;\r\n\r\n uint8 public decimals;\r\n\r\n uint _totalSupply;\r\n\r\n\r\n mapping(address => uint) balances;\r\n\r\n mapping(address => mapping(address => uint)) allowed;\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Constructor\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n constructor() public {\r\n\r\n symbol = \"TEST\";\r\n\r\n name = \"Test Token\";\r\n\r\n decimals = 18;\r\n\r\n _totalSupply = 1000000 * 10**uint(decimals);\r\n\r\n balances[owner] = _totalSupply;\r\n\r\n emit Transfer(address(0), owner, _totalSupply);\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Total supply\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function totalSupply() public view returns (uint) {\r\n\r\n return _totalSupply.sub(balances[address(0)]);\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Get the token balance for account `tokenOwner`\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function balanceOf(address tokenOwner) public view returns (uint balance) {\r\n\r\n return balances[tokenOwner];\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Transfer the balance from token owner's account to `to` account\r\n\r\n // - Owner's account must have sufficient balance to transfer\r\n\r\n // - 0 value transfers are allowed\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function transfer(address to, uint tokens) public returns (bool success) {\r\n\r\n balances[msg.sender] = balances[msg.sender].sub(tokens);\r\n\r\n balances[to] = balances[to].add(tokens);\r\n\r\n emit Transfer(msg.sender, to, tokens);\r\n\r\n return true;\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Token owner can approve for `spender` to transferFrom(...) `tokens`\r\n\r\n // from the token owner's account\r\n\r\n //\r\n\r\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md\r\n\r\n // recommends that there are no checks for the approval double-spend attack\r\n\r\n // as this should be implemented in user interfaces\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function approve(address spender, uint tokens) public returns (bool success) {\r\n\r\n allowed[msg.sender][spender] = tokens;\r\n\r\n emit Approval(msg.sender, spender, tokens);\r\n\r\n return true;\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Transfer `tokens` from the `from` account to the `to` account\r\n\r\n //\r\n\r\n // The calling account must already have sufficient tokens approve(...)-d\r\n\r\n // for spending from the `from` account and\r\n\r\n // - From account must have sufficient balance to transfer\r\n\r\n // - Spender must have sufficient allowance to transfer\r\n\r\n // - 0 value transfers are allowed\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function transferFrom(address from, address to, uint tokens) public returns (bool success) {\r\n\r\n balances[from] = balances[from].sub(tokens);\r\n\r\n allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);\r\n\r\n balances[to] = balances[to].add(tokens);\r\n\r\n emit Transfer(from, to, tokens);\r\n\r\n return true;\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Returns the amount of tokens approved by the owner that can be\r\n\r\n // transferred to the spender's account\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function allowance(address tokenOwner, address spender) public view returns (uint remaining) {\r\n\r\n return allowed[tokenOwner][spender];\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Token owner can approve for `spender` to transferFrom(...) `tokens`\r\n\r\n // from the token owner's account. The `spender` contract function\r\n\r\n // `receiveApproval(...)` is then executed\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) {\r\n\r\n allowed[msg.sender][spender] = tokens;\r\n\r\n emit Approval(msg.sender, spender, tokens);\r\n\r\n ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);\r\n\r\n return true;\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Don't accept ETH\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function () external payable {\r\n\r\n revert();\r\n\r\n }\r\n\r\n\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n // Owner can transfer out any accidentally sent ERC20 tokens\r\n\r\n // ------------------------------------------------------------------------\r\n\r\n function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {\r\n\r\n return ERC20Interface(tokenAddress).transfer(owner, tokens);\r\n\r\n }\r\n\r\n}", + "name": "FixedSupplyToken", + "evm_version": "byzantium" +} From 6f24e25fc80f2fbcd16feccfd37d5e189cb89a1e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 19 Aug 2019 14:14:39 +0300 Subject: [PATCH 213/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f006769dbf..ff2fbeddb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload - [#2569](https://github.com/poanetwork/blockscout/pull/2569) - do not fetch emission rewards for transactions csv exporter From 14f099b5b35b219873751e184d631bcf234c3a73 Mon Sep 17 00:00:00 2001 From: saneery Date: Mon, 19 Aug 2019 17:11:29 +0300 Subject: [PATCH 214/290] remove additional path in local url --- apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex index 895fad79c2..382a7b26b9 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex @@ -44,7 +44,7 @@ defmodule BlockScoutWeb.APIDocsView do "#{scheme}://#{host}#{path}" else port = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:http][:port] - "#{scheme}://#{host}:#{to_string(port)}#{path}" + "#{scheme}://#{host}:#{to_string(port)}" end end From f1c1e066a7803cd56305ad602fbeb5705c27e699 Mon Sep 17 00:00:00 2001 From: saneery Date: Tue, 20 Aug 2019 10:39:40 +0300 Subject: [PATCH 215/290] Add double quotes to copying string --- .../block_scout_web/templates/api_docs/_eth_rpc_item.html.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex index 57f96e42e0..f464533c7e 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex @@ -4,7 +4,7 @@

<%= @action %>

<%= raw @info.notes %>

curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "<%= @action %>", "params": []}' From 0c1963770c6b8012d34fb09ff53d76712cbb38d2 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 10:45:09 +0300 Subject: [PATCH 216/290] add CR issues --- .../templates/address_logs/_logs.html.eex | 2 +- .../templates/transaction_log/_logs.html.eex | 2 +- apps/explorer/lib/explorer/chain/log.ex | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex index cf19ea6420..527a63feab 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex @@ -10,7 +10,7 @@ <%= gettext "Verify the contract " %><%= gettext "here" %> <% _ -> %> <%= nil %> - <% end %> + <% end %>
<% _ -> %> <%= nil %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex index a0922454a9..49a18bf84d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex @@ -9,7 +9,7 @@ <%= gettext "Verify the contract " %><%= gettext "here" %> <% _ -> %> <%= nil %> - <% end %> + <% end %> <% _ -> %> <%= nil %> diff --git a/apps/explorer/lib/explorer/chain/log.ex b/apps/explorer/lib/explorer/chain/log.ex index f84c59c38d..0c9b2087ce 100644 --- a/apps/explorer/lib/explorer/chain/log.ex +++ b/apps/explorer/lib/explorer/chain/log.ex @@ -118,9 +118,14 @@ defmodule Explorer.Chain.Log do def decode(log, transaction) do case log.first_topic do "0x" <> hex_part -> - {number, ""} = Integer.parse(hex_part, 16) - <> = :binary.encode_unsigned(number) - find_candidates(method_id, log, transaction) + case Integer.parse(hex_part, 16) do + {number, ""} -> + <> = :binary.encode_unsigned(number) + find_candidates(method_id, log, transaction) + + _ -> + {:error, :could_not_decode} + end _ -> {:error, :could_not_decode} From 2b6f7eff784c2520731b1cf451fc044e3ffb862e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 11:06:40 +0300 Subject: [PATCH 217/290] do not start genesis data fetching periodically From this point genesis data fetching will start and will be retried on a task failure. Also, this PR disables genesis data fetcher process by default because most our users won't know that they should set chain spec for it. --- apps/explorer/config/config.exs | 2 +- apps/explorer/lib/explorer/chain_spec/genesis_data.ex | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 95c80ba445..93298073e0 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -27,7 +27,7 @@ config :explorer, Explorer.Counters.AverageBlockTime, enabled: true, period: average_block_period -config :explorer, Explorer.ChainSpec.GenesisData, enabled: true, chain_spec_path: System.get_env("CHAIN_SPEC_PATH") +config :explorer, Explorer.ChainSpec.GenesisData, enabled: false, chain_spec_path: System.get_env("CHAIN_SPEC_PATH") config :explorer, Explorer.Chain.Cache.BlockNumber, enabled: true diff --git a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex index a156aae6d7..690be2eb19 100644 --- a/apps/explorer/lib/explorer/chain_spec/genesis_data.ex +++ b/apps/explorer/lib/explorer/chain_spec/genesis_data.ex @@ -18,7 +18,6 @@ defmodule Explorer.ChainSpec.GenesisData do @impl GenServer def init(_) do - :timer.send_interval(@interval, :import) Process.send_after(self(), :import, @interval) {:ok, %{}} From 80186d3ce8443c1655c7b6bf76c048a257f66dc2 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 11:10:52 +0300 Subject: [PATCH 218/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a49616a0a5..a8b6d16ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records ### Chore +- [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically - [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases - [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error - [#2566](https://github.com/poanetwork/blockscout/pull/2566) - upgrade absinthe phoenix From 18848fe472c5f999e544dd79f9a9de3e1fed7894 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 12:40:30 +0300 Subject: [PATCH 219/290] use older version of phoenix framework In the PR (https://github.com/poanetwork/blockscout/pull/2566) phoenix was updated to `1.4.9`. But apparently new changes cause web socket connection to disconnect and connect again which shows `Connection Closed` message. We should investigate this issue and update phoenix framework after that - https://github.com/poanetwork/blockscout/issues/2595 --- apps/block_scout_web/mix.exs | 2 +- mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index e54907177f..de55cb0eb7 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -99,7 +99,7 @@ defmodule BlockScoutWeb.Mixfile do {:logger_file_backend, "~> 0.0.10"}, {:math, "~> 0.3.0"}, {:mock, "~> 0.3.0", only: [:test], runtime: false}, - {:phoenix, "~> 1.4"}, + {:phoenix, "== 1.4.0"}, {:phoenix_ecto, "~> 4.0"}, {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.2", only: [:dev]}, diff --git a/mix.lock b/mix.lock index d589137148..e0d75af01a 100644 --- a/mix.lock +++ b/mix.lock @@ -81,7 +81,7 @@ "optimal": {:hex, :optimal, "0.3.6", "46bbf52fbbbd238cda81e02560caa84f93a53c75620f1fe19e81e4ae7b07d1dd", [:mix], [], "hexpm"}, "parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.4.9", "746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix": {:hex, :phoenix, "1.4.0", "56fe9a809e0e735f3e3b9b31c1b749d4b436e466d8da627b8d82f90eaae714d2", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, "phoenix_ecto": {:hex, :phoenix_ecto, "4.0.0", "c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_form_awesomplete": {:hex, :phoenix_form_awesomplete, "0.1.5", "d09aade160b584e3428e1e095645482396f17bddda4f566f1118f12d2598d11c", [:mix], [{:phoenix_html, "~> 2.10", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.13.3", "850e292ff6e204257f5f9c4c54a8cb1f6fbc16ed53d360c2b780a3d0ba333867", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, From d1a8e7f5130a2b014a2556e998db6b23cbc55273 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 13:45:11 +0300 Subject: [PATCH 220/290] add AuRa's empty step reward type Instead of producing empty blocks nodes in Aura consensus protocol broadcast an EmptyStep(step, parent_hash) message. https://github.com/paritytech/wiki/blob/master/Aura.md#empty-steps --- .../lib/ethereum_jsonrpc/parity/fetched_beneficiaries.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity/fetched_beneficiaries.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity/fetched_beneficiaries.ex index fea1a4c8aa..b2a90d53bc 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity/fetched_beneficiaries.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity/fetched_beneficiaries.ex @@ -182,4 +182,5 @@ defmodule EthereumJSONRPC.Parity.FetchedBeneficiaries do defp get_address_type(reward_type, index) when reward_type == "external" and index == 10, do: :validator defp get_address_type(reward_type, _index) when reward_type == "block", do: :validator defp get_address_type(reward_type, _index) when reward_type == "uncle", do: :uncle + defp get_address_type(reward_type, _index) when reward_type == "emptyStep", do: :validator end From de564dea01a940b31a528e80053ab1f6ab42cf97 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 20 Aug 2019 13:49:43 +0300 Subject: [PATCH 221/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a49616a0a5..c691326fb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2596](https://github.com/poanetwork/blockscout/pull/2596) - support AuRa's empty step reward type - [#2561](https://github.com/poanetwork/blockscout/pull/2561) - Add token's type to the response of tokenlist method - [#2499](https://github.com/poanetwork/blockscout/pull/2499) - import emission reward ranges - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation From 0a647d0acbe3cfcb8b575cf92d420f6ae3268582 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 21 Aug 2019 12:06:20 +0300 Subject: [PATCH 222/290] Remove schema from api url --- apps/block_scout_web/assets/js/lib/try_api.js | 6 +++++- apps/block_scout_web/assets/js/lib/try_eth_api.js | 6 +++++- .../lib/block_scout_web/views/api_docs_view.ex | 5 ++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/block_scout_web/assets/js/lib/try_api.js b/apps/block_scout_web/assets/js/lib/try_api.js index e6460f6c6b..02d82a65ef 100644 --- a/apps/block_scout_web/assets/js/lib/try_api.js +++ b/apps/block_scout_web/assets/js/lib/try_api.js @@ -55,6 +55,10 @@ function handleSuccess (query, xhr, clickedButton) { clickedButton.prop('disabled', false) } +function dropDomain (url) { + return url.split('/').slice(1).join('/') +} + // Show 'Try it out' UI for a module/action. $('button[data-selector*="btn-try-api"]').click(event => { const clickedButton = $(event.target) @@ -124,7 +128,7 @@ $('button[data-try-api-ui-button-type="execute"]').click(event => { } $.ajax({ - url: composeRequestUrl(query), + url: '/' + dropDomain(composeRequestUrl(query)), success: (_data, _status, xhr) => { handleSuccess(query, xhr, clickedButton) }, diff --git a/apps/block_scout_web/assets/js/lib/try_eth_api.js b/apps/block_scout_web/assets/js/lib/try_eth_api.js index f6e1adffae..464229885d 100644 --- a/apps/block_scout_web/assets/js/lib/try_eth_api.js +++ b/apps/block_scout_web/assets/js/lib/try_eth_api.js @@ -43,6 +43,10 @@ function parseInput (input) { } } +function dropDomain (url) { + return url.split('/').slice(1).join('/') +} + $('button[data-try-eth-api-ui-button-type="execute"]').click(event => { const clickedButton = $(event.target) const module = clickedButton.attr('data-module') @@ -62,7 +66,7 @@ $('button[data-try-eth-api-ui-button-type="execute"]').click(event => { const url = $('[data-endpoint-url]').attr('data-endpoint-url') $.ajax({ - url: url, + url: '/' + dropDomain(url), type: 'POST', data: JSON.stringify(formData), dataType: 'json', diff --git a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex index 382a7b26b9..6f731d3627 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex @@ -38,13 +38,12 @@ defmodule BlockScoutWeb.APIDocsView do url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url] host = url_params[:host] path = url_params[:path] - scheme = url_params[:scheme] if host != "localhost" do - "#{scheme}://#{host}#{path}" + "#{host}#{path}" else port = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:http][:port] - "#{scheme}://#{host}:#{to_string(port)}" + "#{host}:#{to_string(port)}" end end From 0da2afb1caafac30fa3d1ac21c6fff61f9f10975 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 12:15:04 +0300 Subject: [PATCH 223/290] use CoinGecko instead of CoinMarketcap for exchange rates CoinMarketcap deprecated and took offline its v1 API. They have v2 API which has free plan and requires API keys. But as part of https://github.com/poanetwork/blockscout/issues/234 we alresy implemented fetching from CoinGecko. Now, coin id should be set for CoinGecko for the required coin. ``` config :explorer, Explorer.ExchangeRates.Source.CoinGecko, coin_id: System.get_env("COIN_GECKO_ID", "poa-network") ``` Or the `COIN_GECKO_ID` env var should be set. For example, COIN_GECKO_ID=poa-network --- apps/explorer/config/config.exs | 2 + apps/explorer/lib/explorer/chain.ex | 2 +- .../{coin_market_cap.ex => exchange_rate.ex} | 4 +- .../lib/explorer/exchange_rates/source.ex | 2 +- .../exchange_rates/source/coin_gecko.ex | 38 +++++++++++-------- 5 files changed, 28 insertions(+), 20 deletions(-) rename apps/explorer/lib/explorer/chain/supply/{coin_market_cap.ex => exchange_rate.ex} (72%) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 95c80ba445..87b57d5f82 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -34,6 +34,8 @@ config :explorer, Explorer.Chain.Cache.BlockNumber, enabled: true config :explorer, Explorer.ExchangeRates.Source.CoinMarketCap, pages: String.to_integer(System.get_env("COINMARKETCAP_PAGES") || "10") +config :explorer, Explorer.ExchangeRates.Source.CoinGecko, coin_id: System.get_env("COIN_GECKO_ID", "poa-network") + balances_update_interval = if System.get_env("ADDRESS_WITH_BALANCES_UPDATE_INTERVAL") do case Integer.parse(System.get_env("ADDRESS_WITH_BALANCES_UPDATE_INTERVAL")) do diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 58253c0f27..90df61749c 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2717,7 +2717,7 @@ defmodule Explorer.Chain do end defp supply_module do - Application.get_env(:explorer, :supply, Explorer.Chain.Supply.CoinMarketCap) + Application.get_env(:explorer, :supply, Explorer.Chain.Supply.ExchangeRate) end @doc """ diff --git a/apps/explorer/lib/explorer/chain/supply/coin_market_cap.ex b/apps/explorer/lib/explorer/chain/supply/exchange_rate.ex similarity index 72% rename from apps/explorer/lib/explorer/chain/supply/coin_market_cap.ex rename to apps/explorer/lib/explorer/chain/supply/exchange_rate.ex index ebaadb3c47..d45a8edc02 100644 --- a/apps/explorer/lib/explorer/chain/supply/coin_market_cap.ex +++ b/apps/explorer/lib/explorer/chain/supply/exchange_rate.ex @@ -1,6 +1,6 @@ -defmodule Explorer.Chain.Supply.CoinMarketCap do +defmodule Explorer.Chain.Supply.ExchangeRate do @moduledoc """ - Defines the supply API for calculating supply for coins from coinmarketcap. + Defines the supply API for calculating supply for coins from exchange_rate.. """ use Explorer.Chain.Supply diff --git a/apps/explorer/lib/explorer/exchange_rates/source.ex b/apps/explorer/lib/explorer/exchange_rates/source.ex index 41b87c1e29..d733b22222 100644 --- a/apps/explorer/lib/explorer/exchange_rates/source.ex +++ b/apps/explorer/lib/explorer/exchange_rates/source.ex @@ -83,7 +83,7 @@ defmodule Explorer.ExchangeRates.Source do @spec exchange_rates_source() :: module() defp exchange_rates_source do - config(:source) || Explorer.ExchangeRates.Source.CoinMarketCap + config(:source) || Explorer.ExchangeRates.Source.CoinGecko end @spec config(atom()) :: term diff --git a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex index 4e59537bf6..f12eaca844 100644 --- a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex +++ b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex @@ -15,39 +15,45 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do {:ok, price} = get_btc_price() btc_price = to_decimal(price) - for item <- decode_json(data), - not is_nil(item["total_supply"]) and not is_nil(item["current_price"]) do - {:ok, last_updated, 0} = DateTime.from_iso8601(item["last_updated"]) + json_data = decode_json(data) - current_price = to_decimal(item["current_price"]) + market_data = json_data["market_data"] + {:ok, last_updated, 0} = DateTime.from_iso8601(market_data["last_updated"]) - id = item["id"] - btc_value = if id != "btc", do: Decimal.div(current_price, btc_price), else: 1 + current_price = to_decimal(market_data["current_price"]["usd"]) + id = json_data["id"] + btc_value = if id != "btc", do: Decimal.div(current_price, btc_price), else: 1 + + [ %Token{ - available_supply: to_decimal(item["total_supply"]), - total_supply: to_decimal(item["total_supply"]), + available_supply: to_decimal(market_data["circulating_supply"]), + total_supply: to_decimal(market_data["total_supply"]), btc_value: btc_value, - id: id, + id: json_data["id"], last_updated: last_updated, - market_cap_usd: to_decimal(item["market_cap"]), - name: item["name"], - symbol: item["symbol"], + market_cap_usd: to_decimal(market_data["market_cap"]["usd"]), + name: json_data["name"], + symbol: String.upcase(json_data["symbol"]), usd_value: current_price, - volume_24h_usd: to_decimal(item["total_volume"]) + volume_24h_usd: to_decimal(market_data["total_volume"]["usd"]) } - end + ] end @impl Source - def source_url(currency \\ "usd") do - "#{base_url()}/coins/markets?vs_currency=#{currency}" + def source_url do + "#{base_url()}/coins/#{coin_id()}" end defp base_url do config(:base_url) || "https://api.coingecko.com/api/v3" end + defp coin_id do + Application.get_env(:explorer, __MODULE__)[:coin_id] + end + defp get_btc_price(currency \\ "usd") do url = "#{base_url()}/exchange_rates" From 6990cac077063258515be73e2867314a11a1dbd9 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 12:24:54 +0300 Subject: [PATCH 224/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a49616a0a5..d54e46cc71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2610](https://github.com/poanetwork/blockscout/pull/2610) - use CoinGecko instead of CoinMarketcap for exchange rates - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload - [#2569](https://github.com/poanetwork/blockscout/pull/2569) - do not fetch emission rewards for transactions csv exporter From 8bae16459a7db6482bb8df42279248eb9a7546b5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 12:28:05 +0300 Subject: [PATCH 225/290] add entry to env vars file --- docs/env-variables.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/env-variables.md b/docs/env-variables.md index 60c9eee442..5ede197596 100644 --- a/docs/env-variables.md +++ b/docs/env-variables.md @@ -53,6 +53,7 @@ $ export NETWORK=POA | `ADDRESS_WITH_BALANCES`
`_UPDATE_INTERVAL`| | Interval in seconds to restart the task, which calculates addresses with balances. | 30 * 60 | v1.3.9+ | | `LINK_TO_OTHER_EXPLORERS` | | true/false. If true, links to other explorers are added in the footer | (empty) | v1.3.0+ | | `COINMARKETCAP_PAGES` | | the number of pages on coinmarketcap to list in order to find token's price | 10 | v1.3.10+ | +| `COIN_GECKO_ID` | | CoinGecko coin id required for fetching an exchange rate | poa-network | master | | `CHAIN_SPEC_PATH` | | Chain specification path (absolute file system path or url) to import block emission reward ranges and genesis account balances from | (empty) | master | | `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ | | `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ | From 1ddbbb4b4063090a4df352bf0a7459dc1cc758db Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 21 Aug 2019 12:41:24 +0300 Subject: [PATCH 226/290] fix tests --- .../block_scout_web/views/api_docs_view_test.exs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs index 7583aeaa4f..69be27ef09 100644 --- a/apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs @@ -17,7 +17,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/"] ) - assert APIDocsView.blockscout_url() == "https://blockscout.com/" + assert APIDocsView.blockscout_url() == "blockscout.com/" end test "returns url with scheme and host with path" do @@ -25,7 +25,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/chain/dog"] ) - assert APIDocsView.blockscout_url() == "https://blockscout.com/chain/dog" + assert APIDocsView.blockscout_url() == "blockscout.com/chain/dog" end end @@ -43,7 +43,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/chain/dog"] ) - assert APIDocsView.api_url() == "https://blockscout.com/chain/dog/api" + assert APIDocsView.api_url() == "blockscout.com/chain/dog/api" end test "does not add slash to empty path" do @@ -51,7 +51,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: ""] ) - assert APIDocsView.api_url() == "https://blockscout.com/api" + assert APIDocsView.api_url() == "blockscout.com/api" end end @@ -69,7 +69,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: "/chain/dog"] ) - assert APIDocsView.eth_rpc_api_url() == "https://blockscout.com/chain/dog/api/eth_rpc" + assert APIDocsView.eth_rpc_api_url() == "blockscout.com/chain/dog/api/eth_rpc" end test "does not add slash to empty path" do @@ -77,7 +77,7 @@ defmodule BlockScoutWeb.ApiDocsViewTest do url: [scheme: "https", host: "blockscout.com", port: 9999, path: ""] ) - assert APIDocsView.eth_rpc_api_url() == "https://blockscout.com/api/eth_rpc" + assert APIDocsView.eth_rpc_api_url() == "blockscout.com/api/eth_rpc" end end end From c563ee363802bebc17672f13c96a9adaeaa49b89 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 13:28:44 +0300 Subject: [PATCH 227/290] fix CoinGecko tests --- .../exchange_rates/source/coin_gecko.ex | 5 +- .../exchange_rates/source/coin_gecko_test.exs | 57 +++++-------------- 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex index f12eaca844..5b0bed2b3b 100644 --- a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex +++ b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex @@ -11,7 +11,7 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do @behaviour Source @impl Source - def format_data(data) do + def format_data(%{"market_data" => _} = data) do {:ok, price} = get_btc_price() btc_price = to_decimal(price) @@ -41,6 +41,9 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do ] end + @impl Source + def format_data(_), do: [] + @impl Source def source_url do "#{base_url()}/coins/#{coin_id()}" diff --git a/apps/explorer/test/explorer/exchange_rates/source/coin_gecko_test.exs b/apps/explorer/test/explorer/exchange_rates/source/coin_gecko_test.exs index 3c2a9b6feb..b4b3313d6c 100644 --- a/apps/explorer/test/explorer/exchange_rates/source/coin_gecko_test.exs +++ b/apps/explorer/test/explorer/exchange_rates/source/coin_gecko_test.exs @@ -18,34 +18,6 @@ defmodule Explorer.ExchangeRates.Source.CoinGeckoTest do } """ - @json_mkt_data """ - [ - { - "id": "poa-network", - "symbol": "poa", - "name": "POA Network", - "image": "https://assets.coingecko.com/coins/images/3157/large/poa.jpg?1520829019", - "current_price": 0.114782883773693, - "market_cap": 25248999.6735956, - "market_cap_rank": 185, - "total_volume": 2344442.13578437, - "high_24h": 0.115215129840519, - "low_24h": 0.101039753612939, - "price_change_24h": 0.0135970966607094, - "price_change_percentage_24h": 13.437753511298, - "market_cap_change_24h": 3058195.58191147, - "market_cap_change_percentage_24h": 13.7813644304017, - "circulating_supply": "219935174.0", - "total_supply": 252193195, - "ath": 0.935923393359191, - "ath_change_percentage": -87.731057963078, - "ath_date": "2018-05-10T09:45:31.809Z", - "roi": null, - "last_updated": "2018-10-23T01:25:31.764Z" - } - ] - """ - describe "format_data/1" do setup do bypass = Bypass.open() @@ -59,31 +31,30 @@ defmodule Explorer.ExchangeRates.Source.CoinGeckoTest do Conn.resp(conn, 200, @json_btc_price) end) - {:ok, expected_date, 0} = "2018-10-23T01:25:31.764Z" |> DateTime.from_iso8601() + json_data = + "#{File.cwd!()}/test/support/fixture/exchange_rates/coin_gecko.json" + |> File.read!() + |> Jason.decode!() expected = [ %Token{ - available_supply: Decimal.new("252193195"), - total_supply: Decimal.new("252193195"), - btc_value: Decimal.new("0.00001753101509231471092879666458"), + available_supply: Decimal.new("220167621.0"), + total_supply: Decimal.new("252193195.0"), + btc_value: Decimal.new("0.000002055310963802830367634997491"), id: "poa-network", - last_updated: expected_date, - market_cap_usd: Decimal.new("25248999.6735956"), + last_updated: ~U[2019-08-21 08:36:49.371Z], + market_cap_usd: Decimal.new("2962791"), name: "POA Network", - symbol: "poa", - usd_value: Decimal.new("0.114782883773693"), - volume_24h_usd: Decimal.new("2344442.13578437") + symbol: "POA", + usd_value: Decimal.new("0.01345698"), + volume_24h_usd: Decimal.new("119946") } ] - assert expected == CoinGecko.format_data(@json_mkt_data) + assert expected == CoinGecko.format_data(json_data) end - test "returns nothing when given bad data", %{bypass: bypass} do - Bypass.expect(bypass, "GET", "/exchange_rates", fn conn -> - Conn.resp(conn, 200, @json_btc_price) - end) - + test "returns nothing when given bad data" do bad_data = """ [{"id": "poa-network"}] """ From 61c65de470ee6dc6907613b19e24a7ce733ebe5d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 13:29:12 +0300 Subject: [PATCH 228/290] add example CoinGecko response --- .../fixture/exchange_rates/coin_gecko.json | 1806 +++++++++++++++++ 1 file changed, 1806 insertions(+) create mode 100644 apps/explorer/test/support/fixture/exchange_rates/coin_gecko.json diff --git a/apps/explorer/test/support/fixture/exchange_rates/coin_gecko.json b/apps/explorer/test/support/fixture/exchange_rates/coin_gecko.json new file mode 100644 index 0000000000..cc110eb402 --- /dev/null +++ b/apps/explorer/test/support/fixture/exchange_rates/coin_gecko.json @@ -0,0 +1,1806 @@ +{ + "asset_platform_id": null, + "block_time_in_minutes": 0, + "categories": [], + "coingecko_rank": 376, + "coingecko_score": 33.7, + "community_data": { + "facebook_likes": 0, + "reddit_accounts_active_48h": 0, + "reddit_average_comments_48h": 0.0, + "reddit_average_posts_48h": 0.0, + "reddit_subscribers": 0, + "telegram_channel_user_count": 5125, + "twitter_followers": 17737 + }, + "community_score": 9.403, + "country_origin": "", + "description": { + "ar": "", + "de": "", + "en": "", + "es": "", + "fr": "", + "hu": "", + "id": "", + "it": "", + "ja": "", + "ko": "", + "nl": "", + "pl": "", + "pt": "", + "ro": "", + "ru": "", + "sv": "", + "th": "", + "tr": "", + "vi": "", + "zh": "", + "zh-tw": "" + }, + "developer_data": { + "closed_issues": 0, + "code_additions_deletions_4_weeks": { + "additions": 0, + "deletions": 0 + }, + "commit_count_4_weeks": 0, + "forks": 44, + "last_4_weeks_commit_activity_series": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "pull_request_contributors": 6, + "pull_requests_merged": 133, + "stars": 58, + "subscribers": 8, + "total_issues": 0 + }, + "developer_score": 52.776, + "genesis_date": null, + "id": "poa-network", + "image": { + "large": "https://assets.coingecko.com/coins/images/3157/large/poa-network.png?1548331565", + "small": "https://assets.coingecko.com/coins/images/3157/small/poa-network.png?1548331565", + "thumb": "https://assets.coingecko.com/coins/images/3157/thumb/poa-network.png?1548331565" + }, + "last_updated": "2019-08-21T08:36:49.371Z", + "links": { + "announcement_url": [ + "", + "" + ], + "bitcointalk_thread_identifier": null, + "blockchain_site": [ + "https://blockscout.com/poa/core/", + "", + "", + "", + "" + ], + "chat_url": [ + "", + "", + "" + ], + "facebook_username": "", + "homepage": [ + "https://poa.network/", + "", + "" + ], + "official_forum_url": [ + "", + "", + "" + ], + "repos_url": { + "bitbucket": [], + "github": [ + "https://github.com/poanetwork/poa-network-consensus-contracts" + ] + }, + "subreddit_url": null, + "telegram_channel_identifier": "oraclesnetwork", + "twitter_screen_name": "poanetwork" + }, + "liquidity_score": 19.334, + "localization": { + "ar": "POA Network", + "de": "POA Network", + "en": "POA Network", + "es": "POA Network", + "fr": "POA Network", + "hu": "POA Network", + "id": "POA Network", + "it": "POA Network", + "ja": "ポアネットワーク", + "ko": "POA 네트워크", + "nl": "POA Network", + "pl": "POA Network", + "pt": "POA Network", + "ro": "POA Network", + "ru": "POA Network", + "sv": "POA Network", + "th": "POA Network", + "tr": "POA Network", + "vi": "POA Network", + "zh": "POA Network", + "zh-tw": "POA Network" + }, + "market_cap_rank": 499, + "market_data": { + "ath": { + "aed": 3.06, + "ars": 18.93, + "aud": 1.25, + "bch": 0.00076772, + "bdt": 70.74, + "bhd": 0.314495, + "bmd": 0.833914, + "bnb": 0.01322268, + "brl": 3.36, + "btc": 0.00010137, + "cad": 1.2, + "chf": 0.938803, + "clp": 519.58, + "cny": 5.94, + "czk": 17.83, + "dkk": 5.87, + "eos": 0.02444974, + "eth": 0.0011725, + "eur": 0.787803, + "gbp": 0.689151, + "hkd": 7.35, + "huf": 219.96, + "idr": 13179.33, + "ils": 2.97, + "inr": 62.94, + "jpy": 102.6, + "krw": 1000.83, + "kwd": 0.251571, + "lkr": 131.79, + "ltc": 0.00537407, + "mmk": 1125.41, + "mxn": 18.15, + "myr": 3.76, + "nok": 6.67, + "nzd": 1.35, + "php": 48.59, + "pkr": 96.55, + "pln": 3.34, + "rub": 58.27, + "sar": 3.13, + "sek": 8.13, + "sgd": 1.25, + "thb": 26.65, + "try": 3.54, + "twd": 27.89, + "uah": 1.44, + "usd": 0.935923, + "vef": 58307, + "vnd": 1281.67, + "xag": 0.056398, + "xau": 0.00071129, + "xdr": 0.656022, + "xlm": 0.58965135, + "xrp": 0.2920468, + "zar": 11.63 + }, + "ath_change_percentage": { + "aed": -98.3819, + "ars": -96.09901, + "aud": -98.40941, + "bch": -94.11046, + "bdt": -98.39058, + "bhd": -98.38261, + "bmd": -98.38194, + "bnb": -96.24179, + "brl": -98.37442, + "btc": -98.68937, + "cad": -98.49893, + "chf": -98.59269, + "clp": -98.15517, + "cny": -98.39701, + "czk": -98.2406, + "dkk": -98.45473, + "eos": -84.56025, + "eth": -93.8673, + "eur": -98.45627, + "gbp": -98.38711, + "hkd": -98.55948, + "huf": -98.18974, + "idr": -98.54127, + "ils": -98.39903, + "inr": -98.46908, + "jpy": -98.59899, + "krw": -98.37868, + "kwd": -98.3684, + "lkr": -98.16735, + "ltc": -96.51103, + "mmk": -98.17585, + "mxn": -98.53298, + "myr": -98.49907, + "nok": -98.18519, + "nzd": -98.43938, + "php": -98.54716, + "pkr": -97.76349, + "pln": -98.41583, + "rub": -98.4658, + "sar": -98.3821, + "sek": -98.39542, + "sgd": -98.51152, + "thb": -98.44172, + "try": -97.81784, + "twd": -98.48322, + "uah": -76.52065, + "usd": -98.5583, + "vef": -94.2496, + "vnd": -75.59837, + "xag": -98.59644, + "xau": -98.73411, + "xdr": -98.49988, + "xlm": -66.24383, + "xrp": -82.56607, + "zar": -98.23009 + }, + "ath_date": { + "aed": "2018-05-10T00:00:00.000Z", + "ars": "2018-05-10T00:00:00.000Z", + "aud": "2018-05-10T09:45:31.809Z", + "bch": "2018-04-14T00:00:00.000Z", + "bdt": "2018-05-10T00:00:00.000Z", + "bhd": "2018-05-10T00:00:00.000Z", + "bmd": "2018-05-10T00:00:00.000Z", + "bnb": "2018-10-16T12:40:17.749Z", + "brl": "2018-05-10T09:45:31.809Z", + "btc": "2018-05-10T09:45:31.809Z", + "cad": "2018-05-10T09:45:31.809Z", + "chf": "2018-05-10T09:45:31.809Z", + "clp": "2018-05-10T00:00:00.000Z", + "cny": "2018-05-10T09:45:31.809Z", + "czk": "2018-05-10T00:00:00.000Z", + "dkk": "2018-05-10T09:45:31.809Z", + "eos": "2018-10-16T12:40:17.749Z", + "eth": "2018-04-09T00:00:00.000Z", + "eur": "2018-05-10T09:45:31.809Z", + "gbp": "2018-05-10T09:45:31.809Z", + "hkd": "2018-05-10T09:45:31.809Z", + "huf": "2018-05-10T00:00:00.000Z", + "idr": "2018-05-10T09:45:31.809Z", + "ils": "2018-05-10T00:00:00.000Z", + "inr": "2018-05-10T09:45:31.809Z", + "jpy": "2018-05-10T09:45:31.809Z", + "krw": "2018-05-10T09:45:31.809Z", + "kwd": "2018-05-10T00:00:00.000Z", + "lkr": "2018-05-10T00:00:00.000Z", + "ltc": "2018-05-10T00:00:00.000Z", + "mmk": "2018-05-10T00:00:00.000Z", + "mxn": "2018-05-10T09:45:31.809Z", + "myr": "2018-05-10T09:45:31.809Z", + "nok": "2018-05-10T00:00:00.000Z", + "nzd": "2018-05-10T09:45:31.809Z", + "php": "2018-05-10T09:45:31.809Z", + "pkr": "2018-05-10T00:00:00.000Z", + "pln": "2018-05-10T09:45:31.809Z", + "rub": "2018-05-10T09:45:31.809Z", + "sar": "2018-05-10T00:00:00.000Z", + "sek": "2018-05-10T09:45:31.809Z", + "sgd": "2018-05-10T09:45:31.809Z", + "thb": "2018-05-10T00:00:00.000Z", + "try": "2018-05-10T00:00:00.000Z", + "twd": "2018-05-10T09:45:31.809Z", + "uah": "2019-05-27T12:49:29.532Z", + "usd": "2018-05-10T09:45:31.809Z", + "vef": "2018-05-10T00:00:00.000Z", + "vnd": "2019-05-27T12:49:29.532Z", + "xag": "2018-05-10T09:45:31.809Z", + "xau": "2018-05-10T09:45:31.809Z", + "xdr": "2018-05-10T09:45:31.809Z", + "xlm": "2018-10-16T12:49:26.379Z", + "xrp": "2018-10-16T12:40:17.749Z", + "zar": "2018-05-10T09:45:31.809Z" + }, + "circulating_supply": 220167621.0, + "current_price": { + "aed": 0.04942712, + "ars": 0.73641, + "aud": 0.0198328, + "bch": 4.486e-05, + "bdt": 1.14, + "bhd": 0.00507448, + "bmd": 0.01345698, + "bnb": 0.00049505, + "brl": 0.054544, + "btc": 1.32e-06, + "cad": 0.0178991, + "chf": 0.01317061, + "clp": 9.55, + "cny": 0.095047, + "czk": 0.312629, + "dkk": 0.090366, + "eos": 0.0037559, + "eth": 7.147e-05, + "eur": 0.01211961, + "gbp": 0.01107566, + "hkd": 0.105541, + "huf": 3.97, + "idr": 191.75, + "ils": 0.04745883, + "inr": 0.960893, + "jpy": 1.43, + "krw": 16.19, + "kwd": 0.00409361, + "lkr": 2.4, + "ltc": 0.00018598, + "mmk": 20.47, + "mxn": 0.26536, + "myr": 0.056211, + "nok": 0.120606, + "nzd": 0.02100918, + "php": 0.704042, + "pkr": 2.15, + "pln": 0.052749, + "rub": 0.891153, + "sar": 0.050476, + "sek": 0.129909, + "sgd": 0.01861909, + "thb": 0.414071, + "try": 0.076819, + "twd": 0.422042, + "uah": 0.338308, + "usd": 0.01345698, + "vef": 3343.89, + "vnd": 311.66, + "xag": 0.00078867, + "xau": 8.98e-06, + "xdr": 0.00981471, + "xlm": 0.1975895, + "xrp": 0.05067322, + "zar": 0.204922 + }, + "high_24h": { + "aed": 0.053611, + "ars": 0.810805, + "aud": 0.02152674, + "bch": 4.628e-05, + "bdt": 1.23, + "bhd": 0.00550347, + "bmd": 0.0145949, + "bnb": 0.00052215, + "brl": 0.058875, + "btc": 1.37e-06, + "cad": 0.01943935, + "chf": 0.01428979, + "clp": 10.36, + "cny": 0.103044, + "czk": 0.339287, + "dkk": 0.098076, + "eos": 0.00402026, + "eth": 7.423e-05, + "eur": 0.01315448, + "gbp": 0.01201087, + "hkd": 0.114474, + "huf": 4.31, + "idr": 208.11, + "ils": 0.051491, + "inr": 1.04, + "jpy": 1.55, + "krw": 17.63, + "kwd": 0.00443977, + "lkr": 2.6, + "ltc": 0.00019631, + "mmk": 22.24, + "mxn": 0.288202, + "myr": 0.061014, + "nok": 0.131376, + "nzd": 0.02274396, + "php": 0.76332, + "pkr": 2.34, + "pln": 0.057291, + "rub": 0.972261, + "sar": 0.054726, + "sek": 0.14165, + "sgd": 0.02021141, + "thb": 0.449117, + "try": 0.083602, + "twd": 0.457778, + "uah": 0.367456, + "usd": 0.0145949, + "vef": 3626.65, + "vnd": 338.27, + "xag": 0.00085369, + "xau": 9.72e-06, + "xdr": 0.01064365, + "xlm": 0.20827298, + "xrp": 0.05318558, + "zar": 0.223696 + }, + "last_updated": "2019-08-21T08:36:49.371Z", + "low_24h": { + "aed": 0.0491677, + "ars": 0.732555, + "aud": 0.0197477, + "bch": 4.364e-05, + "bdt": 1.13, + "bhd": 0.00504693, + "bmd": 0.01338635, + "bnb": 0.00049273, + "brl": 0.054256, + "btc": 1.3e-06, + "cad": 0.01782004, + "chf": 0.01311131, + "clp": 9.51, + "cny": 0.094517, + "czk": 0.311235, + "dkk": 0.089982, + "eos": 0.00373147, + "eth": 7.098e-05, + "eur": 0.01206786, + "gbp": 0.01103078, + "hkd": 0.104993, + "huf": 3.95, + "idr": 190.79, + "ils": 0.04723279, + "inr": 0.958004, + "jpy": 1.43, + "krw": 16.1, + "kwd": 0.00406945, + "lkr": 2.39, + "ltc": 0.00018228, + "mmk": 20.37, + "mxn": 0.264134, + "myr": 0.055903, + "nok": 0.120189, + "nzd": 0.02091282, + "php": 0.700581, + "pkr": 2.14, + "pln": 0.052569, + "rub": 0.886879, + "sar": 0.050214, + "sek": 0.129578, + "sgd": 0.01853166, + "thb": 0.412199, + "try": 0.076627, + "twd": 0.4198, + "uah": 0.336532, + "usd": 0.01338635, + "vef": 3326.34, + "vnd": 310.32, + "xag": 0.00078625, + "xau": 8.93e-06, + "xdr": 0.0097632, + "xlm": 0.19635382, + "xrp": 0.05037993, + "zar": 0.204544 + }, + "market_cap": { + "aed": 10882251, + "ars": 162133701, + "aud": 4366541, + "bch": 9877, + "bdt": 249997342, + "bhd": 1117236, + "bmd": 2962791, + "bnb": 108994, + "brl": 12008719, + "btc": 290.732, + "cad": 3940802, + "chf": 2899743, + "clp": 2101619696, + "cny": 20926193, + "czk": 68830802, + "dkk": 19895675, + "eos": 826927, + "eth": 15736, + "eur": 2668346, + "gbp": 2438501, + "hkd": 23236814, + "huf": 873552757, + "idr": 42217105275, + "ils": 10448899, + "inr": 211557455, + "jpy": 315583737, + "krw": 3564593111, + "kwd": 901281, + "lkr": 529480380, + "ltc": 40948, + "mmk": 4507718929, + "mxn": 58423768, + "myr": 12375904, + "nok": 26553448, + "nzd": 4625542, + "php": 155007300, + "pkr": 474133000, + "pln": 11613646, + "rub": 196202962, + "sar": 11113192, + "sek": 28601664, + "sgd": 4099321, + "thb": 91165079, + "try": 16912998, + "twd": 92920077, + "uah": 74484427, + "usd": 2962791, + "vef": 736216950688, + "vnd": 68617204931, + "xag": 173639, + "xau": 1976.89, + "xdr": 2160882, + "xlm": 43502811, + "xrp": 11156602, + "zar": 45117091 + }, + "market_cap_change_24h": -160615.84039035, + "market_cap_change_24h_in_currency": { + "aed": -590899.65443375, + "ars": -9124373.5980551, + "aud": -239353.78003874, + "bch": 102.549, + "bdt": -13867874.4362154, + "bhd": -60251.00254582, + "bmd": -160615.84039035, + "bnb": -1507.543569741, + "brl": -718070.38245432, + "btc": 0.03769596, + "cad": -221121.61427417, + "chf": -161095.94704691, + "clp": -127118490.79824165, + "cny": -1134429.68067712, + "czk": -3925858.7665586, + "dkk": -1136450.3780936, + "eos": -24548.1071608166, + "eth": -56.533938946, + "eur": -152193.5816755, + "gbp": -144996.42715597, + "hkd": -1263688.72303977, + "huf": -48860628.81047357, + "idr": -2346101857.217293, + "ils": -576162.08791993, + "inr": -12451722.53525829, + "jpy": -16857632.06248754, + "krw": -209731718.0214291, + "kwd": -49171.67933105, + "lkr": -26048761.01962376, + "ltc": -309.0831858893, + "mmk": -251710124.48363495, + "mxn": -3503488.89323037, + "myr": -687829.52792143, + "nok": -1513569.75537506, + "nzd": -244980.03753899, + "php": -8388263.35503852, + "pkr": -26642819.2931419, + "pln": -696325.10549893, + "rub": -12221976.62125358, + "sar": -601457.67784725, + "sek": -1668070.90346983, + "sgd": -230174.18438848, + "thb": -5107689.97148955, + "try": -927927.24538566, + "twd": -5107834.82635887, + "uah": -4241989.31565817, + "usd": -160615.84039035, + "vef": -39911051485.156494, + "vnd": -4088394297.5983276, + "xag": -9606.58322042, + "xau": -102.32803274, + "xdr": -115659.93877989, + "xlm": -1276957.0373063833, + "xrp": -122973.5124849025, + "zar": -2969034.78716005 + }, + "market_cap_change_percentage_24h": -5.14233, + "market_cap_change_percentage_24h_in_currency": { + "aed": -5.15028, + "ars": -5.32785, + "aud": -5.19668, + "bch": 1.0491, + "bdt": -5.25567, + "bhd": -5.11691, + "bmd": -5.14233, + "bnb": -1.36428, + "brl": -5.6422, + "btc": 0.01297, + "cad": -5.31297, + "chf": -5.26313, + "clp": -5.70361, + "cny": -5.14233, + "czk": -5.39588, + "dkk": -5.4034, + "eos": -2.88301, + "eth": -0.35797, + "eur": -5.3959, + "gbp": -5.61241, + "hkd": -5.15781, + "huf": -5.29704, + "idr": -5.26466, + "ils": -5.22593, + "inr": -5.55858, + "jpy": -5.07086, + "krw": -5.5568, + "kwd": -5.1735, + "lkr": -4.689, + "ltc": -0.74917, + "mmk": -5.28866, + "mxn": -5.65743, + "myr": -5.26518, + "nok": -5.3927, + "nzd": -5.02985, + "php": -5.13372, + "pkr": -5.32031, + "pln": -5.65659, + "rub": -5.86397, + "sar": -5.13424, + "sek": -5.51069, + "sgd": -5.31642, + "thb": -5.30544, + "try": -5.20112, + "twd": -5.21059, + "uah": -5.38827, + "usd": -5.14233, + "vef": -5.14233, + "vnd": -5.62322, + "xag": -5.24248, + "xau": -4.92146, + "xdr": -5.08051, + "xlm": -2.85164, + "xrp": -1.09023, + "zar": -6.17441 + }, + "market_cap_rank": 499, + "price_change_24h": -0.00070501, + "price_change_24h_in_currency": { + "aed": -0.00259384, + "ars": -0.0401764, + "aud": -0.00106049, + "bch": 4.401e-07, + "bdt": -0.06091731, + "bhd": -0.00026442, + "bmd": -0.00070501, + "bnb": -7.9537e-06, + "brl": -0.00316161, + "btc": -7e-10, + "cad": -0.000975, + "chf": -0.00070391, + "clp": -0.55975334, + "cny": -0.00498938, + "czk": -0.01720638, + "dkk": -0.00497873, + "eos": -0.0001041039, + "eth": -1.756e-07, + "eur": -0.00066664, + "gbp": -0.00063744, + "hkd": -0.00554812, + "huf": -0.21652693, + "idr": -10.32117361, + "ils": -0.00254123, + "inr": -0.05433204, + "jpy": -0.07396812, + "krw": -0.92440016, + "kwd": -0.00021588, + "lkr": -0.11324611, + "ltc": -1.1432e-06, + "mmk": -1.10591975, + "mxn": -0.01564173, + "myr": -0.00303114, + "nok": -0.0066618, + "nzd": -0.00108422, + "php": -0.03666507, + "pkr": -0.11708205, + "pln": -0.0030605, + "rub": -0.05396307, + "sar": -0.00263569, + "sek": -0.00737328, + "sgd": -0.00101489, + "thb": -0.02240118, + "try": -0.00415931, + "twd": -0.02243055, + "uah": -0.01864934, + "usd": -0.00070501, + "vef": -175.18566197, + "vnd": -17.91454955, + "xag": -4.268e-05, + "xau": -4.5e-07, + "xdr": -0.00050746, + "xlm": -0.0043814329, + "xrp": -0.0005808077, + "zar": -0.01325238 + }, + "price_change_percentage_14d": -20.09212, + "price_change_percentage_14d_in_currency": { + "aed": -20.09664, + "ars": -3.40252, + "aud": -20.3743, + "bch": -10.35771, + "bdt": -20.21051, + "bhd": -20.07198, + "bmd": -20.09212, + "bnb": -18.90438, + "brl": -18.21564, + "btc": -10.20835, + "cad": -19.99931, + "chf": -19.86474, + "clp": -20.70274, + "cny": -19.67703, + "czk": -19.20224, + "dkk": -19.44946, + "eos": -6.27667, + "eth": -3.85819, + "eur": -19.3615, + "gbp": -19.99287, + "hkd": -20.04155, + "huf": -18.72941, + "idr": -19.92585, + "ils": -19.11955, + "inr": -19.53455, + "jpy": -19.93789, + "krw": -20.72061, + "kwd": -20.08213, + "lkr": -19.39749, + "ltc": 3.01755, + "mmk": -19.52559, + "mxn": -19.64657, + "myr": -20.39088, + "nok": -19.55283, + "nzd": -18.54, + "php": -19.79625, + "pkr": -19.69932, + "pln": -18.70635, + "rub": -18.9447, + "sar": -20.11299, + "sek": -19.43426, + "sgd": -19.93866, + "thb": -19.96922, + "try": -17.50796, + "twd": -20.26871, + "uah": -21.43567, + "usd": -20.09212, + "vef": -20.09212, + "vnd": -20.39781, + "xag": -22.82706, + "xau": -21.25807, + "xdr": -19.80447, + "xlm": -6.90503, + "xrp": -5.82792, + "zar": -18.53383 + }, + "price_change_percentage_1h_in_currency": { + "aed": -0.65082, + "ars": -0.65814, + "aud": -0.81241, + "bch": 1.34916, + "bdt": -0.64945, + "bhd": -0.62736, + "bmd": -0.65082, + "bnb": -0.66128, + "brl": -0.65109, + "btc": -0.64949, + "cad": -0.75327, + "chf": -0.6566, + "clp": -0.81121, + "cny": -0.61001, + "czk": -0.71198, + "dkk": -0.72865, + "eos": -0.27623, + "eth": -0.72711, + "eur": -0.73062, + "gbp": -0.79594, + "hkd": -0.65424, + "huf": -0.65304, + "idr": -0.69877, + "ils": -0.68895, + "inr": -0.85681, + "jpy": -0.70261, + "krw": -0.64504, + "kwd": -0.68347, + "lkr": -0.66193, + "ltc": 0.20669, + "mmk": -0.65082, + "mxn": -0.79588, + "myr": -0.58632, + "nok": -0.94166, + "nzd": -0.77361, + "php": -0.65651, + "pkr": -0.65082, + "pln": -0.82133, + "rub": -0.80523, + "sar": -0.62904, + "sek": -0.92466, + "sgd": -0.72845, + "thb": -0.71559, + "try": -0.93842, + "twd": -0.63818, + "uah": -0.65082, + "usd": -0.65082, + "vef": -0.65082, + "vnd": -0.72098, + "xag": -0.86625, + "xau": -0.66422, + "xdr": -0.65082, + "xlm": -0.6397, + "xrp": -0.05073, + "zar": -1.25864 + }, + "price_change_percentage_1y": -80.39683, + "price_change_percentage_1y_in_currency": { + "aed": -80.39794, + "ars": -61.05676, + "aud": -78.80429, + "bch": -66.67604, + "bdt": -80.26581, + "bhd": -80.39891, + "bmd": -80.39683, + "brl": -79.97401, + "btc": -87.93415, + "cad": -80.00734, + "chf": -80.63119, + "clp": -79.21186, + "cny": -79.80673, + "czk": -79.67769, + "dkk": -79.72199, + "eth": -71.77736, + "eur": -79.71573, + "gbp": -79.34655, + "hkd": -80.41399, + "huf": -79.49619, + "idr": -80.5156, + "ils": -81.08059, + "inr": -79.93604, + "jpy": -81.01454, + "krw": -78.90452, + "kwd": -80.34132, + "lkr": -78.15787, + "ltc": -85.4361, + "mmk": -80.27721, + "mxn": -79.65762, + "myr": -80.02222, + "nok": -79.18424, + "nzd": -79.67365, + "php": -80.76747, + "pkr": -74.51734, + "pln": -79.50758, + "rub": -80.62327, + "sar": -80.39647, + "sek": -79.31728, + "sgd": -80.18923, + "thb": -81.67711, + "try": -81.65737, + "twd": -79.98887, + "uah": -82.20648, + "usd": -80.39683, + "vef": -80.39558, + "vnd": -80.34916, + "xag": -83.03235, + "xau": -84.4215, + "xdr": -80.03907, + "zar": -79.43625 + }, + "price_change_percentage_200d": -50.1114, + "price_change_percentage_200d_in_currency": { + "aed": -50.11196, + "ars": -26.51722, + "aud": -46.67198, + "bch": -80.79243, + "bdt": -49.71149, + "bhd": -50.09578, + "bmd": -50.1114, + "bnb": -87.93302, + "brl": -44.75887, + "btc": -83.02991, + "cad": -49.34427, + "chf": -50.94689, + "clp": -45.88183, + "cny": -47.75857, + "czk": -48.37087, + "dkk": -48.59098, + "eos": -67.57399, + "eth": -71.6239, + "eur": -48.52075, + "gbp": -46.27358, + "hkd": -50.136, + "huf": -46.91923, + "idr": -49.00487, + "ils": -51.63145, + "inr": -50.15368, + "jpy": -51.46878, + "krw": -46.36111, + "kwd": -49.91845, + "lkr": -49.53248, + "ltc": -77.44522, + "mmk": -49.82943, + "mxn": -48.49618, + "myr": -49.12989, + "nok": -47.01887, + "nzd": -46.2816, + "php": -50.10377, + "pkr": -42.33563, + "pln": -47.7461, + "rub": -49.52654, + "sar": -50.10515, + "sek": -46.7992, + "sgd": -48.88484, + "thb": -50.95616, + "try": -45.32063, + "twd": -49.1634, + "uah": -54.76622, + "usd": -50.1114, + "vef": -50.1114, + "vnd": -50.2089, + "xag": -53.50147, + "xau": -56.13406, + "xdr": -49.07152, + "xlm": -39.53366, + "xrp": -42.37148, + "zar": -42.98063 + }, + "price_change_percentage_24h": -4.97817, + "price_change_percentage_24h_in_currency": { + "aed": -4.98614, + "ars": -5.17346, + "aud": -5.07575, + "bch": 0.99066, + "bdt": -5.0917, + "bhd": -4.95271, + "bmd": -4.97817, + "bnb": -1.58124, + "brl": -5.4789, + "btc": -0.05257, + "cad": -5.16583, + "chf": -5.07341, + "clp": -5.53921, + "cny": -4.98758, + "czk": -5.21666, + "dkk": -5.22182, + "eos": -2.69699, + "eth": -0.24506, + "eur": -5.21371, + "gbp": -5.44209, + "hkd": -4.99428, + "huf": -5.17487, + "idr": -5.1077, + "ils": -5.08246, + "inr": -5.35173, + "jpy": -4.90717, + "krw": -5.40119, + "kwd": -5.00939, + "lkr": -4.49721, + "ltc": -0.61091, + "mmk": -5.12476, + "mxn": -5.56641, + "myr": -5.1165, + "nok": -5.23449, + "nzd": -4.90745, + "php": -4.95001, + "pkr": -5.15646, + "pln": -5.48383, + "rub": -5.70968, + "sar": -4.96254, + "sek": -5.3709, + "sgd": -5.16905, + "thb": -5.13232, + "try": -5.13634, + "twd": -5.04655, + "uah": -5.22453, + "usd": -4.97817, + "vef": -4.97817, + "vnd": -5.43568, + "xag": -5.1341, + "xau": -4.8084, + "xdr": -4.91624, + "xlm": -2.16934, + "xrp": -1.13319, + "zar": -6.07423 + }, + "price_change_percentage_30d": -34.83569, + "price_change_percentage_30d_in_currency": { + "aed": -34.83544, + "ars": -15.98426, + "aud": -32.35353, + "bch": -30.11906, + "bdt": -34.93771, + "bhd": -34.7457, + "bmd": -34.83569, + "bnb": -27.08407, + "brl": -29.51868, + "btc": -32.08124, + "cad": -33.60701, + "chf": -35.09987, + "clp": -32.84418, + "cny": -33.12269, + "czk": -33.51308, + "dkk": -34.24389, + "eos": -21.08346, + "eth": -21.69788, + "eur": -34.16271, + "gbp": -32.89529, + "hkd": -34.53494, + "huf": -33.76133, + "idr": -33.48833, + "ils": -35.07099, + "inr": -32.4077, + "jpy": -35.60577, + "krw": -33.33925, + "kwd": -34.83162, + "lkr": -33.78522, + "ltc": -10.07379, + "mmk": -34.67478, + "mxn": -32.46726, + "myr": -33.79734, + "nok": -31.87864, + "nzd": -31.23716, + "php": -33.28065, + "pkr": -34.80085, + "pln": -32.59928, + "rub": -31.5309, + "sar": -34.83447, + "sek": -32.96828, + "sgd": -33.73135, + "thb": -35.04678, + "try": -34.23351, + "twd": -34.17354, + "uah": -36.37221, + "usd": -34.83569, + "vef": -34.83569, + "vnd": -35.19581, + "xag": -38.03606, + "xau": -38.0235, + "xdr": -34.25025, + "xlm": -12.74201, + "xrp": -18.8697, + "zar": -28.75132 + }, + "price_change_percentage_60d": -61.24989, + "price_change_percentage_60d_in_currency": { + "aed": -61.25202, + "ars": -50.32249, + "aud": -60.412, + "bch": -43.0945, + "bdt": -61.20391, + "bhd": -61.23344, + "bmd": -61.24989, + "bnb": -44.49169, + "brl": -58.90604, + "btc": -61.42639, + "cad": -61.04496, + "chf": -61.10703, + "clp": -59.79652, + "cny": -60.16104, + "czk": -60.03065, + "dkk": -60.38034, + "eos": -23.51938, + "eth": -39.23291, + "eur": -60.26215, + "gbp": -59.36192, + "hkd": -61.10542, + "huf": -59.91464, + "idr": -60.90777, + "ils": -62.26651, + "inr": -60.23354, + "jpy": -61.53855, + "krw": -59.78067, + "kwd": -61.16844, + "lkr": -60.71768, + "ltc": -25.65935, + "mmk": -61.20413, + "mxn": -60.04539, + "myr": -60.87356, + "nok": -59.13075, + "nzd": -60.12056, + "php": -60.49041, + "pkr": -60.53743, + "pln": -59.42569, + "rub": -59.28727, + "sar": -61.24451, + "sek": -59.99926, + "sgd": -60.43237, + "thb": -61.1805, + "try": -62.00162, + "twd": -60.74424, + "uah": -62.83383, + "usd": -61.24989, + "vef": -61.24989, + "vnd": -61.16958, + "xag": -65.19693, + "xau": -63.82007, + "xdr": -60.62729, + "xlm": -29.85582, + "xrp": -35.11899, + "zar": -58.83133 + }, + "price_change_percentage_7d": -12.91815, + "price_change_percentage_7d_in_currency": { + "aed": -12.92308, + "ars": -14.25115, + "aud": -12.76443, + "bch": 0.88592, + "bdt": -13.147, + "bhd": -12.88673, + "bmd": -12.91815, + "bnb": -5.78627, + "brl": -10.95714, + "btc": -6.92663, + "cad": -12.35787, + "chf": -12.68629, + "clp": -12.25865, + "cny": -12.67706, + "czk": -12.47009, + "dkk": -12.42719, + "eos": -0.91188, + "eth": -3.2526, + "eur": -12.3442, + "gbp": -13.56715, + "hkd": -12.94473, + "huf": -11.29007, + "idr": -13.63998, + "ils": -11.80257, + "inr": -12.53093, + "jpy": -12.98836, + "krw": -13.1693, + "kwd": -12.90068, + "lkr": -11.99684, + "ltc": 1.8824, + "mmk": -12.2934, + "mxn": -11.39186, + "myr": -13.13461, + "nok": -11.99025, + "nzd": -12.14546, + "php": -12.50757, + "pkr": -13.04362, + "pln": -11.96443, + "rub": -11.16958, + "sar": -12.91768, + "sek": -11.88369, + "sgd": -12.90808, + "thb": -12.98884, + "try": -10.77039, + "twd": -12.26523, + "uah": -12.97908, + "usd": -12.91815, + "vef": -12.91815, + "vnd": -13.40154, + "xag": -13.34686, + "xau": -12.77828, + "xdr": -12.6042, + "xlm": -3.71389, + "xrp": -2.40223, + "zar": -12.40714 + }, + "roi": null, + "total_supply": 252193195.0, + "total_volume": { + "aed": 440559, + "ars": 6563849, + "aud": 176776, + "bch": 399.879, + "bdt": 10120936, + "bhd": 45230, + "bmd": 119946, + "bnb": 4413, + "brl": 486163, + "btc": 11.770053, + "cad": 159540, + "chf": 117394, + "clp": 85082341, + "cny": 847180, + "czk": 2786558, + "dkk": 805460, + "eos": 33477, + "eth": 637.075, + "eur": 108026, + "gbp": 98721, + "hkd": 940723, + "huf": 35365063, + "idr": 1709124708, + "ils": 423015, + "inr": 8564729, + "jpy": 12776147, + "krw": 144309614, + "kwd": 36488, + "lkr": 21435577, + "ltc": 1658, + "mmk": 182491285, + "mxn": 2365238, + "myr": 501028, + "nok": 1074994, + "nzd": 187261, + "php": 6275343, + "pkr": 19194884, + "pln": 470169, + "rub": 7943115, + "sar": 449908, + "sek": 1157915, + "sgd": 165958, + "thb": 3690743, + "try": 684709, + "twd": 3761793, + "uah": 3015441, + "usd": 119946, + "vef": 29805136391, + "vnd": 2777910981, + "xag": 7029.61, + "xau": 80.03, + "xdr": 87482, + "xlm": 1761175, + "xrp": 451666, + "zar": 1826528 + } + }, + "name": "POA Network", + "public_interest_score": 27.778, + "public_interest_stats": { + "alexa_rank": 702581, + "bing_matches": 107000 + }, + "sentiment_votes_down_percentage": null, + "sentiment_votes_up_percentage": null, + "status_updates": [], + "symbol": "poa", + "tickers": [ + { + "base": "POA", + "bid_ask_spread_percentage": 1.503759, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.32e-06, + "eth": 7.139e-05, + "usd": 0.01344331 + }, + "converted_volume": { + "btc": 10.856044, + "eth": 587.121, + "usd": 110562 + }, + "is_anomaly": false, + "is_stale": false, + "last": 1.32e-06, + "last_fetch_at": "2019-08-21T08:34:21+00:00", + "last_traded_at": "2019-08-21T08:34:21+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "binance", + "name": "Binance" + }, + "target": "BTC", + "timestamp": "2019-08-21T08:34:21+00:00", + "trade_url": "https://www.binance.com/trade.html?symbol=POA_BTC", + "trust_score": "green", + "volume": 8224275.5227272725 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 1.729386, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.34e-06, + "eth": 7.226e-05, + "usd": 0.01360764 + }, + "converted_volume": { + "btc": 0.35219856, + "eth": 19.04774, + "usd": 3586.91 + }, + "is_anomaly": false, + "is_stale": false, + "last": 7.238e-05, + "last_fetch_at": "2019-08-21T08:34:26+00:00", + "last_traded_at": "2019-08-21T08:34:26+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "binance", + "name": "Binance" + }, + "target": "ETH", + "timestamp": "2019-08-21T08:34:26+00:00", + "trade_url": "https://www.binance.com/trade.html?symbol=POA_ETH", + "trust_score": "green", + "volume": 263595.07819839736 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 1.39165, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.34e-06, + "eth": 7.259e-05, + "usd": 0.01363846 + }, + "converted_volume": { + "btc": 0.24038472, + "eth": 13.008637, + "usd": 2444.17 + }, + "is_anomaly": false, + "is_stale": false, + "last": 0.000502, + "last_fetch_at": "2019-08-21T08:34:26+00:00", + "last_traded_at": "2019-08-21T08:13:08+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "binance", + "name": "Binance" + }, + "target": "BNB", + "timestamp": "2019-08-21T08:13:08+00:00", + "trade_url": "https://www.binance.com/trade.html?symbol=POA_BNB", + "trust_score": "green", + "volume": 179211.83864541832 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 2.985075, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.3e-06, + "eth": 7.036e-05, + "usd": 0.01324803 + }, + "converted_volume": { + "btc": 0.1595777, + "eth": 8.637423, + "usd": 1626.22 + }, + "is_anomaly": false, + "is_stale": false, + "last": 1.3e-06, + "last_fetch_at": "2019-08-21T08:36:07+00:00", + "last_traded_at": "2019-08-21T08:36:07+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "bibox", + "name": "Bibox" + }, + "target": "BTC", + "timestamp": "2019-08-21T08:36:07+00:00", + "trade_url": "https://www.bibox.com/exchange?coinPair=POA_BTC", + "trust_score": "yellow", + "volume": 122752.0737 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 3.247202, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.31e-06, + "eth": 7.077e-05, + "usd": 0.01332498 + }, + "converted_volume": { + "btc": 0.1127777, + "eth": 6.104291, + "usd": 1149.29 + }, + "is_anomaly": false, + "is_stale": false, + "last": 7.087e-05, + "last_fetch_at": "2019-08-21T08:35:50+00:00", + "last_traded_at": "2019-08-21T08:35:50+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "bibox", + "name": "Bibox" + }, + "target": "ETH", + "timestamp": "2019-08-21T08:35:50+00:00", + "trade_url": "https://www.bibox.com/exchange?coinPair=POA_ETH", + "trust_score": "yellow", + "volume": 86251.0552 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": 13.032676, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.16e-06, + "eth": 6.257e-05, + "usd": 0.01177973 + }, + "converted_volume": { + "btc": 0.00087672, + "eth": 0.04748752, + "usd": 8.94 + }, + "is_anomaly": false, + "is_stale": false, + "last": 1.1551e-06, + "last_fetch_at": "2019-08-21T08:37:38+00:00", + "last_traded_at": "2019-08-21T07:08:25+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "BTC", + "timestamp": "2019-08-21T07:08:25+00:00", + "trade_url": "https://hitbtc.com/POA20-to-BTC", + "trust_score": "red", + "volume": 759.0 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": 33.072445, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.57e-06, + "eth": 8.48e-05, + "usd": 0.01595278 + }, + "converted_volume": { + "btc": 0.00021915, + "eth": 0.0118714, + "usd": 2.23 + }, + "is_anomaly": false, + "is_stale": false, + "last": 8.4891e-05, + "last_fetch_at": "2019-08-21T08:37:21+00:00", + "last_traded_at": "2019-08-21T07:37:25+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "ETH", + "timestamp": "2019-08-21T07:37:25+00:00", + "trade_url": "https://hitbtc.com/POA20-to-ETH", + "trust_score": "red", + "volume": 140.0 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": 53.1004, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.15e-06, + "eth": 6.232e-05, + "usd": 0.0117249 + }, + "converted_volume": { + "btc": 7.478e-05, + "eth": 0.00405098, + "usd": 0.762119 + }, + "is_anomaly": false, + "is_stale": false, + "last": 0.0117249, + "last_fetch_at": "2019-08-21T08:37:46+00:00", + "last_traded_at": "2019-08-21T07:37:33+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "USD", + "timestamp": "2019-08-21T07:37:33+00:00", + "trade_url": "https://hitbtc.com/POA20-to-USD", + "trust_score": null, + "volume": 65.0 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": null, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.32e-06, + "eth": 7.134e-05, + "usd": 0.01339322 + }, + "converted_volume": { + "btc": 0.03831341, + "eth": 2.073192, + "usd": 389.22 + }, + "is_anomaly": false, + "is_stale": false, + "last": 0.034733328618915156, + "last_fetch_at": "2019-08-21T08:21:59+00:00", + "last_traded_at": "2019-08-21T08:21:59+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "bancor", + "name": "Bancor Network" + }, + "target": "BNT", + "timestamp": "2019-08-21T08:21:59+00:00", + "trade_url": null, + "trust_score": null, + "volume": 29061.03634563883 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": null, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.31e-06, + "eth": 7.074e-05, + "usd": 0.0132809 + }, + "converted_volume": { + "btc": 0.009587, + "eth": 0.51876605, + "usd": 97.39 + }, + "is_anomaly": false, + "is_stale": false, + "last": 7.0704231362995e-05, + "last_fetch_at": "2019-08-21T08:26:12+00:00", + "last_traded_at": "2019-08-21T08:21:13+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "uniswap", + "name": "Uniswap" + }, + "target": "ETH", + "timestamp": "2019-08-21T08:21:13+00:00", + "trade_url": null, + "trust_score": null, + "volume": 7333.316809051611 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 40.083051, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.33e-06, + "eth": 7.005e-05, + "usd": 0.01377146 + }, + "converted_volume": { + "btc": 0.0022752, + "eth": 0.12002061, + "usd": 23.59 + }, + "is_anomaly": false, + "is_stale": true, + "last": 7.004e-05, + "last_fetch_at": "2019-08-21T08:32:14+00:00", + "last_traded_at": "2019-08-18T18:43:13+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "ethfinex", + "name": "Ethfinex" + }, + "target": "ETH", + "timestamp": "2019-08-18T18:43:13+00:00", + "trade_url": "https://ethfinex.com", + "trust_score": "red", + "volume": 1713.3067 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 44.440399, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.33e-06, + "eth": 7.311e-05, + "usd": 0.013499 + }, + "converted_volume": { + "btc": 0.00442255, + "eth": 0.24305992, + "usd": 44.88 + }, + "is_anomaly": false, + "is_stale": true, + "last": 0.013499, + "last_fetch_at": "2019-08-21T08:32:13+00:00", + "last_traded_at": "2019-08-14T17:19:27+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "ethfinex", + "name": "Ethfinex" + }, + "target": "USD", + "timestamp": "2019-08-14T17:19:27+00:00", + "trade_url": "https://ethfinex.com", + "trust_score": "red", + "volume": 3324.44883078 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 14.012015, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.36e-06, + "eth": 7.49e-05, + "usd": 0.01446844 + }, + "converted_volume": { + "btc": 5.45e-06, + "eth": 0.00029958, + "usd": 0.057874 + }, + "is_anomaly": false, + "is_stale": true, + "last": 7.4743e-05, + "last_fetch_at": "2019-08-21T08:37:09+00:00", + "last_traded_at": "2019-08-21T02:52:09+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "ETH", + "timestamp": "2019-08-21T02:52:09+00:00", + "trade_url": "https://hitbtc.com/POA-to-ETH", + "trust_score": null, + "volume": 4.0 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 64.645979, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.36e-06, + "eth": 7.473e-05, + "usd": 0.01443604 + }, + "converted_volume": { + "btc": 2.72e-06, + "eth": 0.00014946, + "usd": 0.02887207 + }, + "is_anomaly": false, + "is_stale": true, + "last": 0.0143016, + "last_fetch_at": "2019-08-21T08:37:44+00:00", + "last_traded_at": "2019-08-21T02:52:25+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "DAI", + "timestamp": "2019-08-21T02:52:25+00:00", + "trade_url": "https://hitbtc.com/POA-to-DAI", + "trust_score": null, + "volume": 2.0 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 64.353312, + "coin_id": "poa-network", + "converted_last": { + "btc": 2.23e-06, + "eth": 0.00012505, + "usd": 0.02310309 + }, + "converted_volume": { + "btc": 0.00275182, + "eth": 0.15430951, + "usd": 28.51 + }, + "is_anomaly": true, + "is_stale": true, + "last": 2.23e-06, + "last_fetch_at": "2019-08-21T08:32:12+00:00", + "last_traded_at": "2019-08-17T12:50:06+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "ethfinex", + "name": "Ethfinex" + }, + "target": "BTC", + "timestamp": "2019-08-17T12:50:06+00:00", + "trade_url": "https://ethfinex.com", + "trust_score": "red", + "volume": 1234.0 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 21.080977, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.23e-06, + "eth": 6.72e-05, + "usd": 0.01322824 + }, + "converted_volume": { + "btc": 0.0, + "eth": 0.0, + "usd": 0.0 + }, + "is_anomaly": true, + "is_stale": true, + "last": 1.2331e-06, + "last_fetch_at": "2019-08-21T08:37:17+00:00", + "last_traded_at": "2019-08-20T18:50:31+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "BTC", + "timestamp": "2019-08-20T18:50:31+00:00", + "trade_url": "https://hitbtc.com/POA-to-BTC", + "trust_score": null, + "volume": 0.0 + }, + { + "base": "POA", + "bid_ask_spread_percentage": 36.441715, + "coin_id": "poa-network", + "converted_last": { + "btc": 1.22e-06, + "eth": 6.66e-05, + "usd": 0.0131106 + }, + "converted_volume": { + "btc": 0.0, + "eth": 0.0, + "usd": 0.0 + }, + "is_anomaly": true, + "is_stale": true, + "last": 0.0131106, + "last_fetch_at": "2019-08-21T08:37:14+00:00", + "last_traded_at": "2019-08-20T18:50:15+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "USD", + "timestamp": "2019-08-20T18:50:15+00:00", + "trade_url": "https://hitbtc.com/POA-to-USD", + "trust_score": null, + "volume": 0.0 + }, + { + "base": "POA20", + "bid_ask_spread_percentage": 70.656026, + "coin_id": "poa-network", + "converted_last": { + "btc": 7.522e-07, + "eth": 4.006e-05, + "usd": 0.0080416 + }, + "converted_volume": { + "btc": 0.0, + "eth": 0.0, + "usd": 0.0 + }, + "is_anomaly": true, + "is_stale": true, + "last": 0.008, + "last_fetch_at": "2019-08-21T08:37:29+00:00", + "last_traded_at": "2019-08-19T09:09:06+00:00", + "market": { + "has_trading_incentive": false, + "identifier": "hitbtc", + "name": "HitBTC" + }, + "target": "DAI", + "timestamp": "2019-08-19T09:09:06+00:00", + "trade_url": "https://hitbtc.com/POA20-to-DAI", + "trust_score": null, + "volume": 0.0 + } + ] +} From 6b2f2717fe1b494c70e71968c9c0296598d00595 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:21 +0000 Subject: [PATCH 229/290] Bump tar from 2.2.1 to 2.2.2 in /apps/block_scout_web/assets Bumps [tar](https://github.com/npm/node-tar) from 2.2.1 to 2.2.2. - [Release notes](https://github.com/npm/node-tar/releases) - [Commits](https://github.com/npm/node-tar/compare/v2.2.1...v2.2.2) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 129 +++++++++++++----- 1 file changed, 95 insertions(+), 34 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index a03732e4e0..8f53f370d1 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -4293,6 +4293,16 @@ "readable-stream": "^2.0.0" } }, + "fs-minipass": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", + "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -4375,9 +4385,7 @@ "chownr": { "version": "1.0.1", "resolved": false, - "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", - "dev": true, - "optional": true + "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=" }, "code-point-at": { "version": "1.1.0", @@ -4442,8 +4450,6 @@ "version": "1.2.5", "resolved": false, "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", - "dev": true, - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -4577,7 +4583,6 @@ "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", - "dev": true, "optional": true, "requires": { "safe-buffer": "^5.1.1", @@ -4588,8 +4593,6 @@ "version": "1.1.0", "resolved": false, "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", - "dev": true, - "optional": true, "requires": { "minipass": "^2.2.1" } @@ -4799,7 +4802,6 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, "optional": true }, "safer-buffer": { @@ -4876,22 +4878,6 @@ "dev": true, "optional": true }, - "tar": { - "version": "4.4.1", - "resolved": false, - "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.0.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.2.4", - "minizlib": "^1.1.0", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.1", - "yallist": "^3.0.2" - } - }, "util-deprecate": { "version": "1.0.2", "resolved": false, @@ -4920,7 +4906,6 @@ "version": "3.0.2", "resolved": false, "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", - "dev": true, "optional": true } } @@ -6024,7 +6009,7 @@ }, "callsites": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", "dev": true }, @@ -6226,7 +6211,7 @@ }, "jest-get-type": { "version": "22.4.3", - "resolved": "http://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz", "integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==", "dev": true }, @@ -7422,6 +7407,36 @@ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + }, + "dependencies": { + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "dev": true, + "optional": true + } + } + }, + "minizlib": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", + "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, "mississippi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", @@ -7608,6 +7623,31 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true + }, + "tar": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", + "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "dev": true, + "requires": { + "block-stream": "*", + "fstream": "^1.0.12", + "inherits": "2" + }, + "dependencies": { + "fstream": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "inherits": "~2.0.0", + "mkdirp": ">=0.5 0", + "rimraf": "2" + } + } + } } } }, @@ -10720,14 +10760,35 @@ "dev": true }, "tar": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", - "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "version": "4.4.10", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.10.tgz", + "integrity": "sha512-g2SVs5QIxvo6OLp0GudTqEf05maawKUxXru104iaayWA09551tFCTI8f1Asb4lPfkBr91k07iL4c11XO3/b0tA==", "dev": true, + "optional": true, "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.3.5", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + }, + "dependencies": { + "chownr": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz", + "integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==", + "dev": true, + "optional": true + }, + "yallist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", + "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "dev": true, + "optional": true + } } }, "terser": { From a849118d70b21acc757e19b0cec7e7cc63e532f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:21 +0000 Subject: [PATCH 230/290] Bump fstream from 1.0.11 to 1.0.12 in /apps/block_scout_web/assets Bumps [fstream](https://github.com/npm/fstream) from 1.0.11 to 1.0.12. - [Release notes](https://github.com/npm/fstream/releases) - [Commits](https://github.com/npm/fstream/compare/v1.0.11...v1.0.12) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 8f53f370d1..1359939cdc 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -4911,9 +4911,9 @@ } }, "fstream": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", - "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", + "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", "dev": true, "requires": { "graceful-fs": "^4.1.2", From 918b22ae49b5094832b511275cb461f71cb33269 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:21 +0000 Subject: [PATCH 231/290] Bump lodash.mergewith in /apps/block_scout_web/assets Bumps [lodash.mergewith](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/commits) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 1359939cdc..88ba9eedbc 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -7002,9 +7002,9 @@ "dev": true }, "lodash.mergewith": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", - "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz", + "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", "dev": true }, "lodash.sortby": { From 5d1254c567ed90ce518b729ed97f9e173093f21a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:20 +0000 Subject: [PATCH 232/290] Bump js-yaml from 3.7.0 to 3.13.1 in /apps/block_scout_web/assets Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.7.0 to 3.13.1. - [Release notes](https://github.com/nodeca/js-yaml/releases) - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/3.7.0...3.13.1) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 61 +++++-------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 88ba9eedbc..c396e33c4b 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -2678,8 +2678,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "is-svg": { "version": "3.0.0", @@ -2690,16 +2689,6 @@ "html-comment-regex": "^1.1.0" } }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "mdn-data": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", @@ -3638,8 +3627,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", - "dev": true + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==" }, "globals": { "version": "11.7.0", @@ -3647,16 +3635,6 @@ "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==", "dev": true }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -3812,12 +3790,6 @@ "acorn-jsx": "^3.0.0" } }, - "esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", - "dev": true - }, "esquery": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", @@ -6759,13 +6731,21 @@ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" }, "js-yaml": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.7.0.tgz", - "integrity": "sha1-XJZ93YN6m/3KXy3oQlOr6KHAO4A=", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", - "esprima": "^2.6.0" + "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } } }, "jsbn": { @@ -8066,18 +8046,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "parse-json": { "version": "4.0.0", From 57487470cd146674048edb1d96e4ab0ecfac7d0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:16 +0000 Subject: [PATCH 233/290] Bump extend from 3.0.1 to 3.0.2 in /apps/block_scout_web/assets Bumps [extend](https://github.com/justmoon/node-extend) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/justmoon/node-extend/releases) - [Changelog](https://github.com/justmoon/node-extend/blob/master/CHANGELOG.md) - [Commits](https://github.com/justmoon/node-extend/compare/v3.0.1...v3.0.2) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index c396e33c4b..bcf7afd17b 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -3952,9 +3952,9 @@ } }, "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, "extend-shallow": { From 57d234558e702d88fa3f7ecf3cdd9029a04b5536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:15 +0000 Subject: [PATCH 234/290] Bump handlebars from 4.0.12 to 4.1.2 in /apps/block_scout_web/assets Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.12 to 4.1.2. - [Release notes](https://github.com/wycats/handlebars.js/releases) - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md) - [Commits](https://github.com/wycats/handlebars.js/compare/v4.0.12...v4.1.2) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index bcf7afd17b..11ef37482c 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -5115,15 +5115,23 @@ "dev": true }, "handlebars": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.12.tgz", - "integrity": "sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", + "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", "dev": true, "requires": { - "async": "^2.5.0", + "neo-async": "^2.6.0", "optimist": "^0.6.1", "source-map": "^0.6.1", "uglify-js": "^3.1.4" + }, + "dependencies": { + "neo-async": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", + "dev": true + } } }, "har-schema": { From c26ec1c19072cce8614157117359a0e9dc468d84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2019 12:33:15 +0000 Subject: [PATCH 235/290] Bump lodash from 4.17.11 to 4.17.13 in /apps/block_scout_web/assets Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.13. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.13) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- apps/block_scout_web/assets/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 11ef37482c..2c78f45f55 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -6961,9 +6961,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.13.tgz", + "integrity": "sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==" }, "lodash.assign": { "version": "4.2.0", diff --git a/apps/block_scout_web/assets/package.json b/apps/block_scout_web/assets/package.json index 5c92b7b1f9..98fbc501d6 100644 --- a/apps/block_scout_web/assets/package.json +++ b/apps/block_scout_web/assets/package.json @@ -30,7 +30,7 @@ "highlightjs-solidity": "^1.0.6", "humps": "^2.0.1", "jquery": "^3.3.1", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "moment": "^2.22.1", "nanomorph": "^5.1.3", "numeral": "^2.0.6", From e3fac4f2b190c63010381322954c264df280089e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 21 Aug 2019 15:32:04 +0300 Subject: [PATCH 236/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b6d16ed3..a90e6e26b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records ### Chore +- [#2611](https://github.com/poanetwork/blockscout/pull/2611) - fix js dependency vulnerabilities - [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically - [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases - [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error From 48a01e98a599ad34c892fa01fb031059ef2fbcfe Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 22 Aug 2019 11:22:54 +0300 Subject: [PATCH 237/290] fix json decoding --- apps/explorer/lib/explorer/exchange_rates/source.ex | 7 ++++++- .../lib/explorer/exchange_rates/source/coin_gecko.ex | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/explorer/lib/explorer/exchange_rates/source.ex b/apps/explorer/lib/explorer/exchange_rates/source.ex index d733b22222..6d95e48796 100644 --- a/apps/explorer/lib/explorer/exchange_rates/source.ex +++ b/apps/explorer/lib/explorer/exchange_rates/source.ex @@ -39,7 +39,12 @@ defmodule Explorer.ExchangeRates.Source do defp fetch_exchange_rates_request(source) do case HTTPoison.get(source.source_url(), headers()) do {:ok, %Response{body: body, status_code: 200}} -> - {:ok, source.format_data(body)} + result = + body + |> decode_json() + |> source.format_data() + + {:ok, result} {:ok, %Response{body: body, status_code: status_code}} when status_code in 400..499 -> {:error, decode_json(body)["error"]} diff --git a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex index 5b0bed2b3b..95ecafb046 100644 --- a/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex +++ b/apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex @@ -11,12 +11,10 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do @behaviour Source @impl Source - def format_data(%{"market_data" => _} = data) do + def format_data(%{"market_data" => _} = json_data) do {:ok, price} = get_btc_price() btc_price = to_decimal(price) - json_data = decode_json(data) - market_data = json_data["market_data"] {:ok, last_updated, 0} = DateTime.from_iso8601(market_data["last_updated"]) From 48e9005f5b1553bbd495e21e4d6129b44b43c37c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 22 Aug 2019 13:36:55 +0300 Subject: [PATCH 238/290] remove reward from getminedblocks rpc response Reward calculation is a heavy operation since it joins `rewards` and `transactions` tables with `blocks`. `transactions` is one of the largest tables in the DB. So that was a reason for a request timeout. Removing rewards fixed the issue. From this point rewards should be fetched with `getblockreward` rpc. --- .../block_scout_web/views/api/rpc/address_view.ex | 3 +-- apps/explorer/lib/explorer/etherscan.ex | 12 ++---------- 2 files changed, 3 insertions(+), 12 deletions(-) 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 2ec350da71..8063b1db40 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 @@ -157,8 +157,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do defp prepare_block(block) do %{ "blockNumber" => to_string(block.number), - "timeStamp" => to_string(block.timestamp), - "blockReward" => to_string(block.reward.value) + "timeStamp" => to_string(block.timestamp) } end diff --git a/apps/explorer/lib/explorer/etherscan.ex b/apps/explorer/lib/explorer/etherscan.ex index ca31cc5c3c..848f5ae620 100644 --- a/apps/explorer/lib/explorer/etherscan.ex +++ b/apps/explorer/lib/explorer/etherscan.ex @@ -8,8 +8,7 @@ defmodule Explorer.Etherscan do alias Explorer.Etherscan.Logs alias Explorer.{Chain, Repo} alias Explorer.Chain.Address.TokenBalance - alias Explorer.Chain.{Block, Hash, InternalTransaction, Transaction, Wei} - alias Explorer.Chain.Block.EmissionReward + alias Explorer.Chain.{Block, Hash, InternalTransaction, Transaction} @default_options %{ order_by_direction: :asc, @@ -187,22 +186,15 @@ defmodule Explorer.Etherscan do query = from( b in Block, - left_join: t in assoc(b, :transactions), - inner_join: r in EmissionReward, - on: fragment("? <@ ?", b.number, r.block_range), where: b.miner_hash == ^address_hash, order_by: [desc: b.number], group_by: b.number, group_by: b.timestamp, - group_by: r.reward, limit: ^merged_options.page_size, offset: ^offset(merged_options), select: %{ number: b.number, - timestamp: b.timestamp, - reward: %Wei{ - value: fragment("coalesce(sum(? * ?), 0) + ?", t.gas_used, t.gas_price, r.reward) - } + timestamp: b.timestamp } ) From b5999c45fe026ad897ac9527f4f60d4da2cf0ee9 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 22 Aug 2019 13:54:19 +0300 Subject: [PATCH 239/290] update docs --- apps/block_scout_web/lib/block_scout_web/etherscan.ex | 5 ----- 1 file changed, 5 deletions(-) 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 867b56e746..021a0b3aa1 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -713,11 +713,6 @@ defmodule BlockScoutWeb.Etherscan do type: "timestamp", definition: "When the block was collated.", example: ~s("1480072029") - }, - blockReward: %{ - type: "block reward", - definition: "The reward given to the miner of a block.", - example: ~s("5003251945421042780") } } } From 8b91527965aa5aaeb5cfa8fdb0d3ca9609744cf5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 22 Aug 2019 13:55:47 +0300 Subject: [PATCH 240/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 683dbac49f..08c0f4bd21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2613](https://github.com/poanetwork/blockscout/pull/2613) - fix getminedblocks rpc endpoint - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload From c5e4485d3d658b5fc53c2e254e93338ae4348c13 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 12:54:27 +0300 Subject: [PATCH 241/290] deduplicate coin history records by delta On coin history page we show records that are found in the db. Since we may fetch a lot of duplicated balances for the same address if its balance is not changes for multiple blocks. This PR adds deduplication by delta value to remove duplication. --- apps/explorer/lib/explorer/chain.ex | 3 +++ apps/explorer/test/explorer/chain_test.exs | 26 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 58253c0f27..a6200a81f9 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2967,6 +2967,9 @@ defmodule Explorer.Chain do |> CoinBalance.fetch_coin_balances(paging_options) |> page_coin_balances(paging_options) |> Repo.all() + |> Enum.dedup_by(fn record -> + record.delta == Decimal.new(0) + end) end def get_coin_balance(address_hash, block_number) do diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index f49be6da4e..10788b60ba 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -4159,4 +4159,30 @@ defmodule Explorer.ChainTest do assert Chain.staking_pools_count(:inactive) == 1 end end + + describe "address_to_coin_balances/2" do + test "deduplicates records by zero delta" do + address = insert(:address) + + 1..5 + |> Enum.each(fn block_number -> + insert(:block, number: block_number) + insert(:fetched_balance, value: 1, block_number: block_number, address_hash: address.hash) + end) + + insert(:block, number: 6) + insert(:fetched_balance, value: 2, block_number: 6, address_hash: address.hash) + + assert [first, second, third] = Chain.address_to_coin_balances(address.hash, []) + + assert first.block_number == 6 + assert first.delta == Decimal.new(1) + + assert second.block_number == 5 + assert second.delta == Decimal.new(0) + + assert third.block_number == 1 + assert third.delta == Decimal.new(1) + end + end end From e8ba3b22785931c890ebc856096b99482c99a399 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 12:59:07 +0300 Subject: [PATCH 242/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26c016be..d6cfce7118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2616](https://github.com/poanetwork/blockscout/pull/2616) - deduplicate coin history records by delta - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload From 045652a505a93120d28a1db92fc20241a6a8dd40 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 14:00:16 +0300 Subject: [PATCH 243/290] fix tests --- apps/explorer/lib/explorer/chain.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index a6200a81f9..c781a3463e 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2968,7 +2968,11 @@ defmodule Explorer.Chain do |> page_coin_balances(paging_options) |> Repo.all() |> Enum.dedup_by(fn record -> - record.delta == Decimal.new(0) + if record.delta == Decimal.new(0) do + :dup + else + System.unique_integer + end end) end From cd979c02c2f257fa06eb79d05684cd14333e6406 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 14:02:46 +0300 Subject: [PATCH 244/290] mix format --- apps/explorer/lib/explorer/chain.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index c781a3463e..b2c18e8a50 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2971,7 +2971,7 @@ defmodule Explorer.Chain do if record.delta == Decimal.new(0) do :dup else - System.unique_integer + System.unique_integer() end end) end From 0e736637a7a12484752ff65653227688d1d5518f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 15:31:02 +0300 Subject: [PATCH 245/290] skip cache update if there are no blocks inserted Sometimes due to some error (mostly network) if may not fetch any data when indexing block. If block cache update is triggered it fails. This PR check if list is passed to cache update function. --- apps/indexer/lib/indexer/block/fetcher.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index 6a4eb3661b..a8b28d1391 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -183,7 +183,7 @@ defmodule Indexer.Block.Fetcher do end end - defp update_block_cache(blocks) do + defp update_block_cache(blocks) when is_list(blocks) do max_block = Enum.max_by(blocks, fn block -> block.number end) min_block = Enum.min_by(blocks, fn block -> block.number end) @@ -192,6 +192,8 @@ defmodule Indexer.Block.Fetcher do BlocksCache.update(blocks) end + defp update_block_cache(_), do: :ok + defp update_transactions_cache(transactions) do Transactions.update(transactions) end From dc4ad23953db4edbdd676b08b284e095917b02af Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 15:34:33 +0300 Subject: [PATCH 246/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26c016be..6c8c5cbf3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records ### Chore +- [#2617](https://github.com/poanetwork/blockscout/pull/2617) - skip cache update if there are no blocks inserted - [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically - [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases - [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error From b38c6d1e65b02ba053237046d577acdfbb8473dc Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 11:57:22 +0300 Subject: [PATCH 247/290] fix transaction assign in view --- .../lib/block_scout_web/templates/address_logs/_logs.html.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex index 527a63feab..790e463981 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex @@ -5,7 +5,7 @@ <%= {:error, :contract_not_verified, _cadidates} -> %>
<%= gettext "To see accurate decoded input data, the contract must be verified." %> - <%= case @transaction do %> + <%= case @log.transaction do %> <% %{to_address: %{hash: hash}} -> %> <%= gettext "Verify the contract " %><%= gettext "here" %> <% _ -> %> From d108e541a19b8801d36008b3657344b89e97bfe4 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 12:05:23 +0300 Subject: [PATCH 248/290] fix html for address logs view --- .../lib/block_scout_web/templates/address_logs/_logs.html.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex index 790e463981..92a8ebc6cc 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex @@ -1,5 +1,4 @@
"> -
<% decoded_result = decode(@log, @log.transaction) %> <%= case decoded_result do %> <%= {:error, :contract_not_verified, _cadidates} -> %> @@ -15,6 +14,7 @@ <% _ -> %> <%= nil %> <% end %> +
<%= gettext "Transaction" %>

From b007451f0671567f5eda9326550b1725380fbe15 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 12:10:04 +0300 Subject: [PATCH 249/290] fix a blinking test The test was failing because `RollingWindow` process is already initialized in `setup` hook --- .../test/ethereum_jsonrpc/rolling_window_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs index 43f400434a..d053a66493 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs @@ -29,7 +29,7 @@ defmodule EthereumJSONRPC.RollingWindowTest do describe "init/1" do test "raises when duration isn't evenly divisble by window_count" do assert_raise ArgumentError, ~r"evenly divisible", fn -> - RollingWindow.init(table: @table, duration: :timer.seconds(2), window_count: 3) + RollingWindow.init(table: :init_test_table, duration: :timer.seconds(2), window_count: 3) end end From dfbc6fa7fe2c19c06c2c241bcb2293e22dd0a214 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 12:21:01 +0300 Subject: [PATCH 250/290] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26c016be..2ee0459051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2623](https://github.com/poanetwork/blockscout/pull/2623) - fix a blinking test - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload From e6a65b82a3b221738a3b0e2885355b19685d2dbb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 13:46:58 +0300 Subject: [PATCH 251/290] fix tests --- .../ethereum_jsonrpc/rolling_window_test.exs | 114 ++++++++++-------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs index d053a66493..5f8db2a821 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs @@ -1,27 +1,8 @@ defmodule EthereumJSONRPC.RollingWindowTest do - use ExUnit.Case, - # The same named process is used for all tests and they use the same key in the table, so they would interfere - async: false + use ExUnit.Case, async: true alias EthereumJSONRPC.RollingWindow - @table :table - - setup do - # We set `window_length` to a large time frame so that we can sweep manually to simulate - # time passing - {:ok, pid} = - RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow) - - on_exit(fn -> Process.exit(pid, :normal) end) - - :ok - end - - defp sweep do - GenServer.call(RollingWindow, :sweep) - end - test "start_link/2" do assert {:ok, _} = RollingWindow.start_link(table: :test_table, duration: 5, window_count: 1) end @@ -40,61 +21,85 @@ defmodule EthereumJSONRPC.RollingWindowTest do end test "when no increments have happened, inspect returns an empty list" do - assert RollingWindow.inspect(@table, :foobar) == [] + table = :no_increments_have_happened + start_rolling_window(table) + + assert RollingWindow.inspect(table, :foobar) == [] end test "when no increments have happened, count returns 0" do - assert RollingWindow.count(@table, :foobar) == 0 + table = :no_increments_have_happened_empty_list + start_rolling_window(table) + + assert RollingWindow.count(table, :foobar) == 0 end test "when an increment has happened, inspect returns the count for that window" do - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_count + start_rolling_window(table) - assert RollingWindow.inspect(@table, :foobar) == [1] + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1] end test "when an increment has happened, count returns the count for that window" do - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_count1 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) - assert RollingWindow.count(@table, :foobar) == 1 + assert RollingWindow.count(table, :foobar) == 1 end test "when an increment has happened in multiple windows, inspect returns the count for both windows" do - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_multiple_windows + start_rolling_window(table) - assert RollingWindow.inspect(@table, :foobar) == [1, 1] + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1, 1] end test "when an increment has happened in multiple windows, count returns the sum of both windows" do - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_multiple_windows1 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) - assert RollingWindow.count(@table, :foobar) == 2 + assert RollingWindow.count(table, :foobar) == 2 end test "when an increment has happened, but has been swept times, it no longer appears in inspect" do - RollingWindow.inc(@table, :foobar) - sweep() - sweep() - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) - - assert RollingWindow.inspect(@table, :foobar) == [1, 1, 0] + table = :no_increments_have_happened_multiple_windows3 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + sweep(table) + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1, 1, 0] end test "when an increment has happened, but has been swept times, it no longer is included in count" do - RollingWindow.inc(@table, :foobar) - sweep() - sweep() - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) - - assert RollingWindow.count(@table, :foobar) == 2 + table = :no_increments_have_happened_multiple_windows4 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + sweep(table) + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.count(table, :foobar) == 2 end test "sweeping schedules another sweep" do @@ -102,4 +107,13 @@ defmodule EthereumJSONRPC.RollingWindowTest do RollingWindow.handle_info(:sweep, state) assert_receive(:sweep) end + + defp start_rolling_window(table_name) do + {:ok, _pid} = + RollingWindow.start_link([table: table_name, duration: :timer.minutes(120), window_count: 3], name: table_name) + end + + defp sweep(name) do + GenServer.call(name, :sweep) + end end From 3d732bd4b40129297b59b585f79631fde24500dd Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 14:13:14 +0300 Subject: [PATCH 252/290] fix rpc/address_controller test --- .../api/rpc/address_controller_test.exs | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs index 7e88d4717f..96716f0935 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs @@ -2266,7 +2266,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do end test "returns all the required fields", %{conn: conn} do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) @@ -2274,17 +2274,10 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do |> insert(gas_price: 1) |> with_block(block, gas_used: 1) - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(1)) - |> Wei.from(:wei) - expected_result = [ %{ "blockNumber" => to_string(block.number), - "timeStamp" => to_string(block.timestamp), - "blockReward" => to_string(expected_reward.value) + "timeStamp" => to_string(block.timestamp) } ] @@ -2306,7 +2299,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do end test "with a block with one transaction", %{conn: conn} do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) @@ -2314,12 +2307,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do |> insert(gas_price: 1) |> with_block(block, gas_used: 1) - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(1)) - |> Wei.from(:wei) - params = %{ "module" => "account", "action" => "getminedblocks", @@ -2329,8 +2316,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do expected_result = [ %{ "blockNumber" => to_string(block.number), - "timeStamp" => to_string(block.timestamp), - "blockReward" => to_string(expected_reward.value) + "timeStamp" => to_string(block.timestamp) } ] @@ -2346,7 +2332,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do end test "with pagination options", %{conn: conn} do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block_numbers = Range.new(range.from, range.to) @@ -2361,12 +2347,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do |> insert(gas_price: 2) |> with_block(block2, gas_used: 2) - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(4)) - |> Wei.from(:wei) - params = %{ "module" => "account", "action" => "getminedblocks", @@ -2380,8 +2360,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do expected_result = [ %{ "blockNumber" => to_string(block2.number), - "timeStamp" => to_string(block2.timestamp), - "blockReward" => to_string(expected_reward.value) + "timeStamp" => to_string(block2.timestamp) } ] @@ -2683,7 +2662,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do }) end - defp resolve_schema(result \\ %{}) do + defp resolve_schema(result) do %{ "type" => "object", "properties" => %{ From 4b19c5557459ab0d40407469a47b2be2cf75010f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 14:20:40 +0300 Subject: [PATCH 253/290] fix explorer/etherscan tests --- .../explorer/test/explorer/etherscan_test.exs | 97 +++---------------- 1 file changed, 13 insertions(+), 84 deletions(-) diff --git a/apps/explorer/test/explorer/etherscan_test.exs b/apps/explorer/test/explorer/etherscan_test.exs index 420dd3e7d2..ded7f2cc30 100644 --- a/apps/explorer/test/explorer/etherscan_test.exs +++ b/apps/explorer/test/explorer/etherscan_test.exs @@ -4,7 +4,7 @@ defmodule Explorer.EtherscanTest do import Explorer.Factory alias Explorer.{Etherscan, Chain} - alias Explorer.Chain.{Transaction, Wei} + alias Explorer.Chain.Transaction describe "list_transactions/2" do test "with empty db" do @@ -1170,7 +1170,7 @@ defmodule Explorer.EtherscanTest do describe "list_blocks/1" do test "it returns all required fields" do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) @@ -1181,17 +1181,10 @@ defmodule Explorer.EtherscanTest do |> insert(gas_price: 1) |> with_block(block, gas_used: 1) - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(1)) - |> Wei.from(:wei) - expected = [ %{ number: block.number, - timestamp: block.timestamp, - reward: expected_reward + timestamp: block.timestamp } ] @@ -1199,32 +1192,14 @@ defmodule Explorer.EtherscanTest do end test "with block containing multiple transactions" do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) - # irrelevant transaction - insert(:transaction) - - :transaction - |> insert(gas_price: 1) - |> with_block(block, gas_used: 1) - - :transaction - |> insert(gas_price: 1) - |> with_block(block, gas_used: 2) - - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(3)) - |> Wei.from(:wei) - expected = [ %{ number: block.number, - timestamp: block.timestamp, - reward: expected_reward + timestamp: block.timestamp } ] @@ -1232,7 +1207,7 @@ defmodule Explorer.EtherscanTest do end test "with block without transactions" do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block = insert(:block, number: Enum.random(Range.new(range.from, range.to))) @@ -1242,8 +1217,7 @@ defmodule Explorer.EtherscanTest do expected = [ %{ number: block.number, - timestamp: block.timestamp, - reward: emission_reward.reward + timestamp: block.timestamp } ] @@ -1251,7 +1225,7 @@ defmodule Explorer.EtherscanTest do end test "with multiple blocks" do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block_numbers = Range.new(range.from, range.to) @@ -1262,47 +1236,14 @@ defmodule Explorer.EtherscanTest do block1 = insert(:block, number: block_number1, miner: address) block2 = insert(:block, number: block_number2, miner: address) - # irrelevant transaction - insert(:transaction) - - :transaction - |> insert(gas_price: 2) - |> with_block(block1, gas_used: 2) - - :transaction - |> insert(gas_price: 2) - |> with_block(block1, gas_used: 2) - - :transaction - |> insert(gas_price: 3) - |> with_block(block2, gas_used: 3) - - :transaction - |> insert(gas_price: 3) - |> with_block(block2, gas_used: 3) - - expected_reward_block1 = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(8)) - |> Wei.from(:wei) - - expected_reward_block2 = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(18)) - |> Wei.from(:wei) - expected = [ %{ number: block2.number, - timestamp: block2.timestamp, - reward: expected_reward_block2 + timestamp: block2.timestamp }, %{ number: block1.number, - timestamp: block1.timestamp, - reward: expected_reward_block1 + timestamp: block1.timestamp } ] @@ -1310,7 +1251,7 @@ defmodule Explorer.EtherscanTest do end test "with pagination options" do - %{block_range: range} = emission_reward = insert(:emission_reward) + %{block_range: range} = insert(:emission_reward) block_numbers = Range.new(range.from, range.to) @@ -1321,29 +1262,17 @@ defmodule Explorer.EtherscanTest do block1 = insert(:block, number: block_number1, miner: address) block2 = insert(:block, number: block_number2, miner: address) - :transaction - |> insert(gas_price: 2) - |> with_block(block1, gas_used: 2) - - expected_reward = - emission_reward.reward - |> Wei.to(:wei) - |> Decimal.add(Decimal.new(4)) - |> Wei.from(:wei) - expected1 = [ %{ number: block2.number, - timestamp: block2.timestamp, - reward: emission_reward.reward + timestamp: block2.timestamp } ] expected2 = [ %{ number: block1.number, - timestamp: block1.timestamp, - reward: expected_reward + timestamp: block1.timestamp } ] From 66dec0c4591f9b6491bcc44615edb5d88d5d11ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2019 11:49:24 +0000 Subject: [PATCH 254/290] Bump jquery from 3.3.1 to 3.4.0 in /apps/block_scout_web/assets Bumps [jquery](https://github.com/jquery/jquery) from 3.3.1 to 3.4.0. - [Release notes](https://github.com/jquery/jquery/releases) - [Commits](https://github.com/jquery/jquery/compare/3.3.1...3.4.0) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- apps/block_scout_web/assets/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 2c78f45f55..1545e3b759 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -6723,9 +6723,9 @@ } }, "jquery": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", - "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.0.tgz", + "integrity": "sha512-ggRCXln9zEqv6OqAGXFEcshF5dSBvCkzj6Gm2gzuR5fWawaX8t7cxKVkkygKODrDAzKdoYw3l/e3pm3vlT4IbQ==" }, "js-base64": { "version": "2.4.5", diff --git a/apps/block_scout_web/assets/package.json b/apps/block_scout_web/assets/package.json index 98fbc501d6..1169e22859 100644 --- a/apps/block_scout_web/assets/package.json +++ b/apps/block_scout_web/assets/package.json @@ -29,7 +29,7 @@ "highlight.js": "^9.13.1", "highlightjs-solidity": "^1.0.6", "humps": "^2.0.1", - "jquery": "^3.3.1", + "jquery": "^3.4.0", "lodash": "^4.17.13", "moment": "^2.22.1", "nanomorph": "^5.1.3", From 8491259093ee93aa3371c05e9e159f1fa2d87d29 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2019 11:50:18 +0000 Subject: [PATCH 255/290] Bump lodash from 4.17.13 to 4.17.15 in /apps/block_scout_web/assets Bumps [lodash](https://github.com/lodash/lodash) from 4.17.13 to 4.17.15. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.13...4.17.15) Signed-off-by: dependabot[bot] --- apps/block_scout_web/assets/package-lock.json | 6 +++--- apps/block_scout_web/assets/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 2c78f45f55..9747ccfe67 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -6961,9 +6961,9 @@ } }, "lodash": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.13.tgz", - "integrity": "sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA==" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash.assign": { "version": "4.2.0", diff --git a/apps/block_scout_web/assets/package.json b/apps/block_scout_web/assets/package.json index 98fbc501d6..30845a3be3 100644 --- a/apps/block_scout_web/assets/package.json +++ b/apps/block_scout_web/assets/package.json @@ -30,7 +30,7 @@ "highlightjs-solidity": "^1.0.6", "humps": "^2.0.1", "jquery": "^3.3.1", - "lodash": "^4.17.13", + "lodash": "^4.17.15", "moment": "^2.22.1", "nanomorph": "^5.1.3", "numeral": "^2.0.6", From 3f30610dde9a3f2d425552c1696069f84c6c557b Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Thu, 15 Aug 2019 20:36:48 +0200 Subject: [PATCH 256/290] Add generic Map-like Cache behaviour and implementation Problem: multiple caches exist that contain some data as a map (key-value storing). More are to be implemented, so it would be good to abstract their implementation. Solution: add a behaviour and a macro (providing an implementation) to create this type of caches. At the same time, where possible: - redefine the existing ones using the new macro - optimize the implementation --- CHANGELOG.md | 1 + .../controllers/api/rpc/block_controller.ex | 2 +- .../controllers/block_controller_test.exs | 4 +- .../controllers/chain_controller_test.exs | 4 +- .../features/viewing_chain_test.exs | 4 +- apps/explorer/lib/explorer/application.ex | 9 +- apps/explorer/lib/explorer/chain.ex | 36 +-- apps/explorer/lib/explorer/chain/address.ex | 2 +- .../lib/explorer/chain/cache/block_count.ex | 168 ++++---------- .../lib/explorer/chain/cache/block_number.ex | 91 ++------ .../lib/explorer/chain/cache/net_version.ex | 47 ++-- .../explorer/chain/cache/transaction_count.ex | 174 ++++---------- apps/explorer/lib/explorer/chain/map_cache.ex | 217 ++++++++++++++++++ .../explorer/lib/explorer/chain/supply/rsk.ex | 2 +- .../explorer/chain/cache/block_count_test.exs | 26 +-- .../chain/cache/block_number_test.exs | 50 ++-- .../test/explorer/chain/cache/blocks_test.exs | 4 +- .../chain/cache/transaction_count_test.exs | 26 +-- apps/explorer/test/explorer/chain_test.exs | 24 +- apps/explorer/test/support/data_case.ex | 3 +- apps/indexer/lib/indexer/block/fetcher.ex | 9 +- .../indexer/fetcher/coin_balance_on_demand.ex | 2 +- 22 files changed, 458 insertions(+), 447 deletions(-) create mode 100644 apps/explorer/lib/explorer/chain/map_cache.ex diff --git a/CHANGELOG.md b/CHANGELOG.md index f8335319cb..0f8742c44b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2581](https://github.com/poanetwork/blockscout/pull/2581) - Add generic Map-like Cache behaviour and implementation - [#2596](https://github.com/poanetwork/blockscout/pull/2596) - support AuRa's empty step reward type - [#2561](https://github.com/poanetwork/blockscout/pull/2561) - Add token's type to the response of tokenlist method - [#2499](https://github.com/poanetwork/blockscout/pull/2499) - import emission reward ranges diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex index 835e19bf3e..2b9bdc0dd6 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex @@ -26,7 +26,7 @@ defmodule BlockScoutWeb.API.RPC.BlockController do def eth_block_number(conn, params) do id = Map.get(params, "id", 1) - max_block_number = BlockNumber.max_number() + max_block_number = BlockNumber.get_max() render(conn, :eth_block_number, number: max_block_number, id: id) end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs index e8c4af7de8..6c0bfabfa0 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs @@ -3,8 +3,8 @@ defmodule BlockScoutWeb.BlockControllerTest do alias Explorer.Chain.Block setup do - Supervisor.terminate_child(Explorer.Supervisor, {ConCache, :blocks}) - Supervisor.restart_child(Explorer.Supervisor, {ConCache, :blocks}) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) :ok end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs index 00a53689c8..fa82bb5bab 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs @@ -9,8 +9,8 @@ defmodule BlockScoutWeb.ChainControllerTest do alias Explorer.Counters.AddressesWithBalanceCounter setup do - Supervisor.terminate_child(Explorer.Supervisor, {ConCache, :blocks}) - Supervisor.restart_child(Explorer.Supervisor, {ConCache, :blocks}) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) start_supervised!(AddressesWithBalanceCounter) AddressesWithBalanceCounter.consolidate() diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_chain_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_chain_test.exs index a32e4f5da3..27b4dbb329 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_chain_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_chain_test.exs @@ -10,8 +10,8 @@ defmodule BlockScoutWeb.ViewingChainTest do alias Explorer.Counters.AddressesWithBalanceCounter setup do - Supervisor.terminate_child(Explorer.Supervisor, {ConCache, :blocks}) - Supervisor.restart_child(Explorer.Supervisor, {ConCache, :blocks}) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) Enum.map(401..404, &insert(:block, number: &1)) diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index c28469c340..1bd2778762 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -42,10 +42,11 @@ defmodule Explorer.Application do Explorer.SmartContract.SolcDownloader, {Registry, keys: :duplicate, name: Registry.ChainEvents, id: Registry.ChainEvents}, {Admin.Recovery, [[], [name: Admin.Recovery]]}, - {TransactionCount, [[], []]}, - {BlockCount, []}, + TransactionCount, + BlockCount, Blocks, - con_cache_child_spec(NetVersion.cache_name()), + NetVersion, + BlockNumber, con_cache_child_spec(MarketHistoryCache.cache_name()), con_cache_child_spec(RSK.cache_name(), ttl_check_interval: :timer.minutes(1), global_ttl: :timer.minutes(30)), Transactions @@ -57,8 +58,6 @@ defmodule Explorer.Application do res = Supervisor.start_link(children, opts) - BlockNumber.setup() - res end diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 58253c0f27..eac7f3ce6f 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -267,7 +267,7 @@ defmodule Explorer.Chain do def address_to_logs(address_hash, options \\ []) when is_list(options) do paging_options = Keyword.get(options, :paging_options) || %PagingOptions{page_size: 50} - {block_number, transaction_index, log_index} = paging_options.key || {BlockNumber.max_number(), 0, 0} + {block_number, transaction_index, log_index} = paging_options.key || {BlockNumber.get_max(), 0, 0} base_query = from(log in Log, @@ -1176,7 +1176,7 @@ defmodule Explorer.Chain do """ @spec indexed_ratio() :: Decimal.t() def indexed_ratio do - {min, max} = BlockNumber.min_and_max_numbers() + %{min: min, max: max} = BlockNumber.get_all() case {min, max} do {0, 0} -> @@ -1189,20 +1189,30 @@ defmodule Explorer.Chain do end end - @spec fetch_min_and_max_block_numbers() :: {non_neg_integer, non_neg_integer} - def fetch_min_and_max_block_numbers do + @spec fetch_min_block_number() :: non_neg_integer + def fetch_min_block_number do query = from(block in Block, - select: {min(block.number), max(block.number)}, - where: block.consensus == true + select: block.number, + where: block.consensus == true, + order_by: [asc: block.number], + limit: 1 ) - result = Repo.one!(query) + Repo.one(query) || 0 + end - case result do - {nil, nil} -> {0, 0} - _ -> result - end + @spec fetch_max_block_number() :: non_neg_integer + def fetch_max_block_number do + query = + from(block in Block, + select: block.number, + where: block.consensus == true, + order_by: [desc: block.number], + limit: 1 + ) + + Repo.one(query) || 0 end @spec fetch_count_consensus_block() :: non_neg_integer @@ -2195,7 +2205,7 @@ defmodule Explorer.Chain do """ @spec transaction_estimated_count() :: non_neg_integer() def transaction_estimated_count do - cached_value = TransactionCount.value() + cached_value = TransactionCount.get_count() if is_nil(cached_value) do %Postgrex.Result{rows: [[rows]]} = @@ -2214,7 +2224,7 @@ defmodule Explorer.Chain do """ @spec block_estimated_count() :: non_neg_integer() def block_estimated_count do - cached_value = BlockCount.count() + cached_value = BlockCount.get_count() if is_nil(cached_value) do %Postgrex.Result{rows: [[count]]} = Repo.query!("SELECT reltuples FROM pg_class WHERE relname = 'blocks';") diff --git a/apps/explorer/lib/explorer/chain/address.ex b/apps/explorer/lib/explorer/chain/address.ex index 478c35deb1..96d4dc7ab4 100644 --- a/apps/explorer/lib/explorer/chain/address.ex +++ b/apps/explorer/lib/explorer/chain/address.ex @@ -170,7 +170,7 @@ defmodule Explorer.Chain.Address do end def rsk_checksum(hash) do - chain_id = NetVersion.version() + chain_id = NetVersion.get_version() string_hash = hash diff --git a/apps/explorer/lib/explorer/chain/cache/block_count.ex b/apps/explorer/lib/explorer/chain/cache/block_count.ex index 8ba09cc86f..c4e6c6a4a0 100644 --- a/apps/explorer/lib/explorer/chain/cache/block_count.ex +++ b/apps/explorer/lib/explorer/chain/cache/block_count.ex @@ -5,143 +5,61 @@ defmodule Explorer.Chain.Cache.BlockCount do require Logger - use GenServer + @default_cache_period :timer.minutes(10) - alias Explorer.Chain - - # 10 minutes - @cache_period 1_000 * 60 * 10 - @key "count" - @default_value nil - @name __MODULE__ - - def start_link(params) do - name = params[:name] || @name - params_with_name = Keyword.put(params, :name, name) - - GenServer.start_link(__MODULE__, params_with_name, name: name) - end - - def init(params) do - cache_period = period_from_env_var() || params[:cache_period] || @cache_period - current_value = params[:default_value] || @default_value - name = params[:name] - - init_ets_table(name) - - {:ok, {{cache_period, current_value, name}, nil}} - end - - def count(process_name \\ __MODULE__) do - GenServer.call(process_name, :count) - end - - def handle_call(:count, _, {{cache_period, default_value, name}, task}) do - {count, task} = - case cached_values(name) do - nil -> - {default_value, update_cache(task, name)} - - {cached_value, timestamp} -> - task = - if current_time() - timestamp > cache_period do - update_cache(task, name) - end - - {cached_value, task} - end - - {:reply, count, {{cache_period, default_value, name}, task}} - end - - def update_cache(nil, name) do - async_update_cache(name) - end - - def update_cache(task, _) do - task - end + use Explorer.Chain.MapCache, + name: :block_count, + key: :count, + key: :async_task, + global_ttl: cache_period(), + ttl_check_interval: :timer.minutes(1), + callback: &async_task_on_deletion(&1) - def handle_cast({:update_cache, value}, {{cache_period, default_value, name}, _}) do - current_time = current_time() - tuple = {value, current_time} - - table_name = table_name(name) - - :ets.insert(table_name, {@key, tuple}) - - {:noreply, {{cache_period, default_value, name}, nil}} - end - - def handle_info({:DOWN, _, _, _, _}, {{cache_period, default_value, name}, _}) do - {:noreply, {{cache_period, default_value, name}, nil}} - end - - def handle_info(_, {{cache_period, default_value, name}, _}) do - {:noreply, {{cache_period, default_value, name}, nil}} - end - - # sobelow_skip ["DOS"] - defp table_name(name) do - name - |> Atom.to_string() - |> Macro.underscore() - |> String.to_atom() - end + alias Explorer.Chain - def async_update_cache(name) do - Task.async(fn -> - try do - result = Chain.fetch_count_consensus_block() + defp handle_fallback(:count) do + # This will get the task PID if one exists and launch a new task if not + # See next `handle_fallback` definition + get_async_task() - GenServer.cast(name, {:update_cache, result}) - rescue - e -> - Logger.debug([ - "Coudn't update block count test #{inspect(e)}" - ]) - end - end) + {:return, nil} end - defp init_ets_table(name) do - table_name = table_name(name) - - if :ets.whereis(table_name) == :undefined do - :ets.new(table_name, [ - :set, - :named_table, - :public, - write_concurrency: true - ]) - end - end + defp handle_fallback(:async_task) do + # If this gets called it means an async task was requested, but none exists + # so a new one needs to be launched + task = + Task.async(fn -> + try do + result = Chain.fetch_count_consensus_block() + + set_count(result) + rescue + e -> + Logger.debug([ + "Coudn't update block count test #{inspect(e)}" + ]) + end - defp cached_values(name) do - table_name = table_name(name) + set_async_task(nil) + end) - case :ets.lookup(table_name, @key) do - [{_, cached_values}] -> cached_values - _ -> nil - end + {:update, task} end - defp current_time do - utc_now = DateTime.utc_now() - - DateTime.to_unix(utc_now, :millisecond) - end + # By setting this as a `callback` an async task will be started each time the + # `count` expires (unless there is one already running) + defp async_task_on_deletion({:delete, _, :count}), do: get_async_task() - defp period_from_env_var do - case System.get_env("BLOCK_COUNT_CACHE_PERIOD") do - value when is_binary(value) -> - case Integer.parse(value) do - {integer, ""} -> integer * 1_000 - _ -> nil - end + defp async_task_on_deletion(_data), do: nil - _ -> - nil + defp cache_period do + "BLOCK_COUNT_CACHE_PERIOD" + |> System.get_env("") + |> Integer.parse() + |> case do + {integer, ""} -> :timer.seconds(integer) + _ -> @default_cache_period end end end diff --git a/apps/explorer/lib/explorer/chain/cache/block_number.ex b/apps/explorer/lib/explorer/chain/cache/block_number.ex index 5212117793..d19551fa59 100644 --- a/apps/explorer/lib/explorer/chain/cache/block_number.ex +++ b/apps/explorer/lib/explorer/chain/cache/block_number.ex @@ -3,89 +3,36 @@ defmodule Explorer.Chain.Cache.BlockNumber do Cache for max and min block numbers. """ - alias Explorer.Chain - - @tab :block_number_cache - @key "min_max" + @type value :: non_neg_integer() - @spec setup() :: :ok - def setup do - if :ets.whereis(@tab) == :undefined do - :ets.new(@tab, [ - :set, - :named_table, - :public, - write_concurrency: true - ]) - end + use Explorer.Chain.MapCache, + name: :block_number, + keys: [:min, :max] - update_cache() - - :ok - end + alias Explorer.Chain - def max_number do - value(:max) - end + defp handle_update(_key, nil, value), do: {:ok, value} - def min_number do - value(:min) - end + defp handle_update(:min, old_value, new_value), do: {:ok, min(new_value, old_value)} - def min_and_max_numbers do - value(:all) - end + defp handle_update(:max, old_value, new_value), do: {:ok, max(new_value, old_value)} - defp value(type) do - {min, max} = - if Application.get_env(:explorer, __MODULE__)[:enabled] do - cached_values() - else - min_and_max_from_db() - end + defp handle_fallback(key) do + result = fetch_from_db(key) - case type do - :max -> max - :min -> min - :all -> {min, max} + if Application.get_env(:explorer, __MODULE__)[:enabled] do + {:update, result} + else + {:return, result} end end - @spec update(non_neg_integer()) :: boolean() - def update(number) do - {old_min, old_max} = cached_values() - - cond do - number > old_max -> - tuple = {old_min, number} - :ets.insert(@tab, {@key, tuple}) - - number < old_min -> - tuple = {number, old_max} - :ets.insert(@tab, {@key, tuple}) - - true -> - false + defp fetch_from_db(key) do + case key do + :min -> Chain.fetch_min_block_number() + :max -> Chain.fetch_max_block_number() end - end - - defp update_cache do - {min, max} = min_and_max_from_db() - tuple = {min, max} - - :ets.insert(@tab, {@key, tuple}) - end - - defp cached_values do - [{_, cached_values}] = :ets.lookup(@tab, @key) - - cached_values - end - - defp min_and_max_from_db do - Chain.fetch_min_and_max_block_numbers() rescue - _e -> - {0, 0} + _e -> 0 end end diff --git a/apps/explorer/lib/explorer/chain/cache/net_version.ex b/apps/explorer/lib/explorer/chain/cache/net_version.ex index ac33ca8f45..4a5c0cd144 100644 --- a/apps/explorer/lib/explorer/chain/cache/net_version.ex +++ b/apps/explorer/lib/explorer/chain/cache/net_version.ex @@ -3,42 +3,27 @@ defmodule Explorer.Chain.Cache.NetVersion do Caches chain version. """ - @cache_name :net_version - @key :version + @json_rpc_named_arguments Application.get_env(:explorer, :json_rpc_named_arguments) - @spec version() :: non_neg_integer() | {:error, any()} - def version do - cached_value = fetch_from_cache() + require Logger - if is_nil(cached_value) do - fetch_from_node() - else - cached_value - end - end - - def cache_name do - @cache_name - end - - defp fetch_from_cache do - ConCache.get(@cache_name, @key) - end + use Explorer.Chain.MapCache, + name: :net_version, + key: :version - defp cache_value(value) do - ConCache.put(@cache_name, @key, value) - end - - defp fetch_from_node do - json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) - - case EthereumJSONRPC.fetch_net_version(json_rpc_named_arguments) do + defp handle_fallback(:version) do + case EthereumJSONRPC.fetch_net_version(@json_rpc_named_arguments) do {:ok, value} -> - cache_value(value) - value + {:update, value} - other -> - other + {:error, reason} -> + Logger.debug([ + "Coudn't fetch net_version, reason: #{inspect(reason)}" + ]) + + {:return, nil} end end + + defp handle_fallback(_key), do: {:return, nil} end diff --git a/apps/explorer/lib/explorer/chain/cache/transaction_count.ex b/apps/explorer/lib/explorer/chain/cache/transaction_count.ex index e1fe2dad82..e81bae7414 100644 --- a/apps/explorer/lib/explorer/chain/cache/transaction_count.ex +++ b/apps/explorer/lib/explorer/chain/cache/transaction_count.ex @@ -3,152 +3,64 @@ defmodule Explorer.Chain.Cache.TransactionCount do Cache for estimated transaction count. """ - require Logger + @default_cache_period :timer.hours(2) + + use Explorer.Chain.MapCache, + name: :transaction_count, + key: :count, + key: :async_task, + global_ttl: cache_period(), + ttl_check_interval: :timer.minutes(10), + callback: &async_task_on_deletion(&1) - use GenServer + require Logger alias Explorer.Chain.Transaction alias Explorer.Repo - # 2 hours - @cache_period 1_000 * 60 * 60 * 2 - @default_value nil - @key "count" - @name __MODULE__ - - def start_link([params, gen_server_options]) do - name = gen_server_options[:name] || @name - params_with_name = Keyword.put(params, :name, name) - - GenServer.start_link(__MODULE__, params_with_name, name: name) - end - - def init(params) do - cache_period = period_from_env_var() || params[:cache_period] || @cache_period - current_value = params[:default_value] || @default_value - name = params[:name] - - init_ets_table(name) - - schedule_cache_update() - - {:ok, {{cache_period, current_value, name}, nil}} - end - - def value(process_name \\ __MODULE__) do - GenServer.call(process_name, :value) - end - - def handle_call(:value, _, {{cache_period, default_value, name}, task}) do - {value, task} = - case cached_values(name) do - nil -> - {default_value, update_cache(task, name)} + defp handle_fallback(:count) do + # This will get the task PID if one exists and launch a new task if not + # See next `handle_fallback` definition + get_async_task() - {cached_value, timestamp} -> - task = - if current_time() - timestamp > cache_period do - update_cache(task, name) - end - - {cached_value, task} - end - - {:reply, value, {{cache_period, default_value, name}, task}} + {:return, nil} end - def update_cache(nil, name) do - async_update_cache(name) - end - - def update_cache(task, _) do - task - end - - def handle_cast({:update_cache, value}, {{cache_period, default_value, name}, _}) do - current_time = current_time() - tuple = {value, current_time} - - table_name = table_name(name) - - :ets.insert(table_name, {@key, tuple}) + defp handle_fallback(:async_task) do + # If this gets called it means an async task was requested, but none exists + # so a new one needs to be launched + task = + Task.async(fn -> + try do + result = Repo.aggregate(Transaction, :count, :hash, timeout: :infinity) - {:noreply, {{cache_period, default_value, name}, nil}} - end - - def handle_info({:DOWN, _, _, _, _}, {{cache_period, default_value, name}, _}) do - {:noreply, {{cache_period, default_value, name}, nil}} - end - - def handle_info(_, {{cache_period, default_value, name}, _}) do - {:noreply, {{cache_period, default_value, name}, nil}} - end - - # sobelow_skip ["DOS"] - defp table_name(name) do - name - |> Atom.to_string() - |> Macro.underscore() - |> String.to_atom() - end - - def async_update_cache(name) do - Task.async(fn -> - try do - result = Repo.aggregate(Transaction, :count, :hash, timeout: :infinity) - - GenServer.cast(name, {:update_cache, result}) - rescue - e -> - Logger.debug([ - "Coudn't update transaction count test #{inspect(e)}" - ]) - end - end) - end - - defp init_ets_table(name) do - table_name = table_name(name) - - if :ets.whereis(table_name) == :undefined do - :ets.new(table_name, [ - :set, - :named_table, - :public, - write_concurrency: true - ]) - end - end - - defp cached_values(name) do - table_name = table_name(name) + set_count(result) + rescue + e -> + Logger.debug([ + "Coudn't update transaction count test #{inspect(e)}" + ]) + end - case :ets.lookup(table_name, @key) do - [{_, cached_values}] -> cached_values - _ -> nil - end - end + set_async_task(nil) + end) - defp schedule_cache_update do - Process.send_after(self(), :update_cache, 2_000) + {:update, task} end - defp current_time do - utc_now = DateTime.utc_now() + # By setting this as a `callback` an async task will be started each time the + # `count` expires (unless there is one already running) + defp async_task_on_deletion({:delete, _, :count}), do: get_async_task() - DateTime.to_unix(utc_now, :millisecond) - end - - defp period_from_env_var do - case System.get_env("TXS_COUNT_CACHE_PERIOD") do - value when is_binary(value) -> - case Integer.parse(value) do - {integer, ""} -> integer * 1_000 - _ -> nil - end + defp async_task_on_deletion(_data), do: nil - _ -> - nil + defp cache_period do + "TXS_COUNT_CACHE_PERIOD" + |> System.get_env("") + |> Integer.parse() + |> case do + {integer, ""} -> :timer.seconds(integer) + _ -> @default_cache_period end end end diff --git a/apps/explorer/lib/explorer/chain/map_cache.ex b/apps/explorer/lib/explorer/chain/map_cache.ex new file mode 100644 index 0000000000..d50a4c5e44 --- /dev/null +++ b/apps/explorer/lib/explorer/chain/map_cache.ex @@ -0,0 +1,217 @@ +defmodule Explorer.Chain.MapCache do + @moduledoc """ + Behaviour for a map-like cache of elements. + + A macro based on `ConCache` is provided as well, at its minimum it can be used as; + ``` + use Explorer.Chain.MapCache, + name: :name, + keys: [:fst, :snd] + ``` + Note: `keys` can also be set singularly with the option `key`, e.g.: + ``` + use Explorer.Chain.MapCache, + name: :cache, + key: :fst, + key: :snd + ``` + Additionally all of the options accepted by `ConCache.start_link/1` can be + provided as well. By default only `ttl_check_interval:` is set (to `false`). + + ## Named functions + Apart from the functions defined in the behaviour, the macro will also create + 3 named function for each key, for instance for the key `:fst`: + - `get_fst` + - `set_fst` + - `update_fst` + These all work as their respective counterparts with the `t:key/0` parameter. + + ## Callbacks + Apart from the `callback` that can be set as part of the `ConCache` options, + two callbacks esist and can be overridden: + + `c:handle_update/3` will be called whenever an update is issued. It will receive + the `t:key/0` that is going to be updated, the current `t:value/0` that is + stored for said key and the new `t:value/0` to evaluate. + This allows to select what value to keep and do additional processing. + By default this just stores the new `t:value/0`. + + `c:handle_fallback/1` will be called whenever a get is performed and there is no + stored value for the given `t:key/0` (or when the value is `nil`). + It can return 2 different tuples: + - `{:update, value}` that will cause the value to be returned and the `t:key/0` + to be `c:update/2`d + - `{:return, value}` that will cause the value to be returned but not stored + This allows to define of a default value or perform some actions. + By default it will simply `{:return, nil}` + """ + + @type key :: atom() + + @type value :: term() + + @doc """ + An atom that identifies this cache + """ + @callback cache_name :: atom() + + @doc """ + List of `t:key/0`s that the cache contains + """ + @callback cache_keys :: [key()] + + @doc """ + Gets everything in a map + """ + @callback get_all :: map() + + @doc """ + Gets the stored `t:value/0` for a given `t:key/0` + """ + @callback get(atom()) :: value() + + @doc """ + Stores the same `t:value/0` for every `t:key/0` + """ + @callback set_all(value()) :: :ok + + @doc """ + Stores the given `t:value/0` for the given `t:key/0` + """ + @callback set(key(), value()) :: :ok + + @doc """ + Updates every `t:key/0` with the given `t:value/0` + """ + @callback update_all(value()) :: :ok + + @doc """ + Updates the given `t:key/0` (or every `t:key/0` in a list) using the given `t:value/0` + """ + @callback update(key() | [key()], value()) :: :ok + + @doc """ + Gets called during an update for the given `t:key/0` + """ + @callback handle_update(key(), value(), value()) :: {:ok, value()} | {:error, term()} + + @doc """ + Gets called when a `c:get/1` finds no `t:value/0` + """ + @callback handle_fallback(key()) :: {:update, value()} | {:return, value()} + + # credo:disable-for-next-line /Complexity/ + defmacro __using__(opts) when is_list(opts) do + # name is necessary + name = Keyword.fetch!(opts, :name) + keys = Keyword.get(opts, :keys) || Keyword.get_values(opts, :key) + + concache_params = + opts + |> Keyword.drop([:keys, :key]) + |> Keyword.put_new(:ttl_check_interval, false) + + # credo:disable-for-next-line Credo.Check.Refactor.LongQuoteBlocks + quote do + alias Explorer.Chain.MapCache + + @behaviour MapCache + + @dialyzer {:nowarn_function, handle_fallback: 1} + + @impl MapCache + def cache_name, do: unquote(name) + + @impl MapCache + def cache_keys, do: unquote(keys) + + @impl MapCache + def get_all do + Map.new(cache_keys(), fn key -> {key, get(key)} end) + end + + @impl MapCache + def get(key) do + case ConCache.get(cache_name(), key) do + nil -> + case handle_fallback(key) do + {:update, new_value} -> + update(key, new_value) + new_value + + {:return, new_value} -> + new_value + end + + value -> + value + end + end + + @impl MapCache + def set_all(value) do + Enum.each(cache_keys(), &set(&1, value)) + end + + @impl MapCache + def set(key, value) do + ConCache.put(cache_name(), key, value) + end + + @impl MapCache + def update_all(value), do: update(cache_keys(), value) + + @impl MapCache + def update(keys, value) when is_list(keys) do + Enum.each(keys, &update(&1, value)) + end + + @impl MapCache + def update(key, value) do + ConCache.update(cache_name(), key, fn old_val -> handle_update(key, old_val, value) end) + end + + ### Autogenerated named functions + + unquote(Enum.map(keys, &named_functions(&1))) + + ### Overridable callback functions + + @impl MapCache + def handle_update(_key, _old_value, new_value), do: {:ok, new_value} + + @impl MapCache + def handle_fallback(_key), do: {:return, nil} + + defoverridable handle_update: 3, handle_fallback: 1 + + ### Supervisor's child specification + + @doc """ + The child specification for a Supervisor. Note that all the `params` + provided to this function will override the ones set by using the macro + """ + def child_spec(params \\ []) do + params = Keyword.merge(unquote(concache_params), params) + + Supervisor.child_spec({ConCache, params}, id: child_id()) + end + + def child_id, do: {ConCache, cache_name()} + end + end + + # sobelow_skip ["DOS"] + defp named_functions(key) do + quote do + # sobelow_skip ["DOS"] + def unquote(:"get_#{key}")(), do: get(unquote(key)) + + # sobelow_skip ["DOS"] + def unquote(:"set_#{key}")(value), do: set(unquote(key), value) + + # sobelow_skip ["DOS"] + def unquote(:"update_#{key}")(value), do: update(unquote(key), value) + end + end +end diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index eb7c4571cd..c34cf62d49 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -102,7 +102,7 @@ defmodule Explorer.Chain.Supply.RSK do def cache_name, do: @cache_name defp fetch_circulating_value do - max_number = BlockNumber.max_number() + max_number = BlockNumber.get_max() params = [ %{block_quantity: integer_to_quantity(max_number), hash_data: "0x0000000000000000000000000000000001000006"} diff --git a/apps/explorer/test/explorer/chain/cache/block_count_test.exs b/apps/explorer/test/explorer/chain/cache/block_count_test.exs index 646af8de43..108c929a75 100644 --- a/apps/explorer/test/explorer/chain/cache/block_count_test.exs +++ b/apps/explorer/test/explorer/chain/cache/block_count_test.exs @@ -3,53 +3,53 @@ defmodule Explorer.Chain.Cache.BlockCountTest do alias Explorer.Chain.Cache.BlockCount - test "returns default transaction count" do - BlockCount.start_link(name: BlockTestCache) + setup do + Supervisor.terminate_child(Explorer.Supervisor, BlockCount.child_id()) + Supervisor.restart_child(Explorer.Supervisor, BlockCount.child_id()) + :ok + end - result = BlockCount.count(BlockTestCache) + test "returns default transaction count" do + result = BlockCount.get_count() assert is_nil(result) end test "updates cache if initial value is zero" do - BlockCount.start_link(name: BlockTestCache) - insert(:block, consensus: true) insert(:block, consensus: true) insert(:block, consensus: false) - _result = BlockCount.count(BlockTestCache) + _result = BlockCount.get_count() Process.sleep(1000) - updated_value = BlockCount.count(BlockTestCache) + updated_value = BlockCount.get_count() assert updated_value == 2 end test "does not update cache if cache period did not pass" do - BlockCount.start_link(name: BlockTestCache) - insert(:block, consensus: true) insert(:block, consensus: true) insert(:block, consensus: false) - _result = BlockCount.count(BlockTestCache) + _result = BlockCount.get_count() Process.sleep(1000) - updated_value = BlockCount.count(BlockTestCache) + updated_value = BlockCount.get_count() assert updated_value == 2 insert(:block, consensus: true) insert(:block, consensus: true) - _updated_value = BlockCount.count(BlockTestCache) + _updated_value = BlockCount.get_count() Process.sleep(1000) - updated_value = BlockCount.count(BlockTestCache) + updated_value = BlockCount.get_count() assert updated_value == 2 end diff --git a/apps/explorer/test/explorer/chain/cache/block_number_test.exs b/apps/explorer/test/explorer/chain/cache/block_number_test.exs index 381ded440b..64170695eb 100644 --- a/apps/explorer/test/explorer/chain/cache/block_number_test.exs +++ b/apps/explorer/test/explorer/chain/cache/block_number_test.exs @@ -11,49 +11,63 @@ defmodule Explorer.Chain.Cache.BlockNumberTest do end) end - describe "max_number/1" do + describe "get_max/1" do test "returns max number" do insert(:block, number: 5) - BlockNumber.setup() - - assert BlockNumber.max_number() == 5 + assert BlockNumber.get_max() == 5 end end - describe "min_number/1" do - test "returns max number" do + describe "get_min/1" do + test "returns min number" do insert(:block, number: 2) - BlockNumber.setup() + assert BlockNumber.get_min() == 2 + end + end - assert BlockNumber.max_number() == 2 + describe "get_all/1" do + test "returns min and max number" do + insert(:block, number: 6) + + assert BlockNumber.get_all() == %{min: 6, max: 6} end end - describe "update/1" do + describe "update_all/1" do test "updates max number" do insert(:block, number: 2) - BlockNumber.setup() - - assert BlockNumber.max_number() == 2 + assert BlockNumber.get_max() == 2 - assert BlockNumber.update(3) + assert BlockNumber.update_all(3) - assert BlockNumber.max_number() == 3 + assert BlockNumber.get_max() == 3 end test "updates min number" do insert(:block, number: 2) - BlockNumber.setup() + assert BlockNumber.get_min() == 2 + + assert BlockNumber.update_all(1) + + assert BlockNumber.get_min() == 1 + end + + test "updates min and number" do + insert(:block, number: 2) + + assert BlockNumber.get_all() == %{min: 2, max: 2} + + assert BlockNumber.update_all(1) - assert BlockNumber.min_number() == 2 + assert BlockNumber.get_all() == %{min: 1, max: 2} - assert BlockNumber.update(1) + assert BlockNumber.update_all(6) - assert BlockNumber.min_number() == 1 + assert BlockNumber.get_all() == %{min: 1, max: 6} end end end diff --git a/apps/explorer/test/explorer/chain/cache/blocks_test.exs b/apps/explorer/test/explorer/chain/cache/blocks_test.exs index 87f887ae26..41fe344a1e 100644 --- a/apps/explorer/test/explorer/chain/cache/blocks_test.exs +++ b/apps/explorer/test/explorer/chain/cache/blocks_test.exs @@ -5,8 +5,8 @@ defmodule Explorer.Chain.Cache.BlocksTest do alias Explorer.Repo setup do - Supervisor.terminate_child(Explorer.Supervisor, {ConCache, :blocks}) - Supervisor.restart_child(Explorer.Supervisor, {ConCache, :blocks}) + Supervisor.terminate_child(Explorer.Supervisor, Blocks.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Blocks.child_id()) :ok end diff --git a/apps/explorer/test/explorer/chain/cache/transaction_count_test.exs b/apps/explorer/test/explorer/chain/cache/transaction_count_test.exs index 5020486cb8..5385492de7 100644 --- a/apps/explorer/test/explorer/chain/cache/transaction_count_test.exs +++ b/apps/explorer/test/explorer/chain/cache/transaction_count_test.exs @@ -3,51 +3,51 @@ defmodule Explorer.Chain.Cache.TransactionCountTest do alias Explorer.Chain.Cache.TransactionCount - test "returns default transaction count" do - TransactionCount.start_link([[], [name: TestCache]]) + setup do + Supervisor.terminate_child(Explorer.Supervisor, TransactionCount.child_id()) + Supervisor.restart_child(Explorer.Supervisor, TransactionCount.child_id()) + :ok + end - result = TransactionCount.value(TestCache) + test "returns default transaction count" do + result = TransactionCount.get_count() assert is_nil(result) end test "updates cache if initial value is zero" do - TransactionCount.start_link([[], [name: TestCache]]) - insert(:transaction) insert(:transaction) - _result = TransactionCount.value(TestCache) + _result = TransactionCount.get_count() Process.sleep(1000) - updated_value = TransactionCount.value(TestCache) + updated_value = TransactionCount.get_count() assert updated_value == 2 end test "does not update cache if cache period did not pass" do - TransactionCount.start_link([[], [name: TestCache]]) - insert(:transaction) insert(:transaction) - _result = TransactionCount.value(TestCache) + _result = TransactionCount.get_count() Process.sleep(1000) - updated_value = TransactionCount.value(TestCache) + updated_value = TransactionCount.get_count() assert updated_value == 2 insert(:transaction) insert(:transaction) - _updated_value = TransactionCount.value(TestCache) + _updated_value = TransactionCount.get_count() Process.sleep(1000) - updated_value = TransactionCount.value(TestCache) + updated_value = TransactionCount.get_count() assert updated_value == 2 end diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index f49be6da4e..ee1b8ed987 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -1121,23 +1121,31 @@ defmodule Explorer.ChainTest do end end - describe "fetch_min_and_max_block_numbers/0" do - test "fetches min and max block numbers" do + describe "fetch_min_block_number/0" do + test "fetches min block numbers" do for index <- 5..9 do insert(:block, number: index) end - assert {5, 9} = Chain.fetch_min_and_max_block_numbers() + assert 5 = Chain.fetch_min_block_number() end - test "fetches min and max when there are no blocks" do - assert {0, 0} = Chain.fetch_min_and_max_block_numbers() + test "fetches min when there are no blocks" do + assert 0 = Chain.fetch_min_block_number() end + end - test "fetches min and max where there is only one block" do - insert(:block, number: 1) + describe "fetch_max_block_number/0" do + test "fetches max block numbers" do + for index <- 5..9 do + insert(:block, number: index) + end + + assert 9 = Chain.fetch_max_block_number() + end - assert {1, 1} = Chain.fetch_min_and_max_block_numbers() + test "fetches max when there are no blocks" do + assert 0 = Chain.fetch_max_block_number() end end diff --git a/apps/explorer/test/support/data_case.ex b/apps/explorer/test/support/data_case.ex index fa87839725..47c15bbca0 100644 --- a/apps/explorer/test/support/data_case.ex +++ b/apps/explorer/test/support/data_case.ex @@ -39,7 +39,8 @@ defmodule Explorer.DataCase do Ecto.Adapters.SQL.Sandbox.mode(Explorer.Repo, {:shared, self()}) end - Explorer.Chain.Cache.BlockNumber.setup() + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.BlockNumber.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.BlockNumber.child_id()) Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Transactions.child_id()) diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index a8b28d1391..28002f010a 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -184,11 +184,10 @@ defmodule Indexer.Block.Fetcher do end defp update_block_cache(blocks) when is_list(blocks) do - max_block = Enum.max_by(blocks, fn block -> block.number end) - min_block = Enum.min_by(blocks, fn block -> block.number end) + {min_block, max_block} = Enum.min_max_by(blocks, & &1.number) - BlockNumber.update(max_block.number) - BlockNumber.update(min_block.number) + BlockNumber.update_all(max_block.number) + BlockNumber.update_all(min_block.number) BlocksCache.update(blocks) end @@ -269,7 +268,7 @@ defmodule Indexer.Block.Fetcher do end def async_import_internal_transactions(%{transactions: transactions}, EthereumJSONRPC.Geth) do - {_, max_block_number} = Chain.fetch_min_and_max_block_numbers() + max_block_number = Chain.fetch_max_block_number() transactions |> Enum.flat_map(fn diff --git a/apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex b/apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex index 4dfed6e73a..d6d7d66d71 100644 --- a/apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex +++ b/apps/indexer/lib/indexer/fetcher/coin_balance_on_demand.ex @@ -162,7 +162,7 @@ defmodule Indexer.Fetcher.CoinBalanceOnDemand do end defp latest_block_number do - BlockNumber.max_number() + BlockNumber.get_max() end defp stale_balance_window(block_number) do From b9f9bbfac7979efdff1f34f475f2bce78adecc04 Mon Sep 17 00:00:00 2001 From: Ethan van Ballegooyen Date: Mon, 26 Aug 2019 20:39:29 +0200 Subject: [PATCH 257/290] Removed "nav-item-networks" Having "nav-item-networks" causes the networks menu button on mobile to be pushed to the right, by removing it, it corrects this and moves the menu inline with the rest. --- .../lib/block_scout_web/templates/layout/_topnav.html.eex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 970206636c..a990e73000 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -99,7 +99,7 @@

<% end %> -