From 14da2d280585c475fc3f3db3c1483b13840cec54 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 7 Nov 2016 13:18:36 +0100 Subject: [PATCH] sms verification: check if certified --- .../CheckIfCertified/checkIfCertified.css | 27 ++++++ .../CheckIfCertified/checkIfCertified.js | 88 +++++++++++++++++++ .../SMSVerification/CheckIfCertified/index.js | 17 ++++ .../modals/SMSVerification/SMSVerification.js | 17 +++- 4 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css create mode 100644 js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js create mode 100644 js/src/modals/SMSVerification/CheckIfCertified/index.js diff --git a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css new file mode 100644 index 000000000..13779b8f4 --- /dev/null +++ b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css @@ -0,0 +1,27 @@ +/* Copyright 2015, 2016 Ethcore (UK) Ltd. +/* This file is part of Parity. +/* +/* Parity is free software: you can redistribute it and/or modify +/* it under the terms of the GNU General Public License as published by +/* the Free Software Foundation, either version 3 of the License, or +/* (at your option) any later version. +/* +/* Parity is distributed in the hope that it will be useful, +/* but WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU General Public License for more details. +/* +/* You should have received a copy of the GNU General Public License +/* along with Parity. If not, see . +*/ + +.container { + display: flex; + align-items: center; +} + +.message { + margin-top: 0; + margin-bottom: 0; + margin-left: .5em; +} diff --git a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js new file mode 100644 index 000000000..d28665855 --- /dev/null +++ b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js @@ -0,0 +1,88 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import React, { Component, PropTypes } from 'react'; +import { Checkbox } from 'material-ui'; +import SuccessIcon from 'material-ui/svg-icons/navigation/check'; +import ErrorIcon from 'material-ui/svg-icons/alert/error-outline'; + +import { Form, Input } from '../../../ui'; + +import styles from './checkIfCertified.css'; + +export default class CheckIfCertified extends Component { + static contextTypes = { + api: PropTypes.object.isRequired + } + + static propTypes = { + account: PropTypes.string.isRequired, + contract: PropTypes.object.isRequired, + onIsCertified: PropTypes.func.isRequired, + onIsNotCertified: PropTypes.func.isRequired + } + + state = { + pending: false, + isCertified: null + }; + + componentWillMount () { + const { pending } = this.state; + if (pending) { + return; + } + this.setState({ pending: true }); + + const { account, contract, onIsCertified, onIsNotCertified } = this.props; + + contract.instance.certified.call({}, [account]) + .then((isCertified) => { + this.setState({ isCertified, pending: false }); + if (isCertified) { + onIsCertified(); + } else { + onIsNotCertified(); + } + }) + .catch((err) => { + console.error('error checking if certified', err); + }); + } + + render () { + const { pending, isCertified } = this.state; + + if (pending) { + return (

Checking if your account is verified…

); + } + + if (isCertified) { + return ( +
+ +

Your account is already verified.

+
+ ); + } + return ( +
+ +

Your account is not verified yet.

+
+ ); + } +} diff --git a/js/src/modals/SMSVerification/CheckIfCertified/index.js b/js/src/modals/SMSVerification/CheckIfCertified/index.js new file mode 100644 index 000000000..2577505e2 --- /dev/null +++ b/js/src/modals/SMSVerification/CheckIfCertified/index.js @@ -0,0 +1,17 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +export default from './checkIfCertified'; diff --git a/js/src/modals/SMSVerification/SMSVerification.js b/js/src/modals/SMSVerification/SMSVerification.js index a1b306363..be8353acf 100644 --- a/js/src/modals/SMSVerification/SMSVerification.js +++ b/js/src/modals/SMSVerification/SMSVerification.js @@ -24,6 +24,7 @@ import { validateAddress, validateUint } from '../../util/validation'; import ABI from '../../contracts/abi/sms-verification.json'; const contract = '0x7B3F58965439b22ef1dA4BB78f16191d11ab80B0'; +import CheckIfCertified from './CheckIfCertified'; import GatherData from './GatherData'; export default class SMSVerification extends Component { @@ -119,16 +120,28 @@ export default class SMSVerification extends Component { onDataIsValid = () => { this.setState({ stepIsValid: true }); } - onDataIsInvalid = () => { this.setState({ stepIsValid: false }); } next = () => { - this.setState({ step: this.state.step + 1 }); + this.setState({ step: this.state.step + 1, stepIsValid: false }); } renderFirstStep () { + const { account } = this.props; + const { contract } = this.state; + + return ( + + ); + } + + renderSecondStep () { return (