From 6c1894cd87fedfcfbb98271d2315f480cabc09fc Mon Sep 17 00:00:00 2001 From: Michael Chappell <7581002+mchappell@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:48:21 +0100 Subject: [PATCH] fix: use try/catch with unknown address --- src/ui/app/components/transaction.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ui/app/components/transaction.jsx b/src/ui/app/components/transaction.jsx index 3fc4c127..14d78062 100644 --- a/src/ui/app/components/transaction.jsx +++ b/src/ui/app/components/transaction.jsx @@ -495,9 +495,17 @@ const getTimestamp = (date) => { }; const getAddressCredentials = (address) => { - const cmlAddress = Loader.Cardano.Address.from_bech32(address); - return [cmlAddress.payment_cred()?.to_cbor_hex(), cmlAddress.staking_cred()?.to_cbor_hex()]; -} + try { + const cmlAddress = Loader.Cardano.Address.from_bech32(address); + return [ + cmlAddress.payment_cred()?.to_cbor_hex(), + cmlAddress.staking_cred()?.to_cbor_hex(), + ]; + } catch (error) { + console.error(error); + return [null, null]; + } +}; const matchesAnyCredential = (address, [ownPaymentCred, ownStakingCred]) => { const [otherPaymentCred, otherStakingCred] = getAddressCredentials(address); @@ -516,7 +524,8 @@ const calculateAmount = (currentAddr, uTxOList, validContract = true) => { let outputs = compileOutputs( uTxOList.outputs.filter( (output) => - matchesAnyCredential(output.address, ownCredentials) && !(output.collateral && validContract) + matchesAnyCredential(output.address, ownCredentials) && + !(output.collateral && validContract) ) ); let amounts = [];