Skip to content

Commit

Permalink
feat: add ability for tokens to add token information
Browse files Browse the repository at this point in the history
  • Loading branch information
kasumi-1 committed Nov 22, 2021
1 parent 7126b9a commit 5a3ed4e
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ git clone https://github.com/mistswapdex/mistswap-analytics.git && cd mistswap-a

Add your logo by opening a PR against mistswapdex/assets

## Add token information

Edit src/core/tokeninfo.js to add your token information.

## Licence

MIT
54 changes: 54 additions & 0 deletions src/components/TokenDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Box, Card, CardContent, Grid, Typography } from "@material-ui/core";

import React from "react";
import clsx from "clsx";
import { formatCurrency, TokenInfo } from "app/core";
import { makeStyles } from "@material-ui/styles";

const useStyles = makeStyles((theme) => ({
cardContent: {
// textAlign: "center",
"&:last-child": {
paddingBottom: 16,
},
},
title: {
fontWeight: 500,
},
content: {
display: "flex",
alignItems: "center",
justifyContent: "flex-start",
},
}));

function TokenDetail({
className,
title = "",
value = "",
format = "none",
...rest
}) {
const classes = useStyles();

return (
<Card variant="outlined">
<CardContent className={classes.cardContent}>
<Typography
variant="subtitle2"
color="textSecondary"
gutterBottom
noWrap
className={classes.title}
>
{ title }
</Typography>
<div className={classes.content}>
{ value }
</div>
</CardContent>
</Card>
);
}

export default TokenDetail;
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export { default as Search } from "./Search";
export { default as Sushi } from "./Sushi";
export { default as SortableTable } from "./SortableTable";
export { default as SortableTableHead } from "./SortableTableHead";
export { default as TokenDetail } from "./TokenDetail";
export { default as TokenIcon } from "./TokenIcon";
export { default as TokenTable } from "./TokenTable";
export { default as Transactions } from "./Transactions";
Expand Down
1 change: 1 addition & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from "./hooks";
export * from "./format";
export * from "./queries";
export * from "./timestamps";
export * from "./tokeninfo";
24 changes: 24 additions & 0 deletions src/core/tokeninfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const TokenInfo = {
"COPY_THIS_AND_REPLACE_WITH_LOWERCASE_CONTRACT_ADDRESS": {
description: 'Copy this entire section and add to end of list, keeping the trailing comma. Any unused fields may be set to null. Do not leave any example values.',
discord: 'tokenchat',
docs: 'https://docs.token.com',
github: 'tokendev',
gitlab: 'tokendev',
telegram: 'tokenchat',
twitter: 'token_news',
website: 'https://token.com',
whitepaper: 'https://token.com/whitepaper.pdf',
},
"0x5fa664f69c2a4a3ec94fac3cbf7049bd9ca73129": {
description: 'Mist is the native token of the MistSwap protocol.',
discord: 'mistswapdex',
docs: 'https://docs.mistswap.fi',
github: 'mistswapdex',
gitlab: null,
telegram: 'MistSwapOfficial',
twitter: 'mistswapdex',
website: 'https://mistswap.fi',
whitepaper: null,
},
}
145 changes: 145 additions & 0 deletions src/pages/tokens/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PairTable,
Percent,
TokenIcon,
TokenDetail,
Transactions,
} from "app/components";
import { Box, Grid, Paper, Typography } from "@material-ui/core";
Expand All @@ -30,6 +31,7 @@ import {
tokenQuery,
transactionsQuery,
useInterval,
TokenInfo,
} from "app/core";

import Head from "next/head";
Expand Down Expand Up @@ -333,6 +335,149 @@ function TokenPage() {
<Link href={`https://smartscan.cash/address/${token.id}`}>View</Link>,
]}
/>
<Grid
container
direction="row"
justify="space-between"
alignItems="center"
>
<Grid item xs={12} sm={12} md={12}>
<Grid item xs={12} md={12}>
<TokenDetail
title="Description"
value={
TokenInfo[token.id]
? TokenInfo[token.id]['description']
: (
<div>
No description exists yet for this token. Please go
<Link
href={`https://github.com/mistswapdex/mistswap-analytics`}
target="_blank"
variant="body1"
>
{' '}here{' '}
</Link>
to update information about a token.
</div>
)
}
/>
</Grid>
{ TokenInfo[token.id] && TokenInfo[token.id].discord && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Discord"
value=<Link
href={`https://discord.gg/invite/${TokenInfo[token.id]['discord']}`}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['discord'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].telegram && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Telegram"
value=<Link
href={`https://t.me/${TokenInfo[token.id]['telegram']}`}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['telegram'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].twitter && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Twitter"
value=<Link
href={`https://twitter.com/${TokenInfo[token.id]['twitter']}`}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['twitter'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].website && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Website"
value=<Link
href={TokenInfo[token.id]['website']}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['website'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].docs && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Docs"
value=<Link
href={TokenInfo[token.id]['docs']}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['docs'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].whitepaper && (
<Grid item xs={12} md={12}>
<TokenDetail
title="White Paper"
value=<Link
href={TokenInfo[token.id]['whitepaper']}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['whitepaper'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].github && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Github"
value=<Link
href={`https://github.com/${TokenInfo[token.id]['github']}`}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['github'] }
</Link>
/>
</Grid>
) }
{ TokenInfo[token.id] && TokenInfo[token.id].gitlab && (
<Grid item xs={12} md={12}>
<TokenDetail
title="Github"
value=<Link
href={`https://gitlab.com/${TokenInfo[token.id]['gitlab']}`}
target="_blank"
variant="body1"
>
{ TokenInfo[token.id]['gitlab'] }
</Link>
/>
</Grid>
) }
</Grid>
</Grid>
</Box>

<PairTable title="Pairs" pairs={pairs} />
Expand Down

1 comment on commit 5a3ed4e

@vercel
Copy link

@vercel vercel bot commented on 5a3ed4e Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.