Skip to content

Commit

Permalink
fixes bad check for identifying contract IDs in remove workflow (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristidesstaffieri authored Feb 1, 2024
1 parent 7e6d7bf commit 6521fa9
Showing 1 changed file with 47 additions and 53 deletions.
100 changes: 47 additions & 53 deletions extension/src/popup/components/manageAssets/ManageAssetRows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import "./styles.scss";
import { NETWORKS } from "@shared/constants/stellar";
import { getManageAssetXDR } from "popup/helpers/getManageAssetXDR";
import { checkForSuspiciousAsset } from "popup/helpers/checkForSuspiciousAsset";
import { isContractId } from "popup/helpers/soroban";

export type ManageAssetCurrency = StellarToml.Api.Currency & {
domain: string;
Expand Down Expand Up @@ -281,61 +282,54 @@ export const ManageAssetRows = ({
<div className="ManageAssetRows__scrollbar">
{header}
<div className="ManageAssetRows__content">
{assetRows.map(
({
code = "",
domain,
image = "",
issuer = "",
contractId = "",
}) => {
if (!balances) return null;
const canonicalAsset = getCanonicalFromAsset(code, issuer);
const isTrustlineActive = Object.keys(balances).some(
(balance) => balance === canonicalAsset,
);
const isActionPending =
submitStatus === ActionStatus.PENDING ||
accountBalanceStatus === ActionStatus.PENDING;

return (
<div
className="ManageAssetRows__row"
key={canonicalAsset}
data-testid="ManageAssetRow"
>
<ManageAssetRow
code={code}
issuer={issuer}
image={image}
domain={domain}
/>
<div className="ManageAssetRows__button">
<PillButton
disabled={isActionPending}
isLoading={
isActionPending && assetSubmitting === canonicalAsset
{assetRows.map(({ code = "", domain, image = "", issuer = "" }) => {
if (!balances) return null;
const isContract = isContractId(issuer);
const canonicalAsset = getCanonicalFromAsset(code, issuer);
const isTrustlineActive = Object.keys(balances).some(
(balance) => balance === canonicalAsset,
);
const isActionPending =
submitStatus === ActionStatus.PENDING ||
accountBalanceStatus === ActionStatus.PENDING;

return (
<div
className="ManageAssetRows__row"
key={canonicalAsset}
data-testid="ManageAssetRow"
>
<ManageAssetRow
code={code}
issuer={issuer}
image={image}
domain={domain}
/>
<div className="ManageAssetRows__button">
<PillButton
disabled={isActionPending}
isLoading={
isActionPending && assetSubmitting === canonicalAsset
}
onClick={() => {
if (isContract) {
handleTokenRowClick(issuer, canonicalAsset);
} else {
handleRowClick(
{ code, issuer, image, domain },
isTrustlineActive,
);
}
onClick={() => {
if (contractId) {
handleTokenRowClick(issuer, canonicalAsset);
} else {
handleRowClick(
{ code, issuer, image, domain },
isTrustlineActive,
);
}
}}
type="button"
data-testid="ManageAssetRowButton"
>
{isTrustlineActive || contractId ? t("Remove") : t("Add")}
</PillButton>
</div>
}}
type="button"
data-testid="ManageAssetRowButton"
>
{isTrustlineActive || isContract ? t("Remove") : t("Add")}
</PillButton>
</div>
);
},
)}
</div>
);
})}

{tokensWithNoBalance.map((tokenId) => {
const isActionPending =
Expand Down

0 comments on commit 6521fa9

Please sign in to comment.