From 90618ea03109ff3d700b8d1d82191a74831379d1 Mon Sep 17 00:00:00 2001 From: Michael Chappell <7581002+mchappell@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:10:41 +0100 Subject: [PATCH] fixup! fix: use try/catch with unknown address --- src/ui/app/components/transaction.jsx | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ui/app/components/transaction.jsx b/src/ui/app/components/transaction.jsx index 14d78062..cc89b5e6 100644 --- a/src/ui/app/components/transaction.jsx +++ b/src/ui/app/components/transaction.jsx @@ -498,10 +498,36 @@ const getAddressCredentials = (address) => { try { const cmlAddress = Loader.Cardano.Address.from_bech32(address); return [ - cmlAddress.payment_cred()?.to_cbor_hex(), - cmlAddress.staking_cred()?.to_cbor_hex(), + cmlAddress.payment_cred()?.to_cbor_hex() || null, + cmlAddress.staking_cred()?.to_cbor_hex() || null, ]; } catch (error) { + try { + // try casting as byron address + const cmlAddress = new Loader.Cardano.ByronAddress(address); + return [ + cmlAddress.to_address()?.payment_cred()?.to_cbor_hex() || null, + cmlAddress.to_address()?.staking_cred()?.to_cbor_hex() || null, + ]; + } catch { + try { + // try casting as enterprise address + const cmlAddress = new Loader.Cardano.EnterpriseAddress(address); + return [ + cmlAddress.to_address()?.payment_cred()?.to_cbor_hex() || null, + cmlAddress.to_address()?.staking_cred()?.to_cbor_hex() || null, + ]; + } catch { + try { + // try casting as enterprise address + const cmlAddress = new Loader.Cardano.PointerAddress(address); + return [ + cmlAddress.to_address()?.payment_cred()?.to_cbor_hex() || null, + cmlAddress.to_address()?.staking_cred()?.to_cbor_hex() || null, + ]; + } catch {} + } + } console.error(error); return [null, null]; }