From 0c0877b9f744e504b5df8b24a44f26ba01093755 Mon Sep 17 00:00:00 2001 From: Anastasios Date: Fri, 27 Dec 2024 18:56:47 +0400 Subject: [PATCH 1/4] fix: inscription settings btn styles --- .../collectibles/components/bitcoin/inscription.tsx | 6 +++--- src/app/pages/home/components/account-actions.tsx | 5 ++++- src/app/ui/components/account/account.card.tsx | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/features/collectibles/components/bitcoin/inscription.tsx b/src/app/features/collectibles/components/bitcoin/inscription.tsx index 7f9ce6752b..eee68eaad2 100644 --- a/src/app/features/collectibles/components/bitcoin/inscription.tsx +++ b/src/app/features/collectibles/components/bitcoin/inscription.tsx @@ -124,6 +124,9 @@ export function Inscription({ inscription }: InscriptionProps) { {content} {isHovered && ( } diff --git a/src/app/pages/home/components/account-actions.tsx b/src/app/pages/home/components/account-actions.tsx index 8a83182c27..3148fdd321 100644 --- a/src/app/pages/home/components/account-actions.tsx +++ b/src/app/pages/home/components/account-actions.tsx @@ -15,6 +15,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 { useCurrentNetworkState } from '@app/store/networks/networks.hooks'; import { useCurrentNetwork } from '@app/store/networks/networks.selectors'; import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; @@ -29,8 +30,10 @@ export function AccountActions() { 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 diff --git a/src/app/ui/components/account/account.card.tsx b/src/app/ui/components/account/account.card.tsx index 15f915e663..79c452a812 100644 --- a/src/app/ui/components/account/account.card.tsx +++ b/src/app/ui/components/account/account.card.tsx @@ -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; From 7d284864cf1644bad5c56373b40b5afefd0c9d6d Mon Sep 17 00:00:00 2001 From: Anastasios Date: Fri, 27 Dec 2024 19:00:31 +0400 Subject: [PATCH 2/4] chore: update query package --- package.json | 2 +- pnpm-lock.yaml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 61aa1ea67e..116e6aa53e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86a7d77549..3f4df31224 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ importers: specifier: 0.24.0 version: 0.24.0 '@leather.io/query': - specifier: 2.26.9 - version: 2.26.9(encoding@0.1.13)(react@18.3.1) + specifier: 2.26.10 + version: 2.26.10(encoding@0.1.13)(react@18.3.1) '@leather.io/stacks': specifier: 1.4.0 version: 1.4.0(encoding@0.1.13) @@ -3284,8 +3284,8 @@ packages: '@leather.io/bitcoin@0.17.0': resolution: {integrity: sha512-Nc4Bl2HWmxWvgIXbpa6Gs8EpqR1UJHDzXPu+R+2TIyOsjxFoGXoIQwLohxySnQa4i0UodrCXBrqDOqOTHtwbMQ==} - '@leather.io/bitcoin@0.19.8': - resolution: {integrity: sha512-gqTD8Mtp8cYPcvQd0DnzFNz/uXbghpadPvB8rtB467g4fbjswW/52lOKzazrzNrl+CmQXuCKep4NrTBgTBRNpg==} + '@leather.io/bitcoin@0.19.9': + resolution: {integrity: sha512-gCc4AcOtv0gAgdMATBlHBBQU0k+Ut3uY9mkhNRQV8ISl2f3sOhLbjN2DAbddpsL77W2+OYFGCDeBVdNjElXsyw==} '@leather.io/constants@0.13.5': resolution: {integrity: sha512-FOh/F/g8WepB8HfoTXsMB/BYcm/F6INPEpyEZc3ljzaN0mLwVLO1kwgMTFU9Pq7tQlITvyWiyGHcB7OYovLoUQ==} @@ -3326,8 +3326,8 @@ packages: '@leather.io/prettier-config@0.6.0': resolution: {integrity: sha512-QBKtLanfxFxXBlR58U/j8a6lBI0xzJzqqi36fXpGVp+9mJoEf6Ro6xrtFrixjW6seY6EOva4OApVnnPBsvOC/w==} - '@leather.io/query@2.26.9': - resolution: {integrity: sha512-ijmVE6RoiU+kZY5ApvwkZ5IAXWGZFl18AG2/YBveZNc5ExKjlNnunfqp1UFxE62REwkp8sGIWSsnZpysNosAHw==} + '@leather.io/query@2.26.10': + resolution: {integrity: sha512-GhOHwDQVkqP5IgM6qzItOrSssN29X6WDQ9YFsvls7a2dA00NB0emSZ+YGM3KNsn6ppXPJJNzwpIhtmGWX/yKlA==} peerDependencies: react: '*' @@ -19127,7 +19127,7 @@ snapshots: transitivePeerDependencies: - encoding - '@leather.io/bitcoin@0.19.8(encoding@0.1.13)': + '@leather.io/bitcoin@0.19.9(encoding@0.1.13)': dependencies: '@bitcoinerlab/secp256k1': 1.0.2 '@leather.io/constants': 0.15.2 @@ -19233,11 +19233,11 @@ snapshots: - '@vue/compiler-sfc' - supports-color - '@leather.io/query@2.26.9(encoding@0.1.13)(react@18.3.1)': + '@leather.io/query@2.26.10(encoding@0.1.13)(react@18.3.1)': dependencies: '@fungible-systems/zone-file': 2.0.0 '@hirosystems/token-metadata-api-client': 1.2.0(encoding@0.1.13) - '@leather.io/bitcoin': 0.19.8(encoding@0.1.13) + '@leather.io/bitcoin': 0.19.9(encoding@0.1.13) '@leather.io/constants': 0.15.2 '@leather.io/models': 0.24.2 '@leather.io/rpc': 2.4.1(encoding@0.1.13) From 7f838c2f8d5594a255c6c25596b3f5b770bf14e7 Mon Sep 17 00:00:00 2001 From: Fara Woolf Date: Fri, 27 Dec 2024 12:07:08 -0500 Subject: [PATCH 3/4] refactor: stx available balance --- src/app/common/hooks/balance/use-balances.tsx | 25 +++++++++++---- .../pages/home/components/account-actions.tsx | 32 +++---------------- .../form/stacks/stacks-common-send-form.tsx | 1 - .../ui/components/account/account.card.tsx | 2 +- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/app/common/hooks/balance/use-balances.tsx b/src/app/common/hooks/balance/use-balances.tsx index f92a1bd7b1..60272a2207 100644 --- a/src/app/common/hooks/balance/use-balances.tsx +++ b/src/app/common/hooks/balance/use-balances.tsx @@ -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 { @@ -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, @@ -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 { @@ -86,8 +96,9 @@ export function useBalances({ btcAddress, stxAddress }: UseBalanceArgs) { isLoadingAdditionalDataStxBalance || isLoadingAdditionalDataBtcBalance, }; }, [ - stxBalance, + totalStxBalance, stxMarketData, + availableUnlockedStxBalance, btcBalance.availableBalance, btcBalance.totalBalance, btcMarketData, diff --git a/src/app/pages/home/components/account-actions.tsx b/src/app/pages/home/components/account-actions.tsx index 3148fdd321..e58bfd57b6 100644 --- a/src/app/pages/home/components/account-actions.tsx +++ b/src/app/pages/home/components/account-actions.tsx @@ -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'; @@ -16,7 +14,6 @@ import { import { useCurrentAccountNativeSegwitIndexZeroSignerNullable } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks'; import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; import { useCurrentNetworkState } from '@app/store/networks/networks.hooks'; -import { useCurrentNetwork } from '@app/store/networks/networks.selectors'; import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; import { SendButton } from './send-button'; @@ -29,7 +26,6 @@ export function AccountActions() { const stacksAccount = useCurrentStacksAccount(); const currentBtcSigner = useCurrentAccountNativeSegwitIndexZeroSignerNullable(); const btcAccount = currentBtcSigner?.address; - const currentNetwork = useCurrentNetwork(); const { isTestnet } = useCurrentNetworkState(); const swapsEnabled = useConfigSwapsEnabled(); @@ -57,28 +53,8 @@ export function AccountActions() { onClick={() => navigate(RouteUrls.FundChooseCurrency)} /> )} - {whenStacksChainId(currentNetwork.chain.stacks.chainId)({ - [ChainID.Mainnet]: ( - } - side="left" - asChild - > - - } - label="Swap" - onClick={() => - navigate(RouteUrls.Swap.replace(':base', 'STX').replace(':quote', '')) - } - /> - - - ), - // Temporary for sBTC testing - [ChainID.Testnet]: ( + } side="left" asChild> + navigate(RouteUrls.Swap.replace(':base', 'STX').replace(':quote', ''))} /> - ), - })} + + ); } diff --git a/src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx b/src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx index e321858fdb..47d102f3e8 100644 --- a/src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx +++ b/src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx @@ -44,7 +44,6 @@ export function StacksCommonSendForm({ amountField, selectedAssetField, fees, - availableTokenBalance, }: StacksCommonSendFormProps) { const navigate = useNavigate(); diff --git a/src/app/ui/components/account/account.card.tsx b/src/app/ui/components/account/account.card.tsx index 79c452a812..a64d8dbd36 100644 --- a/src/app/ui/components/account/account.card.tsx +++ b/src/app/ui/components/account/account.card.tsx @@ -21,7 +21,7 @@ import { PrivateTextLayout } from '@app/components/privacy/private-text.layout'; import { BasicTooltip } from '../tooltip/basic-tooltip'; const availableBalanceTooltipLabel = - 'Total balance minus locked amounts, outbound transfers, protected collectibles and uneconomical UTXOs'; + 'Total balance minus locked amounts, outbound transfers, protected collectibles and uneconomical UTXOs.'; interface AccountCardProps { name: string; From 3a1b17e8169fd13646403b609ca02d272502005d Mon Sep 17 00:00:00 2001 From: Fara Woolf Date: Mon, 6 Jan 2025 11:58:36 -0500 Subject: [PATCH 4/4] fix: btc balance --- .../query/bitcoin/balance/btc-balance-native-segwit.hooks.ts | 2 +- src/app/ui/components/account/account.card.tsx | 2 +- tests/page-object-models/onboarding.page.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/query/bitcoin/balance/btc-balance-native-segwit.hooks.ts b/src/app/query/bitcoin/balance/btc-balance-native-segwit.hooks.ts index 805382a0e5..d7a34e045d 100644 --- a/src/app/query/bitcoin/balance/btc-balance-native-segwit.hooks.ts +++ b/src/app/query/bitcoin/balance/btc-balance-native-segwit.hooks.ts @@ -44,7 +44,7 @@ export function useBtcCryptoAssetBalanceNativeSegwit(address: string) { ...defaultZeroValues, totalBalance: createMoney(sumNumbers(totalUtxosQuery.data.map(utxo => utxo.value)), 'BTC'), availableBalance: createMoney( - // Here we add back in the utxos that are spending beacuse they've been discarded + // Here we add back in the utxos that are spending because they've been discarded sumNumbers( [ ...filterOutNativeSegwitInscriptions(totalUtxosQuery.data), diff --git a/src/app/ui/components/account/account.card.tsx b/src/app/ui/components/account/account.card.tsx index a64d8dbd36..79c452a812 100644 --- a/src/app/ui/components/account/account.card.tsx +++ b/src/app/ui/components/account/account.card.tsx @@ -21,7 +21,7 @@ import { PrivateTextLayout } from '@app/components/privacy/private-text.layout'; import { BasicTooltip } from '../tooltip/basic-tooltip'; const availableBalanceTooltipLabel = - 'Total balance minus locked amounts, outbound transfers, protected collectibles and uneconomical UTXOs.'; + 'Total balance minus locked amounts, outbound transfers, protected collectibles and uneconomical UTXOs'; interface AccountCardProps { name: string; diff --git a/tests/page-object-models/onboarding.page.ts b/tests/page-object-models/onboarding.page.ts index 08c694a233..ab2d549b32 100644 --- a/tests/page-object-models/onboarding.page.ts +++ b/tests/page-object-models/onboarding.page.ts @@ -12,7 +12,7 @@ const TEST_ACCOUNT_SECRET_KEY = process.env.TEST_ACCOUNT_SECRET_KEY ?? ''; // If default wallet state changes, we'll need to update this export const testSoftwareAccountDefaultWalletState = { - chains: { stx: { default: { highestAccountIndex: 1, currentAccountIndex: 0 } } }, + chains: { stx: { default: { highestAccountIndex: 2, currentAccountIndex: 0 } } }, appPermissions: { entities: {}, ids: [],