Changeset View
Changeset View
Standalone View
Standalone View
apps/marlin-wallet/web/src/screen/send.ts
| Show All 15 Lines | import { | ||||
| estimateTransactionFee, | estimateTransactionFee, | ||||
| estimateTokenSendFeeAndGas, | estimateTokenSendFeeAndGas, | ||||
| unitToAtoms, | unitToAtoms, | ||||
| } from '../amount'; | } from '../amount'; | ||||
| import { buildAction, buildTokenSendAction } from '../wallet'; | import { buildAction, buildTokenSendAction } from '../wallet'; | ||||
| import { | import { | ||||
| activeAssetDefinition, | activeAssetDefinition, | ||||
| activeAssetTicker, | activeAssetTicker, | ||||
| activeCryptoTicker, | |||||
| activeAssetDecimals, | activeAssetDecimals, | ||||
| activeTokenId, | activeTokenId, | ||||
| allowFiatForActiveAsset, | allowFiatForActiveAsset, | ||||
| activeQuoteCurrency, | activeQuoteCurrency, | ||||
| formatActiveAssetAmount, | |||||
| } from '../active-asset'; | } from '../active-asset'; | ||||
| import { isValidECashAddress } from '../address'; | import { isValidECashAddress } from '../address'; | ||||
| import { parseBip21Uri, Bip21ParseResult } from '../bip21'; | import { parseBip21Uri, Bip21ParseResult } from '../bip21'; | ||||
| import { isPayButtonTransaction } from '../deeplink'; | import { isPayButtonTransaction } from '../deeplink'; | ||||
| import { config } from '../config'; | import { config } from '../config'; | ||||
| import { XEC_ASSET } from '../supported-assets'; | import { XEC_ASSET } from '../supported-assets'; | ||||
| import { sendMessageToBackend, webViewLog, webViewError } from '../common'; | import { sendMessageToBackend, webViewLog, webViewError } from '../common'; | ||||
| import { t } from '../i18n'; | import { t } from '../i18n'; | ||||
| ▲ Show 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | private primaryToXec(primary: number): number { | ||||
| return this.useActiveAssetPrimary | return this.useActiveAssetPrimary | ||||
| ? primary | ? primary | ||||
| : primary / this.currentActiveAssetPrice; | : primary / this.currentActiveAssetPrice; | ||||
| } | } | ||||
| private formatPrimary(primary: number): string { | private formatPrimary(primary: number): string { | ||||
| const cryptoDecimals = activeAssetDecimals(); | const cryptoDecimals = activeAssetDecimals(); | ||||
| return this.useActiveAssetPrimary | return this.useActiveAssetPrimary | ||||
| ? formatPrice(primary, activeCryptoTicker(), { | ? formatActiveAssetAmount(primary, { | ||||
| locale: this.params.appSettings.locale, | locale: this.params.appSettings.locale, | ||||
| decimals: cryptoDecimals, | decimals: cryptoDecimals, | ||||
| }) | }) | ||||
| : formatPrice(primary, this.params.appSettings.fiatCurrency, { | : formatPrice(primary, this.params.appSettings.fiatCurrency, { | ||||
| locale: this.params.appSettings.locale, | locale: this.params.appSettings.locale, | ||||
| }); | }); | ||||
| } | } | ||||
| private formatSecondary(cryptoAmount: number): string | null { | private formatSecondary(cryptoAmount: number): string | null { | ||||
| if (this.currentActiveAssetPrice === null) { | if (this.currentActiveAssetPrice === null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| const cryptoDecimals = activeAssetDecimals(); | const cryptoDecimals = activeAssetDecimals(); | ||||
| return this.useActiveAssetPrimary | return this.useActiveAssetPrimary | ||||
| ? formatPrice( | ? formatPrice( | ||||
| cryptoAmount * this.currentActiveAssetPrice, | cryptoAmount * this.currentActiveAssetPrice, | ||||
| this.params.appSettings.fiatCurrency, | this.params.appSettings.fiatCurrency, | ||||
| { locale: this.params.appSettings.locale }, | { locale: this.params.appSettings.locale }, | ||||
| ) | ) | ||||
| : formatPrice(cryptoAmount, activeCryptoTicker(), { | : formatActiveAssetAmount(cryptoAmount, { | ||||
| locale: this.params.appSettings.locale, | locale: this.params.appSettings.locale, | ||||
| decimals: cryptoDecimals, | decimals: cryptoDecimals, | ||||
| }); | }); | ||||
| } | } | ||||
| private formatSecondaryXec(xecAmount: number): string | null { | private formatSecondaryXec(xecAmount: number): string | null { | ||||
| if (this.currentXecPrice === null) { | if (this.currentXecPrice === null) { | ||||
| return null; | return null; | ||||
| ▲ Show 20 Lines • Show All 587 Lines • Show Last 20 Lines | |||||