Fix postsign (#4347)

* Fix whitespace.

* Fix post sign.

* Fix message.

* Fix tests.

* Rest of the problems.

* All hail the linter and its omniscience.

* ...and its divine omniscience.

* Grumbles and wording.
This commit is contained in:
Gav Wood
2017-01-30 15:08:02 +01:00
committed by GitHub
parent 5a18ed7c3e
commit ca196d683e
14 changed files with 94 additions and 53 deletions

View File

@@ -297,6 +297,11 @@ export default class Parity {
.execute('parity_postTransaction', inOptions(options));
}
postSign (from, message) {
return this._transport
.execute('parity_postSign', from, message);
}
registryAddress () {
return this._transport
.execute('parity_registryAddress')

View File

@@ -61,7 +61,7 @@ export default class RequestPending extends Component {
address={ sign.address }
className={ className }
focus={ focus }
hash={ sign.hash }
data={ sign.data }
id={ id }
isFinished={ false }
isSending={ isSending }

View File

@@ -27,8 +27,20 @@
min-height: $pendingHeight;
}
.signData {
border: 0.25em solid red;
padding: 0.5em;
margin-left: -2em;
overflow: auto;
max-height: 6em;
}
.signData > p {
color: white;
}
.signDetails {
flex: 1;
flex: 10;
}
.address, .info {

View File

@@ -19,16 +19,30 @@ import { observer } from 'mobx-react';
import Account from '../Account';
import TransactionPendingForm from '../TransactionPendingForm';
import TxHashLink from '../TxHashLink';
import styles from './signRequest.css';
function isAscii (data) {
for (var i = 2; i < data.length; i += 2) {
let n = parseInt(data.substr(i, 2), 16);
if (n < 32 || n >= 128) {
return false;
}
}
return true;
}
@observer
export default class SignRequest extends Component {
static contextTypes = {
api: PropTypes.object
};
static propTypes = {
id: PropTypes.object.isRequired,
address: PropTypes.string.isRequired,
hash: PropTypes.string.isRequired,
data: PropTypes.string.isRequired,
isFinished: PropTypes.bool.isRequired,
isTest: PropTypes.bool.isRequired,
store: PropTypes.object.isRequired,
@@ -62,8 +76,23 @@ export default class SignRequest extends Component {
);
}
renderAsciiDetails (ascii) {
return (
<div className={ styles.signData }>
<p>{ascii}</p>
</div>
);
}
renderBinaryDetails (data) {
return (<div className={ styles.signData }>
<p>(Unknown binary data)</p>
</div>);
}
renderDetails () {
const { address, hash, isTest, store } = this.props;
const { api } = this.context;
const { address, isTest, store, data } = this.props;
const balance = store.balances[address];
if (!balance) {
@@ -79,9 +108,14 @@ export default class SignRequest extends Component {
isTest={ isTest }
/>
</div>
<div className={ styles.info } title={ hash }>
<p>Dapp is requesting to sign arbitrary transaction using this account.</p>
<p><strong>Confirm the transaction only if you trust the app.</strong></p>
<div className={ styles.info } title={ api.util.sha3(data) }>
<p>A request to sign data using your account:</p>
{
isAscii(data)
? this.renderAsciiDetails(api.util.hexToAscii(data))
: this.renderBinaryDetails(data)
}
<p><strong>WARNING: This consequences of doing this may be grave. Confirm the request only if you are sure.</strong></p>
</div>
</div>
);
@@ -92,19 +126,9 @@ export default class SignRequest extends Component {
if (isFinished) {
if (status === 'confirmed') {
const { hash, isTest } = this.props;
return (
<div className={ styles.actions }>
<span className={ styles.isConfirmed }>Confirmed</span>
<div>
Transaction hash:
<TxHashLink
isTest={ isTest }
txHash={ hash }
className={ styles.txHash }
/>
</div>
</div>
);
}

View File

@@ -150,7 +150,7 @@ class TransactionPendingFormConfirm extends Component {
label={
isSending
? 'Confirming...'
: 'Confirm Transaction'
: 'Confirm Request'
}
onTouchTap={ this.onConfirm }
primary
@@ -256,7 +256,8 @@ function mapStateToProps (_, initProps) {
return (state) => {
const { accounts } = state.personal;
const account = accounts[address] || {};
let gotAddress = Object.keys(accounts).find(a => a.toLowerCase() === address);
const account = gotAddress ? accounts[gotAddress] : {};
return { account };
};

View File

@@ -32,14 +32,14 @@ export default class TransactionPendingFormReject extends Component {
return (
<div>
<div className={ styles.rejectText }>
Are you sure you want to reject transaction? <br />
Are you sure you want to reject request? <br />
<strong>This cannot be undone</strong>
</div>
<RaisedButton
onTouchTap={ onReject }
className={ styles.rejectButton }
fullWidth
label={ 'Reject Transaction' }
label={ 'Reject Request' }
/>
</div>
);

View File

@@ -75,7 +75,7 @@ export default class TransactionPendingForm extends Component {
let html;
if (!isRejectOpen) {
html = <span>reject transaction</span>;
html = <span>reject request</span>;
} else {
html = <span><BackIcon />{ "I've changed my mind" }</span>;
}