From fa77bc3ffac777ff3a73c62c988cdad8ec9bf1db Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:54:02 +0200 Subject: [PATCH] Add label validation to instantiate --- .../CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx | 8 ++++++++ .../CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx index ed9d02c..7ce09ec 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx @@ -50,12 +50,14 @@ const MsgInstantiateContract2Form = ({ const [amount, setAmount] = useState("0"); const [codeIdError, setCodeIdError] = useState(""); + const [labelError, setLabelError] = useState(""); const [adminAddressError, setAdminAddressError] = useState(""); const [customDenomError, setCustomDenomError] = useState(""); const [amountError, setAmountError] = useState(""); useEffect(() => { setCodeIdError(""); + setLabelError(""); setAdminAddressError(""); setCustomDenomError(""); setAmountError(""); @@ -66,6 +68,11 @@ const MsgInstantiateContract2Form = ({ return false; } + if (!label) { + setLabelError("Label is required"); + return false; + } + const addressErrorMsg = checkAddress(adminAddress, chain.addressPrefix); if (adminAddress && addressErrorMsg) { setAdminAddressError(`Invalid address for network ${chain.chainId}: ${addressErrorMsg}`); @@ -174,6 +181,7 @@ const MsgInstantiateContract2Form = ({ name="label" value={label} onChange={({ target }) => setLabel(target.value)} + error={labelError} />