Include open edition minter queries in Collection Actions > Queries
This commit is contained in:
parent
6b89a60216
commit
5044aedee4
@ -7,7 +7,7 @@ import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
||||
|
||||
import type { MinterType } from '../actions/Combobox'
|
||||
import type { QueryListItem } from './query'
|
||||
import { BASE_QUERY_LIST, VENDING_QUERY_LIST } from './query'
|
||||
import { BASE_QUERY_LIST, OPEN_EDITION_QUERY_LIST, VENDING_QUERY_LIST } from './query'
|
||||
|
||||
export interface QueryComboboxProps {
|
||||
value: QueryListItem | null
|
||||
@ -22,6 +22,8 @@ export const QueryCombobox = ({ value, onChange, minterType }: QueryComboboxProp
|
||||
useEffect(() => {
|
||||
if (minterType === 'base') {
|
||||
SET_QUERY_LIST(BASE_QUERY_LIST)
|
||||
} else if (minterType === 'openEdition') {
|
||||
SET_QUERY_LIST(OPEN_EDITION_QUERY_LIST)
|
||||
} else {
|
||||
SET_QUERY_LIST(VENDING_QUERY_LIST)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import { AddressInput, TextInput } from 'components/forms/FormInput'
|
||||
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||
import { JsonPreview } from 'components/JsonPreview'
|
||||
import type { BaseMinterInstance } from 'contracts/baseMinter'
|
||||
import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter'
|
||||
import type { SG721Instance } from 'contracts/sg721'
|
||||
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||
import { toast } from 'react-hot-toast'
|
||||
@ -21,6 +22,7 @@ interface CollectionQueriesProps {
|
||||
sg721Messages: SG721Instance | undefined
|
||||
vendingMinterMessages: VendingMinterInstance | undefined
|
||||
baseMinterMessages: BaseMinterInstance | undefined
|
||||
openEditionMinterMessages: OpenEditionMinterInstance | undefined
|
||||
minterType: MinterType
|
||||
}
|
||||
export const CollectionQueries = ({
|
||||
@ -28,6 +30,7 @@ export const CollectionQueries = ({
|
||||
sg721Messages,
|
||||
minterContractAddress,
|
||||
vendingMinterMessages,
|
||||
openEditionMinterMessages,
|
||||
baseMinterMessages,
|
||||
minterType,
|
||||
}: CollectionQueriesProps) => {
|
||||
@ -57,9 +60,25 @@ export const CollectionQueries = ({
|
||||
const showAddressField = type === 'tokens_minted_to_user' || type === 'tokens'
|
||||
|
||||
const { data: response } = useQuery(
|
||||
[sg721Messages, baseMinterMessages, vendingMinterMessages, type, tokenId, address] as const,
|
||||
[
|
||||
sg721Messages,
|
||||
baseMinterMessages,
|
||||
vendingMinterMessages,
|
||||
openEditionMinterMessages,
|
||||
type,
|
||||
tokenId,
|
||||
address,
|
||||
] as const,
|
||||
async ({ queryKey }) => {
|
||||
const [_sg721Messages, _baseMinterMessages_, _vendingMinterMessages, _type, _tokenId, _address] = queryKey
|
||||
const [
|
||||
_sg721Messages,
|
||||
_baseMinterMessages_,
|
||||
_vendingMinterMessages,
|
||||
_openEditionMinterMessages,
|
||||
_type,
|
||||
_tokenId,
|
||||
_address,
|
||||
] = queryKey
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const res = await resolveAddress(_address, wallet).then(async (resolvedAddress) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
@ -67,6 +86,7 @@ export const CollectionQueries = ({
|
||||
tokenId: _tokenId,
|
||||
vendingMinterMessages: _vendingMinterMessages,
|
||||
baseMinterMessages: _baseMinterMessages_,
|
||||
openEditionMinterMessages: _openEditionMinterMessages,
|
||||
sg721Messages: _sg721Messages,
|
||||
address: resolvedAddress,
|
||||
type: _type,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { BaseMinterInstance } from 'contracts/baseMinter'
|
||||
import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter/contract'
|
||||
import type { SG721Instance } from 'contracts/sg721'
|
||||
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||
|
||||
@ -9,6 +10,7 @@ export const QUERY_TYPES = [
|
||||
'mint_price',
|
||||
'num_tokens',
|
||||
'tokens_minted_to_user',
|
||||
'total_mint_count',
|
||||
'tokens',
|
||||
// 'token_owners',
|
||||
'token_info',
|
||||
@ -91,6 +93,48 @@ export const BASE_QUERY_LIST: QueryListItem[] = [
|
||||
description: `Query Minter Status`,
|
||||
},
|
||||
]
|
||||
export const OPEN_EDITION_QUERY_LIST: QueryListItem[] = [
|
||||
{
|
||||
id: 'collection_info',
|
||||
name: 'Collection Info',
|
||||
description: `Get information about the collection.`,
|
||||
},
|
||||
{
|
||||
id: 'mint_price',
|
||||
name: 'Mint Price',
|
||||
description: `Get the price of minting a token.`,
|
||||
},
|
||||
{
|
||||
id: 'tokens_minted_to_user',
|
||||
name: 'Tokens Minted to User',
|
||||
description: `Get the number of tokens minted in the collection to a user.`,
|
||||
},
|
||||
{
|
||||
id: 'total_mint_count',
|
||||
name: 'Total Mint Count',
|
||||
description: `Get the total number of tokens minted for the collection.`,
|
||||
},
|
||||
// {
|
||||
// id: 'token_owners',
|
||||
// name: 'Token Owners',
|
||||
// description: `Get the list of users who own tokens in the collection.`,
|
||||
// },
|
||||
{
|
||||
id: 'token_info',
|
||||
name: 'Token Info',
|
||||
description: `Get information about a token in the collection.`,
|
||||
},
|
||||
{
|
||||
id: 'config',
|
||||
name: 'Minter Config',
|
||||
description: `Query Minter Config`,
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
name: 'Minter Status',
|
||||
description: `Query Minter Status`,
|
||||
},
|
||||
]
|
||||
|
||||
export interface DispatchExecuteProps {
|
||||
type: QueryType
|
||||
@ -102,6 +146,7 @@ type Select<T extends QueryType> = T
|
||||
export type DispatchQueryArgs = {
|
||||
baseMinterMessages?: BaseMinterInstance
|
||||
vendingMinterMessages?: VendingMinterInstance
|
||||
openEditionMinterMessages?: OpenEditionMinterInstance
|
||||
sg721Messages?: SG721Instance
|
||||
} & (
|
||||
| { type: undefined }
|
||||
@ -109,6 +154,7 @@ export type DispatchQueryArgs = {
|
||||
| { type: Select<'mint_price'> }
|
||||
| { type: Select<'num_tokens'> }
|
||||
| { type: Select<'tokens_minted_to_user'>; address: string }
|
||||
| { type: Select<'total_mint_count'> }
|
||||
| { type: Select<'tokens'>; address: string }
|
||||
// | { type: Select<'token_owners'> }
|
||||
| { type: Select<'token_info'>; tokenId: string }
|
||||
@ -117,8 +163,8 @@ export type DispatchQueryArgs = {
|
||||
)
|
||||
|
||||
export const dispatchQuery = async (args: DispatchQueryArgs) => {
|
||||
const { baseMinterMessages, vendingMinterMessages, sg721Messages } = args
|
||||
if (!baseMinterMessages || !vendingMinterMessages || !sg721Messages) {
|
||||
const { baseMinterMessages, vendingMinterMessages, openEditionMinterMessages, sg721Messages } = args
|
||||
if (!baseMinterMessages || !vendingMinterMessages || !openEditionMinterMessages || !sg721Messages) {
|
||||
throw new Error('Cannot execute actions')
|
||||
}
|
||||
switch (args.type) {
|
||||
@ -134,6 +180,9 @@ export const dispatchQuery = async (args: DispatchQueryArgs) => {
|
||||
case 'tokens_minted_to_user': {
|
||||
return vendingMinterMessages.getMintCount(args.address)
|
||||
}
|
||||
case 'total_mint_count': {
|
||||
return openEditionMinterMessages.getTotalMintCount()
|
||||
}
|
||||
case 'tokens': {
|
||||
return sg721Messages.tokens(args.address)
|
||||
}
|
||||
|
@ -237,6 +237,7 @@ const CollectionActionsPage: NextPage = () => {
|
||||
baseMinterMessages={baseMinterMessages}
|
||||
minterContractAddress={minterContractState.value}
|
||||
minterType={minterType}
|
||||
openEditionMinterMessages={openEditionMinterMessages}
|
||||
sg721ContractAddress={sg721ContractState.value}
|
||||
sg721Messages={sg721Messages}
|
||||
vendingMinterMessages={vendingMinterMessages}
|
||||
|
Loading…
Reference in New Issue
Block a user