Merge branch 'master' into ui-2
# Conflicts: # js/src/shell/Signer/components/TransactionPendingFormConfirm/transaction PendingFormConfirm.js # js/src/ui/Container/Title/title.js # js/src/views/Application/Snackbar/snackbar.js # js/src/views/Status/Peers/peers.js
This commit is contained in:
@@ -114,7 +114,7 @@ class DecryptRequest extends Component {
|
||||
}
|
||||
|
||||
renderActions () {
|
||||
const { accounts, address, focus, isFinished, status } = this.props;
|
||||
const { accounts, address, focus, isFinished, status, data } = this.props;
|
||||
const account = accounts[address];
|
||||
|
||||
if (isFinished) {
|
||||
@@ -153,15 +153,16 @@ class DecryptRequest extends Component {
|
||||
onConfirm={ this.onConfirm }
|
||||
onReject={ this.onReject }
|
||||
className={ styles.actions }
|
||||
dataToSign={ { decrypt: data } }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
onConfirm = (data) => {
|
||||
const { id } = this.props;
|
||||
const { password } = data;
|
||||
const { password, decrypted, wallet } = data;
|
||||
|
||||
this.props.onConfirm({ id, password });
|
||||
this.props.onConfirm({ id, password, decrypted, wallet });
|
||||
}
|
||||
|
||||
onReject = () => {
|
||||
|
||||
@@ -40,6 +40,12 @@ const PAYLOAD_SIGN = {
|
||||
const PAYLOAD_SIGNTX = {
|
||||
signTransaction: TRANSACTION
|
||||
};
|
||||
const PAYLOAD_DECRYPT = {
|
||||
decrypt: {
|
||||
address: ADDRESS,
|
||||
msg: 'testing'
|
||||
}
|
||||
};
|
||||
|
||||
let component;
|
||||
let onConfirm;
|
||||
@@ -109,4 +115,18 @@ describe('views/Signer/RequestPending', () => {
|
||||
expect(component.find('Connect(TransactionPending)')).to.have.length(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decrypt', () => {
|
||||
beforeEach(() => {
|
||||
render(PAYLOAD_DECRYPT);
|
||||
});
|
||||
|
||||
it('renders defaults', () => {
|
||||
expect(component).to.be.ok;
|
||||
});
|
||||
|
||||
it('renders DecryptRequest component', () => {
|
||||
expect(component.find('Connect(DecryptRequest)')).to.have.length(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,6 +41,9 @@ export default class TransactionPendingForm extends Component {
|
||||
}),
|
||||
PropTypes.shape({
|
||||
data: PropTypes.string.isRequired
|
||||
}),
|
||||
PropTypes.shape({
|
||||
decrypt: PropTypes.string.isRequired
|
||||
})
|
||||
]).isRequired
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ import ReactTooltip from 'react-tooltip';
|
||||
|
||||
import { Button, Form, Input, IdentityIcon, QrCode, QrScan } from '@parity/ui';
|
||||
|
||||
import { generateTxQr, generateDataQr } from '~/shell/Signer/utils/qrscan';
|
||||
import { generateTxQr, generateDecryptQr, generateDataQr } from '~/shell/Signer/utils/qrscan';
|
||||
|
||||
import styles from './transactionPendingFormConfirm.css';
|
||||
|
||||
@@ -344,7 +344,7 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
return (
|
||||
<QrScan
|
||||
className={ styles.camera }
|
||||
onScan={ this.onScanTx }
|
||||
onScan={ this.onScan }
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -396,8 +396,8 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
onScanTx = (signature) => {
|
||||
const { chainId, rlp, tx, data } = this.state.qr;
|
||||
onScan = (signature) => {
|
||||
const { chainId, rlp, tx, data, decrypt } = this.state.qr;
|
||||
|
||||
if (signature && signature.substr(0, 2) !== '0x') {
|
||||
signature = `0x${signature}`;
|
||||
@@ -417,6 +417,16 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decrypt) {
|
||||
this.props.onConfirm({
|
||||
decrypted: {
|
||||
decrypt,
|
||||
msg: signature
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onConfirm({
|
||||
dataSigned: {
|
||||
data,
|
||||
@@ -491,7 +501,7 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
generateQr = () => {
|
||||
const { api } = this.context;
|
||||
const { netVersion, dataToSign } = this.props;
|
||||
const { transaction, data } = dataToSign;
|
||||
const { transaction, data, decrypt } = dataToSign;
|
||||
const setState = qr => {
|
||||
this.setState({ qr });
|
||||
};
|
||||
@@ -501,6 +511,11 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (decrypt) {
|
||||
generateDecryptQr(decrypt).then(setState);
|
||||
return;
|
||||
}
|
||||
|
||||
generateDataQr(data).then(setState);
|
||||
}
|
||||
|
||||
@@ -539,7 +554,7 @@ export default class TransactionPendingFormConfirm extends Component {
|
||||
const { account, dataToSign } = this.props;
|
||||
const { qr } = this.state;
|
||||
|
||||
if (dataToSign.data && qr && !qr.value) {
|
||||
if ((dataToSign.data || dataToSign.decrypt) && qr && !qr.value) {
|
||||
this.generateQr();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,16 @@ export function generateDataQr (data) {
|
||||
});
|
||||
}
|
||||
|
||||
export function generateDecryptQr (data) {
|
||||
return Promise.resolve({
|
||||
decrypt: data,
|
||||
value: JSON.stringify({
|
||||
action: 'decrypt',
|
||||
data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function generateTxQr (api, netVersion, transaction) {
|
||||
return createUnsignedTx(api, netVersion, transaction)
|
||||
.then((qr) => {
|
||||
|
||||
Reference in New Issue
Block a user