Check for null microCoin and allow empty custom denom

This commit is contained in:
abefernan
2024-01-08 12:43:05 +01:00
parent e880aaeb04
commit 3cfb2c15b7
5 changed files with 46 additions and 4 deletions
@@ -76,6 +76,10 @@ const MsgCreateVestingAccountForm = ({
const microCoin = (() => {
try {
if (!amount || amount === "0") {
return null;
}
return macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
} catch {
return null;
@@ -73,7 +73,12 @@ const MsgExecuteContractForm = ({
return false;
}
if (selectedDenom.value === customDenomOption.value && !customDenom) {
if (
selectedDenom.value === customDenomOption.value &&
!customDenom &&
amount &&
amount !== "0"
) {
setCustomDenomError("Custom denom must be set because of selection above");
return false;
}
@@ -102,6 +107,10 @@ const MsgExecuteContractForm = ({
const microCoin = (() => {
try {
if (!denom || !amount || amount === "0") {
return null;
}
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch {
return null;
@@ -124,6 +133,8 @@ const MsgExecuteContractForm = ({
funds: microCoin ? [microCoin] : [],
});
console.log({ msgValue });
const msg: MsgExecuteContractEncodeObject = { typeUrl: MsgTypeUrls.Execute, value: msgValue };
setMsgGetter({ isMsgValid, msg });
@@ -101,7 +101,12 @@ const MsgInstantiateContract2Form = ({
return false;
}
if (selectedDenom.value === customDenomOption.value && !customDenom) {
if (
selectedDenom.value === customDenomOption.value &&
!customDenom &&
amount &&
amount !== "0"
) {
setCustomDenomError("Custom denom must be set because of selection above");
return false;
}
@@ -131,6 +136,10 @@ const MsgInstantiateContract2Form = ({
const microCoin = (() => {
try {
if (!denom || !amount || amount === "0") {
return null;
}
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch {
return null;
@@ -87,7 +87,12 @@ const MsgInstantiateContractForm = ({
return false;
}
if (selectedDenom.value === customDenomOption.value && !customDenom) {
if (
selectedDenom.value === customDenomOption.value &&
!customDenom &&
amount &&
amount !== "0"
) {
setCustomDenomError("Custom denom must be set because of selection above");
return false;
}
@@ -117,6 +122,10 @@ const MsgInstantiateContractForm = ({
const microCoin = (() => {
try {
if (!denom || !amount || amount === "0") {
return null;
}
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch {
return null;
@@ -57,7 +57,12 @@ const MsgSendForm = ({ fromAddress, setMsgGetter, deleteMsg }: MsgSendFormProps)
return false;
}
if (selectedDenom.value === customDenomOption.value && !customDenom) {
if (
selectedDenom.value === customDenomOption.value &&
!customDenom &&
amount &&
amount !== "0"
) {
setCustomDenomError("Custom denom must be set because of selection above");
return false;
}
@@ -87,6 +92,10 @@ const MsgSendForm = ({ fromAddress, setMsgGetter, deleteMsg }: MsgSendFormProps)
const microCoin = (() => {
try {
if (!denom || !amount || amount === "0") {
return null;
}
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch {
return null;