You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/components/notifications/Context/components/Static/index.js

83 lines
3.1 KiB

6 years ago
/* @flow */
import * as React from 'react';
import { Notification, Link } from 'trezor-ui-components';
5 years ago
import Bignumber from 'bignumber.js';
import { FormattedMessage } from 'react-intl';
5 years ago
import { withRouter } from 'react-router-dom';
import l10nCommonMessages from 'views/common.messages';
5 years ago
import { matchPath } from 'react-router';
import { getPattern } from 'support/routes';
import l10nMessages from './index.messages';
6 years ago
import type { Props } from '../../index';
5 years ago
export default withRouter((props: Props) => {
const { selectedAccount } = props;
const { account } = selectedAccount;
6 years ago
const { location } = props.router;
5 years ago
const notifications = [];
5 years ago
if (!location) return null;
// Ripple minimum reserve notification
5 years ago
if (selectedAccount && account && account.networkType === 'ripple') {
const { reserve, balance } = account;
const bigBalance = new Bignumber(balance);
const bigReserve = new Bignumber(reserve);
if (bigBalance.isLessThan(bigReserve)) {
notifications.push(
<Notification
key="xrp-warning"
type="warning"
5 years ago
title={
<FormattedMessage {...l10nMessages.TR_MINIMUM_ACCOUNT_RESERVE_REQUIRED} />
5 years ago
}
message={
<>
<FormattedMessage
{...l10nMessages.TR_RIPPLE_ADDRESSES_REQUIRE_MINIMUM_BALANCE}
values={{
minBalance: bigReserve.toString(),
TR_LEARN_MORE: (
<Link isGreen href="https://wiki.trezor.io/Ripple_(XRP)">
5 years ago
<FormattedMessage
{...l10nCommonMessages.TR_LEARN_MORE}
/>
</Link>
),
}}
/>
</>
5 years ago
}
/>
);
}
}
6 years ago
5 years ago
// Import tool notification
if (matchPath(location.pathname, { path: getPattern('wallet-import') })) {
notifications.push(
<Notification
key="import-warning"
type="warning"
title="Use at your own risk"
message="This is an advanced interface intended for developer use only. Never use this process unless you really know what you are doing."
/>
);
}
if (account && account.imported) {
notifications.push(
<Notification
key="watch-only-info"
type="info"
title="The account is watch-only"
message="A watch-only account is a public address youve imported into your wallet, allowing the wallet to watch for outputs but not spend them."
/>
);
}
5 years ago
return <React.Fragment>{notifications}</React.Fragment>;
5 years ago
});