Skip to content

Commit

Permalink
fix(app): transaction details page crash
Browse files Browse the repository at this point in the history
  • Loading branch information
yudhomax committed Nov 11, 2024
1 parent b6ad69f commit 20e71c9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
6 changes: 3 additions & 3 deletions apps/app/src/components/Transactions/Execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ const Execution = (props: Props) => {
const receipt = parseReceipt
? parseReceipt(
txn.receipts.find(
(rpcReceipt) => rpcReceipt.receipt_id === receiptOutcome.id,
(rpcReceipt) => rpcReceipt?.receipt_id === receiptOutcome?.id,
),
receiptOutcome,
txn.transaction,
)
: '';
return mapping.set(receiptOutcome.id, {
return mapping.set(receiptOutcome?.id, {
...receipt,
outcome: parseOutcomeOld ? parseOutcomeOld(receiptOutcome) : '',
});
}, new Map());

const receipts = collectNestedReceiptWithOutcomeOld
? collectNestedReceiptWithOutcomeOld(
txn.transaction_outcome.outcome.receipt_ids[0],
txn?.transaction_outcome?.outcome?.receipt_ids[0],
receiptsMap,
)
: '';
Expand Down
6 changes: 3 additions & 3 deletions apps/app/src/components/Transactions/Receipt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const Receipt = (props: Props) => {

if (
receipts?.length === 0 ||
receipts[0]?.receipt_id !== receiptsOutcome[0]?.id
receipts?.[0]?.receipt_id !== receiptsOutcome?.[0]?.id
) {
receipts?.unshift({
predecessor_id: txn?.transaction?.signer_id,
receipt: actions,
receipt_id: receiptsOutcome[0]?.id,
receipt_id: receiptsOutcome?.[0]?.id ?? '',
receiver_id: txn?.transaction?.receiver_id,
});
}
Expand Down Expand Up @@ -78,7 +78,7 @@ const Receipt = (props: Props) => {
};
};

return collectReceipts(receiptsOutcome[0]?.id);
return collectReceipts(receiptsOutcome?.[0]?.id);
}

useEffect(() => {
Expand Down
8 changes: 4 additions & 4 deletions apps/app/src/components/Transactions/ReceiptSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const ReceiptSummary = (props: Props) => {

if (
receipts?.length === 0 ||
receipts[0]?.receipt_id !== receiptsOutcome[0]?.id
receipts?.[0]?.receipt_id !== receiptsOutcome?.[0]?.id
) {
receipts?.unshift({
predecessor_id: txn?.transaction?.signer_id,
receipt: actions,
receipt_id: receiptsOutcome[0]?.id,
receipt_id: receiptsOutcome?.[0]?.id,
receiver_id: txn?.transaction?.receiver_id,
});
}
Expand All @@ -56,7 +56,7 @@ const ReceiptSummary = (props: Props) => {
receiptsByIdMap?.set(receiptItem?.receipt_id, {
...receiptItem,
actions:
receiptItem?.receipt_id === receiptsOutcome[0]?.id
receiptItem?.receipt_id === receiptsOutcome?.[0]?.id
? actions
: receiptItem?.receipt?.Action?.actions &&
receiptItem?.receipt?.Action?.actions.map((receipt) =>
Expand All @@ -81,7 +81,7 @@ const ReceiptSummary = (props: Props) => {
};
};

return collectReceipts(receiptsOutcome[0]?.id);
return collectReceipts(receiptsOutcome?.[0]?.id);
}

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions apps/app/src/components/Transactions/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const Tree = (props: Props) => {

if (
receipts?.length === 0 ||
receipts[0]?.receipt_id !== receiptsOutcome[0]?.id
receipts?.[0]?.receipt_id !== receiptsOutcome?.[0]?.id
) {
receipts?.unshift({
predecessor_id: txn?.transaction?.signer_id,
receipt: actions,
receipt_id: receiptsOutcome[0]?.id,
receipt_id: receiptsOutcome?.[0]?.id,
receiver_id: txn?.transaction?.receiver_id,
});
}
Expand Down Expand Up @@ -74,7 +74,7 @@ const Tree = (props: Props) => {
};
};

return collectReceipts(receiptsOutcome[0]?.id);
return collectReceipts(receiptsOutcome?.[0]?.id);
}

useEffect(() => {
Expand Down
12 changes: 4 additions & 8 deletions apps/app/src/hooks/useHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ const useHash = (): [string | undefined, (newHash: string) => void] => {

const setHash = useCallback(
(newHash: string) => {
push(
{
pathname: new URL(asPath, 'http://localhost/').pathname,
hash: newHash,
},
undefined,
{ shallow: true },
);
if (asPath) {
const pathname = asPath.split('#')[0];
push({ pathname, hash: newHash }, undefined, { shallow: true });
}
},
[asPath, push],
);
Expand Down

0 comments on commit 20e71c9

Please sign in to comment.