Skip to content

Commit

Permalink
fix: review screen errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie authored and camerow committed Dec 18, 2024
1 parent a1c6efd commit fd060e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ export function useGetLegacyAuthBitcoinAddresses() {
return {
btcAddress: {
p2tr: {
mainnet: taprootAccount?.mainnet?.payment.address,
testnet: taprootAccount?.testnet?.payment.address,
regtest: taprootAccount?.regtest?.payment.address,
signet: taprootAccount?.signet?.payment.address,
mainnet: taprootAccount?.mainnet?.payment?.address,
testnet: taprootAccount?.testnet?.payment?.address,
regtest: taprootAccount?.regtest?.payment?.address,
signet: taprootAccount?.signet?.payment?.address,
},
p2wpkh: {
mainnet: nativeSegwitAccount?.mainnet?.payment.address,
testnet: nativeSegwitAccount?.testnet?.payment.address,
regtest: nativeSegwitAccount?.regtest?.payment.address,
signet: nativeSegwitAccount?.signet?.payment.address,
mainnet: nativeSegwitAccount?.mainnet?.payment?.address,
testnet: nativeSegwitAccount?.testnet?.payment?.address,
regtest: nativeSegwitAccount?.regtest?.payment?.address,
signet: nativeSegwitAccount?.signet?.payment?.address,
},
},
btcPublicKey: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bytesToUtf8 } from '@stacks/common';
import {
type Address,
ClarityType,
ContractCallPayload,
IntCV,
Expand All @@ -25,6 +26,14 @@ import {

import { removeTrailingNullCharacters } from '@app/common/utils';

function safeAddressToString(address: Address) {
try {
return addressToString(address);
} catch (error) {
return '';
}
}

export function useStacksTransactionSummary(token: CryptoCurrency) {
// TODO: unsafe type assumption
const tokenMarketData = useCryptoCurrencyMarketDataMeanAverage(token as 'BTC' | 'STX');
Expand Down Expand Up @@ -54,9 +63,11 @@ export function useStacksTransactionSummary(token: CryptoCurrency) {
const memoDisplayText = removeTrailingNullCharacters(memoContent) || 'No memo';

return {
recipient: addressToString(payload.recipient.address),
recipient: safeAddressToString(payload?.recipient?.address),
fee: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(fee))),
totalSpend: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(txValue + fee))),
totalSpend: formatMoney(
convertToMoneyTypeWithDefaultOfZero('STX', Number(txValue) + Number(fee))
),
symbol: 'STX',
txValue: microStxToStx(Number(txValue)).toString(),
sendingValue: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(txValue))),
Expand Down

0 comments on commit fd060e2

Please sign in to comment.