implementation on selectedAccount.pending

pull/2/merge
Szymon Lesisz 6 years ago
parent 7b639fb223
commit 43ddffb6e9

@ -151,6 +151,8 @@ export const calculate = (prevProps: Props, props: Props) => {
const { const {
account, account,
tokens,
pending,
} = props.selectedAccount; } = props.selectedAccount;
if (!account) return; if (!account) return;
@ -171,13 +173,13 @@ export const calculate = (prevProps: Props, props: Props) => {
if (state.setMax) { if (state.setMax) {
const pendingAmount = props.pending.reduce((value, p) => { const pendingAmount = pending.reduce((value, p) => {
//if (p.tx.amount) //if (p.tx.amount)
console.warn("PENDING AMOUNT!", p, value); console.warn("PENDING AMOUNT!", p, value);
}, 0); }, 0);
if (isToken) { 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) { if (token) {
state.amount = token.balance; state.amount = token.balance;
} }

@ -8,15 +8,13 @@ import ScaleText from 'react-scale-text';
import { findAccountTokens } from '~/js/reducers/TokensReducer'; import { findAccountTokens } from '~/js/reducers/TokensReducer';
import type { Coin } from '~/js/reducers/LocalStorageReducer'; import type { Coin } from '~/js/reducers/LocalStorageReducer';
import type { Account } from '~/js/reducers/AccountsReducer';
import type { Token } from '~/js/reducers/TokensReducer'; import type { Token } from '~/js/reducers/TokensReducer';
import type { Props as BaseProps } from './index'; import type { Props as BaseProps } from './index';
type Props = { type Props = {
pending: $ElementType<BaseProps, 'pending'>, pending: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'pending'>,
tokens: $ElementType<BaseProps, 'tokens'>, tokens: $PropertyType<$ElementType<BaseProps, 'selectedAccount'>, 'tokens'>,
account: Account, network: Coin
selectedCoin: Coin
} }
type Style = { type Style = {
@ -27,12 +25,11 @@ type Style = {
const PendingTransactions = (props: Props) => { const PendingTransactions = (props: Props) => {
const account = props.account; const pending = props.pending;
const pending = props.pending.filter(p => p.network === account.network && p.address === account.address);
if (pending.length < 1) return null; 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 bgColorFactory = new ColorHash({lightness: 0.7});
const textColorFactory = new ColorHash(); const textColorFactory = new ColorHash();
@ -42,7 +39,7 @@ const PendingTransactions = (props: Props) => {
let iconColor: Style; let iconColor: Style;
let symbol: string; let symbol: string;
let name: string; let name: string;
const isSmartContractTx: boolean = tx.currency !== props.selectedCoin.symbol; const isSmartContractTx: boolean = tx.currency !== props.network.symbol;
if (isSmartContractTx) { if (isSmartContractTx) {
const token: ?Token = tokens.find(t => t.symbol === tx.currency); const token: ?Token = tokens.find(t => t.symbol === tx.currency);
if (!token) { if (!token) {
@ -69,8 +66,8 @@ const PendingTransactions = (props: Props) => {
background: bgColorFactory.hex(tx.network), background: bgColorFactory.hex(tx.network),
borderColor: bgColorFactory.hex(tx.network) borderColor: bgColorFactory.hex(tx.network)
} }
symbol = props.selectedCoin.symbol; symbol = props.network.symbol;
name = props.selectedCoin.name; name = props.network.name;
} }
return ( return (
@ -81,7 +78,7 @@ const PendingTransactions = (props: Props) => {
</div> </div>
</div> </div>
<div className="name"> <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>
<div className="amount">{ tx.amount } { symbol }</div> <div className="amount">{ tx.amount } { symbol }</div>
</div> </div>

@ -45,7 +45,6 @@ const Send = (props: Props) => {
if (!device || !account || !discovery || !network) return null; if (!device || !account || !discovery || !network) return null;
const { const {
address, address,
amount, amount,
@ -192,10 +191,9 @@ const Send = (props: Props) => {
</AdvancedForm> </AdvancedForm>
<PendingTransactions <PendingTransactions
pending={ props.pending } pending={ props.selectedAccount.pending }
tokens={ props.tokens } tokens={ props.selectedAccount.tokens }
account={ account } network={ network } />
selectedCoin={ network } />
</section> </section>
); );

@ -15,8 +15,6 @@ import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps }
type OwnProps = { } type OwnProps = { }
export type StateProps = BaseStateProps & { export type StateProps = BaseStateProps & {
tokens: $ElementType<State, 'tokens'>,
pending: $ElementType<State, 'pending'>,
sendForm: $ElementType<State, 'sendForm'>, sendForm: $ElementType<State, 'sendForm'>,
fiat: $ElementType<State, 'fiat'>, fiat: $ElementType<State, 'fiat'>,
localStorage: $ElementType<State, 'localStorage'>, localStorage: $ElementType<State, 'localStorage'>,
@ -35,8 +33,6 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
selectedAccount: state.selectedAccount, selectedAccount: state.selectedAccount,
wallet: state.wallet, wallet: state.wallet,
tokens: state.tokens,
pending: state.pending,
sendForm: state.sendForm, sendForm: state.sendForm,
fiat: state.fiat, fiat: state.fiat,
localStorage: state.localStorage localStorage: state.localStorage

Loading…
Cancel
Save