diff --git a/package.json b/package.json index 3c3bc5a0a..0946afe2c 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,9 @@ "perMachine": true } }, + "scripts": { + "start": "./node_modules/.bin/electron src/main" + }, "devDependencies": { "devtron": "^1.4.0", "electron": "^1.7.9", diff --git a/src/renderer/js/component/publishForm/index.js b/src/renderer/js/component/publishForm/index.js index a55cf9187..df41581d9 100644 --- a/src/renderer/js/component/publishForm/index.js +++ b/src/renderer/js/component/publishForm/index.js @@ -1,5 +1,10 @@ import React from "react"; import { connect } from "react-redux"; import PublishForm from "./view"; +import { selectBalance } from "redux/selectors/wallet"; -export default connect(null, null)(PublishForm); +const select = state => ({ + balance: selectBalance(state), +}); + +export default connect(select, null)(PublishForm); diff --git a/src/renderer/js/component/publishForm/internal/channelSection.jsx b/src/renderer/js/component/publishForm/internal/channelSection.jsx index 203e90e74..49c560f65 100644 --- a/src/renderer/js/component/publishForm/internal/channelSection.jsx +++ b/src/renderer/js/component/publishForm/internal/channelSection.jsx @@ -48,11 +48,22 @@ class ChannelSection extends React.PureComponent { handleNewChannelBidChange(event) { this.setState({ - newChannelBid: event.target.value, + newChannelBid: parseFloat(event.target.value), }); } handleCreateChannelClick(event) { + const { balance } = this.props; + const { newChannelBid } = this.state; + + if (newChannelBid > balance) { + this.refs.newChannelName.showError( + __("Unable to create channel due to insufficient funds.") + ); + + return; + } + this.setState({ creatingChannel: true, }); diff --git a/src/renderer/js/component/publishForm/view.jsx b/src/renderer/js/component/publishForm/view.jsx index 75ac22d2b..deb16e248 100644 --- a/src/renderer/js/component/publishForm/view.jsx +++ b/src/renderer/js/component/publishForm/view.jsx @@ -61,6 +61,15 @@ class PublishForm extends React.PureComponent { } handleSubmit() { + const { balance } = this.props; + const { bid } = this.state; + + if (bid > balance) { + this.handlePublishError({ message: "insufficient funds" }); + + return; + } + this.setState({ submitting: true, });