Commit 76e90ddb authored by isstuev's avatar isstuev

Add possibility to change ERC to something else

parent b5757e40
......@@ -15,6 +15,7 @@ const chain = Object.freeze({
secondaryCoin: {
symbol: getEnvValue('NEXT_PUBLIC_NETWORK_SECONDARY_COIN_SYMBOL'),
},
tokenStandard: getEnvValue('NEXT_PUBLIC_NETWORK_TOKEN_STANDARD_NAME') || 'ERC',
rpcUrl: getEnvValue('NEXT_PUBLIC_NETWORK_RPC_URL'),
isTestnet: getEnvValue('NEXT_PUBLIC_IS_TESTNET') === 'true',
verificationType: getEnvValue('NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE') || 'mining',
......
......@@ -479,6 +479,7 @@ const schema = yup
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS: yup.number().integer().positive(),
NEXT_PUBLIC_NETWORK_SECONDARY_COIN_SYMBOL: yup.string(),
NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE: yup.string<NetworkVerificationType>().oneOf([ 'validation', 'mining' ]),
NEXT_PUBLIC_NETWORK_TOKEN_STANDARD_NAME: yup.string(),
NEXT_PUBLIC_IS_TESTNET: yup.boolean(),
// 3. API configuration
......
......@@ -89,6 +89,7 @@ Please be aware that all environment variables prefixed with `NEXT_PUBLIC_` will
| NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS | `string` | Network currency decimals | - | `18` | `6` |
| NEXT_PUBLIC_NETWORK_SECONDARY_COIN_SYMBOL | `string` | Network secondary coin symbol. | - | - | `GNO` |
| NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE | `validation` or `mining` | Verification type in the network | - | `mining` | `validation` |
| NEXT_PUBLIC_NETWORK_TOKEN_STANDARD_NAME | `string` | Name of the standard for creating tokens | - | `ERC` | `BEP` |
| NEXT_PUBLIC_IS_TESTNET | `boolean`| Set to true if network is testnet | - | `false` | `true` |
&nbsp;
......
import type { NFTTokenType, TokenType } from 'types/api/token';
export const NFT_TOKEN_TYPES: Array<{ title: string; id: NFTTokenType }> = [
{ title: 'ERC-721', id: 'ERC-721' },
{ title: 'ERC-1155', id: 'ERC-1155' },
{ title: 'ERC-404', id: 'ERC-404' },
];
export const TOKEN_TYPES: Array<{ title: string; id: TokenType }> = [
{ title: 'ERC-20', id: 'ERC-20' },
import config from 'configs/app';
const tokenStandardName = config.chain.tokenStandard;
export const NFT_TOKEN_TYPES: Record<NFTTokenType, string > = {
'ERC-721': `${ tokenStandardName }-721`,
'ERC-1155': `${ tokenStandardName }-1155`,
'ERC-404': `${ tokenStandardName }-404`,
};
export const TOKEN_TYPES: Record<TokenType, string > = {
'ERC-20': `${ tokenStandardName }-20`,
...NFT_TOKEN_TYPES,
];
};
export const NFT_TOKEN_TYPE_IDS: Array<NFTTokenType> = [ 'ERC-721', 'ERC-1155', 'ERC-404' ];
export const TOKEN_TYPE_IDS: Array<TokenType> = [ 'ERC-20', ...NFT_TOKEN_TYPE_IDS ];
export const NFT_TOKEN_TYPE_IDS = NFT_TOKEN_TYPES.map(i => i.id);
export const TOKEN_TYPE_IDS = TOKEN_TYPES.map(i => i.id);
export function getTokenTypeName(typeId: TokenType) {
return TOKEN_TYPES[typeId];
}
......@@ -5,6 +5,7 @@ import React from 'react';
import type { NFTTokenType } from 'types/api/token';
import type { PaginationParams } from 'ui/shared/pagination/types';
import config from 'configs/app';
import { useAppContext } from 'lib/contexts/app';
import * as cookies from 'lib/cookies';
import getFilterValuesFromQuery from 'lib/getFilterValuesFromQuery';
......@@ -118,7 +119,7 @@ const AddressTokens = ({ shouldRender = true }: Props) => {
const hasActiveFilters = Boolean(tokenTypes?.length);
const tabs = [
{ id: 'tokens_erc20', title: 'ERC-20', component: <ERC20Tokens tokensQuery={ erc20Query }/> },
{ id: 'tokens_erc20', title: `${ config.chain.tokenStandard }-20`, component: <ERC20Tokens tokensQuery={ erc20Query }/> },
{
id: 'tokens_nfts',
title: 'NFTs',
......
......@@ -6,6 +6,7 @@ import React from 'react';
import type { FormattedData } from './types';
import type { TokenType } from 'types/api/token';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import IconSvg from 'ui/shared/IconSvg';
import type { Sort } from '../utils/tokenUtils';
......@@ -73,9 +74,11 @@ const TokenSelectMenu = ({ erc20sort, erc1155sort, erc404sort, filteredData, onI
return (
<Box key={ type }>
<Flex justifyContent="space-between">
<Text mb={ 3 } color="gray.500" fontWeight={ 600 } fontSize="sm">{ type } tokens ({ numPrefix }{ tokenInfo.items.length })</Text>
<Text mb={ 3 } color="gray.500" fontWeight={ 600 } fontSize="sm">
{ getTokenTypeName(type) } tokens ({ numPrefix }{ tokenInfo.items.length })
</Text>
{ hasSort && (
<Link data-type={ type } onClick={ onSortClick } aria-label={ `Sort ${ type } tokens` }>
<Link data-type={ type } onClick={ onSortClick } aria-label={ `Sort ${ getTokenTypeName(type) } tokens` }>
<IconSvg name="arrows/east" boxSize={ 5 } transform={ arrowTransform } transitionDuration="faster"/>
</Link>
) }
......
......@@ -6,6 +6,7 @@ import type { AddressNFT } from 'types/api/address';
import { route } from 'nextjs-routes';
import getCurrencyValue from 'lib/getCurrencyValue';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import NftEntity from 'ui/shared/entities/nft/NftEntity';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
import NftMedia from 'ui/shared/nft/NftMedia';
......@@ -23,7 +24,7 @@ const NFTItem = ({ token, value, isLoading, withTokenLink, ...tokenInstance }: P
return (
<NFTItemContainer position="relative">
<Skeleton isLoaded={ !isLoading }>
<LightMode><Tag background="gray.50" zIndex={ 1 } position="absolute" top="18px" right="18px">{ token.type }</Tag></LightMode>
<LightMode><Tag background="gray.50" zIndex={ 1 } position="absolute" top="18px" right="18px">{ getTokenTypeName(token.type) }</Tag></LightMode>
</Skeleton>
<Link href={ isLoading ? undefined : tokenInstanceLink }>
<NftMedia
......
......@@ -11,6 +11,7 @@ import throwOnResourceLoadError from 'lib/errors/throwOnResourceLoadError';
import useIsMobile from 'lib/hooks/useIsMobile';
import * as metadata from 'lib/metadata';
import * as regexp from 'lib/regexp';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import {
TOKEN_INSTANCE,
TOKEN_INFO_ERC_1155,
......@@ -130,7 +131,7 @@ const TokenInstanceContent = () => {
throwOnResourceLoadError(tokenInstanceQuery);
const tokenTag = <Tag isLoading={ tokenInstanceQuery.isPlaceholderData }>{ tokenQuery.data?.type }</Tag>;
const tokenTag = tokenQuery.data?.type ? <Tag isLoading={ tokenInstanceQuery.isPlaceholderData }>{ getTokenTypeName(tokenQuery.data?.type) }</Tag> : null;
const address = {
hash: hash || '',
......
......@@ -5,6 +5,7 @@ import type { TokenTransfer } from 'types/api/tokenTransfer';
import getCurrencyValue from 'lib/getCurrencyValue';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import Tag from 'ui/shared/chakra/Tag';
import NftEntity from 'ui/shared/entities/nft/NftEntity';
......@@ -54,7 +55,7 @@ const TokenTransferListItem = ({
noCopy
w="auto"
/>
<Tag flexShrink={ 0 } isLoading={ isLoading }>{ token.type }</Tag>
<Tag flexShrink={ 0 } isLoading={ isLoading }>{ getTokenTypeName(token.type) }</Tag>
<Tag colorScheme="orange" isLoading={ isLoading }>{ getTokenTransferTypeText(type) }</Tag>
</Flex>
{ showTxInfo && txHash && (
......
......@@ -5,6 +5,7 @@ import type { TokenTransfer } from 'types/api/tokenTransfer';
import getCurrencyValue from 'lib/getCurrencyValue';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import Tag from 'ui/shared/chakra/Tag';
import NftEntity from 'ui/shared/entities/nft/NftEntity';
......@@ -60,7 +61,7 @@ const TokenTransferTableItem = ({
mt={ 1 }
/>
<Flex columnGap={ 2 } rowGap={ 2 } mt={ 2 } flexWrap="wrap">
<Tag isLoading={ isLoading }>{ token.type }</Tag>
<Tag isLoading={ isLoading }>{ getTokenTypeName(token.type) }</Tag>
<Tag colorScheme="orange" isLoading={ isLoading }>{ getTokenTransferTypeText(type) }</Tag>
</Flex>
</Td>
......
......@@ -3,7 +3,8 @@ import React from 'react';
import type { NFTTokenType, TokenType } from 'types/api/token';
import { NFT_TOKEN_TYPES, TOKEN_TYPES } from 'lib/token/tokenTypes';
import {
TOKEN_TYPES, TOKEN_TYPE_IDS, NFT_TOKEN_TYPE_IDS } from 'lib/token/tokenTypes';
type Props<T extends TokenType | NFTTokenType> = {
onChange: (nextValue: Array<T>) => void;
......@@ -42,9 +43,9 @@ const TokenTypeFilter = <T extends TokenType | NFTTokenType>({ nftOnly, onChange
</Link>
</Flex>
<CheckboxGroup size="lg" onChange={ handleChange } value={ value }>
{ (nftOnly ? NFT_TOKEN_TYPES : TOKEN_TYPES).map(({ title, id }) => (
{ (nftOnly ? NFT_TOKEN_TYPE_IDS : TOKEN_TYPE_IDS).map((id) => (
<Checkbox key={ id } value={ id }>
<Text fontSize="md">{ title }</Text>
<Text fontSize="md">{ TOKEN_TYPES[id] }</Text>
</Checkbox>
)) }
</CheckboxGroup>
......
......@@ -17,8 +17,8 @@ export type SearchResultAppItem = {
export const searchCategories: Array<{id: Category; title: string }> = [
{ id: 'app', title: 'DApps' },
{ id: 'token', title: 'Tokens (ERC-20)' },
{ id: 'nft', title: 'NFTs (ERC-721 & 1155)' },
{ id: 'token', title: `Tokens (${ config.chain.tokenStandard }-20)` },
{ id: 'nft', title: `NFTs (${ config.chain.tokenStandard }-721 & 1155)` },
{ id: 'address', title: 'Addresses' },
{ id: 'public_tag', title: 'Public tags' },
{ id: 'transaction', title: 'Transactions' },
......
......@@ -11,6 +11,7 @@ import useAddressMetadataInfoQuery from 'lib/address/useAddressMetadataInfoQuery
import type { ResourceError } from 'lib/api/resources';
import useApiQuery from 'lib/api/useApiQuery';
import { useAppContext } from 'lib/contexts/app';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import AddressQrCode from 'ui/address/details/AddressQrCode';
import AccountActionsMenu from 'ui/shared/AccountActionsMenu/AccountActionsMenu';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
......@@ -67,7 +68,7 @@ const TokenPageTitle = ({ tokenQuery, addressQuery, hash }: Props) => {
const tags: Array<EntityTag> = React.useMemo(() => {
return [
tokenQuery.data ? { slug: tokenQuery.data?.type, name: tokenQuery.data?.type, tagType: 'custom' as const, ordinal: -20 } : undefined,
tokenQuery.data ? { slug: tokenQuery.data?.type, name: getTokenTypeName(tokenQuery.data.type), tagType: 'custom' as const, ordinal: -20 } : undefined,
config.features.bridgedTokens.isEnabled && tokenQuery.data?.is_bridged ?
{
slug: 'bridged',
......
......@@ -5,6 +5,7 @@ import React from 'react';
import type { TokenInfo } from 'types/api/token';
import config from 'configs/app';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import Tag from 'ui/shared/chakra/Tag';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
......@@ -59,7 +60,7 @@ const TokensTableItem = ({
fontWeight="700"
/>
<Flex ml={ 3 } flexShrink={ 0 } columnGap={ 1 }>
<Tag isLoading={ isLoading }>{ type }</Tag>
<Tag isLoading={ isLoading }>{ getTokenTypeName(type) }</Tag>
{ bridgedChainTag && <Tag isLoading={ isLoading }>{ bridgedChainTag }</Tag> }
</Flex>
<Skeleton isLoaded={ !isLoading } fontSize="sm" ml="auto" color="text_secondary" minW="24px" textAlign="right" lineHeight={ 6 }>
......
......@@ -5,6 +5,7 @@ import React from 'react';
import type { TokenInfo } from 'types/api/token';
import config from 'configs/app';
import { getTokenTypeName } from 'lib/token/tokenTypes';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import Tag from 'ui/shared/chakra/Tag';
import type { EntityProps as AddressEntityProps } from 'ui/shared/entities/address/AddressEntity';
......@@ -96,7 +97,7 @@ const TokensTableItem = ({
/>
</Flex>
<Flex columnGap={ 1 }>
<Tag isLoading={ isLoading }>{ type }</Tag>
<Tag isLoading={ isLoading }>{ getTokenTypeName(type) }</Tag>
{ bridgedChainTag && <Tag isLoading={ isLoading }>{ bridgedChainTag }</Tag> }
</Flex>
</Flex>
......
......@@ -6,9 +6,14 @@ import type { Path, ControllerRenderProps, FieldValues, Control } from 'react-ho
import config from 'configs/app';
import CheckboxInput from 'ui/shared/CheckboxInput';
// does it depend on the network?
const tokenStandardName = config.chain.tokenStandard;
const NOTIFICATIONS = [ 'native', 'ERC-20', 'ERC-721', 'ERC-404' ] as const;
const NOTIFICATIONS_NAMES = [ config.chain.currency.symbol, 'ERC-20', 'ERC-721, ERC-1155 (NFT)', 'ERC-404' ];
const NOTIFICATIONS_NAMES = [
config.chain.currency.symbol,
`${ tokenStandardName }-20`,
`${ tokenStandardName }-721, ${ tokenStandardName }-1155 (NFT)`,
`${ tokenStandardName }-404` ];
type Props<Inputs extends FieldValues> = {
control: Control<Inputs>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment