Skip to content

Commit

Permalink
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 fc1bfa9 commit 6c1894c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ui/app/components/transaction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = [];
Expand Down

0 comments on commit 6c1894c

Please sign in to comment.