added button to convert wei to ether and vice versa

pull/594/head
mulili 6 years ago committed by Luke Imhoff
parent 247ad179e2
commit bf3308bc94
  1. 3
      .gitignore
  2. 1
      apps/block_scout_web/assets/js/app.js
  3. 27
      apps/block_scout_web/assets/js/lib/smart_contract/wei_ether_converter.js
  4. 13
      apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex
  5. 10
      apps/block_scout_web/priv/gettext/default.pot
  6. 10
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  7. 166
      apps/explorer/package-lock.json

3
.gitignore vendored

@ -36,3 +36,6 @@ screenshots/
# Sobelow
.sobelow
# osx
.DS_Store

@ -28,6 +28,7 @@ import './lib/market_history_chart'
import './lib/reload_button'
import './lib/tooltip'
import './lib/smart_contract/read_only_functions'
import './lib/smart_contract/wei_ether_converter'
import './lib/pretty_json'
import './lib/try_api'
import './lib/token_balance_dropdown'

@ -0,0 +1,27 @@
import $ from 'jquery'
import { BigNumber } from 'bignumber.js'
const weiToEtherConverter = (element, event) => {
const weiUnit = '1000000000000000000'
const $element = $(element)
const $conversionTextWei = $element.find('[data-conversion-text-wei]')
const $conversionTextEth = $element.find('[data-conversion-text-eth]')
const $conversionUnit = $element.find('[data-conversion-unit]')
let unitVal = new BigNumber($conversionUnit.html())
if (event.target.checked) {
$conversionTextWei.css({display: 'none'})
$conversionTextEth.css({display: 'inline-block'})
unitVal = unitVal / new BigNumber(weiUnit)
$conversionUnit.html(String(unitVal > 0 ? unitVal : unitVal.toFixed(3)))
} else {
$conversionTextWei.css({display: 'inline-block'})
$conversionTextEth.css({display: 'none'})
unitVal = unitVal * new BigNumber(weiUnit)
$conversionUnit.html(unitVal)
}
}
$('[data-smart-contract-functions]').on('change', '[data-wei-ether-converter]', function (event) {
weiToEtherConverter(this, event)
})

@ -41,7 +41,20 @@
to: address_path(@conn, :show, output["value"])
) %>
<% else %>
<%= if output["type"] == "uint256" do %>
<div data-wei-ether-converter>
<span data-conversion-unit>
<%= output["value"] %>
</span>
<span class="py-2 px-2">
<input class="wei-ether" type="checkbox" autocomplete="off">
<span style="display: inline-block;" data-conversion-text-wei><%= gettext("WEI")%></span>
<span style="display: none;" data-conversion-text-eth><%= gettext("ETH")%></span>
<span>
</div>
<% else %>
<%= output["value"] %>
<% end %>
<% end %>
<% end %>
</span>

@ -688,6 +688,16 @@ msgstr ""
msgid "Query"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:51
msgid "WEI"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:52
msgid "ETH"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:44
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:49

@ -700,6 +700,16 @@ msgstr ""
msgid "Query"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:51
msgid "WEI"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:52
msgid "ETH"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:44
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:49

