Merge pull request #130 from public-awesome/sg721-updatable-switch
Conditionally disable sg721-updatable functionality
This commit is contained in:
commit
ae380dea0d
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
||||||
|
|
||||||
import { useBaseMinterContract } from 'contracts/baseMinter'
|
import { useBaseMinterContract } from 'contracts/baseMinter'
|
||||||
import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
|
import type { CollectionInfo, SG721Instance } from 'contracts/sg721'
|
||||||
import { useSG721Contract } from 'contracts/sg721'
|
import { useSG721Contract } from 'contracts/sg721'
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
|
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
|
import { Conditional } from 'components/Conditional'
|
||||||
import { FormControl } from 'components/FormControl'
|
import { FormControl } from 'components/FormControl'
|
||||||
import { FormGroup } from 'components/FormGroup'
|
import { FormGroup } from 'components/FormGroup'
|
||||||
import { useInputState } from 'components/forms/FormInput.hooks'
|
import { useInputState } from 'components/forms/FormInput.hooks'
|
||||||
@ -12,6 +13,7 @@ import { Tooltip } from 'components/Tooltip'
|
|||||||
import type { ChangeEvent } from 'react'
|
import type { ChangeEvent } from 'react'
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { toast } from 'react-hot-toast'
|
import { toast } from 'react-hot-toast'
|
||||||
|
import { SG721_UPDATABLE_CODE_ID } from 'utils/constants'
|
||||||
|
|
||||||
import { TextInput } from '../../forms/FormInput'
|
import { TextInput } from '../../forms/FormInput'
|
||||||
import type { MinterType } from '../actions/Combobox'
|
import type { MinterType } from '../actions/Combobox'
|
||||||
@ -241,36 +243,38 @@ export const CollectionDetails = ({ onChange, uploadMethod, coverImageUrl, minte
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Tooltip
|
<Conditional test={SG721_UPDATABLE_CODE_ID > 0}>
|
||||||
backgroundColor="bg-blue-500"
|
<Tooltip
|
||||||
label={
|
backgroundColor="bg-blue-500"
|
||||||
<div className="grid grid-flow-row">
|
label={
|
||||||
<span>
|
<div className="grid grid-flow-row">
|
||||||
ℹ️ When enabled, the metadata for tokens can be updated after the collection is created until the
|
<span>
|
||||||
collection is frozen by the creator.
|
ℹ️ When enabled, the metadata for tokens can be updated after the collection is created until the
|
||||||
</span>
|
collection is frozen by the creator.
|
||||||
</div>
|
</span>
|
||||||
}
|
</div>
|
||||||
placement="bottom"
|
}
|
||||||
>
|
placement="bottom"
|
||||||
<div
|
|
||||||
className={clsx(
|
|
||||||
minterType === 'base'
|
|
||||||
? 'flex flex-col -ml-16 space-y-2 w-1/2 form-control'
|
|
||||||
: 'flex flex-col space-y-2 w-3/4 form-control',
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<label className="justify-start cursor-pointer label">
|
<div
|
||||||
<span className="mr-4 font-bold">Updatable Token Metadata</span>
|
className={clsx(
|
||||||
<input
|
minterType === 'base'
|
||||||
checked={updatable}
|
? 'flex flex-col -ml-16 space-y-2 w-1/2 form-control'
|
||||||
className={`toggle ${updatable ? `bg-stargaze` : `bg-gray-600`}`}
|
: 'flex flex-col space-y-2 w-3/4 form-control',
|
||||||
onClick={() => setUpdatable(!updatable)}
|
)}
|
||||||
type="checkbox"
|
>
|
||||||
/>
|
<label className="justify-start cursor-pointer label">
|
||||||
</label>
|
<span className="mr-4 font-bold">Updatable Token Metadata</span>
|
||||||
</div>
|
<input
|
||||||
</Tooltip>
|
checked={updatable}
|
||||||
|
className={`toggle ${updatable ? `bg-stargaze` : `bg-gray-600`}`}
|
||||||
|
onClick={() => setUpdatable(!updatable)}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</Conditional>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -77,7 +77,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti
|
|||||||
unitPrice: unitPriceState.value ? (Number(unitPriceState.value) * 1_000_000).toString() : '',
|
unitPrice: unitPriceState.value ? (Number(unitPriceState.value) * 1_000_000).toString() : '',
|
||||||
perAddressLimit: perAddressLimitState.value,
|
perAddressLimit: perAddressLimitState.value,
|
||||||
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
|
startTime: timestamp ? (timestamp.getTime() * 1_000_000).toString() : '',
|
||||||
paymentAddress: paymentAddressState.value,
|
paymentAddress: paymentAddressState.value.trim(),
|
||||||
}
|
}
|
||||||
onChange(data)
|
onChange(data)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
@ -770,7 +770,10 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
)
|
)
|
||||||
if (mintingDetails.startTime === '') throw new Error('Start time is required')
|
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 (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')
|
throw new Error('Invalid payment address')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user