From 76ee21911182fdb9b1f06777972888bd19675d6c Mon Sep 17 00:00:00 2001 From: alter-eggo Date: Fri, 24 May 2024 09:57:33 +0400 Subject: [PATCH 1/3] fix: display runes balance, closes #5434 --- src/app/query/bitcoin/runes/runes-ticker-info.query.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/query/bitcoin/runes/runes-ticker-info.query.ts b/src/app/query/bitcoin/runes/runes-ticker-info.query.ts index 25096223f0b..068f6a094c9 100644 --- a/src/app/query/bitcoin/runes/runes-ticker-info.query.ts +++ b/src/app/query/bitcoin/runes/runes-ticker-info.query.ts @@ -1,10 +1,12 @@ import { useQueries } from '@tanstack/react-query'; -import { useConfigRunesEnabled } from '@app/query/common/remote-config/remote-config.query'; +import { isDefined } from '@shared/utils'; + import { useBitcoinClient } from '@app/store/common/api-clients.hooks'; import { useCurrentNetwork } from '@app/store/networks/networks.selectors'; import type { RuneBalance, RuneTickerInfo } from '../bitcoin-client'; +import { useRunesEnabled } from './runes.hooks'; import { createRuneCryptoAssetDetails } from './runes.utils'; const queryOptions = { staleTime: 5 * 60 * 1000 }; @@ -12,13 +14,12 @@ const queryOptions = { staleTime: 5 * 60 * 1000 }; export function useGetRunesTickerInfoQuery(runesBalances: RuneBalance[]) { const client = useBitcoinClient(); const network = useCurrentNetwork(); - const runesEnabled = useConfigRunesEnabled(); + const runesEnabled = useRunesEnabled(); return useQueries({ queries: runesBalances.map(runeBalance => { return { - enabled: - !runeBalance && (network.chain.bitcoin.bitcoinNetwork === 'testnet' || runesEnabled), + enabled: isDefined(runeBalance) && runesEnabled, queryKey: ['runes-ticker-info', runeBalance.rune_name], queryFn: () => client.bestinSlotApi.getRunesTickerInfo( From 613ab5525b0e5f316966b08990043236a08463ee Mon Sep 17 00:00:00 2001 From: Pete Watters <2938440+pete-watters@users.noreply.github.com> Date: Fri, 24 May 2024 06:18:55 +0100 Subject: [PATCH 2/3] fix: handle undefined memo type for SIP10, ref #5436 --- .../hooks/use-stacks-transaction-summary.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts b/src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts index 16fbd3c7af1..054472e0f3b 100644 --- a/src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts +++ b/src/app/features/stacks-transaction-request/hooks/use-stacks-transaction-summary.ts @@ -13,6 +13,7 @@ import BigNumber from 'bignumber.js'; import { CryptoCurrencies } from '@shared/models/currencies.model'; import { createMoney } from '@shared/models/money.model'; +import { isDefined } from '@shared/utils'; import { baseCurrencyAmountInQuote, @@ -72,13 +73,20 @@ export function useStacksTransactionSummary(token: CryptoCurrencies) { }; } + function getSip10MemoDisplayText(payload: ContractCallPayload): string { + const noMemoText = 'No memo'; + if (!isDefined(payload.functionArgs[3])) { + return noMemoText; + } + const isSome = payload.functionArgs[3].type === ClarityType.OptionalSome; + return isSome ? bytesToUtf8(serializeCV(payload.functionArgs[3])) : noMemoText; + } + function formSip10TxSummary(tx: StacksTransaction, symbol: string, decimals = 6) { const payload = tx.payload as ContractCallPayload; const fee = tx.auth.spendingCondition.fee; const txValue = Number((payload.functionArgs[0] as IntCV).value); - const isSome = payload.functionArgs[3].type === ClarityType.OptionalSome; - const memo = bytesToUtf8(serializeCV(payload.functionArgs[3])); - const memoDisplayText = isSome ? memo : 'No memo'; + const memoDisplayText = getSip10MemoDisplayText(payload); const sendingValue = formatMoney( convertToMoneyTypeWithDefaultOfZero(symbol, txValue, decimals) From 9a8d965ffdeec6462cf58c314a788e26e44fa043 Mon Sep 17 00:00:00 2001 From: Pete Watters <2938440+pete-watters@users.noreply.github.com> Date: Fri, 24 May 2024 11:05:56 +0100 Subject: [PATCH 3/3] fix: always set memo for SIP10, ref #5436 --- src/app/store/transactions/token-transfer.hooks.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/store/transactions/token-transfer.hooks.ts b/src/app/store/transactions/token-transfer.hooks.ts index c88cc12bcb1..68b9216c90d 100644 --- a/src/app/store/transactions/token-transfer.hooks.ts +++ b/src/app/store/transactions/token-transfer.hooks.ts @@ -119,9 +119,7 @@ export function useGenerateFtTokenTransferUnsignedTx(info: Sip10CryptoAssetInfo) standardPrincipalCVFromAddress(recipient), ]; - if (info.hasMemo) { - functionArgs.push(memo); - } + functionArgs.push(memo); const options = { txData: { @@ -149,7 +147,6 @@ export function useGenerateFtTokenTransferUnsignedTx(info: Sip10CryptoAssetInfo) [ account, info.decimals, - info.hasMemo, network, nextNonce?.nonce, contractName,