Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
8634bc5a
Unverified
Commit
8634bc5a
authored
May 29, 2024
by
Igor Stuev
Committed by
GitHub
May 29, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1961 from blockscout/fe-1955
Add possibility to change ERC to something else
parents
89be9fd8
76e90ddb
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
56 additions
and
28 deletions
+56
-28
chain.ts
configs/app/chain.ts
+1
-0
schema.ts
deploy/tools/envs-validator/schema.ts
+1
-0
ENVS.md
docs/ENVS.md
+1
-0
tokenTypes.ts
lib/token/tokenTypes.ts
+19
-11
AddressTokens.tsx
ui/address/AddressTokens.tsx
+2
-1
TokenSelectMenu.tsx
ui/address/tokenSelect/TokenSelectMenu.tsx
+5
-2
NFTItem.tsx
ui/address/tokens/NFTItem.tsx
+2
-1
TokenInstance.tsx
ui/pages/TokenInstance.tsx
+2
-1
TokenTransferListItem.tsx
ui/shared/TokenTransfer/TokenTransferListItem.tsx
+2
-1
TokenTransferTableItem.tsx
ui/shared/TokenTransfer/TokenTransferTableItem.tsx
+2
-1
TokenTypeFilter.tsx
ui/shared/filters/TokenTypeFilter.tsx
+4
-3
utils.ts
ui/shared/search/utils.ts
+2
-2
TokenPageTitle.tsx
ui/token/TokenPageTitle.tsx
+2
-1
TokensListItem.tsx
ui/tokens/TokensListItem.tsx
+2
-1
TokensTableItem.tsx
ui/tokens/TokensTableItem.tsx
+2
-1
AddressFormNotifications.tsx
ui/watchlist/AddressModal/AddressFormNotifications.tsx
+7
-2
No files found.
configs/app/chain.ts
View file @
8634bc5a
...
...
@@ -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
'
,
...
...
deploy/tools/envs-validator/schema.ts
View file @
8634bc5a
...
...
@@ -492,6 +492,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
...
...
docs/ENVS.md
View file @
8634bc5a
...
...
@@ -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`
|
...
...
lib/token/tokenTypes.ts
View file @
8634bc5a
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
];
}
ui/address/AddressTokens.tsx
View file @
8634bc5a
...
...
@@ -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
'
,
...
...
ui/address/tokenSelect/TokenSelectMenu.tsx
View file @
8634bc5a
...
...
@@ -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
>
)
}
...
...
ui/address/tokens/NFTItem.tsx
View file @
8634bc5a
...
...
@@ -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
...
...
ui/pages/TokenInstance.tsx
View file @
8634bc5a
...
...
@@ -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
||
''
,
...
...
ui/shared/TokenTransfer/TokenTransferListItem.tsx
View file @
8634bc5a
...
...
@@ -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
&&
(
...
...
ui/shared/TokenTransfer/TokenTransferTableItem.tsx
View file @
8634bc5a
...
...
@@ -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
>
...
...
ui/shared/filters/TokenTypeFilter.tsx
View file @
8634bc5a
...
...
@@ -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_TYPE
S
:
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
>
...
...
ui/shared/search/utils.ts
View file @
8634bc5a
...
...
@@ -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
'
},
...
...
ui/token/TokenPageTitle.tsx
View file @
8634bc5a
...
...
@@ -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
'
,
...
...
ui/tokens/TokensListItem.tsx
View file @
8634bc5a
...
...
@@ -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
}
>
...
...
ui/tokens/TokensTableItem.tsx
View file @
8634bc5a
...
...
@@ -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
>
...
...
ui/watchlist/AddressModal/AddressFormNotifications.tsx
View file @
8634bc5a
...
...
@@ -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
>
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment