Skip to content

Commit

Permalink
refactor(guard-app): update token ids display condition
Browse files Browse the repository at this point in the history
Switch from checking token id length to checking `isNativeToken`
attribute of token info as display condition for tokens.
  • Loading branch information
mkermani144 committed Oct 14, 2023
1 parent 3613354 commit 4954101
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions apps/watcher/app/_mock/mockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,30 @@ const addressAssets: ApiAddressAssetsResponse = {
'2162efc108a0aeba2c040a3a29b1e8573dc6b6d746d33e5fe9cf9ccc1796f630',
amount: 10000,
decimals: 2,
isNativeToken: false,
},
{
tokenId:
'91e9086194cd9144a1661c5820dd53869afd1711d4c5a305b568a452e86f81b1',
amount: 2,
decimals: 0,
isNativeToken: false,
},
{
name: 'another awesome token',
tokenId:
'c6cce2d65182c2e4343d942000263b75d103e6d56fea08ded6dfc25548c2d34d',
amount: 200,
decimals: 1,
isNativeToken: false,
},
{
name: 'fakeRSN',
tokenId:
'6c1526b2a5ef010edb622719d9d7fbde8437a39543547c3effbe72ad33504cf1',
amount: 20,
decimals: 5,
isNativeToken: false,
},
],
total: 4,
Expand Down Expand Up @@ -278,13 +282,15 @@ const generateRevenueRecords = (numberOfRecords: number) => {
amount: 1000,
name: 'fakeRSN',
decimals: 0,
isNativeToken: false,
},
{
tokenId:
'6c1526b2a5ef010edb622719d9d7fbde8437a39543547c3effbe72ad33504cf2',
amount: 100,
name: 'awesome token',
decimals: 2,
isNativeToken: false,
},
],
}));
Expand Down
2 changes: 1 addition & 1 deletion apps/watcher/app/actions/@form/withdraw/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const WithdrawForm = () => {
<MenuItem value={token.tokenId} key={token.tokenId}>
{token.name ?? TOKEN_NAME_PLACEHOLDER}
&nbsp;
{token.tokenId.length >= 64 && (
{!token.isNativeToken && (
<>
(<Id id={token.tokenId} />)
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface TokenListItemProps {
index: number;
name?: string;
value: string;
isNativeToken: boolean;
}
/**
* render a token list item, showing its name, id, avatar and value
Expand All @@ -33,6 +34,7 @@ export const TokenListItem = ({
index,
name,
value,
isNativeToken,
}: TokenListItemProps) => {
const nameOrPlaceholder = name || TOKEN_NAME_PLACEHOLDER;
const theme = useTheme();
Expand All @@ -49,7 +51,7 @@ export const TokenListItem = ({
<Typography>{getDecimalString(value, decimals)}</Typography>
</Box>
}
{...(id.length >= 64 ? { secondary: <Id id={id} /> } : {})}
{...(!isNativeToken ? { secondary: <Id id={id} /> } : {})}
secondaryTypographyProps={{
component: 'div',
style: { fontSize: theme.typography.body2.fontSize },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const TokensList = ({ tokens, isLoading }: TokensListProps) => (
key={token.tokenId}
name={token.name}
value={token.amount.toString()}
isNativeToken={token.isNativeToken}
/>
))
)}
Expand Down

0 comments on commit 4954101

Please sign in to comment.