diff --git a/src/app/(sidebar)/xdr/view/page.tsx b/src/app/(sidebar)/xdr/view/page.tsx index eb0ec768..c74eabcb 100644 --- a/src/app/(sidebar)/xdr/view/page.tsx +++ b/src/app/(sidebar)/xdr/view/page.tsx @@ -71,7 +71,7 @@ export default function ViewXdr() { } catch (e) { return { jsonString: "", - error: `Unable to decode input as ${xdr.type}: ${e}`, + error: `Unable to decode input as ${xdr.type}: ${e}. Select another XDR type.`, }; } }; diff --git a/src/components/TransactionHashReadOnlyField.tsx b/src/components/TransactionHashReadOnlyField.tsx index f0a70bf1..4293ff24 100644 --- a/src/components/TransactionHashReadOnlyField.tsx +++ b/src/components/TransactionHashReadOnlyField.tsx @@ -12,12 +12,18 @@ export const TransactionHashReadOnlyField = ({ return null; } + const hashValue = transactionHashFromXdr(xdr, networkPassphrase); + + if (!hashValue) { + return null; + } + return ( diff --git a/src/helpers/transactionHashFromXdr.ts b/src/helpers/transactionHashFromXdr.ts index 632601be..c56f9b6c 100644 --- a/src/helpers/transactionHashFromXdr.ts +++ b/src/helpers/transactionHashFromXdr.ts @@ -3,4 +3,15 @@ import { TransactionBuilder } from "@stellar/stellar-sdk"; export const transactionHashFromXdr = ( xdr: string, networkPassphrase: string, -) => TransactionBuilder.fromXDR(xdr, networkPassphrase).hash().toString("hex"); +) => { + try { + // Code to read XDR data + return TransactionBuilder?.fromXDR(xdr, networkPassphrase) + .hash() + .toString("hex"); + } catch (e) { + // @TODO Do nothing for now + // add amplitude error tracking + return; + } +};