sms verification: wait for tx confirmations
This commit is contained in:
parent
d0d737d1e3
commit
3ef54f9172
19
js/src/modals/SMSVerification/SendRequest/sendRequest.css
Normal file
19
js/src/modals/SMSVerification/SendRequest/sendRequest.css
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
.centered {
|
||||
text-align: center;
|
||||
}
|
@ -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 (
|
||||
<div>
|
||||
<p>The transaction has been sent to the network.</p>
|
||||
<TxHash hash={ this.props.data.txHash } />
|
||||
</div>
|
||||
);
|
||||
<div className={ styles.centered }>
|
||||
<TxHash hash={ this.props.data.txHash } maxConfirmations={ 3 } />
|
||||
</div>);
|
||||
}
|
||||
|
||||
if (step === 'mined') {
|
||||
return (<p>mined</p>);
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user