Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
disable remove signature on broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbondi committed Nov 13, 2019
1 parent 403562c commit 94e1a0f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
8 changes: 6 additions & 2 deletions src/components/Spend/OutputsForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down Expand Up @@ -338,7 +341,8 @@ function mapStateToProps(state) {
client: state.client,
},
...state.spend.transaction,
...state.client
...state.client,
signatureImporters: state.spend.signatureImporters,
};
}

Expand Down
27 changes: 15 additions & 12 deletions src/components/Spend/SignatureImporter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import {wrapText,} from "../../utils";

// Components
import {
import {
Card,
CardHeader,
CardContent,
Expand All @@ -25,7 +25,7 @@ import {
Button,
Grid,
Box,
FormControl,
FormControl,
} from '@material-ui/core';
import Copyable from "../Copyable";
import TextSignatureImporter from "./TextSignatureImporter";
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -133,7 +134,7 @@ class SignatureImporter extends React.Component {
</p>
);
}

return (
<form>

Expand Down Expand Up @@ -169,7 +170,7 @@ class SignatureImporter extends React.Component {
validateAndSetSignature={this.validateAndSetSignature} />;
}
if (signatureImporter.method === HERMIT) {
return <HermitSignatureImporter
return <HermitSignatureImporter
network={network}
signatureImporter={signatureImporter}
inputs={inputs}
Expand All @@ -182,7 +183,7 @@ class SignatureImporter extends React.Component {
disableChangeMethod={this.disableChangeMethod} />;
}
if (signatureImporter.method === TREZOR || signatureImporter.method === LEDGER) {
return <HardwareWalletSignatureImporter
return <HardwareWalletSignatureImporter
network={network}
signatureImporter={signatureImporter}
signatureImporters={signatureImporters}
Expand Down Expand Up @@ -220,7 +221,7 @@ class SignatureImporter extends React.Component {

//
// Unsigned Transaction
//
//

renderUnsignedTransaction = () => {
const {showUnsignedTransaction} = this.state;
Expand All @@ -234,9 +235,9 @@ class SignatureImporter extends React.Component {
<Button size="small" onClick={this.handleHideUnsignedTransaction}>
Hide Unsigned Transaction
</Button>
</small>
</small>
</div>

);
} else {
return (
Expand All @@ -260,7 +261,7 @@ class SignatureImporter extends React.Component {

//
// State
//
//

reset = () => {
const { number, setSignature, setPublicKeys, setFinalized } = this.props;
Expand All @@ -271,7 +272,7 @@ class SignatureImporter extends React.Component {

//
// BIP32 Path
//
//

defaultBIP32Path = () => {
const {addressType, network} = this.props;
Expand Down Expand Up @@ -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 (
<div>
Expand All @@ -315,13 +316,14 @@ class SignatureImporter extends React.Component {
<Button
variant="contained"
color="secondary"
disabled={txid !== ""}
size="small"
onClick={this.reset}
>
Remove Signature
</Button>
</Box>

</div>
);
}
Expand Down Expand Up @@ -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,
};
Expand Down
8 changes: 6 additions & 2 deletions src/components/Spend/Transaction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 = '';
Expand All @@ -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);
}
}

Expand All @@ -139,6 +141,8 @@ function mapStateToProps(state) {
};
}

const mapDispatchToProps = {};
const mapDispatchToProps = {
setTxid: setTXID
};

export default connect(mapStateToProps, mapDispatchToProps)(Transaction);

0 comments on commit 94e1a0f

Please sign in to comment.