Merge pull request #130 from public-awesome/sg721-updatable-switch

Conditionally disable sg721-updatable functionality
This commit is contained in:
Serkan Reis 2023-03-27 15:06:43 +03:00 committed by GitHub
commit ae380dea0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 31 deletions

View File

@ -1,3 +1,5 @@
/* eslint-disable eslint-comments/disable-enable-pair */
import { useBaseMinterContract } from 'contracts/baseMinter'
import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
import { useSG721Contract } from 'contracts/sg721'

View File

@ -4,6 +4,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import clsx from 'clsx'
import { Conditional } from 'components/Conditional'
import { FormControl } from 'components/FormControl'
import { FormGroup } from 'components/FormGroup'
import { useInputState } from 'components/forms/FormInput.hooks'
@ -12,6 +13,7 @@ import { Tooltip } from 'components/Tooltip'
import type { ChangeEvent } from 'react'
import { useEffect, useRef, useState } from 'react'
import { toast } from 'react-hot-toast'
import { SG721_UPDATABLE_CODE_ID } from 'utils/constants'
import { TextInput } from '../../forms/FormInput'
import type { MinterType } from '../actions/Combobox'
@ -241,6 +243,7 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
</div>
</div>
</div>
<Conditional test={SG721_UPDATABLE_CODE_ID > 0}>
<Tooltip
backgroundColor="bg-blue-500"
label={
@ -271,6 +274,7 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
</label>
</div>
</Tooltip>
</Conditional>
</FormGroup>
</div>
)

View File

@ -77,7 +77,7 @@ 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,
paymentAddress: paymentAddressState.value.trim(),
}
onChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps

View File

@ -770,7 +770,10 @@ 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))
if (
mintingDetails.paymentAddress &&
(!isValidAddress(mintingDetails.paymentAddress) || !mintingDetails.paymentAddress.startsWith('stars1'))
)
throw new Error('Invalid payment address')
}