diff --git a/js/src/modals/SMSVerification/SendRequest/sendRequest.css b/js/src/modals/SMSVerification/SendRequest/sendRequest.css new file mode 100644 index 000000000..563bf01ad --- /dev/null +++ b/js/src/modals/SMSVerification/SendRequest/sendRequest.css @@ -0,0 +1,19 @@ +/* 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 . +*/ +.centered { + text-align: center; +} diff --git a/js/src/modals/SMSVerification/SendRequest/sendRequest.js b/js/src/modals/SMSVerification/SendRequest/sendRequest.js index 1cfb757af..9e3a1ffe8 100644 --- a/js/src/modals/SMSVerification/SendRequest/sendRequest.js +++ b/js/src/modals/SMSVerification/SendRequest/sendRequest.js @@ -23,7 +23,7 @@ import TxHash from '../../../ui/TxHash'; import { toWei } from '../../../api/util/wei'; import { sha3 } from '../../../api/util/sha3'; -// import styles from './sendRequest.css'; +import styles from './sendRequest.css'; export default class SendRequest extends Component { static contextTypes = { @@ -65,11 +65,13 @@ export default class SendRequest extends Component { if (step === 'posted') { return ( -
-

The transaction has been sent to the network.

- -
- ); +
+ +
); + } + + if (step === 'mined') { + return (

mined

); } return null; @@ -101,7 +103,28 @@ export default class SendRequest extends Component { .then((txHash) => { onData({ txHash: txHash }); this.setState({ step: 'posted' }); - // TODO: subscribe to `Requested` + + return api.pollMethod('eth_getTransactionReceipt', txHash, (receipt) => { + return receipt && receipt.blockNumber && receipt.blockNumber.gt(0); + }); + }) + .then((receipt) => new Promise((resolve, reject) => { + let subscription; + api.subscribe('eth_blockNumber', (err, block) => { + if (err) { + reject(err); + } else if (block.minus(2).gte(receipt.blockNumber)) { + api.unsubscribe(subscription); + resolve(); + } + }) + .then((_subscription) => { + subscription = _subscription; + }) + .catch(reject); + })) + .then(() => { + this.setState({ step: 'mined' }); }) .catch((err) => { console.error('failed to request sms verification', err);