Implement Base Minter Contract dashboard
This commit is contained in:
parent
b690022655
commit
a8c2548554
@ -1,9 +1,11 @@
|
|||||||
APP_VERSION=0.1.0
|
APP_VERSION=0.2.0
|
||||||
|
|
||||||
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
|
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
|
||||||
NEXT_PUBLIC_SG721_CODE_ID=274
|
NEXT_PUBLIC_SG721_CODE_ID=274
|
||||||
NEXT_PUBLIC_VENDING_MINTER_CODE_ID=275
|
NEXT_PUBLIC_VENDING_MINTER_CODE_ID=275
|
||||||
NEXT_PUBLIC_VENDING_FACTORY_ADDRESS="stars1j4qn9krchp5xs8nued4j4vcr4j654wxkhf7acy76734xe5fsz08sku28s2"
|
NEXT_PUBLIC_VENDING_FACTORY_ADDRESS="stars1j4qn9krchp5xs8nued4j4vcr4j654wxkhf7acy76734xe5fsz08sku28s2"
|
||||||
|
NEXT_PUBLIC_BASE_FACTORY_ADDRESS=""
|
||||||
|
NEXT_PUBLIC_BASE_MINTER_CODE_ID=275
|
||||||
NEXT_PUBLIC_WHITELIST_CODE_ID=277
|
NEXT_PUBLIC_WHITELIST_CODE_ID=277
|
||||||
|
|
||||||
NEXT_PUBLIC_API_URL=https://
|
NEXT_PUBLIC_API_URL=https://
|
||||||
|
@ -18,26 +18,49 @@ export const sg721LinkTabs: LinkTabProps[] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const minterLinkTabs: LinkTabProps[] = [
|
export const vendingMinterLinkTabs: LinkTabProps[] = [
|
||||||
{
|
{
|
||||||
title: 'Instantiate',
|
title: 'Instantiate',
|
||||||
description: `Initialize a new Minter contract`,
|
description: `Initialize a new Vending Minter contract`,
|
||||||
href: '/contracts/minter/instantiate',
|
href: '/contracts/vendingMinter/instantiate',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Query',
|
title: 'Query',
|
||||||
description: `Dispatch queries with your Minter contract`,
|
description: `Dispatch queries with your Vending Minter contract`,
|
||||||
href: '/contracts/minter/query',
|
href: '/contracts/vendingMinter/query',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Execute',
|
title: 'Execute',
|
||||||
description: `Execute Minter contract actions`,
|
description: `Execute Vending Minter contract actions`,
|
||||||
href: '/contracts/minter/execute',
|
href: '/contracts/vendingMinter/execute',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Migrate',
|
title: 'Migrate',
|
||||||
description: `Migrate Minter contract`,
|
description: `Migrate Vending Minter contract`,
|
||||||
href: '/contracts/minter/migrate',
|
href: '/contracts/vendingMinter/migrate',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export const baseMinterLinkTabs: LinkTabProps[] = [
|
||||||
|
{
|
||||||
|
title: 'Instantiate',
|
||||||
|
description: `Initialize a new Base Minter contract`,
|
||||||
|
href: '/contracts/baseMinter/instantiate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Query',
|
||||||
|
description: `Dispatch queries with your Base Minter contract`,
|
||||||
|
href: '/contracts/baseMinter/query',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Execute',
|
||||||
|
description: `Execute Base Minter contract actions`,
|
||||||
|
href: '/contracts/baseMinter/execute',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Migrate',
|
||||||
|
description: `Migrate Base Minter contract`,
|
||||||
|
href: '/contracts/baseMinter/migrate',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ const routes = [
|
|||||||
{ text: 'My Collections', href: `/collections/myCollections/`, isChild: true },
|
{ text: 'My Collections', href: `/collections/myCollections/`, isChild: true },
|
||||||
{ text: 'Collection Actions', href: `/collections/actions/`, isChild: true },
|
{ text: 'Collection Actions', href: `/collections/actions/`, isChild: true },
|
||||||
{ text: 'Contract Dashboards', href: `/contracts/`, isChild: false },
|
{ text: 'Contract Dashboards', href: `/contracts/`, isChild: false },
|
||||||
{ text: 'Minter Contract', href: `/contracts/minter/`, isChild: true },
|
{ text: 'Base Minter Contract', href: `/contracts/baseMinter/`, isChild: true },
|
||||||
|
{ text: 'Vending Minter Contract', href: `/contracts/vendingMinter/`, isChild: true },
|
||||||
{ text: 'SG721 Contract', href: `/contracts/sg721/`, isChild: true },
|
{ text: 'SG721 Contract', href: `/contracts/sg721/`, isChild: true },
|
||||||
{ text: 'Whitelist Contract', href: `/contracts/whitelist/`, isChild: true },
|
{ text: 'Whitelist Contract', href: `/contracts/whitelist/`, isChild: true },
|
||||||
]
|
]
|
||||||
@ -37,9 +38,9 @@ export const Sidebar = () => {
|
|||||||
<Anchor
|
<Anchor
|
||||||
key={href}
|
key={href}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'px-4 -mx-5 font-extrabold uppercase rounded-lg', // styling
|
'px-2 -mx-5 font-extrabold uppercase rounded-lg', // styling
|
||||||
'hover:bg-white/5 transition-colors', // hover styling
|
'hover:bg-white/5 transition-colors', // hover styling
|
||||||
{ 'py-0 ml-2 text-sm font-bold': isChild },
|
{ 'py-0 -ml-2 text-sm font-bold': isChild },
|
||||||
{
|
{
|
||||||
'text-gray hover:text-white':
|
'text-gray hover:text-white':
|
||||||
!router.asPath.substring(0, router.asPath.lastIndexOf('/') + 1).includes(href) && isChild,
|
!router.asPath.substring(0, router.asPath.lastIndexOf('/') + 1).includes(href) && isChild,
|
||||||
|
@ -13,8 +13,8 @@ import { InputDateTime } from 'components/InputDateTime'
|
|||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import { TransactionHash } from 'components/TransactionHash'
|
import { TransactionHash } from 'components/TransactionHash'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { MinterInstance } from 'contracts/minter'
|
|
||||||
import type { SG721Instance } from 'contracts/sg721'
|
import type { SG721Instance } from 'contracts/sg721'
|
||||||
|
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
import type { FormEvent } from 'react'
|
import type { FormEvent } from 'react'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { toast } from 'react-hot-toast'
|
import { toast } from 'react-hot-toast'
|
||||||
@ -29,7 +29,7 @@ interface CollectionActionsProps {
|
|||||||
minterContractAddress: string
|
minterContractAddress: string
|
||||||
sg721ContractAddress: string
|
sg721ContractAddress: string
|
||||||
sg721Messages: SG721Instance | undefined
|
sg721Messages: SG721Instance | undefined
|
||||||
minterMessages: MinterInstance | undefined
|
vendingMinterMessages: VendingMinterInstance | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExplicitContentType = true | false | undefined
|
type ExplicitContentType = true | false | undefined
|
||||||
@ -38,7 +38,7 @@ export const CollectionActions = ({
|
|||||||
sg721ContractAddress,
|
sg721ContractAddress,
|
||||||
sg721Messages,
|
sg721Messages,
|
||||||
minterContractAddress,
|
minterContractAddress,
|
||||||
minterMessages,
|
vendingMinterMessages,
|
||||||
}: CollectionActionsProps) => {
|
}: CollectionActionsProps) => {
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
const [lastTx, setLastTx] = useState('')
|
const [lastTx, setLastTx] = useState('')
|
||||||
@ -169,7 +169,7 @@ export const CollectionActions = ({
|
|||||||
tokenId: tokenIdState.value,
|
tokenId: tokenIdState.value,
|
||||||
tokenIds: tokenIdListState.value,
|
tokenIds: tokenIdListState.value,
|
||||||
batchNumber: batchNumberState.value,
|
batchNumber: batchNumberState.value,
|
||||||
minterMessages,
|
vendingMinterMessages,
|
||||||
sg721Messages,
|
sg721Messages,
|
||||||
recipient: recipientState.value,
|
recipient: recipientState.value,
|
||||||
recipients: airdropArray,
|
recipients: airdropArray,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { MinterInstance } from 'contracts/minter'
|
|
||||||
import { useMinterContract } from 'contracts/minter'
|
|
||||||
import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
|
import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
|
||||||
import { useSG721Contract } from 'contracts/sg721'
|
import { useSG721Contract } from 'contracts/sg721'
|
||||||
|
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
|
import { useVendingMinterContract } from 'contracts/vendingMinter'
|
||||||
|
|
||||||
export type ActionType = typeof ACTION_TYPES[number]
|
export type ActionType = typeof ACTION_TYPES[number]
|
||||||
|
|
||||||
@ -150,11 +150,11 @@ export interface DispatchExecuteProps {
|
|||||||
|
|
||||||
type Select<T extends ActionType> = T
|
type Select<T extends ActionType> = T
|
||||||
|
|
||||||
/** @see {@link MinterInstance} */
|
/** @see {@link VendingMinterInstance} */
|
||||||
export type DispatchExecuteArgs = {
|
export type DispatchExecuteArgs = {
|
||||||
minterContract: string
|
minterContract: string
|
||||||
sg721Contract: string
|
sg721Contract: string
|
||||||
minterMessages?: MinterInstance
|
vendingMinterMessages?: VendingMinterInstance
|
||||||
sg721Messages?: SG721Instance
|
sg721Messages?: SG721Instance
|
||||||
txSigner: string
|
txSigner: string
|
||||||
} & (
|
} & (
|
||||||
@ -183,40 +183,40 @@ export type DispatchExecuteArgs = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||||
const { minterMessages, sg721Messages, txSigner } = args
|
const { vendingMinterMessages, sg721Messages, txSigner } = args
|
||||||
if (!minterMessages || !sg721Messages) {
|
if (!vendingMinterMessages || !sg721Messages) {
|
||||||
throw new Error('Cannot execute actions')
|
throw new Error('Cannot execute actions')
|
||||||
}
|
}
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
case 'mint': {
|
case 'mint': {
|
||||||
return minterMessages.mint(txSigner)
|
return vendingMinterMessages.mint(txSigner)
|
||||||
}
|
}
|
||||||
case 'purge': {
|
case 'purge': {
|
||||||
return minterMessages.purge(txSigner)
|
return vendingMinterMessages.purge(txSigner)
|
||||||
}
|
}
|
||||||
case 'update_mint_price': {
|
case 'update_mint_price': {
|
||||||
return minterMessages.updateMintPrice(txSigner, args.price)
|
return vendingMinterMessages.updateMintPrice(txSigner, args.price)
|
||||||
}
|
}
|
||||||
case 'mint_to': {
|
case 'mint_to': {
|
||||||
return minterMessages.mintTo(txSigner, args.recipient)
|
return vendingMinterMessages.mintTo(txSigner, args.recipient)
|
||||||
}
|
}
|
||||||
case 'mint_for': {
|
case 'mint_for': {
|
||||||
return minterMessages.mintFor(txSigner, args.recipient, args.tokenId)
|
return vendingMinterMessages.mintFor(txSigner, args.recipient, args.tokenId)
|
||||||
}
|
}
|
||||||
case 'batch_mint': {
|
case 'batch_mint': {
|
||||||
return minterMessages.batchMint(txSigner, args.recipient, args.batchNumber)
|
return vendingMinterMessages.batchMint(txSigner, args.recipient, args.batchNumber)
|
||||||
}
|
}
|
||||||
case 'set_whitelist': {
|
case 'set_whitelist': {
|
||||||
return minterMessages.setWhitelist(txSigner, args.whitelist)
|
return vendingMinterMessages.setWhitelist(txSigner, args.whitelist)
|
||||||
}
|
}
|
||||||
case 'update_start_time': {
|
case 'update_start_time': {
|
||||||
return minterMessages.updateStartTime(txSigner, args.startTime)
|
return vendingMinterMessages.updateStartTime(txSigner, args.startTime)
|
||||||
}
|
}
|
||||||
case 'update_start_trading_time': {
|
case 'update_start_trading_time': {
|
||||||
return minterMessages.updateStartTradingTime(txSigner, args.startTime)
|
return vendingMinterMessages.updateStartTradingTime(txSigner, args.startTime)
|
||||||
}
|
}
|
||||||
case 'update_per_address_limit': {
|
case 'update_per_address_limit': {
|
||||||
return minterMessages.updatePerAddressLimit(txSigner, args.limit)
|
return vendingMinterMessages.updatePerAddressLimit(txSigner, args.limit)
|
||||||
}
|
}
|
||||||
case 'update_collection_info': {
|
case 'update_collection_info': {
|
||||||
return sg721Messages.updateCollectionInfo(args.collectionInfo as CollectionInfo)
|
return sg721Messages.updateCollectionInfo(args.collectionInfo as CollectionInfo)
|
||||||
@ -225,10 +225,10 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
return sg721Messages.freezeCollectionInfo()
|
return sg721Messages.freezeCollectionInfo()
|
||||||
}
|
}
|
||||||
case 'shuffle': {
|
case 'shuffle': {
|
||||||
return minterMessages.shuffle(txSigner)
|
return vendingMinterMessages.shuffle(txSigner)
|
||||||
}
|
}
|
||||||
case 'withdraw': {
|
case 'withdraw': {
|
||||||
return minterMessages.withdraw(txSigner)
|
return vendingMinterMessages.withdraw(txSigner)
|
||||||
}
|
}
|
||||||
case 'transfer': {
|
case 'transfer': {
|
||||||
return sg721Messages.transferNft(args.recipient, args.tokenId.toString())
|
return sg721Messages.transferNft(args.recipient, args.tokenId.toString())
|
||||||
@ -243,13 +243,13 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
return sg721Messages.batchBurn(args.tokenIds)
|
return sg721Messages.batchBurn(args.tokenIds)
|
||||||
}
|
}
|
||||||
case 'batch_mint_for': {
|
case 'batch_mint_for': {
|
||||||
return minterMessages.batchMintFor(txSigner, args.recipient, args.tokenIds)
|
return vendingMinterMessages.batchMintFor(txSigner, args.recipient, args.tokenIds)
|
||||||
}
|
}
|
||||||
case 'airdrop': {
|
case 'airdrop': {
|
||||||
return minterMessages.airdrop(txSigner, args.recipients)
|
return vendingMinterMessages.airdrop(txSigner, args.recipients)
|
||||||
}
|
}
|
||||||
case 'burn_remaining': {
|
case 'burn_remaining': {
|
||||||
return minterMessages.burnRemaining(txSigner)
|
return vendingMinterMessages.burnRemaining(txSigner)
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error('Unknown action')
|
throw new Error('Unknown action')
|
||||||
@ -259,40 +259,40 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
|
|
||||||
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages: minterMessages } = useMinterContract()
|
const { messages: vendingMinterMessages } = useVendingMinterContract()
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages: sg721Messages } = useSG721Contract()
|
const { messages: sg721Messages } = useSG721Contract()
|
||||||
const { minterContract, sg721Contract } = args
|
const { minterContract, sg721Contract } = args
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
case 'mint': {
|
case 'mint': {
|
||||||
return minterMessages(minterContract)?.mint()
|
return vendingMinterMessages(minterContract)?.mint()
|
||||||
}
|
}
|
||||||
case 'purge': {
|
case 'purge': {
|
||||||
return minterMessages(minterContract)?.purge()
|
return vendingMinterMessages(minterContract)?.purge()
|
||||||
}
|
}
|
||||||
case 'update_mint_price': {
|
case 'update_mint_price': {
|
||||||
return minterMessages(minterContract)?.updateMintPrice(args.price)
|
return vendingMinterMessages(minterContract)?.updateMintPrice(args.price)
|
||||||
}
|
}
|
||||||
case 'mint_to': {
|
case 'mint_to': {
|
||||||
return minterMessages(minterContract)?.mintTo(args.recipient)
|
return vendingMinterMessages(minterContract)?.mintTo(args.recipient)
|
||||||
}
|
}
|
||||||
case 'mint_for': {
|
case 'mint_for': {
|
||||||
return minterMessages(minterContract)?.mintFor(args.recipient, args.tokenId)
|
return vendingMinterMessages(minterContract)?.mintFor(args.recipient, args.tokenId)
|
||||||
}
|
}
|
||||||
case 'batch_mint': {
|
case 'batch_mint': {
|
||||||
return minterMessages(minterContract)?.batchMint(args.recipient, args.batchNumber)
|
return vendingMinterMessages(minterContract)?.batchMint(args.recipient, args.batchNumber)
|
||||||
}
|
}
|
||||||
case 'set_whitelist': {
|
case 'set_whitelist': {
|
||||||
return minterMessages(minterContract)?.setWhitelist(args.whitelist)
|
return vendingMinterMessages(minterContract)?.setWhitelist(args.whitelist)
|
||||||
}
|
}
|
||||||
case 'update_start_time': {
|
case 'update_start_time': {
|
||||||
return minterMessages(minterContract)?.updateStartTime(args.startTime)
|
return vendingMinterMessages(minterContract)?.updateStartTime(args.startTime)
|
||||||
}
|
}
|
||||||
case 'update_start_trading_time': {
|
case 'update_start_trading_time': {
|
||||||
return minterMessages(minterContract)?.updateStartTradingTime(args.startTime as string)
|
return vendingMinterMessages(minterContract)?.updateStartTradingTime(args.startTime as string)
|
||||||
}
|
}
|
||||||
case 'update_per_address_limit': {
|
case 'update_per_address_limit': {
|
||||||
return minterMessages(minterContract)?.updatePerAddressLimit(args.limit)
|
return vendingMinterMessages(minterContract)?.updatePerAddressLimit(args.limit)
|
||||||
}
|
}
|
||||||
case 'update_collection_info': {
|
case 'update_collection_info': {
|
||||||
return sg721Messages(sg721Contract)?.updateCollectionInfo(args.collectionInfo as CollectionInfo)
|
return sg721Messages(sg721Contract)?.updateCollectionInfo(args.collectionInfo as CollectionInfo)
|
||||||
@ -301,10 +301,10 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
|||||||
return sg721Messages(sg721Contract)?.freezeCollectionInfo()
|
return sg721Messages(sg721Contract)?.freezeCollectionInfo()
|
||||||
}
|
}
|
||||||
case 'shuffle': {
|
case 'shuffle': {
|
||||||
return minterMessages(minterContract)?.shuffle()
|
return vendingMinterMessages(minterContract)?.shuffle()
|
||||||
}
|
}
|
||||||
case 'withdraw': {
|
case 'withdraw': {
|
||||||
return minterMessages(minterContract)?.withdraw()
|
return vendingMinterMessages(minterContract)?.withdraw()
|
||||||
}
|
}
|
||||||
case 'transfer': {
|
case 'transfer': {
|
||||||
return sg721Messages(sg721Contract)?.transferNft(args.recipient, args.tokenId.toString())
|
return sg721Messages(sg721Contract)?.transferNft(args.recipient, args.tokenId.toString())
|
||||||
@ -319,13 +319,13 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
|||||||
return sg721Messages(sg721Contract)?.batchBurn(args.tokenIds)
|
return sg721Messages(sg721Contract)?.batchBurn(args.tokenIds)
|
||||||
}
|
}
|
||||||
case 'batch_mint_for': {
|
case 'batch_mint_for': {
|
||||||
return minterMessages(minterContract)?.batchMintFor(args.recipient, args.tokenIds)
|
return vendingMinterMessages(minterContract)?.batchMintFor(args.recipient, args.tokenIds)
|
||||||
}
|
}
|
||||||
case 'airdrop': {
|
case 'airdrop': {
|
||||||
return minterMessages(minterContract)?.airdrop(args.recipients)
|
return vendingMinterMessages(minterContract)?.airdrop(args.recipients)
|
||||||
}
|
}
|
||||||
case 'burn_remaining': {
|
case 'burn_remaining': {
|
||||||
return minterMessages(minterContract)?.burnRemaining()
|
return vendingMinterMessages(minterContract)?.burnRemaining()
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return {}
|
return {}
|
||||||
|
@ -5,8 +5,8 @@ import { FormControl } from 'components/FormControl'
|
|||||||
import { AddressInput, TextInput } from 'components/forms/FormInput'
|
import { AddressInput, TextInput } from 'components/forms/FormInput'
|
||||||
import { useInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import type { MinterInstance } from 'contracts/minter'
|
|
||||||
import type { SG721Instance } from 'contracts/sg721'
|
import type { SG721Instance } from 'contracts/sg721'
|
||||||
|
import type { MinterInstance } from 'contracts/vendingMinter'
|
||||||
import { toast } from 'react-hot-toast'
|
import { toast } from 'react-hot-toast'
|
||||||
import { useQuery } from 'react-query'
|
import { useQuery } from 'react-query'
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { MinterInstance } from 'contracts/minter'
|
|
||||||
import type { SG721Instance } from 'contracts/sg721'
|
import type { SG721Instance } from 'contracts/sg721'
|
||||||
|
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
|
|
||||||
export type QueryType = typeof QUERY_TYPES[number]
|
export type QueryType = typeof QUERY_TYPES[number]
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ export interface DispatchExecuteProps {
|
|||||||
type Select<T extends QueryType> = T
|
type Select<T extends QueryType> = T
|
||||||
|
|
||||||
export type DispatchQueryArgs = {
|
export type DispatchQueryArgs = {
|
||||||
minterMessages?: MinterInstance
|
vendingMinterMessages?: VendingMinterInstance
|
||||||
sg721Messages?: SG721Instance
|
sg721Messages?: SG721Instance
|
||||||
} & (
|
} & (
|
||||||
| { type: undefined }
|
| { type: undefined }
|
||||||
@ -72,8 +72,8 @@ export type DispatchQueryArgs = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const dispatchQuery = async (args: DispatchQueryArgs) => {
|
export const dispatchQuery = async (args: DispatchQueryArgs) => {
|
||||||
const { minterMessages, sg721Messages } = args
|
const { vendingMinterMessages, sg721Messages } = args
|
||||||
if (!minterMessages || !sg721Messages) {
|
if (!vendingMinterMessages || !sg721Messages) {
|
||||||
throw new Error('Cannot execute actions')
|
throw new Error('Cannot execute actions')
|
||||||
}
|
}
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
@ -81,16 +81,16 @@ export const dispatchQuery = async (args: DispatchQueryArgs) => {
|
|||||||
return sg721Messages.collectionInfo()
|
return sg721Messages.collectionInfo()
|
||||||
}
|
}
|
||||||
case 'mint_price': {
|
case 'mint_price': {
|
||||||
return minterMessages.getMintPrice()
|
return vendingMinterMessages.getMintPrice()
|
||||||
}
|
}
|
||||||
case 'num_tokens': {
|
case 'num_tokens': {
|
||||||
return minterMessages.getMintableNumTokens()
|
return vendingMinterMessages.getMintableNumTokens()
|
||||||
}
|
}
|
||||||
case 'tokens_minted_to_user': {
|
case 'tokens_minted_to_user': {
|
||||||
return minterMessages.getMintCount(args.address)
|
return vendingMinterMessages.getMintCount(args.address)
|
||||||
}
|
}
|
||||||
// case 'token_owners': {
|
// case 'token_owners': {
|
||||||
// return minterMessages.updateStartTime(txSigner, args.startTime)
|
// return vendingMinterMessages.updateStartTime(txSigner, args.startTime)
|
||||||
// }
|
// }
|
||||||
case 'token_info': {
|
case 'token_info': {
|
||||||
if (!args.tokenId) return
|
if (!args.tokenId) return
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ExecuteListItem } from 'contracts/minter/messages/execute'
|
import type { ExecuteListItem } from 'contracts/baseMinter/messages/execute'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
export const useExecuteComboboxState = () => {
|
export const useExecuteComboboxState = () => {
|
@ -1,8 +1,8 @@
|
|||||||
import { Combobox, Transition } from '@headlessui/react'
|
import { Combobox, Transition } from '@headlessui/react'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { FormControl } from 'components/FormControl'
|
import { FormControl } from 'components/FormControl'
|
||||||
import type { ExecuteListItem } from 'contracts/minter/messages/execute'
|
import type { ExecuteListItem } from 'contracts/baseMinter/messages/execute'
|
||||||
import { EXECUTE_LIST } from 'contracts/minter/messages/execute'
|
import { EXECUTE_LIST } from 'contracts/baseMinter/messages/execute'
|
||||||
import { matchSorter } from 'match-sorter'
|
import { matchSorter } from 'match-sorter'
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useState } from 'react'
|
||||||
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
@ -0,0 +1,7 @@
|
|||||||
|
import type { ExecuteListItem } from 'contracts/vendingMinter/messages/execute'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
export const useExecuteComboboxState = () => {
|
||||||
|
const [value, setValue] = useState<ExecuteListItem | null>(null)
|
||||||
|
return { value, onChange: (item: ExecuteListItem) => setValue(item) }
|
||||||
|
}
|
92
components/contracts/vendingMinter/ExecuteCombobox.tsx
Normal file
92
components/contracts/vendingMinter/ExecuteCombobox.tsx
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import { Combobox, Transition } from '@headlessui/react'
|
||||||
|
import clsx from 'clsx'
|
||||||
|
import { FormControl } from 'components/FormControl'
|
||||||
|
import type { ExecuteListItem } from 'contracts/vendingMinter/messages/execute'
|
||||||
|
import { EXECUTE_LIST } from 'contracts/vendingMinter/messages/execute'
|
||||||
|
import { matchSorter } from 'match-sorter'
|
||||||
|
import { Fragment, useState } from 'react'
|
||||||
|
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
||||||
|
|
||||||
|
export interface ExecuteComboboxProps {
|
||||||
|
value: ExecuteListItem | null
|
||||||
|
onChange: (item: ExecuteListItem) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExecuteCombobox = ({ value, onChange }: ExecuteComboboxProps) => {
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
|
||||||
|
const filtered =
|
||||||
|
search === '' ? EXECUTE_LIST : matchSorter(EXECUTE_LIST, search, { keys: ['id', 'name', 'description'] })
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Combobox
|
||||||
|
as={FormControl}
|
||||||
|
htmlId="message-type"
|
||||||
|
labelAs={Combobox.Label}
|
||||||
|
onChange={onChange}
|
||||||
|
subtitle="Contract execute message type"
|
||||||
|
title="Message Type"
|
||||||
|
value={value}
|
||||||
|
>
|
||||||
|
<div className="relative">
|
||||||
|
<Combobox.Input
|
||||||
|
className={clsx(
|
||||||
|
'w-full bg-white/10 rounded border-2 border-white/20 form-input',
|
||||||
|
'placeholder:text-white/50',
|
||||||
|
'focus:ring focus:ring-plumbus-20',
|
||||||
|
)}
|
||||||
|
displayValue={(val?: ExecuteListItem) => val?.name ?? ''}
|
||||||
|
id="message-type"
|
||||||
|
onChange={(event) => setSearch(event.target.value)}
|
||||||
|
placeholder="Select message type"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Combobox.Button
|
||||||
|
className={clsx(
|
||||||
|
'flex absolute inset-y-0 right-0 items-center p-4',
|
||||||
|
'opacity-50 hover:opacity-100 active:opacity-100',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{({ open }) => <FaChevronDown aria-hidden="true" className={clsx('w-4 h-4', { 'rotate-180': open })} />}
|
||||||
|
</Combobox.Button>
|
||||||
|
|
||||||
|
<Transition afterLeave={() => setSearch('')} as={Fragment}>
|
||||||
|
<Combobox.Options
|
||||||
|
className={clsx(
|
||||||
|
'overflow-auto absolute z-10 mt-2 w-full max-h-[30vh]',
|
||||||
|
'bg-stone-800/80 rounded shadow-lg backdrop-blur-sm',
|
||||||
|
'divide-y divide-stone-500/50',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{filtered.length < 1 && (
|
||||||
|
<span className="flex flex-col justify-center items-center p-4 text-sm text-center text-white/50">
|
||||||
|
Message type not found.
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{filtered.map((entry) => (
|
||||||
|
<Combobox.Option
|
||||||
|
key={entry.id}
|
||||||
|
className={({ active }) =>
|
||||||
|
clsx('flex relative flex-col py-2 px-4 space-y-1 cursor-pointer', { 'bg-plumbus-70': active })
|
||||||
|
}
|
||||||
|
value={entry}
|
||||||
|
>
|
||||||
|
<span className="font-bold">{entry.name}</span>
|
||||||
|
<span className="max-w-md text-sm">{entry.description}</span>
|
||||||
|
</Combobox.Option>
|
||||||
|
))}
|
||||||
|
</Combobox.Options>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{value && (
|
||||||
|
<div className="flex space-x-2 text-white/50">
|
||||||
|
<div className="mt-1">
|
||||||
|
<FaInfoCircle className="w-3 h-3" />
|
||||||
|
</div>
|
||||||
|
<span className="text-sm">{value.description}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Combobox>
|
||||||
|
)
|
||||||
|
}
|
@ -1,9 +1,13 @@
|
|||||||
import type { UseMinterContractProps } from 'contracts/minter'
|
import type { UseBaseFactoryContractProps } from 'contracts/baseFactory'
|
||||||
import { useMinterContract } from 'contracts/minter'
|
import { useBaseFactoryContract } from 'contracts/baseFactory'
|
||||||
|
import type { UseBaseMinterContractProps } from 'contracts/baseMinter'
|
||||||
|
import { useBaseMinterContract } from 'contracts/baseMinter'
|
||||||
import type { UseSG721ContractProps } from 'contracts/sg721'
|
import type { UseSG721ContractProps } from 'contracts/sg721'
|
||||||
import { useSG721Contract } from 'contracts/sg721'
|
import { useSG721Contract } from 'contracts/sg721'
|
||||||
import type { UseVendingFactoryContractProps } from 'contracts/vendingFactory'
|
import type { UseVendingFactoryContractProps } from 'contracts/vendingFactory'
|
||||||
import { useVendingFactoryContract } from 'contracts/vendingFactory'
|
import { useVendingFactoryContract } from 'contracts/vendingFactory'
|
||||||
|
import type { UseVendingMinterContractProps } from 'contracts/vendingMinter'
|
||||||
|
import { useVendingMinterContract } from 'contracts/vendingMinter'
|
||||||
import type { UseWhiteListContractProps } from 'contracts/whitelist'
|
import type { UseWhiteListContractProps } from 'contracts/whitelist'
|
||||||
import { useWhiteListContract } from 'contracts/whitelist'
|
import { useWhiteListContract } from 'contracts/whitelist'
|
||||||
import type { ReactNode, VFC } from 'react'
|
import type { ReactNode, VFC } from 'react'
|
||||||
@ -16,9 +20,11 @@ import create from 'zustand'
|
|||||||
*/
|
*/
|
||||||
export interface ContractsStore extends State {
|
export interface ContractsStore extends State {
|
||||||
sg721: UseSG721ContractProps | null
|
sg721: UseSG721ContractProps | null
|
||||||
minter: UseMinterContractProps | null
|
vendingMinter: UseVendingMinterContractProps | null
|
||||||
|
baseMinter: UseBaseMinterContractProps | null
|
||||||
whitelist: UseWhiteListContractProps | null
|
whitelist: UseWhiteListContractProps | null
|
||||||
vendingFactory: UseVendingFactoryContractProps | null
|
vendingFactory: UseVendingFactoryContractProps | null
|
||||||
|
baseFactory: UseBaseFactoryContractProps | null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,9 +32,11 @@ export interface ContractsStore extends State {
|
|||||||
*/
|
*/
|
||||||
export const defaultValues: ContractsStore = {
|
export const defaultValues: ContractsStore = {
|
||||||
sg721: null,
|
sg721: null,
|
||||||
minter: null,
|
vendingMinter: null,
|
||||||
|
baseMinter: null,
|
||||||
whitelist: null,
|
whitelist: null,
|
||||||
vendingFactory: null,
|
vendingFactory: null,
|
||||||
|
baseFactory: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,18 +61,22 @@ export const ContractsProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
|
|
||||||
const ContractsSubscription: VFC = () => {
|
const ContractsSubscription: VFC = () => {
|
||||||
const sg721 = useSG721Contract()
|
const sg721 = useSG721Contract()
|
||||||
const minter = useMinterContract()
|
const vendingMinter = useVendingMinterContract()
|
||||||
|
const baseMinter = useBaseMinterContract()
|
||||||
const whitelist = useWhiteListContract()
|
const whitelist = useWhiteListContract()
|
||||||
const vendingFactory = useVendingFactoryContract()
|
const vendingFactory = useVendingFactoryContract()
|
||||||
|
const baseFactory = useBaseFactoryContract()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
useContracts.setState({
|
useContracts.setState({
|
||||||
sg721,
|
sg721,
|
||||||
minter,
|
vendingMinter,
|
||||||
|
baseMinter,
|
||||||
whitelist,
|
whitelist,
|
||||||
vendingFactory,
|
vendingFactory,
|
||||||
|
baseFactory,
|
||||||
})
|
})
|
||||||
}, [sg721, minter, whitelist, vendingFactory])
|
}, [sg721, vendingMinter, baseMinter, whitelist, vendingFactory, baseFactory])
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
93
contracts/baseFactory/contract.ts
Normal file
93
contracts/baseFactory/contract.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
|
||||||
|
import type { Coin } from '@cosmjs/proto-signing'
|
||||||
|
import { coin } from '@cosmjs/proto-signing'
|
||||||
|
import type { logs } from '@cosmjs/stargate'
|
||||||
|
import { BASE_FACTORY_ADDRESS } from 'utils/constants'
|
||||||
|
|
||||||
|
export interface CreateBaseMinterResponse {
|
||||||
|
readonly baseMinterAddress: string
|
||||||
|
readonly sg721Address: string
|
||||||
|
readonly transactionHash: string
|
||||||
|
readonly logs: readonly logs.Log[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseFactoryInstance {
|
||||||
|
readonly contractAddress: string
|
||||||
|
|
||||||
|
//Query
|
||||||
|
getParams: () => Promise<any>
|
||||||
|
//Execute
|
||||||
|
createBaseMinter: (
|
||||||
|
senderAddress: string,
|
||||||
|
msg: Record<string, unknown>,
|
||||||
|
funds: Coin[],
|
||||||
|
) => Promise<CreateBaseMinterResponse>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseFactoryMessages {
|
||||||
|
createBaseMinter: (msg: Record<string, unknown>) => CreateBaseMinterMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateBaseMinterMessage {
|
||||||
|
sender: string
|
||||||
|
contract: string
|
||||||
|
msg: Record<string, unknown>
|
||||||
|
funds: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseFactoryContract {
|
||||||
|
use: (contractAddress: string) => BaseFactoryInstance
|
||||||
|
|
||||||
|
messages: (contractAddress: string) => BaseFactoryMessages
|
||||||
|
}
|
||||||
|
|
||||||
|
export const baseFactory = (client: SigningCosmWasmClient, txSigner: string): BaseFactoryContract => {
|
||||||
|
const use = (contractAddress: string): BaseFactoryInstance => {
|
||||||
|
//Query
|
||||||
|
const getParams = async (): Promise<any> => {
|
||||||
|
const res = await client.queryContractSmart(contractAddress, {
|
||||||
|
params: {},
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
//Execute
|
||||||
|
const createBaseMinter = async (
|
||||||
|
senderAddress: string,
|
||||||
|
msg: Record<string, unknown>,
|
||||||
|
funds: Coin[],
|
||||||
|
): Promise<CreateBaseMinterResponse> => {
|
||||||
|
const result = await client.execute(senderAddress, BASE_FACTORY_ADDRESS, msg, 'auto', '', funds)
|
||||||
|
|
||||||
|
return {
|
||||||
|
baseMinterAddress: result.logs[0].events[5].attributes[0].value,
|
||||||
|
sg721Address: result.logs[0].events[5].attributes[2].value,
|
||||||
|
transactionHash: result.transactionHash,
|
||||||
|
logs: result.logs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
contractAddress,
|
||||||
|
getParams,
|
||||||
|
createBaseMinter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = (contractAddress: string) => {
|
||||||
|
const createBaseMinter = (msg: Record<string, unknown>): CreateBaseMinterMessage => {
|
||||||
|
return {
|
||||||
|
sender: txSigner,
|
||||||
|
contract: contractAddress,
|
||||||
|
msg,
|
||||||
|
funds: [coin('1000000000', 'ustars')],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
createBaseMinter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { use, messages }
|
||||||
|
}
|
28
contracts/baseFactory/messages/execute.ts
Normal file
28
contracts/baseFactory/messages/execute.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import type { Coin } from '@cosmjs/proto-signing'
|
||||||
|
|
||||||
|
import type { BaseFactoryInstance } from '../index'
|
||||||
|
import { useBaseFactoryContract } from '../index'
|
||||||
|
|
||||||
|
/** @see {@link VendingFactoryInstance} */
|
||||||
|
export interface DispatchExecuteArgs {
|
||||||
|
contract: string
|
||||||
|
messages?: BaseFactoryInstance
|
||||||
|
txSigner: string
|
||||||
|
msg: Record<string, unknown>
|
||||||
|
funds: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||||
|
const { messages, txSigner } = args
|
||||||
|
if (!messages) {
|
||||||
|
throw new Error('cannot dispatch execute, messages is not defined')
|
||||||
|
}
|
||||||
|
return messages.createBaseMinter(txSigner, args.msg, args.funds)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
const { messages } = useBaseFactoryContract()
|
||||||
|
const { contract } = args
|
||||||
|
return messages(contract)?.createBaseMinter(args.msg)
|
||||||
|
}
|
57
contracts/baseFactory/useContract.ts
Normal file
57
contracts/baseFactory/useContract.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import type { BaseFactoryContract, BaseFactoryInstance, BaseFactoryMessages } from './contract'
|
||||||
|
import { baseFactory as initContract } from './contract'
|
||||||
|
|
||||||
|
export interface UseBaseFactoryContractProps {
|
||||||
|
use: (customAddress: string) => BaseFactoryInstance | undefined
|
||||||
|
updateContractAddress: (contractAddress: string) => void
|
||||||
|
getContractAddress: () => string | undefined
|
||||||
|
messages: (contractAddress: string) => BaseFactoryMessages | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useBaseFactoryContract(): UseBaseFactoryContractProps {
|
||||||
|
const wallet = useWallet()
|
||||||
|
|
||||||
|
const [address, setAddress] = useState<string>('')
|
||||||
|
const [baseFactory, setBaseFactory] = useState<BaseFactoryContract>()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setAddress(localStorage.getItem('contract_address') || '')
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const BaseFactoryBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||||
|
setBaseFactory(BaseFactoryBaseContract)
|
||||||
|
}, [wallet])
|
||||||
|
|
||||||
|
const updateContractAddress = (contractAddress: string) => {
|
||||||
|
setAddress(contractAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
const use = useCallback(
|
||||||
|
(customAddress = ''): BaseFactoryInstance | undefined => {
|
||||||
|
return baseFactory?.use(address || customAddress)
|
||||||
|
},
|
||||||
|
[baseFactory, address],
|
||||||
|
)
|
||||||
|
|
||||||
|
const getContractAddress = (): string | undefined => {
|
||||||
|
return address
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = useCallback(
|
||||||
|
(customAddress = ''): BaseFactoryMessages | undefined => {
|
||||||
|
return baseFactory?.messages(address || customAddress)
|
||||||
|
},
|
||||||
|
[baseFactory, address],
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
use,
|
||||||
|
updateContractAddress,
|
||||||
|
getContractAddress,
|
||||||
|
messages,
|
||||||
|
}
|
||||||
|
}
|
243
contracts/baseMinter/contract.ts
Normal file
243
contracts/baseMinter/contract.ts
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
|
||||||
|
import type { Coin } from '@cosmjs/proto-signing'
|
||||||
|
import { coin } from '@cosmjs/proto-signing'
|
||||||
|
import type { logs } from '@cosmjs/stargate'
|
||||||
|
import type { Timestamp } from '@stargazezone/types/contracts/minter/shared-types'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { BASE_FACTORY_ADDRESS } from 'utils/constants'
|
||||||
|
|
||||||
|
export interface InstantiateResponse {
|
||||||
|
readonly contractAddress: string
|
||||||
|
readonly transactionHash: string
|
||||||
|
readonly logs: readonly logs.Log[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MigrateResponse {
|
||||||
|
readonly transactionHash: string
|
||||||
|
readonly logs: readonly logs.Log[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoyaltyInfo {
|
||||||
|
payment_address: string
|
||||||
|
share: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseMinterInstance {
|
||||||
|
readonly contractAddress: string
|
||||||
|
|
||||||
|
//Query
|
||||||
|
getConfig: () => Promise<any>
|
||||||
|
getStatus: () => Promise<any>
|
||||||
|
|
||||||
|
//Execute
|
||||||
|
mint: (senderAddress: string, tokenUri: string) => Promise<string>
|
||||||
|
updateStartTradingTime: (senderAddress: string, time?: Timestamp) => Promise<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseMinterMessages {
|
||||||
|
mint: (tokenUri: string) => MintMessage
|
||||||
|
updateStartTradingTime: (time: Timestamp) => UpdateStartTradingTimeMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MintMessage {
|
||||||
|
sender: string
|
||||||
|
contract: string
|
||||||
|
msg: {
|
||||||
|
mint: {
|
||||||
|
token_uri: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
funds: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateStartTradingTimeMessage {
|
||||||
|
sender: string
|
||||||
|
contract: string
|
||||||
|
msg: {
|
||||||
|
update_start_trading_time: string
|
||||||
|
}
|
||||||
|
funds: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CustomMessage {
|
||||||
|
sender: string
|
||||||
|
contract: string
|
||||||
|
msg: Record<string, unknown>[]
|
||||||
|
funds: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MintPriceMessage {
|
||||||
|
public_price: {
|
||||||
|
denom: string
|
||||||
|
amount: string
|
||||||
|
}
|
||||||
|
airdrop_price: {
|
||||||
|
denom: string
|
||||||
|
amount: string
|
||||||
|
}
|
||||||
|
whitelist_price?: {
|
||||||
|
denom: string
|
||||||
|
amount: string
|
||||||
|
}
|
||||||
|
current_price: {
|
||||||
|
denom: string
|
||||||
|
amount: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseMinterContract {
|
||||||
|
instantiate: (
|
||||||
|
senderAddress: string,
|
||||||
|
codeId: number,
|
||||||
|
initMsg: Record<string, unknown>,
|
||||||
|
label: string,
|
||||||
|
admin?: string,
|
||||||
|
funds?: Coin[],
|
||||||
|
) => Promise<InstantiateResponse>
|
||||||
|
|
||||||
|
migrate: (
|
||||||
|
senderAddress: string,
|
||||||
|
contractAddress: string,
|
||||||
|
codeId: number,
|
||||||
|
migrateMsg: Record<string, unknown>,
|
||||||
|
) => Promise<MigrateResponse>
|
||||||
|
|
||||||
|
use: (contractAddress: string) => BaseMinterInstance
|
||||||
|
|
||||||
|
messages: (contractAddress: string) => BaseMinterMessages
|
||||||
|
}
|
||||||
|
|
||||||
|
export const baseMinter = (client: SigningCosmWasmClient, txSigner: string): BaseMinterContract => {
|
||||||
|
const use = (contractAddress: string): BaseMinterInstance => {
|
||||||
|
//Query
|
||||||
|
const getFactoryParameters = async (): Promise<any> => {
|
||||||
|
const res = await client.queryContractSmart(BASE_FACTORY_ADDRESS, { params: {} })
|
||||||
|
return res
|
||||||
|
console.log(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getConfig = async (): Promise<any> => {
|
||||||
|
const res = await client.queryContractSmart(contractAddress, {
|
||||||
|
config: {},
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
const getStatus = async (): Promise<any> => {
|
||||||
|
const res = await client.queryContractSmart(contractAddress, {
|
||||||
|
status: {},
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
//Execute
|
||||||
|
const mint = async (senderAddress: string, tokenUri: string): Promise<string> => {
|
||||||
|
//const factoryParameters = await baseFactory?.use(BASE_FACTORY_ADDRESS)?.getParams()
|
||||||
|
|
||||||
|
const factoryParameters = await toast.promise(getFactoryParameters(), {
|
||||||
|
loading: 'Querying Factory Parameters...',
|
||||||
|
error: 'Querying Factory Parameters failed!',
|
||||||
|
success: 'Query successful! Minting...',
|
||||||
|
})
|
||||||
|
console.log(factoryParameters.params.mint_fee_bps)
|
||||||
|
|
||||||
|
const price = (await getConfig()).config.mint_price.amount
|
||||||
|
console.log(price)
|
||||||
|
console.log((Number(price) * Number(factoryParameters.params.mint_fee_bps)) / 100)
|
||||||
|
const res = await client.execute(
|
||||||
|
senderAddress,
|
||||||
|
contractAddress,
|
||||||
|
{
|
||||||
|
mint: { token_uri: tokenUri },
|
||||||
|
},
|
||||||
|
'auto',
|
||||||
|
'',
|
||||||
|
[coin((Number(price) * Number(factoryParameters.params.mint_fee_bps)) / 100 / 100, 'ustars')],
|
||||||
|
)
|
||||||
|
|
||||||
|
return res.transactionHash
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStartTradingTime = async (senderAddress: string, time?: Timestamp): Promise<string> => {
|
||||||
|
const res = await client.execute(
|
||||||
|
senderAddress,
|
||||||
|
contractAddress,
|
||||||
|
{
|
||||||
|
update_start_trading_time: time || null,
|
||||||
|
},
|
||||||
|
'auto',
|
||||||
|
'',
|
||||||
|
)
|
||||||
|
|
||||||
|
return res.transactionHash
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
contractAddress,
|
||||||
|
getConfig,
|
||||||
|
getStatus,
|
||||||
|
mint,
|
||||||
|
updateStartTradingTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const migrate = async (
|
||||||
|
senderAddress: string,
|
||||||
|
contractAddress: string,
|
||||||
|
codeId: number,
|
||||||
|
migrateMsg: Record<string, unknown>,
|
||||||
|
): Promise<MigrateResponse> => {
|
||||||
|
const result = await client.migrate(senderAddress, contractAddress, codeId, migrateMsg, 'auto')
|
||||||
|
return {
|
||||||
|
transactionHash: result.transactionHash,
|
||||||
|
logs: result.logs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const instantiate = async (
|
||||||
|
senderAddress: string,
|
||||||
|
codeId: number,
|
||||||
|
initMsg: Record<string, unknown>,
|
||||||
|
label: string,
|
||||||
|
): Promise<InstantiateResponse> => {
|
||||||
|
const result = await client.instantiate(senderAddress, codeId, initMsg, label, 'auto', {
|
||||||
|
funds: [coin('1000000000', 'ustars')],
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
contractAddress: result.contractAddress,
|
||||||
|
transactionHash: result.transactionHash,
|
||||||
|
logs: result.logs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = (contractAddress: string) => {
|
||||||
|
const mint = (tokenUri: string): MintMessage => {
|
||||||
|
return {
|
||||||
|
sender: txSigner,
|
||||||
|
contract: contractAddress,
|
||||||
|
msg: {
|
||||||
|
mint: { token_uri: tokenUri },
|
||||||
|
},
|
||||||
|
funds: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateStartTradingTime = (startTime: string): UpdateStartTradingTimeMessage => {
|
||||||
|
return {
|
||||||
|
sender: txSigner,
|
||||||
|
contract: contractAddress,
|
||||||
|
msg: {
|
||||||
|
update_start_trading_time: startTime,
|
||||||
|
},
|
||||||
|
funds: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
mint,
|
||||||
|
updateStartTradingTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { use, instantiate, migrate, messages }
|
||||||
|
}
|
2
contracts/baseMinter/index.ts
Normal file
2
contracts/baseMinter/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './contract'
|
||||||
|
export * from './useContract'
|
82
contracts/baseMinter/messages/execute.ts
Normal file
82
contracts/baseMinter/messages/execute.ts
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import type { BaseMinterInstance } from '../index'
|
||||||
|
import { useBaseMinterContract } from '../index'
|
||||||
|
|
||||||
|
export type ExecuteType = typeof EXECUTE_TYPES[number]
|
||||||
|
|
||||||
|
export const EXECUTE_TYPES = ['mint', 'update_start_trading_time'] as const
|
||||||
|
|
||||||
|
export interface ExecuteListItem {
|
||||||
|
id: ExecuteType
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const EXECUTE_LIST: ExecuteListItem[] = [
|
||||||
|
{
|
||||||
|
id: 'mint',
|
||||||
|
name: 'Mint',
|
||||||
|
description: `Mint new tokens for a given address`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_start_trading_time',
|
||||||
|
name: 'Update Start Trading Time',
|
||||||
|
description: `Update start trading time for minting`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export interface DispatchExecuteProps {
|
||||||
|
type: ExecuteType
|
||||||
|
[k: string]: unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
type Select<T extends ExecuteType> = T
|
||||||
|
|
||||||
|
/** @see {@link BaseMinterInstance} */
|
||||||
|
export type DispatchExecuteArgs = {
|
||||||
|
contract: string
|
||||||
|
messages?: BaseMinterInstance
|
||||||
|
txSigner: string
|
||||||
|
} & (
|
||||||
|
| { type: undefined }
|
||||||
|
| { type: Select<'mint'>; tokenUri: string }
|
||||||
|
| { type: Select<'update_start_trading_time'>; startTime?: string }
|
||||||
|
)
|
||||||
|
|
||||||
|
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||||
|
const { messages, txSigner } = args
|
||||||
|
if (!messages) {
|
||||||
|
throw new Error('cannot dispatch execute, messages is not defined')
|
||||||
|
}
|
||||||
|
switch (args.type) {
|
||||||
|
case 'mint': {
|
||||||
|
return messages.mint(txSigner, args.tokenUri)
|
||||||
|
}
|
||||||
|
case 'update_start_trading_time': {
|
||||||
|
return messages.updateStartTradingTime(txSigner, args.startTime)
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error('unknown execute type')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
const { messages } = useBaseMinterContract()
|
||||||
|
const { contract } = args
|
||||||
|
switch (args.type) {
|
||||||
|
case 'mint': {
|
||||||
|
return messages(contract)?.mint(args.tokenUri)
|
||||||
|
}
|
||||||
|
case 'update_start_trading_time': {
|
||||||
|
return messages(contract)?.updateStartTradingTime(args.startTime as string)
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isEitherType = <T extends ExecuteType>(type: unknown, arr: T[]): type is T => {
|
||||||
|
return arr.some((val) => type === val)
|
||||||
|
}
|
37
contracts/baseMinter/messages/query.ts
Normal file
37
contracts/baseMinter/messages/query.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import type { BaseMinterInstance } from '../contract'
|
||||||
|
|
||||||
|
export type QueryType = typeof QUERY_TYPES[number]
|
||||||
|
|
||||||
|
export const QUERY_TYPES = ['config', 'status'] as const
|
||||||
|
|
||||||
|
export interface QueryListItem {
|
||||||
|
id: QueryType
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const QUERY_LIST: QueryListItem[] = [
|
||||||
|
{ id: 'config', name: 'Config', description: 'Query current contract config' },
|
||||||
|
{ id: 'status', name: 'Status', description: 'Query current contract status' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export interface DispatchQueryProps {
|
||||||
|
address: string
|
||||||
|
messages: BaseMinterInstance | undefined
|
||||||
|
type: QueryType
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dispatchQuery = (props: DispatchQueryProps) => {
|
||||||
|
const { address, messages, type } = props
|
||||||
|
switch (type) {
|
||||||
|
case 'config': {
|
||||||
|
return messages?.getConfig()
|
||||||
|
}
|
||||||
|
case 'status': {
|
||||||
|
return messages?.getStatus()
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error('unknown query type')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
contracts/baseMinter/useContract.ts
Normal file
102
contracts/baseMinter/useContract.ts
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
import type { Coin } from '@cosmjs/proto-signing'
|
||||||
|
import type { logs } from '@cosmjs/stargate'
|
||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import type { BaseMinterContract, BaseMinterInstance, BaseMinterMessages, MigrateResponse } from './contract'
|
||||||
|
import { baseMinter as initContract } from './contract'
|
||||||
|
|
||||||
|
interface InstantiateResponse {
|
||||||
|
readonly contractAddress: string
|
||||||
|
readonly transactionHash: string
|
||||||
|
readonly logs: readonly logs.Log[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UseBaseMinterContractProps {
|
||||||
|
instantiate: (
|
||||||
|
codeId: number,
|
||||||
|
initMsg: Record<string, unknown>,
|
||||||
|
label: string,
|
||||||
|
admin?: string,
|
||||||
|
funds?: Coin[],
|
||||||
|
) => Promise<InstantiateResponse>
|
||||||
|
migrate: (contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>) => Promise<MigrateResponse>
|
||||||
|
use: (customAddress: string) => BaseMinterInstance | undefined
|
||||||
|
updateContractAddress: (contractAddress: string) => void
|
||||||
|
getContractAddress: () => string | undefined
|
||||||
|
messages: (contractAddress: string) => BaseMinterMessages | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useBaseMinterContract(): UseBaseMinterContractProps {
|
||||||
|
const wallet = useWallet()
|
||||||
|
|
||||||
|
const [address, setAddress] = useState<string>('')
|
||||||
|
const [baseMinter, setBaseMinter] = useState<BaseMinterContract>()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setAddress(localStorage.getItem('contract_address') || '')
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const BaseMinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||||
|
setBaseMinter(BaseMinterBaseContract)
|
||||||
|
}, [wallet])
|
||||||
|
|
||||||
|
const updateContractAddress = (contractAddress: string) => {
|
||||||
|
setAddress(contractAddress)
|
||||||
|
}
|
||||||
|
|
||||||
|
const instantiate = useCallback(
|
||||||
|
(codeId: number, initMsg: Record<string, unknown>, label: string, admin?: string): Promise<InstantiateResponse> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!baseMinter) {
|
||||||
|
reject(new Error('Contract is not initialized.'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseMinter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[baseMinter, wallet],
|
||||||
|
)
|
||||||
|
|
||||||
|
const migrate = useCallback(
|
||||||
|
(contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>): Promise<MigrateResponse> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!baseMinter) {
|
||||||
|
reject(new Error('Contract is not initialized.'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(wallet.address, contractAddress, codeId)
|
||||||
|
baseMinter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[baseMinter, wallet],
|
||||||
|
)
|
||||||
|
|
||||||
|
const use = useCallback(
|
||||||
|
(customAddress = ''): BaseMinterInstance | undefined => {
|
||||||
|
return baseMinter?.use(address || customAddress)
|
||||||
|
},
|
||||||
|
[baseMinter, address],
|
||||||
|
)
|
||||||
|
|
||||||
|
const getContractAddress = (): string | undefined => {
|
||||||
|
return address
|
||||||
|
}
|
||||||
|
|
||||||
|
const messages = useCallback(
|
||||||
|
(customAddress = ''): BaseMinterMessages | undefined => {
|
||||||
|
return baseMinter?.messages(address || customAddress)
|
||||||
|
},
|
||||||
|
[baseMinter, address],
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
instantiate,
|
||||||
|
use,
|
||||||
|
updateContractAddress,
|
||||||
|
getContractAddress,
|
||||||
|
messages,
|
||||||
|
migrate,
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import type { Coin, logs } from '@cosmjs/stargate'
|
|||||||
import { coin } from '@cosmjs/stargate'
|
import { coin } from '@cosmjs/stargate'
|
||||||
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx'
|
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx'
|
||||||
|
|
||||||
import type { RoyaltyInfo } from '../minter/contract'
|
import type { RoyaltyInfo } from '../vendingMinter/contract'
|
||||||
|
|
||||||
export interface InstantiateResponse {
|
export interface InstantiateResponse {
|
||||||
readonly contractAddress: string
|
readonly contractAddress: string
|
||||||
|
@ -4,8 +4,8 @@ import { coin } from '@cosmjs/proto-signing'
|
|||||||
import type { logs } from '@cosmjs/stargate'
|
import type { logs } from '@cosmjs/stargate'
|
||||||
import { VENDING_FACTORY_ADDRESS } from 'utils/constants'
|
import { VENDING_FACTORY_ADDRESS } from 'utils/constants'
|
||||||
|
|
||||||
export interface CreateMinterResponse {
|
export interface CreateVendingMinterResponse {
|
||||||
readonly minterAddress: string
|
readonly vendingMinterAddress: string
|
||||||
readonly sg721Address: string
|
readonly sg721Address: string
|
||||||
readonly transactionHash: string
|
readonly transactionHash: string
|
||||||
readonly logs: readonly logs.Log[]
|
readonly logs: readonly logs.Log[]
|
||||||
@ -17,14 +17,18 @@ export interface VendingFactoryInstance {
|
|||||||
//Query
|
//Query
|
||||||
|
|
||||||
//Execute
|
//Execute
|
||||||
createMinter: (senderAddress: string, msg: Record<string, unknown>, funds: Coin[]) => Promise<CreateMinterResponse>
|
createVendingMinter: (
|
||||||
|
senderAddress: string,
|
||||||
|
msg: Record<string, unknown>,
|
||||||
|
funds: Coin[],
|
||||||
|
) => Promise<CreateVendingMinterResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VendingFactoryMessages {
|
export interface VendingFactoryMessages {
|
||||||
createMinter: (msg: Record<string, unknown>) => CreateMinterMessage
|
createVendingMinter: (msg: Record<string, unknown>) => CreateVendingMinterMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateMinterMessage {
|
export interface CreateVendingMinterMessage {
|
||||||
sender: string
|
sender: string
|
||||||
contract: string
|
contract: string
|
||||||
msg: Record<string, unknown>
|
msg: Record<string, unknown>
|
||||||
@ -42,15 +46,15 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
//Query
|
//Query
|
||||||
|
|
||||||
//Execute
|
//Execute
|
||||||
const createMinter = async (
|
const createVendingMinter = async (
|
||||||
senderAddress: string,
|
senderAddress: string,
|
||||||
msg: Record<string, unknown>,
|
msg: Record<string, unknown>,
|
||||||
funds: Coin[],
|
funds: Coin[],
|
||||||
): Promise<CreateMinterResponse> => {
|
): Promise<CreateVendingMinterResponse> => {
|
||||||
const result = await client.execute(senderAddress, VENDING_FACTORY_ADDRESS, msg, 'auto', '', funds)
|
const result = await client.execute(senderAddress, VENDING_FACTORY_ADDRESS, msg, 'auto', '', funds)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
minterAddress: result.logs[0].events[5].attributes[0].value,
|
vendingMinterAddress: result.logs[0].events[5].attributes[0].value,
|
||||||
sg721Address: result.logs[0].events[5].attributes[2].value,
|
sg721Address: result.logs[0].events[5].attributes[2].value,
|
||||||
transactionHash: result.transactionHash,
|
transactionHash: result.transactionHash,
|
||||||
logs: result.logs,
|
logs: result.logs,
|
||||||
@ -59,12 +63,12 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
contractAddress,
|
contractAddress,
|
||||||
createMinter,
|
createVendingMinter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages = (contractAddress: string) => {
|
const messages = (contractAddress: string) => {
|
||||||
const createMinter = (msg: Record<string, unknown>): CreateMinterMessage => {
|
const createVendingMinter = (msg: Record<string, unknown>): CreateVendingMinterMessage => {
|
||||||
return {
|
return {
|
||||||
sender: txSigner,
|
sender: txSigner,
|
||||||
contract: contractAddress,
|
contract: contractAddress,
|
||||||
@ -74,7 +78,7 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
createMinter,
|
createVendingMinter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
if (!messages) {
|
if (!messages) {
|
||||||
throw new Error('cannot dispatch execute, messages is not defined')
|
throw new Error('cannot dispatch execute, messages is not defined')
|
||||||
}
|
}
|
||||||
return messages.createMinter(txSigner, args.msg, args.funds)
|
return messages.createVendingMinter(txSigner, args.msg, args.funds)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages } = useVendingFactoryContract()
|
const { messages } = useVendingFactoryContract()
|
||||||
const { contract } = args
|
const { contract } = args
|
||||||
return messages(contract)?.createMinter(args.msg)
|
return messages(contract)?.createVendingMinter(args.msg)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export interface RoyaltyInfo {
|
|||||||
share: string
|
share: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MinterInstance {
|
export interface VendingMinterInstance {
|
||||||
readonly contractAddress: string
|
readonly contractAddress: string
|
||||||
|
|
||||||
//Query
|
//Query
|
||||||
@ -50,7 +50,7 @@ export interface MinterInstance {
|
|||||||
burnRemaining: (senderAddress: string) => Promise<string>
|
burnRemaining: (senderAddress: string) => Promise<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MinterMessages {
|
export interface VendingMinterMessages {
|
||||||
mint: () => MintMessage
|
mint: () => MintMessage
|
||||||
purge: () => PurgeMessage
|
purge: () => PurgeMessage
|
||||||
updateMintPrice: (price: string) => UpdateMintPriceMessage
|
updateMintPrice: (price: string) => UpdateMintPriceMessage
|
||||||
@ -219,7 +219,7 @@ export interface MintPriceMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MinterContract {
|
export interface VendingMinterContract {
|
||||||
instantiate: (
|
instantiate: (
|
||||||
senderAddress: string,
|
senderAddress: string,
|
||||||
codeId: number,
|
codeId: number,
|
||||||
@ -236,13 +236,13 @@ export interface MinterContract {
|
|||||||
migrateMsg: Record<string, unknown>,
|
migrateMsg: Record<string, unknown>,
|
||||||
) => Promise<MigrateResponse>
|
) => Promise<MigrateResponse>
|
||||||
|
|
||||||
use: (contractAddress: string) => MinterInstance
|
use: (contractAddress: string) => VendingMinterInstance
|
||||||
|
|
||||||
messages: (contractAddress: string) => MinterMessages
|
messages: (contractAddress: string) => VendingMinterMessages
|
||||||
}
|
}
|
||||||
|
|
||||||
export const minter = (client: SigningCosmWasmClient, txSigner: string): MinterContract => {
|
export const vendingMinter = (client: SigningCosmWasmClient, txSigner: string): VendingMinterContract => {
|
||||||
const use = (contractAddress: string): MinterInstance => {
|
const use = (contractAddress: string): VendingMinterInstance => {
|
||||||
//Query
|
//Query
|
||||||
const getConfig = async (): Promise<any> => {
|
const getConfig = async (): Promise<any> => {
|
||||||
const res = await client.queryContractSmart(contractAddress, {
|
const res = await client.queryContractSmart(contractAddress, {
|
2
contracts/vendingMinter/index.ts
Normal file
2
contracts/vendingMinter/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './contract'
|
||||||
|
export * from './useContract'
|
@ -1,5 +1,5 @@
|
|||||||
import type { MinterInstance } from '../index'
|
import type { VendingMinterInstance } from '../index'
|
||||||
import { useMinterContract } from '../index'
|
import { useVendingMinterContract } from '../index'
|
||||||
|
|
||||||
export type ExecuteType = typeof EXECUTE_TYPES[number]
|
export type ExecuteType = typeof EXECUTE_TYPES[number]
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ export interface DispatchExecuteProps {
|
|||||||
|
|
||||||
type Select<T extends ExecuteType> = T
|
type Select<T extends ExecuteType> = T
|
||||||
|
|
||||||
/** @see {@link MinterInstance} */
|
/** @see {@link VendingMinterInstance} */
|
||||||
export type DispatchExecuteArgs = {
|
export type DispatchExecuteArgs = {
|
||||||
contract: string
|
contract: string
|
||||||
messages?: MinterInstance
|
messages?: VendingMinterInstance
|
||||||
txSigner: string
|
txSigner: string
|
||||||
} & (
|
} & (
|
||||||
| { type: undefined }
|
| { type: undefined }
|
||||||
@ -160,7 +160,7 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
|
|
||||||
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages } = useMinterContract()
|
const { messages } = useVendingMinterContract()
|
||||||
const { contract } = args
|
const { contract } = args
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
case 'mint': {
|
case 'mint': {
|
@ -1,4 +1,4 @@
|
|||||||
import type { MinterInstance } from '../contract'
|
import type { VendingMinterInstance } from '../contract'
|
||||||
|
|
||||||
export type QueryType = typeof QUERY_TYPES[number]
|
export type QueryType = typeof QUERY_TYPES[number]
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ export const QUERY_LIST: QueryListItem[] = [
|
|||||||
|
|
||||||
export interface DispatchQueryProps {
|
export interface DispatchQueryProps {
|
||||||
address: string
|
address: string
|
||||||
messages: MinterInstance | undefined
|
messages: VendingMinterInstance | undefined
|
||||||
type: QueryType
|
type: QueryType
|
||||||
}
|
}
|
||||||
|
|
@ -3,8 +3,8 @@ import type { logs } from '@cosmjs/stargate'
|
|||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import { useCallback, useEffect, useState } from 'react'
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
import type { MigrateResponse, MinterContract, MinterInstance, MinterMessages } from './contract'
|
import type { MigrateResponse, VendingMinterContract, VendingMinterInstance, VendingMinterMessages } from './contract'
|
||||||
import { minter as initContract } from './contract'
|
import { vendingMinter as initContract } from './contract'
|
||||||
|
|
||||||
/*export interface InstantiateResponse {
|
/*export interface InstantiateResponse {
|
||||||
/** The address of the newly instantiated contract *-/
|
/** The address of the newly instantiated contract *-/
|
||||||
@ -24,7 +24,7 @@ interface InstantiateResponse {
|
|||||||
readonly logs: readonly logs.Log[]
|
readonly logs: readonly logs.Log[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UseMinterContractProps {
|
export interface UseVendingMinterContractProps {
|
||||||
instantiate: (
|
instantiate: (
|
||||||
codeId: number,
|
codeId: number,
|
||||||
initMsg: Record<string, unknown>,
|
initMsg: Record<string, unknown>,
|
||||||
@ -33,25 +33,25 @@ export interface UseMinterContractProps {
|
|||||||
funds?: Coin[],
|
funds?: Coin[],
|
||||||
) => Promise<InstantiateResponse>
|
) => Promise<InstantiateResponse>
|
||||||
migrate: (contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>) => Promise<MigrateResponse>
|
migrate: (contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>) => Promise<MigrateResponse>
|
||||||
use: (customAddress: string) => MinterInstance | undefined
|
use: (customAddress: string) => VendingMinterInstance | undefined
|
||||||
updateContractAddress: (contractAddress: string) => void
|
updateContractAddress: (contractAddress: string) => void
|
||||||
getContractAddress: () => string | undefined
|
getContractAddress: () => string | undefined
|
||||||
messages: (contractAddress: string) => MinterMessages | undefined
|
messages: (contractAddress: string) => VendingMinterMessages | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useMinterContract(): UseMinterContractProps {
|
export function useVendingMinterContract(): UseVendingMinterContractProps {
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
|
|
||||||
const [address, setAddress] = useState<string>('')
|
const [address, setAddress] = useState<string>('')
|
||||||
const [minter, setMinter] = useState<MinterContract>()
|
const [vendingMinter, setVendingMinter] = useState<VendingMinterContract>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAddress(localStorage.getItem('contract_address') || '')
|
setAddress(localStorage.getItem('contract_address') || '')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const MinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
const VendingMinterBaseContract = initContract(wallet.getClient(), wallet.address)
|
||||||
setMinter(MinterBaseContract)
|
setVendingMinter(VendingMinterBaseContract)
|
||||||
}, [wallet])
|
}, [wallet])
|
||||||
|
|
||||||
const updateContractAddress = (contractAddress: string) => {
|
const updateContractAddress = (contractAddress: string) => {
|
||||||
@ -61,35 +61,35 @@ export function useMinterContract(): UseMinterContractProps {
|
|||||||
const instantiate = useCallback(
|
const instantiate = useCallback(
|
||||||
(codeId: number, initMsg: Record<string, unknown>, label: string, admin?: string): Promise<InstantiateResponse> => {
|
(codeId: number, initMsg: Record<string, unknown>, label: string, admin?: string): Promise<InstantiateResponse> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!minter) {
|
if (!vendingMinter) {
|
||||||
reject(new Error('Contract is not initialized.'))
|
reject(new Error('Contract is not initialized.'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
minter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
vendingMinter.instantiate(wallet.address, codeId, initMsg, label, admin).then(resolve).catch(reject)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[minter, wallet],
|
[vendingMinter, wallet],
|
||||||
)
|
)
|
||||||
|
|
||||||
const migrate = useCallback(
|
const migrate = useCallback(
|
||||||
(contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>): Promise<MigrateResponse> => {
|
(contractAddress: string, codeId: number, migrateMsg: Record<string, unknown>): Promise<MigrateResponse> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!minter) {
|
if (!vendingMinter) {
|
||||||
reject(new Error('Contract is not initialized.'))
|
reject(new Error('Contract is not initialized.'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(wallet.address, contractAddress, codeId)
|
console.log(wallet.address, contractAddress, codeId)
|
||||||
minter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
vendingMinter.migrate(wallet.address, contractAddress, codeId, migrateMsg).then(resolve).catch(reject)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[minter, wallet],
|
[vendingMinter, wallet],
|
||||||
)
|
)
|
||||||
|
|
||||||
const use = useCallback(
|
const use = useCallback(
|
||||||
(customAddress = ''): MinterInstance | undefined => {
|
(customAddress = ''): VendingMinterInstance | undefined => {
|
||||||
return minter?.use(address || customAddress)
|
return vendingMinter?.use(address || customAddress)
|
||||||
},
|
},
|
||||||
[minter, address],
|
[vendingMinter, address],
|
||||||
)
|
)
|
||||||
|
|
||||||
const getContractAddress = (): string | undefined => {
|
const getContractAddress = (): string | undefined => {
|
||||||
@ -97,10 +97,10 @@ export function useMinterContract(): UseMinterContractProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const messages = useCallback(
|
const messages = useCallback(
|
||||||
(customAddress = ''): MinterMessages | undefined => {
|
(customAddress = ''): VendingMinterMessages | undefined => {
|
||||||
return minter?.messages(address || customAddress)
|
return vendingMinter?.messages(address || customAddress)
|
||||||
},
|
},
|
||||||
[minter, address],
|
[vendingMinter, address],
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
2
env.d.ts
vendored
2
env.d.ts
vendored
@ -18,6 +18,8 @@ declare namespace NodeJS {
|
|||||||
readonly NEXT_PUBLIC_WHITELIST_CODE_ID: string
|
readonly NEXT_PUBLIC_WHITELIST_CODE_ID: string
|
||||||
readonly NEXT_PUBLIC_VENDING_MINTER_CODE_ID: string
|
readonly NEXT_PUBLIC_VENDING_MINTER_CODE_ID: string
|
||||||
readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string
|
readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string
|
||||||
|
readonly NEXT_PUBLIC_BASE_FACTORY_ADDRESS: string
|
||||||
|
readonly NEXT_PUBLIC_BASE_MINTER_CODE_ID: string
|
||||||
|
|
||||||
readonly NEXT_PUBLIC_PINATA_ENDPOINT_URL: string
|
readonly NEXT_PUBLIC_PINATA_ENDPOINT_URL: string
|
||||||
readonly NEXT_PUBLIC_API_URL: string
|
readonly NEXT_PUBLIC_API_URL: string
|
||||||
|
@ -13,7 +13,7 @@ import { withMetadata } from 'utils/layout'
|
|||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
const CollectionActionsPage: NextPage = () => {
|
const CollectionActionsPage: NextPage = () => {
|
||||||
const { minter: minterContract, sg721: sg721Contract } = useContracts()
|
const { vendingMinter: vendingMinterContract, sg721: sg721Contract } = useContracts()
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
|
|
||||||
const [action, setAction] = useState<boolean>(false)
|
const [action, setAction] = useState<boolean>(false)
|
||||||
@ -32,9 +32,9 @@ const CollectionActionsPage: NextPage = () => {
|
|||||||
subtitle: 'Address of the Minter contract',
|
subtitle: 'Address of the Minter contract',
|
||||||
})
|
})
|
||||||
|
|
||||||
const minterMessages = useMemo(
|
const vendingMinterMessages = useMemo(
|
||||||
() => minterContract?.use(minterContractState.value),
|
() => vendingMinterContract?.use(minterContractState.value),
|
||||||
[minterContract, minterContractState.value],
|
[vendingMinterContract, minterContractState.value],
|
||||||
)
|
)
|
||||||
const sg721Messages = useMemo(
|
const sg721Messages = useMemo(
|
||||||
() => sg721Contract?.use(sg721ContractState.value),
|
() => sg721Contract?.use(sg721ContractState.value),
|
||||||
@ -126,14 +126,14 @@ const CollectionActionsPage: NextPage = () => {
|
|||||||
{(action && (
|
{(action && (
|
||||||
<CollectionActions
|
<CollectionActions
|
||||||
minterContractAddress={minterContractState.value}
|
minterContractAddress={minterContractState.value}
|
||||||
minterMessages={minterMessages}
|
minterMessages={vendingMinterMessages}
|
||||||
sg721ContractAddress={sg721ContractState.value}
|
sg721ContractAddress={sg721ContractState.value}
|
||||||
sg721Messages={sg721Messages}
|
sg721Messages={sg721Messages}
|
||||||
/>
|
/>
|
||||||
)) || (
|
)) || (
|
||||||
<CollectionQueries
|
<CollectionQueries
|
||||||
minterContractAddress={minterContractState.value}
|
minterContractAddress={minterContractState.value}
|
||||||
minterMessages={minterMessages}
|
minterMessages={vendingMinterMessages}
|
||||||
sg721ContractAddress={sg721ContractState.value}
|
sg721ContractAddress={sg721ContractState.value}
|
||||||
sg721Messages={sg721Messages}
|
sg721Messages={sg721Messages}
|
||||||
/>
|
/>
|
||||||
|
@ -49,7 +49,7 @@ import { getAssetType } from '../../utils/getAssetType'
|
|||||||
const CollectionCreationPage: NextPage = () => {
|
const CollectionCreationPage: NextPage = () => {
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
const {
|
const {
|
||||||
minter: minterContract,
|
vendingMinter: vendingMinterContract,
|
||||||
whitelist: whitelistContract,
|
whitelist: whitelistContract,
|
||||||
vendingFactory: vendingFactoryContract,
|
vendingFactory: vendingFactoryContract,
|
||||||
} = useContracts()
|
} = useContracts()
|
||||||
@ -69,7 +69,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
const [uploading, setUploading] = useState(false)
|
const [uploading, setUploading] = useState(false)
|
||||||
const [creatingCollection, setCreatingCollection] = useState(false)
|
const [creatingCollection, setCreatingCollection] = useState(false)
|
||||||
const [readyToCreate, setReadyToCreate] = useState(false)
|
const [readyToCreate, setReadyToCreate] = useState(false)
|
||||||
const [minterContractAddress, setMinterContractAddress] = useState<string | null>(null)
|
const [vendingMinterContractAddress, setVendingMinterContractAddress] = useState<string | null>(null)
|
||||||
const [sg721ContractAddress, setSg721ContractAddress] = useState<string | null>(null)
|
const [sg721ContractAddress, setSg721ContractAddress] = useState<string | null>(null)
|
||||||
const [whitelistContractAddress, setWhitelistContractAddress] = useState<string | null | undefined>(null)
|
const [whitelistContractAddress, setWhitelistContractAddress] = useState<string | null | undefined>(null)
|
||||||
const [baseTokenUri, setBaseTokenUri] = useState<string | null>(null)
|
const [baseTokenUri, setBaseTokenUri] = useState<string | null>(null)
|
||||||
@ -102,7 +102,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
setCreatingCollection(true)
|
setCreatingCollection(true)
|
||||||
setBaseTokenUri(null)
|
setBaseTokenUri(null)
|
||||||
setCoverImageUrl(null)
|
setCoverImageUrl(null)
|
||||||
setMinterContractAddress(null)
|
setVendingMinterContractAddress(null)
|
||||||
setSg721ContractAddress(null)
|
setSg721ContractAddress(null)
|
||||||
setWhitelistContractAddress(null)
|
setWhitelistContractAddress(null)
|
||||||
setTransactionHash(null)
|
setTransactionHash(null)
|
||||||
@ -176,7 +176,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
|
|
||||||
const instantiate = async (baseUri: string, coverImageUri: string, whitelist?: string) => {
|
const instantiate = async (baseUri: string, coverImageUri: string, whitelist?: string) => {
|
||||||
if (!wallet.initialized) throw new Error('Wallet not connected')
|
if (!wallet.initialized) throw new Error('Wallet not connected')
|
||||||
if (!minterContract) throw new Error('Contract not found')
|
if (!vendingMinterContract) throw new Error('Contract not found')
|
||||||
|
|
||||||
let royaltyInfo = null
|
let royaltyInfo = null
|
||||||
if (royaltyDetails?.royaltyType === 'new') {
|
if (royaltyDetails?.royaltyType === 'new') {
|
||||||
@ -229,7 +229,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
}
|
}
|
||||||
const data = await dispatchExecute(payload)
|
const data = await dispatchExecute(payload)
|
||||||
setTransactionHash(data.transactionHash)
|
setTransactionHash(data.transactionHash)
|
||||||
setMinterContractAddress(data.minterAddress)
|
setVendingMinterContractAddress(data.vendingMinterAddress)
|
||||||
setSg721ContractAddress(data.sg721Address)
|
setSg721ContractAddress(data.sg721Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,8 +399,8 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (minterContractAddress !== null) scrollRef.current?.scrollIntoView({ behavior: 'smooth' })
|
if (vendingMinterContractAddress !== null) scrollRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||||
}, [minterContractAddress])
|
}, [vendingMinterContractAddress])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBaseTokenUri(uploadDetails?.baseTokenURI as string)
|
setBaseTokenUri(uploadDetails?.baseTokenURI as string)
|
||||||
@ -427,7 +427,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mx-10" ref={scrollRef}>
|
<div className="mx-10" ref={scrollRef}>
|
||||||
<Conditional test={minterContractAddress !== null}>
|
<Conditional test={vendingMinterContractAddress !== null}>
|
||||||
<Alert className="mt-5" type="info">
|
<Alert className="mt-5" type="info">
|
||||||
<div>
|
<div>
|
||||||
Base Token URI:{' '}
|
Base Token URI:{' '}
|
||||||
@ -456,9 +456,9 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
<Anchor
|
<Anchor
|
||||||
className="text-stargaze hover:underline"
|
className="text-stargaze hover:underline"
|
||||||
external
|
external
|
||||||
href={`/contracts/minter/query/?contractAddress=${minterContractAddress as string}`}
|
href={`/contracts/minter/query/?contractAddress=${vendingMinterContractAddress as string}`}
|
||||||
>
|
>
|
||||||
{minterContractAddress}
|
{vendingMinterContractAddress}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
<br />
|
<br />
|
||||||
SG721 Contract Address:{' '}
|
SG721 Contract Address:{' '}
|
||||||
@ -504,7 +504,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
<Anchor
|
<Anchor
|
||||||
className="text-white"
|
className="text-white"
|
||||||
external
|
external
|
||||||
href={`${STARGAZE_URL}/launchpad/${minterContractAddress as string}`}
|
href={`${STARGAZE_URL}/launchpad/${vendingMinterContractAddress as string}`}
|
||||||
>
|
>
|
||||||
View on Launchpad
|
View on Launchpad
|
||||||
</Anchor>
|
</Anchor>
|
||||||
|
@ -16,7 +16,7 @@ import { withMetadata } from 'utils/layout'
|
|||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
const CollectionQueriesPage: NextPage = () => {
|
const CollectionQueriesPage: NextPage = () => {
|
||||||
const { minter: minterContract, sg721: sg721Contract } = useContracts()
|
const { vendingMinter: vendingMinterContract, sg721: sg721Contract } = useContracts()
|
||||||
|
|
||||||
const comboboxState = useQueryComboboxState()
|
const comboboxState = useQueryComboboxState()
|
||||||
const type = comboboxState.value?.id
|
const type = comboboxState.value?.id
|
||||||
@ -57,19 +57,19 @@ const CollectionQueriesPage: NextPage = () => {
|
|||||||
const showTokenIdField = type === 'token_info'
|
const showTokenIdField = type === 'token_info'
|
||||||
const showAddressField = type === 'tokens_minted_to_user'
|
const showAddressField = type === 'tokens_minted_to_user'
|
||||||
|
|
||||||
const minterMessages = useMemo(
|
const vendingMinterMessages = useMemo(
|
||||||
() => minterContract?.use(minterContractAddress),
|
() => vendingMinterContract?.use(minterContractAddress),
|
||||||
[minterContract, minterContractAddress],
|
[vendingMinterContract, minterContractAddress],
|
||||||
)
|
)
|
||||||
const sg721Messages = useMemo(() => sg721Contract?.use(sg721ContractAddress), [sg721Contract, sg721ContractAddress])
|
const sg721Messages = useMemo(() => sg721Contract?.use(sg721ContractAddress), [sg721Contract, sg721ContractAddress])
|
||||||
|
|
||||||
const { data: response } = useQuery(
|
const { data: response } = useQuery(
|
||||||
[sg721Messages, minterMessages, type, tokenId, address] as const,
|
[sg721Messages, vendingMinterMessages, type, tokenId, address] as const,
|
||||||
async ({ queryKey }) => {
|
async ({ queryKey }) => {
|
||||||
const [_sg721Messages, _minterMessages, _type, _tokenId, _address] = queryKey
|
const [_sg721Messages, _vendingMinterMessages, _type, _tokenId, _address] = queryKey
|
||||||
const result = await dispatchQuery({
|
const result = await dispatchQuery({
|
||||||
tokenId: _tokenId,
|
tokenId: _tokenId,
|
||||||
minterMessages: _minterMessages,
|
minterMessages: _vendingMinterMessages,
|
||||||
sg721Messages: _sg721Messages,
|
sg721Messages: _sg721Messages,
|
||||||
address: _address,
|
address: _address,
|
||||||
type: _type,
|
type: _type,
|
||||||
|
145
pages/contracts/baseMinter/execute.tsx
Normal file
145
pages/contracts/baseMinter/execute.tsx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import { Button } from 'components/Button'
|
||||||
|
import { Conditional } from 'components/Conditional'
|
||||||
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
|
import { ExecuteCombobox } from 'components/contracts/baseMinter/ExecuteCombobox'
|
||||||
|
import { useExecuteComboboxState } from 'components/contracts/baseMinter/ExecuteCombobox.hooks'
|
||||||
|
import { FormControl } from 'components/FormControl'
|
||||||
|
import { AddressInput, TextInput } from 'components/forms/FormInput'
|
||||||
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
|
import { InputDateTime } from 'components/InputDateTime'
|
||||||
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
|
import { baseMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
|
import { TransactionHash } from 'components/TransactionHash'
|
||||||
|
import { useContracts } from 'contexts/contracts'
|
||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import type { DispatchExecuteArgs } from 'contracts/baseMinter/messages/execute'
|
||||||
|
import { dispatchExecute, previewExecutePayload } from 'contracts/baseMinter/messages/execute'
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
import { NextSeo } from 'next-seo'
|
||||||
|
import type { FormEvent } from 'react'
|
||||||
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
|
import { toast } from 'react-hot-toast'
|
||||||
|
import { FaArrowRight } from 'react-icons/fa'
|
||||||
|
import { useMutation } from 'react-query'
|
||||||
|
import { withMetadata } from 'utils/layout'
|
||||||
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
|
const BaseMinterExecutePage: NextPage = () => {
|
||||||
|
const { baseMinter: contract } = useContracts()
|
||||||
|
const wallet = useWallet()
|
||||||
|
const [lastTx, setLastTx] = useState('')
|
||||||
|
|
||||||
|
const [timestamp, setTimestamp] = useState<Date | undefined>(undefined)
|
||||||
|
|
||||||
|
const comboboxState = useExecuteComboboxState()
|
||||||
|
const type = comboboxState.value?.id
|
||||||
|
|
||||||
|
const contractState = useInputState({
|
||||||
|
id: 'contract-address',
|
||||||
|
name: 'contract-address',
|
||||||
|
title: 'Base Minter Address',
|
||||||
|
subtitle: 'Address of the Base Minter contract',
|
||||||
|
})
|
||||||
|
|
||||||
|
const tokenUriState = useInputState({
|
||||||
|
id: 'token-uri',
|
||||||
|
name: 'token-uri',
|
||||||
|
title: 'Token URI',
|
||||||
|
placeholder: 'ipfs://',
|
||||||
|
})
|
||||||
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
|
const showDateField = type === 'update_start_trading_time'
|
||||||
|
const showTokenUriField = type === 'mint'
|
||||||
|
|
||||||
|
const messages = useMemo(() => contract?.use(contractState.value), [contract, wallet.address, contractState.value])
|
||||||
|
const payload: DispatchExecuteArgs = {
|
||||||
|
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
|
||||||
|
tokenUri: tokenUriState.value,
|
||||||
|
contract: contractState.value,
|
||||||
|
messages,
|
||||||
|
txSigner: wallet.address,
|
||||||
|
type,
|
||||||
|
}
|
||||||
|
const { isLoading, mutate } = useMutation(
|
||||||
|
async (event: FormEvent) => {
|
||||||
|
event.preventDefault()
|
||||||
|
if (!type) {
|
||||||
|
throw new Error('Please select message type!')
|
||||||
|
}
|
||||||
|
if (!wallet.initialized) {
|
||||||
|
throw new Error('Please connect your wallet.')
|
||||||
|
}
|
||||||
|
const txHash = await toast.promise(dispatchExecute(payload), {
|
||||||
|
error: `${type.charAt(0).toUpperCase() + type.slice(1)} execute failed!`,
|
||||||
|
loading: 'Executing message...',
|
||||||
|
success: (tx) => `Transaction ${tx} success!`,
|
||||||
|
})
|
||||||
|
if (txHash) {
|
||||||
|
setLastTx(txHash)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onError: (error) => {
|
||||||
|
toast.error(String(error), { style: { maxWidth: 'none' } })
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (contractAddress.length > 0) {
|
||||||
|
void router.replace({ query: { contractAddress } })
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [contractAddress])
|
||||||
|
useEffect(() => {
|
||||||
|
const initial = new URL(document.URL).searchParams.get('contractAddress')
|
||||||
|
if (initial && initial.length > 0) contractState.onChange(initial)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="py-6 px-12 space-y-4">
|
||||||
|
<NextSeo title="Execute Base Minter Contract" />
|
||||||
|
<ContractPageHeader
|
||||||
|
description="Base Minter contract facilitates 1/1 minting."
|
||||||
|
link={links.Documentation}
|
||||||
|
title="Base Minter Contract"
|
||||||
|
/>
|
||||||
|
<LinkTabs activeIndex={2} data={baseMinterLinkTabs} />
|
||||||
|
|
||||||
|
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
||||||
|
<div className="space-y-8">
|
||||||
|
<AddressInput {...contractState} />
|
||||||
|
<ExecuteCombobox {...comboboxState} />
|
||||||
|
<Conditional test={showTokenUriField}>
|
||||||
|
<TextInput {...tokenUriState} />
|
||||||
|
</Conditional>
|
||||||
|
<Conditional test={showDateField}>
|
||||||
|
<FormControl htmlId="start-date" subtitle="Start time for trading." title="Trading Start Time">
|
||||||
|
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
||||||
|
</FormControl>
|
||||||
|
</Conditional>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-8">
|
||||||
|
<div className="relative">
|
||||||
|
<Button className="absolute top-0 right-0" isLoading={isLoading} rightIcon={<FaArrowRight />} type="submit">
|
||||||
|
Execute
|
||||||
|
</Button>
|
||||||
|
<FormControl subtitle="View execution transaction hash" title="Transaction Hash">
|
||||||
|
<TransactionHash hash={lastTx} />
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
<FormControl subtitle="View current message to be sent" title="Payload Preview">
|
||||||
|
<JsonPreview content={previewExecutePayload(payload)} isCopyable />
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withMetadata(BaseMinterExecutePage, { center: false })
|
259
pages/contracts/baseMinter/instantiate.tsx
Normal file
259
pages/contracts/baseMinter/instantiate.tsx
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
import { coin } from '@cosmjs/proto-signing'
|
||||||
|
import { Alert } from 'components/Alert'
|
||||||
|
import { Button } from 'components/Button'
|
||||||
|
import { Conditional } from 'components/Conditional'
|
||||||
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
|
import { FormControl } from 'components/FormControl'
|
||||||
|
import { FormGroup } from 'components/FormGroup'
|
||||||
|
import { NumberInput, TextInput } from 'components/forms/FormInput'
|
||||||
|
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
||||||
|
import { FormTextArea } from 'components/forms/FormTextArea'
|
||||||
|
import { InputDateTime } from 'components/InputDateTime'
|
||||||
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
|
import { baseMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
|
import { useContracts } from 'contexts/contracts'
|
||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import { NextSeo } from 'next-seo'
|
||||||
|
import type { FormEvent } from 'react'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { toast } from 'react-hot-toast'
|
||||||
|
import { FaAsterisk } from 'react-icons/fa'
|
||||||
|
import { useMutation } from 'react-query'
|
||||||
|
import { BASE_FACTORY_ADDRESS } from 'utils/constants'
|
||||||
|
import { withMetadata } from 'utils/layout'
|
||||||
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
|
import type { CreateBaseMinterResponse } from '../../../contracts/baseFactory/contract'
|
||||||
|
import { SG721_CODE_ID } from '../../../utils/constants'
|
||||||
|
|
||||||
|
const BaseMinterInstantiatePage: NextPage = () => {
|
||||||
|
const wallet = useWallet()
|
||||||
|
const contract = useContracts().baseFactory
|
||||||
|
|
||||||
|
const [timestamp, setTimestamp] = useState<Date | undefined>()
|
||||||
|
const [explicit, setExplicit] = useState<boolean>(false)
|
||||||
|
|
||||||
|
const nameState = useInputState({
|
||||||
|
id: 'name',
|
||||||
|
name: 'name',
|
||||||
|
title: 'Name',
|
||||||
|
placeholder: 'My Awesome SG721 Contract',
|
||||||
|
subtitle: 'Name of the sg721 contract',
|
||||||
|
})
|
||||||
|
|
||||||
|
const symbolState = useInputState({
|
||||||
|
id: 'symbol',
|
||||||
|
name: 'symbol',
|
||||||
|
title: 'Symbol',
|
||||||
|
placeholder: 'AWSM',
|
||||||
|
subtitle: 'Symbol of the sg721 contract',
|
||||||
|
})
|
||||||
|
|
||||||
|
const codeIdState = useNumberInputState({
|
||||||
|
id: 'code-id',
|
||||||
|
name: 'code-id',
|
||||||
|
title: 'Code ID',
|
||||||
|
subtitle: 'Code ID for the sg721 contract',
|
||||||
|
placeholder: '1',
|
||||||
|
defaultValue: SG721_CODE_ID,
|
||||||
|
})
|
||||||
|
|
||||||
|
const creatorState = useInputState({
|
||||||
|
id: 'creator-address',
|
||||||
|
name: 'creatorAddress',
|
||||||
|
title: 'Creator Address',
|
||||||
|
placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...',
|
||||||
|
subtitle: 'Address of the collection creator',
|
||||||
|
defaultValue: wallet.address,
|
||||||
|
})
|
||||||
|
|
||||||
|
const descriptionState = useInputState({
|
||||||
|
id: 'description',
|
||||||
|
name: 'description',
|
||||||
|
title: 'Description',
|
||||||
|
subtitle: 'Description of the collection',
|
||||||
|
})
|
||||||
|
|
||||||
|
const imageState = useInputState({
|
||||||
|
id: 'image',
|
||||||
|
name: 'image',
|
||||||
|
title: 'Image',
|
||||||
|
subtitle: 'Image of the collection',
|
||||||
|
placeholder: 'ipfs://bafybe....',
|
||||||
|
})
|
||||||
|
|
||||||
|
const externalLinkState = useInputState({
|
||||||
|
id: 'external-link',
|
||||||
|
name: 'externalLink',
|
||||||
|
title: 'External Link (optional)',
|
||||||
|
subtitle: 'External link to the collection',
|
||||||
|
})
|
||||||
|
|
||||||
|
const royaltyPaymentAddressState = useInputState({
|
||||||
|
id: 'royalty-payment-address',
|
||||||
|
name: 'royaltyPaymentAddress',
|
||||||
|
title: 'Payment Address',
|
||||||
|
subtitle: 'Address to receive royalties',
|
||||||
|
placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...',
|
||||||
|
})
|
||||||
|
|
||||||
|
const royaltyShareState = useInputState({
|
||||||
|
id: 'royalty-share',
|
||||||
|
name: 'royaltyShare',
|
||||||
|
title: 'Share Percentage',
|
||||||
|
subtitle: 'Percentage of royalties to be paid',
|
||||||
|
placeholder: '8%',
|
||||||
|
})
|
||||||
|
|
||||||
|
const { data, isLoading, mutate } = useMutation(
|
||||||
|
async (event: FormEvent): Promise<CreateBaseMinterResponse | null> => {
|
||||||
|
event.preventDefault()
|
||||||
|
if (!contract) {
|
||||||
|
throw new Error('Smart contract connection failed')
|
||||||
|
}
|
||||||
|
|
||||||
|
let royaltyInfo = null
|
||||||
|
if (royaltyPaymentAddressState.value && royaltyShareState.value) {
|
||||||
|
royaltyInfo = {
|
||||||
|
payment_address: royaltyPaymentAddressState.value,
|
||||||
|
share: (Number(royaltyShareState.value) / 100).toString(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const msg = {
|
||||||
|
create_minter: {
|
||||||
|
collection_params: {
|
||||||
|
code_id: codeIdState.value,
|
||||||
|
name: nameState.value,
|
||||||
|
symbol: symbolState.value,
|
||||||
|
info: {
|
||||||
|
creator: creatorState.value,
|
||||||
|
description: descriptionState.value,
|
||||||
|
image: imageState.value,
|
||||||
|
external_link: externalLinkState.value || null,
|
||||||
|
explicit_content: explicit,
|
||||||
|
start_trading_time: timestamp ? (timestamp.getTime() * 1_000_000).toString() : null,
|
||||||
|
royalty_info: royaltyInfo,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return toast.promise(
|
||||||
|
contract
|
||||||
|
.use(BASE_FACTORY_ADDRESS)
|
||||||
|
?.createBaseMinter(wallet.address, msg, [coin('1000000000', 'ustars')]) as Promise<CreateBaseMinterResponse>,
|
||||||
|
{
|
||||||
|
loading: 'Instantiating contract...',
|
||||||
|
error: 'Instantiation failed!',
|
||||||
|
success: 'Instantiation success!',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onError: (error) => {
|
||||||
|
toast.error(String(error), { style: { maxWidth: 'none' } })
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const txHash = data?.transactionHash
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form className="py-6 px-12 space-y-4" onSubmit={mutate}>
|
||||||
|
<NextSeo title="Instantiate Base Minter Contract" />
|
||||||
|
<ContractPageHeader
|
||||||
|
description="Base Minter contract facilitates 1/1 minting."
|
||||||
|
link={links.Documentation}
|
||||||
|
title="Base Minter Contract"
|
||||||
|
/>
|
||||||
|
<LinkTabs activeIndex={0} data={baseMinterLinkTabs} />
|
||||||
|
|
||||||
|
<Conditional test={Boolean(data)}>
|
||||||
|
<Alert type="info">
|
||||||
|
<b>Instantiate success!</b> Here is the transaction result containing the contract address and the transaction
|
||||||
|
hash.
|
||||||
|
</Alert>
|
||||||
|
<JsonPreview content={data} title="Transaction Result" />
|
||||||
|
<br />
|
||||||
|
</Conditional>
|
||||||
|
|
||||||
|
<FormGroup subtitle="Information about your sg721 contract" title="SG721 Contract Details">
|
||||||
|
<NumberInput isRequired {...codeIdState} />
|
||||||
|
<TextInput isRequired {...nameState} />
|
||||||
|
<TextInput isRequired {...symbolState} />
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
|
<FormGroup subtitle="Information about your collection" title="Collection Details">
|
||||||
|
<TextInput isRequired {...creatorState} />
|
||||||
|
<FormTextArea isRequired {...descriptionState} />
|
||||||
|
<TextInput isRequired {...imageState} />
|
||||||
|
<TextInput {...externalLinkState} />
|
||||||
|
<FormControl htmlId="timestamp" subtitle="Trading start time (local)" title="Trading Start Time (optional)">
|
||||||
|
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
||||||
|
</FormControl>
|
||||||
|
<div className="flex flex-col space-y-2">
|
||||||
|
<div>
|
||||||
|
<div className="flex">
|
||||||
|
<span className="mt-1 text-sm first-letter:capitalize">
|
||||||
|
Does the collection contain explicit content?
|
||||||
|
</span>
|
||||||
|
<div className="ml-2 font-bold form-check form-check-inline">
|
||||||
|
<input
|
||||||
|
checked={explicit}
|
||||||
|
className="peer sr-only"
|
||||||
|
id="explicitRadio1"
|
||||||
|
name="explicitRadioOptions1"
|
||||||
|
onClick={() => {
|
||||||
|
setExplicit(true)
|
||||||
|
}}
|
||||||
|
type="radio"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="inline-block py-1 px-2 text-sm text-gray peer-checked:text-white hover:text-white peer-checked:bg-black hover:rounded-sm peer-checked:border-b-2 hover:border-b-2 peer-checked:border-plumbus hover:border-plumbus cursor-pointer form-check-label"
|
||||||
|
htmlFor="explicitRadio1"
|
||||||
|
>
|
||||||
|
YES
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="ml-2 font-bold form-check form-check-inline">
|
||||||
|
<input
|
||||||
|
checked={!explicit}
|
||||||
|
className="peer sr-only"
|
||||||
|
id="explicitRadio2"
|
||||||
|
name="explicitRadioOptions2"
|
||||||
|
onClick={() => {
|
||||||
|
setExplicit(false)
|
||||||
|
}}
|
||||||
|
type="radio"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="inline-block py-1 px-2 text-sm text-gray peer-checked:text-white hover:text-white peer-checked:bg-black hover:rounded-sm peer-checked:border-b-2 hover:border-b-2 peer-checked:border-plumbus hover:border-plumbus cursor-pointer form-check-label"
|
||||||
|
htmlFor="explicitRadio2"
|
||||||
|
>
|
||||||
|
NO
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
|
<FormGroup subtitle="Information about royalty" title="Royalty Details (optional)">
|
||||||
|
<TextInput {...royaltyPaymentAddressState} />
|
||||||
|
<NumberInput {...royaltyShareState} />
|
||||||
|
</FormGroup>
|
||||||
|
|
||||||
|
<div className="flex items-center p-4">
|
||||||
|
<div className="flex-grow" />
|
||||||
|
<Button isLoading={isLoading} isWide rightIcon={<FaAsterisk />} type="submit">
|
||||||
|
Instantiate Contract
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withMetadata(BaseMinterInstantiatePage, { center: false })
|
@ -1,16 +1,16 @@
|
|||||||
import { Button } from 'components/Button'
|
import { Button } from 'components/Button'
|
||||||
import { ContractPageHeader } from 'components/ContractPageHeader'
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
import { useExecuteComboboxState } from 'components/contracts/minter/ExecuteCombobox.hooks'
|
import { useExecuteComboboxState } from 'components/contracts/baseMinter/ExecuteCombobox.hooks'
|
||||||
import { FormControl } from 'components/FormControl'
|
import { FormControl } from 'components/FormControl'
|
||||||
import { AddressInput, NumberInput } from 'components/forms/FormInput'
|
import { AddressInput, NumberInput } from 'components/forms/FormInput'
|
||||||
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import { LinkTabs } from 'components/LinkTabs'
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
import { minterLinkTabs } from 'components/LinkTabs.data'
|
import { baseMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
import { TransactionHash } from 'components/TransactionHash'
|
import { TransactionHash } from 'components/TransactionHash'
|
||||||
import { useContracts } from 'contexts/contracts'
|
import { useContracts } from 'contexts/contracts'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { MigrateResponse } from 'contracts/minter'
|
import type { MigrateResponse } from 'contracts/baseMinter'
|
||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { NextSeo } from 'next-seo'
|
import { NextSeo } from 'next-seo'
|
||||||
@ -22,8 +22,8 @@ import { useMutation } from 'react-query'
|
|||||||
import { withMetadata } from 'utils/layout'
|
import { withMetadata } from 'utils/layout'
|
||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
const MinterMigratePage: NextPage = () => {
|
const BaseMinterMigratePage: NextPage = () => {
|
||||||
const { minter: contract } = useContracts()
|
const { baseMinter: contract } = useContracts()
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
|
|
||||||
const [lastTx, setLastTx] = useState('')
|
const [lastTx, setLastTx] = useState('')
|
||||||
@ -34,15 +34,15 @@ const MinterMigratePage: NextPage = () => {
|
|||||||
id: 'code-id',
|
id: 'code-id',
|
||||||
name: 'code-id',
|
name: 'code-id',
|
||||||
title: 'Code ID',
|
title: 'Code ID',
|
||||||
subtitle: 'Code ID of the New Minter',
|
subtitle: 'Code ID of the New Base Minter',
|
||||||
placeholder: '1',
|
placeholder: '1',
|
||||||
})
|
})
|
||||||
|
|
||||||
const contractState = useInputState({
|
const contractState = useInputState({
|
||||||
id: 'contract-address',
|
id: 'contract-address',
|
||||||
name: 'contract-address',
|
name: 'contract-address',
|
||||||
title: 'Minter Address',
|
title: 'Base Minter Address',
|
||||||
subtitle: 'Address of the Minter contract',
|
subtitle: 'Address of the Base Minter contract',
|
||||||
})
|
})
|
||||||
const contractAddress = contractState.value
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
@ -90,13 +90,13 @@ const MinterMigratePage: NextPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="py-6 px-12 space-y-4">
|
<section className="py-6 px-12 space-y-4">
|
||||||
<NextSeo title="Migrate Minter Contract" />
|
<NextSeo title="Migrate Base Minter Contract" />
|
||||||
<ContractPageHeader
|
<ContractPageHeader
|
||||||
description="Minter contract facilitates primary market vending machine style minting."
|
description="Base Minter contract facilitates 1/1 minting."
|
||||||
link={links.Documentation}
|
link={links.Documentation}
|
||||||
title="Minter Contract"
|
title="Base Minter Contract"
|
||||||
/>
|
/>
|
||||||
<LinkTabs activeIndex={3} data={minterLinkTabs} />
|
<LinkTabs activeIndex={3} data={baseMinterLinkTabs} />
|
||||||
|
|
||||||
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
@ -129,4 +129,4 @@ const MinterMigratePage: NextPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withMetadata(MinterMigratePage, { center: false })
|
export default withMetadata(BaseMinterMigratePage, { center: false })
|
116
pages/contracts/baseMinter/query.tsx
Normal file
116
pages/contracts/baseMinter/query.tsx
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import clsx from 'clsx'
|
||||||
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
|
import { FormControl } from 'components/FormControl'
|
||||||
|
import { AddressInput } from 'components/forms/FormInput'
|
||||||
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
|
import { baseMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
|
import { useContracts } from 'contexts/contracts'
|
||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import type { QueryType } from 'contracts/baseMinter/messages/query'
|
||||||
|
import { dispatchQuery, QUERY_LIST } from 'contracts/baseMinter/messages/query'
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
import { NextSeo } from 'next-seo'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { toast } from 'react-hot-toast'
|
||||||
|
import { useQuery } from 'react-query'
|
||||||
|
import { withMetadata } from 'utils/layout'
|
||||||
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
|
const BaseMinterQueryPage: NextPage = () => {
|
||||||
|
const { baseMinter: contract } = useContracts()
|
||||||
|
const wallet = useWallet()
|
||||||
|
|
||||||
|
const contractState = useInputState({
|
||||||
|
id: 'contract-address',
|
||||||
|
name: 'contract-address',
|
||||||
|
title: 'Base Minter Address',
|
||||||
|
subtitle: 'Address of the Base Minter contract',
|
||||||
|
})
|
||||||
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
|
const addressState = useInputState({
|
||||||
|
id: 'address',
|
||||||
|
name: 'address',
|
||||||
|
title: 'Address',
|
||||||
|
subtitle: 'Address of the user - defaults to current address',
|
||||||
|
})
|
||||||
|
const address = addressState.value
|
||||||
|
|
||||||
|
const [type, setType] = useState<QueryType>('config')
|
||||||
|
|
||||||
|
const { data: response } = useQuery(
|
||||||
|
[contractAddress, type, contract, wallet, address] as const,
|
||||||
|
async ({ queryKey }) => {
|
||||||
|
const [_contractAddress, _type, _contract, _wallet] = queryKey
|
||||||
|
const messages = contract?.use(_contractAddress)
|
||||||
|
const result = await dispatchQuery({
|
||||||
|
address,
|
||||||
|
messages,
|
||||||
|
type,
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
{
|
||||||
|
placeholderData: null,
|
||||||
|
onError: (error: any) => {
|
||||||
|
toast.error(error.message, { style: { maxWidth: 'none' } })
|
||||||
|
},
|
||||||
|
enabled: Boolean(contractAddress && contract && wallet),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (contractAddress.length > 0) {
|
||||||
|
void router.replace({ query: { contractAddress } })
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [contractAddress])
|
||||||
|
useEffect(() => {
|
||||||
|
const initial = new URL(document.URL).searchParams.get('contractAddress')
|
||||||
|
if (initial && initial.length > 0) contractState.onChange(initial)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="py-6 px-12 space-y-4">
|
||||||
|
<NextSeo title="Query Base Minter Contract" />
|
||||||
|
<ContractPageHeader
|
||||||
|
description="Base Minter contract facilitates 1/1 minting."
|
||||||
|
link={links.Documentation}
|
||||||
|
title="Base Minter Contract"
|
||||||
|
/>
|
||||||
|
<LinkTabs activeIndex={1} data={baseMinterLinkTabs} />
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 p-4 space-x-8">
|
||||||
|
<div className="space-y-8">
|
||||||
|
<AddressInput {...contractState} />
|
||||||
|
<FormControl htmlId="contract-query-type" subtitle="Type of query to be dispatched" title="Query Type">
|
||||||
|
<select
|
||||||
|
className={clsx(
|
||||||
|
'bg-white/10 rounded border-2 border-white/20 form-select',
|
||||||
|
'placeholder:text-white/50',
|
||||||
|
'focus:ring focus:ring-plumbus-20',
|
||||||
|
)}
|
||||||
|
id="contract-query-type"
|
||||||
|
name="query-type"
|
||||||
|
onChange={(e) => setType(e.target.value as QueryType)}
|
||||||
|
>
|
||||||
|
{QUERY_LIST.map(({ id, name }) => (
|
||||||
|
<option key={`query-${id}`} value={id}>
|
||||||
|
{name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
<JsonPreview content={contractAddress ? { type, response } : null} title="Query Response" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withMetadata(BaseMinterQueryPage, { center: false })
|
@ -1,20 +1,20 @@
|
|||||||
import { Button } from 'components/Button'
|
import { Button } from 'components/Button'
|
||||||
import { Conditional } from 'components/Conditional'
|
import { Conditional } from 'components/Conditional'
|
||||||
import { ContractPageHeader } from 'components/ContractPageHeader'
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
import { ExecuteCombobox } from 'components/contracts/minter/ExecuteCombobox'
|
import { ExecuteCombobox } from 'components/contracts/vendingMinter/ExecuteCombobox'
|
||||||
import { useExecuteComboboxState } from 'components/contracts/minter/ExecuteCombobox.hooks'
|
import { useExecuteComboboxState } from 'components/contracts/vendingMinter/ExecuteCombobox.hooks'
|
||||||
import { FormControl } from 'components/FormControl'
|
import { FormControl } from 'components/FormControl'
|
||||||
import { AddressInput, NumberInput } from 'components/forms/FormInput'
|
import { AddressInput, NumberInput } from 'components/forms/FormInput'
|
||||||
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
||||||
import { InputDateTime } from 'components/InputDateTime'
|
import { InputDateTime } from 'components/InputDateTime'
|
||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import { LinkTabs } from 'components/LinkTabs'
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
import { minterLinkTabs } from 'components/LinkTabs.data'
|
import { vendingMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
import { TransactionHash } from 'components/TransactionHash'
|
import { TransactionHash } from 'components/TransactionHash'
|
||||||
import { useContracts } from 'contexts/contracts'
|
import { useContracts } from 'contexts/contracts'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { DispatchExecuteArgs } from 'contracts/minter/messages/execute'
|
import type { DispatchExecuteArgs } from 'contracts/vendingMinter/messages/execute'
|
||||||
import { dispatchExecute, isEitherType, previewExecutePayload } from 'contracts/minter/messages/execute'
|
import { dispatchExecute, isEitherType, previewExecutePayload } from 'contracts/vendingMinter/messages/execute'
|
||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { NextSeo } from 'next-seo'
|
import { NextSeo } from 'next-seo'
|
||||||
@ -26,8 +26,8 @@ import { useMutation } from 'react-query'
|
|||||||
import { withMetadata } from 'utils/layout'
|
import { withMetadata } from 'utils/layout'
|
||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
const MinterExecutePage: NextPage = () => {
|
const VendingMinterExecutePage: NextPage = () => {
|
||||||
const { minter: contract } = useContracts()
|
const { vendingMinter: contract } = useContracts()
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
const [lastTx, setLastTx] = useState('')
|
const [lastTx, setLastTx] = useState('')
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ const MinterExecutePage: NextPage = () => {
|
|||||||
const contractState = useInputState({
|
const contractState = useInputState({
|
||||||
id: 'contract-address',
|
id: 'contract-address',
|
||||||
name: 'contract-address',
|
name: 'contract-address',
|
||||||
title: 'Minter Address',
|
title: 'Vending Minter Address',
|
||||||
subtitle: 'Address of the Minter contract',
|
subtitle: 'Address of the Vending Minter contract',
|
||||||
})
|
})
|
||||||
const contractAddress = contractState.value
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
@ -139,13 +139,13 @@ const MinterExecutePage: NextPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="py-6 px-12 space-y-4">
|
<section className="py-6 px-12 space-y-4">
|
||||||
<NextSeo title="Execute Minter Contract" />
|
<NextSeo title="Execute Vending Minter Contract" />
|
||||||
<ContractPageHeader
|
<ContractPageHeader
|
||||||
description="Minter contract facilitates primary market vending machine style minting."
|
description="Vending Minter contract facilitates primary market vending machine style minting."
|
||||||
link={links.Documentation}
|
link={links.Documentation}
|
||||||
title="Minter Contract"
|
title="Vending Minter Contract"
|
||||||
/>
|
/>
|
||||||
<LinkTabs activeIndex={2} data={minterLinkTabs} />
|
<LinkTabs activeIndex={2} data={vendingMinterLinkTabs} />
|
||||||
|
|
||||||
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
@ -181,4 +181,4 @@ const MinterExecutePage: NextPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withMetadata(MinterExecutePage, { center: false })
|
export default withMetadata(VendingMinterExecutePage, { center: false })
|
1
pages/contracts/vendingMinter/index.tsx
Normal file
1
pages/contracts/vendingMinter/index.tsx
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from './instantiate'
|
@ -11,7 +11,7 @@ import { FormTextArea } from 'components/forms/FormTextArea'
|
|||||||
import { InputDateTime } from 'components/InputDateTime'
|
import { InputDateTime } from 'components/InputDateTime'
|
||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import { LinkTabs } from 'components/LinkTabs'
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
import { minterLinkTabs } from 'components/LinkTabs.data'
|
import { vendingMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
import { useContracts } from 'contexts/contracts'
|
import { useContracts } from 'contexts/contracts'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
@ -25,9 +25,9 @@ import { VENDING_FACTORY_ADDRESS } from 'utils/constants'
|
|||||||
import { withMetadata } from 'utils/layout'
|
import { withMetadata } from 'utils/layout'
|
||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
import type { CreateMinterResponse } from '../../../contracts/vendingFactory/contract'
|
import type { CreateVendingMinterResponse } from '../../../contracts/vendingFactory/contract'
|
||||||
|
|
||||||
const MinterInstantiatePage: NextPage = () => {
|
const VendingMinterInstantiatePage: NextPage = () => {
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
const contract = useContracts().vendingFactory
|
const contract = useContracts().vendingFactory
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ const MinterInstantiatePage: NextPage = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const { data, isLoading, mutate } = useMutation(
|
const { data, isLoading, mutate } = useMutation(
|
||||||
async (event: FormEvent): Promise<CreateMinterResponse | null> => {
|
async (event: FormEvent): Promise<CreateVendingMinterResponse | null> => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (!contract) {
|
if (!contract) {
|
||||||
throw new Error('Smart contract connection failed')
|
throw new Error('Smart contract connection failed')
|
||||||
@ -206,7 +206,9 @@ const MinterInstantiatePage: NextPage = () => {
|
|||||||
return toast.promise(
|
return toast.promise(
|
||||||
contract
|
contract
|
||||||
.use(VENDING_FACTORY_ADDRESS)
|
.use(VENDING_FACTORY_ADDRESS)
|
||||||
?.createMinter(wallet.address, msg, [coin('1000000000', 'ustars')]) as Promise<CreateMinterResponse>,
|
?.createVendingMinter(wallet.address, msg, [
|
||||||
|
coin('1000000000', 'ustars'),
|
||||||
|
]) as Promise<CreateVendingMinterResponse>,
|
||||||
{
|
{
|
||||||
loading: 'Instantiating contract...',
|
loading: 'Instantiating contract...',
|
||||||
error: 'Instantiation failed!',
|
error: 'Instantiation failed!',
|
||||||
@ -225,13 +227,13 @@ const MinterInstantiatePage: NextPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="py-6 px-12 space-y-4" onSubmit={mutate}>
|
<form className="py-6 px-12 space-y-4" onSubmit={mutate}>
|
||||||
<NextSeo title="Instantiate Minter Contract" />
|
<NextSeo title="Instantiate Vending Minter Contract" />
|
||||||
<ContractPageHeader
|
<ContractPageHeader
|
||||||
description="Minter contract facilitates primary market vending machine style minting."
|
description="Vending Minter contract facilitates primary market vending machine style minting."
|
||||||
link={links.Documentation}
|
link={links.Documentation}
|
||||||
title="Minter Contract"
|
title="Vending Minter Contract"
|
||||||
/>
|
/>
|
||||||
<LinkTabs activeIndex={0} data={minterLinkTabs} />
|
<LinkTabs activeIndex={0} data={vendingMinterLinkTabs} />
|
||||||
|
|
||||||
<Conditional test={Boolean(data)}>
|
<Conditional test={Boolean(data)}>
|
||||||
<Alert type="info">
|
<Alert type="info">
|
||||||
@ -329,4 +331,4 @@ const MinterInstantiatePage: NextPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withMetadata(MinterInstantiatePage, { center: false })
|
export default withMetadata(VendingMinterInstantiatePage, { center: false })
|
132
pages/contracts/vendingMinter/migrate.tsx
Normal file
132
pages/contracts/vendingMinter/migrate.tsx
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
import { Button } from 'components/Button'
|
||||||
|
import { ContractPageHeader } from 'components/ContractPageHeader'
|
||||||
|
import { useExecuteComboboxState } from 'components/contracts/vendingMinter/ExecuteCombobox.hooks'
|
||||||
|
import { FormControl } from 'components/FormControl'
|
||||||
|
import { AddressInput, NumberInput } from 'components/forms/FormInput'
|
||||||
|
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
|
||||||
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
|
import { vendingMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
|
import { TransactionHash } from 'components/TransactionHash'
|
||||||
|
import { useContracts } from 'contexts/contracts'
|
||||||
|
import { useWallet } from 'contexts/wallet'
|
||||||
|
import type { MigrateResponse } from 'contracts/vendingMinter'
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
import { NextSeo } from 'next-seo'
|
||||||
|
import type { FormEvent } from 'react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { toast } from 'react-hot-toast'
|
||||||
|
import { FaArrowRight } from 'react-icons/fa'
|
||||||
|
import { useMutation } from 'react-query'
|
||||||
|
import { withMetadata } from 'utils/layout'
|
||||||
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
|
const VendingMinterMigratePage: NextPage = () => {
|
||||||
|
const { vendingMinter: contract } = useContracts()
|
||||||
|
const wallet = useWallet()
|
||||||
|
|
||||||
|
const [lastTx, setLastTx] = useState('')
|
||||||
|
|
||||||
|
const comboboxState = useExecuteComboboxState()
|
||||||
|
const type = comboboxState.value?.id
|
||||||
|
const codeIdState = useNumberInputState({
|
||||||
|
id: 'code-id',
|
||||||
|
name: 'code-id',
|
||||||
|
title: 'Code ID',
|
||||||
|
subtitle: 'Code ID of the New Vending Minter',
|
||||||
|
placeholder: '1',
|
||||||
|
})
|
||||||
|
|
||||||
|
const contractState = useInputState({
|
||||||
|
id: 'contract-address',
|
||||||
|
name: 'contract-address',
|
||||||
|
title: 'Vending Minter Address',
|
||||||
|
subtitle: 'Address of the Vending Minter contract',
|
||||||
|
})
|
||||||
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
|
const { data, isLoading, mutate } = useMutation(
|
||||||
|
async (event: FormEvent): Promise<MigrateResponse | null> => {
|
||||||
|
event.preventDefault()
|
||||||
|
if (!contract) {
|
||||||
|
throw new Error('Smart contract connection failed')
|
||||||
|
}
|
||||||
|
if (!wallet.initialized) {
|
||||||
|
throw new Error('Please connect your wallet.')
|
||||||
|
}
|
||||||
|
|
||||||
|
const migrateMsg = {}
|
||||||
|
return toast.promise(contract.migrate(contractAddress, codeIdState.value, migrateMsg), {
|
||||||
|
error: `Migration failed!`,
|
||||||
|
loading: 'Executing message...',
|
||||||
|
success: (tx) => {
|
||||||
|
if (tx) {
|
||||||
|
setLastTx(tx.transactionHash)
|
||||||
|
}
|
||||||
|
return `Transaction success!`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onError: (error) => {
|
||||||
|
toast.error(String(error))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (contractAddress.length > 0) {
|
||||||
|
void router.replace({ query: { contractAddress } })
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [contractAddress])
|
||||||
|
useEffect(() => {
|
||||||
|
const initial = new URL(document.URL).searchParams.get('contractAddress')
|
||||||
|
if (initial && initial.length > 0) contractState.onChange(initial)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="py-6 px-12 space-y-4">
|
||||||
|
<NextSeo title="Migrate Vending Minter Contract" />
|
||||||
|
<ContractPageHeader
|
||||||
|
description="Vending Minter contract facilitates primary market vending machine style minting."
|
||||||
|
link={links.Documentation}
|
||||||
|
title="Vending Minter Contract"
|
||||||
|
/>
|
||||||
|
<LinkTabs activeIndex={3} data={vendingMinterLinkTabs} />
|
||||||
|
|
||||||
|
<form className="grid grid-cols-2 p-4 space-x-8" onSubmit={mutate}>
|
||||||
|
<div className="space-y-8">
|
||||||
|
<AddressInput {...contractState} />
|
||||||
|
<NumberInput isRequired {...codeIdState} />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-8">
|
||||||
|
<div className="relative">
|
||||||
|
<Button className="absolute top-0 right-0" isLoading={isLoading} rightIcon={<FaArrowRight />} type="submit">
|
||||||
|
Execute
|
||||||
|
</Button>
|
||||||
|
<FormControl subtitle="View execution transaction hash" title="Transaction Hash">
|
||||||
|
<TransactionHash hash={lastTx} />
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
<FormControl subtitle="View current message to be sent" title="Payload Preview">
|
||||||
|
<JsonPreview
|
||||||
|
content={{
|
||||||
|
sender: wallet.address,
|
||||||
|
contract: contractAddress,
|
||||||
|
code_id: codeIdState.value,
|
||||||
|
msg: {},
|
||||||
|
}}
|
||||||
|
isCopyable
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withMetadata(VendingMinterMigratePage, { center: false })
|
@ -6,11 +6,11 @@ import { AddressInput } from 'components/forms/FormInput'
|
|||||||
import { useInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
import { JsonPreview } from 'components/JsonPreview'
|
import { JsonPreview } from 'components/JsonPreview'
|
||||||
import { LinkTabs } from 'components/LinkTabs'
|
import { LinkTabs } from 'components/LinkTabs'
|
||||||
import { minterLinkTabs } from 'components/LinkTabs.data'
|
import { vendingMinterLinkTabs } from 'components/LinkTabs.data'
|
||||||
import { useContracts } from 'contexts/contracts'
|
import { useContracts } from 'contexts/contracts'
|
||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { QueryType } from 'contracts/minter/messages/query'
|
import type { QueryType } from 'contracts/vendingMinter/messages/query'
|
||||||
import { dispatchQuery, QUERY_LIST } from 'contracts/minter/messages/query'
|
import { dispatchQuery, QUERY_LIST } from 'contracts/vendingMinter/messages/query'
|
||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { NextSeo } from 'next-seo'
|
import { NextSeo } from 'next-seo'
|
||||||
@ -20,15 +20,15 @@ import { useQuery } from 'react-query'
|
|||||||
import { withMetadata } from 'utils/layout'
|
import { withMetadata } from 'utils/layout'
|
||||||
import { links } from 'utils/links'
|
import { links } from 'utils/links'
|
||||||
|
|
||||||
const MinterQueryPage: NextPage = () => {
|
const VendingMinterQueryPage: NextPage = () => {
|
||||||
const { minter: contract } = useContracts()
|
const { vendingMinter: contract } = useContracts()
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
|
|
||||||
const contractState = useInputState({
|
const contractState = useInputState({
|
||||||
id: 'contract-address',
|
id: 'contract-address',
|
||||||
name: 'contract-address',
|
name: 'contract-address',
|
||||||
title: 'Minter Address',
|
title: 'Vending Minter Address',
|
||||||
subtitle: 'Address of the Minter contract',
|
subtitle: 'Address of the Vending Minter contract',
|
||||||
})
|
})
|
||||||
const contractAddress = contractState.value
|
const contractAddress = contractState.value
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ const MinterQueryPage: NextPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="py-6 px-12 space-y-4">
|
<section className="py-6 px-12 space-y-4">
|
||||||
<NextSeo title="Query Minter Contract" />
|
<NextSeo title="Query Vending Minter Contract" />
|
||||||
<ContractPageHeader
|
<ContractPageHeader
|
||||||
description="Minter contract facilitates primary market vending machine style minting."
|
description="Vending Minter contract facilitates primary market vending machine style minting."
|
||||||
link={links.Documentation}
|
link={links.Documentation}
|
||||||
title="Minter Contract"
|
title="Vending Minter Contract"
|
||||||
/>
|
/>
|
||||||
<LinkTabs activeIndex={1} data={minterLinkTabs} />
|
<LinkTabs activeIndex={1} data={vendingMinterLinkTabs} />
|
||||||
|
|
||||||
<div className="grid grid-cols-2 p-4 space-x-8">
|
<div className="grid grid-cols-2 p-4 space-x-8">
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
@ -117,4 +117,4 @@ const MinterQueryPage: NextPage = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withMetadata(MinterQueryPage, { center: false })
|
export default withMetadata(VendingMinterQueryPage, { center: false })
|
@ -2,6 +2,8 @@ export const SG721_CODE_ID = parseInt(process.env.NEXT_PUBLIC_SG721_CODE_ID, 10)
|
|||||||
export const WHITELIST_CODE_ID = parseInt(process.env.NEXT_PUBLIC_WHITELIST_CODE_ID, 10)
|
export const WHITELIST_CODE_ID = parseInt(process.env.NEXT_PUBLIC_WHITELIST_CODE_ID, 10)
|
||||||
export const VENDING_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10)
|
export const VENDING_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10)
|
||||||
export const VENDING_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_ADDRESS
|
export const VENDING_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_ADDRESS
|
||||||
|
export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS
|
||||||
|
export const BASE_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10)
|
||||||
|
|
||||||
export const PINATA_ENDPOINT_URL = process.env.NEXT_PUBLIC_PINATA_ENDPOINT_URL
|
export const PINATA_ENDPOINT_URL = process.env.NEXT_PUBLIC_PINATA_ENDPOINT_URL
|
||||||
export const NETWORK = process.env.NEXT_PUBLIC_NETWORK
|
export const NETWORK = process.env.NEXT_PUBLIC_NETWORK
|
||||||
|
Loading…
Reference in New Issue
Block a user