Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Fix Engine UI crash when chain is undefined | DASH-42 (#2654)
Browse files Browse the repository at this point in the history
<!-- start pr-codex -->

## PR-Codex overview
This PR ensures optional chaining is used to access properties in various components, preventing errors when properties are undefined.

### Detailed summary
- Added optional chaining to access `chain` properties in multiple components
- Ensured safe access to `chain.explorers` and `chain.icon` properties

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Jun 13, 2024
1 parent 9601678 commit bf7d1da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const RemoveModal = ({
<FormControl>
<FormLabel>Chain</FormLabel>
<Flex align="center" gap={2}>
<ChainIcon size={12} ipfsSrc={chain.icon?.url} />
<ChainIcon size={12} ipfsSrc={chain?.icon?.url} />
<Text>{chain.name}</Text>
</Flex>
</FormControl>
Expand Down
2 changes: 1 addition & 1 deletion src/components/engine/overview/backend-wallets-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const BackendWalletBalanceCell: React.FC<BackendWalletBalanceCellProps> = ({
</Text>
);

const explorer = chain.explorers?.[0];
const explorer = chain?.explorers?.[0];
if (!explorer) {
return balanceComponent;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/engine/relayer/relayers-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const RelayersTable: React.FC<RelayersTableProps> = ({
const chain = chainIdToChainRecord[parseInt(cell.getValue())];
return (
<Flex align="center" gap={2}>
<ChainIcon size={12} ipfsSrc={chain.icon?.url} />
<ChainIcon size={12} ipfsSrc={chain?.icon?.url} />
<Text>{chain.name}</Text>
</Flex>
);
Expand All @@ -83,7 +83,7 @@ export const RelayersTable: React.FC<RelayersTableProps> = ({
const { chainId, backendWalletAddress } = cell.row.original;
const chain = chainIdToChainRecord[parseInt(chainId)];

const explorer = chain.explorers?.[0];
const explorer = chain?.explorers?.[0];
if (!explorer) {
return backendWalletAddress;
}
Expand Down

0 comments on commit bf7d1da

Please sign in to comment.