Merge pull request #205 from public-awesome/develop

Sync dev > main
This commit is contained in:
Serkan Reis 2023-08-31 14:19:37 +03:00 committed by GitHub
commit 3118d14087
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1201 additions and 167 deletions

View File

@ -1,4 +1,4 @@
APP_VERSION=0.7.2
APP_VERSION=0.7.4
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
NEXT_PUBLIC_SG721_CODE_ID=2595
@ -8,14 +8,35 @@ NEXT_PUBLIC_OPEN_EDITION_SG721_UPDATABLE_CODE_ID=2596
NEXT_PUBLIC_VENDING_MINTER_CODE_ID=2600
NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID=2601
NEXT_PUBLIC_BASE_MINTER_CODE_ID=2598
NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID=2579
NEXT_PUBLIC_VENDING_FACTORY_ADDRESS="stars18h7ugh8eaug7wr0w4yjw0ls5s937z35pnkg935ucsek2y9xl3gaqqk4jtx"
NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS="stars1h65nms9gwg4vdktyqj84tu50gwlm34e0eczl5w2ezllxuzfxy9esa9qlt0"
NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q"
NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS=
NEXT_PUBLIC_BASE_FACTORY_ADDRESS="stars1a45hcxty3spnmm2f0papl8v4dk5ew29s4syhn4efte8u5haex99qlkrtnx"
NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS="stars100xegx2syry4tclkmejjwxk4nfqahvcqhm9qxut5wxuzhj5d9qfsh5nmym"
NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS="stars1sqweqcxlf2f7qhf27gn5naqusk5q52fkzewmy63c4sglvle3s7ls6k828e"
NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS="stars1fk5dkzcylam8mcpqrn8y9spauvc3d4navtaqurcc49dc3p9f8d3qdkvymx"
NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID=2579
# NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS=
# NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS=
# NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS=
# NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS=
NEXT_PUBLIC_OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS="stars1vzffawsjhvspstu5lvtzz2x5n7zh07hnw09c9dfxcj78un05rcms5n3q3e"
NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS="stars1tc09vlgdg8rqyapcxwm9qdq8naj4gym9px4ntue9cs0kse5rvess0nee3a"
NEXT_PUBLIC_SG721_NAME_ADDRESS="stars1fx74nkqkw2748av8j7ew7r3xt9cgjqduwn8m0ur5lhe49uhlsasszc5fhr"
NEXT_PUBLIC_WHITELIST_CODE_ID=2602
@ -33,4 +54,4 @@ NEXT_PUBLIC_NETWORK=testnet
NEXT_PUBLIC_STARGAZE_WEBSITE_URL=https://testnet.publicawesome.dev
NEXT_PUBLIC_BADGES_URL=https://badges.publicawesome.dev
NEXT_PUBLIC_WEBSITE_URL=https://
NEXT_PUBLIC_SYNC_COLLECTIONS_API_URL="https://..."
NEXT_PUBLIC_SYNC_COLLECTIONS_API_URL="https://..."

View File

