Changeset View
Changeset View
Standalone View
Standalone View
apps/marlin-wallet/web/src/screen/main.ts
| // Copyright (c) 2026 The Bitcoin developers | // Copyright (c) 2026 The Bitcoin developers | ||||
| // Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
| import { Navigation } from '../navigation'; | import { Navigation } from '../navigation'; | ||||
| import { AppSettings } from '../settings'; | import { AppSettings } from '../settings'; | ||||
| import { Wallet } from 'ecash-wallet'; | import { Wallet } from 'ecash-wallet'; | ||||
| import { CryptoTicker, formatPrice } from 'ecash-price'; | import { CryptoTicker, formatPrice } from 'ecash-price'; | ||||
| import type { MarlinPriceFetcher } from '../price'; | import type { MarlinPriceFetcher } from '../price'; | ||||
| import { | import { | ||||
| activeAssetDecimals, | activeAssetDecimals, | ||||
| activeAssetDefinition, | activeAssetDefinition, | ||||
| activeAssetTicker, | activeAssetTicker, | ||||
| activeCryptoTicker, | activeCryptoTicker, | ||||
| activeQuoteCurrency, | activeQuoteCurrency, | ||||
| allowFiatForActiveAsset, | allowFiatForActiveAsset, | ||||
| formatActiveAssetAmount, | |||||
| setActiveAsset as commitActiveAsset, | setActiveAsset as commitActiveAsset, | ||||
| } from '../active-asset'; | } from '../active-asset'; | ||||
| import { coinIconUrlForAssetKey } from '../coin-icon-url'; | import { coinIconUrlForAssetKey } from '../coin-icon-url'; | ||||
| import { | import { | ||||
| SUPPORTED_ASSETS, | SUPPORTED_ASSETS, | ||||
| XEC_ASSET, | XEC_ASSET, | ||||
| type AssetDefinition, | type AssetDefinition, | ||||
| } from '../supported-assets'; | } from '../supported-assets'; | ||||
| ▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | ): void { | ||||
| const fiatFormatOptions = { | const fiatFormatOptions = { | ||||
| locale: this.params.appSettings.locale, | locale: this.params.appSettings.locale, | ||||
| alwaysShowSign: true, | alwaysShowSign: true, | ||||
| }; | }; | ||||
| const displayText = | const displayText = | ||||
| this.params.appSettings.primaryBalanceType === 'XEC' || | this.params.appSettings.primaryBalanceType === 'XEC' || | ||||
| pricePerXec === null | pricePerXec === null | ||||
| ? formatPrice( | ? formatActiveAssetAmount(transitionalXec, cryptoFormatOptions) | ||||
| transitionalXec, | |||||
| this.params.primaryBalanceTicker, | |||||
| cryptoFormatOptions, | |||||
| ) | |||||
| : formatPrice( | : formatPrice( | ||||
| transitionalXec * pricePerXec, | transitionalXec * pricePerXec, | ||||
| this.params.appSettings.fiatCurrency, | this.params.appSettings.fiatCurrency, | ||||
| fiatFormatOptions, | fiatFormatOptions, | ||||
| ); | ); | ||||
| this.ui.transitionalBalance.textContent = displayText; | this.ui.transitionalBalance.textContent = displayText; | ||||
| this.ui.transitionalBalance.className = `transitional-balance ${type}`; | this.ui.transitionalBalance.className = `transitional-balance ${type}`; | ||||
| ▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | private updateBalanceElement(params: UpdateBalanceElementParams): void { | ||||
| // If pricePerXec is null show as XEC, otherwise show as Fiat | // If pricePerXec is null show as XEC, otherwise show as Fiat | ||||
| const fromValue = | const fromValue = | ||||
| pricePerXec === null ? fromXec : fromXec * pricePerXec; | pricePerXec === null ? fromXec : fromXec * pricePerXec; | ||||
| const toValue = pricePerXec === null ? toXec : toXec * pricePerXec; | const toValue = pricePerXec === null ? toXec : toXec * pricePerXec; | ||||
| const formatValue = | const formatValue = | ||||
| pricePerXec === null | pricePerXec === null | ||||
| ? (value: number) => { | ? (value: number) => { | ||||
| return formatPrice( | return formatActiveAssetAmount(value, { | ||||
| value, | |||||
| this.params.primaryBalanceTicker, | |||||
| { | |||||
| locale: this.params.appSettings.locale, | locale: this.params.appSettings.locale, | ||||
| decimals: this.params.primaryBalanceDecimals, | decimals: this.params.primaryBalanceDecimals, | ||||
| }, | }); | ||||
| ); | |||||
| } | } | ||||
| : (value: number) => { | : (value: number) => { | ||||
| return formatPrice( | return formatPrice( | ||||
| value, | value, | ||||
| this.params.appSettings.fiatCurrency, | this.params.appSettings.fiatCurrency, | ||||
| { locale: this.params.appSettings.locale }, | { locale: this.params.appSettings.locale }, | ||||
| ); | ); | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||