eth_sign improvements backport (#4473)
* 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. * Make signing compatible with geth. (#4468)
This commit is contained in:
committed by
Arkadiy Paronyan
parent
2bfcfd3813
commit
8c049e5d05
@@ -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) {
|
||||
@@ -78,9 +107,14 @@ export default class SignRequest extends Component {
|
||||
balance={ balance }
|
||||
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>
|
||||
);
|
||||
@@ -91,18 +125,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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user