Merge pull request #146 from public-awesome/develop

Sync development > main
This commit is contained in:
Serkan Reis 2023-04-05 17:22:08 +03:00 committed by GitHub
commit c1da34dacb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 18 deletions

View File

@ -1,4 +1,4 @@
APP_VERSION=0.5.6 APP_VERSION=0.5.7
NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS
NEXT_PUBLIC_SG721_CODE_ID=1911 NEXT_PUBLIC_SG721_CODE_ID=1911

View File

@ -1,3 +1,4 @@
import { toUtf8 } from '@cosmjs/encoding'
import { AirdropUpload } from 'components/AirdropUpload' import { AirdropUpload } from 'components/AirdropUpload'
import { Button } from 'components/Button' import { Button } from 'components/Button'
import type { DispatchExecuteArgs } from 'components/collections/actions/actions' import type { DispatchExecuteArgs } from 'components/collections/actions/actions'
@ -347,6 +348,30 @@ export const CollectionActions = ({
throw new Error('Royalty payment address and share percentage are both required') throw new Error('Royalty payment address and share percentage are both required')
} }
if (
type === 'update_collection_info' &&
royaltyPaymentAddressState.value &&
!royaltyPaymentAddressState.value.trim().endsWith('.stars')
) {
const contractInfoResponse = await wallet.client
?.queryContractRaw(
royaltyPaymentAddressState.value.trim(),
toUtf8(Buffer.from(Buffer.from('contract_info').toString('hex'), 'hex').toString()),
)
.catch((e) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (e.message.includes('bech32')) throw new Error('Invalid royalty payment address.')
console.log(e.message)
})
if (contractInfoResponse !== undefined) {
const contractInfo = JSON.parse(new TextDecoder().decode(contractInfoResponse as Uint8Array))
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (contractInfo && !contractInfo.contract.includes('splits'))
throw new Error('The provided royalty payment address does not belong to a splits contract.')
else console.log(contractInfo)
}
}
const txHash = await toast.promise(dispatchExecute(payload), { const txHash = await toast.promise(dispatchExecute(payload), {
error: `${type.charAt(0).toUpperCase() + type.slice(1)} execute failed!`, error: `${type.charAt(0).toUpperCase() + type.slice(1)} execute failed!`,
loading: 'Executing message...', loading: 'Executing message...',

View File

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

View File

@ -5,6 +5,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { toUtf8 } from '@cosmjs/encoding'
import { coin } from '@cosmjs/proto-signing' import { coin } from '@cosmjs/proto-signing'
import clsx from 'clsx' import clsx from 'clsx'
import { Alert } from 'components/Alert' import { Alert } from 'components/Alert'
@ -113,7 +114,8 @@ const CollectionCreationPage: NextPage = () => {
checkUploadDetails() checkUploadDetails()
checkCollectionDetails() checkCollectionDetails()
checkMintingDetails() checkMintingDetails()
checkRoyaltyDetails() void checkRoyaltyDetails()
.then(() => {
checkWhitelistDetails() checkWhitelistDetails()
.then(() => { .then(() => {
checkwalletBalance() checkwalletBalance()
@ -125,6 +127,11 @@ const CollectionCreationPage: NextPage = () => {
else toast.error(`Error in Whitelist Configuration: ${err.message}`, { style: { maxWidth: 'none' } }) else toast.error(`Error in Whitelist Configuration: ${err.message}`, { style: { maxWidth: 'none' } })
setReadyToCreateVm(false) setReadyToCreateVm(false)
}) })
})
.catch((err) => {
toast.error(`Error in Royalty Details: ${err.message}`, { style: { maxWidth: 'none' } })
setReadyToCreateVm(false)
})
} catch (error: any) { } catch (error: any) {
toast.error(error.message, { style: { maxWidth: 'none' } }) toast.error(error.message, { style: { maxWidth: 'none' } })
setUploading(false) setUploading(false)
@ -136,8 +143,9 @@ const CollectionCreationPage: NextPage = () => {
try { try {
setReadyToCreateBm(false) setReadyToCreateBm(false)
checkUploadDetails() checkUploadDetails()
checkRoyaltyDetails()
checkCollectionDetails() checkCollectionDetails()
void checkRoyaltyDetails()
.then(() => {
checkWhitelistDetails() checkWhitelistDetails()
.then(() => { .then(() => {
checkwalletBalance() checkwalletBalance()
@ -147,6 +155,11 @@ const CollectionCreationPage: NextPage = () => {
toast.error(`${err.message}`, { style: { maxWidth: 'none' } }) toast.error(`${err.message}`, { style: { maxWidth: 'none' } })
setReadyToCreateBm(false) setReadyToCreateBm(false)
}) })
})
.catch((err) => {
toast.error(`Error in Royalty Configuration: ${err.message}`, { style: { maxWidth: 'none' } })
setReadyToCreateBm(false)
})
} catch (error: any) { } catch (error: any) {
toast.error(error.message, { style: { maxWidth: 'none' } }) toast.error(error.message, { style: { maxWidth: 'none' } })
setUploading(false) setUploading(false)
@ -414,7 +427,7 @@ const CollectionCreationPage: NextPage = () => {
let royaltyInfo = null let royaltyInfo = null
if (royaltyDetails?.royaltyType === 'new') { if (royaltyDetails?.royaltyType === 'new') {
royaltyInfo = { royaltyInfo = {
payment_address: royaltyDetails.paymentAddress, payment_address: royaltyDetails.paymentAddress.trim(),
share: (Number(royaltyDetails.share) / 100).toString(), share: (Number(royaltyDetails.share) / 100).toString(),
} }
} }
@ -483,7 +496,7 @@ const CollectionCreationPage: NextPage = () => {
let royaltyInfo = null let royaltyInfo = null
if (royaltyDetails?.royaltyType === 'new') { if (royaltyDetails?.royaltyType === 'new') {
royaltyInfo = { royaltyInfo = {
payment_address: royaltyDetails.paymentAddress, payment_address: royaltyDetails.paymentAddress.trim(),
share: (Number(royaltyDetails.share) / 100).toString(), share: (Number(royaltyDetails.share) / 100).toString(),
} }
} }
@ -868,18 +881,35 @@ const CollectionCreationPage: NextPage = () => {
} }
} }
const checkRoyaltyDetails = () => { const checkRoyaltyDetails = async () => {
if (!royaltyDetails) throw new Error('Please fill out the royalty details') if (!royaltyDetails) throw new Error('Please fill out the royalty details')
if (royaltyDetails.royaltyType === 'new') { if (royaltyDetails.royaltyType === 'new') {
if (royaltyDetails.share === 0) throw new Error('Royalty share percentage is required') if (royaltyDetails.share === 0) throw new Error('Royalty share percentage is required')
if (royaltyDetails.share > 100 || royaltyDetails.share < 0) throw new Error('Invalid royalty share percentage') if (royaltyDetails.share > 100 || royaltyDetails.share < 0) throw new Error('Invalid royalty share percentage')
if (royaltyDetails.paymentAddress === '') throw new Error('Royalty payment address is required') if (royaltyDetails.paymentAddress === '') throw new Error('Royalty payment address is required')
if (!isValidAddress(royaltyDetails.paymentAddress)) { if (!isValidAddress(royaltyDetails.paymentAddress.trim())) {
if (royaltyDetails.paymentAddress.trim().endsWith('.stars')) { if (royaltyDetails.paymentAddress.trim().endsWith('.stars')) {
throw new Error('Royalty payment address could not be resolved') throw new Error('Royalty payment address could not be resolved')
} }
throw new Error('Invalid royalty payment address') throw new Error('Invalid royalty payment address')
} }
const contractInfoResponse = await wallet.client
?.queryContractRaw(
royaltyDetails.paymentAddress.trim(),
toUtf8(Buffer.from(Buffer.from('contract_info').toString('hex'), 'hex').toString()),
)
.catch((e) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (e.message.includes('bech32')) throw new Error('Invalid royalty payment address.')
console.log(e.message)
})
if (contractInfoResponse !== undefined) {
const contractInfo = JSON.parse(new TextDecoder().decode(contractInfoResponse as Uint8Array))
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
if (contractInfo && !contractInfo.contract.includes('splits'))
throw new Error('The provided royalty payment address does not belong to a splits contract.')
else console.log(contractInfo)
}
} }
} }