Disable QR seed import on IPFS (#2979)
This commit is contained in:
parent
5bcba25f35
commit
519af249f3
@ -7,6 +7,7 @@ import { ModalProps } from '../../types';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { AddressRow, Button, Input, InputAddress, Modal } from '@polkadot/react-components';
|
||||
import { useIpfs } from '@polkadot/react-hooks';
|
||||
import { QrScanAddress } from '@polkadot/react-qr';
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
|
||||
@ -26,6 +27,7 @@ interface Props extends ModalProps {
|
||||
|
||||
function QrModal ({ className = '', onClose, onStatusChange }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { isIpfs } = useIpfs();
|
||||
const [{ isNameValid, name }, setName] = useState({ isNameValid: false, name: '' });
|
||||
const [scanned, setScanned] = useState<Scanned | null>(null);
|
||||
const [isAddress, setIsAddress] = useState<boolean>(false);
|
||||
@ -156,7 +158,7 @@ function QrModal ({ className = '', onClose, onStatusChange }: Props): React.Rea
|
||||
<Modal.Actions onCancel={onClose}>
|
||||
<Button
|
||||
icon='sign-in'
|
||||
isDisabled={!scanned || !isValid}
|
||||
isDisabled={!scanned || !isValid || (isAddress && isIpfs)}
|
||||
isPrimary
|
||||
label={t<string>('Create')}
|
||||
onClick={_onSave}
|
||||
|
||||
@ -6,7 +6,7 @@ import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { useAccounts } from '@polkadot/react-hooks';
|
||||
import { useAccounts, useIpfs } from '@polkadot/react-hooks';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
|
||||
import basicMd from './md/basic.md';
|
||||
@ -21,6 +21,7 @@ export { useCounter };
|
||||
function AccountsApp ({ basePath, onStatusChange }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { hasAccounts } = useAccounts();
|
||||
const { isIpfs } = useIpfs();
|
||||
const items = useMemo(() => [
|
||||
{
|
||||
isRoot: true,
|
||||
@ -37,8 +38,8 @@ function AccountsApp ({ basePath, onStatusChange }: Props): React.ReactElement<P
|
||||
}
|
||||
], [t]);
|
||||
const hidden = useMemo(
|
||||
() => hasAccounts ? [] : ['vanity'],
|
||||
[hasAccounts]
|
||||
() => (hasAccounts && !isIpfs) ? [] : ['vanity'],
|
||||
[hasAccounts, isIpfs]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@ -36,13 +36,9 @@ export default function withObservable<T, P> (observable: Observable<P>, { callO
|
||||
observable
|
||||
.pipe(
|
||||
map(transform),
|
||||
catchError((): Observable<any> =>
|
||||
of(undefined)
|
||||
)
|
||||
catchError(() => of(undefined))
|
||||
)
|
||||
.subscribe((value: any): void =>
|
||||
this.triggerUpdate(this.props, value)
|
||||
),
|
||||
.subscribe((value: any) => this.triggerUpdate(this.props, value)),
|
||||
intervalObservable(this)
|
||||
]
|
||||
});
|
||||
@ -61,8 +57,7 @@ export default function withObservable<T, P> (observable: Observable<P>, { callO
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
triggerChange(callResult, callOnResult, (props as any).callOnResult || defaultProps.callOnResult);
|
||||
triggerChange(callResult, callOnResult, (props as Options).callOnResult || defaultProps.callOnResult);
|
||||
|
||||
this.setState({
|
||||
callResult,
|
||||
|
||||
@ -251,7 +251,7 @@ class InputAddress extends React.PureComponent<Props, State> {
|
||||
|
||||
const lastValue = getLastValue(type);
|
||||
|
||||
this.setState({ lastValue });
|
||||
this.setState(() => ({ lastValue }));
|
||||
|
||||
return lastValue;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user