From 6da52258b2225539236adb7b22ad4c4beeae0ef6 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sat, 18 Mar 2023 16:11:40 +0300 Subject: [PATCH 1/3] Standard collection creation now includes optional payment address input --- .../creation/CollectionDetails.tsx | 11 ++++-- .../collections/creation/MintingDetails.tsx | 38 +++++++++++++++++-- pages/collections/create.tsx | 3 ++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/components/collections/creation/CollectionDetails.tsx b/components/collections/creation/CollectionDetails.tsx index 17a40a2..2dd528a 100644 --- a/components/collections/creation/CollectionDetails.tsx +++ b/components/collections/creation/CollectionDetails.tsx @@ -142,9 +142,9 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
- +
-
+
Does the collection contain explicit content? @@ -240,11 +242,12 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
ℹ️ When enabled, the metadata for tokens can be updated after the collection is created until the - metadata is frozen by the creator. + collection is frozen by the creator.
} diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index 6afc367..8928051 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -1,10 +1,12 @@ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' -import { useNumberInputState } from 'components/forms/FormInput.hooks' +import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' import { InputDateTime } from 'components/InputDateTime' import React, { useEffect, useState } from 'react' +import { resolveAddress } from 'utils/resolveAddress' -import { NumberInput } from '../../forms/FormInput' +import { useWallet } from '../../../contexts/wallet' +import { NumberInput, TextInput } from '../../forms/FormInput' import type { UploadMethod } from './UploadDetails' interface MintingDetailsProps { @@ -18,9 +20,12 @@ export interface MintingDetailsDataProps { unitPrice: string perAddressLimit: number startTime: string + paymentAddress?: string } export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: MintingDetailsProps) => { + const wallet = useWallet() + const [timestamp, setTimestamp] = useState() const numberOfTokensState = useNumberInputState({ @@ -47,6 +52,24 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti placeholder: '1', }) + const paymentAddressState = useInputState({ + id: 'payment-address', + name: 'paymentAddress', + title: 'Payment Address (optional)', + subtitle: 'Address to receive minting revenues (defaults to current wallet address)', + placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...', + }) + + const resolvePaymentAddress = async () => { + await resolveAddress(paymentAddressState.value.trim(), wallet).then((resolvedAddress) => { + paymentAddressState.onChange(resolvedAddress) + }) + } + + useEffect(() => { + void resolvePaymentAddress() + }, [paymentAddressState.value]) + useEffect(() => { if (numberOfTokens) numberOfTokensState.onChange(numberOfTokens) const data: MintingDetailsDataProps = { @@ -54,10 +77,18 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti unitPrice: unitPriceState.value ? (Number(unitPriceState.value) * 1_000_000).toString() : '', perAddressLimit: perAddressLimitState.value, startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '', + paymentAddress: paymentAddressState.value, } onChange(data) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [numberOfTokens, numberOfTokensState.value, unitPriceState.value, perAddressLimitState.value, timestamp]) + }, [ + numberOfTokens, + numberOfTokensState.value, + unitPriceState.value, + perAddressLimitState.value, + timestamp, + paymentAddressState.value, + ]) return (
@@ -74,6 +105,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti setTimestamp(date)} value={timestamp} /> +
) } diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index a9a7993..c09d8d3 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -414,6 +414,7 @@ const CollectionCreationPage: NextPage = () => { base_token_uri: `${uploadDetails?.uploadMethod === 'new' ? `ipfs://${baseUri}` : `${baseUri}`}`, start_time: mintingDetails?.startTime, num_tokens: mintingDetails?.numTokens, + payment_address: mintingDetails?.paymentAddress ? mintingDetails.paymentAddress : undefined, mint_price: { amount: mintingDetails?.unitPrice, denom: 'ustars', @@ -769,6 +770,8 @@ const CollectionCreationPage: NextPage = () => { ) if (mintingDetails.startTime === '') throw new Error('Start time is required') if (Number(mintingDetails.startTime) < new Date().getTime() * 1000000) throw new Error('Invalid start time') + if (mintingDetails.paymentAddress && !isValidAddress(mintingDetails.paymentAddress)) + throw new Error('Invalid payment address') } const checkWhitelistDetails = async () => { From d71bf2147cb86ae42c11f7de5c2252b2195eab4f Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sat, 18 Mar 2023 16:23:24 +0300 Subject: [PATCH 2/3] Update insufficient funds error messages --- pages/collections/create.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index c09d8d3..7f6ca39 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -864,7 +864,11 @@ const CollectionCreationPage: NextPage = () => { Math.ceil(Number(whitelistDetails.memberLimit) / 1000) * 100000000 + (collectionDetails?.updatable ? 5000000000 : 3000000000) if (amountNeeded >= Number(wallet.balance[0].amount)) - throw new Error('Insufficient wallet balance to instantiate the required contracts.') + throw new Error( + `Insufficient wallet balance to instantiate the required contracts. Needed amount: ${( + amountNeeded / 1000000 + ).toString()} STARS`, + ) } else { const amountNeeded = minterType === 'vending' @@ -875,7 +879,11 @@ const CollectionCreationPage: NextPage = () => { ? 3000000000 : 1000000000 if (amountNeeded >= Number(wallet.balance[0].amount)) - throw new Error('Insufficient wallet balance to instantiate the required contracts.') + throw new Error( + `Insufficient wallet balance to instantiate the required contracts. Needed amount: ${( + amountNeeded / 1000000 + ).toString()} STARS`, + ) } } useEffect(() => { From 866039ebe36a2bb96a1928da06ca1efa37360398 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sat, 18 Mar 2023 16:24:18 +0300 Subject: [PATCH 3/3] Bump Studio version --- .env.example | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 6ef4451..d9055f9 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_VERSION=0.5.0 +APP_VERSION=0.5.1 NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS NEXT_PUBLIC_SG721_CODE_ID=1911 diff --git a/package.json b/package.json index 9cfca2b..859b1cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stargaze-studio", - "version": "0.5.0", + "version": "0.5.1", "workspaces": [ "packages/*" ],