Skip to content

Commit

Permalink
feat: display account address qr code
Browse files Browse the repository at this point in the history
  • Loading branch information
anukulpandey committed Dec 6, 2023
1 parent 78b6045 commit 6037578
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/extension-ui/src/Popup/Accounts/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ function Account ({ address, className, genesisHash, hideBalance, isExternal, is
{t<string>('Export Account')}
</Link>
)}
{!isExternal && (
<Link
className='menuItem'
isDanger
to={`/account/account-qr/${address}`}
>
{t<string>('Show Account Address')}
</Link>
)}
{!isExternal && (
<Link
className='menuItem'
Expand Down
76 changes: 76 additions & 0 deletions packages/extension-ui/src/Popup/AddressQr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2019-2021 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { ThemeProps } from '../types';

import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { faTimes } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { useCallback, useContext } from 'react';
import { RouteComponentProps, withRouter } from 'react-router';
import styled from 'styled-components';

import { ActionContext, Address, VerticalSpace, } from '../components';

Check failure on line 13 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma

Check failure on line 13 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Multiple spaces found before '}'

Check failure on line 13 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma

Check failure on line 13 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Multiple spaces found before '}'
import useTranslation from '../hooks/useTranslation';
import { Header } from '../partials';
import QRCodeComponent from '../partials/QrCodeComponent';


Check failure on line 18 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 18 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
interface Props extends RouteComponentProps<{address: string}>, ThemeProps {
className?: string;
}

function AddressQr ({ className, match: { params: { address } } }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const onAction = useContext(ActionContext);

const _goHome = useCallback(
() => onAction('/'),
[onAction]
);


Check failure on line 32 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 32 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
return (
<>
<Header
showLogo
text={t<string>('Account QR')}>
<div className='steps'>
<button
className='popup__close-btn'
type='button'
onClick={_goHome}>
<FontAwesomeIcon
className='popup__close-btn-icon'
icon={faTimes as IconProp}
title='Close'
/>
</button>
</div>
</Header>
<div className={className}>
<Address

Check failure on line 52 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 6

Check failure on line 52 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 8 spaces but found 6
address={address}
exporting
presentation
>
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>

Check failure on line 57 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 11

Check failure on line 57 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 11
<QRCodeComponent value={address} size={256}/>

Check failure on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 12 spaces but found 8

Check warning on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Prop `size` must be placed on a new line

Check failure on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

A space is required before closing bracket

Check failure on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 12 spaces but found 8

Check warning on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Prop `size` must be placed on a new line

Check failure on line 58 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

A space is required before closing bracket
</div>

Check failure on line 59 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 8

Check failure on line 59 in packages/extension-ui/src/Popup/AddressQr.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 8
</Address>
</div>
<VerticalSpace />
</>
);
}

export default withRouter(styled(AddressQr)`
margin-top: 15px;
.actionArea {
padding: 10px 24px;
}
.movedWarning {
margin-top: 8px;
}
`);
6 changes: 5 additions & 1 deletion packages/extension-ui/src/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import PhishingDetected from './PhishingDetected';
import RestoreJson from './RestoreJson';
import Signing from './Signing';
import Welcome from './Welcome';
import AddressQr from './AddressQr';

const startSettings = uiSettings.get();

Expand Down Expand Up @@ -194,7 +195,10 @@ export default function Popup (): React.ReactElement {
<Route path='/account/create'>{wrapWithErrorBoundary(<CreateAccount />, 'account-creation')}</Route>
<Route path='/account/forget/:address'>{wrapWithErrorBoundary(<Forget />, 'forget-address')}</Route>
<Route path='/account/export/:address'>{wrapWithErrorBoundary(<Export />, 'export-address')}</Route>
<Route path='/account/export-qr/:address'>{wrapWithErrorBoundary(<ExportQr />, 'export-qr-address')}</Route>
<Route path='/account/export-qr/:address'>{wrapWithErrorBoundary(<ExportQr />, 'export-qr-address')}
</Route>
<Route path='/account/account-qr/:address'>{wrapWithErrorBoundary(<AddressQr />, 'export-address-qr')}
</Route>
<Route path='/account/export-all'>{wrapWithErrorBoundary(<ExportAll />, 'export-all-address')}</Route>
<Route path='/account/import-ledger'>{wrapWithErrorBoundary(<ImportLedger />, 'import-ledger')}</Route>
<Route path='/account/import-qr'>{wrapWithErrorBoundary(<ImportQr />, 'import-qr')}</Route>
Expand Down
3 changes: 2 additions & 1 deletion packages/extension-ui/src/partials/QrCodeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const QRCodeComponent: React.FC<QRCodeProps> = ({ size = 384, value }) => {
justifyContent: 'center',
alignItems: 'center',
background: 'white',
padding: '10px' }}>
padding: '10px' ,
borderRadius:'10px'}}>
<QRCode
value={value}
size={size}
Expand Down
5 changes: 4 additions & 1 deletion packages/extension/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,8 @@
"Create account": "",
"Or import .": "",
"You currently don't have any accounts. Create your first account to get started. Or import if you already have an account.": "",
"Export Account using QR": ""
"Export Account using QR": "",
"Show Account Address QR": "",
"Show Account Address": "",
"Account QR": ""
}

0 comments on commit 6037578

Please sign in to comment.