From 4ae390cf6b3834250ed54f3ed7cf369a192f1380 Mon Sep 17 00:00:00 2001 From: Rustem Date: Wed, 5 Jun 2024 13:06:00 +0300 Subject: [PATCH] multiple fiat dialog (#1388) * copy logic * create UI * make fiat on inputs & stats * improve search * Update SelectCurrencyDialog.vue * Update ChartSkeleton.vue * make proof of concept * Revert "make proof of concept" This reverts commit a4a18075081803b9408b6cff820fa4e5705b7c45. * bump wallet * bump wallet * add missing conversion * update wallet * bump wallet * Update AppHeaderMenu.vue * fix vice versa conversion * refactor icons * Delete polkaswap_icons copy.ttf * add translations * add missing types & fixes * Update PriceChart.vue --------- Co-authored-by: Stefan Popov --- src/App.vue | 3 + src/assets/fonts/polkaswap_icons.ttf | Bin 60328 -> 61500 bytes src/components/App/Header/AppHeader.vue | 2 + src/components/App/Header/AppHeaderMenu.vue | 57 +++---- src/components/App/Header/BellIcon.vue | 17 -- .../Currency/SelectCurrencyDialog.vue | 155 ++++++++++++++++++ src/components/pages/OrderBook/BookWidget.vue | 10 +- src/components/pages/Stats/BarChart.vue | 8 +- src/components/pages/Stats/TvlChart.vue | 3 +- src/components/shared/Chart/ChartSkeleton.vue | 1 + src/components/shared/Input/TokenInput.vue | 28 +++- src/components/shared/Widget/PriceChart.vue | 13 +- src/consts/index.ts | 1 + src/lang/cs.json | 7 +- src/lang/de.json | 7 +- src/lang/en.json | 7 +- src/lang/es.json | 7 +- src/lang/fr.json | 7 +- src/lang/hr.json | 7 +- src/lang/hu.json | 7 +- src/lang/hy.json | 7 +- src/lang/id.json | 7 +- src/lang/it.json | 7 +- src/lang/messages.ts | 5 + src/lang/nl.json | 7 +- src/lang/no.json | 7 +- src/lang/pl.json | 7 +- src/lang/ru.json | 7 +- src/lang/sk.json | 7 +- src/lang/sr.json | 7 +- src/lang/sv.json | 7 +- src/lang/vi.json | 7 +- src/lang/yo.json | 7 +- src/lang/zh_CN.json | 7 +- src/store/settings/mutations.ts | 3 + src/store/settings/state.ts | 1 + src/store/settings/types.ts | 1 + src/utils/index.ts | 6 + 38 files changed, 372 insertions(+), 82 deletions(-) delete mode 100644 src/components/App/Header/BellIcon.vue create mode 100644 src/components/App/Settings/Currency/SelectCurrencyDialog.vue diff --git a/src/App.vue b/src/App.vue index b39967769..027d2794e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -133,6 +133,7 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) @mutation.referrals.resetStorageReferrer private resetStorageReferrer!: FnWithoutArgs; @action.wallet.settings.setApiKeys private setApiKeys!: (apiKeys: WALLET_TYPES.ApiKeysObject) => Promise; + @action.wallet.settings.subscribeOnExchangeRatesApi subscribeOnExchangeRatesApi!: AsyncFnWithoutArgs; @action.wallet.subscriptions.resetNetworkSubscriptions private resetNetworkSubscriptions!: AsyncFnWithoutArgs; @action.wallet.subscriptions.resetInternalSubscriptions private resetInternalSubscriptions!: AsyncFnWithoutArgs; @action.wallet.subscriptions.activateNetwokSubscriptions private activateNetwokSubscriptions!: AsyncFnWithoutArgs; @@ -230,6 +231,8 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) this.setEvmNetworksApp(data.EVM_NETWORKS_IDS); this.setSubNetworkApps(data.SUB_NETWORKS); + this.subscribeOnExchangeRatesApi(); + if (data.PARACHAIN_IDS) { api.bridgeProxy.sub.parachainIds = data.PARACHAIN_IDS; } diff --git a/src/assets/fonts/polkaswap_icons.ttf b/src/assets/fonts/polkaswap_icons.ttf index 3753e4149b28d7d9ad705dd6684adb6f45569e97..4498b92a95210260701e13acded304a11361e4e4 100644 GIT binary patch delta 1555 zcmaJ-e`r%@6usa3UXs@&&9A;BFHM^!ZJK0hOuAMR+e$>6G}=z1Z8}Y@wNYau*fnZ! z6`c`Q7z4$v5p*#2rVXHP|z|&oGY6HWj|ox>h5d1&cWE@9qzg3 zJNJI)y@@+?=01JLWO%X`0JvBr+5tRV2Y6ETuIHtEQT;nWjT(>69m)<3-#(JN10bIO zFeZjl$Fr#G(8^1rLq|>?icA`xqW?0$*HxKx>R@f$W(OeBd@zFo$Fk?Kk6`c24ChAA zbvsXBzkvAo$jE`z`?GWC|Ne9AbHl08>>!<&oy8`D1NPTa!|Bl!e;VKi4{BGlBgb<; zf9U=QU||kG5y>7)XN|v>9spRM0nl&QiScnwQRX$}3r>c)pCG03JR43ogbKraaoPJBMLM23D1m1*8 zFbQ|z7t${62NAe{2t48h;t^tVbhilUfb}}0ArelOzyoa{Hk4o-E-ckEaB8W}!Y!;K zjO#?u%pq_X=0)&e@50^{C_z2|8UVea1y`aRpWkE!1;oLOa3ey97-AP<2=O}NEyN|n zRm2qH8$|iuO)|KRyK+kj##Y&5iRJMa{~-tdrN~FPAq zvovDFMvN@+B=RKkqsYgQkFD?zkW1QEEA<}Md-z$8ao!y7xt4-K1@PkD#M7<*hVy9P+C{(XE5pVyH2)}Oxooq0b({ufkULDGHCL3 zuCt~4bRnB9r0+{tH*VP2w)iI@L`FH!`i^?R;p`MzlUj~2ENkfRST=U_8(5Y>7m?+u zez;TXGS)?fw%z}2qgQa4s+(fH0T*Ma?cEvCsa{m-59Ih)&WY2MCLmZkjm<|<#EMaMk{ok^*vaN0~Vs*r11>;`waUajKlgIbnS zRvUD3Dz!c%nOqyx43*2ZEq1+Y)x)xqCoh>uR2o&v1#gXkkhr?aSCjg;V)faXE|%rv zO_qS$#!-AUZLV^y)@-W~Y7C0oywz*dsjNN+@3Hb~#~Q1OVawzyK_;s*sd;PMU9M9r z70Va!oKR+>gfL}oJ_5z=iH9u%9TTx&?7J<#EswUI?TmB@U6Ze5wpDIhh#!oPcPDzb z_vCsm_ssO%PskJAL^dHN7JGBO4`21{$|XPRQ}^B73#rY<{4iQ;v1?$=dS(>l5hRRl0iOU+)#q0(__jP}`O64&`FK zc?n?WFaYx&2u=~OMVI#pfvwd)A(ur1U}Z9}uvyo8=9kCINdtM5xIpF!Sxg+HCwPiU z!o2G{GrlKZNlfN@uVfHd1fZq#6jVU}_%+*(0R!k@wA7Xh92g)6F(CrtL>iG0(u-V1 zZXi=g5_y4S_-!iOXn>Ch<9`Bb+-BI8U6lfLSqjKXc?HpFIYXhThFDC+W>QAX1j_-7 zRU}qne6>kGUUoxq>W5HEPOcQDc#wcUuKf6s&GuUu2|N97Bm(Ln%X8 zpDP%2`M69Cm!V-*I#qd~S`-Agp6B&$K@e-?3Y9L6Vab+EPNl(n5D4P|#%L=Xf^Z5( z62E3&SG74Tj%UuZ&XlXWHobP?=$*PFbw7?x)yEsY9nU+t>V7AIWRz;9sB~RQN`F0e z&s8sY74O4FXcC)l`a-^BGu!NJPPSCGBwJtl3;expjR8wwsC`Lpl5ZtSK4~@o04E@( A+W-In diff --git a/src/components/App/Header/AppHeader.vue b/src/components/App/Header/AppHeader.vue index d6c40cb52..43f2b4883 100644 --- a/src/components/App/Header/AppHeader.vue +++ b/src/components/App/Header/AppHeader.vue @@ -14,6 +14,7 @@ + @@ -43,6 +44,7 @@ import type Theme from '@soramitsu-ui/ui-vue2/lib/types/Theme'; AppHeaderMenu, AppLogoButton, SelectLanguageDialog: lazyComponent(Components.SelectLanguageDialog), + SelectCurrencyDialog: lazyComponent(Components.SelectCurrencyDialog), PairTokenLogo: lazyComponent(Components.PairTokenLogo), WalletAvatar: components.WalletAvatar, }, diff --git a/src/components/App/Header/AppHeaderMenu.vue b/src/components/App/Header/AppHeaderMenu.vue index 4c255160c..794d504e7 100644 --- a/src/components/App/Header/AppHeaderMenu.vue +++ b/src/components/App/Header/AppHeaderMenu.vue @@ -26,11 +26,10 @@ :disabled="disabled" > {{ text }} + + {{ currency?.toUpperCase() }} + -
- - {{ t('browserNotificationDialog.title') }} -
@@ -45,12 +44,13 @@ import { Component, Mixins } from 'vue-property-decorator'; import TranslationMixin from '@/components/mixins/TranslationMixin'; import { getter, mutation, state } from '@/store/decorators'; -import BellIcon from './BellIcon.vue'; +import type { Currency } from '@soramitsu/soraneo-wallet-web/lib/types/currency'; enum HeaderMenuType { HideBalances = 'hide-balances', Theme = 'theme', Language = 'language', + Currency = 'currency', Notification = 'notification', Disclaimer = 'disclaimer', } @@ -64,11 +64,7 @@ type MenuItem = { const BREAKPOINT = 1440; -@Component({ - components: { - BellIcon, - }, -}) +@Component export default class AppHeaderMenu extends Mixins(TranslationMixin) { readonly iconSize = 28; readonly HeaderMenuType = HeaderMenuType; @@ -76,6 +72,7 @@ export default class AppHeaderMenu extends Mixins(TranslationMixin) { @state.settings.disclaimerVisibility disclaimerVisibility!: boolean; @state.settings.userDisclaimerApprove userDisclaimerApprove!: boolean; @state.wallet.settings.shouldBalanceBeHidden private shouldBalanceBeHidden!: boolean; + @state.wallet.settings.currency currency!: Currency; @getter.libraryTheme private libraryTheme!: Theme; @getter.settings.notificationActivated notificationActivated!: boolean; @@ -83,6 +80,7 @@ export default class AppHeaderMenu extends Mixins(TranslationMixin) { @mutation.wallet.settings.toggleHideBalance private toggleHideBalance!: FnWithoutArgs; @mutation.settings.setAlertSettingsPopup private setAlertSettingsPopup!: (flag: boolean) => void; @mutation.settings.setSelectLanguageDialogVisibility private setLanguageDialogVisibility!: (flag: boolean) => void; + @mutation.settings.setSelectCurrencyDialogVisibility private setCurrencyDialogVisibility!: (flag: boolean) => void; @mutation.settings.toggleDisclaimerDialogVisibility private toggleDisclaimerDialogVisibility!: FnWithoutArgs; get mediaQueryList(): MediaQueryList { @@ -139,12 +137,22 @@ export default class AppHeaderMenu extends Mixins(TranslationMixin) { icon: 'basic-globe-24', text: this.t('headerMenu.switchLanguage'), }, + { + value: HeaderMenuType.Currency, + icon: 'various-lightbulb-24', + text: this.t('headerMenu.selectCurrency'), + }, { value: HeaderMenuType.Disclaimer, icon: 'info-16', text: this.disclaimerText, disabled: this.disclaimerDisabled, }, + { + value: HeaderMenuType.Notification, + icon: 'notifications-bell-24', + text: this.t('browserNotificationDialog.title'), + }, ]; } @@ -180,10 +188,16 @@ export default class AppHeaderMenu extends Mixins(TranslationMixin) { case HeaderMenuType.Language: this.setLanguageDialogVisibility(true); break; + case HeaderMenuType.Currency: + this.setCurrencyDialogVisibility(true); + break; case HeaderMenuType.Disclaimer: if (this.disclaimerDisabled) return; this.toggleDisclaimerDialogVisibility(); break; + case HeaderMenuType.Notification: + this.openNotificationDialog(); + break; } } } @@ -234,27 +248,10 @@ $icon-size: 28px; } } } - } -} -.notif-option { - display: flex; - - &__bell { - width: $icon-size; - height: $icon-size; - margin: auto 0; - fill: var(--s-color-base-content-tertiary); - - &--dropdown { - margin-top: $inner-spacing-mini; - margin-right: $basic-spacing-mini; - } - } - - &:hover { - .notif-option__bell { - fill: var(--s-color-base-content-secondary); + .current-currency { + margin-left: 5px; + color: var(--s-color-base-content-tertiary); } } } diff --git a/src/components/App/Header/BellIcon.vue b/src/components/App/Header/BellIcon.vue deleted file mode 100644 index 9065b6191..000000000 --- a/src/components/App/Header/BellIcon.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - diff --git a/src/components/App/Settings/Currency/SelectCurrencyDialog.vue b/src/components/App/Settings/Currency/SelectCurrencyDialog.vue new file mode 100644 index 000000000..45be2ca0f --- /dev/null +++ b/src/components/App/Settings/Currency/SelectCurrencyDialog.vue @@ -0,0 +1,155 @@ + + + + + + + diff --git a/src/components/pages/OrderBook/BookWidget.vue b/src/components/pages/OrderBook/BookWidget.vue index 9f929cf9b..bb90a243c 100644 --- a/src/components/pages/OrderBook/BookWidget.vue +++ b/src/components/pages/OrderBook/BookWidget.vue @@ -101,6 +101,8 @@ export default class BookWidget extends Mixins(TranslationMixin, mixins.LoadingM @getter.orderBook.currentOrderBook currentOrderBook!: OrderBook; @getter.orderBook.orderBookId orderBookId!: string; @getter.settings.nodeIsConnected nodeIsConnected!: boolean; + @getter.wallet.settings.exchangeRate private exchangeRate!: number; + @getter.wallet.settings.currencySymbol private currencySymbol!: string; @mutation.orderBook.setQuoteValue setQuoteValue!: (value: string) => void; @mutation.orderBook.setSide setSide!: (side: PriceVariant) => void; @@ -221,9 +223,11 @@ export default class BookWidget extends Mixins(TranslationMixin, mixins.LoadingM get fiatValue(): string { if (!this.quoteAsset) return ZeroStringValue; - const fiat = this.getFiatAmount(this.lastDealPrice.toString(), this.quoteAsset); + const fiatUsd = this.getFiatAmount(this.lastDealPrice.toString(), this.quoteAsset) || '0'; - return fiat ? `$${fiat}` : ''; + const currentFiat = new FPNumber(fiatUsd).mul(this.exchangeRate).toLocaleString(); + + return currentFiat ? `${this.currencySymbol}${currentFiat}` : ''; } getComputedClassTrend(): string { @@ -439,6 +443,8 @@ $mono-font: 'JetBrainsMono'; margin-left: $inner-spacing-big; font-size: var(--s-font-size-big); font-weight: 450; + unicode-bidi: bidi-override; + direction: ltr; } .trend-icon { diff --git a/src/components/pages/Stats/BarChart.vue b/src/components/pages/Stats/BarChart.vue index 766ac02be..389d5b4c8 100644 --- a/src/components/pages/Stats/BarChart.vue +++ b/src/components/pages/Stats/BarChart.vue @@ -10,10 +10,12 @@ :is-error="isFetchingError" @retry="updateData" > - - + + {{ amount.suffix }} + + + {{ amount.suffix }} - diff --git a/src/components/pages/Stats/TvlChart.vue b/src/components/pages/Stats/TvlChart.vue index f221d5e6d..6dcfa7f3a 100644 --- a/src/components/pages/Stats/TvlChart.vue +++ b/src/components/pages/Stats/TvlChart.vue @@ -10,8 +10,7 @@ :is-error="isFetchingError" @retry="updateData" > - - + {{ amount.suffix }} diff --git a/src/components/shared/Chart/ChartSkeleton.vue b/src/components/shared/Chart/ChartSkeleton.vue index 9f3d0ed95..7e0170493 100644 --- a/src/components/shared/Chart/ChartSkeleton.vue +++ b/src/components/shared/Chart/ChartSkeleton.vue @@ -85,6 +85,7 @@ $skeleton-label-width: 34px; font-weight: 600; font-size: var(--s-heading3-font-size); line-height: var(--s-line-height-extra-small); + color: var(--s-color-base-content-primary) !important; } } diff --git a/src/components/shared/Input/TokenInput.vue b/src/components/shared/Input/TokenInput.vue index b36535f29..a3b00d6e1 100644 --- a/src/components/shared/Input/TokenInput.vue +++ b/src/components/shared/Input/TokenInput.vue @@ -77,7 +77,7 @@ @focus="handleFiatFocus" @blur="handleFiatBlur" > - $ + {{ currencySymbol }} @@ -113,10 +113,11 @@ import { Component, Mixins, Prop, Ref, Watch } from 'vue-property-decorator'; import TranslationMixin from '@/components/mixins/TranslationMixin'; import { Components, ZeroStringValue } from '@/consts'; import { lazyComponent } from '@/router'; -import { mutation } from '@/store/decorators'; +import { state, getter, mutation } from '@/store/decorators'; import type { CodecString } from '@sora-substrate/util'; import type { RegisteredAccountAsset } from '@sora-substrate/util/build/assets/types'; +import type { Currency, FiatExchangeRateObject } from '@soramitsu/soraneo-wallet-web/lib/types/currency'; @Component({ components: { @@ -131,6 +132,11 @@ export default class TokenInput extends Mixins( mixins.FormattedAmountMixin, TranslationMixin ) { + @state.wallet.settings.currency currency!: Currency; + @state.wallet.settings.fiatExchangeRateObject fiatExchangeRateObject!: FiatExchangeRateObject; + + @getter.wallet.settings.currencySymbol currencySymbol!: string; + @mutation.orderBook.setAmountSliderValue setAmountSliderValue!: (value: number) => void; readonly delimiters = FPNumber.DELIMITERS_CONFIG; @@ -164,9 +170,16 @@ export default class TokenInput extends Mixins( this.fiatValue = this.fiatAmount.isZero() ? '' : this.fiatAmount.toFixed(this.fiatDecimals); } - recalcValue(fiatValue: string): void { - const result = - !this.tokenPrice.isZero() && fiatValue ? new FPNumber(fiatValue).div(this.tokenPrice).toString() : ''; + @Watch('currency', { immediate: true }) + private reactToCurrencyChange(): void { + this.setFiatValue(this.fiatValue); + } + + recalcValue(value: string): void { + const currentCurrencyRate = this.fiatExchangeRateObject[this.currency]; + const fiatValue = new FPNumber(value).div(currentCurrencyRate); + + const result = !this.tokenPrice.isZero() && value ? new FPNumber(fiatValue).div(this.tokenPrice).toString() : ''; this.$emit('input', result); } @@ -249,7 +262,10 @@ export default class TokenInput extends Mixins( calcFiatAmount(value: string | number): FPNumber { if (!value) return FPNumber.ZERO; - return new FPNumber(value).mul(this.tokenPrice); + const currentCurrencyRate = this.fiatExchangeRateObject[this.currency]; + const tokenPrice = this.tokenPrice.mul(currentCurrencyRate); + + return new FPNumber(value).mul(tokenPrice); } handleMax(): void { diff --git a/src/components/shared/Widget/PriceChart.vue b/src/components/shared/Widget/PriceChart.vue index b3fe10516..6995a1f07 100644 --- a/src/components/shared/Widget/PriceChart.vue +++ b/src/components/shared/Widget/PriceChart.vue @@ -78,6 +78,7 @@ import { subscribeOnOrderBookUpdates } from '@/indexer/queries/orderBook'; import { fetchAssetData } from '@/indexer/queries/price/asset'; import { fetchOrderBookData } from '@/indexer/queries/price/orderBook'; import { lazyComponent } from '@/router'; +import { state, getter } from '@/store/decorators'; import type { OCLH, SnapshotItem } from '@/types/chart'; import { Timeframes } from '@/types/filters'; import type { SnapshotFilter } from '@/types/filters'; @@ -87,10 +88,12 @@ import { calcPriceChange, formatDecimalPlaces, formatAmountWithSuffix, + getCurrency, } from '@/utils'; import type { AccountAsset } from '@sora-substrate/util/build/assets/types'; import type { PageInfo, SnapshotTypes } from '@soramitsu/soraneo-wallet-web/lib/services/indexer/types'; +import type { Currency, CurrencyFields } from '@soramitsu/soraneo-wallet-web/lib/types/currency'; const USD_SYMBOL = 'USD'; @@ -270,6 +273,10 @@ export default class PriceChartWidget extends Mixins( mixins.NumberFormatterMixin, mixins.FormattedAmountMixin ) { + @state.wallet.settings.currency private currency!: Currency; + @state.wallet.settings.currencies private currencies!: Array; + @getter.wallet.settings.exchangeRate private exchangeRate!: number; + @Prop({ default: DexId.XOR, type: Number }) readonly dexId!: DexId; @Prop({ default: () => null, type: Object }) readonly baseAsset!: Nullable; @Prop({ default: () => null, type: Object }) readonly quoteAsset!: Nullable; @@ -373,7 +380,9 @@ export default class PriceChartWidget extends Mixins( } get symbol(): string { - return this.tokenB?.symbol ?? USD_SYMBOL; + const currentCurrencyAbbr = getCurrency(this.currency, this.currencies)?.key.toUpperCase() || USD_SYMBOL; + + return this.tokenB?.symbol ?? currentCurrencyAbbr; } get currentPrice(): FPNumber { @@ -381,7 +390,7 @@ export default class PriceChartWidget extends Mixins( } get currentPriceFormatted(): string { - return this.currentPrice.toLocaleString(this.precision); + return this.currentPrice.mul(this.exchangeRate).toLocaleString(this.precision); } get isAllHistoricalPricesFetched(): boolean { diff --git a/src/consts/index.ts b/src/consts/index.ts index bfe47ae9f..fd37d23ee 100644 --- a/src/consts/index.ts +++ b/src/consts/index.ts @@ -166,6 +166,7 @@ export enum Components { CreateAlert = 'App/Alerts/CreateAlert', AlertsSelectAsset = 'pages/Alerts/SelectAsset', SelectLanguageDialog = 'App/Settings/Language/SelectLanguageDialog', + SelectCurrencyDialog = 'App/Settings/Currency/SelectCurrencyDialog', AppFooter = 'App/Footer/AppFooter', AppDisclaimer = 'App/Header/AppDisclaimer', SelectIndexer = 'App/Footer/Indexer/SelectIndexer', diff --git a/src/lang/cs.json b/src/lang/cs.json index edae6248c..91c8afdec 100644 --- a/src/lang/cs.json +++ b/src/lang/cs.json @@ -903,7 +903,8 @@ "switchTheme": "Přepnout do režimu {theme}", "switchLanguage": "Vybrat jazyk", "showDisclaimer": "Zobrazit vyloučení odpovědnosti", - "hideDisclaimer": "Skrýt vyloučení odpovědnosti" + "hideDisclaimer": "Skrýt vyloučení odpovědnosti", + "selectCurrency": "Vyberte možnost Měna" }, "sentText": "Odesláno", "learnMoreText": "Zjistit více", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Zadejte heslo", "googleOnly": "Pouze účty {Google}" + }, + "currencyDialog": { + "currency": "Měna", + "searchPlaceholder": "Hledejte podle názvu měny nebo symbolu" } } \ No newline at end of file diff --git a/src/lang/de.json b/src/lang/de.json index a3c8b0c19..6be9d125b 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -903,7 +903,8 @@ "switchTheme": "Wechseln Sie in den {theme}-Modus", "switchLanguage": "Sprache wählen", "showDisclaimer": "Haftungsausschluss anzeigen", - "hideDisclaimer": "Haftungsausschluss ausblenden" + "hideDisclaimer": "Haftungsausschluss ausblenden", + "selectCurrency": "Währung wählen" }, "sentText": "Gesendet", "learnMoreText": "Mehr erfahren", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Passwort eingeben", "googleOnly": "Nur {Google} -Konten" + }, + "currencyDialog": { + "currency": "Währung", + "searchPlaceholder": "Suche nach Währungsnamen oder -symbol" } } \ No newline at end of file diff --git a/src/lang/en.json b/src/lang/en.json index c8edb2b91..28eb6ae80 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -903,7 +903,8 @@ "switchTheme": "Switch to {theme} Mode", "switchLanguage": "Choose Language", "showDisclaimer": "Show Disclaimer", - "hideDisclaimer": "Hide Disclaimer" + "hideDisclaimer": "Hide Disclaimer", + "selectCurrency": "Select Currency" }, "sentText": "Sent", "learnMoreText": "Learn more", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Enter password", "googleOnly": "{Google} accounts only" + }, + "currencyDialog": { + "currency": "Currency", + "searchPlaceholder": "Search by currency name or symbol" } } \ No newline at end of file diff --git a/src/lang/es.json b/src/lang/es.json index 7d82d71ec..af6174c7f 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -903,7 +903,8 @@ "switchTheme": "Cambiar al modo {theme}", "switchLanguage": "Elige lenguaje", "showDisclaimer": "Mostrar descargo de responsabilidad", - "hideDisclaimer": "Ocultar descargo de responsabilidad" + "hideDisclaimer": "Ocultar descargo de responsabilidad", + "selectCurrency": "Seleccione el tipo de moneda" }, "sentText": "Enviado", "learnMoreText": "Aprende más", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Introduzca la contraseña", "googleOnly": "Solo cuentas de {Google}" + }, + "currencyDialog": { + "currency": "Divisa", + "searchPlaceholder": "Buscar por nombre o símbolo de moneda" } } \ No newline at end of file diff --git a/src/lang/fr.json b/src/lang/fr.json index b7679b7f9..27dd1653d 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -903,7 +903,8 @@ "switchTheme": "Passer en mode {theme}", "switchLanguage": "Choisissez la langue", "showDisclaimer": "Afficher la clause de non-responsabilité", - "hideDisclaimer": "Masquer la clause de non-responsabilité" + "hideDisclaimer": "Masquer la clause de non-responsabilité", + "selectCurrency": "Sélectionnez la devise" }, "sentText": "Envoyé", "learnMoreText": "En savoir plus", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Entrer le mot de passe", "googleOnly": "Comptes {Google} uniquement" + }, + "currencyDialog": { + "currency": "Devise", + "searchPlaceholder": "Rechercher par nom ou symbole de devise" } } \ No newline at end of file diff --git a/src/lang/hr.json b/src/lang/hr.json index 3dc1c4860..bbd5dacc2 100644 --- a/src/lang/hr.json +++ b/src/lang/hr.json @@ -903,7 +903,8 @@ "switchTheme": "Prijeđite na {theme} modus", "switchLanguage": "Odaberite jezik", "showDisclaimer": "Prikaži Odricanje od odgovornosti", - "hideDisclaimer": "Sakrij izjavu o odricanju odgovornosti" + "hideDisclaimer": "Sakrij izjavu o odricanju odgovornosti", + "selectCurrency": "Odaberite Valutu" }, "sentText": "Poslano", "learnMoreText": "Saznajte više", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Upišite lozinku", "googleOnly": "Samo {Google} računi" + }, + "currencyDialog": { + "currency": "Valuta", + "searchPlaceholder": "Pretražujte prema nazivu valute ili simbolu" } } \ No newline at end of file diff --git a/src/lang/hu.json b/src/lang/hu.json index 7938bfd2e..6213ab9f6 100644 --- a/src/lang/hu.json +++ b/src/lang/hu.json @@ -903,7 +903,8 @@ "switchTheme": "Váltás {theme} módra", "switchLanguage": "Nyelv kiválasztása", "showDisclaimer": "Felelősségi nyilatkozat megjelenítése", - "hideDisclaimer": "Felelősségi nyilatkozat elrejtése" + "hideDisclaimer": "Felelősségi nyilatkozat elrejtése", + "selectCurrency": "Válassza a Pénznem lehetőséget" }, "sentText": "Küldött", "learnMoreText": "Tudj meg többet", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Írd be a jelszót", "googleOnly": "Csak {Google} -fiókok" + }, + "currencyDialog": { + "currency": "Valuta", + "searchPlaceholder": "Keresés pénznem neve vagy szimbóluma alapján" } } \ No newline at end of file diff --git a/src/lang/hy.json b/src/lang/hy.json index 4a2994103..56f9e74e8 100644 --- a/src/lang/hy.json +++ b/src/lang/hy.json @@ -903,7 +903,8 @@ "switchTheme": "Անցնել {theme} ռեժիմի", "switchLanguage": "Ընտրեք Լեզուն", "showDisclaimer": "Ցույց տալ հերքումը", - "hideDisclaimer": "Թաքցնել հերքումը" + "hideDisclaimer": "Թաքցնել հերքումը", + "selectCurrency": "Ընտրեք արժույթ" }, "sentText": "Ուղարկված է", "learnMoreText": "Իմանալ ավելին", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Մուտքագրեք գաղտնաբառը", "googleOnly": "Միայն {Google} հաշիվները" + }, + "currencyDialog": { + "currency": "Արժույթ", + "searchPlaceholder": "Որոնել ըստ արժույթի անվանման կամ խորհրդանիշի" } } \ No newline at end of file diff --git a/src/lang/id.json b/src/lang/id.json index 34750a68a..befe01078 100644 --- a/src/lang/id.json +++ b/src/lang/id.json @@ -903,7 +903,8 @@ "switchTheme": "Beralih ke Mode {theme}", "switchLanguage": "Pilih bahasa", "showDisclaimer": "Tampilkan Penafian", - "hideDisclaimer": "Sembunyikan Penafian" + "hideDisclaimer": "Sembunyikan Penafian", + "selectCurrency": "Pilih Mata Uang" }, "sentText": "Terkirim", "learnMoreText": "Pelajari lebih lanjut", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Masukan kata sandi", "googleOnly": "Khusus akun {Google}" + }, + "currencyDialog": { + "currency": "Mata uang", + "searchPlaceholder": "Cari berdasarkan nama atau simbol mata uang" } } \ No newline at end of file diff --git a/src/lang/it.json b/src/lang/it.json index dd2654ed3..19854a8c5 100644 --- a/src/lang/it.json +++ b/src/lang/it.json @@ -903,7 +903,8 @@ "switchTheme": "Passa alla modalità {theme}", "switchLanguage": "Scegli la lingua", "showDisclaimer": "Mostra esclusione di responsabilità", - "hideDisclaimer": "Nascondi Dichiarazione di non responsabilità" + "hideDisclaimer": "Nascondi Dichiarazione di non responsabilità", + "selectCurrency": "Seleziona Valuta" }, "sentText": "Inviato", "learnMoreText": "Per saperne di più", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Inserire la password", "googleOnly": "Solo account {Google}" + }, + "currencyDialog": { + "currency": "Valuta", + "searchPlaceholder": "Cerca per nome o simbolo della valuta" } } \ No newline at end of file diff --git a/src/lang/messages.ts b/src/lang/messages.ts index 56198afab..bd89c0d8c 100644 --- a/src/lang/messages.ts +++ b/src/lang/messages.ts @@ -149,6 +149,7 @@ export default { settings: 'Settings', switchTheme: 'Switch to {theme} Mode', switchLanguage: 'Choose Language', + selectCurrency: 'Select Currency', showDisclaimer: 'Show Disclaimer', hideDisclaimer: 'Hide Disclaimer', }, @@ -173,6 +174,10 @@ export default { appVersion: '{AppName} version', contactUs: 'Contact us', }, + currencyDialog: { + currency: 'Currency', + searchPlaceholder: 'Search by currency name or symbol', + }, aboutNetworkDialog: { title: 'About', network: { diff --git a/src/lang/nl.json b/src/lang/nl.json index 4945f2151..675b519c4 100644 --- a/src/lang/nl.json +++ b/src/lang/nl.json @@ -903,7 +903,8 @@ "switchTheme": "Overschakelen naar {theme} -modus", "switchLanguage": "Kies een taal", "showDisclaimer": "Disclaimer tonen", - "hideDisclaimer": "Disclaimer verbergen" + "hideDisclaimer": "Disclaimer verbergen", + "selectCurrency": "selecteer valuta" }, "sentText": "Verzonden", "learnMoreText": "Kom meer te weten", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Voer wachtwoord in", "googleOnly": "Alleen {Google} -accounts" + }, + "currencyDialog": { + "currency": "Munteenheid", + "searchPlaceholder": "Zoek op valutanaam of symbool" } } \ No newline at end of file diff --git a/src/lang/no.json b/src/lang/no.json index 23cbc85fc..50d2ed2a7 100644 --- a/src/lang/no.json +++ b/src/lang/no.json @@ -903,7 +903,8 @@ "switchTheme": "Bytt til {theme} -modus", "switchLanguage": "Velg språk", "showDisclaimer": "Vis ansvarsfraskrivelse", - "hideDisclaimer": "Skjul ansvarsfraskrivelse" + "hideDisclaimer": "Skjul ansvarsfraskrivelse", + "selectCurrency": "Velg Valuta" }, "sentText": "Sendt", "learnMoreText": "Lær mer", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Oppgi passord", "googleOnly": "Bare {Google} -kontoer" + }, + "currencyDialog": { + "currency": "Valuta", + "searchPlaceholder": "Søk etter valutanavn eller symbol" } } \ No newline at end of file diff --git a/src/lang/pl.json b/src/lang/pl.json index 856ded958..864e6c34d 100644 --- a/src/lang/pl.json +++ b/src/lang/pl.json @@ -903,7 +903,8 @@ "switchTheme": "Przełącz na tryb {theme}", "switchLanguage": "Wybierz język", "showDisclaimer": "Pokaż zastrzeżenie", - "hideDisclaimer": "Ukryj wyłączenie odpowiedzialności" + "hideDisclaimer": "Ukryj wyłączenie odpowiedzialności", + "selectCurrency": "Wybierz walutę" }, "sentText": "Wysłano", "learnMoreText": "Dowiedz się więcej", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Wprowadź hasło", "googleOnly": "Tylko konta {Google}" + }, + "currencyDialog": { + "currency": "Waluta", + "searchPlaceholder": "Szukaj według nazwy waluty lub symbolu" } } \ No newline at end of file diff --git a/src/lang/ru.json b/src/lang/ru.json index 93b93c4c5..da9574e8f 100644 --- a/src/lang/ru.json +++ b/src/lang/ru.json @@ -903,7 +903,8 @@ "switchTheme": "Перейти в {theme} режим", "switchLanguage": "Изменить язык", "showDisclaimer": "Показать дисклеймер", - "hideDisclaimer": "Скрыть дисклеймер" + "hideDisclaimer": "Скрыть дисклеймер", + "selectCurrency": "Выберите валюту" }, "sentText": "Отправить", "learnMoreText": "Узнать больше", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Введите пароль", "googleOnly": "Только аккаунты {Google}" + }, + "currencyDialog": { + "currency": "Валюта", + "searchPlaceholder": "Поиск по названию или символу валюты" } } \ No newline at end of file diff --git a/src/lang/sk.json b/src/lang/sk.json index 23b31de78..e1dc86aad 100644 --- a/src/lang/sk.json +++ b/src/lang/sk.json @@ -903,7 +903,8 @@ "switchTheme": "Prepnite do režimu {theme}", "switchLanguage": "Vyberte Jazyk", "showDisclaimer": "Zobraziť vylúčenie zodpovednosti", - "hideDisclaimer": "Skryť vylúčenie zodpovednosti" + "hideDisclaimer": "Skryť vylúčenie zodpovednosti", + "selectCurrency": "Vyberte položku Mena" }, "sentText": "Odoslané", "learnMoreText": "Dozvedieť sa viac", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Zadajte heslo", "googleOnly": "iba účty {Google}" + }, + "currencyDialog": { + "currency": "mena", + "searchPlaceholder": "Hľadajte podľa názvu meny alebo symbolu" } } \ No newline at end of file diff --git a/src/lang/sr.json b/src/lang/sr.json index 6c95a07e7..760dda5d3 100644 --- a/src/lang/sr.json +++ b/src/lang/sr.json @@ -903,7 +903,8 @@ "switchTheme": "Пребаците се на {theme} mод", "switchLanguage": "Изаберите језик", "showDisclaimer": "Схов Дисцлаимер", - "hideDisclaimer": "Сакриј одрицање одговорности" + "hideDisclaimer": "Сакриј одрицање одговорности", + "selectCurrency": "Изаберите Валута" }, "sentText": "Poslato", "learnMoreText": "Сазнајте више", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Унесите лозинку", "googleOnly": "Само {Google} налози" + }, + "currencyDialog": { + "currency": "Валута", + "searchPlaceholder": "Претражујте по називу валуте или симболу" } } \ No newline at end of file diff --git a/src/lang/sv.json b/src/lang/sv.json index 92d6ef6f3..56e8cd0e5 100644 --- a/src/lang/sv.json +++ b/src/lang/sv.json @@ -903,7 +903,8 @@ "switchTheme": "Byt till {theme} Läge", "switchLanguage": "Välj Språk", "showDisclaimer": "Visa ansvarsfriskrivning", - "hideDisclaimer": "Dölj ansvarsfriskrivning" + "hideDisclaimer": "Dölj ansvarsfriskrivning", + "selectCurrency": "Välj valuta" }, "sentText": "Skickat", "learnMoreText": "Lär dig mer", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Skriv in lösenord", "googleOnly": "Endast {Google} -konton" + }, + "currencyDialog": { + "currency": "Valuta", + "searchPlaceholder": "Sök efter valutanamn eller symbol" } } \ No newline at end of file diff --git a/src/lang/vi.json b/src/lang/vi.json index fc1385532..a883a7544 100644 --- a/src/lang/vi.json +++ b/src/lang/vi.json @@ -903,7 +903,8 @@ "switchTheme": "Chuyển sang chế độ {theme}", "switchLanguage": "Chọn ngôn ngữ", "showDisclaimer": "Hiển thị tuyên bố miễn trừ trách nhiệm", - "hideDisclaimer": "Ẩn tuyên bố từ chối trách nhiệm" + "hideDisclaimer": "Ẩn tuyên bố từ chối trách nhiệm", + "selectCurrency": "Chọn tiền tệ" }, "sentText": "Đã gửi", "learnMoreText": "Tìm hiểu thêm", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Nhập mật khẩu", "googleOnly": "Chỉ tài khoản {Google}" + }, + "currencyDialog": { + "currency": "Tiền tệ", + "searchPlaceholder": "Tìm kiếm theo tên hoặc ký hiệu tiền tệ" } } \ No newline at end of file diff --git a/src/lang/yo.json b/src/lang/yo.json index 1354b841b..5d0493f84 100644 --- a/src/lang/yo.json +++ b/src/lang/yo.json @@ -903,7 +903,8 @@ "switchTheme": "Yipada si {theme} Ipo", "switchLanguage": "Yan Ede", "showDisclaimer": "Ṣafihan AlAIgBA", - "hideDisclaimer": "Tọju AlAIgBA" + "hideDisclaimer": "Tọju AlAIgBA", + "selectCurrency": "Yan Owo" }, "sentText": "Ti firanṣẹ", "learnMoreText": "Kọ ẹkọ si", @@ -1678,5 +1679,9 @@ }, "enterPassword": "Tẹ ọrọ igbaniwọle sii", "googleOnly": "Awọn akọọlẹ {Google} nikan" + }, + "currencyDialog": { + "currency": "Owo owo", + "searchPlaceholder": "Ṣewadii nipasẹ orukọ owo tabi aami" } } \ No newline at end of file diff --git a/src/lang/zh_CN.json b/src/lang/zh_CN.json index 45259ad16..645bc102b 100644 --- a/src/lang/zh_CN.json +++ b/src/lang/zh_CN.json @@ -903,7 +903,8 @@ "switchTheme": "切换到{theme}模式", "switchLanguage": "选择语言", "showDisclaimer": "显示免责声明", - "hideDisclaimer": "隐藏免责声明" + "hideDisclaimer": "隐藏免责声明", + "selectCurrency": "选择货币" }, "sentText": "已发送", "learnMoreText": "了解更多", @@ -1678,5 +1679,9 @@ }, "enterPassword": "请输入密码", "googleOnly": "仅限{Google}帐户" + }, + "currencyDialog": { + "currency": "货币", + "searchPlaceholder": "按货币名称或符号搜索" } } \ No newline at end of file diff --git a/src/store/settings/mutations.ts b/src/store/settings/mutations.ts index 1ddd56761..78e3ac529 100644 --- a/src/store/settings/mutations.ts +++ b/src/store/settings/mutations.ts @@ -32,6 +32,9 @@ const mutations = defineMutations()({ setSelectLanguageDialogVisibility(state, value: boolean): void { state.selectLanguageDialogVisibility = value; }, + setSelectCurrencyDialogVisibility(state, value: boolean): void { + state.selectCurrencyDialogVisibility = value; + }, toggleDisclaimerDialogVisibility(state): void { state.disclaimerVisibility = !state.disclaimerVisibility; }, diff --git a/src/store/settings/state.ts b/src/store/settings/state.ts index 4931008a3..460bccaaf 100644 --- a/src/store/settings/state.ts +++ b/src/store/settings/state.ts @@ -29,6 +29,7 @@ function initialState(): SettingsState { selectNodeDialogVisibility: false, selectIndexerDialogVisibility: false, selectLanguageDialogVisibility: false, + selectCurrencyDialogVisibility: false, disclaimerVisibility: false, alertSettingsVisibility: false, browserNotifPopupVisibility: false, diff --git a/src/store/settings/types.ts b/src/store/settings/types.ts index 39af9a9a0..b3ae5c538 100644 --- a/src/store/settings/types.ts +++ b/src/store/settings/types.ts @@ -34,6 +34,7 @@ export type SettingsState = { selectNodeDialogVisibility: boolean; selectIndexerDialogVisibility: boolean; selectLanguageDialogVisibility: boolean; + selectCurrencyDialogVisibility: boolean; disclaimerVisibility: boolean; alertSettingsVisibility: boolean; browserNotifPopupVisibility: boolean; diff --git a/src/utils/index.ts b/src/utils/index.ts index 6c8653c99..650c9eb86 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -15,6 +15,7 @@ import storage from './storage'; import type { AmountWithSuffix } from '../types/formats'; import type { Asset, AccountAsset, RegisteredAccountAsset } from '@sora-substrate/util/build/assets/types'; import type { AccountLiquidity } from '@sora-substrate/util/build/poolXyk/types'; +import type { Currency, CurrencyFields } from '@soramitsu/soraneo-wallet-web/lib/types/currency'; import type { Route } from 'vue-router'; type AssetWithBalance = AccountAsset | RegisteredAccountAsset; @@ -133,6 +134,11 @@ export const showMostFittingValue = ( return toPrecision(value, precision).toLocaleString(); }; +// TODO: export from wallet +export const getCurrency = (currencyName: Currency, currencies: CurrencyFields[]): CurrencyFields | undefined => { + return currencies.find((currency) => currency.key === currencyName); +}; + export const hasInsufficientBalance = ( asset: AccountAsset | RegisteredAccountAsset, amount: string | number,