Skip to content

Commit

Permalink
Fix formatting of gas price for all conversion currencies (#3731)
Browse files Browse the repository at this point in the history
* Fix gas currency formatting

* Add support for Intl on Android

Co-authored-by: Gustavo Antunes <[email protected]>
  • Loading branch information
Fatxx and Gustavo Antunes authored Mar 25, 2022
1 parent bd11758 commit f1bee2a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def enableSeparateBuildPerCPUArchitecture = true
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
def jscFlavor = 'org.webkit:android-jsc-intl:+'
/**
* Whether to enable the Hermes VM.
*
Expand Down Expand Up @@ -282,7 +282,7 @@ dependencies {
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
Expand Down
17 changes: 8 additions & 9 deletions app/util/confirm-tx.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import currencyFormatter from 'currency-formatter';
import currencies from 'currency-formatter/currencies';
import BigNumber from 'bignumber.js';
import { addHexPrefix } from './number';

import { conversionUtil, addCurrencies, multiplyCurrencies, conversionGreaterThan } from './conversion';
import I18n from '../../locales/i18n';

export function increaseLastGasPrice(lastGasPrice) {
return addHexPrefix(
Expand Down Expand Up @@ -86,13 +85,13 @@ export function getTransactionFee({ value, fromCurrency = 'ETH', toCurrency, con
export function formatCurrency(value, currencyCode) {
const upperCaseCurrencyCode = currencyCode.toUpperCase();

return currencies.find((currency) => currency.code === upperCaseCurrencyCode)
? currencyFormatter.format(Number(value), {
code: upperCaseCurrencyCode,
style: 'currency',
// eslint-disable-next-line no-mixed-spaces-and-tabs
})
: `value ${upperCaseCurrencyCode}`;
const formatedCurrency = new Intl.NumberFormat(I18n.locale, {
currency: upperCaseCurrencyCode,
style: 'currency',
// eslint-disable-next-line no-mixed-spaces-and-tabs
}).format(Number(value));

return formatedCurrency;
}

export function convertTokenToFiat({ value, fromCurrency = 'ETH', toCurrency, conversionRate, contractExchangeRate }) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
"codecov": "^3.8.1",
"compare-versions": "^3.6.0",
"content-hash": "2.5.2",
"currency-formatter": "^1.5.8",
"dnode": "1.2.2",
"eth-ens-namehash": "2.0.8",
"eth-json-rpc-errors": "^2.0.2",
Expand Down
19 changes: 0 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3713,11 +3713,6 @@ accepts@^1.3.7, accepts@~1.3.5, accepts@~1.3.7:
mime-types "~2.1.24"
negotiator "0.6.2"

accounting@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/accounting/-/accounting-0.4.1.tgz#87dd4103eff7f4460f1e186f5c677ed6cf566883"
integrity sha1-h91BA+/39EYPHhhvXGd+1s9WaIM=

acorn-globals@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45"
Expand Down Expand Up @@ -5875,15 +5870,6 @@ csstype@^3.0.2:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.8.tgz#d2266a792729fb227cd216fb572f43728e1ad340"
integrity sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==

currency-formatter@^1.5.8:
version "1.5.8"
resolved "https://registry.yarnpkg.com/currency-formatter/-/currency-formatter-1.5.8.tgz#5c2a18673d966fc355bac901f7423ccce607b983"
integrity sha512-/Oim4XnX82wf+JknrObifmBHpXnSQZC3FrCi+Oss4olXm3nqGWd8eY3sL2Tf0pZ/zuUqj1stU7f//5Hh27+cSQ==
dependencies:
accounting "^0.4.1"
locale-currency "0.0.2"
object-assign "^4.1.1"

[email protected]:
version "1.0.3"
resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2"
Expand Down Expand Up @@ -10945,11 +10931,6 @@ loader-utils@^1.4.0:
emojis-list "^3.0.0"
json5 "^1.0.1"

[email protected]:
version "0.0.2"
resolved "https://registry.yarnpkg.com/locale-currency/-/locale-currency-0.0.2.tgz#e2c90607563ce47a59f9559e45a70e24e4db4b6d"
integrity sha1-4skGB1Y85HpZ+VWeRacOJOTbS20=

localforage@^1.8.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.9.0.tgz#f3e4d32a8300b362b4634cc4e066d9d00d2f09d1"
Expand Down

0 comments on commit f1bee2a

Please sign in to comment.