mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 20:57:12 +01:00
a931316a53
* support qr based signer * add CSP for fire fox * get QR Hardware wallet name from device * fix qrHardware state missing in runtime * support qr based signer sign transaction * refine Request Signature modal ui * remove feature toggle * refine ui * fix notification is closing even there is a pending qr hardware transaction * add chinese translation, refine ui, fix qr process was breaking in some case * support import accounts by pubkeys * refine qr-based wallet ui and fix bugs * update @keystonehq/metamask-airgapped-keyring to fix that the signing hd path was inconsistent in some edge case * fix: avoid unnecessay navigation, fix ci * refactor qr-hardware-popover with @zxing/browser * update lavamoat policy, remove firefox CSP * refine qr reader ui, ignore unnecessary warning display * code refactor, use async functions insteads promise Co-authored-by: Soralit <soralitria@gmail.com>
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import React, { useCallback, useState } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { submitQRHardwareSignature } from '../../../../store/actions';
|
|
import Player from './player';
|
|
import Reader from './reader';
|
|
|
|
const QRHardwareSignRequest = ({ request, handleCancel, setErrorTitle }) => {
|
|
const [status, setStatus] = useState('play');
|
|
|
|
const toRead = useCallback(() => setStatus('read'), []);
|
|
|
|
const renderPlayer = () => {
|
|
const { payload } = request;
|
|
return (
|
|
<Player
|
|
type={payload.type}
|
|
cbor={payload.cbor}
|
|
cancelQRHardwareSignRequest={handleCancel}
|
|
toRead={toRead}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const renderReader = () => {
|
|
return (
|
|
<Reader
|
|
cancelQRHardwareSignRequest={handleCancel}
|
|
submitQRHardwareSignature={submitQRHardwareSignature}
|
|
requestId={request.requestId}
|
|
setErrorTitle={setErrorTitle}
|
|
/>
|
|
);
|
|
};
|
|
|
|
if (status === 'play') return renderPlayer();
|
|
return renderReader();
|
|
};
|
|
|
|
QRHardwareSignRequest.propTypes = {
|
|
request: PropTypes.object.isRequired,
|
|
handleCancel: PropTypes.func.isRequired,
|
|
setErrorTitle: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default QRHardwareSignRequest;
|