Check the users balance before trying to publish/create a channel #794
|
@ -66,6 +66,9 @@
|
|||
"perMachine": true
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./node_modules/.bin/electron src/main"
|
||||
It does, I like to show the full path so others know exactly whats going on It does, I like to show the full path so others know exactly whats going on
I can change it to I can change it to `electron src/main` if you think that looks better
hmm no need, lets keep it as is then hmm no need, lets keep it as is then
|
||||
},
|
||||
"devDependencies": {
|
||||
"devtron": "^1.4.0",
|
||||
"electron": "^1.7.9",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import PublishForm from "./view";
|
||||
import { selectBalance } from "redux/selectors/wallet";
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
|
||||
export default connect(null, null)(PublishForm);
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
const select = state => ({
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
balance: selectBalance(state),
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
});
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
export default connect(select, null)(PublishForm);
|
||||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
||||
|
|
|||
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
Why format this? Also we should probably trust selector to fallback to 0? Why format this? Also we should probably trust selector to fallback to 0?
Ignore this for now. Just copy/pasted from somewhere else Ignore this for now. Just copy/pasted from somewhere else
|
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
does it work to just say "electron src/main" since electron is in the bin?