From ed86c3fdd623defa18fe02f7479a6692b48efbe7 Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:50:41 +0100 Subject: [PATCH] Add macrocoinToMicrocoin to validaiton --- .../CreateTxForm/MsgForm/MsgCreateVestingAccountForm.tsx | 7 +++++++ components/forms/CreateTxForm/MsgForm/MsgDelegateForm.tsx | 7 +++++++ .../forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx | 7 +++++++ .../CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx | 7 +++++++ .../CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx | 7 +++++++ .../forms/CreateTxForm/MsgForm/MsgRedelegateForm.tsx | 7 +++++++ components/forms/CreateTxForm/MsgForm/MsgSendForm.tsx | 7 +++++++ .../forms/CreateTxForm/MsgForm/MsgUndelegateForm.tsx | 7 +++++++ 8 files changed, 56 insertions(+) diff --git a/components/forms/CreateTxForm/MsgForm/MsgCreateVestingAccountForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgCreateVestingAccountForm.tsx index f067e54..687035c 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgCreateVestingAccountForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgCreateVestingAccountForm.tsx @@ -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"); diff --git a/components/forms/CreateTxForm/MsgForm/MsgDelegateForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgDelegateForm.tsx index 65bb303..484081b 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgDelegateForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgDelegateForm.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx index f689478..df552bd 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx index a4d73cc..8b4d1a3 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx index 25d03ec..1f39410 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgRedelegateForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgRedelegateForm.tsx index 9a90587..28205b2 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgRedelegateForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgRedelegateForm.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgSendForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgSendForm.tsx index 64f65fe..4e738db 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgSendForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgSendForm.tsx @@ -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; }; diff --git a/components/forms/CreateTxForm/MsgForm/MsgUndelegateForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgUndelegateForm.tsx index d4b81e6..b3a707b 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgUndelegateForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgUndelegateForm.tsx @@ -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; };