Add label validation to instantiate
This commit is contained in:
parent
ff805e34b1
commit
fa77bc3ffa
@ -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}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-item">
|
||||
|
||||
@ -48,12 +48,14 @@ const MsgInstantiateContractForm = ({
|
||||
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("");
|
||||
@ -64,6 +66,11 @@ const MsgInstantiateContractForm = ({
|
||||
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}`);
|
||||
@ -168,6 +175,7 @@ const MsgInstantiateContractForm = ({
|
||||
name="label"
|
||||
value={label}
|
||||
onChange={({ target }) => setLabel(target.value)}
|
||||
error={labelError}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-item">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user