diff --git a/components/dataViews/MultisigHoldings.js b/components/dataViews/MultisigHoldings.js index 8195728..a247c16 100644 --- a/components/dataViews/MultisigHoldings.js +++ b/components/dataViews/MultisigHoldings.js @@ -1,15 +1,22 @@ import StackableContainer from "../layout/StackableContainer"; -export default (props) => ( - -

Holdings

- - 1,021,010 ATOM +export default (props) => { + const uatomToAtom = (uatom) => { + if (uatom === 0) return 0; + return uatom / 1000000; + }; + + return ( + +

Holdings

+ + {props.holdings} ATOM + +
- -
-); + ); +}; diff --git a/components/dataViews/TransactionInfo.js b/components/dataViews/TransactionInfo.js index 3482cb9..4948471 100644 --- a/components/dataViews/TransactionInfo.js +++ b/components/dataViews/TransactionInfo.js @@ -1,48 +1,43 @@ import { abbreviateLongString } from "../../lib/displayHelpers"; import StackableContainer from "../layout/StackableContainer"; +const uatomToAtom = (uatom) => { + return uatom / 1000000; +}; export default (props) => ( diff --git a/components/forms/TransactionForm.js b/components/forms/TransactionForm.js index 46ca4e2..bcecf82 100644 --- a/components/forms/TransactionForm.js +++ b/components/forms/TransactionForm.js @@ -1,4 +1,5 @@ import axios from "axios"; +import { coins } from "@cosmjs/launchpad"; import React from "react"; import { withRouter } from "next/router"; @@ -6,33 +7,6 @@ import Button from "../../components/inputs/Button"; import Input from "../../components/inputs/Input"; import StackableContainer from "../layout/StackableContainer"; -const baseTX = { - type: "cosmos-sdk/StdTx", - value: { - msg: [ - { - type: "cosmos-sdk/MsgSend", - value: { - from_address: "", - to_address: "", - amount: [ - { - denom: "uatom", - amount: "0", - }, - ], - }, - }, - ], - fee: { - amount: [], - gas: "0", - }, - signatures: null, - memo: "", - }, -}; - class TransactionForm extends React.Component { constructor(props) { super(props); @@ -54,10 +28,29 @@ class TransactionForm extends React.Component { }; createTransaction = (toAddress, amount, gas) => { - baseTX.value.msg[0].value.to_address = toAddress; - baseTX.value.msg[0].value.from_address = this.props.address; - baseTX.value.msg[0].value.amount[0].amount = amount.toString(); - baseTX.value.fee.gas = gas.toString(); + const msgSend = { + fromAddress: this.props.address, + toAddress: toAddress, + amount: coins(amount * 1000000, "uatom"), + }; + const msg = { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: msgSend, + }; + const gasLimit = gas; + const fee = { + amount: coins(2000, "uatom"), + gas: gasLimit.toString(), + }; + + return { + accountNumber: this.props.accountOnChain.accountNumber, + sequence: this.props.accountOnChain.sequence, + chainId: "cosmoshub-4", + msgs: [msg], + fee: fee, + memo: this.state.memo, + }; return baseTX; }; @@ -70,13 +63,11 @@ class TransactionForm extends React.Component { this.state.gas ); - const res = await axios.post("/api/transaction", { - unsignedJson: JSON.stringify(tx), - multiAddress: this.props.multiAddress, - }); - + const dataJSON = JSON.stringify(tx); + const res = await axios.post("/api/transaction", { dataJSON }); + const { transactionID } = res.data; this.props.router.push( - `${this.props.multiAddress}/transaction/${res.data}` + `${this.props.address}/transaction/${transactionID}` ); } else { this.setState({ addressError: "Use a valid cosmos-hub address" }); @@ -86,6 +77,9 @@ class TransactionForm extends React.Component { render() { return ( +

Create New transaction

@@ -107,21 +102,23 @@ class TransactionForm extends React.Component {
-