Skip to content

Commit

Permalink
fix: show total fedimint ecash as sats
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Dec 14, 2023
1 parent 13e0f42 commit 46e5f01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/client/src/hooks/UseGatewayEcashTotal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Big from 'big.js';
import { useGatewayState } from '../context/GatewayContext';

export const useGatewayEcashTotal = () => {
export const useGatewayEcashTotalSats = () => {
const { gatewayInfo } = useGatewayState();

if (!gatewayInfo || !gatewayInfo.federations) {
Expand All @@ -10,5 +10,6 @@ export const useGatewayEcashTotal = () => {

return gatewayInfo.federations
.reduce((acc, federation) => acc.add(federation.balance_msat), new Big(0))
.div(1000) // Convert from millisatoshis to satoshis
.toString();
};
4 changes: 2 additions & 2 deletions src/client/src/layouts/navigation/nodeInfo/NodeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../../../components/generic/Styled';
import { useConfigState } from '../../../context/ConfigContext';
import { usePriceState } from '../../../context/PriceContext';
import { useGatewayEcashTotal } from '../../../hooks/UseGatewayEcashTotal';
import { useGatewayEcashTotalSats } from '../../../hooks/UseGatewayEcashTotal';

const Closed = styled.div`
display: flex;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const NodeInfo = ({ isOpen, isBurger }: NodeInfoProps) => {
} = useNodeInfo();

const { onchain, lightning } = useNodeBalances();
const totalFedimintEcash = useGatewayEcashTotal();
const totalFedimintEcash = useGatewayEcashTotalSats();

const { currency, displayValues } = useConfigState();
const priceContext = usePriceState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Price } from '../../../../components/price/Price';
import { useGatewayDispatch } from '../../../../context/GatewayContext';
import { gatewayApi } from '../../../../api/GatewayApi';
import { GatewayInfo } from '../../../../api/types';
import { useGatewayEcashTotalSats } from '../../../../hooks/UseGatewayEcashTotal';

interface FedimintGatewayCardProps {
gatewayInfo: GatewayInfo;
Expand All @@ -28,6 +29,7 @@ export const FedimintGatewayCard = ({
}: FedimintGatewayCardProps) => {
const gatewayDispath = useGatewayDispatch();
const [inviteCode, setInviteCode] = useState('');
const totalFedimintEcash = useGatewayEcashTotalSats();

const handleEnter = () => {
gatewayApi.connectFederation(inviteCode).then(() => {
Expand Down Expand Up @@ -72,10 +74,7 @@ export const FedimintGatewayCard = ({
</>
) : (
<div style={{ margin: '0px 0px 8px 0px', minHeight: '54px' }}>
{renderLine(
'Total Amount',
<Price amount={gatewayInfo.federations[0].balance_msat} />
)}
{renderLine('Total Amount', <Price amount={totalFedimintEcash} />)}
{renderLine(
'Connected Federations',
gatewayInfo.federations.length
Expand Down

0 comments on commit 46e5f01

Please sign in to comment.