Skip to content

Commit

Permalink
hide send button when token is not transferable (#1706)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Sinclair <4412473+DanielSinclair@users.noreply.github.com>
  • Loading branch information
greg-schrammel and DanielSinclair authored Oct 2, 2024
1 parent 7574dbf commit 3048605
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/core/types/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface ParsedAsset {
isBridgeable: boolean;
networks: { [id in ChainId]?: { bridgeable: boolean } };
};
transferable?: boolean;
}

export interface ParsedUserAsset extends ParsedAsset {
Expand Down Expand Up @@ -101,6 +102,7 @@ export type AssetApiResponse = {
};
type?: AssetType;
interface?: 'erc-721' | 'erc-1155';
transferable?: boolean;
};

type AssetType = ProtocolType | 'nft';
Expand Down
1 change: 1 addition & 0 deletions src/core/utils/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function parseAsset({
networks: asset.bridging.networks,
},
}),
transferable: asset.transferable,
};

return parsedAsset;
Expand Down
28 changes: 16 additions & 12 deletions src/entries/popup/pages/home/TokenDetails/TokenDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ function SwapSend({
navigate(to);
};
const isBridgeable = token.bridging?.isBridgeable;
const isTransferable = token.transferable ?? true;

if (!isSwappable && !isBridgeable && !isTransferable) return null;
return (
<Box display="flex" gap="8px">
{isSwappable && (
Expand Down Expand Up @@ -213,17 +215,19 @@ function SwapSend({
{i18n.t('token_details.bridge')}
</Button>
)}
<Button
height="32px"
variant="flat"
width="full"
color="accent"
symbol="paperplane.fill"
onClick={() => selectTokenAndNavigate(ROUTES.SEND)}
tabIndex={0}
>
{i18n.t('token_details.send')}
</Button>
{isTransferable && (
<Button
height="32px"
variant="flat"
width="full"
color="accent"
symbol="paperplane.fill"
onClick={() => selectTokenAndNavigate(ROUTES.SEND)}
tabIndex={0}
>
{i18n.t('token_details.send')}
</Button>
)}
</Box>
);
}
Expand Down Expand Up @@ -828,9 +832,9 @@ export function TokenDetails() {
);
})}
</Stack>
<Separator color="separatorTertiary" />
</Box>
) : null}
<Separator color="separatorTertiary" />
<About token={token} tokenInfo={tokenInfo} />
</Box>
)}
Expand Down

0 comments on commit 3048605

Please sign in to comment.