Check the users balance before trying to publish/create a channel #794

Merged
neb-b merged 2 commits from insufficient-funds-create-channel into master 2017-11-29 21:42:50 +01:00
4 changed files with 30 additions and 2 deletions

View file

@ -66,6 +66,9 @@
"perMachine": true
}
},
"scripts": {
"start": "./node_modules/.bin/electron src/main"
liamcardenas commented 2017-11-29 20:42:17 +01:00 (Migrated from github.com)
Review

does it work to just say "electron src/main" since electron is in the bin?

does it work to just say "electron src/main" since electron is in the bin?
neb-b commented 2017-11-29 20:56:55 +01:00 (Migrated from github.com)
Review

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
neb-b commented 2017-11-29 20:57:15 +01:00 (Migrated from github.com)
Review

I can change it to electron src/main if you think that looks better

I can change it to `electron src/main` if you think that looks better
liamcardenas commented 2017-11-29 21:24:51 +01:00 (Migrated from github.com)
Review

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",

View file

@ -1,5 +1,10 @@
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

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";
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

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);
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
const select = state => ({
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
balance: selectBalance(state),
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
});
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

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);
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else

kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

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?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else

View file

@ -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,
});

View file

@ -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,
});