From c9250b6991b978a2d2d5814ec4fbb5e136f24f66 Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 25 Jul 2019 13:31:13 +0300 Subject: [PATCH 01/29] 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/29] 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/29] 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/29] 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/29] 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 77b7d34d50225ad68b47cd0565ec972e33decc3e Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 6 Aug 2019 19:53:43 +0300 Subject: [PATCH 06/29] Isolating staking dapp css, extracting of non-critical css --- apps/block_scout_web/assets/css/app.scss | 20 ++---- .../assets/css/components/_modal.scss | 6 -- .../css/components/_modal_variables.scss | 5 ++ .../assets/css/components/_stakes_table.scss | 2 + .../components/{ => stakes}/_copy_icon.scss | 0 .../{ => stakes}/_modal_become_candidate.scss | 0 .../_modal_bottom_disclaimer.scss | 0 .../components/{ => stakes}/_modal_stake.scss | 0 .../{ => stakes}/_modal_validator_info.scss | 0 .../{ => stakes}/_progress_from_to.scss | 0 .../css/components/{ => stakes}/_stakes.scss | 0 .../{ => stakes}/_stakes_btn_remove_pool.scss | 0 .../{ => stakes}/_stakes_empty_content.scss | 0 .../{ => stakes}/_stakes_progress.scss | 3 + .../assets/css/non-critical.scss | 13 ++++ apps/block_scout_web/assets/css/stakes.scss | 19 ++++++ .../block_scout_web/assets/js/non-critical.js | 63 +++++++++++++++++++ .../block_scout_web/assets/js/pages/stakes.js | 1 + apps/block_scout_web/assets/package.json | 4 +- apps/block_scout_web/assets/webpack.config.js | 10 ++- .../templates/layout/app.html.eex | 2 + 21 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 apps/block_scout_web/assets/css/components/_modal_variables.scss rename apps/block_scout_web/assets/css/components/{ => stakes}/_copy_icon.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_modal_become_candidate.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_modal_bottom_disclaimer.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_modal_stake.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_modal_validator_info.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_progress_from_to.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_stakes.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_stakes_btn_remove_pool.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_stakes_empty_content.scss (100%) rename apps/block_scout_web/assets/css/components/{ => stakes}/_stakes_progress.scss (93%) create mode 100644 apps/block_scout_web/assets/css/non-critical.scss create mode 100644 apps/block_scout_web/assets/css/stakes.scss create mode 100644 apps/block_scout_web/assets/js/non-critical.js create mode 100644 apps/block_scout_web/assets/js/pages/stakes.js diff --git a/apps/block_scout_web/assets/css/app.scss b/apps/block_scout_web/assets/css/app.scss index e91df91740..4a914c6944 100644 --- a/apps/block_scout_web/assets/css/app.scss +++ b/apps/block_scout_web/assets/css/app.scss @@ -24,7 +24,6 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "node_modules/bootstrap/scss/reboot"; @import "node_modules/bootstrap/scss/grid"; @import "node_modules/bootstrap/scss/code"; -@import "node_modules/bootstrap/scss/modal"; @import "node_modules/bootstrap/scss/close"; @import "node_modules/bootstrap/scss/buttons"; @import "node_modules/bootstrap/scss/forms"; @@ -50,7 +49,6 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "node_modules/bootstrap/scss/navbar"; @import "node_modules/bootstrap/scss/pagination"; @import "node_modules/bootstrap/scss/tables"; -@import "node_modules/bootstrap/scss/tooltip"; @import "node_modules/bootstrap/scss/transitions"; // Code highlight @@ -75,8 +73,10 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/filter"; @import "components/button"; @import "components/table"; -@import "components/qr-code"; @import "components/navbar"; + +@import "theme/dark-theme"; + @import "components/animations"; @import "components/card"; @import "components/tile"; @@ -93,26 +93,14 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/transaction-input"; @import "components/coin-balance-tile"; @import "components/highlight"; -@import "components/copy_icon"; @import "components/btn_full"; @import "components/btn_line"; -@import "components/stakes"; @import "components/check"; @import "components/stakes_table"; @import "components/i_tooltip"; @import "components/check_tooltip"; @import "components/tooltip"; -@import "components/progress_from_to"; -@import "components/stakes_empty_content"; -@import "components/stakes_btn_remove_pool"; -@import "components/modal"; -@import "components/modal_validator_info"; @import "components/form"; -@import "components/stakes_progress"; -@import "components/modal_status"; -@import "components/modal_bottom_disclaimer"; -@import "components/modal_become_candidate"; -@import "components/modal_stake"; @import "components/btn_copy"; @import "components/btn_qr"; @import "components/btn_address_card"; @@ -124,11 +112,11 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/errors"; @import "components/log-search"; @import "components/radio"; +@import "components/modal_variables"; @import "components/network-selector"; @import "components/new_smart_contract"; @import "components/radio_big"; @import "components/btn_no_border"; -@import "theme/dark-theme"; :export { dashboardBannerChartAxisFontColor: $dashboard-banner-chart-axis-font-color; diff --git a/apps/block_scout_web/assets/css/components/_modal.scss b/apps/block_scout_web/assets/css/components/_modal.scss index bc9e16c875..4e70be687c 100644 --- a/apps/block_scout_web/assets/css/components/_modal.scss +++ b/apps/block_scout_web/assets/css/components/_modal.scss @@ -1,9 +1,3 @@ -$modal-overlay-color: rgba($primary, 0.9) !default; -$modal-horizontal-padding: 30px !default; -$modal-vertical-padding: 25px !default; -$modal-border-radius: 10px !default; -$modal-gray-background: #f6f7f9 !default; - .modal-backdrop { background-color: $modal-overlay-color; diff --git a/apps/block_scout_web/assets/css/components/_modal_variables.scss b/apps/block_scout_web/assets/css/components/_modal_variables.scss new file mode 100644 index 0000000000..92e2a94a33 --- /dev/null +++ b/apps/block_scout_web/assets/css/components/_modal_variables.scss @@ -0,0 +1,5 @@ +$modal-overlay-color: rgba($primary, 0.9) !default; +$modal-horizontal-padding: 30px !default; +$modal-vertical-padding: 25px !default; +$modal-border-radius: 10px !default; +$modal-gray-background: #f6f7f9 !default; \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/components/_stakes_table.scss b/apps/block_scout_web/assets/css/components/_stakes_table.scss index 1831dc4d5b..46530836fb 100644 --- a/apps/block_scout_web/assets/css/components/_stakes_table.scss +++ b/apps/block_scout_web/assets/css/components/_stakes_table.scss @@ -1,5 +1,7 @@ $stakes-table-th-background: #f5f6fa !default; $stakes-table-cell-separation: 25px !default; +$stakes-banned-background: #fff3f7 !default; +$stakes-banned-color: #ff7986 !default; .stakes-table-container { max-width: 100%; diff --git a/apps/block_scout_web/assets/css/components/_copy_icon.scss b/apps/block_scout_web/assets/css/components/stakes/_copy_icon.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_copy_icon.scss rename to apps/block_scout_web/assets/css/components/stakes/_copy_icon.scss diff --git a/apps/block_scout_web/assets/css/components/_modal_become_candidate.scss b/apps/block_scout_web/assets/css/components/stakes/_modal_become_candidate.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_modal_become_candidate.scss rename to apps/block_scout_web/assets/css/components/stakes/_modal_become_candidate.scss diff --git a/apps/block_scout_web/assets/css/components/_modal_bottom_disclaimer.scss b/apps/block_scout_web/assets/css/components/stakes/_modal_bottom_disclaimer.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_modal_bottom_disclaimer.scss rename to apps/block_scout_web/assets/css/components/stakes/_modal_bottom_disclaimer.scss diff --git a/apps/block_scout_web/assets/css/components/_modal_stake.scss b/apps/block_scout_web/assets/css/components/stakes/_modal_stake.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_modal_stake.scss rename to apps/block_scout_web/assets/css/components/stakes/_modal_stake.scss diff --git a/apps/block_scout_web/assets/css/components/_modal_validator_info.scss b/apps/block_scout_web/assets/css/components/stakes/_modal_validator_info.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_modal_validator_info.scss rename to apps/block_scout_web/assets/css/components/stakes/_modal_validator_info.scss diff --git a/apps/block_scout_web/assets/css/components/_progress_from_to.scss b/apps/block_scout_web/assets/css/components/stakes/_progress_from_to.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_progress_from_to.scss rename to apps/block_scout_web/assets/css/components/stakes/_progress_from_to.scss diff --git a/apps/block_scout_web/assets/css/components/_stakes.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_stakes.scss rename to apps/block_scout_web/assets/css/components/stakes/_stakes.scss diff --git a/apps/block_scout_web/assets/css/components/_stakes_btn_remove_pool.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes_btn_remove_pool.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_stakes_btn_remove_pool.scss rename to apps/block_scout_web/assets/css/components/stakes/_stakes_btn_remove_pool.scss diff --git a/apps/block_scout_web/assets/css/components/_stakes_empty_content.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes_empty_content.scss similarity index 100% rename from apps/block_scout_web/assets/css/components/_stakes_empty_content.scss rename to apps/block_scout_web/assets/css/components/stakes/_stakes_empty_content.scss diff --git a/apps/block_scout_web/assets/css/components/_stakes_progress.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss similarity index 93% rename from apps/block_scout_web/assets/css/components/_stakes_progress.scss rename to apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss index 4159099fcd..002860110c 100644 --- a/apps/block_scout_web/assets/css/components/_stakes_progress.scss +++ b/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss @@ -1,3 +1,6 @@ +$modal-horizontal-padding: 30px !default; +$modal-vertical-padding: 25px !default; + .stakes-progress { .modal-stake-right & { border-left: 1px solid $base-border-color; diff --git a/apps/block_scout_web/assets/css/non-critical.scss b/apps/block_scout_web/assets/css/non-critical.scss new file mode 100644 index 0000000000..81d5bd2b09 --- /dev/null +++ b/apps/block_scout_web/assets/css/non-critical.scss @@ -0,0 +1,13 @@ +// Bootstrap Core CSS +@import "node_modules/bootstrap/scss/functions"; +@import "node_modules/bootstrap/scss/mixins"; + +@import "theme/variables"; + +@import "node_modules/bootstrap/scss/modal"; +@import "node_modules/bootstrap/scss/tooltip"; + +@import "components/qr-code"; +@import "components/modal_variables"; +@import "components/modal"; +@import "components/modal_status"; \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/stakes.scss b/apps/block_scout_web/assets/css/stakes.scss new file mode 100644 index 0000000000..81410e12f0 --- /dev/null +++ b/apps/block_scout_web/assets/css/stakes.scss @@ -0,0 +1,19 @@ +@import "./mixins"; + +// Bootstrap Core CSS +@import "node_modules/bootstrap/scss/functions"; +@import "node_modules/bootstrap/scss/mixins"; + +@import "theme/variables"; + +@import "components/stakes/copy_icon"; +@import "components/stakes/stakes"; +@import "components/stakes/progress_from_to"; +@import "components/stakes/stakes_empty_content"; +@import "components/stakes/stakes_btn_remove_pool"; +@import "components/stakes/stakes_progress"; +@import "components/modal_variables"; +@import "components/stakes/modal_stake"; +@import "components/stakes/modal_become_candidate"; +@import "components/stakes/modal_validator_info"; +@import "components/stakes/modal_bottom_disclaimer"; \ No newline at end of file diff --git a/apps/block_scout_web/assets/js/non-critical.js b/apps/block_scout_web/assets/js/non-critical.js new file mode 100644 index 0000000000..89059dd306 --- /dev/null +++ b/apps/block_scout_web/assets/js/non-critical.js @@ -0,0 +1,63 @@ +// We need to import the CSS so that webpack will load it. +// The ExtractTextPlugin is used to separate it out into +// its own CSS file. +import '../css/app.scss' + +// webpack automatically concatenates all files in your +// watched paths. Those paths can be configured as +// endpoints in "webpack.config.js". +// +// Import dependencies +// +import '@babel/polyfill' +import 'phoenix_html' +import 'bootstrap' + +// Import local files +// +// Local files can be imported directly using relative +// paths "./socket" or full ones "web/static/js/socket". + +import './locale' + +import './pages/address' +import './pages/address/coin_balances' +import './pages/address/transactions' +import './pages/address/logs' +import './pages/address/validations' +import './pages/address/internal_transactions' +import './pages/blocks' +import './pages/chain' +import './pages/pending_transactions' +import './pages/transaction' +import './pages/transactions' +import './pages/favorites' +import './pages/network-search' +import './pages/layout' +import './pages/verification_form' +import './pages/dark-mode-switcher' + +import './pages/admin/tasks.js' + +import './lib/clipboard_buttons' +import './lib/currency' +import './lib/from_now' +import './lib/indexing' +import './lib/loading_element' +import './lib/market_history_chart' +import './lib/pending_transactions_toggle' +import './lib/pretty_json' +import './lib/reload_button' +import './lib/smart_contract/read_only_functions' +import './lib/smart_contract/wei_ether_converter' +import './lib/stop_propagation' +import './lib/token_balance_dropdown' +import './lib/token_balance_dropdown_search' +import './lib/token_transfers_toggle' +import './lib/transaction_input_dropdown' +import './lib/async_listing_load' +import './lib/tooltip' +import './lib/modals' +import './lib/try_api' +import './lib/card_tabs' +import './lib/network_selector' diff --git a/apps/block_scout_web/assets/js/pages/stakes.js b/apps/block_scout_web/assets/js/pages/stakes.js new file mode 100644 index 0000000000..dd379d254f --- /dev/null +++ b/apps/block_scout_web/assets/js/pages/stakes.js @@ -0,0 +1 @@ +import '../../css/stakes.scss' diff --git a/apps/block_scout_web/assets/package.json b/apps/block_scout_web/assets/package.json index 3ae8973cca..1e8bc813cb 100644 --- a/apps/block_scout_web/assets/package.json +++ b/apps/block_scout_web/assets/package.json @@ -20,12 +20,12 @@ }, "dependencies": { "@fortawesome/fontawesome-free": "^5.1.0-4", - "highlight.js": "^9.13.1", - "highlightjs-solidity": "^1.0.6", "bignumber.js": "^7.2.1", "bootstrap": "^4.1.3", "chart.js": "^2.7.2", "clipboard": "^2.0.1", + "highlight.js": "^9.13.1", + "highlightjs-solidity": "^1.0.6", "humps": "^2.0.1", "jquery": "^3.3.1", "lodash": "^4.17.11", diff --git a/apps/block_scout_web/assets/webpack.config.js b/apps/block_scout_web/assets/webpack.config.js index f1091dcffb..6a50bd5a06 100644 --- a/apps/block_scout_web/assets/webpack.config.js +++ b/apps/block_scout_web/assets/webpack.config.js @@ -29,9 +29,13 @@ function transpileViewScript(file) { const appJs = { - entry: './js/app.js', + entry: { + app: './js/app.js', + stakes: './js/pages/stakes.js', + 'non-critical': './css/non-critical.scss', + }, output: { - filename: 'app.js', + filename: '[name].js', path: path.resolve(__dirname, '../priv/static/js') }, optimization: { @@ -80,7 +84,7 @@ const appJs = }, plugins: [ new MiniCssExtractPlugin({ - filename: '../css/app.css' + filename: '../css/[name].css' }), new CopyWebpackPlugin([{ from: 'static/', to: '../' }]), new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex index c3b0fe2ff1..15b2167d43 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex @@ -5,6 +5,8 @@ "> + + "> "> From 83ee47fc85142bfb3e0f9753ce073d19d5254bfc Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 6 Aug 2019 21:28:13 +0300 Subject: [PATCH 07/29] Update variables --- apps/block_scout_web/assets/css/app.scss | 1 + apps/block_scout_web/assets/css/components/_stakes_table.scss | 2 -- apps/block_scout_web/assets/css/components/stakes/_stakes.scss | 2 -- .../assets/css/components/stakes/_stakes_progress.scss | 3 --- apps/block_scout_web/assets/css/stakes.scss | 3 ++- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/assets/css/app.scss b/apps/block_scout_web/assets/css/app.scss index 4a914c6944..9c0f27e976 100644 --- a/apps/block_scout_web/assets/css/app.scss +++ b/apps/block_scout_web/assets/css/app.scss @@ -96,6 +96,7 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/btn_full"; @import "components/btn_line"; @import "components/check"; +@import "components/stakes_variables"; @import "components/stakes_table"; @import "components/i_tooltip"; @import "components/check_tooltip"; diff --git a/apps/block_scout_web/assets/css/components/_stakes_table.scss b/apps/block_scout_web/assets/css/components/_stakes_table.scss index 46530836fb..1831dc4d5b 100644 --- a/apps/block_scout_web/assets/css/components/_stakes_table.scss +++ b/apps/block_scout_web/assets/css/components/_stakes_table.scss @@ -1,7 +1,5 @@ $stakes-table-th-background: #f5f6fa !default; $stakes-table-cell-separation: 25px !default; -$stakes-banned-background: #fff3f7 !default; -$stakes-banned-color: #ff7986 !default; .stakes-table-container { max-width: 100%; diff --git a/apps/block_scout_web/assets/css/components/stakes/_stakes.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes.scss index 87271bc983..c6335ec066 100644 --- a/apps/block_scout_web/assets/css/components/stakes/_stakes.scss +++ b/apps/block_scout_web/assets/css/components/stakes/_stakes.scss @@ -1,8 +1,6 @@ $stakes-dashboard-copy-icon-color: $copy-icon-color !default; $stakes-address-color: $primary !default; $stakes-control-color: $primary !default; -$stakes-banned-color: #ff7986 !default; -$stakes-banned-background: #fff3f7 !default; $stakes-stats-item-color: #fff !default; $stakes-stats-item-border-color: #fff !default; diff --git a/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss b/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss index 002860110c..4159099fcd 100644 --- a/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss +++ b/apps/block_scout_web/assets/css/components/stakes/_stakes_progress.scss @@ -1,6 +1,3 @@ -$modal-horizontal-padding: 30px !default; -$modal-vertical-padding: 25px !default; - .stakes-progress { .modal-stake-right & { border-left: 1px solid $base-border-color; diff --git a/apps/block_scout_web/assets/css/stakes.scss b/apps/block_scout_web/assets/css/stakes.scss index 81410e12f0..77ada07b46 100644 --- a/apps/block_scout_web/assets/css/stakes.scss +++ b/apps/block_scout_web/assets/css/stakes.scss @@ -6,13 +6,14 @@ @import "theme/variables"; +@import "components/stakes_variables"; @import "components/stakes/copy_icon"; @import "components/stakes/stakes"; @import "components/stakes/progress_from_to"; @import "components/stakes/stakes_empty_content"; @import "components/stakes/stakes_btn_remove_pool"; -@import "components/stakes/stakes_progress"; @import "components/modal_variables"; +@import "components/stakes/stakes_progress"; @import "components/stakes/modal_stake"; @import "components/stakes/modal_become_candidate"; @import "components/stakes/modal_validator_info"; From 023d9d13a437a57feafd476be33fd294cdd60b85 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 6 Aug 2019 21:32:42 +0300 Subject: [PATCH 08/29] stakes_variables.scss --- CHANGELOG.md | 1 + .../assets/css/components/_stakes_variables.scss | 2 ++ apps/block_scout_web/priv/gettext/default.pot | 16 ++++++++-------- .../priv/gettext/en/LC_MESSAGES/default.po | 16 ++++++++-------- 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 apps/block_scout_web/assets/css/components/_stakes_variables.scss diff --git a/CHANGELOG.md b/CHANGELOG.md index 62d1cc05b7..619b9ff6f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2456](https://github.com/poanetwork/blockscout/pull/2456) - fetch pending transactions for geth ### Fixes +- [#2514](https://github.com/poanetwork/blockscout/pull/2514) - Isolating of staking dapp css && extracting of non-critical css - [#2503](https://github.com/poanetwork/blockscout/pull/2503) - Mitigate autocompletion library influence to page loading performance - [#2502](https://github.com/poanetwork/blockscout/pull/2502) - increase reward task timeout - [#2463](https://github.com/poanetwork/blockscout/pull/2463) - dark theme fixes diff --git a/apps/block_scout_web/assets/css/components/_stakes_variables.scss b/apps/block_scout_web/assets/css/components/_stakes_variables.scss new file mode 100644 index 0000000000..4c23ea421b --- /dev/null +++ b/apps/block_scout_web/assets/css/components/_stakes_variables.scss @@ -0,0 +1,2 @@ +$stakes-banned-background: #fff3f7 !default; +$stakes-banned-color: #ff7986 !default; \ No newline at end of file diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 95bb1f079b..1ea7381c9a 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -62,7 +62,7 @@ msgid "(query)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:36 +#: lib/block_scout_web/templates/layout/app.html.eex:38 msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" @@ -157,7 +157,7 @@ msgid "Block Height: %{height}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:51 +#: lib/block_scout_web/templates/layout/app.html.eex:53 msgid "Block Mined, awaiting import..." msgstr "" @@ -184,7 +184,7 @@ msgid "Blocks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:50 +#: lib/block_scout_web/templates/layout/app.html.eex:52 msgid "Blocks Indexed" msgstr "" @@ -368,7 +368,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_balance_card.html.eex:15 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:21 -#: lib/block_scout_web/templates/layout/app.html.eex:56 +#: lib/block_scout_web/templates/layout/app.html.eex:58 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_tile.html.eex:30 #: lib/block_scout_web/templates/transaction/overview.html.eex:196 @@ -446,7 +446,7 @@ msgid "IN" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:52 +#: lib/block_scout_web/templates/layout/app.html.eex:54 msgid "Indexing Tokens" msgstr "" @@ -478,7 +478,7 @@ msgid "Inventory" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:53 +#: lib/block_scout_web/templates/layout/app.html.eex:55 msgid "Less than" msgstr "" @@ -499,7 +499,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:31 -#: lib/block_scout_web/templates/layout/app.html.eex:54 +#: lib/block_scout_web/templates/layout/app.html.eex:56 #: lib/block_scout_web/views/address_view.ex:121 #: lib/block_scout_web/views/address_view.ex:121 msgid "Market Cap" @@ -615,7 +615,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:24 -#: lib/block_scout_web/templates/layout/app.html.eex:55 +#: lib/block_scout_web/templates/layout/app.html.eex:57 msgid "Price" 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 6ecd22e7fa..21d90a2493 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 @@ -62,7 +62,7 @@ msgid "(query)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:36 +#: lib/block_scout_web/templates/layout/app.html.eex:38 msgid "- We're indexing this chain right now. Some of the counts may be inaccurate." msgstr "" @@ -157,7 +157,7 @@ msgid "Block Height: %{height}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:51 +#: lib/block_scout_web/templates/layout/app.html.eex:53 msgid "Block Mined, awaiting import..." msgstr "" @@ -184,7 +184,7 @@ msgid "Blocks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:50 +#: lib/block_scout_web/templates/layout/app.html.eex:52 msgid "Blocks Indexed" msgstr "" @@ -368,7 +368,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_balance_card.html.eex:15 #: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:21 -#: lib/block_scout_web/templates/layout/app.html.eex:56 +#: lib/block_scout_web/templates/layout/app.html.eex:58 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20 #: lib/block_scout_web/templates/transaction/_tile.html.eex:30 #: lib/block_scout_web/templates/transaction/overview.html.eex:196 @@ -446,7 +446,7 @@ msgid "IN" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:52 +#: lib/block_scout_web/templates/layout/app.html.eex:54 msgid "Indexing Tokens" msgstr "" @@ -478,7 +478,7 @@ msgid "Inventory" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/layout/app.html.eex:53 +#: lib/block_scout_web/templates/layout/app.html.eex:55 msgid "Less than" msgstr "" @@ -499,7 +499,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:31 -#: lib/block_scout_web/templates/layout/app.html.eex:54 +#: lib/block_scout_web/templates/layout/app.html.eex:56 #: lib/block_scout_web/views/address_view.ex:121 #: lib/block_scout_web/views/address_view.ex:121 msgid "Market Cap" @@ -615,7 +615,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:24 -#: lib/block_scout_web/templates/layout/app.html.eex:55 +#: lib/block_scout_web/templates/layout/app.html.eex:57 msgid "Price" msgstr "" From d8d4e8ccd83201f1757560e0a36d3f7a5b7295b7 Mon Sep 17 00:00:00 2001 From: saneery Date: Wed, 7 Aug 2019 12:08:56 +0300 Subject: [PATCH 09/29] 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 10/29] 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 11/29] 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 12/29] 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 @@
-
-