Add oracle rates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, formatSatoshis, formatHex } from '../../../theme.js';
|
||||
import { useSatoshisConversion } from '../../../hooks/useSatoshisConversion.js';
|
||||
import type { SelectableUTXO, FocusArea } from '../types.js';
|
||||
|
||||
interface Props {
|
||||
@@ -22,6 +23,13 @@ export function InputsStep({
|
||||
changeAmount,
|
||||
focusArea,
|
||||
}: Props): React.ReactElement {
|
||||
const { formatSatoshisToFiat } = useSatoshisConversion('USD');
|
||||
|
||||
const getFiatSuffix = (satoshis: bigint): string => {
|
||||
const fiatValue = formatSatoshisToFiat(satoshis);
|
||||
return fiatValue ? ` (~${fiatValue})` : '';
|
||||
};
|
||||
|
||||
return (
|
||||
<Box flexDirection='column'>
|
||||
<Text color={colors.text} bold>
|
||||
@@ -32,6 +40,7 @@ export function InputsStep({
|
||||
<Text color={colors.textMuted}>
|
||||
Required: {formatSatoshis(requiredAmount)} +{' '}
|
||||
{formatSatoshis(fee)} fee
|
||||
{getFiatSuffix(requiredAmount + fee)}
|
||||
</Text>
|
||||
<Text
|
||||
color={
|
||||
@@ -41,10 +50,12 @@ export function InputsStep({
|
||||
}
|
||||
>
|
||||
Selected: {formatSatoshis(selectedAmount)}
|
||||
{getFiatSuffix(selectedAmount)}
|
||||
</Text>
|
||||
{selectedAmount > requiredAmount + fee && (
|
||||
<Text color={colors.info}>
|
||||
Change: {formatSatoshis(changeAmount)}
|
||||
{getFiatSuffix(changeAmount)}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
@@ -65,6 +76,7 @@ export function InputsStep({
|
||||
return (
|
||||
<Box
|
||||
key={`${utxo.outpointTransactionHash}:${utxo.outpointIndex}`}
|
||||
flexDirection='column'
|
||||
>
|
||||
<Text
|
||||
color={isCursor ? colors.focus : colors.text}
|
||||
@@ -75,6 +87,15 @@ export function InputsStep({
|
||||
{formatHex(utxo.outpointTransactionHash, 12)}:
|
||||
{utxo.outpointIndex}
|
||||
</Text>
|
||||
{(() => {
|
||||
const fiatValue = formatSatoshisToFiat(utxo.valueSatoshis);
|
||||
if (!fiatValue) return null;
|
||||
return (
|
||||
<Text color={colors.textMuted}>
|
||||
{' '}≈ {fiatValue}
|
||||
</Text>
|
||||
);
|
||||
})()}
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user