mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 01:08:27 +00:00
implementation on selectedAccount.pending
This commit is contained in:
parent
7b639fb223
commit
43ddffb6e9
@ -151,6 +151,8 @@ export const calculate = (prevProps: Props, props: Props) => {
|
||||
|
||||
const {
|
||||
account,
|
||||
tokens,
|
||||
pending,
|
||||
} = props.selectedAccount;
|
||||
if (!account) return;
|
||||
|
||||
@ -171,13 +173,13 @@ export const calculate = (prevProps: Props, props: Props) => {
|
||||
|
||||
if (state.setMax) {
|
||||
|
||||
const pendingAmount = props.pending.reduce((value, p) => {
|
||||
const pendingAmount = pending.reduce((value, p) => {
|
||||
//if (p.tx.amount)
|
||||
console.warn("PENDING AMOUNT!", p, value);
|
||||
}, 0);
|
||||
|
||||
if (isToken) {
|
||||
const token: ?Token = findToken(props.tokens, account.address, state.currency, account.deviceState);
|
||||
const token: ?Token = findToken(tokens, account.address, state.currency, account.deviceState);
|
||||
if (token) {
|
||||
state.amount = token.balance;
|
||||
}
|
||||
|
@ -8,15 +8,13 @@ import ScaleText from 'react-scale-text';
|
||||
import { findAccountTokens } from '~/js/reducers/TokensReducer';
|
||||
|
||||
import type { Coin } from '~/js/reducers/LocalStorageReducer';
|
||||
import type { Account } from '~/js/reducers/AccountsReducer';
|
||||
import type { Token } from '~/js/reducers/TokensReducer';
|
||||
import type { Props as BaseProps } from './index';
|
||||
|
||||
type Props = {
|
||||
pending: $ElementType<BaseProps, 'pending'>,
|
||||
tokens: $ElementType<BaseProps, 'tokens'>,
|
||||
account: Account,
|
||||
selectedCoin: Coin
|
||||
pending: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'pending'>,
|
||||
tokens: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'tokens'>,
|
||||
network: Coin
|
||||
}
|
||||
|
||||
type Style = {
|
||||
@ -27,12 +25,11 @@ type Style = {
|
||||
|
||||
const PendingTransactions = (props: Props) => {
|
||||
|
||||
const account = props.account;
|
||||
const pending = props.pending.filter(p => p.network === account.network && p.address === account.address);
|
||||
const pending = props.pending;
|
||||
|
||||
if (pending.length < 1) return null;
|
||||
|
||||
const tokens: Array<Token> = findAccountTokens(props.tokens, account);
|
||||
const tokens: Array<Token> = props.tokens;
|
||||
|
||||
const bgColorFactory = new ColorHash({lightness: 0.7});
|
||||
const textColorFactory = new ColorHash();
|
||||
@ -42,7 +39,7 @@ const PendingTransactions = (props: Props) => {
|
||||
let iconColor: Style;
|
||||
let symbol: string;
|
||||
let name: string;
|
||||
const isSmartContractTx: boolean = tx.currency !== props.selectedCoin.symbol;
|
||||
const isSmartContractTx: boolean = tx.currency !== props.network.symbol;
|
||||
if (isSmartContractTx) {
|
||||
const token: ?Token = tokens.find(t => t.symbol === tx.currency);
|
||||
if (!token) {
|
||||
@ -69,8 +66,8 @@ const PendingTransactions = (props: Props) => {
|
||||
background: bgColorFactory.hex(tx.network),
|
||||
borderColor: bgColorFactory.hex(tx.network)
|
||||
}
|
||||
symbol = props.selectedCoin.symbol;
|
||||
name = props.selectedCoin.name;
|
||||
symbol = props.network.symbol;
|
||||
name = props.network.name;
|
||||
}
|
||||
|
||||
return (
|
||||
@ -81,7 +78,7 @@ const PendingTransactions = (props: Props) => {
|
||||
</div>
|
||||
</div>
|
||||
<div className="name">
|
||||
<a href={ `${props.selectedCoin.explorer.tx}${tx.id}`} target="_blank" rel="noreferrer noopener">{ name }</a>
|
||||
<a href={ `${props.network.explorer.tx}${tx.id}`} target="_blank" rel="noreferrer noopener">{ name }</a>
|
||||
</div>
|
||||
<div className="amount">{ tx.amount } { symbol }</div>
|
||||
</div>
|
||||
|
@ -45,7 +45,6 @@ const Send = (props: Props) => {
|
||||
|
||||
if (!device || !account || !discovery || !network) return null;
|
||||
|
||||
|
||||
const {
|
||||
address,
|
||||
amount,
|
||||
@ -192,10 +191,9 @@ const Send = (props: Props) => {
|
||||
</AdvancedForm>
|
||||
|
||||
<PendingTransactions
|
||||
pending={ props.pending }
|
||||
tokens={ props.tokens }
|
||||
account={ account }
|
||||
selectedCoin={ network } />
|
||||
pending={ props.selectedAccount.pending }
|
||||
tokens={ props.selectedAccount.tokens }
|
||||
network={ network } />
|
||||
|
||||
</section>
|
||||
);
|
||||
|
@ -15,8 +15,6 @@ import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps }
|
||||
type OwnProps = { }
|
||||
|
||||
export type StateProps = BaseStateProps & {
|
||||
tokens: $ElementType<State, 'tokens'>,
|
||||
pending: $ElementType<State, 'pending'>,
|
||||
sendForm: $ElementType<State, 'sendForm'>,
|
||||
fiat: $ElementType<State, 'fiat'>,
|
||||
localStorage: $ElementType<State, 'localStorage'>,
|
||||
@ -35,8 +33,6 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
||||
selectedAccount: state.selectedAccount,
|
||||
wallet: state.wallet,
|
||||
|
||||
tokens: state.tokens,
|
||||
pending: state.pending,
|
||||
sendForm: state.sendForm,
|
||||
fiat: state.fiat,
|
||||
localStorage: state.localStorage
|
||||
|
Loading…
Reference in New Issue
Block a user