Merge pull request #231 from public-awesome/develop

Sync dev > main
This commit is contained in:
Serkan Reis 2023-10-10 14:22:18 +03:00 committed by GitHub
commit fbeeb4212a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 267 additions and 44 deletions

View File

@ -1,4 +1,4 @@
APP_VERSION=0.7.10 APP_VERSION=0.7.11
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=2595 NEXT_PUBLIC_SG721_CODE_ID=2595
@ -40,6 +40,7 @@ NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS="stars1tc09vlgdg8rqy
NEXT_PUBLIC_SG721_NAME_ADDRESS="stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr" NEXT_PUBLIC_SG721_NAME_ADDRESS="stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr"
NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS="stars1crgx0f70fzksa57hq87wtl8f04h0qyk5la0hk0fu8dyhl67ju80qaxzr5z" NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS="stars1crgx0f70fzksa57hq87wtl8f04h0qyk5la0hk0fu8dyhl67ju80qaxzr5z"
NEXT_PUBLIC_INFINITY_SWAP_PROTOCOL_ADDRESS="stars136yp6fl9h66m0cwv8weu4w4aawveuz40992ty0atj5ecjd8z0thqv9xpy5"
NEXT_PUBLIC_WHITELIST_CODE_ID=2602 NEXT_PUBLIC_WHITELIST_CODE_ID=2602
NEXT_PUBLIC_WHITELIST_FLEX_CODE_ID=2603 NEXT_PUBLIC_WHITELIST_FLEX_CODE_ID=2603
NEXT_PUBLIC_BADGE_HUB_CODE_ID=1336 NEXT_PUBLIC_BADGE_HUB_CODE_ID=1336

View File

