|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
|
import { Box, Text, Tip } from "grommet"; |
|
|
|
|
import { |
|
|
|
|
Address, |
|
|
|
@ -15,7 +15,13 @@ import { ONEValueDropdown } from "src/components/ui/OneValueDropdown"; |
|
|
|
|
import { binanceAddressMap } from "src/config/BinanceAddressMap"; |
|
|
|
|
import { useERC1155Pool } from "src/hooks/ERC1155_Pool"; |
|
|
|
|
import { CircleQuestion } from "grommet-icons"; |
|
|
|
|
import styled from "styled-components"; |
|
|
|
|
|
|
|
|
|
export const StyledBox = styled(Box)` |
|
|
|
|
transition: all .2s linear; |
|
|
|
|
border-radius: 2px; |
|
|
|
|
padding-left: 5px; |
|
|
|
|
` |
|
|
|
|
interface AddressDetailsProps { |
|
|
|
|
address: string; |
|
|
|
|
contracts: AddressDetails | null; |
|
|
|
@ -27,12 +33,24 @@ export function AddressDetailsDisplay(props: AddressDetailsProps) { |
|
|
|
|
const { address, contracts, tokens, balance } = props; |
|
|
|
|
const erc20Map = useERC20Pool(); |
|
|
|
|
const erc1155Map = useERC1155Pool(); |
|
|
|
|
const [isNewAddress, setIsNewAddress] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
const erc20Token = erc20Map[address] || null; |
|
|
|
|
const type = getType(contracts, erc20Token); |
|
|
|
|
const erc1151data = erc1155Map[address] || {}; |
|
|
|
|
const { meta = {}, ...restErc1151data } = erc1151data; |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
let tId = 0; |
|
|
|
|
const getActiveIndex = () => { |
|
|
|
|
setIsNewAddress(true); |
|
|
|
|
tId = window.setTimeout(() => setIsNewAddress(false), 1000); |
|
|
|
|
}; |
|
|
|
|
getActiveIndex(); |
|
|
|
|
|
|
|
|
|
return () => clearTimeout(tId); |
|
|
|
|
}, [address]); |
|
|
|
|
|
|
|
|
|
const data = { |
|
|
|
|
...contracts, |
|
|
|
|
...erc20Token, |
|
|
|
@ -53,7 +71,13 @@ export function AddressDetailsDisplay(props: AddressDetailsProps) { |
|
|
|
|
<Box> |
|
|
|
|
{items.sort(sortByOrder).map((i) => ( |
|
|
|
|
//@ts-ignore
|
|
|
|
|
<DetailItem key={i} name={i} data={data} type={type} /> |
|
|
|
|
<DetailItem |
|
|
|
|
key={i} |
|
|
|
|
name={i} |
|
|
|
|
data={data} |
|
|
|
|
type={type} |
|
|
|
|
isNewAddress={isNewAddress} |
|
|
|
|
/> |
|
|
|
|
))} |
|
|
|
|
</Box> |
|
|
|
|
); |
|
|
|
@ -83,8 +107,13 @@ export const Item = (props: { label: any; value: any }) => { |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function DetailItem(props: { data: any; name: string; type: TAddressType }) { |
|
|
|
|
const { data, name, type } = props; |
|
|
|
|
function DetailItem(props: { |
|
|
|
|
data: any; |
|
|
|
|
name: string; |
|
|
|
|
type: TAddressType; |
|
|
|
|
isNewAddress: boolean; |
|
|
|
|
}) { |
|
|
|
|
const { data, name, type, isNewAddress } = props; |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
!addressPropertyDisplayNames[name] || |
|
|
|
@ -97,7 +126,12 @@ function DetailItem(props: { data: any; name: string; type: TAddressType }) { |
|
|
|
|
return ( |
|
|
|
|
<Item |
|
|
|
|
label={addressPropertyDisplayNames[name](data, { type })} |
|
|
|
|
value={addressPropertyDisplayValues[name](data[name], data, { type })} |
|
|
|
|
value={addressPropertyDisplayValues[name]( |
|
|
|
|
data[name], |
|
|
|
|
data, |
|
|
|
|
{ type }, |
|
|
|
|
isNewAddress |
|
|
|
|
)} |
|
|
|
|
/> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -128,13 +162,24 @@ const addressPropertyDisplayNames: Record< |
|
|
|
|
|
|
|
|
|
const addressPropertyDisplayValues: Record< |
|
|
|
|
string, |
|
|
|
|
(value: any, data: any, options: { type: TAddressType }) => React.ReactNode |
|
|
|
|
( |
|
|
|
|
value: any, |
|
|
|
|
data: any, |
|
|
|
|
options: { type: TAddressType }, |
|
|
|
|
isNewAddress: boolean |
|
|
|
|
) => React.ReactNode |
|
|
|
|
> = { |
|
|
|
|
address: (value, data, options: { type: TAddressType }) => { |
|
|
|
|
address: (value, data, options: { type: TAddressType }, isNewAddress) => { |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<StyledBox |
|
|
|
|
direction={"row"} |
|
|
|
|
background={isNewAddress ? "backgroundSuccess" : ""} |
|
|
|
|
style={{ maxWidth: "550px" }} |
|
|
|
|
> |
|
|
|
|
<Address address={value} displayHash /> |
|
|
|
|
{binanceAddressMap[value] ? ` (${binanceAddressMap[value]})` : null} |
|
|
|
|
</StyledBox> |
|
|
|
|
</> |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
@ -203,7 +248,6 @@ const addressPropertyDisplayValues: Record< |
|
|
|
|
description: (value) => <>{value}</>, |
|
|
|
|
transactionHash: (value) => <Address address={value} type={"tx"} />, |
|
|
|
|
circulatingSupply: (value, data) => ( |
|
|
|
|
|
|
|
|
|
<Box direction={"row"}> |
|
|
|
|
<TokenValue |
|
|
|
|
value={value} |
|
|
|
@ -227,7 +271,6 @@ const addressPropertyDisplayValues: Record< |
|
|
|
|
</span> |
|
|
|
|
</Tip> |
|
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|