Include open edition minter actions in Collection Actions > Actions
This commit is contained in:
parent
52632ff42d
commit
6b89a60216
@ -15,6 +15,7 @@ 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 { BaseMinterInstance } from 'contracts/baseMinter'
|
import type { BaseMinterInstance } from 'contracts/baseMinter'
|
||||||
|
import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter'
|
||||||
import type { SG721Instance } from 'contracts/sg721'
|
import type { SG721Instance } from 'contracts/sg721'
|
||||||
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
import type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
import type { FormEvent } from 'react'
|
import type { FormEvent } from 'react'
|
||||||
@ -35,6 +36,7 @@ interface CollectionActionsProps {
|
|||||||
sg721Messages: SG721Instance | undefined
|
sg721Messages: SG721Instance | undefined
|
||||||
vendingMinterMessages: VendingMinterInstance | undefined
|
vendingMinterMessages: VendingMinterInstance | undefined
|
||||||
baseMinterMessages: BaseMinterInstance | undefined
|
baseMinterMessages: BaseMinterInstance | undefined
|
||||||
|
openEditionMinterMessages: OpenEditionMinterInstance | undefined
|
||||||
minterType: MinterType
|
minterType: MinterType
|
||||||
sg721Type: Sg721Type
|
sg721Type: Sg721Type
|
||||||
}
|
}
|
||||||
@ -47,6 +49,7 @@ export const CollectionActions = ({
|
|||||||
minterContractAddress,
|
minterContractAddress,
|
||||||
vendingMinterMessages,
|
vendingMinterMessages,
|
||||||
baseMinterMessages,
|
baseMinterMessages,
|
||||||
|
openEditionMinterMessages,
|
||||||
minterType,
|
minterType,
|
||||||
sg721Type,
|
sg721Type,
|
||||||
}: CollectionActionsProps) => {
|
}: CollectionActionsProps) => {
|
||||||
@ -54,6 +57,7 @@ export const CollectionActions = ({
|
|||||||
const [lastTx, setLastTx] = useState('')
|
const [lastTx, setLastTx] = useState('')
|
||||||
|
|
||||||
const [timestamp, setTimestamp] = useState<Date | undefined>(undefined)
|
const [timestamp, setTimestamp] = useState<Date | undefined>(undefined)
|
||||||
|
const [endTimestamp, setEndTimestamp] = useState<Date | undefined>(undefined)
|
||||||
const [airdropAllocationArray, setAirdropAllocationArray] = useState<AirdropAllocation[]>([])
|
const [airdropAllocationArray, setAirdropAllocationArray] = useState<AirdropAllocation[]>([])
|
||||||
const [airdropArray, setAirdropArray] = useState<string[]>([])
|
const [airdropArray, setAirdropArray] = useState<string[]>([])
|
||||||
const [collectionInfo, setCollectionInfo] = useState<CollectionInfo>()
|
const [collectionInfo, setCollectionInfo] = useState<CollectionInfo>()
|
||||||
@ -168,6 +172,7 @@ export const CollectionActions = ({
|
|||||||
const showTokenUriField = isEitherType(type, ['mint_token_uri', 'update_token_metadata'])
|
const showTokenUriField = isEitherType(type, ['mint_token_uri', 'update_token_metadata'])
|
||||||
const showWhitelistField = type === 'set_whitelist'
|
const showWhitelistField = type === 'set_whitelist'
|
||||||
const showDateField = isEitherType(type, ['update_start_time', 'update_start_trading_time'])
|
const showDateField = isEitherType(type, ['update_start_time', 'update_start_trading_time'])
|
||||||
|
const showEndDateField = type === 'update_end_time'
|
||||||
const showLimitField = type === 'update_per_address_limit'
|
const showLimitField = type === 'update_per_address_limit'
|
||||||
const showTokenIdField = isEitherType(type, ['transfer', 'mint_for', 'burn', 'update_token_metadata'])
|
const showTokenIdField = isEitherType(type, ['transfer', 'mint_for', 'burn', 'update_token_metadata'])
|
||||||
const showNumberOfTokensField = type === 'batch_mint'
|
const showNumberOfTokensField = type === 'batch_mint'
|
||||||
@ -197,6 +202,7 @@ export const CollectionActions = ({
|
|||||||
const payload: DispatchExecuteArgs = {
|
const payload: DispatchExecuteArgs = {
|
||||||
whitelist: whitelistState.value,
|
whitelist: whitelistState.value,
|
||||||
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
|
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
|
||||||
|
endTime: endTimestamp ? (endTimestamp.getTime() * 1_000_000).toString() : '',
|
||||||
limit: limitState.value,
|
limit: limitState.value,
|
||||||
minterContract: minterContractAddress,
|
minterContract: minterContractAddress,
|
||||||
sg721Contract: sg721ContractAddress,
|
sg721Contract: sg721ContractAddress,
|
||||||
@ -208,6 +214,7 @@ export const CollectionActions = ({
|
|||||||
batchNumber: batchNumberState.value,
|
batchNumber: batchNumberState.value,
|
||||||
vendingMinterMessages,
|
vendingMinterMessages,
|
||||||
baseMinterMessages,
|
baseMinterMessages,
|
||||||
|
openEditionMinterMessages,
|
||||||
sg721Messages,
|
sg721Messages,
|
||||||
recipient: resolvedRecipientAddress,
|
recipient: resolvedRecipientAddress,
|
||||||
recipients: airdropArray,
|
recipients: airdropArray,
|
||||||
@ -493,6 +500,11 @@ export const CollectionActions = ({
|
|||||||
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Conditional>
|
</Conditional>
|
||||||
|
<Conditional test={showEndDateField}>
|
||||||
|
<FormControl className="mt-2" htmlId="end-date" title="End Time">
|
||||||
|
<InputDateTime minDate={new Date()} onChange={(date) => setEndTimestamp(date)} value={endTimestamp} />
|
||||||
|
</FormControl>
|
||||||
|
</Conditional>
|
||||||
</div>
|
</div>
|
||||||
<div className="-mt-6">
|
<div className="-mt-6">
|
||||||
<div className="relative mb-2">
|
<div className="relative mb-2">
|
||||||
|
@ -6,7 +6,7 @@ import { Fragment, useEffect, useState } from 'react'
|
|||||||
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
import { FaChevronDown, FaInfoCircle } from 'react-icons/fa'
|
||||||
|
|
||||||
import type { ActionListItem } from './actions'
|
import type { ActionListItem } from './actions'
|
||||||
import { BASE_ACTION_LIST, SG721_UPDATABLE_ACTION_LIST, VENDING_ACTION_LIST } from './actions'
|
import { BASE_ACTION_LIST, OPEN_EDITION_ACTION_LIST, SG721_UPDATABLE_ACTION_LIST, VENDING_ACTION_LIST } from './actions'
|
||||||
|
|
||||||
export type MinterType = 'base' | 'vending' | 'openEdition'
|
export type MinterType = 'base' | 'vending' | 'openEdition'
|
||||||
export type Sg721Type = 'updatable' | 'base'
|
export type Sg721Type = 'updatable' | 'base'
|
||||||
@ -29,6 +29,9 @@ export const ActionsCombobox = ({ value, onChange, minterType, sg721Type }: Acti
|
|||||||
} else if (minterType === 'vending') {
|
} else if (minterType === 'vending') {
|
||||||
if (sg721Type === 'updatable') SET_ACTION_LIST(VENDING_ACTION_LIST.concat(SG721_UPDATABLE_ACTION_LIST))
|
if (sg721Type === 'updatable') SET_ACTION_LIST(VENDING_ACTION_LIST.concat(SG721_UPDATABLE_ACTION_LIST))
|
||||||
else SET_ACTION_LIST(VENDING_ACTION_LIST)
|
else SET_ACTION_LIST(VENDING_ACTION_LIST)
|
||||||
|
} else if (minterType === 'openEdition') {
|
||||||
|
if (sg721Type === 'updatable') SET_ACTION_LIST(OPEN_EDITION_ACTION_LIST.concat(SG721_UPDATABLE_ACTION_LIST))
|
||||||
|
else SET_ACTION_LIST(OPEN_EDITION_ACTION_LIST)
|
||||||
} else SET_ACTION_LIST(VENDING_ACTION_LIST.concat(SG721_UPDATABLE_ACTION_LIST))
|
} else SET_ACTION_LIST(VENDING_ACTION_LIST.concat(SG721_UPDATABLE_ACTION_LIST))
|
||||||
}, [minterType, sg721Type])
|
}, [minterType, sg721Type])
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable eslint-comments/disable-enable-pair */
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||||
|
|
||||||
import { useBaseMinterContract } from 'contracts/baseMinter'
|
import { useBaseMinterContract } from 'contracts/baseMinter'
|
||||||
|
import { useOpenEditionMinterContract } from 'contracts/openEditionMinter'
|
||||||
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 type { VendingMinterInstance } from 'contracts/vendingMinter'
|
||||||
@ -8,6 +8,7 @@ import { useVendingMinterContract } from 'contracts/vendingMinter'
|
|||||||
import type { AirdropAllocation } from 'utils/isValidAccountsFile'
|
import type { AirdropAllocation } from 'utils/isValidAccountsFile'
|
||||||
|
|
||||||
import type { BaseMinterInstance } from '../../../contracts/baseMinter/contract'
|
import type { BaseMinterInstance } from '../../../contracts/baseMinter/contract'
|
||||||
|
import type { OpenEditionMinterInstance } from '../../../contracts/openEditionMinter/contract'
|
||||||
|
|
||||||
export type ActionType = typeof ACTION_TYPES[number]
|
export type ActionType = typeof ACTION_TYPES[number]
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ export const ACTION_TYPES = [
|
|||||||
'batch_mint',
|
'batch_mint',
|
||||||
'set_whitelist',
|
'set_whitelist',
|
||||||
'update_start_time',
|
'update_start_time',
|
||||||
|
'update_end_time',
|
||||||
'update_start_trading_time',
|
'update_start_trading_time',
|
||||||
'update_per_address_limit',
|
'update_per_address_limit',
|
||||||
'update_collection_info',
|
'update_collection_info',
|
||||||
@ -197,6 +199,79 @@ export const VENDING_ACTION_LIST: ActionListItem[] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const OPEN_EDITION_ACTION_LIST: ActionListItem[] = [
|
||||||
|
{
|
||||||
|
id: 'update_mint_price',
|
||||||
|
name: 'Update Mint Price',
|
||||||
|
description: `Update mint price`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'mint_to',
|
||||||
|
name: 'Mint To',
|
||||||
|
description: `Mint a token to a user`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'batch_mint',
|
||||||
|
name: 'Batch Mint To',
|
||||||
|
description: `Mint multiple tokens to a user`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_start_time',
|
||||||
|
name: 'Update Minting Start Time',
|
||||||
|
description: `Update the start time for minting`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_end_time',
|
||||||
|
name: 'Update Minting End Time',
|
||||||
|
description: `Update the end time for minting`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_start_trading_time',
|
||||||
|
name: 'Update Trading Start Time',
|
||||||
|
description: `Update start time for trading`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_per_address_limit',
|
||||||
|
name: 'Update Tokens Per Address Limit',
|
||||||
|
description: `Update token per address limit`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'update_collection_info',
|
||||||
|
name: 'Update Collection Info',
|
||||||
|
description: `Update Collection Info`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'freeze_collection_info',
|
||||||
|
name: 'Freeze Collection Info',
|
||||||
|
description: `Freeze collection info to prevent further updates`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'transfer',
|
||||||
|
name: 'Transfer Tokens',
|
||||||
|
description: `Transfer tokens from one address to another`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'batch_transfer',
|
||||||
|
name: 'Batch Transfer Tokens',
|
||||||
|
description: `Transfer a list of tokens to a recipient`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'burn',
|
||||||
|
name: 'Burn Token',
|
||||||
|
description: `Burn a specified token from the collection`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'batch_burn',
|
||||||
|
name: 'Batch Burn Tokens',
|
||||||
|
description: `Burn a list of tokens from the collection`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'airdrop',
|
||||||
|
name: 'Airdrop Tokens',
|
||||||
|
description: 'Airdrop tokens to given addresses',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export const SG721_UPDATABLE_ACTION_LIST: ActionListItem[] = [
|
export const SG721_UPDATABLE_ACTION_LIST: ActionListItem[] = [
|
||||||
{
|
{
|
||||||
id: 'update_token_metadata',
|
id: 'update_token_metadata',
|
||||||
@ -231,6 +306,7 @@ export interface DispatchExecuteArgs {
|
|||||||
sg721Contract: string
|
sg721Contract: string
|
||||||
vendingMinterMessages?: VendingMinterInstance
|
vendingMinterMessages?: VendingMinterInstance
|
||||||
baseMinterMessages?: BaseMinterInstance
|
baseMinterMessages?: BaseMinterInstance
|
||||||
|
openEditionMinterMessages?: OpenEditionMinterInstance
|
||||||
sg721Messages?: SG721Instance
|
sg721Messages?: SG721Instance
|
||||||
txSigner: string
|
txSigner: string
|
||||||
type: string | undefined
|
type: string | undefined
|
||||||
@ -241,6 +317,7 @@ export interface DispatchExecuteArgs {
|
|||||||
batchNumber: number
|
batchNumber: number
|
||||||
whitelist: string
|
whitelist: string
|
||||||
startTime: string | undefined
|
startTime: string | undefined
|
||||||
|
endTime: string | undefined
|
||||||
limit: number
|
limit: number
|
||||||
tokenIds: string
|
tokenIds: string
|
||||||
recipients: string[]
|
recipients: string[]
|
||||||
@ -250,8 +327,8 @@ export interface DispatchExecuteArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
||||||
const { vendingMinterMessages, baseMinterMessages, sg721Messages, txSigner } = args
|
const { vendingMinterMessages, baseMinterMessages, openEditionMinterMessages, sg721Messages, txSigner } = args
|
||||||
if (!vendingMinterMessages || !baseMinterMessages || !sg721Messages) {
|
if (!vendingMinterMessages || !baseMinterMessages || !openEditionMinterMessages || !sg721Messages) {
|
||||||
throw new Error('Cannot execute actions')
|
throw new Error('Cannot execute actions')
|
||||||
}
|
}
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
@ -282,6 +359,9 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
|
|||||||
case 'update_start_time': {
|
case 'update_start_time': {
|
||||||
return vendingMinterMessages.updateStartTime(txSigner, args.startTime as string)
|
return vendingMinterMessages.updateStartTime(txSigner, args.startTime as string)
|
||||||
}
|
}
|
||||||
|
case 'update_end_time': {
|
||||||
|
return openEditionMinterMessages.updateEndTime(txSigner, args.endTime as string)
|
||||||
|
}
|
||||||
case 'update_start_trading_time': {
|
case 'update_start_trading_time': {
|
||||||
return vendingMinterMessages.updateStartTradingTime(txSigner, args.startTime)
|
return vendingMinterMessages.updateStartTradingTime(txSigner, args.startTime)
|
||||||
}
|
}
|
||||||
@ -346,6 +426,8 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
|||||||
const { messages: sg721Messages } = useSG721Contract()
|
const { messages: sg721Messages } = useSG721Contract()
|
||||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
const { messages: baseMinterMessages } = useBaseMinterContract()
|
const { messages: baseMinterMessages } = useBaseMinterContract()
|
||||||
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||||
|
const { messages: openEditionMinterMessages } = useOpenEditionMinterContract()
|
||||||
const { minterContract, sg721Contract } = args
|
const { minterContract, sg721Contract } = args
|
||||||
switch (args.type) {
|
switch (args.type) {
|
||||||
case 'mint_token_uri': {
|
case 'mint_token_uri': {
|
||||||
@ -375,6 +457,9 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
|
|||||||
case 'update_start_time': {
|
case 'update_start_time': {
|
||||||
return vendingMinterMessages(minterContract)?.updateStartTime(args.startTime as string)
|
return vendingMinterMessages(minterContract)?.updateStartTime(args.startTime as string)
|
||||||
}
|
}
|
||||||
|
case 'update_end_time': {
|
||||||
|
return openEditionMinterMessages(minterContract)?.updateEndTime(args.endTime as string)
|
||||||
|
}
|
||||||
case 'update_start_trading_time': {
|
case 'update_start_trading_time': {
|
||||||
return vendingMinterMessages(minterContract)?.updateStartTradingTime(args.startTime as string)
|
return vendingMinterMessages(minterContract)?.updateStartTradingTime(args.startTime as string)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,12 @@ import { links } from 'utils/links'
|
|||||||
import type { MinterType, Sg721Type } from '../../components/collections/actions/Combobox'
|
import type { MinterType, Sg721Type } from '../../components/collections/actions/Combobox'
|
||||||
|
|
||||||
const CollectionActionsPage: NextPage = () => {
|
const CollectionActionsPage: NextPage = () => {
|
||||||
const { baseMinter: baseMinterContract, vendingMinter: vendingMinterContract, sg721: sg721Contract } = useContracts()
|
const {
|
||||||
|
baseMinter: baseMinterContract,
|
||||||
|
vendingMinter: vendingMinterContract,
|
||||||
|
openEditionMinter: openEditionMinterContract,
|
||||||
|
sg721: sg721Contract,
|
||||||
|
} = useContracts()
|
||||||
const wallet = useWallet()
|
const wallet = useWallet()
|
||||||
|
|
||||||
const [action, setAction] = useState<boolean>(false)
|
const [action, setAction] = useState<boolean>(false)
|
||||||
@ -51,6 +56,11 @@ const CollectionActionsPage: NextPage = () => {
|
|||||||
() => baseMinterContract?.use(minterContractState.value),
|
() => baseMinterContract?.use(minterContractState.value),
|
||||||
[baseMinterContract, minterContractState.value],
|
[baseMinterContract, minterContractState.value],
|
||||||
)
|
)
|
||||||
|
const openEditionMinterMessages = useMemo(
|
||||||
|
() => openEditionMinterContract?.use(minterContractState.value),
|
||||||
|
[openEditionMinterContract, minterContractState.value],
|
||||||
|
)
|
||||||
|
|
||||||
const sg721Messages = useMemo(
|
const sg721Messages = useMemo(
|
||||||
() => sg721Contract?.use(sg721ContractState.value),
|
() => sg721Contract?.use(sg721ContractState.value),
|
||||||
[sg721Contract, sg721ContractState.value],
|
[sg721Contract, sg721ContractState.value],
|
||||||
@ -105,6 +115,8 @@ const CollectionActionsPage: NextPage = () => {
|
|||||||
.then((contract) => {
|
.then((contract) => {
|
||||||
if (contract?.includes('sg-base-minter')) {
|
if (contract?.includes('sg-base-minter')) {
|
||||||
setMinterType('base')
|
setMinterType('base')
|
||||||
|
} else if (contract?.includes('open-edition')) {
|
||||||
|
setMinterType('openEdition')
|
||||||
} else {
|
} else {
|
||||||
setMinterType('vending')
|
setMinterType('vending')
|
||||||
}
|
}
|
||||||
@ -214,6 +226,7 @@ const CollectionActionsPage: NextPage = () => {
|
|||||||
baseMinterMessages={baseMinterMessages}
|
baseMinterMessages={baseMinterMessages}
|
||||||
minterContractAddress={minterContractState.value}
|
minterContractAddress={minterContractState.value}
|
||||||
minterType={minterType}
|
minterType={minterType}
|
||||||
|
openEditionMinterMessages={openEditionMinterMessages}
|
||||||
sg721ContractAddress={sg721ContractState.value}
|
sg721ContractAddress={sg721ContractState.value}
|
||||||
sg721Messages={sg721Messages}
|
sg721Messages={sg721Messages}
|
||||||
sg721Type={sg721Type}
|
sg721Type={sg721Type}
|
||||||
|
Loading…
Reference in New Issue
Block a user