@ -1,6 +1,7 @@
/* eslint-disable eslint-comments/disable-enable-pair */ /* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable no-nested-ternary */ /* eslint-disable no-nested-ternary */
import { toUtf8 } from '@cosmjs/encoding' import { toUtf8 } from '@cosmjs/encoding'
import clsx from 'clsx'
import { AirdropUpload } from 'components/AirdropUpload' import { AirdropUpload } from 'components/AirdropUpload'
import { Button } from 'components/Button' import { Button } from 'components/Button'
import type { DispatchExecuteArgs } from 'components/collections/actions/actions' import type { DispatchExecuteArgs } from 'components/collections/actions/actions'
@ -20,6 +21,7 @@ import { useGlobalSettings } from 'contexts/globalSettings'
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 { OpenEditionMinterInstance } from 'contracts/openEditionMinter'
import type { RoyaltyRegistryInstance } from 'contracts/royaltyRegistry'
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'
@ -27,6 +29,7 @@ import { useEffect, useState } from 'react'
import { toast } from 'react-hot-toast' import { toast } from 'react-hot-toast'
import { FaArrowRight } from 'react-icons/fa' import { FaArrowRight } from 'react-icons/fa'
import { useMutation } from 'react-query' import { useMutation } from 'react-query'
import { ROYALTY_REGISTRY_ADDRESS } from 'utils/constants'
import type { AirdropAllocation } from 'utils/isValidAccountsFile' import type { AirdropAllocation } from 'utils/isValidAccountsFile'
import { resolveAddress } from 'utils/resolveAddress' import { resolveAddress } from 'utils/resolveAddress'
@ -41,6 +44,7 @@ interface CollectionActionsProps {
vendingMinterMessages: VendingMinterInstance | undefined vendingMinterMessages: VendingMinterInstance | undefined
baseMinterMessages: BaseMinterInstance | undefined baseMinterMessages: BaseMinterInstance | undefined
openEditionMinterMessages: OpenEditionMinterInstance | undefined openEditionMinterMessages: OpenEditionMinterInstance | undefined
royaltyRegistryMessages: RoyaltyRegistryInstance | undefined
minterType: MinterType minterType: MinterType
sg721Type: Sg721Type sg721Type: Sg721Type
} }
@ -54,6 +58,7 @@ export const CollectionActions = ({
vendingMinterMessages, vendingMinterMessages,
baseMinterMessages, baseMinterMessages,
openEditionMinterMessages, openEditionMinterMessages,
royaltyRegistryMessages,
minterType, minterType,
sg721Type, sg721Type,
}: CollectionActionsProps) => { }: CollectionActionsProps) => {
@ -69,6 +74,7 @@ export const CollectionActions = ({
const [explicitContent, setExplicitContent] = useState<ExplicitContentType>(undefined) const [explicitContent, setExplicitContent] = useState<ExplicitContentType>(undefined)
const [resolvedRecipientAddress, setResolvedRecipientAddress] = useState<string>('') const [resolvedRecipientAddress, setResolvedRecipientAddress] = useState<string>('')
const [jsonExtensions, setJsonExtensions] = useState<boolean>(false) const [jsonExtensions, setJsonExtensions] = useState<boolean>(false)
const [decrement, setDecrement] = useState<boolean>(false)
const actionComboboxState = useActionsComboboxState() const actionComboboxState = useActionsComboboxState()
const type = actionComboboxState.value?.id const type = actionComboboxState.value?.id
@ -170,8 +176,11 @@ export const CollectionActions = ({
const royaltyShareState = useInputState({ const royaltyShareState = useInputState({
id: 'royalty-share', id: 'royalty-share',
name: 'royaltyShare', name: 'royaltyShare',
title: 'Share Percentage', title: type !== 'update_royalties_for_infinity_swap' ? 'Share Percentage' : 'Share Delta',
subtitle: 'Percentage of royalties to be paid', subtitle:
type !== 'update_royalties_for_infinity_swap'
? 'Percentage of royalties to be paid'
: 'Change in share percentage',
placeholder: '5%', placeholder: '5%',
}) })
@ -208,7 +217,10 @@ export const CollectionActions = ({
const showDescriptionField = type === 'update_collection_info' const showDescriptionField = type === 'update_collection_info'
const showImageField = type === 'update_collection_info' const showImageField = type === 'update_collection_info'
const showExternalLinkField = type === 'update_collection_info' const showExternalLinkField = type === 'update_collection_info'
const showRoyaltyRelatedFields = type === 'update_collection_info' const showRoyaltyRelatedFields =
type === 'update_collection_info' ||
type === 'set_royalties_for_infinity_swap' ||
type === 'update_royalties_for_infinity_swap'
const showExplicitContentField = type === 'update_collection_info' const showExplicitContentField = type === 'update_collection_info'
const showBaseUriField = type === 'batch_update_token_metadata' const showBaseUriField = type === 'batch_update_token_metadata'
@ -219,6 +231,7 @@ export const CollectionActions = ({
limit: limitState.value, limit: limitState.value,
minterContract: minterContractAddress, minterContract: minterContractAddress,
sg721Contract: sg721ContractAddress, sg721Contract: sg721ContractAddress,
royaltyRegistryContract: ROYALTY_REGISTRY_ADDRESS,
tokenId: tokenIdState.value, tokenId: tokenIdState.value,
tokenIds: tokenIdListState.value, tokenIds: tokenIdListState.value,
tokenUri: tokenURIState.value.trim().endsWith('/') tokenUri: tokenURIState.value.trim().endsWith('/')
@ -229,6 +242,7 @@ export const CollectionActions = ({
baseMinterMessages, baseMinterMessages,
openEditionMinterMessages, openEditionMinterMessages,
sg721Messages, sg721Messages,
royaltyRegistryMessages,
recipient: resolvedRecipientAddress, recipient: resolvedRecipientAddress,
recipients: airdropArray, recipients: airdropArray,
tokenRecipients: airdropAllocationArray, tokenRecipients: airdropAllocationArray,
@ -240,6 +254,7 @@ export const CollectionActions = ({
: baseURIState.value.trim(), : baseURIState.value.trim(),
collectionInfo, collectionInfo,
jsonExtensions, jsonExtensions,
decrement,
} }
const resolveRecipientAddress = async () => { const resolveRecipientAddress = async () => {
await resolveAddress(recipientState.value.trim(), wallet).then((resolvedAddress) => { await resolveAddress(recipientState.value.trim(), wallet).then((resolvedAddress) => {
@ -448,6 +463,24 @@ export const CollectionActions = ({
<div className="p-2 my-4 rounded border-2 border-gray-500/50"> <div className="p-2 my-4 rounded border-2 border-gray-500/50">
<TextInput className="mb-2" {...royaltyPaymentAddressState} /> <TextInput className="mb-2" {...royaltyPaymentAddressState} />
<NumberInput className="mb-2" {...royaltyShareState} /> <NumberInput className="mb-2" {...royaltyShareState} />
<Conditional test={type === 'update_royalties_for_infinity_swap'}>
<div className="flex flex-row space-y-2 w-1/4">
<div className={clsx('flex flex-col space-y-2 w-full form-control')}>
<label className="justify-start cursor-pointer label">
<div className="flex flex-col">
<span className="mr-4 font-bold">Increment</span>
</div>
<input
checked={decrement}
className={`toggle ${decrement ? `bg-stargaze` : `bg-gray-600`}`}
onClick={() => setDecrement(!decrement)}
type="checkbox"
/>
</label>
</div>
<span className="mx-4 font-bold">Decrement</span>
</div>
</Conditional>
</div> </div>
)} )}
{showExplicitContentField && ( {showExplicitContentField && (

View File

@ -1,10 +1,13 @@
/* 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 { useOpenEditionMinterContract } from 'contracts/openEditionMinter'
import type { RoyaltyRegistryInstance } from 'contracts/royaltyRegistry'
import { useRoyaltyRegistryContract } from 'contracts/royaltyRegistry'
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'
import { useVendingMinterContract } from 'contracts/vendingMinter' import { useVendingMinterContract } from 'contracts/vendingMinter'
import { INFINITY_SWAP_PROTOCOL_ADDRESS } from 'utils/constants'
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'
@ -29,6 +32,8 @@ export const ACTION_TYPES = [
'update_per_address_limit', 'update_per_address_limit',
'update_collection_info', 'update_collection_info',
'freeze_collection_info', 'freeze_collection_info',
'set_royalties_for_infinity_swap',
'update_royalties_for_infinity_swap',
'transfer', 'transfer',
'batch_transfer', 'batch_transfer',
'batch_transfer_multi_address', 'batch_transfer_multi_address',
@ -73,6 +78,16 @@ export const BASE_ACTION_LIST: ActionListItem[] = [
name: 'Freeze Collection Info', name: 'Freeze Collection Info',
description: `Freeze collection info to prevent further updates`, description: `Freeze collection info to prevent further updates`,
}, },
{
id: 'set_royalties_for_infinity_swap',
name: 'Set Royalty Details for Infinity Swap',
description: `Set royalty details for Infinity Swap`,
},
{
id: 'update_royalties_for_infinity_swap',
name: 'Update Royalty Details for Infinity Swap',
description: `Update royalty details for Infinity Swap`,
},
{ {
id: 'transfer', id: 'transfer',
name: 'Transfer Tokens', name: 'Transfer Tokens',
@ -166,6 +181,16 @@ export const VENDING_ACTION_LIST: ActionListItem[] = [
name: 'Freeze Collection Info', name: 'Freeze Collection Info',
description: `Freeze collection info to prevent further updates`, description: `Freeze collection info to prevent further updates`,
}, },
{
id: 'set_royalties_for_infinity_swap',
name: 'Set Royalty Details for Infinity Swap',
description: `Set royalty details for Infinity Swap`,
},
{
id: 'update_royalties_for_infinity_swap',
name: 'Update Royalty Details for Infinity Swap',
description: `Update royalty details for Infinity Swap`,
},
{ {
id: 'transfer', id: 'transfer',
name: 'Transfer Tokens', name: 'Transfer Tokens',
@ -259,6 +284,16 @@ export const OPEN_EDITION_ACTION_LIST: ActionListItem[] = [
name: 'Freeze Collection Info', name: 'Freeze Collection Info',
description: `Freeze collection info to prevent further updates`, description: `Freeze collection info to prevent further updates`,
}, },
{
id: 'set_royalties_for_infinity_swap',
name: 'Set Royalty Details for Infinity Swap',
description: `Set royalty details for Infinity Swap`,
},
{
id: 'update_royalties_for_infinity_swap',
name: 'Update Royalty Details for Infinity Swap',
description: `Update royalty details for Infinity Swap`,
},
{ {
id: 'transfer', id: 'transfer',
name: 'Transfer Tokens', name: 'Transfer Tokens',
@ -323,10 +358,12 @@ export interface DispatchExecuteProps {
export interface DispatchExecuteArgs { export interface DispatchExecuteArgs {
minterContract: string minterContract: string
sg721Contract: string sg721Contract: string
royaltyRegistryContract: string
vendingMinterMessages?: VendingMinterInstance vendingMinterMessages?: VendingMinterInstance
baseMinterMessages?: BaseMinterInstance baseMinterMessages?: BaseMinterInstance
openEditionMinterMessages?: OpenEditionMinterInstance openEditionMinterMessages?: OpenEditionMinterInstance
sg721Messages?: SG721Instance sg721Messages?: SG721Instance
royaltyRegistryMessages?: RoyaltyRegistryInstance
txSigner: string txSigner: string
type: string | undefined type: string | undefined
tokenUri: string tokenUri: string
@ -344,11 +381,25 @@ export interface DispatchExecuteArgs {
collectionInfo: CollectionInfo | undefined collectionInfo: CollectionInfo | undefined
baseUri: string baseUri: string
jsonExtensions: boolean jsonExtensions: boolean
decrement: boolean
} }
export const dispatchExecute = async (args: DispatchExecuteArgs) => { export const dispatchExecute = async (args: DispatchExecuteArgs) => {
const { vendingMinterMessages, baseMinterMessages, openEditionMinterMessages, sg721Messages, txSigner } = args const {
if (!vendingMinterMessages || !baseMinterMessages || !openEditionMinterMessages || !sg721Messages) { vendingMinterMessages,
baseMinterMessages,
openEditionMinterMessages,
sg721Messages,
royaltyRegistryMessages,
txSigner,
} = args
if (
!vendingMinterMessages ||
!baseMinterMessages ||
!openEditionMinterMessages ||
!sg721Messages ||
!royaltyRegistryMessages
) {
throw new Error('Cannot execute actions') throw new Error('Cannot execute actions')
} }
switch (args.type) { switch (args.type) {
@ -415,6 +466,23 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => {
case 'shuffle': { case 'shuffle': {
return vendingMinterMessages.shuffle(txSigner) return vendingMinterMessages.shuffle(txSigner)
} }
case 'set_royalties_for_infinity_swap': {
return royaltyRegistryMessages.setCollectionRoyaltyProtocol(
args.sg721Contract,
INFINITY_SWAP_PROTOCOL_ADDRESS,
args.collectionInfo?.royalty_info?.payment_address as string,
Number(args.collectionInfo?.royalty_info?.share) * 100,
)
}
case 'update_royalties_for_infinity_swap': {
return royaltyRegistryMessages.updateCollectionRoyaltyProtocol(
args.sg721Contract,
INFINITY_SWAP_PROTOCOL_ADDRESS,
args.collectionInfo?.royalty_info?.payment_address as string,
Number(args.collectionInfo?.royalty_info?.share) * 100,
args.decrement,
)
}
case 'transfer': { case 'transfer': {
return sg721Messages.transferNft(args.recipient, args.tokenId.toString()) return sg721Messages.transferNft(args.recipient, args.tokenId.toString())
} }
@ -460,7 +528,10 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
const { messages: baseMinterMessages } = useBaseMinterContract() const { messages: baseMinterMessages } = useBaseMinterContract()
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
const { messages: openEditionMinterMessages } = useOpenEditionMinterContract() const { messages: openEditionMinterMessages } = useOpenEditionMinterContract()
const { minterContract, sg721Contract } = args // eslint-disable-next-line react-hooks/rules-of-hooks
const { messages: royaltyRegistryMessages } = useRoyaltyRegistryContract()
const { minterContract, sg721Contract, royaltyRegistryContract } = args
switch (args.type) { switch (args.type) {
case 'mint_token_uri': { case 'mint_token_uri': {
return baseMinterMessages(minterContract)?.mint(args.tokenUri) return baseMinterMessages(minterContract)?.mint(args.tokenUri)
@ -525,6 +596,23 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => {
case 'shuffle': { case 'shuffle': {
return vendingMinterMessages(minterContract)?.shuffle() return vendingMinterMessages(minterContract)?.shuffle()
} }
case 'set_royalties_for_infinity_swap': {
return royaltyRegistryMessages(royaltyRegistryContract)?.setCollectionRoyaltyProtocol(
args.sg721Contract,
INFINITY_SWAP_PROTOCOL_ADDRESS,
args.collectionInfo?.royalty_info?.payment_address as string,
Number(args.collectionInfo?.royalty_info?.share) * 100,
)
}
case 'update_royalties_for_infinity_swap': {
return royaltyRegistryMessages(royaltyRegistryContract)?.updateCollectionRoyaltyProtocol(
args.sg721Contract,
INFINITY_SWAP_PROTOCOL_ADDRESS,
args.collectionInfo?.royalty_info?.payment_address as string,
Number(args.collectionInfo?.royalty_info?.share) * 100,
args.decrement,
)
}
case 'transfer': { case 'transfer': {
return sg721Messages(sg721Contract)?.transferNft(args.recipient, args.tokenId.toString()) return sg721Messages(sg721Contract)?.transferNft(args.recipient, args.tokenId.toString())
} }

View File

@ -7,6 +7,7 @@ import { useInputState } from 'components/forms/FormInput.hooks'
import { JsonPreview } from 'components/JsonPreview' import { JsonPreview } from 'components/JsonPreview'
import type { BaseMinterInstance } from 'contracts/baseMinter' import type { BaseMinterInstance } from 'contracts/baseMinter'
import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter' import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter'
import type { RoyaltyRegistryInstance } from 'contracts/royaltyRegistry'
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 { toast } from 'react-hot-toast' import { toast } from 'react-hot-toast'
@ -19,10 +20,12 @@ import type { MinterType } from '../actions/Combobox'
interface CollectionQueriesProps { interface CollectionQueriesProps {
minterContractAddress: string minterContractAddress: string
sg721ContractAddress: string sg721ContractAddress: string
royaltyRegistryContractAddress: string
sg721Messages: SG721Instance | undefined sg721Messages: SG721Instance | undefined
vendingMinterMessages: VendingMinterInstance | undefined vendingMinterMessages: VendingMinterInstance | undefined
baseMinterMessages: BaseMinterInstance | undefined baseMinterMessages: BaseMinterInstance | undefined
openEditionMinterMessages: OpenEditionMinterInstance | undefined openEditionMinterMessages: OpenEditionMinterInstance | undefined
royaltyRegistryMessages: RoyaltyRegistryInstance | undefined
minterType: MinterType minterType: MinterType
} }
export const CollectionQueries = ({ export const CollectionQueries = ({
@ -33,6 +36,7 @@ export const CollectionQueries = ({
openEditionMinterMessages, openEditionMinterMessages,
baseMinterMessages, baseMinterMessages,
minterType, minterType,
royaltyRegistryMessages,
}: CollectionQueriesProps) => { }: CollectionQueriesProps) => {
const wallet = useWallet() const wallet = useWallet()
@ -65,9 +69,11 @@ export const CollectionQueries = ({
baseMinterMessages, baseMinterMessages,
vendingMinterMessages, vendingMinterMessages,
openEditionMinterMessages, openEditionMinterMessages,
royaltyRegistryMessages,
type, type,
tokenId, tokenId,
address, address,
sg721ContractAddress,
] as const, ] as const,
async ({ queryKey }) => { async ({ queryKey }) => {
const [ const [
@ -75,9 +81,11 @@ export const CollectionQueries = ({
_baseMinterMessages_, _baseMinterMessages_,
_vendingMinterMessages, _vendingMinterMessages,
_openEditionMinterMessages, _openEditionMinterMessages,
_royaltyRegistryMessages,
_type, _type,
_tokenId, _tokenId,
_address, _address,
_sg721ContractAddress,
] = queryKey ] = queryKey
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const res = await resolveAddress(_address, wallet).then(async (resolvedAddress) => { const res = await resolveAddress(_address, wallet).then(async (resolvedAddress) => {
@ -88,8 +96,10 @@ export const CollectionQueries = ({
baseMinterMessages: _baseMinterMessages_, baseMinterMessages: _baseMinterMessages_,
openEditionMinterMessages: _openEditionMinterMessages, openEditionMinterMessages: _openEditionMinterMessages,
sg721Messages: _sg721Messages, sg721Messages: _sg721Messages,
royaltyRegistryMessages: _royaltyRegistryMessages,
address: resolvedAddress, address: resolvedAddress,
type: _type, type: _type,
sg721ContractAddress: _sg721ContractAddress,
}) })
return result return result
}) })
@ -102,7 +112,9 @@ export const CollectionQueries = ({
toast.error(error.message, { style: { maxWidth: 'none' } }) toast.error(error.message, { style: { maxWidth: 'none' } })
} }
}, },
enabled: Boolean(sg721ContractAddress && minterContractAddress && type), enabled:
Boolean(type && type === 'infinity_swap_royalties' && sg721ContractAddress) ||
Boolean(sg721ContractAddress && minterContractAddress && type),
retry: false, retry: false,
}, },
) )

View File

@ -1,7 +1,9 @@
import type { BaseMinterInstance } from 'contracts/baseMinter' import type { BaseMinterInstance } from 'contracts/baseMinter'
import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter/contract' import type { OpenEditionMinterInstance } from 'contracts/openEditionMinter/contract'
import type { RoyaltyRegistryInstance } from 'contracts/royaltyRegistry'
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 { INFINITY_SWAP_PROTOCOL_ADDRESS } from 'utils/constants'
export type QueryType = typeof QUERY_TYPES[number] export type QueryType = typeof QUERY_TYPES[number]
@ -13,6 +15,7 @@ export const QUERY_TYPES = [
'total_mint_count', 'total_mint_count',
'tokens', 'tokens',
// 'token_owners', // 'token_owners',
'infinity_swap_royalties',
'token_info', 'token_info',
'config', 'config',
'status', 'status',
@ -35,6 +38,11 @@ export const VENDING_QUERY_LIST: QueryListItem[] = [
name: 'Mint Price', name: 'Mint Price',
description: `Get the price of minting a token.`, description: `Get the price of minting a token.`,
}, },
{
id: 'infinity_swap_royalties',
name: 'Infinity Swap Royalty Details',
description: `Get the collection's royalty details for Infinity Swap`,
},
{ {
id: 'num_tokens', id: 'num_tokens',
name: 'Mintable Number of Tokens', name: 'Mintable Number of Tokens',
@ -77,6 +85,11 @@ export const BASE_QUERY_LIST: QueryListItem[] = [
name: 'Tokens Minted to User', name: 'Tokens Minted to User',
description: `Get the number of tokens minted in the collection to a user.`, description: `Get the number of tokens minted in the collection to a user.`,
}, },
{
id: 'infinity_swap_royalties',
name: 'Infinity Swap Royalty Details',
description: `Get the collection's royalty details for Infinity Swap`,
},
{ {
id: 'token_info', id: 'token_info',
name: 'Token Info', name: 'Token Info',
@ -104,6 +117,11 @@ export const OPEN_EDITION_QUERY_LIST: QueryListItem[] = [
name: 'Mint Price', name: 'Mint Price',
description: `Get the price of minting a token.`, description: `Get the price of minting a token.`,
}, },
{
id: 'infinity_swap_royalties',
name: 'Infinity Swap Royalty Details',
description: `Get the collection's royalty details for Infinity Swap`,
},
{ {
id: 'tokens_minted_to_user', id: 'tokens_minted_to_user',
name: 'Tokens Minted to User', name: 'Tokens Minted to User',
@ -148,6 +166,8 @@ export type DispatchQueryArgs = {
vendingMinterMessages?: VendingMinterInstance vendingMinterMessages?: VendingMinterInstance
openEditionMinterMessages?: OpenEditionMinterInstance openEditionMinterMessages?: OpenEditionMinterInstance
sg721Messages?: SG721Instance sg721Messages?: SG721Instance
royaltyRegistryMessages?: RoyaltyRegistryInstance
sg721ContractAddress?: string
} & ( } & (
| { type: undefined } | { type: undefined }
| { type: Select<'collection_info'> } | { type: Select<'collection_info'> }
@ -156,6 +176,7 @@ export type DispatchQueryArgs = {
| { type: Select<'tokens_minted_to_user'>; address: string } | { type: Select<'tokens_minted_to_user'>; address: string }
| { type: Select<'total_mint_count'> } | { type: Select<'total_mint_count'> }
| { type: Select<'tokens'>; address: string } | { type: Select<'tokens'>; address: string }
| { type: Select<'infinity_swap_royalties'> }
// | { type: Select<'token_owners'> } // | { type: Select<'token_owners'> }
| { type: Select<'token_info'>; tokenId: string } | { type: Select<'token_info'>; tokenId: string }
| { type: Select<'config'> } | { type: Select<'config'> }
@ -163,7 +184,13 @@ export type DispatchQueryArgs = {
) )
export const dispatchQuery = async (args: DispatchQueryArgs) => { export const dispatchQuery = async (args: DispatchQueryArgs) => {
const { baseMinterMessages, vendingMinterMessages, openEditionMinterMessages, sg721Messages } = args const {
baseMinterMessages,
vendingMinterMessages,
openEditionMinterMessages,
sg721Messages,
royaltyRegistryMessages,
} = args
if (!baseMinterMessages || !vendingMinterMessages || !openEditionMinterMessages || !sg721Messages) { if (!baseMinterMessages || !vendingMinterMessages || !openEditionMinterMessages || !sg721Messages) {
throw new Error('Cannot execute actions') throw new Error('Cannot execute actions')
} }
@ -189,6 +216,12 @@ export const dispatchQuery = async (args: DispatchQueryArgs) => {
// case 'token_owners': { // case 'token_owners': {
// return vendingMinterMessages.updateStartTime(txSigner, args.startTime) // return vendingMinterMessages.updateStartTime(txSigner, args.startTime)
// } // }
case 'infinity_swap_royalties': {
return royaltyRegistryMessages?.collectionRoyaltyProtocol(
args.sg721ContractAddress as string,
INFINITY_SWAP_PROTOCOL_ADDRESS,
)
}
case 'token_info': { case 'token_info': {
if (!args.tokenId) return if (!args.tokenId) return
return sg721Messages.allNftInfo(args.tokenId) return sg721Messages.allNftInfo(args.tokenId)

View File

@ -25,23 +25,23 @@ export const EXECUTE_LIST: ExecuteListItem[] = [
}, },
{ {
id: 'set_collection_royalty_default', id: 'set_collection_royalty_default',
name: 'Set Collection Royalty Default', name: 'Set Default Collection Royalty',
description: 'Set collection royalty default', description: 'Set default collection royalty for unknown protocols',
}, },
{ {
id: 'update_collection_royalty_default', id: 'update_collection_royalty_default',
name: 'Update Collection Royalty Default', name: 'Update Default Collection Royalty',
description: 'Update collection royalty default', description: 'Update default collection royalty for unknown protocols',
}, },
{ {
id: 'set_collection_royalty_protocol', id: 'set_collection_royalty_protocol',
name: 'Set Collection Royalty Protocol', name: 'Set Protocol Collection Royalty',
description: 'Set collection royalty protocol', description: 'Set collection royalty for a specific protocol',
}, },
{ {
id: 'update_collection_royalty_protocol', id: 'update_collection_royalty_protocol',
name: 'Update Collection Royalty Protocol', name: 'Update Protocol Collection Royalty',
description: 'Update collection royalty protocol', description: 'Update collection royalty for a specific protocol',
}, },
] ]

1
env.d.ts vendored
View File

@ -47,6 +47,7 @@ declare namespace NodeJS {
readonly NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS: string readonly NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS: string
readonly NEXT_PUBLIC_SG721_NAME_ADDRESS: string readonly NEXT_PUBLIC_SG721_NAME_ADDRESS: string
readonly NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS: string readonly NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS: string
readonly NEXT_PUBLIC_INFINITY_SWAP_PROTOCOL_ADDRESS: string
readonly NEXT_PUBLIC_BASE_MINTER_CODE_ID: string readonly NEXT_PUBLIC_BASE_MINTER_CODE_ID: string
readonly NEXT_PUBLIC_BADGE_HUB_CODE_ID: string readonly NEXT_PUBLIC_BADGE_HUB_CODE_ID: string
readonly NEXT_PUBLIC_BADGE_HUB_ADDRESS: string readonly NEXT_PUBLIC_BADGE_HUB_ADDRESS: string

View File

@ -1,6 +1,6 @@
{ {
"name": "stargaze-studio", "name": "stargaze-studio",
"version": "0.7.10", "version": "0.7.11",
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
], ],

View File

@ -12,6 +12,7 @@ import { useRouter } from 'next/router'
import { NextSeo } from 'next-seo' import { NextSeo } from 'next-seo'
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import toast from 'react-hot-toast' import toast from 'react-hot-toast'
import { ROYALTY_REGISTRY_ADDRESS } from 'utils/constants'
import { useDebounce } from 'utils/debounce' import { useDebounce } from 'utils/debounce'
import { withMetadata } from 'utils/layout' import { withMetadata } from 'utils/layout'
import { links } from 'utils/links' import { links } from 'utils/links'
@ -24,6 +25,7 @@ const CollectionActionsPage: NextPage = () => {
vendingMinter: vendingMinterContract, vendingMinter: vendingMinterContract,
openEditionMinter: openEditionMinterContract, openEditionMinter: openEditionMinterContract,
sg721: sg721Contract, sg721: sg721Contract,
royaltyRegistry: royaltyRegistryContract,
} = useContracts() } = useContracts()
const wallet = useWallet() const wallet = useWallet()
@ -66,6 +68,11 @@ const CollectionActionsPage: NextPage = () => {
[sg721Contract, sg721ContractState.value], [sg721Contract, sg721ContractState.value],
) )
const royaltyRegistryMessages = useMemo(
() => royaltyRegistryContract?.use(ROYALTY_REGISTRY_ADDRESS),
[royaltyRegistryContract],
)
const sg721ContractAddress = sg721ContractState.value const sg721ContractAddress = sg721ContractState.value
const minterContractAddress = minterContractState.value const minterContractAddress = minterContractState.value
@ -227,6 +234,7 @@ const CollectionActionsPage: NextPage = () => {
minterContractAddress={minterContractState.value} minterContractAddress={minterContractState.value}
minterType={minterType} minterType={minterType}
openEditionMinterMessages={openEditionMinterMessages} openEditionMinterMessages={openEditionMinterMessages}
royaltyRegistryMessages={royaltyRegistryMessages}
sg721ContractAddress={sg721ContractState.value} sg721ContractAddress={sg721ContractState.value}
sg721Messages={sg721Messages} sg721Messages={sg721Messages}
sg721Type={sg721Type} sg721Type={sg721Type}
@ -238,6 +246,8 @@ const CollectionActionsPage: NextPage = () => {
minterContractAddress={minterContractState.value} minterContractAddress={minterContractState.value}
minterType={minterType} minterType={minterType}
openEditionMinterMessages={openEditionMinterMessages} openEditionMinterMessages={openEditionMinterMessages}
royaltyRegistryContractAddress={ROYALTY_REGISTRY_ADDRESS}
royaltyRegistryMessages={royaltyRegistryMessages}
sg721ContractAddress={sg721ContractState.value} sg721ContractAddress={sg721ContractState.value}
sg721Messages={sg721Messages} sg721Messages={sg721Messages}
vendingMinterMessages={vendingMinterMessages} vendingMinterMessages={vendingMinterMessages}

View File

@ -23,15 +23,18 @@ import { useEffect, useMemo, useState } from 'react'
import { toast } from 'react-hot-toast' import { toast } from 'react-hot-toast'
import { FaArrowRight } from 'react-icons/fa' import { FaArrowRight } from 'react-icons/fa'
import { useMutation } from 'react-query' import { useMutation } from 'react-query'
import { ROYALTY_REGISTRY_ADDRESS } from 'utils/constants' import { INFINITY_SWAP_PROTOCOL_ADDRESS, ROYALTY_REGISTRY_ADDRESS } from 'utils/constants'
import { withMetadata } from 'utils/layout' import { withMetadata } from 'utils/layout'
import { links } from 'utils/links' import { links } from 'utils/links'
export const protocolList = [{ name: 'Infinity Swap', address: INFINITY_SWAP_PROTOCOL_ADDRESS }]
const RoyaltyRegistryExecutePage: NextPage = () => { const RoyaltyRegistryExecutePage: NextPage = () => {
const { royaltyRegistry: contract } = useContracts() const { royaltyRegistry: contract } = useContracts()
const wallet = useWallet() const wallet = useWallet()
const [lastTx, setLastTx] = useState('') const [lastTx, setLastTx] = useState('')
const [manualProtocolInput, setManualProtocolInput] = useState(false)
const comboboxState = useExecuteComboboxState() const comboboxState = useExecuteComboboxState()
const type = comboboxState.value?.id const type = comboboxState.value?.id
@ -52,11 +55,14 @@ const RoyaltyRegistryExecutePage: NextPage = () => {
subtitle: 'Address of the collection', subtitle: 'Address of the collection',
}) })
const collectionAddress = collectionAddressState.value
const protocolAddressState = useInputState({ const protocolAddressState = useInputState({
id: 'protocol-address', id: 'protocol-address',
name: 'protocol-address', name: 'protocol-address',
title: 'Protocol Address', title: 'Protocol Address',
subtitle: 'Address of the protocol', subtitle: 'Address of the protocol',
defaultValue: INFINITY_SWAP_PROTOCOL_ADDRESS,
}) })
const recipientAddressState = useInputState({ const recipientAddressState = useInputState({
@ -131,14 +137,14 @@ const RoyaltyRegistryExecutePage: NextPage = () => {
const router = useRouter() const router = useRouter()
useEffect(() => { useEffect(() => {
if (contractAddress.length > 0) { if (collectionAddress.length > 0) {
void router.replace({ query: { contractAddress } }) void router.replace({ query: { collectionAddress } })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress]) }, [collectionAddress])
useEffect(() => { useEffect(() => {
const initial = new URL(document.URL).searchParams.get('contractAddress') const initial = new URL(document.URL).searchParams.get('collectionAddress')
if (initial && initial.length > 0) contractState.onChange(initial) if (initial && initial.length > 0) collectionAddressState.onChange(initial)
}, []) }, [])
return ( return (
@ -153,14 +159,35 @@ const RoyaltyRegistryExecutePage: NextPage = () => {
<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">
<AddressInput {...contractState} />
<ExecuteCombobox {...comboboxState} />
<AddressInput {...collectionAddressState} /> <AddressInput {...collectionAddressState} />
<ExecuteCombobox {...comboboxState} />
<Conditional <Conditional
test={isEitherType(type, ['set_collection_royalty_protocol', 'update_collection_royalty_protocol'])} test={isEitherType(type, ['set_collection_royalty_protocol', 'update_collection_royalty_protocol'])}
> >
<span className="mr-4 font-bold">Selected Protocol</span>
<select
className="py-2 px-4 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => {
if (e.target.value) {
protocolAddressState.onChange(e.target.value)
setManualProtocolInput(false)
} else {
protocolAddressState.onChange('')
setManualProtocolInput(true)
}
}}
>
{protocolList.map((protocol) => (
<option key={protocol.address} value={protocol.address}>
{protocol.name}
</option>
))}
<option value="">Manual Input</option>
</select>
<Conditional test={manualProtocolInput}>
<AddressInput {...protocolAddressState} /> <AddressInput {...protocolAddressState} />
</Conditional> </Conditional>
</Conditional>
<Conditional test={showRecipientAddress}> <Conditional test={showRecipientAddress}>
<AddressInput {...recipientAddressState} /> <AddressInput {...recipientAddressState} />
</Conditional> </Conditional>

View File

@ -17,11 +17,13 @@ import { NextSeo } from 'next-seo'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { toast } from 'react-hot-toast' import { toast } from 'react-hot-toast'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { ROYALTY_REGISTRY_ADDRESS } from 'utils/constants' import { INFINITY_SWAP_PROTOCOL_ADDRESS, ROYALTY_REGISTRY_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 { resolveAddress } from 'utils/resolveAddress' import { resolveAddress } from 'utils/resolveAddress'
import { protocolList } from './execute'
const RoyaltyRegistryQueryPage: NextPage = () => { const RoyaltyRegistryQueryPage: NextPage = () => {
const { royaltyRegistry: contract } = useContracts() const { royaltyRegistry: contract } = useContracts()
const wallet = useWallet() const wallet = useWallet()
@ -47,12 +49,14 @@ const RoyaltyRegistryQueryPage: NextPage = () => {
name: 'protocol-address', name: 'protocol-address',
title: 'Protocol Address', title: 'Protocol Address',
subtitle: 'Address of the protocol', subtitle: 'Address of the protocol',
defaultValue: INFINITY_SWAP_PROTOCOL_ADDRESS,
}) })
const collectionAddress = collectionAddressState.value const collectionAddress = collectionAddressState.value
const protocolAddress = protocolAddressState.value const protocolAddress = protocolAddressState.value
const [type, setType] = useState<QueryType>('config') const [type, setType] = useState<QueryType>('config')
const [manualProtocolInput, setManualProtocolInput] = useState(false)
const { data: response } = useQuery( const { data: response } = useQuery(
[contractAddress, type, contract, wallet, collectionAddress, protocolAddress] as const, [contractAddress, type, contract, wallet, collectionAddress, protocolAddress] as const,
@ -82,14 +86,14 @@ const RoyaltyRegistryQueryPage: NextPage = () => {
const router = useRouter() const router = useRouter()
useEffect(() => { useEffect(() => {
if (contractAddress.length > 0) { if (collectionAddress.length > 0) {
void router.replace({ query: { contractAddress } }) void router.replace({ query: { collectionAddress } })
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [contractAddress]) }, [collectionAddress])
useEffect(() => { useEffect(() => {
const initial = new URL(document.URL).searchParams.get('contractAddress') const initial = new URL(document.URL).searchParams.get('collectionAddress')
if (initial && initial.length > 0) contractState.onChange(initial) if (initial && initial.length > 0) collectionAddressState.onChange(initial)
}, []) }, [])
return ( return (
@ -104,7 +108,7 @@ const RoyaltyRegistryQueryPage: NextPage = () => {
<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">
<AddressInput {...contractState} /> <AddressInput {...collectionAddressState} />
<FormControl htmlId="contract-query-type" subtitle="Type of query to be dispatched" title="Query Type"> <FormControl htmlId="contract-query-type" subtitle="Type of query to be dispatched" title="Query Type">
<select <select
className={clsx( className={clsx(
@ -124,18 +128,31 @@ const RoyaltyRegistryQueryPage: NextPage = () => {
))} ))}
</select> </select>
</FormControl> </FormControl>
<Conditional
test={
type === 'collection_royalty_default' ||
type === 'royalty_payment' ||
type === 'collection_royalty_protocol'
}
>
<AddressInput {...collectionAddressState} />
</Conditional>
<Conditional test={type === 'collection_royalty_protocol' || type === 'royalty_payment'}> <Conditional test={type === 'collection_royalty_protocol' || type === 'royalty_payment'}>
<span className="mr-4 font-bold">Selected Protocol</span>
<select
className="py-2 px-4 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => {
if (e.target.value) {
protocolAddressState.onChange(e.target.value)
setManualProtocolInput(false)
} else {
protocolAddressState.onChange('')
setManualProtocolInput(true)
}
}}
>
{protocolList.map((protocol) => (
<option key={protocol.address} value={protocol.address}>
{protocol.name}
</option>
))}
<option value="">Manual Input</option>
</select>
<Conditional test={manualProtocolInput}>
<AddressInput {...protocolAddressState} /> <AddressInput {...protocolAddressState} />
</Conditional> </Conditional>
</Conditional>
</div> </div>
<JsonPreview content={contractAddress ? { type, response } : null} title="Query Response" /> <JsonPreview content={contractAddress ? { type, response } : null} title="Query Response" />
</div> </div>

View File

@ -41,6 +41,7 @@ export const OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS =
export const OPEN_EDITION_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID, 10) export const OPEN_EDITION_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID, 10)
export const SG721_NAME_ADDRESS = process.env.NEXT_PUBLIC_SG721_NAME_ADDRESS export const SG721_NAME_ADDRESS = process.env.NEXT_PUBLIC_SG721_NAME_ADDRESS
export const ROYALTY_REGISTRY_ADDRESS = process.env.NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS export const ROYALTY_REGISTRY_ADDRESS = process.env.NEXT_PUBLIC_ROYALTY_REGISTRY_ADDRESS
export const INFINITY_SWAP_PROTOCOL_ADDRESS = process.env.NEXT_PUBLIC_INFINITY_SWAP_PROTOCOL_ADDRESS
export const BASE_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10) export const BASE_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10)
export const BADGE_HUB_CODE_ID = parseInt(process.env.NEXT_PUBLIC_BADGE_HUB_CODE_ID, 10) export const BADGE_HUB_CODE_ID = parseInt(process.env.NEXT_PUBLIC_BADGE_HUB_CODE_ID, 10)
export const BADGE_HUB_ADDRESS = process.env.NEXT_PUBLIC_BADGE_HUB_ADDRESS export const BADGE_HUB_ADDRESS = process.env.NEXT_PUBLIC_BADGE_HUB_ADDRESS