mirror of https://github.com/trezor/trezor-wallet
Merge pull request #625 from trezor/feature/passphrase-redesign
[WIP] Feature/passphrase redesignrelease/1.4.0-beta
commit
bb6a13812b
@ -0,0 +1,43 @@
|
|||||||
|
/* @flow */
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { H5, P, colors } from 'trezor-ui-components';
|
||||||
|
import DeviceIcon from 'components/images/DeviceIcon';
|
||||||
|
|
||||||
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
device: TrezorDevice,
|
||||||
|
};
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
max-width: 360px;
|
||||||
|
padding: 30px 48px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledDeviceIcon = styled(DeviceIcon)`
|
||||||
|
margin-bottom: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Header = styled.div``;
|
||||||
|
|
||||||
|
const PassphraseType = (props: Props) => (
|
||||||
|
<Wrapper>
|
||||||
|
<Header>
|
||||||
|
<StyledDeviceIcon device={props.device} size={32} color={colors.TEXT_SECONDARY} />
|
||||||
|
<H5>Enter passphrase on {props.device.label} device</H5>
|
||||||
|
<P size="small">
|
||||||
|
If you enter a wrong passphrase, you will not unlock the desired hidden wallet.
|
||||||
|
</P>
|
||||||
|
</Header>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
PassphraseType.propTypes = {
|
||||||
|
device: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PassphraseType;
|
@ -1,58 +0,0 @@
|
|||||||
/* @flow */
|
|
||||||
|
|
||||||
declare module 'bignumber.js' {
|
|
||||||
declare type $npm$big$number$object = number | string | T_BigNumber
|
|
||||||
declare type $npm$cmp$result = -1 | 0 | 1
|
|
||||||
declare type DIGIT = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
||||||
declare type ROUND_DOWN = 0
|
|
||||||
declare type ROUND_HALF_UP = 1
|
|
||||||
declare type ROUND_HALF_EVEN = 2
|
|
||||||
declare type ROUND_UP = 3
|
|
||||||
declare type RM = ROUND_DOWN | ROUND_HALF_UP | ROUND_HALF_EVEN | ROUND_UP
|
|
||||||
|
|
||||||
declare class T_BigNumber {
|
|
||||||
// Properties
|
|
||||||
static DP: number;
|
|
||||||
static RM: RM;
|
|
||||||
static E_NEG: number;
|
|
||||||
static E_POS: number;
|
|
||||||
|
|
||||||
c: Array<DIGIT>;
|
|
||||||
e: number;
|
|
||||||
s: -1 | 1;
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
static (value: $npm$big$number$object): T_BigNumber;
|
|
||||||
constructor(value: $npm$big$number$object): T_BigNumber;
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
abs(): T_BigNumber;
|
|
||||||
div(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
dividedBy(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
eq(n: $npm$big$number$object): boolean;
|
|
||||||
gt(n: $npm$big$number$object): boolean;
|
|
||||||
isGreaterThan(n: $npm$big$number$object): boolean;
|
|
||||||
gte(n: $npm$big$number$object): boolean;
|
|
||||||
lt(n: $npm$big$number$object): boolean;
|
|
||||||
isLessThan(n: $npm$big$number$object): boolean;
|
|
||||||
lte(n: $npm$big$number$object): boolean;
|
|
||||||
isLessThanOrEqualTo(n: $npm$big$number$object): boolean;
|
|
||||||
isNaN(): boolean;
|
|
||||||
minus(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
mod(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
plus(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
pow(exp: number): BigNumber;
|
|
||||||
sqrt(): T_BigNumber;
|
|
||||||
times(n: $npm$big$number$object): T_BigNumber;
|
|
||||||
toExponential(dp: ?number): string;
|
|
||||||
toFixed(dp: ?number): string;
|
|
||||||
toPrecision(sd: ?number): string;
|
|
||||||
toString(format?: number): string;
|
|
||||||
toNumber(): number;
|
|
||||||
valueOf(): string;
|
|
||||||
toJSON(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//declare module.exports: typeof T_BigNumber
|
|
||||||
declare export default typeof T_BigNumber;
|
|
||||||
}
|
|
@ -0,0 +1,114 @@
|
|||||||
|
/* @flow */
|
||||||
|
import { toDecimalAmount } from 'utils/formatUtils';
|
||||||
|
import type { AccountInfo, AccountTransaction } from 'trezor-connect';
|
||||||
|
import type { Account, Transaction, Network, TrezorDevice } from 'flowtype';
|
||||||
|
|
||||||
|
// Merge fresh AccountInfo into existing Account
|
||||||
|
export const mergeAccount = (
|
||||||
|
info: AccountInfo,
|
||||||
|
account: Account,
|
||||||
|
network: Network,
|
||||||
|
block: number
|
||||||
|
): Account => {
|
||||||
|
if (account.networkType === 'ethereum') {
|
||||||
|
const nonce = info.misc && info.misc.nonce ? info.misc.nonce : '0';
|
||||||
|
return {
|
||||||
|
networkType: 'ethereum',
|
||||||
|
...account,
|
||||||
|
balance: toDecimalAmount(info.balance, network.decimals),
|
||||||
|
availableBalance: toDecimalAmount(info.availableBalance, network.decimals),
|
||||||
|
block,
|
||||||
|
transactions: info.history.total,
|
||||||
|
empty: account.empty,
|
||||||
|
nonce,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account.networkType === 'ripple') {
|
||||||
|
const sequence = info.misc && info.misc.sequence ? info.misc.sequence : 0;
|
||||||
|
const reserve = info.misc && info.misc.reserve ? info.misc.reserve : '0';
|
||||||
|
return {
|
||||||
|
...account,
|
||||||
|
balance: toDecimalAmount(info.balance, network.decimals),
|
||||||
|
availableBalance: toDecimalAmount(info.availableBalance, network.decimals),
|
||||||
|
block,
|
||||||
|
empty: info.empty,
|
||||||
|
|
||||||
|
networkType: 'ripple',
|
||||||
|
sequence,
|
||||||
|
reserve: toDecimalAmount(reserve || '0', network.decimals),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return account;
|
||||||
|
};
|
||||||
|
|
||||||
|
type EnhanceAccountOptions = {
|
||||||
|
index: number,
|
||||||
|
network: Network,
|
||||||
|
device: TrezorDevice,
|
||||||
|
imported?: boolean,
|
||||||
|
block?: number,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create Account from AccountInfo
|
||||||
|
export const enhanceAccount = (account: AccountInfo, options: EnhanceAccountOptions): Account => {
|
||||||
|
if (options.network.type === 'ethereum') {
|
||||||
|
const nonce = account.misc && account.misc.nonce ? account.misc.nonce : '0';
|
||||||
|
return {
|
||||||
|
imported: !!options.imported,
|
||||||
|
index: options.index,
|
||||||
|
network: options.network.shortcut,
|
||||||
|
deviceID: options.device.id || '0',
|
||||||
|
deviceState: options.device.state || '0',
|
||||||
|
accountPath: account.path,
|
||||||
|
descriptor: account.descriptor,
|
||||||
|
|
||||||
|
balance: toDecimalAmount(account.balance, options.network.decimals),
|
||||||
|
availableBalance: toDecimalAmount(account.availableBalance, options.network.decimals),
|
||||||
|
block: options.block || 0,
|
||||||
|
transactions: account.history.total,
|
||||||
|
empty: account.empty,
|
||||||
|
|
||||||
|
networkType: 'ethereum',
|
||||||
|
nonce,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const sequence = account.misc && account.misc.sequence ? account.misc.sequence : 0;
|
||||||
|
const reserve = account.misc && account.misc.reserve ? account.misc.reserve : '0';
|
||||||
|
return {
|
||||||
|
imported: !!options.imported,
|
||||||
|
index: options.index,
|
||||||
|
network: options.network.shortcut,
|
||||||
|
deviceID: options.device.id || '0',
|
||||||
|
deviceState: options.device.state || '0',
|
||||||
|
accountPath: account.path,
|
||||||
|
descriptor: account.descriptor,
|
||||||
|
|
||||||
|
balance: toDecimalAmount(account.balance, options.network.decimals),
|
||||||
|
availableBalance: toDecimalAmount(account.availableBalance, options.network.decimals),
|
||||||
|
block: options.block || 0,
|
||||||
|
transactions: 0,
|
||||||
|
empty: account.empty,
|
||||||
|
|
||||||
|
networkType: 'ripple',
|
||||||
|
sequence,
|
||||||
|
reserve: toDecimalAmount(reserve, options.network.decimals),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const enhanceTransaction = (
|
||||||
|
account: Account,
|
||||||
|
tx: AccountTransaction,
|
||||||
|
network: Network
|
||||||
|
): Transaction => {
|
||||||
|
return {
|
||||||
|
...tx,
|
||||||
|
descriptor: account.descriptor,
|
||||||
|
deviceState: account.deviceState,
|
||||||
|
network: account.network,
|
||||||
|
amount: toDecimalAmount(tx.amount, network.decimals),
|
||||||
|
fee: toDecimalAmount(tx.fee, network.decimals),
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in new issue