@ -13,6 +13,8 @@ export interface MetadataInputProps {
selectedAssetFile: File
selectedMetadataFile: File
updateMetadataToUpload: (metadataFile: File) => void
onChange?: (metadata: any) => void
importedMetadata?: any
}
export const MetadataInput = (props: MetadataInputProps) => {
@ -151,9 +153,12 @@ export const MetadataInput = (props: MetadataInputProps) => {
useEffect(() => {
console.log(props.selectedMetadataFile?.name)
if (props.selectedMetadataFile) void parseMetadata(props.selectedMetadataFile)
else void parseMetadata(emptyMetadataFile)
}, [props.selectedMetadataFile?.name])
if (props.selectedMetadataFile) {
void parseMetadata(props.selectedMetadataFile)
} else if (!props.importedMetadata) {
void parseMetadata(emptyMetadataFile)
}
}, [props.selectedMetadataFile?.name, props.importedMetadata])
const nameStateMemo = useMemo(() => nameState, [nameState.value])
const descriptionStateMemo = useMemo(() => descriptionState, [descriptionState.value])
@ -163,7 +168,10 @@ export const MetadataInput = (props: MetadataInputProps) => {
useEffect(() => {
console.log('Update metadata')
if (metadata) generateUpdatedMetadata()
if (metadata) {
generateUpdatedMetadata()
if (props.onChange) props.onChange(metadata)
}
console.log(metadata)
}, [
nameStateMemo.value,
@ -173,6 +181,33 @@ export const MetadataInput = (props: MetadataInputProps) => {
attributesStateMemo.entries,
])
useEffect(() => {
if (props.importedMetadata) {
void parseMetadata(emptyMetadataFile).then(() => {
console.log('Imported metadata: ', props.importedMetadata)
nameState.onChange(props.importedMetadata.name || '')
descriptionState.onChange(props.importedMetadata.description || '')
externalUrlState.onChange(props.importedMetadata.external_url || '')
youtubeUrlState.onChange(props.importedMetadata.youtube_url || '')
if (props.importedMetadata?.attributes && props.importedMetadata?.attributes?.length > 0) {
attributesState.reset()
props.importedMetadata?.attributes?.forEach((attribute: { trait_type: string; value: string }) => {
attributesState.add({
trait_type: attribute.trait_type,
value: attribute.value,
})
})
} else {
attributesState.reset()
attributesState.add({
trait_type: '',
value: '',
})
}
})
}
}, [props.importedMetadata])
return (
<div>
<div className="grid grid-cols-2 mt-4 mr-4 ml-8 w-full max-w-6xl max-h-full no-scrollbar">

View File

@ -44,7 +44,7 @@ export interface BadgeDetailsDataProps {
youtube_url?: string
}
export const BadgeDetails = ({ metadataSize, onChange }: BadgeDetailsProps) => {
export const BadgeDetails = ({ metadataSize, onChange, uploadMethod }: BadgeDetailsProps) => {
const wallet = useWallet()
const [timestamp, setTimestamp] = useState<Date | undefined>(undefined)
const [transferrable, setTransferrable] = useState<boolean>(false)
@ -192,6 +192,10 @@ export const BadgeDetails = ({ metadataSize, onChange }: BadgeDetailsProps) => {
})
}, [metadataFile])
useEffect(() => {
animationUrlState.onChange('')
}, [uploadMethod])
useEffect(() => {
try {
const data: BadgeDetailsDataProps = {
@ -266,6 +270,7 @@ export const BadgeDetails = ({ metadataSize, onChange }: BadgeDetailsProps) => {
<TextInput className="mt-2" {...nameState} />
<TextInput className="mt-2" {...descriptionState} />
<NumberInput className="mt-2" {...maxSupplyState} />
{uploadMethod === 'existing' ? <TextInput className="mt-2" {...animationUrlState} /> : null}
<TextInput className="mt-2" {...externalUrlState} />
<FormControl className="mt-2" htmlId="expiry-date" subtitle="Badge minting expiry date" title="Expiry Date">

View File

@ -1,5 +1,5 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable jsx-a11y/media-has-caption */
/* eslint-disable no-misleading-character-class */
/* eslint-disable no-control-regex */
@ -10,9 +10,10 @@ import { TextInput } from 'components/forms/FormInput'
import { useInputState } from 'components/forms/FormInput.hooks'
import { SingleAssetPreview } from 'components/SingleAssetPreview'
import type { ChangeEvent } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'react-hot-toast'
import type { UploadServiceType } from 'services/upload'
import { getAssetType } from 'utils/getAssetType'
export type UploadMethod = 'new' | 'existing'
export type MintRule = 'by_key' | 'by_minter' | 'by_keys' | 'not_resolved'
@ -129,6 +130,22 @@ export const ImageUploadDetails = ({ onChange, mintRule }: ImageUploadDetailsPro
imageUrlState.onChange('')
}, [uploadMethod, mintRule])
const videoPreview = useMemo(
() => (
<video
className="ml-4"
controls
id="video"
onMouseEnter={(e) => e.currentTarget.play()}
onMouseLeave={(e) => e.currentTarget.pause()}
src={
imageUrlState.value ? imageUrlState.value.replace('ipfs://', 'https://ipfs-gw.stargaze-apis.com/ipfs/') : ''
}
/>
),
[imageUrlState.value],
)
return (
<div className="justify-items-start mb-3 rounded border-2 border-white/20 flex-column">
<div className="flex justify-center">
@ -190,13 +207,16 @@ export const ImageUploadDetails = ({ onChange, mintRule }: ImageUploadDetailsPro
<div className="flex flex-row w-full">
<TextInput {...imageUrlState} className="mt-2 ml-6 w-full max-w-2xl" />
<Conditional test={imageUrlState.value !== ''}>
<div className="mt-2 ml-4 w-1/4 border-2 border-dashed">
<img
alt="badge-preview"
className="w-full"
src={imageUrlState.value.replace('IPFS://', 'ipfs://').replace(/,/g, '').replace(/"/g, '').trim()}
/>
</div>
{getAssetType(imageUrlState.value) === 'image' && (
<div className="mt-2 ml-4 w-1/4 border-2 border-dashed">
<img
alt="badge-preview"
className="w-full"
src={imageUrlState.value.replace('IPFS://', 'ipfs://').replace(/,/g, '').replace(/"/g, '').trim()}
/>
</div>
)}
{getAssetType(imageUrlState.value) === 'video' && videoPreview}
</Conditional>
</div>
</div>
@ -277,7 +297,7 @@ export const ImageUploadDetails = ({ onChange, mintRule }: ImageUploadDetailsPro
)}
>
<input
accept="image/*"
accept="image/*, video/*"
className={clsx(
'file:py-2 file:px-4 file:mr-4 file:bg-plumbus-light file:rounded file:border-0 cursor-pointer',
'before:absolute before:inset-0 before:hover:bg-white/5 before:transition',

View File

@ -28,6 +28,7 @@ export interface MinterInfo {
interface BaseMinterDetailsProps {
onChange: (data: BaseMinterDetailsDataProps) => void
minterType: MinterType
importedBaseMinterDetails?: BaseMinterDetailsDataProps
}
export interface BaseMinterDetailsDataProps {
@ -37,7 +38,7 @@ export interface BaseMinterDetailsDataProps {
collectionTokenCount: number | undefined
}
export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsProps) => {
export const BaseMinterDetails = ({ onChange, minterType, importedBaseMinterDetails }: BaseMinterDetailsProps) => {
const wallet = useWallet()
const [myBaseMinterContracts, setMyBaseMinterContracts] = useState<MinterInfo[]>([])
@ -198,6 +199,15 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
collectionTokenCount,
])
useEffect(() => {
if (importedBaseMinterDetails) {
setBaseMinterAcquisitionMethod(importedBaseMinterDetails.baseMinterAcquisitionMethod)
existingBaseMinterState.onChange(
importedBaseMinterDetails.existingBaseMinter ? importedBaseMinterDetails.existingBaseMinter : '',
)
}
}, [importedBaseMinterDetails])
return (
<div className="mx-10 mb-4 rounded border-2 border-white/20">
<div className="flex justify-center mb-2">

View File

@ -26,6 +26,7 @@ interface CollectionDetailsProps {
uploadMethod: UploadMethod
coverImageUrl: string
minterType: MinterType
importedCollectionDetails?: CollectionDetailsDataProps
}
export interface CollectionDetailsDataProps {
@ -39,7 +40,13 @@ export interface CollectionDetailsDataProps {
updatable: boolean
}
export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minterType }: CollectionDetailsProps) => {
export const CollectionDetails = ({
onChange,
uploadMethod,
coverImageUrl,
minterType,
importedCollectionDetails,
}: CollectionDetailsProps) => {
const [coverImage, setCoverImage] = useState<File | null>(null)
const [timestamp, setTimestamp] = useState<Date | undefined>()
const [explicit, setExplicit] = useState<boolean>(false)
@ -105,6 +112,23 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
updatable,
])
useEffect(() => {
if (importedCollectionDetails) {
nameState.onChange(importedCollectionDetails.name)
descriptionState.onChange(importedCollectionDetails.description)
symbolState.onChange(importedCollectionDetails.symbol)
externalLinkState.onChange(importedCollectionDetails.externalLink || '')
setTimestamp(
importedCollectionDetails.startTradingTime
? new Date(parseInt(importedCollectionDetails.startTradingTime) / 1_000_000)
: undefined,
)
setExplicit(importedCollectionDetails.explicit)
setUpdatable(importedCollectionDetails.updatable)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedCollectionDetails])
const selectCoverImage = (event: ChangeEvent<HTMLInputElement>) => {
if (event.target.files === null) return toast.error('Error selecting cover image')
if (event.target.files.length === 0) {

View File

@ -4,6 +4,9 @@ import { FormControl } from 'components/FormControl'
import { FormGroup } from 'components/FormGroup'
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
import { InputDateTime } from 'components/InputDateTime'
import { vendingMinterList } from 'config/minter'
import type { TokenInfo } from 'config/token'
import { stars, tokensList } from 'config/token'
import React, { useEffect, useState } from 'react'
import { resolveAddress } from 'utils/resolveAddress'
@ -16,6 +19,8 @@ interface MintingDetailsProps {
numberOfTokens: number | undefined
uploadMethod: UploadMethod
minimumMintPrice: number
mintingTokenFromFactory?: TokenInfo
importedMintingDetails?: MintingDetailsDataProps
}
export interface MintingDetailsDataProps {
@ -24,12 +29,21 @@ export interface MintingDetailsDataProps {
perAddressLimit: number
startTime: string
paymentAddress?: string
selectedMintToken?: TokenInfo
}
export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimumMintPrice }: MintingDetailsProps) => {
export const MintingDetails = ({
onChange,
numberOfTokens,
uploadMethod,
minimumMintPrice,
mintingTokenFromFactory,
importedMintingDetails,
}: MintingDetailsProps) => {
const wallet = useWallet()
const [timestamp, setTimestamp] = useState<Date | undefined>()
const [selectedMintToken, setSelectedMintToken] = useState<TokenInfo | undefined>(stars)
const numberOfTokensState = useNumberInputState({
id: 'numberoftokens',
@ -43,7 +57,9 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum
id: 'unitPrice',
name: 'unitPrice',
title: 'Unit Price',
subtitle: `Price of each token (min. ${minimumMintPrice} STARS)`,
subtitle: `Price of each token (min. ${minimumMintPrice} ${
mintingTokenFromFactory ? mintingTokenFromFactory.displayName : 'STARS'
})`,
placeholder: '50',
})
@ -85,6 +101,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum
perAddressLimit: perAddressLimitState.value,
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
paymentAddress: paymentAddressState.value.trim(),
selectedMintToken,
}
onChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps
@ -95,8 +112,21 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum
perAddressLimitState.value,
timestamp,
paymentAddressState.value,
selectedMintToken,
])
useEffect(() => {
if (importedMintingDetails) {
numberOfTokensState.onChange(importedMintingDetails.numTokens)
unitPriceState.onChange(Number(importedMintingDetails.unitPrice) / 1_000_000)
perAddressLimitState.onChange(importedMintingDetails.perAddressLimit)
setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000))
paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '')
setSelectedMintToken(tokensList.find((token) => token.id === importedMintingDetails.selectedMintToken?.id))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedMintingDetails])
return (
<div>
<FormGroup subtitle="Information about your minting settings" title="Minting Details">
@ -106,7 +136,23 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimum
isRequired
value={uploadMethod === 'new' ? numberOfTokens : numberOfTokensState.value}
/>
<NumberInput {...unitPriceState} isRequired />
<div className="flex flex-row items-center">
<NumberInput {...unitPriceState} isRequired />
<select
className="py-[9px] px-4 mt-14 ml-2 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))}
value={selectedMintToken?.displayName}
>
{vendingMinterList
.filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false)
.map((minter) => (
<option key={minter.id} className="bg-black" value={minter.supportedToken.displayName}>
{minter.supportedToken.displayName}
</option>
))}
</select>
</div>
<NumberInput {...perAddressLimitState} isRequired />
<FormControl htmlId="timestamp" isRequired subtitle="Minting start time (local)" title="Start Time">
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />

View File

@ -9,6 +9,7 @@ import { NumberInput, TextInput } from '../../forms/FormInput'
interface RoyaltyDetailsProps {
onChange: (data: RoyaltyDetailsDataProps) => void
importedRoyaltyDetails?: RoyaltyDetailsDataProps
}
export interface RoyaltyDetailsDataProps {
@ -19,7 +20,7 @@ export interface RoyaltyDetailsDataProps {
type RoyaltyState = 'none' | 'new'
export const RoyaltyDetails = ({ onChange }: RoyaltyDetailsProps) => {
export const RoyaltyDetails = ({ onChange, importedRoyaltyDetails }: RoyaltyDetailsProps) => {
const wallet = useWallet()
const [royaltyState, setRoyaltyState] = useState<RoyaltyState>('none')
@ -60,6 +61,15 @@ export const RoyaltyDetails = ({ onChange }: RoyaltyDetailsProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [royaltyState, royaltyPaymentAddressState.value, royaltyShareState.value])
useEffect(() => {
if (importedRoyaltyDetails) {
setRoyaltyState(importedRoyaltyDetails.royaltyType)
royaltyPaymentAddressState.onChange(importedRoyaltyDetails.paymentAddress)
royaltyShareState.onChange(importedRoyaltyDetails.share.toString())
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedRoyaltyDetails])
return (
<div className="py-3 px-8 rounded border-2 border-white/20">
<div className="flex justify-center">

View File

@ -31,6 +31,7 @@ interface UploadDetailsProps {
onChange: (value: UploadDetailsDataProps) => void
minterType: MinterType
baseMinterAcquisitionMethod?: BaseMinterAcquisitionMethod
importedUploadDetails?: UploadDetailsDataProps
}
export interface UploadDetailsDataProps {
@ -46,7 +47,12 @@ export interface UploadDetailsDataProps {
baseMinterMetadataFile?: File
}
export const UploadDetails = ({ onChange, minterType, baseMinterAcquisitionMethod }: UploadDetailsProps) => {
export const UploadDetails = ({
onChange,
minterType,
baseMinterAcquisitionMethod,
importedUploadDetails,
}: UploadDetailsProps) => {
const [assetFilesArray, setAssetFilesArray] = useState<File[]>([])
const [metadataFilesArray, setMetadataFilesArray] = useState<File[]>([])
const [uploadMethod, setUploadMethod] = useState<UploadMethod>('new')
@ -274,10 +280,31 @@ export const UploadDetails = ({ onChange, minterType, baseMinterAcquisitionMetho
setMetadataFilesArray([])
if (assetFilesRef.current) assetFilesRef.current.value = ''
setAssetFilesArray([])
baseTokenUriState.onChange('')
coverImageUrlState.onChange('')
if (!importedUploadDetails || minterType === 'base') {
baseTokenUriState.onChange('')
coverImageUrlState.onChange('')
}
}, [uploadMethod, minterType, baseMinterAcquisitionMethod])
useEffect(() => {
if (importedUploadDetails) {
if (importedUploadDetails.uploadMethod === 'new') {
setUploadMethod('new')
setUploadService(importedUploadDetails.uploadService)
nftStorageApiKeyState.onChange(importedUploadDetails.nftStorageApiKey || '')
pinataApiKeyState.onChange(importedUploadDetails.pinataApiKey || '')
pinataSecretKeyState.onChange(importedUploadDetails.pinataSecretKey || '')
baseTokenUriState.onChange(importedUploadDetails.baseTokenURI || '')
coverImageUrlState.onChange(importedUploadDetails.imageUrl || '')
} else if (importedUploadDetails.uploadMethod === 'existing') {
setUploadMethod('existing')
baseTokenUriState.onChange(importedUploadDetails.baseTokenURI || '')
coverImageUrlState.onChange(importedUploadDetails.imageUrl || '')
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedUploadDetails])
return (
<div className="justify-items-start mb-3 rounded border-2 border-white/20 flex-column">
<div className="flex justify-center">

View File

@ -8,6 +8,8 @@ import { useInputState, useNumberInputState } from 'components/forms/FormInput.h
import { InputDateTime } from 'components/InputDateTime'
import type { WhitelistFlexMember } from 'components/WhitelistFlexUpload'
import { WhitelistFlexUpload } from 'components/WhitelistFlexUpload'
import type { TokenInfo } from 'config/token'
import { useWallet } from 'contexts/wallet'
import React, { useEffect, useState } from 'react'
import { isValidAddress } from 'utils/isValidAddress'
@ -18,6 +20,8 @@ import { WhitelistUpload } from '../../WhitelistUpload'
interface WhitelistDetailsProps {
onChange: (data: WhitelistDetailsDataProps) => void
mintingTokenFromFactory?: TokenInfo
importedWhitelistDetails?: WhitelistDetailsDataProps
}
export interface WhitelistDetailsDataProps {
@ -38,7 +42,13 @@ type WhitelistState = 'none' | 'existing' | 'new'
type WhitelistType = 'standard' | 'flex'
export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => {
export const WhitelistDetails = ({
onChange,
mintingTokenFromFactory,
importedWhitelistDetails,
}: WhitelistDetailsProps) => {
const wallet = useWallet()
const [whitelistState, setWhitelistState] = useState<WhitelistState>('none')
const [whitelistType, setWhitelistType] = useState<WhitelistType>('standard')
const [startDate, setStartDate] = useState<Date | undefined>(undefined)
@ -58,7 +68,9 @@ export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => {
id: 'unit-price',
name: 'unitPrice',
title: 'Unit Price',
subtitle: 'Token price for whitelisted addresses \n (min. 0 STARS)',
subtitle: `Token price for whitelisted addresses \n (min. 0 ${
mintingTokenFromFactory ? mintingTokenFromFactory.displayName : 'STARS'
})`,
placeholder: '25',
})
@ -89,8 +101,10 @@ export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => {
}
useEffect(() => {
setWhitelistStandardArray([])
setWhitelistFlexArray([])
if (!importedWhitelistDetails) {
setWhitelistStandardArray([])
setWhitelistFlexArray([])
}
}, [whitelistType])
useEffect(() => {
@ -138,6 +152,63 @@ export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => {
adminsMutable,
])
// make the necessary changes with respect to imported whitelist details
useEffect(() => {
if (importedWhitelistDetails) {
setWhitelistState(importedWhitelistDetails.whitelistState)
setWhitelistType(importedWhitelistDetails.whitelistType)
whitelistAddressState.onChange(
importedWhitelistDetails.contractAddress ? importedWhitelistDetails.contractAddress : '',
)
unitPriceState.onChange(
importedWhitelistDetails.unitPrice ? Number(importedWhitelistDetails.unitPrice) / 1000000 : 0,
)
memberLimitState.onChange(importedWhitelistDetails.memberLimit ? importedWhitelistDetails.memberLimit : 0)
perAddressLimitState.onChange(
importedWhitelistDetails.perAddressLimit ? importedWhitelistDetails.perAddressLimit : 0,
)
setStartDate(
importedWhitelistDetails.startTime
? new Date(Number(importedWhitelistDetails.startTime) / 1_000_000)
: undefined,
)
setEndDate(
importedWhitelistDetails.endTime ? new Date(Number(importedWhitelistDetails.endTime) / 1_000_000) : undefined,
)
setAdminsMutable(importedWhitelistDetails.adminsMutable ? importedWhitelistDetails.adminsMutable : true)
importedWhitelistDetails.admins?.forEach((admin) => {
addressListState.reset()
addressListState.add({ address: admin })
})
if (importedWhitelistDetails.whitelistType === 'standard') {
setWhitelistStandardArray([])
importedWhitelistDetails.members?.forEach((member) => {
setWhitelistStandardArray((standardArray) => [...standardArray, member as string])
})
} else {
setWhitelistFlexArray([])
importedWhitelistDetails.members?.forEach((member) => {
setWhitelistFlexArray((flexArray) => [
...flexArray,
{
address: (member as WhitelistFlexMember).address,
mint_count: (member as WhitelistFlexMember).mint_count,
},
])
})
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedWhitelistDetails])
useEffect(() => {
if (whitelistState === 'new' && wallet.address) {
addressListState.reset()
addressListState.add({ address: wallet.address })
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [whitelistState, wallet.address])
return (
<div className="py-3 px-8 rounded border-2 border-white/20">
<div className="flex justify-center">
@ -286,7 +357,6 @@ export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => {
<div className="my-4 ml-4">
<AddressList
entries={addressListState.entries}
isRequired
onAdd={addressListState.add}
onChange={addressListState.update}
onRemove={addressListState.remove}

View File

@ -31,6 +31,7 @@ export function AddressList(props: AddressListProps) {
{entries.map(([id], i) => (
<Address
key={`ib-${id}`}
defaultValue={entries[i][1]}
id={id}
isLast={i === entries.length - 1}
onAdd={onAdd}
@ -48,9 +49,10 @@ export interface AddressProps {
onAdd: AddressListProps['onAdd']
onChange: AddressListProps['onChange']
onRemove: AddressListProps['onRemove']
defaultValue?: Address
}
export function Address({ id, isLast, onAdd, onChange, onRemove }: AddressProps) {
export function Address({ id, isLast, onAdd, onChange, onRemove, defaultValue }: AddressProps) {
const wallet = useWallet()
const Icon = useMemo(() => (isLast ? FaPlus : FaMinus), [isLast])
@ -60,6 +62,7 @@ export function Address({ id, isLast, onAdd, onChange, onRemove }: AddressProps)
id: `ib-address-${htmlId}`,
name: `ib-address-${htmlId}`,
title: ``,
defaultValue: defaultValue?.address,
})
const resolveAddress = async (name: string) => {

View File

@ -28,6 +28,7 @@ interface CollectionDetailsProps {
uploadMethod: UploadMethod
coverImageUrl: string
metadataStorageMethod: MetadataStorageMethod
importedCollectionDetails?: CollectionDetailsDataProps
}
export interface CollectionDetailsDataProps {
@ -46,6 +47,7 @@ export const CollectionDetails = ({
uploadMethod,
metadataStorageMethod,
coverImageUrl,
importedCollectionDetails,
}: CollectionDetailsProps) => {
const [coverImage, setCoverImage] = useState<File | null>(null)
const [timestamp, setTimestamp] = useState<Date | undefined>()
@ -152,6 +154,23 @@ export const CollectionDetails = ({
}
}, [updatable])
useEffect(() => {
if (importedCollectionDetails) {
nameState.onChange(importedCollectionDetails.name)
descriptionState.onChange(importedCollectionDetails.description)
symbolState.onChange(importedCollectionDetails.symbol)
//setCoverImage(importedCollectionDetails.imageFile[0] || null)
externalLinkState.onChange(importedCollectionDetails.externalLink || '')
setTimestamp(
importedCollectionDetails.startTradingTime
? new Date(parseInt(importedCollectionDetails.startTradingTime) / 1_000_000)
: undefined,
)
setExplicit(importedCollectionDetails.explicit)
setUpdatable(importedCollectionDetails.updatable)
}
}, [importedCollectionDetails])
const videoPreview = useMemo(() => {
if (uploadMethod === 'new' && coverImage) {
return (

View File

@ -20,6 +20,7 @@ export type UploadMethod = 'new' | 'existing'
interface ImageUploadDetailsProps {
onChange: (value: ImageUploadDetailsDataProps) => void
importedImageUploadDetails?: ImageUploadDetailsDataProps
}
export interface ImageUploadDetailsDataProps {
@ -33,7 +34,7 @@ export interface ImageUploadDetailsDataProps {
coverImageUrl?: string
}
export const ImageUploadDetails = ({ onChange }: ImageUploadDetailsProps) => {
export const ImageUploadDetails = ({ onChange, importedImageUploadDetails }: ImageUploadDetailsProps) => {
const [assetFile, setAssetFile] = useState<File>()
const [uploadMethod, setUploadMethod] = useState<UploadMethod>('new')
const [uploadService, setUploadService] = useState<UploadServiceType>('nft-storage')
@ -140,6 +141,18 @@ export const ImageUploadDetails = ({ onChange }: ImageUploadDetailsProps) => {
imageUrlState.onChange('')
}, [uploadMethod])
useEffect(() => {
if (importedImageUploadDetails) {
setUploadMethod(importedImageUploadDetails.uploadMethod)
setUploadService(importedImageUploadDetails.uploadService)
nftStorageApiKeyState.onChange(importedImageUploadDetails.nftStorageApiKey || '')
pinataApiKeyState.onChange(importedImageUploadDetails.pinataApiKey || '')
pinataSecretKeyState.onChange(importedImageUploadDetails.pinataSecretKey || '')
imageUrlState.onChange(importedImageUploadDetails.imageUrl || '')
coverImageUrlState.onChange(importedImageUploadDetails.coverImageUrl || '')
}
}, [importedImageUploadDetails])
const previewUrl = imageUrlState.value.toLowerCase().trim().startsWith('ipfs://')
? `https://ipfs-gw.stargaze-apis.com/ipfs/${imageUrlState.value.substring(7)}`
: imageUrlState.value

View File

@ -4,6 +4,9 @@ import { FormControl } from 'components/FormControl'
import { FormGroup } from 'components/FormGroup'
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
import { InputDateTime } from 'components/InputDateTime'
import { openEditionMinterList } from 'config/minter'
import type { TokenInfo } from 'config/token'
import { stars, tokensList } from 'config/token'
import React, { useEffect, useState } from 'react'
import { resolveAddress } from 'utils/resolveAddress'
@ -15,6 +18,8 @@ interface MintingDetailsProps {
onChange: (data: MintingDetailsDataProps) => void
uploadMethod: UploadMethod
minimumMintPrice: number
mintTokenFromFactory?: TokenInfo | undefined
importedMintingDetails?: MintingDetailsDataProps
}
export interface MintingDetailsDataProps {
@ -23,19 +28,30 @@ export interface MintingDetailsDataProps {
startTime: string
endTime: string
paymentAddress?: string
selectedMintToken?: TokenInfo
}
export const MintingDetails = ({ onChange, uploadMethod, minimumMintPrice }: MintingDetailsProps) => {
export const MintingDetails = ({
onChange,
uploadMethod,
minimumMintPrice,
mintTokenFromFactory,
importedMintingDetails,
}: MintingDetailsProps) => {
const wallet = useWallet()
const [timestamp, setTimestamp] = useState<Date | undefined>()
const [endTimestamp, setEndTimestamp] = useState<Date | undefined>()
const [selectedMintToken, setSelectedMintToken] = useState<TokenInfo | undefined>(stars)
const [mintingDetailsImported, setMintingDetailsImported] = useState(false)
const unitPriceState = useNumberInputState({
id: 'unitPrice',
name: 'unitPrice',
title: 'Unit Price',
subtitle: `Price of each token (min. ${minimumMintPrice} STARS)`,
title: 'Mint Price',
subtitle: `Price of each token (min. ${minimumMintPrice} ${
mintTokenFromFactory ? mintTokenFromFactory.displayName : 'STARS'
})`,
placeholder: '50',
})
@ -62,7 +78,9 @@ export const MintingDetails = ({ onChange, uploadMethod, minimumMintPrice }: Min
}
useEffect(() => {
void resolvePaymentAddress()
if (!importedMintingDetails || (importedMintingDetails && mintingDetailsImported)) {
void resolvePaymentAddress()
}
}, [paymentAddressState.value])
useEffect(() => {
@ -76,15 +94,53 @@ export const MintingDetails = ({ onChange, uploadMethod, minimumMintPrice }: Min
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
endTime: endTimestamp ? (endTimestamp.getTime() * 1_000_000).toString() : '',
paymentAddress: paymentAddressState.value.trim(),
selectedMintToken,
}
onChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [unitPriceState.value, perAddressLimitState.value, timestamp, endTimestamp, paymentAddressState.value])
}, [
unitPriceState.value,
perAddressLimitState.value,
timestamp,
endTimestamp,
paymentAddressState.value,
selectedMintToken,
])
useEffect(() => {
if (importedMintingDetails) {
console.log('Selected Token ID: ', importedMintingDetails.selectedMintToken?.id)
unitPriceState.onChange(Number(importedMintingDetails.unitPrice) / 1000000)
perAddressLimitState.onChange(importedMintingDetails.perAddressLimit)
setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000))
setEndTimestamp(new Date(Number(importedMintingDetails.endTime) / 1_000_000))
paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '')
setSelectedMintToken(tokensList.find((token) => token.id === importedMintingDetails.selectedMintToken?.id))
setMintingDetailsImported(true)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedMintingDetails])
return (
<div className="border-l-[1px] border-gray-500 border-opacity-20">
<FormGroup subtitle="Information about your minting settings" title="Minting Details">
<NumberInput {...unitPriceState} isRequired />
<div className="flex flex-row items-center">
<NumberInput {...unitPriceState} isRequired />
<select
className="py-[9px] px-4 mt-14 ml-4 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))}
value={selectedMintToken?.displayName}
>
{openEditionMinterList
.filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false)
.map((minter) => (
<option key={minter.id} className="bg-black" value={minter.supportedToken.displayName}>
{minter.supportedToken.displayName}
</option>
))}
</select>
</div>
<NumberInput {...perAddressLimitState} isRequired />
<FormControl htmlId="timestamp" isRequired subtitle="Minting start time (local)" title="Start Time">
<InputDateTime minDate={new Date()} onChange={(date) => setTimestamp(date)} value={timestamp} />

View File

@ -28,6 +28,7 @@ export type UploadMethod = 'new' | 'existing'
interface OffChainMetadataUploadDetailsProps {
onChange: (value: OffChainMetadataUploadDetailsDataProps) => void
metadataStorageMethod?: MetadataStorageMethod
importedOffChainMetadataUploadDetails?: OffChainMetadataUploadDetailsDataProps
}
export interface OffChainMetadataUploadDetailsDataProps {
@ -41,11 +42,13 @@ export interface OffChainMetadataUploadDetailsDataProps {
tokenURI?: string
imageUrl?: string
openEditionMinterMetadataFile?: File
exportedMetadata?: any
}
export const OffChainMetadataUploadDetails = ({
onChange,
metadataStorageMethod,
importedOffChainMetadataUploadDetails,
}: OffChainMetadataUploadDetailsProps) => {
const [assetFilesArray, setAssetFilesArray] = useState<File[]>([])
const [metadataFilesArray, setMetadataFilesArray] = useState<File[]>([])
@ -53,6 +56,7 @@ export const OffChainMetadataUploadDetails = ({
const [uploadService, setUploadService] = useState<UploadServiceType>('nft-storage')
const [metadataFileArrayIndex, setMetadataFileArrayIndex] = useState(0)
const [refreshMetadata, setRefreshMetadata] = useState(false)
const [exportedMetadata, setExportedMetadata] = useState(undefined)
const [openEditionMinterMetadataFile, setOpenEditionMinterMetadataFile] = useState<File | undefined>()
@ -204,6 +208,7 @@ export const OffChainMetadataUploadDetails = ({
.replace(regex, '')
.trim(),
openEditionMinterMetadataFile,
exportedMetadata,
}
onChange(data)
} catch (error: any) {
@ -222,6 +227,7 @@ export const OffChainMetadataUploadDetails = ({
coverImageUrlState.value,
refreshMetadata,
openEditionMinterMetadataFile,
exportedMetadata,
])
useEffect(() => {
@ -229,10 +235,25 @@ export const OffChainMetadataUploadDetails = ({
setMetadataFilesArray([])
if (assetFilesRef.current) assetFilesRef.current.value = ''
setAssetFilesArray([])
tokenUriState.onChange('')
coverImageUrlState.onChange('')
if (!importedOffChainMetadataUploadDetails) {
tokenUriState.onChange('')
coverImageUrlState.onChange('')
}
}, [uploadMethod, metadataStorageMethod])
useEffect(() => {
if (importedOffChainMetadataUploadDetails) {
setUploadService(importedOffChainMetadataUploadDetails.uploadService)
nftStorageApiKeyState.onChange(importedOffChainMetadataUploadDetails.nftStorageApiKey || '')
pinataApiKeyState.onChange(importedOffChainMetadataUploadDetails.pinataApiKey || '')
pinataSecretKeyState.onChange(importedOffChainMetadataUploadDetails.pinataSecretKey || '')
setUploadMethod(importedOffChainMetadataUploadDetails.uploadMethod)
tokenUriState.onChange(importedOffChainMetadataUploadDetails.tokenURI || '')
coverImageUrlState.onChange(importedOffChainMetadataUploadDetails.imageUrl || '')
// setOpenEditionMinterMetadataFile(importedOffChainMetadataUploadDetails.openEditionMinterMetadataFile)
}
}, [importedOffChainMetadataUploadDetails])
return (
<div className="justify-items-start mb-3 rounded border-2 border-white/20 flex-column">
<div className="flex justify-center">
@ -447,6 +468,8 @@ export const OffChainMetadataUploadDetails = ({
/>
</div>
<MetadataInput
importedMetadata={importedOffChainMetadataUploadDetails?.exportedMetadata}
onChange={setExportedMetadata}
selectedAssetFile={assetFilesArray[0]}
selectedMetadataFile={metadataFilesArray[0]}
updateMetadataToUpload={updateOpenEditionMinterMetadataFile}

View File

@ -21,6 +21,7 @@ import type { UploadMethod } from './ImageUploadDetails'
interface OnChainMetadataInputDetailsProps {
onChange: (data: OnChainMetadataInputDetailsDataProps) => void
uploadMethod: UploadMethod | undefined
importedOnChainMetadataInputDetails?: OnChainMetadataInputDetailsDataProps
}
export interface OnChainMetadataInputDetailsDataProps {
@ -34,7 +35,11 @@ export interface OnChainMetadataInputDetailsDataProps {
youtube_url?: string
}
export const OnChainMetadataInputDetails = ({ onChange, uploadMethod }: OnChainMetadataInputDetailsProps) => {
export const OnChainMetadataInputDetails = ({
onChange,
uploadMethod,
importedOnChainMetadataInputDetails,
}: OnChainMetadataInputDetailsProps) => {
const wallet = useWallet()
const [timestamp, setTimestamp] = useState<Date | undefined>(undefined)
const [metadataFile, setMetadataFile] = useState<File>()
@ -196,6 +201,26 @@ export const OnChainMetadataInputDetails = ({ onChange, uploadMethod }: OnChainM
youtubeUrlState.value,
])
useEffect(() => {
if (importedOnChainMetadataInputDetails) {
nameState.onChange(importedOnChainMetadataInputDetails.name || '')
descriptionState.onChange(importedOnChainMetadataInputDetails.description || '')
externalUrlState.onChange(importedOnChainMetadataInputDetails.external_url || '')
youtubeUrlState.onChange(importedOnChainMetadataInputDetails.youtube_url || '')
animationUrlState.onChange(importedOnChainMetadataInputDetails.animation_url || '')
imageDataState.onChange(importedOnChainMetadataInputDetails.image_data || '')
if (importedOnChainMetadataInputDetails.attributes) {
attributesState.reset()
importedOnChainMetadataInputDetails.attributes.forEach((attr) => {
attributesState.add({
trait_type: attr.trait_type,
value: attr.value,
})
})
}
}
}, [importedOnChainMetadataInputDetails])
return (
<div className="py-3 px-8 rounded border-2 border-white/20">
<span className="ml-4 text-xl font-bold underline underline-offset-4">NFT Metadata</span>

View File

@ -12,6 +12,8 @@ import type { MinterType } from 'components/collections/actions/Combobox'
import { Conditional } from 'components/Conditional'
import { ConfirmationModal } from 'components/ConfirmationModal'
import { LoadingModal } from 'components/LoadingModal'
import { openEditionMinterList } from 'config/minter'
import type { TokenInfo } from 'config/token'
import { useContracts } from 'contexts/contracts'
import { addLogItem } from 'contexts/log'
import { useWallet } from 'contexts/wallet'
@ -47,13 +49,30 @@ import { type RoyaltyDetailsDataProps, RoyaltyDetails } from './RoyaltyDetails'
export type MetadataStorageMethod = 'off-chain' | 'on-chain'
export interface OpenEditionMinterDetailsDataProps {
imageUploadDetails?: ImageUploadDetailsDataProps
collectionDetails?: CollectionDetailsDataProps
royaltyDetails?: RoyaltyDetailsDataProps
onChainMetadataInputDetails?: OnChainMetadataInputDetailsDataProps
offChainMetadataUploadDetails?: OffChainMetadataUploadDetailsDataProps
mintingDetails?: MintingDetailsDataProps
metadataStorageMethod?: MetadataStorageMethod
openEditionMinterContractAddress?: string | null
coverImageUrl?: string | null
tokenUri?: string | null
tokenImageUri?: string | null
}
interface OpenEditionMinterCreatorProps {
onChange: (data: OpenEditionMinterCreatorDataProps) => void
onDetailsChange: (data: OpenEditionMinterDetailsDataProps) => void
openEditionMinterUpdatableCreationFee?: string
openEditionMinterCreationFee?: string
minimumMintPrice?: string
minimumUpdatableMintPrice?: string
minterType?: MinterType
mintTokenFromFactory?: TokenInfo | undefined
importedOpenEditionMinterDetails?: OpenEditionMinterDetailsDataProps
}
export interface OpenEditionMinterCreatorDataProps {
@ -65,20 +84,19 @@ export interface OpenEditionMinterCreatorDataProps {
export const OpenEditionMinterCreator = ({
onChange,
onDetailsChange,
openEditionMinterCreationFee,
openEditionMinterUpdatableCreationFee,
minimumMintPrice,
minimumUpdatableMintPrice,
minterType,
mintTokenFromFactory,
importedOpenEditionMinterDetails,
}: OpenEditionMinterCreatorProps) => {
const wallet = useWallet()
const { openEditionMinter: openEditionMinterContract, openEditionFactory: openEditionFactoryContract } =
useContracts()
const openEditionFactoryMessages = useMemo(
() => openEditionFactoryContract?.use(OPEN_EDITION_FACTORY_ADDRESS),
[openEditionFactoryContract, wallet.address],
)
const [metadataStorageMethod, setMetadataStorageMethod] = useState<MetadataStorageMethod>('off-chain')
const [imageUploadDetails, setImageUploadDetails] = useState<ImageUploadDetailsDataProps | null>(null)
const [collectionDetails, setCollectionDetails] = useState<CollectionDetailsDataProps | null>(null)
@ -99,6 +117,27 @@ export const OpenEditionMinterCreator = ({
const [sg721ContractAddress, setSg721ContractAddress] = useState<string | null>(null)
const [transactionHash, setTransactionHash] = useState<string | null>(null)
const factoryAddressForSelectedDenom =
openEditionMinterList.find((minter) => minter.supportedToken === mintTokenFromFactory && minter.updatable === false)
?.factoryAddress || OPEN_EDITION_FACTORY_ADDRESS
const updatableFactoryAddressForSelectedDenom =
openEditionMinterList.find((minter) => minter.supportedToken === mintTokenFromFactory && minter.updatable === true)
?.factoryAddress || OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS
const openEditionFactoryMessages = useMemo(
() =>
openEditionFactoryContract?.use(
collectionDetails?.updatable ? updatableFactoryAddressForSelectedDenom : factoryAddressForSelectedDenom,
),
[
openEditionFactoryContract,
wallet.address,
collectionDetails?.updatable,
factoryAddressForSelectedDenom,
updatableFactoryAddressForSelectedDenom,
],
)
const performOpenEditionMinterChecks = () => {
try {
setReadyToCreate(false)
@ -257,14 +296,26 @@ export const OpenEditionMinterCreator = ({
if (collectionDetails?.updatable) {
if (Number(mintingDetails.unitPrice) < Number(minimumUpdatableMintPrice))
throw new Error(
`Invalid mint price: The minimum mint price is ${Number(minimumUpdatableMintPrice) / 1000000} STARS`,
`Invalid mint price: The minimum mint price is ${Number(minimumUpdatableMintPrice) / 1000000} ${
mintTokenFromFactory?.displayName
}`,
)
} else if (Number(mintingDetails.unitPrice) < Number(minimumMintPrice))
throw new Error(`Invalid mint price: The minimum mint price is ${Number(minimumMintPrice) / 1000000} STARS`)
throw new Error(
`Invalid mint price: The minimum mint price is ${Number(minimumMintPrice) / 1000000} ${
mintTokenFromFactory?.displayName
}`,
)
if (!mintingDetails.perAddressLimit || mintingDetails.perAddressLimit < 1 || mintingDetails.perAddressLimit > 50)
throw new Error('Invalid limit for tokens per address')
if (mintingDetails.startTime === '') throw new Error('Start time is required')
if (mintingDetails.endTime === '') throw new Error('End time is required')
if (Number(mintingDetails.startTime) < new Date().getTime() * 1000000) throw new Error('Invalid start time')
if (Number(mintingDetails.endTime) < Number(mintingDetails.startTime))
throw new Error('End time cannot be earlier than start time')
if (Number(mintingDetails.endTime) === Number(mintingDetails.startTime))
throw new Error('End time cannot be equal to the start time')
if (
mintingDetails.paymentAddress &&
(!isValidAddress(mintingDetails.paymentAddress) || !mintingDetails.paymentAddress.startsWith('stars1'))
@ -435,8 +486,10 @@ export const OpenEditionMinterCreator = ({
if (getAssetType(offChainMetadataUploadDetails.assetFiles[0].name) !== 'html')
data.image = `ipfs://${assetUri}/${offChainMetadataUploadDetails.assetFiles[0].name}`
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
if (data.description) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
}
const metadataFileBlob = new Blob([JSON.stringify(data)], {
type: 'application/json',
})
@ -515,7 +568,7 @@ export const OpenEditionMinterCreator = ({
end_time: mintingDetails?.endTime,
mint_price: {
amount: Number(mintingDetails?.unitPrice).toString(),
denom: 'ustars',
denom: (mintTokenFromFactory?.denom as string) || 'ustars',
},
per_address_limit: mintingDetails?.perAddressLimit,
payment_address: mintingDetails?.paymentAddress || null,
@ -536,10 +589,8 @@ export const OpenEditionMinterCreator = ({
},
}
console.log('msg: ', msg)
const payload: OpenEditionFactoryDispatchExecuteArgs = {
contract: collectionDetails?.updatable ? OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS : OPEN_EDITION_FACTORY_ADDRESS,
contract: collectionDetails?.updatable ? updatableFactoryAddressForSelectedDenom : factoryAddressForSelectedDenom,
messages: openEditionFactoryMessages,
txSigner: wallet.address,
msg,
@ -587,6 +638,42 @@ export const OpenEditionMinterCreator = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [metadataStorageMethod, openEditionMinterContractAddress, sg721ContractAddress, transactionHash])
useEffect(() => {
const data: OpenEditionMinterDetailsDataProps = {
imageUploadDetails: imageUploadDetails ? imageUploadDetails : undefined,
collectionDetails: collectionDetails ? collectionDetails : undefined,
royaltyDetails: royaltyDetails ? royaltyDetails : undefined,
onChainMetadataInputDetails: onChainMetadataInputDetails ? onChainMetadataInputDetails : undefined,
offChainMetadataUploadDetails: offChainMetadataUploadDetails ? offChainMetadataUploadDetails : undefined,
mintingDetails: mintingDetails ? mintingDetails : undefined,
metadataStorageMethod,
openEditionMinterContractAddress,
coverImageUrl,
tokenUri,
tokenImageUri,
}
onDetailsChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
imageUploadDetails,
collectionDetails,
royaltyDetails,
onChainMetadataInputDetails,
offChainMetadataUploadDetails,
mintingDetails,
metadataStorageMethod,
openEditionMinterContractAddress,
coverImageUrl,
tokenUri,
tokenImageUri,
])
useEffect(() => {
if (importedOpenEditionMinterDetails) {
setMetadataStorageMethod(importedOpenEditionMinterDetails.metadataStorageMethod as MetadataStorageMethod)
}
}, [importedOpenEditionMinterDetails])
return (
<div>
{/* TODO: Cancel once we're able to index on-chain metadata */}
@ -634,16 +721,23 @@ export const OpenEditionMinterCreator = ({
</div>
</div>
</Conditional>
<div className={clsx('my-4 mx-10')}>
<div className={clsx('my-0 mx-10')}>
<Conditional test={metadataStorageMethod === 'off-chain'}>
<div>
<OffChainMetadataUploadDetails onChange={setOffChainMetadataUploadDetails} />
<OffChainMetadataUploadDetails
importedOffChainMetadataUploadDetails={importedOpenEditionMinterDetails?.offChainMetadataUploadDetails}
onChange={setOffChainMetadataUploadDetails}
/>
</div>
</Conditional>
<Conditional test={metadataStorageMethod === 'on-chain'}>
<div>
<ImageUploadDetails onChange={setImageUploadDetails} />
<ImageUploadDetails
importedImageUploadDetails={importedOpenEditionMinterDetails?.imageUploadDetails}
onChange={setImageUploadDetails}
/>
<OnChainMetadataInputDetails
importedOnChainMetadataInputDetails={importedOpenEditionMinterDetails?.onChainMetadataInputDetails}
onChange={setOnChainMetadataInputDetails}
uploadMethod={imageUploadDetails?.uploadMethod}
/>
@ -657,6 +751,7 @@ export const OpenEditionMinterCreator = ({
? (offChainMetadataUploadDetails?.imageUrl as string)
: (imageUploadDetails?.coverImageUrl as string)
}
importedCollectionDetails={importedOpenEditionMinterDetails?.collectionDetails}
metadataStorageMethod={metadataStorageMethod}
onChange={setCollectionDetails}
uploadMethod={
@ -666,17 +761,22 @@ export const OpenEditionMinterCreator = ({
}
/>
<MintingDetails
importedMintingDetails={importedOpenEditionMinterDetails?.mintingDetails}
minimumMintPrice={
collectionDetails?.updatable
? Number(minimumUpdatableMintPrice) / 1000000
: Number(minimumMintPrice) / 1000000
}
mintTokenFromFactory={mintTokenFromFactory}
onChange={setMintingDetails}
uploadMethod={offChainMetadataUploadDetails?.uploadMethod as UploadMethod}
/>
</div>
<div className="my-6">
<RoyaltyDetails onChange={setRoyaltyDetails} />
<RoyaltyDetails
importedRoyaltyDetails={importedOpenEditionMinterDetails?.royaltyDetails}
onChange={setRoyaltyDetails}
/>
</div>
<div className="flex justify-end w-full">
<Button

View File

@ -9,6 +9,7 @@ import { NumberInput, TextInput } from '../forms/FormInput'
interface RoyaltyDetailsProps {
onChange: (data: RoyaltyDetailsDataProps) => void
importedRoyaltyDetails?: RoyaltyDetailsDataProps
}
export interface RoyaltyDetailsDataProps {
@ -19,9 +20,10 @@ export interface RoyaltyDetailsDataProps {
type RoyaltyState = 'none' | 'new'
export const RoyaltyDetails = ({ onChange }: RoyaltyDetailsProps) => {
export const RoyaltyDetails = ({ onChange, importedRoyaltyDetails }: RoyaltyDetailsProps) => {
const wallet = useWallet()
const [royaltyState, setRoyaltyState] = useState<RoyaltyState>('none')
const [royaltyDetailsImported, setRoyaltyDetailsImported] = useState(false)
const royaltyPaymentAddressState = useInputState({
id: 'royalty-payment-address',
@ -40,26 +42,38 @@ export const RoyaltyDetails = ({ onChange }: RoyaltyDetailsProps) => {
})
useEffect(() => {
void resolveAddress(
royaltyPaymentAddressState.value
.toLowerCase()
.replace(/,/g, '')
.replace(/"/g, '')
.replace(/'/g, '')
.replace(/ /g, ''),
wallet,
).then((royaltyPaymentAddress) => {
royaltyPaymentAddressState.onChange(royaltyPaymentAddress)
const data: RoyaltyDetailsDataProps = {
royaltyType: royaltyState,
paymentAddress: royaltyPaymentAddressState.value,
share: Number(royaltyShareState.value),
}
onChange(data)
})
if (!importedRoyaltyDetails || (importedRoyaltyDetails && royaltyDetailsImported)) {
void resolveAddress(
royaltyPaymentAddressState.value
.toLowerCase()
.replace(/,/g, '')
.replace(/"/g, '')
.replace(/'/g, '')
.replace(/ /g, ''),
wallet,
).then((royaltyPaymentAddress) => {
royaltyPaymentAddressState.onChange(royaltyPaymentAddress)
const data: RoyaltyDetailsDataProps = {
royaltyType: royaltyState,
paymentAddress: royaltyPaymentAddressState.value,
share: Number(royaltyShareState.value),
}
onChange(data)
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [royaltyState, royaltyPaymentAddressState.value, royaltyShareState.value])
useEffect(() => {
if (importedRoyaltyDetails) {
setRoyaltyState(importedRoyaltyDetails.royaltyType)
royaltyPaymentAddressState.onChange(importedRoyaltyDetails.paymentAddress.toString())
royaltyShareState.onChange(importedRoyaltyDetails.share.toString())
setRoyaltyDetailsImported(true)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedRoyaltyDetails])
return (
<div className="py-3 px-8 mx-10 rounded border-2 border-white/20">
<div className="flex justify-center">

214
config/minter.ts Normal file
View File

@ -0,0 +1,214 @@
import {
OPEN_EDITION_FACTORY_ADDRESS,
OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS,
OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS,
OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS,
OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS,
OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS,
OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS,
OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS,
VENDING_FACTORY_ADDRESS,
VENDING_FACTORY_FLEX_ADDRESS,
VENDING_FACTORY_UPDATABLE_ADDRESS,
VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS,
VENDING_IBC_ATOM_FACTORY_ADDRESS,
VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS,
VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS,
VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS,
VENDING_IBC_USDC_FACTORY_ADDRESS,
VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS,
VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS,
VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS,
} from 'utils/constants'
import type { TokenInfo } from './token'
import { ibcAtom, ibcFrnz, ibcUsdc, stars } from './token'
export interface MinterInfo {
id: string
factoryAddress: string
supportedToken: TokenInfo
updatable?: boolean
flexible?: boolean
}
export const openEditionStarsMinter: MinterInfo = {
id: 'open-edition-stars-minter',
factoryAddress: OPEN_EDITION_FACTORY_ADDRESS,
supportedToken: stars,
updatable: false,
}
export const openEditionUpdatableStarsMinter: MinterInfo = {
id: 'open-edition-updatable-stars-minter',
factoryAddress: OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS,
supportedToken: stars,
updatable: true,
}
export const openEditionIbcAtomMinter: MinterInfo = {
id: 'open-edition-ibc-atom-minter',
factoryAddress: OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS,
supportedToken: ibcAtom,
updatable: false,
}
export const openEditionUpdatableIbcAtomMinter: MinterInfo = {
id: 'open-edition-updatable-ibc-atom-minter',
factoryAddress: OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS,
supportedToken: ibcAtom,
updatable: true,
}
export const openEditionIbcUsdcMinter: MinterInfo = {
id: 'open-edition-ibc-usdc-minter',
factoryAddress: OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS,
supportedToken: ibcUsdc,
updatable: false,
}
export const openEditionUpdatableIbcUsdcMinter: MinterInfo = {
id: 'open-edition-updatable-ibc-usdc-minter',
factoryAddress: OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS,
supportedToken: ibcUsdc,
updatable: true,
}
export const openEditionIbcFrnzMinter: MinterInfo = {
id: 'open-edition-ibc-frnz-minter',
factoryAddress: OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS,
supportedToken: ibcFrnz,
updatable: false,
}
export const openEditionUpdatableIbcFrnzMinter: MinterInfo = {
id: 'open-edition-updatable-ibc-frnz-minter',
factoryAddress: OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS,
supportedToken: ibcFrnz,
updatable: true,
}
export const openEditionMinterList = [
openEditionStarsMinter,
openEditionUpdatableStarsMinter,
openEditionUpdatableIbcAtomMinter,
openEditionIbcAtomMinter,
openEditionIbcFrnzMinter,
openEditionUpdatableIbcFrnzMinter,
openEditionIbcUsdcMinter,
openEditionUpdatableIbcUsdcMinter,
]
export const vendingStarsMinter: MinterInfo = {
id: 'vending-stars-minter',
factoryAddress: VENDING_FACTORY_ADDRESS,
supportedToken: stars,
updatable: false,
flexible: false,
}
export const vendingUpdatableStarsMinter: MinterInfo = {
id: 'vending-updatable-stars-minter',
factoryAddress: VENDING_FACTORY_UPDATABLE_ADDRESS,
supportedToken: stars,
updatable: true,
flexible: false,
}
export const vendingIbcAtomMinter: MinterInfo = {
id: 'vending-ibc-atom-minter',
factoryAddress: VENDING_IBC_ATOM_FACTORY_ADDRESS,
supportedToken: ibcAtom,
updatable: false,
flexible: false,
}
export const vendingUpdatableIbcAtomMinter: MinterInfo = {
id: 'vending-updatable-ibc-atom-minter',
factoryAddress: VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS,
supportedToken: ibcAtom,
updatable: true,
flexible: false,
}
export const vendingIbcUsdcMinter: MinterInfo = {
id: 'vending-ibc-usdc-minter',
factoryAddress: VENDING_IBC_USDC_FACTORY_ADDRESS,
supportedToken: ibcUsdc,
updatable: false,
flexible: false,
}
export const vendingUpdatableIbcUsdcMinter: MinterInfo = {
id: 'vending-updatable-ibc-usdc-minter',
factoryAddress: VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS,
supportedToken: ibcUsdc,
updatable: true,
flexible: false,
}
export const vendingMinterList = [
vendingStarsMinter,
vendingUpdatableStarsMinter,
vendingIbcAtomMinter,
vendingUpdatableIbcAtomMinter,
vendingIbcUsdcMinter,
vendingUpdatableIbcUsdcMinter,
]
export const flexibleVendingStarsMinter: MinterInfo = {
id: 'flexible-vending-stars-minter',
factoryAddress: VENDING_FACTORY_FLEX_ADDRESS,
supportedToken: stars,
updatable: false,
flexible: true,
}
export const flexibleVendingUpdatableStarsMinter: MinterInfo = {
id: 'flexible-vending-updatable-stars-minter',
factoryAddress: VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS,
supportedToken: stars,
updatable: true,
flexible: true,
}
export const flexibleVendingIbcAtomMinter: MinterInfo = {
id: 'flexible-vending-ibc-atom-minter',
factoryAddress: VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS,
supportedToken: ibcAtom,
updatable: false,
flexible: true,
}
export const flexibleVendingUpdatableIbcAtomMinter: MinterInfo = {
id: 'flexible-vending-updatable-ibc-atom-minter',
factoryAddress: VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS,
supportedToken: ibcAtom,
updatable: true,
flexible: true,
}
export const flexibleVendingIbcUsdcMinter: MinterInfo = {
id: 'flexible-vending-ibc-usdc-minter',
factoryAddress: VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS,
supportedToken: ibcUsdc,
updatable: false,
flexible: true,
}
export const flexibleVendingUpdatableIbcUsdcMinter: MinterInfo = {
id: 'flexible-vending-updatable-ibc-usdc-minter',
factoryAddress: VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS,
supportedToken: ibcUsdc,
updatable: true,
flexible: true,
}
export const flexibleVendingMinterList = [
flexibleVendingStarsMinter,
flexibleVendingUpdatableStarsMinter,
flexibleVendingIbcAtomMinter,
flexibleVendingUpdatableIbcAtomMinter,
flexibleVendingIbcUsdcMinter,
flexibleVendingUpdatableIbcUsdcMinter,
]

46
config/token.ts Normal file
View File

@ -0,0 +1,46 @@
import { NETWORK } from 'utils/constants'
export interface TokenInfo {
id: string
denom: string
displayName: string
decimalPlaces: number
imageURL?: string
symbol?: string
}
export const stars: TokenInfo = {
id: 'stars',
denom: 'ustars',
displayName: 'STARS',
decimalPlaces: 6,
}
export const ibcAtom: TokenInfo = {
id: 'ibc-atom',
denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
displayName: 'ATOM',
decimalPlaces: 6,
}
export const ibcUsdc: TokenInfo = {
id: 'ibc-usdc',
denom:
NETWORK === 'mainnet'
? 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858'
: 'factory/stars1s8qx0zvz8yd6e4x0mqmqf7fr9vvfn622wtp3g3/uusdc',
displayName: 'USDC',
decimalPlaces: 6,
}
export const ibcFrnz: TokenInfo = {
id: 'ibc-frnz',
denom:
NETWORK === 'mainnet'
? 'ibc/7FA7EC64490E3BDE5A1A28CBE73CC0AD22522794957BC891C46321E3A6074DB9'
: 'factory/stars10w5eulj60qp3cfqa0hkmke78qdy2feq6x9xdmd/ufrnz',
displayName: 'FRNZ',
decimalPlaces: 6,
}
export const tokensList = [stars, ibcAtom, ibcUsdc, ibcFrnz]

View File

@ -3,7 +3,6 @@
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import type { Coin } from '@cosmjs/proto-signing'
import type { logs } from '@cosmjs/stargate'
import { OPEN_EDITION_FACTORY_ADDRESS, OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS } from 'utils/constants'
export interface CreateOpenEditionMinterResponse {
readonly openEditionMinterAddress: string
@ -23,6 +22,7 @@ export interface OpenEditionFactoryInstance {
msg: Record<string, unknown>,
funds: Coin[],
updatable?: boolean,
selectedFactoryAddress?: string,
) => Promise<CreateOpenEditionMinterResponse>
}
@ -56,16 +56,9 @@ export const openEditionFactory = (client: SigningCosmWasmClient, txSigner: stri
senderAddress: string,
msg: Record<string, unknown>,
funds: Coin[],
updatable?: boolean,
): Promise<CreateOpenEditionMinterResponse> => {
const result = await client.execute(
senderAddress,
updatable ? OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS : OPEN_EDITION_FACTORY_ADDRESS,
msg,
'auto',
'',
funds,
)
console.log('Contract Address: ', contractAddress)
const result = await client.execute(senderAddress, contractAddress, msg, 'auto', '', funds)
return {
openEditionMinterAddress: result.logs[0].events[5].attributes[0].value,

View File

@ -356,9 +356,10 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
console.log(factoryParameters?.params?.extension?.airdrop_mint_fee_bps)
const price = factoryParameters?.params?.extension?.airdrop_mint_price.amount
const denom = factoryParameters?.params?.extension?.airdrop_mint_price.denom || 'ustars'
if (!price) {
throw new Error(
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to an Open Edition Factory.',
)
}
const airdropFee = Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)
@ -370,7 +371,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
},
'auto',
'',
airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
airdropFee > 0 ? [coin(airdropFee / 100 / 100, denom as string)] : [],
)
return res.transactionHash
})
@ -386,6 +387,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
})
const price = factoryParameters?.params?.extension?.airdrop_mint_price.amount
const denom = factoryParameters?.params?.extension?.airdrop_mint_price.denom || 'ustars'
if (!price) {
throw new Error(
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
@ -403,7 +405,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
sender: senderAddress,
contract: contractAddress,
msg: toUtf8(JSON.stringify(msg)),
funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, denom as string)] : [],
}),
}
@ -426,6 +428,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
})
const price = factoryParameters?.params?.extension?.airdrop_mint_price.amount
const denom = factoryParameters?.params?.extension?.airdrop_mint_price.denom || 'ustars'
if (!price) {
throw new Error(
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
@ -443,7 +446,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
sender: senderAddress,
contract: contractAddress,
msg: toUtf8(JSON.stringify(msg)),
funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, denom as string)] : [],
}),
}

View File

@ -719,7 +719,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con
},
'auto',
'',
[coin('500000000', 'ustars')],
[coin('2000000000', 'ustars')],
)
return res.transactionHash
}
@ -1018,7 +1018,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con
msg: {
enable_updatable: {},
},
funds: [coin('500000000', 'ustars')],
funds: [coin('2000000000', 'ustars')],
}
}

View File

@ -1,11 +1,8 @@
/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable no-nested-ternary */
import type { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'
import type { Coin } from '@cosmjs/proto-signing'
import type { logs } from '@cosmjs/stargate'
import { VENDING_FACTORY_ADDRESS, VENDING_FACTORY_FLEX_ADDRESS } from 'utils/constants'
import { VENDING_FACTORY_UPDATABLE_ADDRESS } from '../../utils/constants'
export interface CreateVendingMinterResponse {
readonly vendingMinterAddress: string
@ -63,14 +60,7 @@ export const vendingFactory = (client: SigningCosmWasmClient, txSigner: string):
updatable?: boolean,
flex?: boolean,
): Promise<CreateVendingMinterResponse> => {
const result = await client.execute(
senderAddress,
flex ? VENDING_FACTORY_FLEX_ADDRESS : updatable ? VENDING_FACTORY_UPDATABLE_ADDRESS : VENDING_FACTORY_ADDRESS,
msg,
'auto',
'',
funds,
)
const result = await client.execute(senderAddress, contractAddress, msg, 'auto', '', funds)
return {
vendingMinterAddress: result.logs[0].events[5].attributes[0].value,

21
env.d.ts vendored
View File

@ -23,11 +23,26 @@ declare namespace NodeJS {
readonly NEXT_PUBLIC_VENDING_MINTER_CODE_ID: string
readonly NEXT_PUBLIC_VENDING_MINTER_FLEX_CODE_ID: string
readonly NEXT_PUBLIC_VENDING_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID: string
readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_OPEN_EDITION_MINTER_CODE_ID: string
readonly NEXT_PUBLIC_BASE_FACTORY_ADDRESS: string
readonly NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS: string
readonly NEXT_PUBLIC_SG721_NAME_ADDRESS: string

View File

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

View File

@ -41,6 +41,7 @@ import * as secp256k1 from 'secp256k1'
import { upload } from 'services/upload'
import { copy } from 'utils/clipboard'
import { BADGE_HUB_ADDRESS, BLOCK_EXPLORER_URL, NETWORK } from 'utils/constants'
import { getAssetType } from 'utils/getAssetType'
import { withMetadata } from 'utils/layout'
import { links } from 'utils/links'
import { uid } from 'utils/random'
@ -184,7 +185,6 @@ const BadgeCreationPage: NextPage = () => {
if (!badgeHubContract) throw new Error('Contract not found')
setCreatingBadge(true)
const coverUrl = await handleImageUrl()
const badge = {
manager: badgeDetails?.manager as string,
metadata: {
@ -195,7 +195,11 @@ const BadgeCreationPage: NextPage = () => {
external_url: badgeDetails?.external_url || undefined,
attributes: badgeDetails?.attributes || undefined,
background_color: badgeDetails?.background_color || undefined,
animation_url: badgeDetails?.animation_url || undefined,
animation_url: badgeDetails?.animation_url
? badgeDetails.animation_url
: imageUploadDetails?.assetFile && getAssetType(imageUploadDetails.assetFile.name) === 'video'
? coverUrl
: undefined,
youtube_url: badgeDetails?.youtube_url || undefined,
},
transferrable: badgeDetails?.transferrable as boolean,

View File

@ -30,9 +30,12 @@ import type { RoyaltyDetailsDataProps } from 'components/collections/creation/Ro
import type { UploadDetailsDataProps } from 'components/collections/creation/UploadDetails'
import type { WhitelistDetailsDataProps } from 'components/collections/creation/WhitelistDetails'
import { Conditional } from 'components/Conditional'
import { FormControl } from 'components/FormControl'
import { LoadingModal } from 'components/LoadingModal'
import type { OpenEditionMinterCreatorDataProps } from 'components/openEdition/OpenEditionMinterCreator'
import { OpenEditionMinterCreator } from 'components/openEdition/OpenEditionMinterCreator'
import { flexibleVendingMinterList, openEditionMinterList, vendingMinterList } from 'config/minter'
import type { TokenInfo } from 'config/token'
import { useContracts } from 'contexts/contracts'
import { addLogItem } from 'contexts/log'
import { useWallet } from 'contexts/wallet'
@ -42,6 +45,7 @@ import type { DispatchExecuteArgs as VendingFactoryDispatchExecuteArgs } from 'c
import { dispatchExecute as vendingFactoryDispatchExecute } from 'contracts/vendingFactory/messages/execute'
import type { NextPage } from 'next'
import { NextSeo } from 'next-seo'
import type { ChangeEvent } from 'react'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'react-hot-toast'
import { upload } from 'services/upload'
@ -71,6 +75,8 @@ import { uid } from 'utils/random'
import type { MinterType } from '../../components/collections/actions/Combobox'
import type { UploadMethod } from '../../components/collections/creation/UploadDetails'
import { ConfirmationModal } from '../../components/ConfirmationModal'
import type { OpenEditionMinterDetailsDataProps } from '../../components/openEdition/OpenEditionMinterCreator'
import { stars, tokensList } from '../../config/token'
import { getAssetType } from '../../utils/getAssetType'
import { isValidAddress } from '../../utils/isValidAddress'
@ -86,20 +92,23 @@ const CollectionCreationPage: NextPage = () => {
const scrollRef = useRef<HTMLDivElement>(null)
const sidetabRef = useRef<any>(null)
const vendingFactoryMessages = useMemo(
() => vendingFactoryContract?.use(VENDING_FACTORY_ADDRESS),
[vendingFactoryContract, wallet.address],
)
const baseFactoryMessages = useMemo(
() => baseFactoryContract?.use(BASE_FACTORY_ADDRESS),
[baseFactoryContract, wallet.address],
)
const [importedDetails, setImportedDetails] = useState<{
minterType: MinterType
collectionDetails: CollectionDetailsDataProps
uploadDetails: UploadDetailsDataProps
mintingDetails: MintingDetailsDataProps
whitelistDetails: WhitelistDetailsDataProps
royaltyDetails: RoyaltyDetailsDataProps
baseMinterDetails: BaseMinterDetailsDataProps
openEditionMinterDetails: OpenEditionMinterDetailsDataProps
}>()
const [uploadDetails, setUploadDetails] = useState<UploadDetailsDataProps | null>(null)
const [collectionDetails, setCollectionDetails] = useState<CollectionDetailsDataProps | null>(null)
const [baseMinterDetails, setBaseMinterDetails] = useState<BaseMinterDetailsDataProps | null>(null)
const [openEditionMinterDetails, setOpenEditionMinterDetails] = useState<OpenEditionMinterCreatorDataProps | null>(
const [openEditionMinterCreatorData, setOpenEditionMinterCreatorData] =
useState<OpenEditionMinterCreatorDataProps | null>(null)
const [openEditionMinterDetails, setOpenEditionMinterDetails] = useState<OpenEditionMinterDetailsDataProps | null>(
null,
)
const [mintingDetails, setMintingDetails] = useState<MintingDetailsDataProps | null>(null)
@ -122,8 +131,23 @@ const CollectionCreationPage: NextPage = () => {
const [minimumOpenEditionUpdatableMintPrice, setMinimumOpenEditionUpdatableMintPrice] = useState<string | null>('0')
const [minimumFlexMintPrice, setMinimumFlexMintPrice] = useState<string | null>('0')
const [mintTokenFromOpenEditionFactory, setMintTokenFromOpenEditionFactory] = useState<TokenInfo | undefined>(stars)
const [mintTokenFromVendingFactory, setMintTokenFromVendingFactory] = useState<TokenInfo | undefined>(stars)
const [vendingFactoryAddress, setVendingFactoryAddress] = useState<string | null>(VENDING_FACTORY_ADDRESS)
const vendingFactoryMessages = useMemo(
() => vendingFactoryContract?.use(vendingFactoryAddress as string),
[vendingFactoryContract, wallet.address, vendingFactoryAddress],
)
const baseFactoryMessages = useMemo(
() => baseFactoryContract?.use(BASE_FACTORY_ADDRESS),
[baseFactoryContract, wallet.address],
)
const [uploading, setUploading] = useState(false)
const [isMintingComplete, setIsMintingComplete] = useState(false)
const [initialParametersFetched, setInitialParametersFetched] = useState(false)
const [creatingCollection, setCreatingCollection] = useState(false)
const [readyToCreateVm, setReadyToCreateVm] = useState(false)
const [readyToCreateBm, setReadyToCreateBm] = useState(false)
@ -484,7 +508,10 @@ const CollectionCreationPage: NextPage = () => {
members: whitelistDetails?.members,
start_time: whitelistDetails?.startTime,
end_time: whitelistDetails?.endTime,
mint_price: coin(String(Number(whitelistDetails?.unitPrice)), 'ustars'),
mint_price: coin(
String(Number(whitelistDetails?.unitPrice)),
mintTokenFromVendingFactory ? mintTokenFromVendingFactory.denom : 'ustars',
),
per_address_limit: whitelistDetails?.perAddressLimit,
member_limit: whitelistDetails?.memberLimit,
admins: whitelistDetails?.admins || [wallet.address],
@ -495,7 +522,10 @@ const CollectionCreationPage: NextPage = () => {
members: whitelistDetails?.members,
start_time: whitelistDetails?.startTime,
end_time: whitelistDetails?.endTime,
mint_price: coin(String(Number(whitelistDetails?.unitPrice)), 'ustars'),
mint_price: coin(
String(Number(whitelistDetails?.unitPrice)),
mintTokenFromVendingFactory ? mintTokenFromVendingFactory.denom : 'ustars',
),
member_limit: whitelistDetails?.memberLimit,
admins: whitelistDetails?.admins || [wallet.address],
admins_mutable: whitelistDetails?.adminsMutable,
@ -532,17 +562,13 @@ const CollectionCreationPage: NextPage = () => {
payment_address: mintingDetails?.paymentAddress ? mintingDetails.paymentAddress : undefined,
mint_price: {
amount: mintingDetails?.unitPrice,
denom: 'ustars',
denom: (mintTokenFromVendingFactory?.denom as string) || 'ustars',
},
per_address_limit: mintingDetails?.perAddressLimit,
whitelist,
},
collection_params: {
code_id: collectionDetails?.updatable
? whitelistDetails?.whitelistType === 'flex'
? SG721_CODE_ID
: SG721_UPDATABLE_CODE_ID
: SG721_CODE_ID,
code_id: collectionDetails?.updatable ? SG721_UPDATABLE_CODE_ID : SG721_CODE_ID,
name: collectionDetails?.name,
symbol: collectionDetails?.symbol,
info: {
@ -563,12 +589,7 @@ const CollectionCreationPage: NextPage = () => {
}
const payload: VendingFactoryDispatchExecuteArgs = {
contract:
whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex'
? VENDING_FACTORY_FLEX_ADDRESS
: collectionDetails?.updatable
? VENDING_FACTORY_UPDATABLE_ADDRESS
: VENDING_FACTORY_ADDRESS,
contract: vendingFactoryAddress as string,
messages: vendingFactoryMessages,
txSigner: wallet.address,
msg,
@ -668,8 +689,6 @@ const CollectionCreationPage: NextPage = () => {
setCreatingCollection(false)
})
} else {
console.log('Here')
console.log(data.baseMinterAddress)
await toast
.promise(
baseMinterContract
@ -735,8 +754,10 @@ const CollectionCreationPage: NextPage = () => {
if (getAssetType(uploadDetails.assetFiles[i].name) !== 'html')
data.image = `ipfs://${assetUri}/${uploadDetails.assetFiles[i].name}`
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
if (data.description) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
}
const metadataFileBlob = new Blob([JSON.stringify(data)], {
type: 'application/json',
})
@ -791,8 +812,10 @@ const CollectionCreationPage: NextPage = () => {
type: 'application/json',
})
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
if (data.description) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
data.description = data.description.replaceAll('\\n', '\n')
}
console.log('Name: ', (uploadDetails.baseMinterMetadataFile as File).name)
const updatedMetadataFile = new File(
[metadataFileBlob],
@ -907,14 +930,24 @@ const CollectionCreationPage: NextPage = () => {
if (mintingDetails.unitPrice === '') throw new Error('Public mint price is required')
if (whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex') {
if (Number(mintingDetails.unitPrice) < Number(minimumFlexMintPrice))
throw new Error(`Invalid unit price: The minimum unit price is ${Number(minimumFlexMintPrice) / 1000000} STARS`)
throw new Error(
`Invalid unit price: The minimum unit price is ${Number(minimumFlexMintPrice) / 1000000} ${
mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS'
}`,
)
} else if (collectionDetails?.updatable) {
if (Number(mintingDetails.unitPrice) < Number(minimumUpdatableMintPrice))
throw new Error(
`Invalid unit price: The minimum unit price is ${Number(minimumUpdatableMintPrice) / 1000000} STARS`,
`Invalid unit price: The minimum unit price is ${Number(minimumUpdatableMintPrice) / 1000000} ${
mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS'
}`,
)
} else if (Number(mintingDetails.unitPrice) < Number(minimumMintPrice))
throw new Error(`Invalid unit price: The minimum unit price is ${Number(minimumMintPrice) / 1000000} STARS`)
throw new Error(
`Invalid unit price: The minimum unit price is ${Number(minimumMintPrice) / 1000000} ${
mintTokenFromVendingFactory ? mintTokenFromVendingFactory.displayName : 'STARS'
}`,
)
if (
!mintingDetails.perAddressLimit ||
mintingDetails.perAddressLimit < 1 ||
@ -1047,7 +1080,7 @@ const CollectionCreationPage: NextPage = () => {
}
}
const fetchFactoryParameters = async () => {
const fetchInitialFactoryParameters = async () => {
const client = wallet.client
if (!client) return
if (BASE_FACTORY_ADDRESS) {
@ -1122,10 +1155,104 @@ const CollectionCreationPage: NextPage = () => {
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
})
setOpenEditionMinterUpdatableCreationFee(openEditionUpdatableFactoryParameters?.params?.creation_fee?.amount)
setMinimumOpenEditionMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount)
setMinimumOpenEditionUpdatableMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount)
}
setInitialParametersFetched(true)
}
const fetchOpenEditionFactoryParameters = useCallback(async () => {
const client = wallet.client
if (!client) return
const factoryForSelectedDenom = openEditionMinterList.find(
(minter) =>
minter.supportedToken === openEditionMinterDetails?.mintingDetails?.selectedMintToken &&
minter.updatable === false,
)
const updatableFactoryForSelectedDenom = openEditionMinterList.find(
(minter) =>
minter.supportedToken === openEditionMinterDetails?.mintingDetails?.selectedMintToken &&
minter.updatable === true,
)
if (factoryForSelectedDenom?.factoryAddress) {
const openEditionFactoryParameters = await client
.queryContractSmart(factoryForSelectedDenom.factoryAddress, { params: {} })
.catch((error) => {
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
})
setOpenEditionMinterCreationFee(openEditionFactoryParameters?.params?.creation_fee?.amount)
if (!openEditionMinterDetails?.collectionDetails?.updatable) {
setMinimumOpenEditionMintPrice(openEditionFactoryParameters?.params?.min_mint_price?.amount)
setMintTokenFromOpenEditionFactory(
tokensList.find((token) => token.denom === openEditionFactoryParameters?.params?.min_mint_price?.denom),
)
}
}
if (updatableFactoryForSelectedDenom?.factoryAddress) {
const openEditionUpdatableFactoryParameters = await client
.queryContractSmart(updatableFactoryForSelectedDenom.factoryAddress, { params: {} })
.catch((error) => {
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
})
setOpenEditionMinterUpdatableCreationFee(openEditionUpdatableFactoryParameters?.params?.creation_fee?.amount)
if (openEditionMinterDetails?.collectionDetails?.updatable) {
setMinimumOpenEditionUpdatableMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount)
setMintTokenFromOpenEditionFactory(
tokensList.find(
(token) => token.denom === openEditionUpdatableFactoryParameters?.params?.min_mint_price?.denom,
),
)
}
}
}, [
openEditionMinterDetails?.mintingDetails?.selectedMintToken,
openEditionMinterDetails?.collectionDetails?.updatable,
wallet.client,
])
const fetchVendingFactoryParameters = useCallback(async () => {
const client = wallet.client
if (!client) return
const vendingFactoryForSelectedDenom = vendingMinterList
.concat(flexibleVendingMinterList)
.find(
(minter) =>
minter.supportedToken === mintingDetails?.selectedMintToken &&
minter.updatable === collectionDetails?.updatable &&
minter.flexible === (whitelistDetails?.whitelistType === 'flex'),
)?.factoryAddress
if (vendingFactoryForSelectedDenom) {
setVendingFactoryAddress(vendingFactoryForSelectedDenom)
const vendingFactoryParameters = await client
.queryContractSmart(vendingFactoryForSelectedDenom, { params: {} })
.catch((error) => {
toast.error(`${error.message}`, { style: { maxWidth: 'none' } })
addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() })
})
if (whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex') {
setVendingMinterFlexCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount)
setMinimumFlexMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount)
} else if (collectionDetails?.updatable) {
setVendingMinterUpdatableCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount)
setMinimumUpdatableMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount)
} else {
setVendingMinterCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount)
setMinimumMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount)
}
setMintTokenFromVendingFactory(
tokensList.find((token) => token.denom === vendingFactoryParameters?.params?.min_mint_price?.denom),
)
}
}, [
collectionDetails?.updatable,
mintingDetails?.selectedMintToken,
wallet.client,
whitelistDetails?.whitelistState,
whitelistDetails?.whitelistType,
])
const checkwalletBalance = async () => {
const walletBalance = await wallet.client?.getBalance(wallet.address, 'ustars').then((balance) => {
if (minterType === 'vending' && whitelistDetails?.whitelistState === 'new' && whitelistDetails.memberLimit) {
@ -1163,27 +1290,85 @@ const CollectionCreationPage: NextPage = () => {
})
}
const exportDetails = () => {
const details = {
minterType,
collectionDetails,
uploadDetails,
mintingDetails,
whitelistDetails,
royaltyDetails,
baseMinterDetails,
openEditionMinterDetails,
vendingMinterContractAddress,
baseTokenUri: `${baseTokenUri?.startsWith('ipfs://') ? baseTokenUri : `ipfs://${baseTokenUri}`}`,
coverImageUrl:
uploadDetails?.uploadMethod === 'new'
? `ipfs://${coverImageUrl}/${collectionDetails?.imageFile[0]?.name as string}`
: `${coverImageUrl}`,
}
const element = document.createElement('a')
const file = new Blob([JSON.stringify(details)], { type: 'text/plain' })
element.href = URL.createObjectURL(file)
element.download = `${
minterType === 'vending'
? collectionDetails?.name
? `${collectionDetails.name}-`
: ''
: openEditionMinterDetails?.collectionDetails
? `${openEditionMinterDetails.collectionDetails.name}-`
: ''
}configuration-${new Date().toLocaleString().replaceAll(',', '_')}.json`
document.body.appendChild(element) // Required for this to work in FireFox
element.click()
}
const importDetails = (event: ChangeEvent<HTMLInputElement>) => {
if (event.target.files === null || event.target.files.length === 0) return toast.error('No files selected.')
const file = event.target.files[0]
const reader = new FileReader()
reader.onload = (e) => {
const contents = e.target?.result
const details = JSON.parse(contents as string)
setMinterType(details.minterType)
if (details.vendingMinterContractAddress) {
details.uploadDetails.uploadMethod = 'existing'
details.uploadDetails.baseTokenURI = details.baseTokenUri
details.uploadDetails.imageUrl = details.coverImageUrl
}
if (details.openEditionMinterDetails?.openEditionMinterContractAddress) {
details.openEditionMinterDetails.offChainMetadataUploadDetails.uploadMethod = 'existing'
details.openEditionMinterDetails.offChainMetadataUploadDetails.tokenURI =
details.openEditionMinterDetails.tokenUri
details.openEditionMinterDetails.offChainMetadataUploadDetails.imageUrl =
details.openEditionMinterDetails.coverImageUrl
}
setImportedDetails(details)
}
reader.readAsText(file)
}
const syncCollections = useCallback(async () => {
const collectionAddress =
minterType === 'openEdition' ? openEditionMinterDetails?.sg721ContractAddress : sg721ContractAddress
minterType === 'openEdition' ? openEditionMinterCreatorData?.sg721ContractAddress : sg721ContractAddress
if (collectionAddress && SYNC_COLLECTIONS_API_URL) {
await axios.get(`${SYNC_COLLECTIONS_API_URL}/${collectionAddress}`).catch((error) => {
console.error('Sync collections: ', error)
})
}
}, [minterType, openEditionMinterDetails?.sg721ContractAddress, sg721ContractAddress])
}, [minterType, openEditionMinterCreatorData?.sg721ContractAddress, sg721ContractAddress])
useEffect(() => {
if (
vendingMinterContractAddress !== null ||
openEditionMinterDetails?.openEditionMinterContractAddress ||
openEditionMinterCreatorData?.openEditionMinterContractAddress ||
isMintingComplete
) {
scrollRef.current?.scrollIntoView({ behavior: 'smooth' })
}
if (
(minterType === 'vending' && vendingMinterContractAddress !== null) ||
(minterType === 'openEdition' && openEditionMinterDetails?.openEditionMinterContractAddress) ||
(minterType === 'openEdition' && openEditionMinterCreatorData?.openEditionMinterContractAddress) ||
(minterType === 'base' && vendingMinterContractAddress !== null && isMintingComplete)
) {
void syncCollections()
@ -1196,7 +1381,7 @@ const CollectionCreationPage: NextPage = () => {
}
}, [
vendingMinterContractAddress,
openEditionMinterDetails?.openEditionMinterContractAddress,
openEditionMinterCreatorData?.openEditionMinterContractAddress,
isMintingComplete,
minterType,
syncCollections,
@ -1214,9 +1399,19 @@ const CollectionCreationPage: NextPage = () => {
}, [minterType, baseMinterDetails?.baseMinterAcquisitionMethod, uploadDetails?.uploadMethod])
useEffect(() => {
void fetchFactoryParameters()
if (!initialParametersFetched) {
void fetchInitialFactoryParameters()
}
}, [wallet.client])
useEffect(() => {
void fetchOpenEditionFactoryParameters()
}, [fetchOpenEditionFactoryParameters])
useEffect(() => {
void fetchVendingFactoryParameters()
}, [fetchVendingFactoryParameters])
return (
<div>
<NextSeo
@ -1246,9 +1441,10 @@ const CollectionCreationPage: NextPage = () => {
on how to create your collection
</p>
</div>
<div className="mx-10" ref={scrollRef}>
<Conditional
test={minterType === 'openEdition' && openEditionMinterDetails?.openEditionMinterContractAddress !== null}
test={minterType === 'openEdition' && openEditionMinterCreatorData?.openEditionMinterContractAddress !== null}
>
<Alert className="mt-5" type="info">
<div>
@ -1257,10 +1453,10 @@ const CollectionCreationPage: NextPage = () => {
className="text-stargaze hover:underline"
external
href={`/contracts/openEditionMinter/query/?contractAddress=${
openEditionMinterDetails?.openEditionMinterContractAddress as string
openEditionMinterCreatorData?.openEditionMinterContractAddress as string
}`}
>
{openEditionMinterDetails?.openEditionMinterContractAddress as string}
{openEditionMinterCreatorData?.openEditionMinterContractAddress as string}
</Anchor>
<br />
SG721 Contract Address:{' '}
@ -1268,10 +1464,10 @@ const CollectionCreationPage: NextPage = () => {
className="text-stargaze hover:underline"
external
href={`/contracts/sg721/query/?contractAddress=${
openEditionMinterDetails?.sg721ContractAddress as string
openEditionMinterCreatorData?.sg721ContractAddress as string
}`}
>
{openEditionMinterDetails?.sg721ContractAddress as string}
{openEditionMinterCreatorData?.sg721ContractAddress as string}
</Anchor>
<br />
Transaction Hash: {' '}
@ -1279,18 +1475,18 @@ const CollectionCreationPage: NextPage = () => {
<Anchor
className="text-stargaze hover:underline"
external
href={`${BLOCK_EXPLORER_URL}/tx/${openEditionMinterDetails?.transactionHash as string}`}
href={`${BLOCK_EXPLORER_URL}/tx/${openEditionMinterCreatorData?.transactionHash as string}`}
>
{openEditionMinterDetails?.transactionHash}
{openEditionMinterCreatorData?.transactionHash}
</Anchor>
</Conditional>
<Conditional test={NETWORK === 'mainnet'}>
<Anchor
className="text-stargaze hover:underline"
external
href={`${BLOCK_EXPLORER_URL}/txs/${openEditionMinterDetails?.transactionHash as string}`}
href={`${BLOCK_EXPLORER_URL}/txs/${openEditionMinterCreatorData?.transactionHash as string}`}
>
{openEditionMinterDetails?.transactionHash}
{openEditionMinterCreatorData?.transactionHash}
</Anchor>
</Conditional>
<br />
@ -1299,7 +1495,7 @@ const CollectionCreationPage: NextPage = () => {
className="text-white"
external
href={`${STARGAZE_URL}/launchpad/${
openEditionMinterDetails?.openEditionMinterContractAddress as string
openEditionMinterCreatorData?.openEditionMinterContractAddress as string
}`}
>
View on Launchpad
@ -1484,7 +1680,8 @@ const CollectionCreationPage: NextPage = () => {
className={clsx(
'mx-10 mt-5',
'grid before:absolute relative grid-cols-3 grid-flow-col items-stretch rounded',
'before:inset-x-0 before:bottom-0 before:border-white/25',
'before:inset-x-0 before:bottom-0 before:border-white/25',
minterType !== 'base' ? 'rounded-none border-b-2 border-white/25' : 'border-0',
)}
>
<div
@ -1558,6 +1755,22 @@ const CollectionCreationPage: NextPage = () => {
</div>
</div>
<Conditional test={minterType !== 'base'}>
<FormControl className={clsx('py-4 px-10 w-full')} title="Import Creation Configuration">
<div className="flex flex-row justify-between mt-5 space-x-2">
<input
accept="application/json"
className="py-4 px-4 w-1/3 rounded-sm border-[1px] border-zinc-500 border-dashed"
onChange={(e) => importDetails(e)}
type="file"
/>
<Button className="mt-3 h-1/2 w-1/8" onClick={() => exportDetails()}>
Export Creation Configuration
</Button>
</div>
</FormControl>
</Conditional>
{minterType === 'base' && (
<div>
<BaseMinterDetails minterType={minterType} onChange={setBaseMinterDetails} />
@ -1565,10 +1778,13 @@ const CollectionCreationPage: NextPage = () => {
)}
<Conditional test={minterType === 'openEdition'}>
<OpenEditionMinterCreator
importedOpenEditionMinterDetails={importedDetails?.openEditionMinterDetails}
minimumMintPrice={minimumOpenEditionMintPrice as string}
minimumUpdatableMintPrice={minimumOpenEditionUpdatableMintPrice as string}
mintTokenFromFactory={mintTokenFromOpenEditionFactory}
minterType={minterType}
onChange={setOpenEditionMinterDetails}
onChange={setOpenEditionMinterCreatorData}
onDetailsChange={setOpenEditionMinterDetails}
openEditionMinterCreationFee={openEditionMinterCreationFee as string}
openEditionMinterUpdatableCreationFee={openEditionMinterUpdatableCreationFee as string}
/>
@ -1577,6 +1793,7 @@ const CollectionCreationPage: NextPage = () => {
<Conditional test={minterType === 'vending' || minterType === 'base'}>
<UploadDetails
baseMinterAcquisitionMethod={baseMinterDetails?.baseMinterAcquisitionMethod}
importedUploadDetails={importedDetails?.uploadDetails}
minterType={minterType}
onChange={setUploadDetails}
/>
@ -1597,6 +1814,7 @@ const CollectionCreationPage: NextPage = () => {
>
<CollectionDetails
coverImageUrl={coverImageUrl as string}
importedCollectionDetails={importedDetails?.collectionDetails}
minterType={minterType}
onChange={setCollectionDetails}
uploadMethod={uploadDetails?.uploadMethod as UploadMethod}
@ -1604,11 +1822,15 @@ const CollectionCreationPage: NextPage = () => {
</Conditional>
<Conditional test={minterType === 'vending'}>
<MintingDetails
importedMintingDetails={importedDetails?.mintingDetails}
minimumMintPrice={
collectionDetails?.updatable
whitelistDetails?.whitelistState !== 'none' && whitelistDetails?.whitelistType === 'flex'
? Number(minimumFlexMintPrice) / 1000000
: collectionDetails?.updatable
? Number(minimumUpdatableMintPrice) / 1000000
: Number(minimumMintPrice) / 1000000
}
mintingTokenFromFactory={mintTokenFromVendingFactory}
numberOfTokens={uploadDetails?.assetFiles.length}
onChange={setMintingDetails}
uploadMethod={uploadDetails?.uploadMethod as UploadMethod}
@ -1637,10 +1859,14 @@ const CollectionCreationPage: NextPage = () => {
>
<div className="my-6">
<Conditional test={minterType === 'vending'}>
<WhitelistDetails onChange={setWhitelistDetails} />
<WhitelistDetails
importedWhitelistDetails={importedDetails?.whitelistDetails}
mintingTokenFromFactory={mintTokenFromVendingFactory}
onChange={setWhitelistDetails}
/>
<div className="my-6" />
</Conditional>
<RoyaltyDetails onChange={setRoyaltyDetails} />
<RoyaltyDetails importedRoyaltyDetails={importedDetails?.royaltyDetails} onChange={setRoyaltyDetails} />
</div>
</Conditional>
<Conditional test={readyToCreateVm && minterType === 'vending'}>

View File

@ -12,10 +12,32 @@ export const VENDING_MINTER_FLEX_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VEND
export const VENDING_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_ADDRESS
export const VENDING_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS
export const VENDING_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS
export const VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS
export const VENDING_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS
export const VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS =
process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_ADDRESS
export const VENDING_IBC_USDC_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_ADDRESS
export const VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS =
process.env.NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_ADDRESS
export const VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_FLEX_ADDRESS
export const VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS =
process.env.NEXT_PUBLIC_VENDING_IBC_ATOM_UPDATABLE_FACTORY_FLEX_ADDRESS
export const VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS = process.env.NEXT_PUBLIC_VENDING_IBC_USDC_FACTORY_FLEX_ADDRESS
export const VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS =
process.env.NEXT_PUBLIC_VENDING_IBC_USDC_UPDATABLE_FACTORY_FLEX_ADDRESS
export const BASE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_ADDRESS
export const BASE_FACTORY_UPDATABLE_ADDRESS = process.env.NEXT_PUBLIC_BASE_FACTORY_UPDATABLE_ADDRESS
export const OPEN_EDITION_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_FACTORY_ADDRESS
export const OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS
export const OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_ATOM_FACTORY_ADDRESS
export const OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS =
process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_ATOM_FACTORY_ADDRESS
export const OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_USDC_FACTORY_ADDRESS
export const OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS =
process.env.NEXT_PUBLIC_OPEN_EDITION_UPDATABLE_IBC_USDC_FACTORY_ADDRESS
export const OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS = process.env.NEXT_PUBLIC_OPEN_EDITION_IBC_FRNZ_FACTORY_ADDRESS
export const OPEN_EDITION_UPDATABLE_IBC_FRNZ_FACTORY_ADDRESS =
process.env.NEXT_PUBLIC_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 SG721_NAME_ADDRESS = process.env.NEXT_PUBLIC_SG721_NAME_ADDRESS
export const BASE_MINTER_CODE_ID = parseInt(process.env.NEXT_PUBLIC_VENDING_MINTER_CODE_ID, 10)