From deb149809e40833ca6e6c2df884abd5713654919 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Thu, 9 Mar 2023 00:01:34 +0300 Subject: [PATCH] Update Whitelist dashboard > Instantiate UI --- pages/contracts/whitelist/instantiate.tsx | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pages/contracts/whitelist/instantiate.tsx b/pages/contracts/whitelist/instantiate.tsx index 1f4bbf9..3dc28aa 100644 --- a/pages/contracts/whitelist/instantiate.tsx +++ b/pages/contracts/whitelist/instantiate.tsx @@ -5,6 +5,8 @@ import { Conditional } from 'components/Conditional' import { ContractPageHeader } from 'components/ContractPageHeader' import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' +import { AddressList } from 'components/forms/AddressList' +import { useAddressListState } from 'components/forms/AddressList.hooks' import { NumberInput } from 'components/forms/FormInput' import { useNumberInputState } from 'components/forms/FormInput.hooks' import { InputDateTime } from 'components/InputDateTime' @@ -21,6 +23,7 @@ import { type FormEvent, useState } from 'react' import { toast } from 'react-hot-toast' import { FaAsterisk } from 'react-icons/fa' import { useMutation } from 'react-query' +import { isValidAddress } from 'utils/isValidAddress' import { withMetadata } from 'utils/layout' import { links } from 'utils/links' @@ -30,6 +33,7 @@ const WhitelistInstantiatePage: NextPage = () => { const [startDate, setStartDate] = useState(undefined) const [endDate, setEndDate] = useState(undefined) + const [adminsMutable, setAdminsMutable] = useState(false) const [whitelistArray, setWhitelistArray] = useState([]) @@ -57,6 +61,8 @@ const WhitelistInstantiatePage: NextPage = () => { placeholder: '5', }) + const addressListState = useAddressListState() + const { data, isLoading, mutate } = useMutation( async (event: FormEvent): Promise => { event.preventDefault() @@ -78,6 +84,14 @@ const WhitelistInstantiatePage: NextPage = () => { mint_price: coin(String(Number(unitPriceState.value) * 1000000), 'ustars'), per_address_limit: perAddressLimitState.value, member_limit: memberLimitState.value, + admins: [ + ...(new Set( + addressListState.values + .map((a) => a.address.trim()) + .filter((address) => address !== '' && isValidAddress(address.trim()) && address.startsWith('stars')), + ) || [wallet.address]), + ], + admins_mutable: adminsMutable, } return toast.promise(contract.instantiate(1835, msg, 'Stargaze Whitelist Contract', wallet.address), { loading: 'Instantiating contract...', @@ -115,6 +129,29 @@ const WhitelistInstantiatePage: NextPage = () => {
+
+ +
+
+ +
+ 0}>