Skip to content

Commit

Permalink
fix: flip the balances
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 20, 2024
1 parent 1f81cc0 commit 57bb153
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import type { Inscription } from '@leather.io/models';

import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip';

const featureBuilt = false;

interface HighSatValueUtxoProps {
inscription: Inscription;
}

export function HighSatValueUtxoWarning({ inscription }: HighSatValueUtxoProps) {
if (Number(inscription.value) < 5_000) return null;
if (!featureBuilt) return null;
return (
<Box position="absolute" top="space.01" right="space.01">
<BasicTooltip label="This inscription has loads of BTC on it, remove protections? Click">
Expand Down
49 changes: 24 additions & 25 deletions src/app/features/collectibles/components/bitcoin/inscription.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useCallback, useMemo, useState } from 'react';
import { useCallback, useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

import { Box } from 'leather-styles/jsx';
import { useHover } from 'use-events';

import { type Inscription } from '@leather.io/models';
import {
Expand All @@ -11,8 +10,10 @@ import {
ExternalLinkIcon,
Flag,
IconButton,
LockIcon,
OrdinalAvatarIcon,
TrashIcon,
UnlockIcon,
} from '@leather.io/ui';

import { ORD_IO_URL } from '@shared/constants';
Expand Down Expand Up @@ -49,8 +50,6 @@ export function Inscription({ inscription }: InscriptionProps) {
});
}, [navigate, inscription, location]);

const [isHovered, bind] = useHover();

const content = useMemo(() => {
const sharedProps = { onClickSend: () => openSendInscriptionModal() };
switch (inscription.mimeType) {
Expand Down Expand Up @@ -120,8 +119,8 @@ export function Inscription({ inscription }: InscriptionProps) {
]);

return (
<Box position="relative" {...bind} opacity={hasInscriptionBeenDiscarded(inscription) ? 0.5 : 1}>
{content}
<Box position="relative">
<Box opacity={hasInscriptionBeenDiscarded(inscription) ? 0.5 : 1}>{content}</Box>
<Box
bg="ink.background-primary"
position="absolute"
Expand All @@ -146,34 +145,34 @@ export function Inscription({ inscription }: InscriptionProps) {
</DropdownMenu.Item>
{hasInscriptionBeenDiscarded(inscription) ? (
<DropdownMenu.Item onClick={() => recoverInscription(inscription)}>
<Flag img={<TrashIcon variant="small" />}>Protect</Flag>
<Flag img={<LockIcon variant="small" />}>Protect</Flag>
</DropdownMenu.Item>
) : (
<DropdownMenu.Item onClick={() => discardInscription(inscription)}>
<Flag img={<TrashIcon variant="small" />}>Unprotect</Flag>
<Flag img={<UnlockIcon variant="small" />}>Unprotect</Flag>
</DropdownMenu.Item>
)}
</DropdownMenu.Content>
</DropdownMenu.Root>
</Box>
<HighSatValueUtxoWarning inscription={inscription} />
IsDiscarded: {String(hasInscriptionBeenDiscarded(inscription))}
<br />
is hovered: {String(isHovered)}
<br />
value: {inscription.value}
<br />
<button
onClick={() => {
// change api to use txid and output obj
hasInscriptionBeenDiscarded(inscription)
? recoverInscription(inscription)
: discardInscription(inscription);
}}
>
toggle safe to spend
</button>
<br />

{hasInscriptionBeenDiscarded(inscription) && (
<Box
p="space.02"
borderRadius="xs"
border="1px solid"
borderColor="ink.border-transparent"
background="ink.background-secondary"
position="absolute"
bottom="134px"
left="18px"
>
<Flag opacity={0.5} spacing="space.01" img={<TrashIcon variant="small" />}>
Unprotected
</Flag>
</Box>
)}
</Box>
);
}
1 change: 1 addition & 0 deletions src/app/pages/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function Home() {
});

const inscriptions = useInscribedSpendableUtxos();
// eslint-disable-next-line no-console
console.log(inscriptions);

const btcAddress = useCurrentAccountNativeSegwitAddressIndexZero();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function useBtcCryptoAssetBalanceNativeSegwit(address: string) {
const runesEnabled = useRunesEnabled();

const spendableInscriptionUtxos = useInscribedSpendableUtxos();
console.log('spendable utxos', spendableInscriptionUtxos);

Check failure on line 20 in src/app/query/bitcoin/balance/btc-balance-native-segwit.hooks.ts

View workflow job for this annotation

GitHub Actions / lint-eslint

Unexpected console statement

const availableUtxosQuery = useNativeSegwitUtxosByAddress({
address,
Expand Down
12 changes: 8 additions & 4 deletions src/app/ui/components/account/account.card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function AccountCard() {
return (
<Component
name="leather.btc"
balance="$1,000"
availableBalance="$1,000"
totalBalance="$1,000"
toggleSwitchAccount={() => null}
isLoadingBalance={false}
isFetchingBnsName={false}
Expand All @@ -52,7 +53,8 @@ export function AccountCardLoading() {
return (
<Component
name="leather.btc"
balance="$1,000"
availableBalance="$1,000"
totalBalance="$1,000"
toggleSwitchAccount={() => null}
isLoadingBalance
isFetchingBnsName={false}
Expand All @@ -71,7 +73,8 @@ export function AccountCardBnsNameLoading() {
return (
<Component
name="leather.btc"
balance="$1,000"
availableBalance="$1,000"
totalBalance="$1,000"
toggleSwitchAccount={() => null}
isLoadingBalance={false}
isFetchingBnsName
Expand All @@ -91,7 +94,8 @@ export function AccountCardPrivateBalance() {
return (
<Component
name="leather.btc"
balance="$1,000"
availableBalance="$1,000"
totalBalance="$1,000"
toggleSwitchAccount={() => null}
isLoadingBalance={false}
isFetchingBnsName={false}
Expand Down
6 changes: 3 additions & 3 deletions src/app/ui/components/account/account.card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export function AccountCard({
display="inline-block"
overflow="hidden"
>
{availableBalance}
{totalBalance}
</PrivateTextLayout>
</styled.h1>
<styled.h2 textStyle="label.02" color="ink.text-subdued" mt="space.01">
Full balance:
Available balance:
<styled.span ml="space.01">
<BasicTooltip
side="right"
Expand All @@ -115,7 +115,7 @@ export function AccountCard({
spacing="space.01"
img={<InfoCircleIcon display="inline" variant="small" />}
>
{totalBalance}
{availableBalance}
</Flag>
</BasicTooltip>
</styled.span>
Expand Down

0 comments on commit 57bb153

Please sign in to comment.