From fd060e2dbc8f6692ecb633984f90139895946bf2 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Wed, 18 Dec 2024 15:20:59 +0100 Subject: [PATCH] fix: review screen errors --- .../use-legacy-auth-bitcoin-addresses.ts | 16 ++++++++-------- .../hooks/use-stacks-transaction-summary.ts | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/app/common/authentication/use-legacy-auth-bitcoin-addresses.ts b/src/app/common/authentication/use-legacy-auth-bitcoin-addresses.ts index 84b2a314fd7..17e2e8b5181 100644 --- a/src/app/common/authentication/use-legacy-auth-bitcoin-addresses.ts +++ b/src/app/common/authentication/use-legacy-auth-bitcoin-addresses.ts @@ -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: { 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 bc804969942..e3d4adf2ea6 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 @@ -1,5 +1,6 @@ import { bytesToUtf8 } from '@stacks/common'; import { + type Address, ClarityType, ContractCallPayload, IntCV, @@ -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'); @@ -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))),