Add macrocoinToMicrocoin to validaiton

This commit is contained in:
abefernan 2024-01-04 10:50:41 +01:00
parent 678aef8632
commit ed86c3fdd6
8 changed files with 56 additions and 0 deletions

View File

@ -58,6 +58,13 @@ const MsgCreateVestingAccountForm = ({
return false;
}
try {
macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
const timeoutDate = new Date(Number(timestampFromDatetimeLocal(endTime, "ms")));
if (timeoutDate <= new Date()) {
setEndTimeError("End time must be a date in the future");

View File

@ -46,6 +46,13 @@ const MsgDelegateForm = ({ delegatorAddress, setMsgGetter, deleteMsg }: MsgDeleg
return false;
}
try {
macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -86,6 +86,13 @@ const MsgExecuteContractForm = ({
return false;
}
try {
macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -116,6 +116,13 @@ const MsgInstantiateContract2Form = ({
return false;
}
try {
macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -102,6 +102,13 @@ const MsgInstantiateContractForm = ({
return false;
}
try {
macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -61,6 +61,13 @@ const MsgRedelegateForm = ({
return false;
}
try {
macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -72,6 +72,13 @@ const MsgSendForm = ({ fromAddress, setMsgGetter, deleteMsg }: MsgSendFormProps)
return false;
}
try {
macroCoinToMicroCoin({ denom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};

View File

@ -50,6 +50,13 @@ const MsgUndelegateForm = ({
return false;
}
try {
macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
} catch (e: unknown) {
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
return false;
}
return true;
};