From 94e1a0f47717673f012aac58b1823030034c9019 Mon Sep 17 00:00:00 2001 From: Richard Bondi Date: Wed, 13 Nov 2019 14:37:01 -0600 Subject: [PATCH] disable remove signature on broadcast --- src/components/Spend/OutputsForm.jsx | 8 +++++-- src/components/Spend/SignatureImporter.jsx | 27 ++++++++++++---------- src/components/Spend/Transaction.jsx | 8 +++++-- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/components/Spend/OutputsForm.jsx b/src/components/Spend/OutputsForm.jsx index 240a24bc..df2c1a63 100644 --- a/src/components/Spend/OutputsForm.jsx +++ b/src/components/Spend/OutputsForm.jsx @@ -40,6 +40,7 @@ class OutputsForm extends React.Component { fee: PropTypes.string.isRequired, feeRate: PropTypes.string.isRequired, finalizedOutputs: PropTypes.bool.isRequired, + signatureImporters: PropTypes.shape({}).isRequired, setFeeRate: PropTypes.func.isRequired, setFee: PropTypes.func.isRequired, addOutput: PropTypes.func.isRequired, @@ -65,7 +66,9 @@ class OutputsForm extends React.Component { } scrollToTitle = () => { - this.titleRef.current.scrollIntoView({ behavior: 'smooth' }); + const { signatureImporters } = this.props; + const finalizedCount = Object.keys(signatureImporters).reduce((o, k) => o + (signatureImporters[k].finalized), 0); + if(finalizedCount === 0) this.titleRef.current.scrollIntoView({ behavior: 'smooth' }); } async initialOutputState() { @@ -338,7 +341,8 @@ function mapStateToProps(state) { client: state.client, }, ...state.spend.transaction, - ...state.client + ...state.client, + signatureImporters: state.spend.signatureImporters, }; } diff --git a/src/components/Spend/SignatureImporter.jsx b/src/components/Spend/SignatureImporter.jsx index 6812f1f5..fe453218 100644 --- a/src/components/Spend/SignatureImporter.jsx +++ b/src/components/Spend/SignatureImporter.jsx @@ -15,7 +15,7 @@ import { import {wrapText,} from "../../utils"; // Components -import { +import { Card, CardHeader, CardContent, @@ -25,7 +25,7 @@ import { Button, Grid, Box, - FormControl, + FormControl, } from '@material-ui/core'; import Copyable from "../Copyable"; import TextSignatureImporter from "./TextSignatureImporter"; @@ -63,6 +63,7 @@ class SignatureImporter extends React.Component { addressType: PropTypes.string.isRequired, network: PropTypes.string.isRequired, fee: PropTypes.string.isRequired, + txid: PropTypes.string.isRequired, setName: PropTypes.func.isRequired, setMethod: PropTypes.func.isRequired, setBIP32Path: PropTypes.func.isRequired, @@ -133,7 +134,7 @@ class SignatureImporter extends React.Component {

); } - + return (
@@ -169,7 +170,7 @@ class SignatureImporter extends React.Component { validateAndSetSignature={this.validateAndSetSignature} />; } if (signatureImporter.method === HERMIT) { - return ; } if (signatureImporter.method === TREZOR || signatureImporter.method === LEDGER) { - return { const {showUnsignedTransaction} = this.state; @@ -234,9 +235,9 @@ class SignatureImporter extends React.Component { - + - + ); } else { return ( @@ -260,7 +261,7 @@ class SignatureImporter extends React.Component { // // State - // + // reset = () => { const { number, setSignature, setPublicKeys, setFinalized } = this.props; @@ -271,7 +272,7 @@ class SignatureImporter extends React.Component { // // BIP32 Path - // + // defaultBIP32Path = () => { const {addressType, network} = this.props; @@ -301,7 +302,7 @@ class SignatureImporter extends React.Component { // renderSignature = () => { - const { signatureImporter } = this.props; + const { signatureImporter, txid } = this.props; const signatureJSON = JSON.stringify(signatureImporter.signature); return (
@@ -315,13 +316,14 @@ class SignatureImporter extends React.Component { - +
); } @@ -389,6 +391,7 @@ function mapStateToProps(state, ownProps) { signatureImporters: state.spend.signatureImporters, signatureImporter: state.spend.signatureImporters[ownProps.number], fee: state.spend.transaction.fee, + txid: state.spend.transaction.txid, }, ...state.spend.transaction, }; diff --git a/src/components/Spend/Transaction.jsx b/src/components/Spend/Transaction.jsx index da32ef46..fb773101 100644 --- a/src/components/Spend/Transaction.jsx +++ b/src/components/Spend/Transaction.jsx @@ -20,6 +20,7 @@ import { import {OpenInNew} from "@material-ui/icons"; import Copyable from "../Copyable"; import {externalLink} from "../../utils"; +import {setTXID} from '../../actions/transactionActions'; class Transaction extends React.Component { @@ -105,7 +106,7 @@ class Transaction extends React.Component { } handleBroadcast = async () => { - const {client, network} = this.props; + const {client, network, setTxid} = this.props; const signedTransaction = this.buildSignedTransaction(); let error = ''; let txid = ''; @@ -117,6 +118,7 @@ class Transaction extends React.Component { error = `There was an error broadcasting the transaction.: ${e}`; } finally { this.setState({txid, error, broadcasting: false}); + setTxid(txid); } } @@ -139,6 +141,8 @@ function mapStateToProps(state) { }; } -const mapDispatchToProps = {}; +const mapDispatchToProps = { + setTxid: setTXID +}; export default connect(mapStateToProps, mapDispatchToProps)(Transaction);