From aff26adbaf048facd26d40737c4d071634eb2164 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 22 Dec 2020 18:46:49 +0300 Subject: [PATCH 1/2] Integer input: easy setting of precision --- CHANGELOG.md | 3 ++- .../assets/css/components/_card.scss | 19 ++++++++++++++++ .../assets/css/components/_dropdown.scss | 5 +++++ .../assets/js/lib/smart_contract/functions.js | 18 +++++++++++++++ .../smart_contract/_functions.html.eex | 22 ++++++++++++++++--- .../views/smart_contract_view.ex | 1 + apps/block_scout_web/priv/gettext/default.pot | 10 ++++----- .../priv/gettext/en/LC_MESSAGES/default.po | 10 ++++----- 8 files changed, 74 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74be18a38a..e94b11570d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#3532](https://github.com/poanetwork/blockscout/pull/3532) - Contract interaction: an easy setting of precision for integer input - [#3531](https://github.com/poanetwork/blockscout/pull/3531) - Allow double quotes in input data of contract methods - [#3515](https://github.com/poanetwork/blockscout/pull/3515) - CRC total balance - [#3513](https://github.com/poanetwork/blockscout/pull/3513) - Allow square brackets for an array input data in contracts interaction @@ -16,7 +17,7 @@ - [#3513](https://github.com/poanetwork/blockscout/pull/3513) - Fix input data processing for method call (array type of data) - [#3509](https://github.com/poanetwork/blockscout/pull/3509) - Fix QR code tooltip appearance in mobile view - [#3507](https://github.com/poanetwork/blockscout/pull/3507), [#3510](https://github.com/poanetwork/blockscout/pull/3510) - Fix left margin of balance card in mobile view -- [#3506](https://github.com/poanetwork/blockscout/pull/3506) - Fix token trasfer's tile styles: prevent overlapping of long names +- [#3506](https://github.com/poanetwork/blockscout/pull/3506) - Fix token transfer's tile styles: prevent overlapping of long names - [#3505](https://github.com/poanetwork/blockscout/pull/3505) - Fix Staking DApp first loading - [#3433](https://github.com/poanetwork/blockscout/pull/3433) - Token balances and rewards tables deadlocks elimination - [#3494](https://github.com/poanetwork/blockscout/pull/3494), [#3497](https://github.com/poanetwork/blockscout/pull/3497), [#3504](https://github.com/poanetwork/blockscout/pull/3504), [#3517](https://github.com/poanetwork/blockscout/pull/3517) - Contracts interaction: fix method call with array[] inputs diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index a47f84869f..435fee5ef4 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -293,6 +293,25 @@ $card-tab-icon-color-active: #fff !default; padding: 6px 8px !important; height: 31px !important; font-size: 11px; + margin-left: 20px; +} + +.contract-plus-btn-container { + height: 31px !important; + &:hover i { + color: #fff !important; + } +} + +.contract-plus-btn { + color: $primary; + font-size: 15px; +} + +.custom-power-input { + height: 20px; + width: 50px !important; + margin-top: -10px !important; } .list-title-description { diff --git a/apps/block_scout_web/assets/css/components/_dropdown.scss b/apps/block_scout_web/assets/css/components/_dropdown.scss index 5264a73902..b15f6c5c4a 100644 --- a/apps/block_scout_web/assets/css/components/_dropdown.scss +++ b/apps/block_scout_web/assets/css/components/_dropdown.scss @@ -28,6 +28,11 @@ $dropdown-menu-item-hover-background: rgba($secondary, 0.1) !default; border-top-right-radius: 0; } } + + &.exponention-dropdown { + width: 100px; + min-width: 100px; + } } .dropdown-item { diff --git a/apps/block_scout_web/assets/js/lib/smart_contract/functions.js b/apps/block_scout_web/assets/js/lib/smart_contract/functions.js index 98c2b0fc51..4f782801a1 100644 --- a/apps/block_scout_web/assets/js/lib/smart_contract/functions.js +++ b/apps/block_scout_web/assets/js/lib/smart_contract/functions.js @@ -52,6 +52,24 @@ const loadFunctions = (element) => { $('[data-function]').each((_, element) => { readWriteFunction(element) }) + + $('.contract-exponentiation-btn').on('click', (event) => { + const $customPower = $(event.currentTarget).find('[name=custom_power]') + let power + if ($customPower.length > 0) { + power = parseInt($customPower.val(), 10) + } else { + power = parseInt($(event.currentTarget).data('power'), 10) + } + const $input = $(event.currentTarget).parent().parent().parent().find('[name=function_input]') + const currentInputVal = parseInt($input.val(), 10) || 1 + const newInputVal = (currentInputVal * Math.pow(10, power)).toString() + $input.val(newInputVal.toString()) + }) + + $('[name=custom_power]').on('click', (event) => { + $(event.currentTarget).parent().parent().toggleClass('show') + }) }) .fail(function (response) { $element.html(response.statusText) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex index 976892eec0..307ccd2ea3 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex @@ -58,14 +58,30 @@ to: address_contract_path(@conn, :index, metadata_for_verification.address_hash) <%= if queryable?(function["inputs"]) do %> <%= for input <- function["inputs"] do %> -
- +
+ <%= if int?(input["type"]) do %> + + + + + + + + + <% else %> + + <% end %>
<% end %> <% end %> <%= if payable?(function) do %> -
+
<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex b/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex index b28098e84f..69a03441b8 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex @@ -34,6 +34,7 @@ defmodule BlockScoutWeb.SmartContractView do end def address?(type), do: type in ["address", "address payable"] + def int?(type), do: String.contains?(type, "int") && !String.contains?(type, "[") def named_argument?(%{"name" => ""}), do: false def named_argument?(%{"name" => nil}), do: false diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 3524370cc4..f13904c233 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -561,8 +561,8 @@ msgid "ERC-721 " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:69 -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:104 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:85 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:120 msgid "ETH" msgstr "" @@ -1182,7 +1182,7 @@ msgid "QR Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 msgid "Query" msgstr "" @@ -1635,7 +1635,7 @@ msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:103 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:119 msgid "WEI" msgstr "" @@ -1926,7 +1926,7 @@ msgid "Waiting for transaction's confirmation..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 msgid "Write" 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 3524370cc4..f13904c233 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 @@ -561,8 +561,8 @@ msgid "ERC-721 " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:69 -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:104 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:85 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:120 msgid "ETH" msgstr "" @@ -1182,7 +1182,7 @@ msgid "QR Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 msgid "Query" msgstr "" @@ -1635,7 +1635,7 @@ msgid "View transaction %{transaction} on %{subnetwork}" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:103 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:119 msgid "WEI" msgstr "" @@ -1926,7 +1926,7 @@ msgid "Waiting for transaction's confirmation..." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:73 +#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 msgid "Write" msgstr "" From 1c9c407d957c5d75ecec354e9184587c86a53233 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 23 Dec 2020 11:55:04 +0300 Subject: [PATCH 2/2] Dark mode fixes --- apps/block_scout_web/assets/css/theme/_dark-theme.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/block_scout_web/assets/css/theme/_dark-theme.scss b/apps/block_scout_web/assets/css/theme/_dark-theme.scss index c8be6c407a..b58a095d49 100644 --- a/apps/block_scout_web/assets/css/theme/_dark-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_dark-theme.scss @@ -1069,6 +1069,12 @@ $dark-stakes-banned-background: #3e314c; background: $yellow !important; } } + .contract-plus-btn { + color: $dark-primary; + } + .custom-power-input { + border-color: $dark-primary; + } } .navbar-dark .navbar-toggler {