|
|
@ -1,4 +1,4 @@ |
|
|
|
import React from "react"; |
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
import { Box, Text, Tip } from "grommet"; |
|
|
|
import { Box, Text, Tip } from "grommet"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Address, |
|
|
|
Address, |
|
|
@ -15,7 +15,13 @@ import { ONEValueDropdown } from "src/components/ui/OneValueDropdown"; |
|
|
|
import { binanceAddressMap } from "src/config/BinanceAddressMap"; |
|
|
|
import { binanceAddressMap } from "src/config/BinanceAddressMap"; |
|
|
|
import { useERC1155Pool } from "src/hooks/ERC1155_Pool"; |
|
|
|
import { useERC1155Pool } from "src/hooks/ERC1155_Pool"; |
|
|
|
import { CircleQuestion } from "grommet-icons"; |
|
|
|
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 { |
|
|
|
interface AddressDetailsProps { |
|
|
|
address: string; |
|
|
|
address: string; |
|
|
|
contracts: AddressDetails | null; |
|
|
|
contracts: AddressDetails | null; |
|
|
@ -27,12 +33,24 @@ export function AddressDetailsDisplay(props: AddressDetailsProps) { |
|
|
|
const { address, contracts, tokens, balance } = props; |
|
|
|
const { address, contracts, tokens, balance } = props; |
|
|
|
const erc20Map = useERC20Pool(); |
|
|
|
const erc20Map = useERC20Pool(); |
|
|
|
const erc1155Map = useERC1155Pool(); |
|
|
|
const erc1155Map = useERC1155Pool(); |
|
|
|
|
|
|
|
const [isNewAddress, setIsNewAddress] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
|
|
const erc20Token = erc20Map[address] || null; |
|
|
|
const erc20Token = erc20Map[address] || null; |
|
|
|
const type = getType(contracts, erc20Token); |
|
|
|
const type = getType(contracts, erc20Token); |
|
|
|
const erc1151data = erc1155Map[address] || {}; |
|
|
|
const erc1151data = erc1155Map[address] || {}; |
|
|
|
const { meta = {}, ...restErc1151data } = erc1151data; |
|
|
|
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 = { |
|
|
|
const data = { |
|
|
|
...contracts, |
|
|
|
...contracts, |
|
|
|
...erc20Token, |
|
|
|
...erc20Token, |
|
|
@ -53,7 +71,13 @@ export function AddressDetailsDisplay(props: AddressDetailsProps) { |
|
|
|
<Box> |
|
|
|
<Box> |
|
|
|
{items.sort(sortByOrder).map((i) => ( |
|
|
|
{items.sort(sortByOrder).map((i) => ( |
|
|
|
//@ts-ignore
|
|
|
|
//@ts-ignore
|
|
|
|
<DetailItem key={i} name={i} data={data} type={type} /> |
|
|
|
<DetailItem |
|
|
|
|
|
|
|
key={i} |
|
|
|
|
|
|
|
name={i} |
|
|
|
|
|
|
|
data={data} |
|
|
|
|
|
|
|
type={type} |
|
|
|
|
|
|
|
isNewAddress={isNewAddress} |
|
|
|
|
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
); |
|
|
|
); |
|
|
@ -83,8 +107,13 @@ export const Item = (props: { label: any; value: any }) => { |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function DetailItem(props: { data: any; name: string; type: TAddressType }) { |
|
|
|
function DetailItem(props: { |
|
|
|
const { data, name, type } = props; |
|
|
|
data: any; |
|
|
|
|
|
|
|
name: string; |
|
|
|
|
|
|
|
type: TAddressType; |
|
|
|
|
|
|
|
isNewAddress: boolean; |
|
|
|
|
|
|
|
}) { |
|
|
|
|
|
|
|
const { data, name, type, isNewAddress } = props; |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!addressPropertyDisplayNames[name] || |
|
|
|
!addressPropertyDisplayNames[name] || |
|
|
@ -97,7 +126,12 @@ function DetailItem(props: { data: any; name: string; type: TAddressType }) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Item |
|
|
|
<Item |
|
|
|
label={addressPropertyDisplayNames[name](data, { type })} |
|
|
|
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< |
|
|
|
const addressPropertyDisplayValues: Record< |
|
|
|
string, |
|
|
|
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 ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<Address address={value} displayHash /> |
|
|
|
<StyledBox |
|
|
|
{binanceAddressMap[value] ? ` (${binanceAddressMap[value]})` : null} |
|
|
|
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}</>, |
|
|
|
description: (value) => <>{value}</>, |
|
|
|
transactionHash: (value) => <Address address={value} type={"tx"} />, |
|
|
|
transactionHash: (value) => <Address address={value} type={"tx"} />, |
|
|
|
circulatingSupply: (value, data) => ( |
|
|
|
circulatingSupply: (value, data) => ( |
|
|
|
|
|
|
|
|
|
|
|
<Box direction={"row"}> |
|
|
|
<Box direction={"row"}> |
|
|
|
<TokenValue |
|
|
|
<TokenValue |
|
|
|
value={value} |
|
|
|
value={value} |
|
|
@ -227,7 +271,6 @@ const addressPropertyDisplayValues: Record< |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</Tip> |
|
|
|
</Tip> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|