* init solana dashboard * some updates * deploying programs works? * solana program page is go * more updates * various updates and improvements * git add maybe? * working state * working minting / nft list * working drop lazy mint + latest nightly * dashboard works * forgot to add things * fix various small things * fix rpc * implement token page + code organization * update SDK * rename accounts to program * implement token mint button * split dashboard into evm vs sol and separate out solana programs * fix caching * upgrade to combined sdk * merge in main * update to latest nightly SDK * tabs for days * lul query client maybe? * remove unused hook * add super basic nft drawer * lots of updates to start on nft drawer etc * add code tab content * fix merge conflicts * pass program address to code tab * some changes * some minor updates * new nft drawer and table * drawer for solana done (v1) * fix a bunch of stuff * fix some tracking * update nightly * add programId to program deploy event * adapt to changes in react lib * upgrade to dev version * Add batch upload to Solana (#539) * First small necessary refactor * Working version * Working version with yalc * Use nightly * Move everything around * Remove unused imports * Fix types * Add state for hasTried * Fix conditions * Add solana * Move selectedReveal to be part of the form * Improve logic * Update dependencies * Make drawer fullscreen * Fix hasFailed logic * Fix types * Make inputs required conditionally * Fix types * Make loading work * Remove repeated code * Remove unused * Pass progress as a prop * Move common files to core-ui * massive cleanup Co-authored-by: Jonas Daniels <[email protected]> * feat(faucet): build solana faucet (#528) * feat(faucet): build solana faucet * chore: update names * fix: type Co-authored-by: Jonas Daniels <[email protected]> * fix: minor stuff Co-authored-by: Jonas Daniels <[email protected]> * fix: feedback * feat: minor improvements * feat: add faq section * refactor: refactor faq * add accordion * minor fix Co-authored-by: Jonas Daniels <[email protected]> * tiny fix * Revert batch upload styles (#541) * Fix typo, fix drawer width * Revert to old batch upload styles * Fix some more styles * Fix progress bar styles * Update to using TWRegistry * [Solana] Add claim conditions to NFT Drop (#542) * Add tab and getter * Working version * Delete unused imports * Currency selector works but I hate it * Add maxClaimable * Fix build issue * Make batch upload work again * Fix claim conditions for devnet * Test fix * Delete console.logs * A lot of solana stuff (#545) * Remove unused banner * Hide Claim Conditions tab for no drops * Add loading state * Remove comment * Add helper text for nft drop supply * Delete log * Add loading state to program list * Add redirect if you don't have any program deploys * Add default instant reveal for Solana * Fix styles * Fix logic * doc fixes * fix(faucet): minor issues (#543) * fix(spacing): fix spacing in faq * feat: some updates from feedback * fix: use linkButton * feat: use fetch * remove test code * fix: err handling * pass err * fix sucecss state * fix: link * some updates * small fixes Co-authored-by: Nacho Iacovino <[email protected]> * update to latest nightly * fix up form and update deps * Add claim button to Solana (#555) * wip * Add claim buttons, fix warning, disable buttons conditioanlly * Use nightly * Delete unused import * Solana hackathon landing (#554) * feat: build hackathon page (#547) * wip: build hackathon page * add some more stuff * feat: responsievness and some minor stuff Co-authored-by: Nacho Iacovino <[email protected]> * First section * Fix PrizeSection * Add link to register now * Add judges and footer * Update startTime for hackathon * Fix Schedule * Add tracking * Add pageId * Prettier? * Prettier again * Prettier you're drunk * This is my life now * Remove unused import * Add og metadata * Update SEO Co-authored-by: Avneesh Agarwal <[email protected]> Co-authored-by: Jonas Daniels <[email protected]> * Add solana landing page (#556) * Add landing page for Solana * Add solana landing page * Add shopify landing * Add shopify * Remove quote * Add meta tags * Add landing page updates * Add links * small cleanups * fix various & pagination on nft table solana * Show unclaimed instead of tokenId for lazy minted tokens * add full install command for solana react * show create cli command in code tab for react * add funds notice for solana * add various things * various updates * various updates * updated some guides and copy based on juan feedback * Fix Solana faucet link * Add disclaimer on how to deploy with Devnet * Small fixes * Update guidelines * Fix currency selector bug * Update hero copy * fix build issues * update to latest * link solana cards * Add partners * update og images for shopify & solana * Add solanathon og:image * copy changes * Update image size * Center sponsors Co-authored-by: Joaquim Verges <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Avneesh Agarwal <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: Adam Majmudar <[email protected]>
299 lines
9.0 KiB
TypeScript
299 lines
9.0 KiB
TypeScript
import {
|
|
Center,
|
|
Flex,
|
|
Icon,
|
|
IconButton,
|
|
Select,
|
|
Skeleton,
|
|
Spinner,
|
|
Table,
|
|
Tbody,
|
|
Td,
|
|
Th,
|
|
Thead,
|
|
Tr,
|
|
} from "@chakra-ui/react";
|
|
import { PublicKey } from "@solana/web3.js";
|
|
import { useNFTs } from "@thirdweb-dev/react/solana";
|
|
import type { NFT } from "@thirdweb-dev/sdk";
|
|
import type { NFTCollection, NFTDrop } from "@thirdweb-dev/sdk/solana";
|
|
import { MediaCell } from "components/contract-pages/table/table-columns/cells/media-cell";
|
|
import { NFTDrawer } from "core-ui/nft-drawer/nft-drawer";
|
|
import { useNFTDrawerTabs } from "core-ui/nft-drawer/useNftDrawerTabs";
|
|
import { BigNumber } from "ethers";
|
|
import { useEffect, useMemo, useState } from "react";
|
|
import { FiArrowRight } from "react-icons/fi";
|
|
import {
|
|
MdFirstPage,
|
|
MdLastPage,
|
|
MdNavigateBefore,
|
|
MdNavigateNext,
|
|
} from "react-icons/md";
|
|
import { CellProps, Column, usePagination, useTable } from "react-table";
|
|
import { AddressCopyButton, Card, Heading, Text } from "tw-components";
|
|
import { shortenIfAddress } from "utils/usedapp-external";
|
|
|
|
export const NFTGetAllTable: React.FC<{
|
|
program: NFTCollection | NFTDrop;
|
|
}> = ({ program }) => {
|
|
const tableColumns = useMemo(() => {
|
|
const cols: Column<NFT>[] = [
|
|
{
|
|
Header: "Token Id",
|
|
accessor: (row) => {
|
|
if (row.metadata.id === PublicKey.default.toBase58()) {
|
|
return "Unclaimed";
|
|
}
|
|
return row.metadata.id;
|
|
},
|
|
Cell: (cell: CellProps<NFT, string>) => (
|
|
<Text size="body.md" fontFamily="mono">
|
|
{shortenIfAddress(cell.value)}
|
|
</Text>
|
|
),
|
|
},
|
|
{
|
|
Header: "Media",
|
|
accessor: (row) => row.metadata,
|
|
Cell: (cell: CellProps<NFT, NFT["metadata"]>) => (
|
|
<MediaCell cell={cell} />
|
|
),
|
|
},
|
|
{
|
|
Header: "Name",
|
|
accessor: (row) => row.metadata.name,
|
|
Cell: (cell: CellProps<NFT, string>) => (
|
|
<Text size="label.md">{cell.value}</Text>
|
|
),
|
|
},
|
|
{
|
|
Header: "Description",
|
|
accessor: (row) => row.metadata.description,
|
|
Cell: (cell: CellProps<NFT, string>) => (
|
|
<Text
|
|
noOfLines={4}
|
|
size="body.md"
|
|
fontStyle={!cell.value ? "italic" : "normal"}
|
|
>
|
|
{cell.value || "No description"}
|
|
</Text>
|
|
),
|
|
},
|
|
{
|
|
Header: "Owner",
|
|
accessor: (row) => row.owner,
|
|
Cell: (cell: CellProps<NFT, string>) => (
|
|
<AddressCopyButton size="xs" address={cell.value} />
|
|
),
|
|
},
|
|
{
|
|
Header: "Supply",
|
|
accessor: (row) => row.supply,
|
|
Cell: (cell: CellProps<NFT, number>) => (
|
|
<Text noOfLines={4} size="body.md" fontFamily="mono">
|
|
{cell.value}
|
|
</Text>
|
|
),
|
|
},
|
|
];
|
|
return cols;
|
|
}, []);
|
|
|
|
const [queryParams, setQueryParams] = useState({ count: 50, start: 0 });
|
|
|
|
const getAllQueryResult = useNFTs(program);
|
|
const totalCount = getAllQueryResult.data ? getAllQueryResult.data.length : 0;
|
|
const {
|
|
getTableProps,
|
|
getTableBodyProps,
|
|
headerGroups,
|
|
prepareRow,
|
|
page,
|
|
canPreviousPage,
|
|
canNextPage,
|
|
pageCount,
|
|
gotoPage,
|
|
nextPage,
|
|
previousPage,
|
|
setPageSize,
|
|
|
|
state: { pageIndex, pageSize },
|
|
} = useTable(
|
|
{
|
|
columns: tableColumns,
|
|
data:
|
|
getAllQueryResult.data?.slice(
|
|
queryParams.start,
|
|
queryParams.start + queryParams.count,
|
|
) || [],
|
|
initialState: {
|
|
pageSize: queryParams.count,
|
|
pageIndex: 0,
|
|
},
|
|
manualPagination: true,
|
|
pageCount: Math.max(
|
|
Math.ceil(BigNumber.from(totalCount).toNumber() / queryParams.count),
|
|
1,
|
|
),
|
|
},
|
|
usePagination,
|
|
);
|
|
|
|
useEffect(() => {
|
|
setQueryParams({ start: pageIndex * pageSize, count: pageSize });
|
|
}, [pageIndex, pageSize]);
|
|
|
|
const [tokenRow, setTokenRow] = useState<NFT | null>(null);
|
|
|
|
const drawerTabs = useNFTDrawerTabs("solana", program, tokenRow);
|
|
|
|
return (
|
|
<Flex gap={4} direction="column">
|
|
<Card maxW="100%" overflowX="auto" position="relative" px={0} py={0}>
|
|
{getAllQueryResult.isFetching && (
|
|
<Spinner
|
|
color="primary"
|
|
size="xs"
|
|
position="absolute"
|
|
top={2}
|
|
right={4}
|
|
/>
|
|
)}
|
|
<NFTDrawer
|
|
data={tokenRow}
|
|
isOpen={!!tokenRow}
|
|
onClose={() => setTokenRow(null)}
|
|
tabs={drawerTabs}
|
|
/>
|
|
<Table {...getTableProps()}>
|
|
<Thead bg="blackAlpha.50" _dark={{ bg: "whiteAlpha.50" }}>
|
|
{headerGroups.map((headerGroup) => (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Tr {...headerGroup.getHeaderGroupProps()}>
|
|
{headerGroup.headers.map((column) => (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Th {...column.getHeaderProps()} py={5}>
|
|
<Text as="label" size="label.md">
|
|
{column.render("Header")}
|
|
</Text>
|
|
</Th>
|
|
))}
|
|
{/* // Need to add an empty header for the drawer button */}
|
|
<Th />
|
|
</Tr>
|
|
))}
|
|
</Thead>
|
|
<Tbody {...getTableBodyProps()} position="relative">
|
|
{page.map((row) => {
|
|
prepareRow(row);
|
|
return (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Tr
|
|
{...row.getRowProps()}
|
|
role="group"
|
|
_hover={{ bg: "blackAlpha.50" }}
|
|
_dark={{
|
|
_hover: {
|
|
bg: "whiteAlpha.50",
|
|
},
|
|
}}
|
|
// this is a hack to get around the fact that safari does not handle position: relative on table rows
|
|
style={{ cursor: "pointer" }}
|
|
onClick={() => setTokenRow(row.original)}
|
|
// end hack
|
|
borderBottomWidth={1}
|
|
_last={{ borderBottomWidth: 0 }}
|
|
>
|
|
{row.cells.map((cell) => (
|
|
// eslint-disable-next-line react/jsx-key
|
|
<Td {...cell.getCellProps()} borderBottomWidth="inherit">
|
|
{cell.render("Cell")}
|
|
</Td>
|
|
))}
|
|
<Td borderBottomWidth="inherit">
|
|
<Icon as={FiArrowRight} />
|
|
</Td>
|
|
</Tr>
|
|
);
|
|
})}
|
|
{getAllQueryResult.isPreviousData && (
|
|
<Flex
|
|
zIndex="above"
|
|
position="absolute"
|
|
top={0}
|
|
bottom={0}
|
|
left={0}
|
|
right={0}
|
|
backdropFilter="blur(5px)"
|
|
bg="blackAlpha.100"
|
|
_dark={{ bg: "whiteAlpha.50" }}
|
|
borderRadius="md"
|
|
align="flex-end"
|
|
justify="center"
|
|
p={8}
|
|
>
|
|
<Flex align="center" gap={4}>
|
|
<Spinner size="sm" />
|
|
<Heading size="label.lg">Fetching new page</Heading>
|
|
</Flex>
|
|
</Flex>
|
|
)}
|
|
</Tbody>
|
|
</Table>
|
|
</Card>
|
|
<Center w="100%">
|
|
<Flex gap={2} direction="row" align="center">
|
|
<IconButton
|
|
isDisabled={!canPreviousPage || getAllQueryResult.isLoading}
|
|
aria-label="first page"
|
|
icon={<Icon as={MdFirstPage} />}
|
|
onClick={() => gotoPage(0)}
|
|
/>
|
|
<IconButton
|
|
isDisabled={!canPreviousPage || getAllQueryResult.isLoading}
|
|
aria-label="previous page"
|
|
icon={<Icon as={MdNavigateBefore} />}
|
|
onClick={() => previousPage()}
|
|
/>
|
|
<Text whiteSpace="nowrap">
|
|
Page <strong>{pageIndex + 1}</strong> of{" "}
|
|
<Skeleton
|
|
as="span"
|
|
display="inline"
|
|
isLoaded={getAllQueryResult.isSuccess}
|
|
>
|
|
<strong>{pageCount}</strong>
|
|
</Skeleton>
|
|
</Text>
|
|
<IconButton
|
|
isDisabled={!canNextPage || getAllQueryResult.isLoading}
|
|
aria-label="next page"
|
|
icon={<Icon as={MdNavigateNext} />}
|
|
onClick={() => nextPage()}
|
|
/>
|
|
<IconButton
|
|
isDisabled={!canNextPage || getAllQueryResult.isLoading}
|
|
aria-label="last page"
|
|
icon={<Icon as={MdLastPage} />}
|
|
onClick={() => gotoPage(pageCount - 1)}
|
|
/>
|
|
|
|
<Select
|
|
onChange={(e) => {
|
|
setPageSize(parseInt(e.target.value as string, 10));
|
|
}}
|
|
value={pageSize}
|
|
isDisabled={getAllQueryResult.isLoading}
|
|
>
|
|
<option value="25">25</option>
|
|
<option value="50">50</option>
|
|
<option value="100">100</option>
|
|
<option value="250">250</option>
|
|
<option value="500">500</option>
|
|
</Select>
|
|
</Flex>
|
|
</Center>
|
|
</Flex>
|
|
);
|
|
};
|