From ffbc0d2da1a5cda1fef09e19cfae145e3f836852 Mon Sep 17 00:00:00 2001 From: Matthew A Elder Date: Wed, 23 Feb 2022 15:23:11 -0700 Subject: [PATCH] MsgSend --- components/forms/FlexibleTransactionForm.js | 13 +++++++++---- components/messages/MsgSend.js | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/components/forms/FlexibleTransactionForm.js b/components/forms/FlexibleTransactionForm.js index 74d55067..a24ef8f6 100644 --- a/components/forms/FlexibleTransactionForm.js +++ b/components/forms/FlexibleTransactionForm.js @@ -13,6 +13,7 @@ import CodeMirror from "@uiw/react-codemirror"; import MsgDelegate from "../messages/MsgDelegate"; import MsgUndelegate from "../messages/MsgUndelegate"; import MsgRedelegate from "../messages/MsgRedelegate"; +import MsgSend from "../messages/MsgSend"; import MsgVote from "../messages/MsgVote"; const blankMessageJSON = `{ @@ -28,10 +29,12 @@ function blankSendJSON(fromAddress) { value: { fromAddress, toAddress: "", - amount: { - denom: "uumee", - amount: "0", - }, + amount: [ + { + denom: "uumee", + amount: "0", + }, + ], }, }, null, @@ -189,6 +192,8 @@ const FlexibleTransactionForm = (props) => { function getMsgUI(msg, onMsgChange, onCheck) { switch (msg.typeUrl) { + case "/cosmos.bank.v1beta1.MsgSend": + return ; case "/cosmos.staking.v1beta1.MsgDelegate": return ; case "/cosmos.staking.v1beta1.MsgUndelegate": diff --git a/components/messages/MsgSend.js b/components/messages/MsgSend.js index 6bff3c9f..cb0c1037 100644 --- a/components/messages/MsgSend.js +++ b/components/messages/MsgSend.js @@ -19,10 +19,11 @@ const MsgDelegate = (props) => { const v = msg.value; if (!v.amount) return false; - if (!v.amount.denom) return false; - if (!v.amount.amount) return false; + if (!v.amount[0]) return false; + if (!v.amount[0].denom) return false; + if (!v.amount[0].amount) return false; - const _fromAddressError = checkAddress(v.delegatorAddress, state.chain.addressPrefix); + const _fromAddressError = checkAddress(v.fromAddress, state.chain.addressPrefix); if (updateInternalErrors) { if (_fromAddressError) { const errorMsg = `Invalid from address for network ${state.chain.chainId}: ${_fromAddressError}`; @@ -31,7 +32,7 @@ const MsgDelegate = (props) => { setFromAddressError(""); } } - const _toAddressError = checkAddress(v.validatorAddress, state.chain.addressPrefix); + const _toAddressError = checkAddress(v.toAddress, state.chain.addressPrefix); if (updateInternalErrors) { if (_toAddressError) { const errorMsg = `Invalid to address for network ${state.chain.chainId}: ${_toAddressError}`; @@ -49,14 +50,14 @@ const MsgDelegate = (props) => { function checkAndSetAmount(newAmount) { const newMsg = JSON.parse(JSON.stringify(props.msg)); - newMsg.value.amount.amount = newAmount; + newMsg.value.amount[0].amount = newAmount; onMsgChange(newMsg); onCheck(checkMsg(newMsg, true)); } - function checkAndSetToAddress(valaddr) { + function checkAndSetToAddress(toaddr) { const newMsg = JSON.parse(JSON.stringify(props.msg)); - newMsg.value.validatorAddress = valaddr; + newMsg.value.toAddress = toaddr; onMsgChange(newMsg); onCheck(checkMsg(newMsg, true)); } @@ -89,10 +90,10 @@ const MsgDelegate = (props) => {
checkAndSetAmount(e.target.value)} />