diff --git a/.env.example b/.env.example index 9a6492a..2ec7b68 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_VERSION=0.5.4 +APP_VERSION=0.5.5 NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS NEXT_PUBLIC_SG721_CODE_ID=1911 diff --git a/package.json b/package.json index 23c1db2..6df1269 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stargaze-studio", - "version": "0.5.4", + "version": "0.5.5", "workspaces": [ "packages/*" ], diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index a85ecaf..6534d8a 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -1063,15 +1063,28 @@ const CollectionCreationPage: NextPage = () => { {transactionHash} - + + + + + + diff --git a/pages/collections/myCollections.tsx b/pages/collections/myCollections.tsx index d1f8a58..852dc6c 100644 --- a/pages/collections/myCollections.tsx +++ b/pages/collections/myCollections.tsx @@ -4,16 +4,19 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ +import { toUtf8 } from '@cosmjs/encoding' import axios from 'axios' import { Alert } from 'components/Alert' import { Anchor } from 'components/Anchor' import { Conditional } from 'components/Conditional' import { ContractPageHeader } from 'components/ContractPageHeader' +import { Tooltip } from 'components/Tooltip' import { useWallet } from 'contexts/wallet' import type { NextPage } from 'next' import { NextSeo } from 'next-seo' import { useCallback, useEffect, useState } from 'react' -import { FaRocket, FaSlidersH } from 'react-icons/fa' +import { FaCopy, FaRocket, FaSlidersH, FaStore } from 'react-icons/fa' +import { copy } from 'utils/clipboard' import { API_URL, STARGAZE_URL } from 'utils/constants' import { withMetadata } from 'utils/layout' import { links } from 'utils/links' @@ -21,6 +24,41 @@ import { links } from 'utils/links' const CollectionList: NextPage = () => { const wallet = useWallet() const [myCollections, setMyCollections] = useState([]) + const [myOneOfOneCollections, setMyOneOfOneCollections] = useState([]) + const [myStandardCollections, setMyStandardCollections] = useState([]) + + async function getMinterContractType(minterContractAddress: string) { + if (wallet.client && minterContractAddress.length > 0) { + const client = wallet.client + const data = await client.queryContractRaw( + minterContractAddress, + toUtf8(Buffer.from(Buffer.from('contract_info').toString('hex'), 'hex').toString()), + ) + const contractType: string = JSON.parse(new TextDecoder().decode(data as Uint8Array)).contract + return contractType + } + } + + const filterMyCollections = () => { + setMyOneOfOneCollections([]) + setMyStandardCollections([]) + if (myCollections.length > 0) { + myCollections.map(async (collection: any) => { + await getMinterContractType(collection.minter) + .then((contractType) => { + if (contractType?.includes('sg-base-minter')) { + setMyOneOfOneCollections((prevState) => [...prevState, collection]) + } else if (contractType?.includes('sg-minter')) { + setMyStandardCollections((prevState) => [...prevState, collection]) + } + }) + .catch((err) => { + console.log(err) + console.log('Unable to retrieve contract type') + }) + }) + } + } useEffect(() => { const fetchCollections = async () => { @@ -35,76 +73,213 @@ const CollectionList: NextPage = () => { fetchCollections().catch(console.error) }, [wallet.address]) + useEffect(() => { + filterMyCollections() + }, [myCollections]) + const renderTable = useCallback(() => { return ( -
+
{myCollections.length > 0 && ( - - - - - - - - - {myCollections.map((collection: any, index: any) => { - return ( - - - - + + ) + })} + +
Collection NameContract Address -
-
-
-
- Cover -
-
-
-

{collection.name}

-

{collection.description}

-
-
-
- {collection.contractAddress} - {/*
*/} - {/* */} -
-
- - - +
+ {myStandardCollections.length > 0 && ( +
+ Standard Collections + + + + + + + + + {myStandardCollections.map((collection: any, index: any) => { + return ( + + + + + + ) + })} + +
Collection NameContract Address +
+
+
+
+ Cover +
+
+
+

{collection.name}

+

{collection.description}

+
+
+
+
+ Minter: + + + + + +
+
+ SG721: + + + + + +
+
+
+ + + + + + +
+
+
+ )} + {myOneOfOneCollections.length > 0 && ( +
+ 1/1 Collections + + + + + + + + + {myOneOfOneCollections.map((collection: any, index: any) => { + return ( + + + + - - ) - })} - -
Collection NameContract Address +
+
+
+
+ Cover +
+
+
+

{collection.name}

+

{collection.description}

+
+
+
+
+ Minter: + + + + + +
+
+ SG721: + + + + + +
+
+
+ + + - - - -
-
+ + + +
+
+
+ )} +
)} ) - }, [myCollections, wallet.address]) + }, [myCollections, myStandardCollections, myOneOfOneCollections, wallet.address]) return (