Skip to content

Commit

Permalink
fixup! fix: use try/catch with unknown address
Browse files Browse the repository at this point in the history
  • Loading branch information
mchappell committed Oct 25, 2024
1 parent 6c1894c commit 90618ea
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/ui/app/components/transaction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 90618ea

Please sign in to comment.