Use empty array for amount 0. Add check to execute
This commit is contained in:
parent
ed86c3fdd6
commit
e880aaeb04
@ -78,14 +78,14 @@ const MsgCreateVestingAccountForm = ({
|
||||
try {
|
||||
return macroCoinToMicroCoin({ denom: chain.displayDenom, amount }, chain.assets);
|
||||
} catch {
|
||||
return { denom: chain.displayDenom, amount: "0" };
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
const msgValue = MsgCodecs[MsgTypeUrls.CreateVestingAccount].fromPartial({
|
||||
fromAddress,
|
||||
toAddress,
|
||||
amount: [microCoin],
|
||||
amount: microCoin ? [microCoin] : [],
|
||||
endTime: timestampFromDatetimeLocal(endTime, "s"),
|
||||
delayed,
|
||||
});
|
||||
|
||||
@ -55,6 +55,8 @@ const MsgExecuteContractForm = ({
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line no-shadow
|
||||
const { contractAddress, customDenom, amount } = trimmedInputs;
|
||||
const denom =
|
||||
selectedDenom.value === customDenomOption.value ? customDenom : selectedDenom.value.symbol;
|
||||
|
||||
const isMsgValid = (): boolean => {
|
||||
setContractAddressError("");
|
||||
@ -86,24 +88,23 @@ 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;
|
||||
if (denom && amount) {
|
||||
try {
|
||||
macroCoinToMicroCoin({ denom, amount }, chain.assets);
|
||||
} catch (e: unknown) {
|
||||
setAmountError(e instanceof Error ? e.message : "Could not set decimals");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const denom =
|
||||
selectedDenom.value === customDenomOption.value ? customDenom : selectedDenom.value.symbol;
|
||||
|
||||
const microCoin = (() => {
|
||||
try {
|
||||
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
|
||||
} catch {
|
||||
return { denom, amount: "0" };
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
@ -120,7 +121,7 @@ const MsgExecuteContractForm = ({
|
||||
sender: fromAddress,
|
||||
contract: contractAddress,
|
||||
msg: msgContentUtf8Array,
|
||||
funds: [microCoin],
|
||||
funds: microCoin ? [microCoin] : [],
|
||||
});
|
||||
|
||||
const msg: MsgExecuteContractEncodeObject = { typeUrl: MsgTypeUrls.Execute, value: msgValue };
|
||||
|
||||
@ -133,7 +133,7 @@ const MsgInstantiateContract2Form = ({
|
||||
try {
|
||||
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
|
||||
} catch {
|
||||
return { denom, amount: "0" };
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
@ -162,7 +162,7 @@ const MsgInstantiateContract2Form = ({
|
||||
fixMsg: false,
|
||||
salt: hexSalt,
|
||||
msg: msgContentUtf8Array,
|
||||
funds: [microCoin],
|
||||
funds: microCoin ? [microCoin] : [],
|
||||
});
|
||||
|
||||
const msg: MsgInstantiateContract2EncodeObject = {
|
||||
|
||||
@ -119,7 +119,7 @@ const MsgInstantiateContractForm = ({
|
||||
try {
|
||||
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
|
||||
} catch {
|
||||
return { denom, amount: "0" };
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
@ -138,7 +138,7 @@ const MsgInstantiateContractForm = ({
|
||||
label,
|
||||
admin: adminAddress,
|
||||
msg: msgContentUtf8Array,
|
||||
funds: [microCoin],
|
||||
funds: microCoin ? [microCoin] : [],
|
||||
});
|
||||
|
||||
const msg: MsgInstantiateContractEncodeObject = {
|
||||
|
||||
@ -89,14 +89,14 @@ const MsgSendForm = ({ fromAddress, setMsgGetter, deleteMsg }: MsgSendFormProps)
|
||||
try {
|
||||
return macroCoinToMicroCoin({ denom, amount }, chain.assets);
|
||||
} catch {
|
||||
return { denom, amount: "0" };
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
const msgValue = MsgCodecs[MsgTypeUrls.Send].fromPartial({
|
||||
fromAddress,
|
||||
toAddress,
|
||||
amount: [microCoin],
|
||||
amount: microCoin ? [microCoin] : [],
|
||||
});
|
||||
|
||||
const msg: MsgSendEncodeObject = { typeUrl: MsgTypeUrls.Send, value: msgValue };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user