Skip to content

Commit

Permalink
removed gating tokens from display
Browse files Browse the repository at this point in the history
  • Loading branch information
tenfinney committed May 18, 2022
1 parent ef2b103 commit a7a664c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 26 deletions.
51 changes: 28 additions & 23 deletions packages/ui/components/TokensTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,34 @@ export const TokensTable: React.FC<{
</Tr>
</Thead>
<Tbody>
{tokens.map((token: TokenState, index) => (
<Tr key={index}>
<IdTd {...{ token, index }}/>
{(() => {
if(!token.uri && token.error) {
return <ErrorTd {...{ token }}/>
}
if(!token.metadata) {
return <LoadingTd {...{ token }}/>
}
return (
<>
<ImageTd {...{ token }}/>
<DescriptionTd {...{ token }}/>
<LinkTd {...{ token }}/>
</>
)
})()}
{token.uri && <URITd {...{ token }}/>}
<TotalTd {...{ token }}/>
<ActionsTd {...{ token }}/>
</Tr>
))}
{tokens.map((token: TokenState, index) => {
if(token.gating) {
return null
}
return (
<Tr key={index}>
<IdTd {...{ token, index }}/>
{(() => {
if(!token.uri && token.error) {
return <ErrorTd {...{ token }}/>
}
if(!token.metadata) {
return <LoadingTd {...{ token }}/>
}
return (
<>
<ImageTd {...{ token }}/>
<DescriptionTd {...{ token }}/>
<LinkTd {...{ token }}/>
</>
)
})()}
{token.uri && <URITd {...{ token }}/>}
<TotalTd {...{ token }}/>
<ActionsTd {...{ token }}/>
</Tr>
)
})}
</Tbody>
</Table>
)
Expand Down
24 changes: 21 additions & 3 deletions packages/ui/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import { httpURL } from 'lib/helpers'
import type { Maybe, ERC1155Metadata, TokenState } from 'lib/types'
import { Header, TokensTable } from 'components'
import { useWeb3 } from 'lib/hooks'
import { useRouter } from 'next/router'

const Home: NextPage = () => {
const [tokens, setTokens] = useState<Array<TokenState>>([])
const { query: { gating = false } } = useRouter()
const [gatingVisible, setGatingVisible] = useState(!!gating)
console.log({gating, gatingVisible})
const { roContract } = useWeb3()

const setToken = (index: number, info: Record<string, unknown>) => {
Expand All @@ -34,16 +38,30 @@ const Home: NextPage = () => {
const tokens = await Promise.all(
Array.from({ length: typeCount }).map(
async (_, index) => {
const id = (await roContract.tokenByIndex(index + 1)).toHexString()
return { id }
const id = (await roContract.tokenByIndex(index + 1))
const GATING_TYPE = await roContract.GATING_TYPE()
const TYPE_WIDTH = await roContract.TYPE_WIDTH()
const TYPE_BOUNDARY = await roContract.TYPE_BOUNDARY()
const gating = (
!gatingVisible
&& (
(id.toBigInt() & ((BigInt(2**TYPE_WIDTH - 1)) << BigInt(TYPE_BOUNDARY)))
=== GATING_TYPE.toBigInt()
)
)

return { id: id.toHexString(), gating }
}
)
)

setTokens(tokens)

await Promise.all(
tokens.map(async ({ id }, index) => {
tokens.map(async ({ id, gating }, index) => {
if(gating) {
return null
}
let metadata = null
try {
let uri = await roContract.uri(id)
Expand Down

0 comments on commit a7a664c

Please sign in to comment.