Skip to content

Commit

Permalink
add defensive checks for not being able to index balance by asset code
Browse files Browse the repository at this point in the history
  • Loading branch information
piyalbasu committed Oct 30, 2024
1 parent 4a0157c commit 9de6f42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions extension/src/popup/components/account/AssetDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const AssetDetail = ({
transactionSubmissionSelector,
);
const isSuspicious = isAssetSuspicious(
balances.balances?.[selectedAsset].blockaidData,
balances.balances?.[selectedAsset]?.blockaidData,
);

const balance = getRawBalance(accountBalances, selectedAsset)!;
Expand Down Expand Up @@ -232,7 +232,7 @@ export const AssetDetail = ({
{isSuspicious && (
<BlockaidAssetWarning
blockaidData={
balances.balances?.[selectedAsset].blockaidData ||
balances.balances?.[selectedAsset]?.blockaidData ||
defaultBlockaidScanAssetResult
}
/>
Expand Down
10 changes: 5 additions & 5 deletions extension/src/popup/components/sendPayment/SendAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export const SendAmount = ({
}
// check for scam asset
const isSourceAssetScam = isAssetSuspicious(
accountBalances.balances?.[asset].blockaidData,
accountBalances.balances?.[asset]?.blockaidData,
);
if (isSourceAssetScam) {
setShowBlockedDomainWarning(true);
Expand All @@ -228,7 +228,7 @@ export const SendAmount = ({
domain: assetDomains[values.asset],
image: assetIcons[values.asset],
blockaidData:
accountBalances.balances?.[asset].blockaidData ||
accountBalances.balances?.[asset]?.blockaidData ||
defaultBlockaidScanAssetResult,
});
} else if (isDestAssetScam) {
Expand All @@ -239,7 +239,7 @@ export const SendAmount = ({
domain: assetDomains[values.destinationAsset],
image: assetIcons[values.destinationAsset],
blockaidData:
accountBalances.balances?.[destinationAsset].blockaidData ||
accountBalances.balances?.[destinationAsset]?.blockaidData ||
defaultBlockaidScanAssetResult,
});
} else {
Expand Down Expand Up @@ -588,7 +588,7 @@ export const SendAmount = ({
assetCode={parsedSourceAsset.code}
issuerKey={parsedSourceAsset.issuer}
isSuspicious={isAssetSuspicious(
accountBalances.balances?.[asset].blockaidData,
accountBalances.balances?.[asset]?.blockaidData,
)}
/>
)}
Expand All @@ -601,7 +601,7 @@ export const SendAmount = ({
balance={formik.values.amount}
icon=""
isSuspicious={isAssetSuspicious(
accountBalances.balances?.[asset].blockaidData,
accountBalances.balances?.[asset]?.blockaidData,
)}
/>
<PathPayAssetSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export const TransactionDetails = ({
);

const isSourceAssetSuspicious = isAssetSuspicious(
accountBalances.balances?.[asset].blockaidData,
accountBalances.balances?.[asset]?.blockaidData,
);

const isSubmitDisabled = isMemoRequired;
Expand Down Expand Up @@ -709,7 +709,7 @@ export const TransactionDetails = ({
isMemoRequired={isMemoRequired}
blockaidData={
(isSourceAssetSuspicious
? accountBalances.balances?.[asset].blockaidData
? accountBalances.balances?.[asset]?.blockaidData
: accountBalances.balances?.[destinationAsset]
?.blockaidData) || defaultBlockaidScanAssetResult
}
Expand Down

0 comments on commit 9de6f42

Please sign in to comment.