Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token page #142

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/explorer/locales/en-US/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Balance": "Balance",
"ALPH balance": "ALPH balance",
"Address group": "Address group",
"Address": "Address",
Expand Down Expand Up @@ -34,6 +35,7 @@
"Latest activity": "Latest activity",
"Locked": "Locked",
"NFTs": "NFTs",
"NFT": "NFT",
"Nb. of assets": "Nb. of assets",
"Nb. of transactions": "Nb. of transactions",
"Next": "Next",
Expand All @@ -58,6 +60,7 @@
"Supply": "Supply",
"Timestamp": "Timestamp",
"Tokens": "Tokens",
"Token": "Token",
"Total Amount": "Total Amount",
"Total Amounts": "Total Amounts",
"Total": "Total",
Expand Down
3 changes: 3 additions & 0 deletions apps/explorer/locales/fr-FR/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Balance": "Montant",
"ALPH balance": "Montant ALPH",
"Address group": "Groupe de l'adresse",
"Address": "Adresse",
Expand Down Expand Up @@ -34,6 +35,7 @@
"Latest activity": "Dernière activité",
"Locked": "Vérouillés",
"NFTs": "NFTs",
"NFT": "NFT",
"Nb. of assets": "Nb d'actifs",
"Nb. of transactions": "Nb. de transactions",
"Next": "Suivant",
Expand All @@ -58,6 +60,7 @@
"Supply": "Emission",
"Timestamp": "Date",
"Tokens": "Jetons",
"Token": "Jeton",
"Total Amount": "Montant Total",
"Total Amounts": "Montants Totaux",
"Total": "Totale",
Expand Down
2 changes: 2 additions & 0 deletions apps/explorer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import PageNotFound from '@/pages/404'
import AddressInfoSection from '@/pages/AddressInfoPage'
import BlockInfoSection from '@/pages/BlockInfoPage'
import HomeSection from '@/pages/HomePage/HomePage'
import TokenInfoSection from '@/pages/TokenInfoPage'
import TransactionInfoSection from '@/pages/TransactionInfoPage'
import GlobalStyle, { deviceBreakPoints } from '@/styles/globalStyles'
import { darkTheme, lightTheme } from '@/styles/themes'
Expand Down Expand Up @@ -110,6 +111,7 @@ const App = () => {
<Route path="/" element={<HomeSection />} />
<Route path="/blocks/:id" element={<BlockInfoSection />} />
<Route path="/addresses/:id" element={<AddressInfoSection />} />
<Route path="/tokens/:id" element={<TokenInfoSection />} />
<Route path="/transactions/:id" element={<TransactionInfoSection />} />
<Route path="*" element={<PageNotFound />} />
</Routes>
Expand Down
2 changes: 2 additions & 0 deletions apps/explorer/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import { addressQueries } from '@/api/addresses/addressApi'
import { assetsQueries } from '@/api/assets/assetsApi'
import { blocksQueries } from '@/api/blocks/blocksApi'
import { infosQueries } from '@/api/infos/infosApi'
import { tokensQueries } from '@/api/tokens/tokensApi'
import { transactionsQueries } from '@/api/transactions/transactionsApi'

export const queries = {
assets: assetsQueries,
address: addressQueries,
tokens: tokensQueries,
transactions: transactionsQueries,
blocks: blocksQueries,
infos: infosQueries
Expand Down
43 changes: 43 additions & 0 deletions apps/explorer/src/api/tokens/tokensApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2018 - 2022 The Alephium Authors
This file is part of the alephium project.

The library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import client from '@/api/client'
import { createQueriesCollection } from '@/utils/api'

export const tokensQueries = createQueriesCollection({
transactions: {
confirmed: (tokenId: string, pageNumber: number, limit = 10) => ({
queryKey: ['tokenTransactions', tokenId, pageNumber, limit],
queryFn: () =>
client.explorer.tokens.getTokensTokenIdTransactions(tokenId, {
page: pageNumber,
limit
})
}),
total: (tokenId: string) => ({
queryKey: ['tokenTotalTransactions', tokenId],
queryFn: () => client.explorer.tokens.getTokensTokenIdTotalTransactions(tokenId)
})
},
balance:{
details: (tokenId: string) => ({
queryKey: ['tokenBalance', tokenId],
queryFn: () => client.explorer.tokens.getTokensTokenIdBalance(tokenId)
})
}
})
5 changes: 2 additions & 3 deletions apps/explorer/src/pages/AddressInfoPage/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
*/

import { ALPH, TokenInfo } from '@alephium/token-list'
import { addressFromTokenId, Optional } from '@alephium/web3'
import { Optional } from '@alephium/web3'
import { motion } from 'framer-motion'
import { useTranslation } from 'react-i18next'
import { RiErrorWarningFill } from 'react-icons/ri'
Expand Down Expand Up @@ -48,8 +48,7 @@ const TokenList = ({ tokens, limit, isLoading, className }: TokenListProps) => {

const handleTokenNameClick = (tokenId: string) => {
try {
const tokenAddress = addressFromTokenId(tokenId)
navigate(`/addresses/${tokenAddress}`)
navigate(`/tokens/${tokenId}`)
} catch (e) {
console.error(e)
}
Expand Down
Loading
Loading