Merge pull request #274 from public-awesome/wl-easy-access
Include easy access to whitelists on My Collections
This commit is contained in:
commit
6ab7d4017b
@ -1,5 +1,6 @@
|
|||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { Anchor } from 'components/Anchor'
|
import { Anchor } from 'components/Anchor'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
export interface LinkTabProps {
|
export interface LinkTabProps {
|
||||||
title: string
|
title: string
|
||||||
@ -11,6 +12,10 @@ export interface LinkTabProps {
|
|||||||
export const LinkTab = (props: LinkTabProps) => {
|
export const LinkTab = (props: LinkTabProps) => {
|
||||||
const { title, description, href, isActive } = props
|
const { title, description, href, isActive } = props
|
||||||
|
|
||||||
|
// get contract address from the router
|
||||||
|
const router = useRouter()
|
||||||
|
const { contractAddress } = router.query
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Anchor
|
<Anchor
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@ -19,7 +24,7 @@ export const LinkTab = (props: LinkTabProps) => {
|
|||||||
isActive ? 'border-plumbus' : 'border-transparent',
|
isActive ? 'border-plumbus' : 'border-transparent',
|
||||||
isActive ? 'bg-plumbus/5 hover:bg-plumbus/10' : 'hover:bg-white/5',
|
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>
|
<h4 className="font-bold">{title}</h4>
|
||||||
<span className="text-sm text-white/80 line-clamp-2">{description}</span>
|
<span className="text-sm text-white/80 line-clamp-2">{description}</span>
|
||||||
|
@ -14,7 +14,7 @@ import { Tooltip } from 'components/Tooltip'
|
|||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
import { NextSeo } from 'next-seo'
|
import { NextSeo } from 'next-seo'
|
||||||
import { useCallback, useEffect, useState } from 'react'
|
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 { copy } from 'utils/clipboard'
|
||||||
import { API_URL, STARGAZE_URL } from 'utils/constants'
|
import { API_URL, STARGAZE_URL } from 'utils/constants'
|
||||||
import { withMetadata } from 'utils/layout'
|
import { withMetadata } from 'utils/layout'
|
||||||
@ -48,10 +48,16 @@ const CollectionList: NextPage = () => {
|
|||||||
if (myCollections.length > 0) {
|
if (myCollections.length > 0) {
|
||||||
myCollections.map(async (collection: any) => {
|
myCollections.map(async (collection: any) => {
|
||||||
await getMinterContractType(collection.minter)
|
await getMinterContractType(collection.minter)
|
||||||
.then((contractType) => {
|
.then(async (contractType) => {
|
||||||
if (contractType?.includes('sg-base-minter')) {
|
if (contractType?.includes('sg-base-minter')) {
|
||||||
setMyOneOfOneCollections((prevState) => [...prevState, collection])
|
setMyOneOfOneCollections((prevState) => [...prevState, collection])
|
||||||
} else if (contractType?.includes('sg-minter') || contractType?.includes('flex')) {
|
} 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])
|
setMyStandardCollections((prevState) => [...prevState, collection])
|
||||||
} else if (contractType?.includes('open-edition')) {
|
} else if (contractType?.includes('open-edition')) {
|
||||||
setMyOpenEditionCollections((prevState) => [...prevState, collection])
|
setMyOpenEditionCollections((prevState) => [...prevState, collection])
|
||||||
@ -171,6 +177,31 @@ const CollectionList: NextPage = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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>
|
</td>
|
||||||
<th className="bg-black">
|
<th className="bg-black">
|
||||||
<div className="flex items-center space-x-8">
|
<div className="flex items-center space-x-8">
|
||||||
@ -187,6 +218,14 @@ const CollectionList: NextPage = () => {
|
|||||||
>
|
>
|
||||||
<FaRocket />
|
<FaRocket />
|
||||||
</Anchor>
|
</Anchor>
|
||||||
|
<Conditional test={collection.whitelist}>
|
||||||
|
<Anchor
|
||||||
|
className="text-xl text-white"
|
||||||
|
href={`/contracts/whitelist/execute/?contractAddress=${collection.whitelist}`}
|
||||||
|
>
|
||||||
|
<FaList />
|
||||||
|
</Anchor>
|
||||||
|
</Conditional>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -489,6 +489,9 @@ const BadgeHubExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ const BadgeHubMigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -116,6 +116,9 @@ const BadgeHubQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -96,6 +96,9 @@ const BaseMinterExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -81,6 +81,9 @@ const BaseMinterMigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -68,6 +68,9 @@ const BaseMinterQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -188,6 +188,9 @@ const OpenEditionMinterExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -81,6 +81,9 @@ const OpenEditionMinterMigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -73,6 +73,9 @@ const OpenEditionMinterQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -141,6 +141,9 @@ const Sg721ExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -81,6 +81,9 @@ const Sg721MigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -85,6 +85,9 @@ const Sg721QueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -89,6 +89,9 @@ const SplitsExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -82,6 +82,9 @@ const SplitsMigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -99,6 +99,9 @@ const SplitsQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -196,6 +196,9 @@ const VendingMinterExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -81,6 +81,9 @@ const VendingMinterMigratePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -73,6 +73,9 @@ const VendingMinterQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -168,6 +168,9 @@ const WhitelistExecutePage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
|
|
||||||
|
@ -115,6 +115,9 @@ const WhitelistQueryPage: NextPage = () => {
|
|||||||
if (contractAddress.length > 0) {
|
if (contractAddress.length > 0) {
|
||||||
void router.replace({ query: { contractAddress } })
|
void router.replace({ query: { contractAddress } })
|
||||||
}
|
}
|
||||||
|
if (contractAddress.length === 0) {
|
||||||
|
void router.replace({ query: {} })
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [contractAddress])
|
}, [contractAddress])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user