-
+
{showAddressField &&
}
{showTokenIdField &&
}
diff --git a/components/collections/queries/query.ts b/components/collections/queries/query.ts
index ad1482b..37b041b 100644
--- a/components/collections/queries/query.ts
+++ b/components/collections/queries/query.ts
@@ -1,3 +1,4 @@
+import type { BaseMinterInstance } from 'contracts/baseMinter'
import type { SG721Instance } from 'contracts/sg721'
import type { VendingMinterInstance } from 'contracts/vendingMinter'
@@ -10,6 +11,8 @@ export const QUERY_TYPES = [
'tokens_minted_to_user',
// 'token_owners',
'token_info',
+ 'config',
+ 'status',
] as const
export interface QueryListItem {
@@ -18,7 +21,7 @@ export interface QueryListItem {
description?: string
}
-export const QUERY_LIST: QueryListItem[] = [
+export const VENDING_QUERY_LIST: QueryListItem[] = [
{
id: 'collection_info',
name: 'Collection Info',
@@ -49,6 +52,43 @@ export const QUERY_LIST: QueryListItem[] = [
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 const BASE_QUERY_LIST: QueryListItem[] = [
+ {
+ id: 'collection_info',
+ name: 'Collection Info',
+ description: `Get information about the collection.`,
+ },
+ {
+ id: 'tokens_minted_to_user',
+ name: 'Tokens Minted to User',
+ description: `Get the number of tokens minted in the collection to a user.`,
+ },
+ {
+ 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 {
@@ -59,6 +99,7 @@ export interface DispatchExecuteProps {
type Select
= T
export type DispatchQueryArgs = {
+ baseMinterMessages?: BaseMinterInstance
vendingMinterMessages?: VendingMinterInstance
sg721Messages?: SG721Instance
} & (
@@ -69,11 +110,13 @@ export type DispatchQueryArgs = {
| { type: Select<'tokens_minted_to_user'>; address: string }
// | { type: Select<'token_owners'> }
| { type: Select<'token_info'>; tokenId: string }
+ | { type: Select<'config'> }
+ | { type: Select<'status'> }
)
export const dispatchQuery = async (args: DispatchQueryArgs) => {
- const { vendingMinterMessages, sg721Messages } = args
- if (!vendingMinterMessages || !sg721Messages) {
+ const { baseMinterMessages, vendingMinterMessages, sg721Messages } = args
+ if (!baseMinterMessages || !vendingMinterMessages || !sg721Messages) {
throw new Error('Cannot execute actions')
}
switch (args.type) {
@@ -96,6 +139,12 @@ export const dispatchQuery = async (args: DispatchQueryArgs) => {
if (!args.tokenId) return
return sg721Messages.allNftInfo(args.tokenId)
}
+ case 'config': {
+ return baseMinterMessages.getConfig()
+ }
+ case 'status': {
+ return baseMinterMessages.getStatus()
+ }
default: {
throw new Error('Unknown action')
}
diff --git a/pages/collections/actions.tsx b/pages/collections/actions.tsx
index d6ce4b5..0250853 100644
--- a/pages/collections/actions.tsx
+++ b/pages/collections/actions.tsx
@@ -1,3 +1,4 @@
+import { toUtf8 } from '@cosmjs/encoding'
import { CollectionActions } from 'components/collections/actions/Action'
import { CollectionQueries } from 'components/collections/queries/Queries'
import { ContractPageHeader } from 'components/ContractPageHeader'
@@ -9,14 +10,19 @@ import type { NextPage } from 'next'
import { useRouter } from 'next/router'
import { NextSeo } from 'next-seo'
import { useEffect, useMemo, useState } from 'react'
+import toast from 'react-hot-toast'
+import { useDebounce } from 'utils/debounce'
import { withMetadata } from 'utils/layout'
import { links } from 'utils/links'
+import type { MinterType } from '../../components/collections/actions/Combobox'
+
const CollectionActionsPage: NextPage = () => {
- const { vendingMinter: vendingMinterContract, sg721: sg721Contract } = useContracts()
+ const { baseMinter: baseMinterContract, vendingMinter: vendingMinterContract, sg721: sg721Contract } = useContracts()
const wallet = useWallet()
const [action, setAction] = useState(false)
+ const [minterType, setMinterType] = useState('vending')
const sg721ContractState = useInputState({
id: 'sg721-contract-address',
@@ -32,10 +38,16 @@ const CollectionActionsPage: NextPage = () => {
subtitle: 'Address of the Minter contract',
})
+ const debouncedMinterContractState = useDebounce(minterContractState.value, 300)
+
const vendingMinterMessages = useMemo(
() => vendingMinterContract?.use(minterContractState.value),
[vendingMinterContract, minterContractState.value],
)
+ const baseMinterMessages = useMemo(
+ () => baseMinterContract?.use(minterContractState.value),
+ [baseMinterContract, minterContractState.value],
+ )
const sg721Messages = useMemo(
() => sg721Contract?.use(sg721ContractState.value),
[sg721Contract, sg721ContractState.value],
@@ -66,6 +78,41 @@ const CollectionActionsPage: NextPage = () => {
if (initialSg721 && initialSg721.length > 0) sg721ContractState.onChange(initialSg721)
}, [])
+ useEffect(() => {
+ async function getMinterContractType() {
+ if (wallet.client && debouncedMinterContractState.length > 0) {
+ const client = wallet.client
+ const data = await toast.promise(
+ client.queryContractRaw(
+ debouncedMinterContractState,
+ toUtf8(Buffer.from(Buffer.from('contract_info').toString('hex'), 'hex').toString()),
+ ),
+ {
+ loading: 'Retrieving Minter type...',
+ error: 'Minter type retrieval failed.',
+ success: 'Minter type retrieved.',
+ },
+ )
+ const contract: string = JSON.parse(new TextDecoder().decode(data as Uint8Array)).contract
+ console.log(contract)
+ return contract
+ }
+ }
+ void getMinterContractType()
+ .then((contract) => {
+ if (contract?.includes('sg-base-minter')) {
+ setMinterType('base')
+ } else {
+ setMinterType('vending')
+ }
+ })
+ .catch((err) => {
+ console.log(err)
+ setMinterType('vending')
+ console.log('Unable to retrieve contract version')
+ })
+ }, [debouncedMinterContractState, wallet.address])
+
return (
@@ -124,18 +171,23 @@ const CollectionActionsPage: NextPage = () => {
{(action && (
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
)) || (
)}
diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx
index 730e99f..aa9528d 100644
--- a/pages/collections/create.tsx
+++ b/pages/collections/create.tsx
@@ -456,7 +456,7 @@ const CollectionCreationPage: NextPage = () => {