Merge branch 'harmony-one:master' into master

pull/135/head
Victa Kwok Wai Phu 3 years ago committed by GitHub
commit 174870b5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 51
      src/pages/AddressPage/tabs/holders/HoldersTab.tsx

@ -8,12 +8,26 @@ import { useERC1155Pool } from "src/hooks/ERC1155_Pool";
import { useERC20Pool } from "src/hooks/ERC20_Pool"; import { useERC20Pool } from "src/hooks/ERC20_Pool";
import { useERC721Pool } from "src/hooks/ERC721_Pool"; import { useERC721Pool } from "src/hooks/ERC721_Pool";
import { Filter } from "src/types"; import { Filter } from "src/types";
import Big from "big.js";
const getColumns = ( const getColumns = (
id: string, id: string,
type: "erc20" | "erc721" | "erc1155" type: "erc20" | "erc721" | "erc1155"
): ColumnConfig<IHoldersInfo>[] => { ): ColumnConfig<IHoldersInfo>[] => {
return [ const columns = [
{
property: "rank",
header: (
<Text
color="minorText"
size="small"
style={{ fontWeight: 300, width: "30px" }}
>
Rank
</Text>
),
render: (data: any) => <div>{data.rank}</div>,
},
{ {
property: "ownerAddres", property: "ownerAddres",
header: ( header: (
@ -34,7 +48,7 @@ const getColumns = (
Balance Balance
</Text> </Text>
), ),
render: (data) => { render: (data: any) => {
return type === "erc1155" ? ( return type === "erc1155" ? (
<>{data.balance}</> <>{data.balance}</>
) : ( ) : (
@ -43,6 +57,24 @@ const getColumns = (
}, },
}, },
]; ];
if (type === 'erc20' || type === 'erc721') {
columns.push( {
property: "percentage",
header: (
<Text
color="minorText"
size="small"
style={{ fontWeight: 300 }}
>
Percentage
</Text>
),
render: (data: any) => <div>{data.percentage}</div>,
})
}
return columns
}; };
export function HoldersTab(props: { export function HoldersTab(props: {
@ -59,6 +91,11 @@ export function HoldersTab(props: {
erc721Map[props.id]?.holders || erc721Map[props.id]?.holders ||
erc1155Map[props.id]?.holders; erc1155Map[props.id]?.holders;
const totalSupply =
erc20Map[props.id]?.totalSupply ||
erc721Map[props.id]?.totalSupply ||
erc1155Map[props.id]?.totalSupply;
const limitValue = localStorage.getItem("tableLimitValue"); const limitValue = localStorage.getItem("tableLimitValue");
const initFilter: Partial<Filter> = { const initFilter: Partial<Filter> = {
@ -117,6 +154,16 @@ export function HoldersTab(props: {
} }
} }
holdersData = holdersData.map((item, index) => {
return {
...item,
rank: filter.offset + index + 1,
percentage: totalSupply && +totalSupply > 0
? Big(item.balance).div(Big(totalSupply)).mul(100).toFixed(4) + '%'
: ''
}
})
setHolders(holdersData); setHolders(holdersData);
} catch (err) { } catch (err) {
setHolders([]); setHolders([]);

Loading…
Cancel
Save