Update Base Minter creation process

This commit is contained in:
Serkan Reis 2022-12-15 14:59:05 +03:00
parent eab5a4a36c
commit 2ee9f1e73d
3 changed files with 48 additions and 8 deletions

View File

@ -50,7 +50,7 @@ export const CollectionQueries = ({
const address = addressState.value
const showTokenIdField = type === 'token_info'
const showAddressField = type === 'tokens_minted_to_user'
const showAddressField = type === 'tokens_minted_to_user' || type === 'tokens'
const { data: response } = useQuery(
[sg721Messages, baseMinterMessages, vendingMinterMessages, type, tokenId, address] as const,

View File

@ -9,6 +9,7 @@ export const QUERY_TYPES = [
'mint_price',
'num_tokens',
'tokens_minted_to_user',
'tokens',
// 'token_owners',
'token_info',
'config',
@ -70,7 +71,7 @@ export const BASE_QUERY_LIST: QueryListItem[] = [
description: `Get information about the collection.`,
},
{
id: 'tokens_minted_to_user',
id: 'tokens',
name: 'Tokens Minted to User',
description: `Get the number of tokens minted in the collection to a user.`,
},
@ -108,6 +109,7 @@ export type DispatchQueryArgs = {
| { type: Select<'mint_price'> }
| { type: Select<'num_tokens'> }
| { type: Select<'tokens_minted_to_user'>; address: string }
| { type: Select<'tokens'>; address: string }
// | { type: Select<'token_owners'> }
| { type: Select<'token_info'>; tokenId: string }
| { type: Select<'config'> }
@ -132,6 +134,9 @@ export const dispatchQuery = async (args: DispatchQueryArgs) => {
case 'tokens_minted_to_user': {
return vendingMinterMessages.getMintCount(args.address)
}
case 'tokens': {
return sg721Messages.tokens(args.address)
}
// case 'token_owners': {
// return vendingMinterMessages.updateStartTime(txSigner, args.startTime)
// }

View File

@ -241,7 +241,10 @@ const CollectionCreationPage: NextPage = () => {
setBaseTokenUri(baseUri)
setCoverImageUrl(coverImageUri)
await instantiateBaseMinter(baseUri, coverImageUri)
await instantiateBaseMinter(
`ipfs://${baseUri}/${uploadDetails.metadataFiles[0].name.split('.')[0]}`,
coverImageUri,
)
} else {
setBaseTokenUri(uploadDetails?.baseTokenURI as string)
setCoverImageUrl(uploadDetails?.imageUrl as string)
@ -398,6 +401,7 @@ const CollectionCreationPage: NextPage = () => {
const instantiateBaseMinter = async (baseUri: string, coverImageUri: string) => {
if (!wallet.initialized) throw new Error('Wallet not connected')
if (!baseFactoryContract) throw new Error('Contract not found')
if (!baseMinterContract) throw new Error('Contract not found')
let royaltyInfo = null
if (royaltyDetails?.royaltyType === 'new') {
@ -438,10 +442,37 @@ const CollectionCreationPage: NextPage = () => {
msg,
funds: [coin('1000000000', 'ustars')],
}
const data = await baseFactoryDispatchExecute(payload)
await baseFactoryDispatchExecute(payload)
.then(async (data) => {
setTransactionHash(data.transactionHash)
setVendingMinterContractAddress(data.baseMinterAddress)
setSg721ContractAddress(data.sg721Address)
await toast
.promise(
baseMinterContract
.use(data.baseMinterAddress)
?.mint(wallet.address, baseUri) as Promise<string>,
{
loading: 'Minting token...',
success: (result) => `Token minted successfully! Tx Hash: ${result}`,
error: (error) => `Failed to mint token: ${error.message}`,
},
{ style: { maxWidth: 'none' } },
)
.catch((error) => {
toast.error(error.message, { style: { maxWidth: 'none' } })
setUploading(false)
setCreatingCollection(false)
})
setUploading(false)
setCreatingCollection(false)
})
.catch((error) => {
toast.error(error.message, { style: { maxWidth: 'none' } })
setUploading(false)
setCreatingCollection(false)
})
}
const uploadFiles = async (): Promise<string> => {
@ -690,7 +721,11 @@ const CollectionCreationPage: NextPage = () => {
<Anchor
className="text-stargaze hover:underline"
external
href={`/contracts/vendingMinter/query/?contractAddress=${vendingMinterContractAddress as string}`}
href={
minterType === 'vending'
? `/contracts/vendingMinter/query/?contractAddress=${vendingMinterContractAddress as string}`
: `/contracts/baseMinter/query/?contractAddress=${vendingMinterContractAddress as string}`
}
>
{vendingMinterContractAddress}
</Anchor>