From c9250b6991b978a2d2d5814ec4fbb5e136f24f66 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 25 Jul 2019 13:31:13 +0300 Subject: [PATCH 01/27] 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 @@ +
+ + +
+

+ <%= gettext "Parameters" %> + + +

+ +
+
+

<%= gettext "Name" %>

+

<%= gettext "Description" %>

+
+ + <%= for {name, description, type} <- @info.params do %> +
+
+
<%= name %>
+
+
+

<%= description %>

+ +
+
+ <% end %> + + +
+
+ +
+
+ +
+
+
+ + +
+
+
<%= gettext "Curl" %>
+
+

+        
+
+
<%= gettext "Server Response" %>
+
+

<%= gettext "Code" %>

+

<%= gettext "Details" %>

+
+
+
+
+

<%= gettext "Response Body" %>

+
+

+          
+
+
+
+ + +

<%= gettext "Responses" %>

+
+

<%= gettext "Code" %>

+
<%= gettext "Description" %>
+
+
+
200
+
+
+
successful operation
+
+ + + +
+ +
+
+

+            
+
+
+
+
+
+
\ 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 02/27] 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 03/27] 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 5e8eb7d6ab1932ac5c036d7cf1fc1eb00b3136ed Mon Sep 17 00:00:00 2001 From: saneery Date: Tue, 30 Jul 2019 13:24:05 +0300 Subject: [PATCH 04/27] Add default and required field to params --- .../templates/api_docs/_eth_rpc_item.html.eex | 83 ++++++++++--------- .../templates/api_docs/eth_rpc.html.eex | 8 +- apps/block_scout_web/priv/gettext/default.pot | 23 ++--- .../priv/gettext/en/LC_MESSAGES/default.po | 23 ++--- apps/explorer/lib/explorer/eth_rpc.ex | 20 ++++- 5 files changed, 89 insertions(+), 68 deletions(-) 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 14e69b95f5..60c26d25b0 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 @@ -8,7 +8,7 @@ >

<%= @action %>

-

<%= raw @info.notes %>

+

<%= raw @info.notes %>

curl -X POST --data '{"id":0,"jsonrpc":"2.0","method": "<%= @action %>", params: []}'

<%= raw @info.example %>

@@ -51,18 +51,27 @@

<%= gettext "Description" %>

- <%= for {name, description, type} <- @info.params do %> + <%= for param <- @info.params do %>
-
<%= name %>
+
+ <%= param.name %> + <%= if param.required do %> + + *<%= gettext "required" %> + + <% end %> +
-

<%= description %>

+

<%= param.description %>

" + data-parameter-type='<%= param.type %>' + data-required='<%= if param.required, do: "true", else: "false" %>' data-selector='<%= "eth-#{@action}-try-api-ui" %>' - type="text" + type="text", + value='<%= param.default %>' />
@@ -90,38 +99,38 @@ ><%= gettext "Clear" %> - - -
-
-
<%= gettext "Curl" %>
-
-

+      
+      
+
+
<%= gettext "Curl" %>
+
+

+          
-
-
<%= gettext "Server Response" %>
-
-

<%= gettext "Code" %>

-

<%= gettext "Details" %>

-
-
-
-
-

<%= gettext "Response Body" %>

-
-

+        
<%= gettext "Server Response" %>
+
+

<%= gettext "Code" %>

+

<%= gettext "Details" %>

+
+
+
+
+

<%= gettext "Response Body" %>

+
+

