From 423c6c330eab5e1a012bac0c7f2566eebaa321a3 Mon Sep 17 00:00:00 2001 From: sh-wallet <137136919+sh-wallet@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:53:31 +0530 Subject: [PATCH] chore: Additional Currency Support (#404) --- packages/fetch-extension/src/config.ui.ts | 219 ++++++++++++------ .../more/address-book/style.module.scss | 2 +- .../src/pages-new/more/currency/index.tsx | 88 ++++--- 3 files changed, 208 insertions(+), 101 deletions(-) diff --git a/packages/fetch-extension/src/config.ui.ts b/packages/fetch-extension/src/config.ui.ts index 832e994284..047d813732 100644 --- a/packages/fetch-extension/src/config.ui.ts +++ b/packages/fetch-extension/src/config.ui.ts @@ -44,284 +44,373 @@ export const FiatCurrencies: FiatCurrency[] = [ symbol: "$", maxDecimals: 2, locale: "en-US", + name: "United States Dollar", }, { - currency: "eur", - symbol: "€", - maxDecimals: 2, - locale: "en-IE", - }, - { - currency: "gbp", - symbol: "£", + currency: "aed", + symbol: "د.إ", maxDecimals: 2, - locale: "en-GB", + locale: "ar-AE", + name: "United Arab Emirates Dirham", }, { - currency: "cad", - symbol: "CA$", + currency: "ars", + symbol: "$", maxDecimals: 2, - locale: "en-CA", + locale: "es-AR", + name: "Argentine Peso", }, { currency: "aud", symbol: "AU$", maxDecimals: 2, locale: "en-AU", + name: "Australian Dollar", }, { - currency: "rub", - symbol: "₽", - maxDecimals: 0, - locale: "ru-RU", - }, - { - currency: "krw", - symbol: "₩", - maxDecimals: 0, - locale: "ko-KR", - }, - { - currency: "hkd", - symbol: "HK$", - maxDecimals: 1, - locale: "en-HK", - }, - { - currency: "cny", - symbol: "¥", - maxDecimals: 1, - locale: "zh-CN", - }, - { - currency: "jpy", - symbol: "¥", - maxDecimals: 0, - locale: "ja-JP", - }, - { - currency: "inr", - symbol: "₹", - maxDecimals: 1, - locale: "en-IN", + currency: "bdt", + symbol: "৳", + maxDecimals: 2, + locale: "bn-BD", + name: "Bangladeshi Taka", }, { - currency: "ars", - symbol: "$", - maxDecimals: 2, - locale: "es-AR", + currency: "bhd", + symbol: ".د.ب", + maxDecimals: 3, + locale: "ar-BH", + name: "Bahraini Dinar", }, { currency: "bmd", symbol: "BD$", maxDecimals: 2, locale: "en-BM", + name: "Bermudian Dollar", }, { currency: "brl", symbol: "R$", maxDecimals: 2, locale: "pt-BR", + name: "Brazilian Real", + }, + { + currency: "cad", + symbol: "CA$", + maxDecimals: 2, + locale: "en-CA", + name: "Canadian Dollar", }, { currency: "chf", symbol: "CHF", maxDecimals: 2, locale: "de-CH", + name: "Swiss Franc", }, { currency: "clp", symbol: "$", - maxDecimals: 0, + maxDecimals: 2, locale: "es-CL", + name: "Chilean Peso", + }, + { + currency: "cny", + symbol: "¥", + maxDecimals: 1, + locale: "zh-CN", + name: "Chinese Yuan", }, { currency: "czk", symbol: "Kč", maxDecimals: 2, locale: "cs-CZ", + name: "Czech Koruna", }, { currency: "dkk", symbol: "kr", maxDecimals: 2, locale: "da-DK", + name: "Danish Krone", + }, + { + currency: "eur", + symbol: "€", + maxDecimals: 2, + locale: "en-IE", + name: "Euro", + }, + { + currency: "gbp", + symbol: "£", + maxDecimals: 2, + locale: "en-GB", + name: "British Pound Sterling", }, { currency: "gel", symbol: "₾", maxDecimals: 2, locale: "ka-GE", + name: "Georgian Lari", + }, + { + currency: "hkd", + symbol: "HK$", + maxDecimals: 1, + locale: "en-HK", + name: "Hong Kong Dollar", }, { currency: "huf", symbol: "Ft", maxDecimals: 2, locale: "hu-HU", + name: "Hungarian Forint", }, { currency: "idr", symbol: "Rp", maxDecimals: 2, locale: "id-ID", + name: "Indonesian Rupiah", }, { currency: "ils", symbol: "₪", maxDecimals: 2, locale: "he-IL", + name: "Israeli New Shekel", + }, + { + currency: "inr", + symbol: "₹", + maxDecimals: 1, + locale: "en-IN", + name: "Indian Rupee", + }, + { + currency: "jpy", + symbol: "¥", + maxDecimals: 2, + locale: "ja-JP", + name: "Japanese Yen", + }, + { + currency: "krw", + symbol: "₩", + maxDecimals: 2, + locale: "ko-KR", + name: "South Korean Won", }, { currency: "kwd", symbol: "د.ك", maxDecimals: 3, locale: "ar-KW", + name: "Kuwaiti Dinar", }, { currency: "lkr", symbol: "Rs", maxDecimals: 2, locale: "si-LK", + name: "Sri Lankan Rupee", }, { currency: "mmk", symbol: "K", maxDecimals: 0, locale: "my-MM", + name: "Myanmar Kyat", }, { currency: "mxn", symbol: "MX$", maxDecimals: 2, locale: "es-MX", + name: "Mexican Peso", }, { currency: "myr", symbol: "RM", maxDecimals: 2, locale: "ms-MY", + name: "Malaysian Ringgit", }, { currency: "ngn", symbol: "₦", maxDecimals: 2, locale: "en-NG", + name: "Nigerian Naira", }, { currency: "nok", symbol: "kr", maxDecimals: 2, locale: "nb-NO", + name: "Norwegian Krone", }, { currency: "nzd", symbol: "NZ$", maxDecimals: 2, locale: "en-NZ", + name: "New Zealand Dollar", }, { currency: "php", symbol: "₱", maxDecimals: 2, locale: "en-PH", + name: "Philippine Peso", }, { currency: "pkr", symbol: "₨", maxDecimals: 2, locale: "en-PK", + name: "Pakistani Rupee", }, { currency: "pln", symbol: "zł", maxDecimals: 2, locale: "pl-PL", + name: "Polish Zloty", + }, + { + currency: "rub", + symbol: "₽", + maxDecimals: 2, + locale: "ru-RU", + name: "Russian Ruble", }, { currency: "sar", symbol: "ر.س", maxDecimals: 2, locale: "ar-SA", + name: "Saudi Riyal", }, { currency: "sek", symbol: "kr", maxDecimals: 2, locale: "sv-SE", + name: "Swedish Krona", }, { currency: "sgd", symbol: "S$", maxDecimals: 2, locale: "en-SG", + name: "Singapore Dollar", }, { currency: "thb", symbol: "฿", maxDecimals: 2, locale: "th-TH", + name: "Thai Baht", }, { currency: "try", symbol: "₺", maxDecimals: 2, locale: "tr-TR", + name: "Turkish Lira", }, { currency: "twd", symbol: "NT$", maxDecimals: 2, locale: "zh-TW", + name: "New Taiwan Dollar", }, { currency: "uah", symbol: "₴", maxDecimals: 2, locale: "uk-UA", + name: "Ukrainian Hryvnia", }, { currency: "vef", symbol: "Bs", maxDecimals: 2, locale: "es-VE", + name: "Venezuelan Bolívar", }, { currency: "vnd", symbol: "₫", - maxDecimals: 0, + maxDecimals: 2, locale: "vi-VN", + name: "Vietnamese Dong", }, { currency: "zar", symbol: "R", maxDecimals: 2, locale: "en-ZA", - }, - { - currency: "aed", - symbol: "د.إ", - maxDecimals: 2, - locale: "ar-AE", + name: "South African Rand", }, ]; export const SUPPORTED_LOCALE_FIAT_CURRENCIES = [ "usd", + "aed", + "ars", + "aud", + "bdt", + "bhd", + "bmd", + "brl", + "cad", + "chf", + "clp", + "cny", + "czk", + "dkk", "eur", "gbp", - "cad", - "aud", + "gel", "hkd", - "jpy", - "cny", + "huf", + "idr", + "ils", "inr", + "jpy", "krw", - "nzd", + "kwd", + "lkr", + "mmk", + "mxn", + "mvr", + "nyr", + "ngn", + "nok", + "nzk", + "php", "pkr", - "myr", + "pln", + "rub", + "sar", + "sek", "sgd", "thb", - "mxn", + "try", + "twd", + "uah", + "vef", + "vnd", + "zar", ]; export const LanguageToFiatCurrency: TypeLanguageToFiatCurrency = { diff --git a/packages/fetch-extension/src/pages-new/more/address-book/style.module.scss b/packages/fetch-extension/src/pages-new/more/address-book/style.module.scss index 90563a7991..106ea294be 100644 --- a/packages/fetch-extension/src/pages-new/more/address-book/style.module.scss +++ b/packages/fetch-extension/src/pages-new/more/address-book/style.module.scss @@ -50,7 +50,7 @@ border: 0; margin: 0; padding: 0; -background-color: rgba(0, 13, 61); + background-color: rgba(0, 13, 61); &:global(.modal-content) { box-shadow: none; diff --git a/packages/fetch-extension/src/pages-new/more/currency/index.tsx b/packages/fetch-extension/src/pages-new/more/currency/index.tsx index 99f4f65618..b4b0ffaaaa 100644 --- a/packages/fetch-extension/src/pages-new/more/currency/index.tsx +++ b/packages/fetch-extension/src/pages-new/more/currency/index.tsx @@ -21,6 +21,11 @@ export const CurrencyPge: FunctionComponent = observer(() => { [] ); + const handleClick = (currency: string) => { + language.setFiatCurrency(currency); + navigate({ pathname: "/" }); + }; + return ( { language.isFiatCurrencyAutomatic ? selectedIcon : undefined } /> - {Object.keys(priceStore.supportedVsCurrencies).map((currency) => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const fiatCurrency = priceStore.supportedVsCurrencies[currency]!; - - return ( - { - language.setFiatCurrency(fiatCurrency.currency); - navigate({ - pathname: "/", - }); - }} - rightContent={ - !language.isFiatCurrencyAutomatic - ? language.fiatCurrency === fiatCurrency.currency - ? selectedIcon - : undefined - : undefined - } - /> - ); - })} +
+ {Object.keys(priceStore.supportedVsCurrencies).map((currency) => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const fiatCurrency = priceStore.supportedVsCurrencies[currency]!; + return ( +
handleClick(fiatCurrency.currency)} + > +
+ {fiatCurrency.currency.toUpperCase()} +
+
+ {`${fiatCurrency.name} (${fiatCurrency.symbol})`} +
+
+ {!language.isFiatCurrencyAutomatic + ? language.fiatCurrency === fiatCurrency.currency + ? selectedIcon + : undefined + : undefined} +
+
+ ); + })} +
);