Merge pull request #274 from public-awesome/wl-easy-access

Include easy access to whitelists on My Collections
This commit is contained in:
Serkan Reis 2023-11-20 23:18:34 +03:00 committed by GitHub
commit 6ab7d4017b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 107 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import clsx from 'clsx'
import { Anchor } from 'components/Anchor'
import { useRouter } from 'next/router'
export interface LinkTabProps {
title: string
@ -11,6 +12,10 @@ export interface LinkTabProps {
export const LinkTab = (props: LinkTabProps) => {
const { title, description, href, isActive } = props
// get contract address from the router
const router = useRouter()
const { contractAddress } = router.query
return (
<Anchor
className={clsx(
@ -19,7 +24,7 @@ export const LinkTab = (props: LinkTabProps) => {
isActive ? 'border-plumbus' : 'border-transparent',
isActive ? 'bg-plumbus/5 hover:bg-plumbus/10' : 'hover:bg-white/5',
)}
href={href}
href={href + (contractAddress ? `?contractAddress=${contractAddress as string}` : '')}
>
<h4 className="font-bold">{title}</h4>
<span className="text-sm text-white/80 line-clamp-2">{description}</span>

View File

@ -14,7 +14,7 @@ import { Tooltip } from 'components/Tooltip'
import type { NextPage } from 'next'
import { NextSeo } from 'next-seo'
import { useCallback, useEffect, useState } from 'react'
import { FaCopy, FaRocket, FaSlidersH, FaStore } from 'react-icons/fa'
import { FaCopy, FaList, 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'
@ -48,10 +48,16 @@ const CollectionList: NextPage = () => {
if (myCollections.length > 0) {
myCollections.map(async (collection: any) => {
await getMinterContractType(collection.minter)
.then((contractType) => {
.then(async (contractType) => {
if (contractType?.includes('sg-base-minter')) {
setMyOneOfOneCollections((prevState) => [...prevState, collection])
} else if (contractType?.includes('sg-minter') || contractType?.includes('flex')) {
const minterConfig = await (await wallet.getCosmWasmClient())
.queryContractSmart(collection.minter, { config: {} })
.catch(() => {
console.log('Unable to retrieve minter config')
})
if (minterConfig?.whitelist) collection.whitelist = minterConfig.whitelist
setMyStandardCollections((prevState) => [...prevState, collection])
} else if (contractType?.includes('open-edition')) {
setMyOpenEditionCollections((prevState) => [...prevState, collection])
@ -171,6 +177,31 @@ const CollectionList: NextPage = () => {
</Tooltip>
</span>
</div>
<Conditional test={collection.whitelist}>
<div className="flex flex-row items-center space-x-3">
Whitelist:
<span className="ml-2">
<Tooltip
backgroundColor="bg-blue-500"
label="Click to copy the whitelist contract address"
>
<button
className="group flex space-x-2 font-mono text-base text-white/80 hover:underline"
onClick={() => void copy(collection.whitelist as string)}
type="button"
>
<span>
{truncateMiddle(
collection.whitelist ? (collection.whitelist as string) : '',
36,
)}
</span>
<FaCopy className="opacity-0 group-hover:opacity-100" />
</button>
</Tooltip>
</span>
</div>
</Conditional>
</td>
<th className="bg-black">
<div className="flex items-center space-x-8">
@ -187,6 +218,14 @@ const CollectionList: NextPage = () => {
>
<FaRocket />
</Anchor>
<Conditional test={collection.whitelist}>
<Anchor
className="text-xl text-white"
href={`/contracts/whitelist/execute/?contractAddress=${collection.whitelist}`}
>
<FaList />
</Anchor>
</Conditional>
</div>
</th>
</tr>

View File

@ -489,6 +489,9 @@ const BadgeHubExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])

View File

@ -81,6 +81,9 @@ const BadgeHubMigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -116,6 +116,9 @@ const BadgeHubQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -96,6 +96,9 @@ const BaseMinterExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -81,6 +81,9 @@ const BaseMinterMigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -68,6 +68,9 @@ const BaseMinterQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -188,6 +188,9 @@ const OpenEditionMinterExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -81,6 +81,9 @@ const OpenEditionMinterMigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -73,6 +73,9 @@ const OpenEditionMinterQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -141,6 +141,9 @@ const Sg721ExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -81,6 +81,9 @@ const Sg721MigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -85,6 +85,9 @@ const Sg721QueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -89,6 +89,9 @@ const SplitsExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -82,6 +82,9 @@ const SplitsMigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -99,6 +99,9 @@ const SplitsQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -196,6 +196,9 @@ const VendingMinterExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -81,6 +81,9 @@ const VendingMinterMigratePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -73,6 +73,9 @@ const VendingMinterQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {

View File

@ -168,6 +168,9 @@ const WhitelistExecutePage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])

View File

@ -115,6 +115,9 @@ const WhitelistQueryPage: NextPage = () => {
if (contractAddress.length > 0) {
void router.replace({ query: { contractAddress } })
}
if (contractAddress.length === 0) {
void router.replace({ query: {} })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress])
useEffect(() => {