+            
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 2c2c453841..c85e4d3214 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 @@ -17,10 +17,8 @@
-
- <%= for {method, info} <- Map.to_list(@documentation) do %> - <%= render "_eth_rpc_item.html", action: method, info: info %> - <% end %> -
+ <%= for {method, info} <- Map.to_list(@documentation) do %> + <%= render "_eth_rpc_item.html", action: method, info: info %> + <% end %>
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index c483e91d5a..394355ce77 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -205,7 +205,7 @@ 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:99 msgid "Clear" msgstr "" @@ -222,8 +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/templates/api_docs/_eth_rpc_item.html.eex:119 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:142 #: lib/block_scout_web/views/address_view.ex:307 msgid "Code" msgstr "" @@ -329,7 +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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:109 msgid "Curl" msgstr "" @@ -337,14 +337,14 @@ msgstr "" #: 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:143 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:120 msgid "Details" msgstr "" @@ -386,13 +386,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:157 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:90 msgid "Execute" msgstr "" @@ -665,13 +665,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:127 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:140 msgid "Responses" msgstr "" @@ -690,7 +690,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:117 msgid "Server Response" msgstr "" @@ -1013,6 +1013,7 @@ msgstr "" #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:58 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:69 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:81 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:61 msgid "required" 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 0280cfb9e5..e4114af829 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 @@ -205,7 +205,7 @@ 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:99 msgid "Clear" msgstr "" @@ -222,8 +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/templates/api_docs/_eth_rpc_item.html.eex:119 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:142 #: lib/block_scout_web/views/address_view.ex:307 msgid "Code" msgstr "" @@ -329,7 +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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:109 msgid "Curl" msgstr "" @@ -337,14 +337,14 @@ msgstr "" #: 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:143 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:120 msgid "Details" msgstr "" @@ -386,13 +386,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:157 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:90 msgid "Execute" msgstr "" @@ -665,13 +665,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:127 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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:140 msgid "Responses" msgstr "" @@ -690,7 +690,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 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:117 msgid "Server Response" msgstr "" @@ -1013,6 +1013,7 @@ msgstr "" #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:58 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:69 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:81 +#: lib/block_scout_web/templates/api_docs/_eth_rpc_item.html.eex:61 msgid "required" msgstr "" diff --git a/apps/explorer/lib/explorer/eth_rpc.ex b/apps/explorer/lib/explorer/eth_rpc.ex index 3901248938..04d257ffb1 100644 --- a/apps/explorer/lib/explorer/eth_rpc.ex +++ b/apps/explorer/lib/explorer/eth_rpc.ex @@ -12,15 +12,27 @@ defmodule Explorer.EthRPC do "eth_getBalance" => %{ action: :eth_get_balance, notes: """ - the `earliest` parameter will not work as expected currently, because genesis block balances + The `earliest` parameter will not work as expected currently, because genesis block balances are not currently imported """, example: """ {"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"} + %{ + name: "Data", + description: "20 Bytes - address to check for balance", + type: "string", + default: nil, + required: true + }, + %{ + name: "Quantity|Tag", + description: "Integer block number, or the string \"latest\", \"earliest\" or \"pending\"", + type: "string", + default: "latest", + required: true + } ], result: """ {"id": 0, "jsonrpc": "2.0", "result": "0x0234c8a3397aab58"} @@ -42,7 +54,7 @@ defmodule Explorer.EthRPC do "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]} """, params: [ - {"Object", "The filter options", "json"} + %{name: "Object", description: "The filter options", type: "json", default: nil, required: true} ], result: """ { From 7200dfe1658afe14e587c93720783ab319029246 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 1 Aug 2019 12:28:28 +0300 Subject: [PATCH 05/27] Display required fields with default value as valid --- .../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 60c26d25b0..afb4501ab8 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 @@ -66,7 +66,7 @@

<%= param.description %>

" + class="collapse form-control <%= if param.required && !param.default, do: "form-control-danger is-invalid" %>" data-parameter-type='<%= param.type %>' data-required='<%= if param.required, do: "true", else: "false" %>' data-selector='<%= "eth-#{@action}-try-api-ui" %>' From d8d4e8ccd83201f1757560e0a36d3f7a5b7295b7 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 7 Aug 2019 12:08:56 +0300 Subject: [PATCH 06/27] Rounded borders for inputs --- .../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 afb4501ab8..77c8eee6a3 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 @@ -66,7 +66,7 @@

<%= param.description %>

" + class="collapse form-control border-rounded <%= if param.required && !param.default, do: "form-control-danger is-invalid" %>" data-parameter-type='<%= param.type %>' data-required='<%= if param.required, do: "true", else: "false" %>' data-selector='<%= "eth-#{@action}-try-api-ui" %>' From a4809b9571f710bee678189e3b42f5d0f6871236 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 7 Aug 2019 12:10:28 +0300 Subject: [PATCH 07/27] Focus borders on inputs are 1px --- apps/block_scout_web/assets/css/theme/_base_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/theme/_base_variables.scss b/apps/block_scout_web/assets/css/theme/_base_variables.scss index 2238327bd4..b4cf443f05 100644 --- a/apps/block_scout_web/assets/css/theme/_base_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_base_variables.scss @@ -359,7 +359,7 @@ $input-btn-padding-y: 0.375rem !default; $input-btn-padding-x: 0.75rem !default; $input-btn-line-height: $line-height-base !default; -$input-btn-focus-width: 0.2rem !default; +$input-btn-focus-width: 1px !default; $input-btn-focus-color: rgba($component-active-bg, 0.25) !default; $input-btn-focus-box-shadow: 0 0 0 $input-btn-focus-width $input-btn-focus-color !default; From 70c3479658d167cceeba3450c0af7649d5946df4 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 7 Aug 2019 12:42:09 +0300 Subject: [PATCH 08/27] Secondary color for focused imputs' borders --- apps/block_scout_web/assets/css/components/_form.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/block_scout_web/assets/css/components/_form.scss b/apps/block_scout_web/assets/css/components/_form.scss index 5346afcb7c..7f28a8786f 100644 --- a/apps/block_scout_web/assets/css/components/_form.scss +++ b/apps/block_scout_web/assets/css/components/_form.scss @@ -9,6 +9,10 @@ $form-control-border-color: #e2e5ec !default; border-radius: 4px; } + &:focus { + border-color: $secondary; + } + &.n-b-r { border-right: none; } From e51347894a439b740623579b673044331763468a Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 7 Aug 2019 12:46:35 +0300 Subject: [PATCH 09/27] update width of execute button --- .../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 77c8eee6a3..3121638341 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 @@ -81,7 +81,7 @@
-
-