- {availableBalance} |
+
+
+ |
{balance.available.unit} |
@@ -54,11 +55,18 @@ export const Balance = ({
{
balance.hasIncoming && (
-
- {t('account.incoming')} +{incomingBalance} {balance.incoming.unit} /
-
- {' '}
-
+
+ {t('account.incoming')}
+
+ +
+ {' '}{balance.incoming.unit} /
+
+ {' '}
+
+
)
diff --git a/frontends/web/src/components/rates/rates.tsx b/frontends/web/src/components/rates/rates.tsx
index 5d0ae6fe49..c29d31ad35 100644
--- a/frontends/web/src/components/rates/rates.tsx
+++ b/frontends/web/src/components/rates/rates.tsx
@@ -21,7 +21,7 @@ import { reinitializeAccounts } from '../../api/backend';
import { share } from '../../decorators/share';
import { Store } from '../../decorators/store';
import { setConfig } from '../../utils/config';
-import { bitcoinRemoveTrailingZeroes } from '../../utils/trailing-zeroes';
+import { Amount } from '../../components/amount/amount';
import { equal } from '../../utils/equal';
import { apiGet } from '../../utils/request';
import style from './rates.module.css';
@@ -128,27 +128,25 @@ function Conversion({
btcUnit,
}: TProps) {
- let formattedValue = '---';
+ let formattedAmount = <>{'---'}>;
let isAvailable = false;
+ var activeUnit: ConversionUnit = active;
+ if (active === 'BTC' && btcUnit === 'sat') {
+ activeUnit = 'sat';
+ }
+
// amount.conversions[active] can be empty in recent transactions.
if (amount && amount.conversions && amount.conversions[active] && amount.conversions[active] !== '') {
isAvailable = true;
- formattedValue = amount.conversions[active];
- if (noBtcZeroes) {
- formattedValue = bitcoinRemoveTrailingZeroes(formattedValue, active);
- }
+ formattedAmount = ;
}
- var activeUnit: ConversionUnit = active;
- if (active === 'BTC' && btcUnit === 'sat') {
- activeUnit = 'sat';
- }
if (tableRow) {
return (
- {formattedValue} |
+ {formattedAmount} |
{
!noAction && (
{activeUnit} |
@@ -165,7 +163,7 @@ function Conversion({
return (
{isAvailable ? sign : ''}
- {formattedValue}
+ {formattedAmount}
{' '}
{
!skipUnit && !noAction && (
diff --git a/frontends/web/src/components/transactions/transaction.tsx b/frontends/web/src/components/transactions/transaction.tsx
index 7894b8a7b0..0881577031 100644
--- a/frontends/web/src/components/transactions/transaction.tsx
+++ b/frontends/web/src/components/transactions/transaction.tsx
@@ -25,6 +25,7 @@ import { CopyableInput } from '../copy/Copy';
import { Edit, EditLight, ExpandIcon, Save, SaveLight } from '../icon/icon';
import { ProgressRing } from '../progressRing/progressRing';
import { FiatConversion } from '../rates/rates';
+import { Amount } from '../../components/amount/amount';
import { ArrowIn, ArrowOut, ArrowSelf } from './components/icons';
import style from './transaction.module.css';
import parentStyle from './transactions.module.css';
@@ -214,7 +215,8 @@ class Transaction extends Component {
- {sign}{amount.amount}
+ {sign}
+
{amount.unit}
@@ -312,7 +314,10 @@ class Transaction extends Component {
- {sign}{amount.amount}
+
+ {sign}
+
+
{' '}
{transactionInfo.amount.unit}
@@ -322,7 +327,7 @@ class Transaction extends Component
{
{
transactionInfo.fee && transactionInfo.fee.amount ? (
- {transactionInfo.fee.amount}
+
{' '}
{transactionInfo.fee.unit}
diff --git a/frontends/web/src/routes/account/info/buyReceiveCTA.tsx b/frontends/web/src/routes/account/info/buyReceiveCTA.tsx
index b19d8ab05f..3f4c4799ad 100644
--- a/frontends/web/src/routes/account/info/buyReceiveCTA.tsx
+++ b/frontends/web/src/routes/account/info/buyReceiveCTA.tsx
@@ -16,7 +16,7 @@
import { useTranslation } from 'react-i18next';
import { route } from '../../../utils/route';
-import { CoinWithSAT, IBalance } from '../../../api/account';
+import { CoinUnit, IBalance } from '../../../api/account';
import { Button } from '../../../components/forms';
import { Balances } from '../summary/accountssummary';
import styles from './buyReceiveCTA.module.css';
@@ -29,7 +29,7 @@ type TBuyReceiveCTAProps = {
};
export const BuyReceiveCTA = ({ code, unit, balanceList }: TBuyReceiveCTAProps) => {
- const formattedUnit = isBitcoinCoin(unit as CoinWithSAT) ? 'BTC' : unit;
+ const formattedUnit = isBitcoinCoin(unit as CoinUnit) ? 'BTC' : unit;
const { t } = useTranslation();
const onBuyCTA = () => route(code ? `/buy/info/${code}` : '/buy/info');
const onReceiveCTA = () => {
diff --git a/frontends/web/src/routes/account/send/send.tsx b/frontends/web/src/routes/account/send/send.tsx
index c32fae2e73..75c9d13a1f 100644
--- a/frontends/web/src/routes/account/send/send.tsx
+++ b/frontends/web/src/routes/account/send/send.tsx
@@ -1,6 +1,6 @@
/**
* Copyright 2018 Shift Devices AG
- * Copyright 2022 Shift Crypto AG
+ * Copyright 2023 Shift Crypto AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@ import { WaitDialog } from '../../../components/wait-dialog/wait-dialog';
import { translate, TranslateProps } from '../../../decorators/translate';
import { debug } from '../../../utils/env';
import { apiGet, apiPost } from '../../../utils/request';
+import { Amount } from '../../../components/amount/amount';
import { apiWebsocket } from '../../../utils/websocket';
import { isBitcoinBased, customFeeUnit, isBitcoinOnly, findAccount } from '../utils';
import { FeeTargets } from './feetargets';
@@ -771,14 +772,18 @@ class Send extends Component {
- {(proposedAmount && proposedAmount.amount) || 'N/A'}
+ {(proposedAmount &&
+ ) || 'N/A'}
{' '}
{(proposedAmount && proposedAmount.unit) || 'N/A'}
{
proposedAmount && proposedAmount.conversions && (
- / {proposedAmount.conversions[fiatUnit]} {baseCurrencyUnit}
- )
+
+ /
+
+ {' '}{baseCurrencyUnit}
+ )
}
@@ -792,14 +797,16 @@ class Send extends Component {
- {(proposedFee && proposedFee.amount) || 'N/A'}
+ {(proposedFee &&
+ ) || 'N/A'}
{' '}
{(proposedFee && proposedFee.unit) || 'N/A'}
{proposedFee && proposedFee.conversions && (
/
- {proposedFee.conversions[fiatUnit]} {baseCurrencyUnit}
+
+ {' '}{baseCurrencyUnit}
)}
{customFee ? (
@@ -826,12 +833,19 @@ class Send extends Component {
- {(proposedTotal && proposedTotal.amount) || 'N/A'}
+
+ {(proposedTotal &&
+ ) || 'N/A'}
+
{' '}
{(proposedTotal && proposedTotal.unit) || 'N/A'}
{(proposedTotal && proposedTotal.conversions) && (
- / {proposedTotal.conversions[fiatUnit]} {baseCurrencyUnit}
+
+ /
+
+ {' '}{baseCurrencyUnit}
+
)}
diff --git a/frontends/web/src/routes/account/send/utxos.tsx b/frontends/web/src/routes/account/send/utxos.tsx
index 827d9ee481..08e1ef94c8 100644
--- a/frontends/web/src/routes/account/send/utxos.tsx
+++ b/frontends/web/src/routes/account/send/utxos.tsx
@@ -28,6 +28,7 @@ import A from '../../../components/anchor/anchor';
import { Dialog } from '../../../components/dialog/dialog';
import { Button, Checkbox } from '../../../components/forms';
import { ExpandOpen } from '../../../components/icon';
+import { Amount } from '../../../components/amount/amount';
import { FiatConversion } from '../../../components/rates/rates';
import { getScriptName } from '../utils';
import style from './utxos.module.css';
@@ -100,7 +101,7 @@ export const UTXOs = ({
- {utxo.amount.amount}
+
{' '}
{utxo.amount.unit}
diff --git a/frontends/web/src/routes/account/summary/accountssummary.tsx b/frontends/web/src/routes/account/summary/accountssummary.tsx
index 7e30e48531..8ee79bc4a5 100644
--- a/frontends/web/src/routes/account/summary/accountssummary.tsx
+++ b/frontends/web/src/routes/account/summary/accountssummary.tsx
@@ -33,6 +33,7 @@ import { AddBuyReceiveOnEmptyBalances } from '../info/buyReceiveCTA';
import { apiPost } from '../../../utils/request';
import style from './accountssummary.module.css';
import { route } from '../../../utils/route';
+import { Amount } from '../../../components/amount/amount';
import { Skeleton } from '../../../components/skeleton/skeleton';
interface AccountSummaryProps {
@@ -214,7 +215,7 @@ class AccountsSummary extends Component {
{ nameCol }
- {balance.available.amount}{' '}
+ {' '}
{balance.available.unit}
|
@@ -262,7 +263,9 @@ class AccountsSummary extends Component {
{ nameCol }
- {balance.amount}
+
+
+
{' '}
{balance.unit}
@@ -363,7 +366,7 @@ class AccountsSummary extends Component {
{(data && data.formattedChartTotal !== null) ? (
<>
- {data.formattedChartTotal}
+
{' '}
diff --git a/frontends/web/src/routes/account/summary/chart.tsx b/frontends/web/src/routes/account/summary/chart.tsx
index 142decc1dc..b98d67675c 100644
--- a/frontends/web/src/routes/account/summary/chart.tsx
+++ b/frontends/web/src/routes/account/summary/chart.tsx
@@ -1,5 +1,5 @@
/**
- * Copyright 2020 Shift Crypto AG
+ * Copyright 2023 Shift Crypto AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import { ISummary } from '../../../api/account';
import { translate, TranslateProps } from '../../../decorators/translate';
import { Skeleton } from '../../../components/skeleton/skeleton';
import { formatNumber } from '../../../components/rates/rates';
-import { bitcoinRemoveTrailingZeroes } from '../../../utils/trailing-zeroes';
+import { Amount } from '../../../components/amount/amount';
import styles from './chart.module.css';
import Filters from './filters';
import { getDarkmode } from '../../../components/darkmode/darkmode';
@@ -471,7 +471,7 @@ class Chart extends Component {
{formattedChartTotal !== null ? (
// remove trailing zeroes for BTC fiat total
- bitcoinRemoveTrailingZeroes(!showMobileTotalValue ? formattedChartTotal : toolTipValue, chartFiat)
+
) : (
)}
@@ -522,7 +522,7 @@ class Chart extends Component {
{toolTipValue !== undefined ? (
- {toolTipValue}
+
{chartFiat}
diff --git a/frontends/web/src/routes/account/utils.ts b/frontends/web/src/routes/account/utils.ts
index b2d0e3642c..ed19f7c30f 100644
--- a/frontends/web/src/routes/account/utils.ts
+++ b/frontends/web/src/routes/account/utils.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { CoinCode, ScriptType, IAccount, CoinWithSAT } from '../../api/account';
+import { CoinCode, ScriptType, IAccount, CoinUnit } from '../../api/account';
export function findAccount(accounts: IAccount[], accountCode: string): IAccount | undefined {
return accounts.find(({ code }) => accountCode === code);
@@ -38,7 +38,7 @@ export function isBitcoinOnly(coinCode: CoinCode): boolean {
}
}
-export const isBitcoinCoin = (coin: CoinWithSAT) => (coin === 'BTC') || (coin === 'TBTC') || (coin === 'sat') || (coin === 'tsat');
+export const isBitcoinCoin = (coin: CoinUnit) => (coin === 'BTC') || (coin === 'TBTC') || (coin === 'sat') || (coin === 'tsat');
export function isBitcoinBased(coinCode: CoinCode): boolean {
switch (coinCode) {
diff --git a/frontends/web/src/utils/trailing-zeroes.test.tsx b/frontends/web/src/utils/trailing-zeroes.test.tsx
deleted file mode 100644
index a6a39beda2..0000000000
--- a/frontends/web/src/utils/trailing-zeroes.test.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2022 Shift Crypto AG
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { bitcoinRemoveTrailingZeroes } from '../../src/utils/trailing-zeroes';
-
-describe('removeTrailingZeroes', () => {
- let coins;
-
- describe('coins that need to remove trailing zeroes', () => {
- coins = ['BTC', 'TBTC', 'LTC', 'TLTC'];
- coins.forEach(coin => {
- it('10.00000000 ' + coin + ' becomes 10', () => {
- expect(bitcoinRemoveTrailingZeroes('10.00000000', coin)).toBe('10');
- });
- it('10.12300000 ' + coin + ' becomes 10.123', () => {
- expect(bitcoinRemoveTrailingZeroes('10.12300000', coin)).toBe('10.123');
- });
- it('42 ' + coin + ' stays 42', () => {
- expect(bitcoinRemoveTrailingZeroes('42', coin)).toBe('42');
- });
- });
- });
-
- describe('coins that don\'t need to remove trailing zeroes', () => {
- coins = ['ETH', 'GOETH'];
- coins.forEach(coin => {
- it('10.00000000 ' + coin + ' stays 10.00000000', () => {
- expect(bitcoinRemoveTrailingZeroes('10.00000000', coin)).toBe('10.00000000');
- });
- it('10.12300000 ' + coin + ' stays 10.12300000', () => {
- expect(bitcoinRemoveTrailingZeroes('10.12300000', coin)).toBe('10.12300000');
- });
- it('42 ' + coin + ' stays 42', () => {
- expect(bitcoinRemoveTrailingZeroes('42', coin)).toBe('42');
- });
- });
- });
-
-});
diff --git a/frontends/web/src/utils/trailing-zeroes.ts b/frontends/web/src/utils/trailing-zeroes.ts
deleted file mode 100644
index 9f85359011..0000000000
--- a/frontends/web/src/utils/trailing-zeroes.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2022 Shift Crypto AG
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export function bitcoinRemoveTrailingZeroes(amount: string, unit: string): string {
- if (amount.includes('.')) {
- switch (unit) {
- case 'BTC':
- case 'TBTC':
- case 'LTC':
- case 'TLTC':
- return amount.replace(/\.?0+$/, '');
- default:
- }
- }
- return amount;
-}
-
-
|