@ -18,7 +18,7 @@
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "1.0.0",
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
@ -37,9 +37,9 @@
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
"integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=",
"requires": {
"string-width": "1.0.2",
"strip-ansi": "3.0.1",
"wrap-ansi": "2.1.0"
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1",
"wrap-ansi": "^2.0.0"
}
},
"code-point-at": {
@ -62,7 +62,7 @@
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
"integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
"requires": {
"is-arrayish": "0.2.1"
"is-arrayish": "^0.2.1"
}
},
"find-up": {
@ -70,8 +70,8 @@
"resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
"integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
"requires": {
"path-exists": "2.1.0",
"pinkie-promise": "2.0.1"
"path-exists": "^2.0.0",
"pinkie-promise": "^2.0.0"
}
},
"fs-extra": {
@ -79,11 +79,11 @@
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"requires": {
"graceful-fs": "4.1.11",
"jsonfile": "2.4.0",
"klaw": "1.3.1",
"path-is-absolute": "1.0.1",
"rimraf": "2.6.2"
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
}
},
"fs.realpath": {
@ -101,12 +101,12 @@
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"graceful-fs": {
@ -124,8 +124,8 @@
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "1.4.0",
"wrappy": "1.0.2"
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
@ -148,7 +148,7 @@
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz",
"integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=",
"requires": {
"builtin-modules": "1.1.1"
"builtin-modules": "^1.0.0"
}
},
"is-fullwidth-code-point": {
@ -156,7 +156,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
"requires": {
"number-is-nan": "1.0.1"
"number-is-nan": "^1.0.0"
}
},
"is-utf8": {
@ -169,7 +169,7 @@
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"requires": {
"graceful-fs": "4.1.11"
"graceful-fs": "^4.1.6"
}
},
"klaw": {
@ -177,7 +177,7 @@
"resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
"integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=",
"requires": {
"graceful-fs": "4.1.11"
"graceful-fs": "^4.1.9"
}
},
"lcid": {
@ -185,7 +185,7 @@
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
"integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=",
"requires": {
"invert-kv": "1.0.0"
"invert-kv": "^1.0.0"
}
},
"load-json-file": {
@ -193,11 +193,11 @@
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
"requires": {
"graceful-fs": "4.1.11",
"parse-json": "2.2.0",
"pify": "2.3.0",
"pinkie-promise": "2.0.1",
"strip-bom": "2.0.0"
"graceful-fs": "^4.1.2",
"parse-json": "^2.2.0",
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0",
"strip-bom": "^2.0.0"
}
},
"lodash.assign": {
@ -215,7 +215,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "1.1.11"
"brace-expansion": "^1.1.7"
}
},
"normalize-package-data": {
@ -223,10 +223,10 @@
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
"integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==",
"requires": {
"hosted-git-info": "2.6.1",
"is-builtin-module": "1.0.0",
"semver": "5.5.0",
"validate-npm-package-license": "3.0.3"
"hosted-git-info": "^2.1.4",
"is-builtin-module": "^1.0.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
}
},
"number-is-nan": {
@ -239,7 +239,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1.0.2"
"wrappy": "1"
}
},
"os-locale": {
@ -247,7 +247,7 @@
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
"integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
"requires": {
"lcid": "1.0.0"
"lcid": "^1.0.0"
}
},
"parse-json": {
@ -255,7 +255,7 @@
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"requires": {
"error-ex": "1.3.2"
"error-ex": "^1.2.0"
}
},
"path-exists": {
@ -263,7 +263,7 @@
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
"integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
"requires": {
"pinkie-promise": "2.0.1"
"pinkie-promise": "^2.0.0"
}
},
"path-is-absolute": {
@ -276,9 +276,9 @@
"resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz",
"integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=",
"requires": {
"graceful-fs": "4.1.11",
"pify": "2.3.0",
"pinkie-promise": "2.0.1"
"graceful-fs": "^4.1.2",
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0"
}
},
"pify": {
@ -296,7 +296,7 @@
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
"integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=",
"requires": {
"pinkie": "2.0.4"
"pinkie": "^2.0.0"
}
},
"read-pkg": {
@ -304,9 +304,9 @@
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
"integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=",
"requires": {
"load-json-file": "1.1.0",
"normalize-package-data": "2.4.0",
"path-type": "1.1.0"
"load-json-file": "^1.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^1.0.0"
}
},
"read-pkg-up": {
@ -314,8 +314,8 @@
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz",
"integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=",
"requires": {
"find-up": "1.1.2",
"read-pkg": "1.1.0"
"find-up": "^1.0.0",
"read-pkg": "^1.0.0"
}
},
"require-directory": {
@ -338,7 +338,7 @@
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
"requires": {
"glob": "7.1.2"
"glob": "^7.0.5"
}
},
"semver": {
@ -356,11 +356,11 @@
"resolved": "https://registry.npmjs.org/solc-js/-/solc-js-0.4.20.tgz",
"integrity": "sha1-tjCVsPcatkx6fi+C7YUtCzUxTlg=",
"requires": {
"fs-extra": "0.30.0",
"memorystream": "0.3.1",
"require-from-string": "1.2.1",
"semver": "5.5.0",
"yargs": "4.8.1"
"fs-extra": "^0.30.0",
"memorystream": "^0.3.1",
"require-from-string": "^1.1.0",
"semver": "^5.3.0",
"yargs": "^4.7.1"
}
},
"spdx-correct": {
@ -368,8 +368,8 @@
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz",
"integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==",
"requires": {
"spdx-expression-parse": "3.0.0",
"spdx-license-ids": "3.0.0"
"spdx-expression-parse": "^3.0.0",
"spdx-license-ids": "^3.0.0"
}
},
"spdx-exceptions": {
@ -382,8 +382,8 @@
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz",
"integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==",
"requires": {
"spdx-exceptions": "2.1.0",
"spdx-license-ids": "3.0.0"
"spdx-exceptions": "^2.1.0",
"spdx-license-ids": "^3.0.0"
}
},
"spdx-license-ids": {
@ -396,9 +396,9 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
"requires": {
"code-point-at": "1.1.0",
"is-fullwidth-code-point": "1.0.0",
"strip-ansi": "3.0.1"
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
"strip-ansi": "^3.0.0"
}
},
"strip-ansi": {
@ -406,7 +406,7 @@
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "2.1.1"
"ansi-regex": "^2.0.0"
}
},
"strip-bom": {
@ -414,7 +414,7 @@
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
"requires": {
"is-utf8": "0.2.1"
"is-utf8": "^0.2.0"
}
},
"validate-npm-package-license": {
@ -422,8 +422,8 @@
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz",
"integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==",
"requires": {
"spdx-correct": "3.0.0",
"spdx-expression-parse": "3.0.0"
"spdx-correct": "^3.0.0",
"spdx-expression-parse": "^3.0.0"
}
},
"which-module": {
@ -441,8 +441,8 @@
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"requires": {
"string-width": "1.0.2",
"strip-ansi": "3.0.1"
"string-width": "^1.0.1",
"strip-ansi": "^3.0.1"
}
},
"wrappy": {
@ -460,20 +460,20 @@
"resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz",
"integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=",
"requires": {
"cliui": "3.2.0",
"decamelize": "1.2.0",
"get-caller-file": "1.0.2",
"lodash.assign": "4.2.0",
"os-locale": "1.4.0",
"read-pkg-up": "1.0.1",
"require-directory": "2.1.1",
"require-main-filename": "1.0.1",
"set-blocking": "2.0.0",
"string-width": "1.0.2",
"which-module": "1.0.0",
"window-size": "0.2.0",
"y18n": "3.2.1",
"yargs-parser": "2.4.1"
"cliui": "^3.2.0",
"decamelize": "^1.1.1",
"get-caller-file": "^1.0.1",
"lodash.assign": "^4.0.3",
"os-locale": "^1.4.0",
"read-pkg-up": "^1.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^1.0.1",
"set-blocking": "^2.0.0",
"string-width": "^1.0.1",
"which-module": "^1.0.0",
"window-size": "^0.2.0",
"y18n": "^3.2.1",
"yargs-parser": "^2.4.1"
}
},
"yargs-parser": {
@ -481,8 +481,8 @@
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz",
"integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=",
"requires": {
"camelcase": "3.0.0",
"lodash.assign": "4.2.0"
"camelcase": "^3.0.0",
"lodash.assign": "^4.0.6"
}
}
}

Loading…
Cancel
Save