diff --git a/components/collections/actions/Action.tsx b/components/collections/actions/Action.tsx index cc8a036..b8f8b3e 100644 --- a/components/collections/actions/Action.tsx +++ b/components/collections/actions/Action.tsx @@ -32,6 +32,8 @@ interface CollectionActionsProps { minterMessages: MinterInstance | undefined } +type ExplicitContentType = true | false | undefined + export const CollectionActions = ({ sg721ContractAddress, sg721Messages, @@ -45,7 +47,7 @@ export const CollectionActions = ({ const [airdropAllocationArray, setAirdropAllocationArray] = useState([]) const [airdropArray, setAirdropArray] = useState([]) const [collectionInfo, setCollectionInfo] = useState() - const [explicitContent, setExplicitContent] = useState(false) + const [explicitContent, setExplicitContent] = useState(undefined) const actionComboboxState = useActionsComboboxState() const type = actionComboboxState.value?.id @@ -125,6 +127,7 @@ export const CollectionActions = ({ name: 'royaltyPaymentAddress', title: 'Royalty Payment Address', subtitle: 'Address to receive royalties.', + placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...', }) const royaltyShareState = useInputState({ @@ -217,10 +220,16 @@ export const CollectionActions = ({ throw new Error('Please enter minter and sg721 contract addresses!') } if (type === 'update_mint_price' && priceState.value < 50) { - console.log('here') throw new Error('Mint price must be at least 50 STARS') } + if ( + type === 'update_collection_info' && + (royaltyShareState.value ? !royaltyPaymentAddressState.value : royaltyPaymentAddressState.value) + ) { + throw new Error('Royalty payment address and share percentage are both required') + } + const txHash = await toast.promise(dispatchExecute(payload), { error: `${type.charAt(0).toUpperCase() + type.slice(1)} execute failed!`, loading: 'Executing message...', @@ -239,7 +248,6 @@ export const CollectionActions = ({ const airdropFileOnChange = (data: AirdropAllocation[]) => { setAirdropAllocationArray(data) - console.log(data) } return ( @@ -258,10 +266,10 @@ export const CollectionActions = ({ {showImageField && } {showExternalLinkField && } {showRoyaltyRelatedFields && ( - <> +
- +
)} {showExplicitContentField && (
@@ -272,7 +280,7 @@ export const CollectionActions = ({
; recipients: string[] } | { type: Select<'burn_remaining'> } | { type: Select<'update_collection_info'>; collectionInfo: CollectionInfo | undefined } + | { type: Select<'freeze_collection_info'> } ) export const dispatchExecute = async (args: DispatchExecuteArgs) => { @@ -207,6 +214,9 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => { case 'update_collection_info': { return sg721Messages.updateCollectionInfo(args.collectionInfo as CollectionInfo) } + case 'freeze_collection_info': { + return sg721Messages.freezeCollectionInfo() + } case 'shuffle': { return minterMessages.shuffle(txSigner) } @@ -277,6 +287,9 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => { case 'update_collection_info': { return sg721Messages(sg721Contract)?.updateCollectionInfo(args.collectionInfo as CollectionInfo) } + case 'freeze_collection_info': { + return sg721Messages(sg721Contract)?.freezeCollectionInfo() + } case 'shuffle': { return minterMessages(minterContract)?.shuffle() } diff --git a/contracts/sg721/contract.ts b/contracts/sg721/contract.ts index 8db16fc..6163398 100644 --- a/contracts/sg721/contract.ts +++ b/contracts/sg721/contract.ts @@ -76,6 +76,7 @@ export interface SG721Instance { /// Mint a new NFT, can only be called by the contract minter mint: (tokenId: string, owner: string, tokenURI?: string) => Promise //MintMsg updateCollectionInfo: (collectionInfo: CollectionInfo) => Promise + freezeCollectionInfo: () => Promise /// Burn an NFT the sender has access to burn: (tokenId: string) => Promise batchBurn: (tokenIds: string) => Promise @@ -94,6 +95,7 @@ export interface Sg721Messages { batchBurn: (tokenIds: string) => BatchBurnMessage batchTransfer: (recipient: string, tokenIds: string) => BatchTransferMessage updateCollectionInfo: (collectionInfo: CollectionInfo) => UpdateCollectionInfoMessage + freezeCollectionInfo: () => FreezeCollectionInfoMessage } export interface TransferNFTMessage { @@ -219,6 +221,13 @@ export interface UpdateCollectionInfoMessage { funds: Coin[] } +export interface FreezeCollectionInfoMessage { + sender: string + contract: string + msg: { freeze_collection_info: Record } + funds: Coin[] +} + export interface SG721Contract { instantiate: ( senderAddress: string, @@ -537,7 +546,6 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con // eslint-disable-next-line @typescript-eslint/no-shadow const updateCollectionInfo = async (collectionInfo: CollectionInfo): Promise => { - console.log(collectionInfo) const res = await client.execute( txSigner, contractAddress, @@ -550,6 +558,19 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con return res.transactionHash } + const freezeCollectionInfo = async (): Promise => { + const res = await client.execute( + txSigner, + contractAddress, + { + freeze_collection_info: {}, + }, + 'auto', + '', + ) + return res.transactionHash + } + return { contractAddress, ownerOf, @@ -575,6 +596,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con batchBurn, batchTransfer, updateCollectionInfo, + freezeCollectionInfo, } } @@ -767,6 +789,16 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con funds: [], } } + const freezeCollectionInfo = () => { + return { + sender: txSigner, + contract: contractAddress, + msg: { + freeze_collection_info: {}, + }, + funds: [], + } + } return { transferNft, @@ -780,6 +812,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con batchBurn, batchTransfer, updateCollectionInfo, + freezeCollectionInfo, } }