From 17a9ee44e7aee2d7075a98afdfd37b48509b3c6e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 15 May 2019 14:10:25 +0300 Subject: [PATCH] add docs --- .../lib/block_scout_web/etherscan.ex | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) 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 3621a12d10..89c2927a9e 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -279,6 +279,12 @@ defmodule BlockScoutWeb.Etherscan do "result" => nil } + @block_eth_block_number_example_value %{ + "jsonrpc" => "2.0", + "result" => "767969", + "id" => 1 + } + @contract_listcontracts_example_value %{ "status" => "1", "message" => "OK", @@ -476,11 +482,26 @@ defmodule BlockScoutWeb.Etherscan do enum_interpretation: %{"0" => "error", "1" => "ok"} } + @jsonrpc_version_type %{ + type: "string", + example: ~s("2.0") + } + @message_type %{ type: "string", example: ~s("OK") } + @hex_number_type %{ + type: "string", + example: ~s("767969") + } + + @id_type %{ + type: "string", + example: ~s("1") + } + @wei_type %{ type: "wei", definition: &__MODULE__.wei_type_definition/1, @@ -1737,6 +1758,35 @@ defmodule BlockScoutWeb.Etherscan do ] } + @block_eth_block_number_action %{ + name: "eth_block_number", + description: "Mimics Ethereum JSON RPC's eth_blockNumber. Returns the lastest block number", + required_params: [], + optional_params: [ + %{ + key: "id", + placeholder: "request id", + type: "integer", + description: "A nonnegative integer that represents the json rpc request id." + } + ], + responses: [ + %{ + code: "200", + description: "successful request", + example_value: Jason.encode!(@block_eth_block_number_example_value), + model: %{ + name: "Result", + fields: %{ + jsonrpc: @jsonrpc_version_type, + id: @id_type, + result: @hex_number_type + } + } + } + ] + } + @block_getblockreward_action %{ name: "getblockreward", description: "Get block reward by block number.", @@ -2171,7 +2221,7 @@ defmodule BlockScoutWeb.Etherscan do @block_module %{ name: "block", - actions: [@block_getblockreward_action] + actions: [@block_getblockreward_action, @block_eth_block_number_action] } @contract_module %{