From 8eb34a0655e3bebff61230dd7518d03c33b94225 Mon Sep 17 00:00:00 2001 From: iamonuwa Date: Sun, 30 Sep 2018 20:05:58 +0100 Subject: [PATCH 1/2] Fix the Value input on proposal submission #13 --- src/app/Home.js | 68 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/src/app/Home.js b/src/app/Home.js index 382c3c8..205cb95 100755 --- a/src/app/Home.js +++ b/src/app/Home.js @@ -26,8 +26,13 @@ class Home extends Component { proposals: [], statement:'', members: '', + addresses: [ + {name: '0xf03003f0f1ca38b8d26b8be44469aba51f31d9f3', value: '0xf03003f0f1ca38b8d26b8be44469aba51f31d9f3'}, + {name: '0xc42e30da7cb0087e6ad9200f876b084e8f72c040', value: '0xc42e30da7cb0087e6ad9200f876b084e8f72c040'}, {name:'Other', value: 'Other'} + ], search: '0xf03003f0f1ca38b8d26b8be44469aba51f31d9f3', - loading: false + loading: false, + searchBox: false } componentDidMount() { @@ -108,7 +113,14 @@ class Home extends Component { handleChange = field => ({target: { value - }}) => this.setState({[field]: value}) + }}) => { + if (value === 'Other') { + this.setState({ searchBox: true }) + } else { + this.setState({ searchBox: false }) + this.setState({[field]: value}) + } + } search = () => { this @@ -209,7 +221,7 @@ class Home extends Component { .at(this.state.addressContract) .then((contract) => { return contract.addProposal(this.state.name, web3.toWei(this.state.valueDeposit, "ether"), this.state.dataDeposit, { - value: web3.toWei(1, "ether"), + value: web3.toWei(0.1, "ether"), from: this.state.accounts[0], gas: 4000000 }) @@ -280,9 +292,29 @@ class Home extends Component { console.log(err) }); } + + claim = idx => { + this.setState({ loading: true }); + this.state.metaContract.at(this.state.addressContract) + .then(contract => { + return contract.claim(idx, { + value: web3.toWei(0.1, "ether"), + from: this.state.accounts[0], + }) + }) + .then(result => { + this.setState({ loading: false }); + window.location.reload(); + console.log(result); + }) + .catch(err => { + this.setState({ loading: false }); + console.log(err) + }); + } render() { - const { name, balance, search, proposals, statement, members, loading } = this.state; + const { name, balance, searchBox, addresses, proposals, statement, members, loading } = this.state; return (
@@ -292,19 +324,28 @@ class Home extends Component {

Contract Address: - -

- Statement of intent: +

- {statement} + { + searchBox ? +

+ +

+ : '' + } +

- List of members: + Statement of intent:

+ {statement}

{members}

Set Delegate @@ -368,6 +409,9 @@ class Home extends Component { +

  • + +
  • ))} From 4476443621081417916e7a96f326f4d4284e0bc9 Mon Sep 17 00:00:00 2001 From: iamonuwa Date: Mon, 1 Oct 2018 19:18:34 +0100 Subject: [PATCH 2/2] Update input fields to convert to hex values --- src/app/Home.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/app/Home.js b/src/app/Home.js index 205cb95..6d36442 100755 --- a/src/app/Home.js +++ b/src/app/Home.js @@ -122,6 +122,34 @@ class Home extends Component { } } + handleChangeRequestAmount = value => { + this.setState({ + valueDeposit: value + }) + } + + handleChangePropsalName = value => { + let hexValue = this.toHex(value); + this.setState({ + name: hexValue + }) + } + + handleChangeDescription = value => { + let hexValue = `0x${this.toHex(value)}`; + this.setState({ + dataDeposit: hexValue + }) + } + + toHex = (str) => { + let result = ''; + for (var i=0; i { this .state @@ -361,15 +389,15 @@ class Home extends Component { Add proposal  this.handleChangePropsalName(e.target.value)} placeholder="Name of the proposition (hex)"/> this.handleChangeRequestAmount(e.target.value)} placeholder="Requested amount (Wei)"/> this.handleChangeDescription(e.target.value)} placeholder="Link IPFS"/>