From 9972e0617ae3ad01b82e50122e50fcd9298f66b3 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 3 Apr 2023 12:39:59 +0300 Subject: [PATCH 1/4] Update My Collections for 1/1 Collections --- pages/collections/myCollections.tsx | 301 ++++++++++++++++++++++------ 1 file changed, 238 insertions(+), 63 deletions(-) diff --git a/pages/collections/myCollections.tsx b/pages/collections/myCollections.tsx index d1f8a58..3d50809 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 (
From e1707c1ab55e98fd55f6dcde40d99e0a88c04414 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 3 Apr 2023 12:40:33 +0300 Subject: [PATCH 2/4] Update collection creation summary for 1/1 Collections --- pages/collections/create.tsx | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index a85ecaf..5883d77 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -1063,15 +1063,28 @@ const CollectionCreationPage: NextPage = () => { {transactionHash} - + + + + + + From 86f38b028b07fb0cc14167ae5c0e9929db10141d Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 3 Apr 2023 12:41:15 +0300 Subject: [PATCH 3/4] Bump Studio version --- .env.example | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/*" ], From 99a03d4a7be07b2fe6b4b0712e0eb9bbc880f485 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Mon, 3 Apr 2023 12:58:53 +0300 Subject: [PATCH 4/4] Remove the horizontal scrollbar from My Collections --- pages/collections/myCollections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/collections/myCollections.tsx b/pages/collections/myCollections.tsx index 3d50809..852dc6c 100644 --- a/pages/collections/myCollections.tsx +++ b/pages/collections/myCollections.tsx @@ -79,7 +79,7 @@ const CollectionList: NextPage = () => { const renderTable = useCallback(() => { return ( -
+
{myCollections.length > 0 && (
{myStandardCollections.length > 0 && (