Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inscriptions settings btn and available balance #6050

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"@leather.io/constants": "0.13.5",
"@leather.io/crypto": "1.6.14",
"@leather.io/models": "0.24.0",
"@leather.io/query": "2.26.9",
"@leather.io/query": "2.26.10",
"@leather.io/stacks": "1.4.0",
"@leather.io/tokens": "0.12.1",
"@leather.io/ui": "1.44.4",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 18 additions & 7 deletions src/app/common/hooks/balance/use-balances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export function useBalances({ btcAddress, stxAddress }: UseBalanceArgs) {
isPending: isPendingStxBalance,
} = filteredBalanceQuery;

const stxBalance = balance ? balance.totalBalance : createMoney(0, 'STX');
const totalStxBalance = balance ? balance.totalBalance : createMoney(0, 'STX');
const availableUnlockedStxBalance = balance
? balance.availableUnlockedBalance
: createMoney(0, 'STX');

// get btc balance
const {
Expand All @@ -47,7 +50,12 @@ export function useBalances({ btcAddress, stxAddress }: UseBalanceArgs) {

return useMemo(() => {
// calculate total balance
const stxUsdAmount = baseCurrencyAmountInQuote(stxBalance, stxMarketData);
const totalStxUsdAmount = baseCurrencyAmountInQuote(totalStxBalance, stxMarketData);
// calculate available unlocked balance
const availableUnlockedStxUsdAmount = baseCurrencyAmountInQuote(
availableUnlockedStxBalance,
stxMarketData
);

const availableBtcUsdAmount = baseCurrencyAmountInQuote(
btcBalance.availableBalance,
Expand All @@ -57,13 +65,15 @@ export function useBalances({ btcAddress, stxAddress }: UseBalanceArgs) {
const totalBtcUsdAmount = baseCurrencyAmountInQuote(btcBalance.totalBalance, btcMarketData);

const totalBalance = {
...stxUsdAmount,
amount: stxUsdAmount.amount.plus(totalBtcUsdAmount.amount).plus(sip10BalanceUsd.amount),
...totalStxUsdAmount,
amount: totalStxUsdAmount.amount.plus(totalBtcUsdAmount.amount).plus(sip10BalanceUsd.amount),
};

const availableBalance = {
...stxUsdAmount,
amount: stxUsdAmount.amount.plus(availableBtcUsdAmount.amount).plus(sip10BalanceUsd.amount),
...availableUnlockedStxUsdAmount,
amount: availableUnlockedStxUsdAmount.amount
.plus(availableBtcUsdAmount.amount)
.plus(sip10BalanceUsd.amount),
};

return {
Expand All @@ -86,8 +96,9 @@ export function useBalances({ btcAddress, stxAddress }: UseBalanceArgs) {
isLoadingAdditionalDataStxBalance || isLoadingAdditionalDataBtcBalance,
};
}, [
stxBalance,
totalStxBalance,
stxMarketData,
availableUnlockedStxBalance,
btcBalance.availableBalance,
btcBalance.totalBalance,
btcMarketData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export function Inscription({ inscription }: InscriptionProps) {
<Box opacity={hasInscriptionBeenDiscarded(inscription) ? 0.5 : 1}>{content}</Box>
{isHovered && (
<Box
border="1px solid"
borderColor="ink.text-primary"
borderRadius="2px"
bg="ink.background-primary"
position="absolute"
right="space.03"
Expand All @@ -136,9 +139,6 @@ export function Inscription({ inscription }: InscriptionProps) {
_focus={{ outline: 'focus' }}
_hover={{ bg: 'ink.component-background-hover' }}
bg="ink.background-primary"
border="1px solid"
borderColor="ink.text-primary"
borderRadius="2px"
transform="rotate(90deg)"
color="ink.action-primary-default"
icon={<EllipsisVIcon />}
Expand Down
37 changes: 8 additions & 29 deletions src/app/pages/home/components/account-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useLocation, useNavigate } from 'react-router-dom';

import { ChainID } from '@stacks/transactions';
import { HomePageSelectors } from '@tests/selectors/home.selectors';
import { Box, Flex } from 'leather-styles/jsx';

import { whenStacksChainId } from '@leather.io/stacks';
import { ArrowsRepeatLeftRightIcon, CreditCardIcon, IconButton, InboxIcon } from '@leather.io/ui';

import { RouteUrls } from '@shared/route-urls';
Expand All @@ -15,7 +13,7 @@ import {
} from '@app/query/common/remote-config/remote-config.query';
import { useCurrentAccountNativeSegwitIndexZeroSignerNullable } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { useCurrentNetwork } from '@app/store/networks/networks.selectors';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';
import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip';

import { SendButton } from './send-button';
Expand All @@ -28,9 +26,10 @@ export function AccountActions() {
const stacksAccount = useCurrentStacksAccount();
const currentBtcSigner = useCurrentAccountNativeSegwitIndexZeroSignerNullable();
const btcAccount = currentBtcSigner?.address;
const currentNetwork = useCurrentNetwork();
const { isTestnet } = useCurrentNetworkState();

const swapsEnabled = useConfigSwapsEnabled();
const swapsBtnDisabled = !swapsEnabled || !stacksAccount;
const swapsBtnDisabled = !swapsEnabled || !stacksAccount || isTestnet;

const receivePath = isBitcoinEnabled
? RouteUrls.Receive
Expand All @@ -54,37 +53,17 @@ export function AccountActions() {
onClick={() => navigate(RouteUrls.FundChooseCurrency)}
/>
)}
{whenStacksChainId(currentNetwork.chain.stacks.chainId)({
[ChainID.Mainnet]: (
<BasicTooltip
label={swapsEnabled ? '' : <SwapsDisabledTooltipLabel />}
side="left"
asChild
>
<Box display="flex">
<IconButton
data-testid={HomePageSelectors.SwapBtn}
disabled={swapsBtnDisabled}
icon={<ArrowsRepeatLeftRightIcon />}
label="Swap"
onClick={() =>
navigate(RouteUrls.Swap.replace(':base', 'STX').replace(':quote', ''))
}
/>
</Box>
</BasicTooltip>
),
// Temporary for sBTC testing
[ChainID.Testnet]: (
<BasicTooltip label={swapsEnabled ? '' : <SwapsDisabledTooltipLabel />} side="left" asChild>
<Box display="flex">
<IconButton
data-testid={HomePageSelectors.SwapBtn}
disabled={swapsBtnDisabled}
icon={<ArrowsRepeatLeftRightIcon />}
label="Swap"
onClick={() => navigate(RouteUrls.Swap.replace(':base', 'STX').replace(':quote', ''))}
/>
),
})}
</Box>
</BasicTooltip>
</Flex>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function StacksCommonSendForm({
amountField,
selectedAssetField,
fees,

availableTokenBalance,
}: StacksCommonSendFormProps) {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/components/account/account.card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { PrivateTextLayout } from '@app/components/privacy/private-text.layout';
import { BasicTooltip } from '../tooltip/basic-tooltip';

const availableBalanceTooltipLabel =
'Total balance minus outbound transfers, protected collectibles and uneconomical UTXOs.';
'Total balance minus locked amounts, outbound transfers, protected collectibles and uneconomical UTXOs.';

interface AccountCardProps {
name: string;
Expand Down
Loading