Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wallet displays some extra transactions - Closes #278 #297

Merged
merged 3 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/components/accountTransactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ class accountTransactions extends React.Component {
<Send/>
</div>
<div className={`${grid['col-sm-12']} ${styles.transactions} ${grid['col-md-8']}`}>
<Transactions address={this.props.match.params.address} />
<Transactions
address={this.props.match.params.address}
balance={this.props.balance} />
</div>
</div>;
}
}

const mapStateToProps = state => ({
balance: state.transactions.account ? state.transactions.account.balance : null,
});

const mapDispatchToProps = dispatch => ({
transactionsRequestInit: data => dispatch(transactionsRequestInit(data)),
});


export default connect(null, mapDispatchToProps)(translate()(accountTransactions));
export default connect(mapStateToProps, mapDispatchToProps)(translate()(accountTransactions));
4 changes: 2 additions & 2 deletions src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Login from '../login';
import Register from '../register';
import Search from '../search';
import TransactionDashboard from '../transactionDashboard';
import accountTransactions from '../accountTransactions';
import AccountTransactions from '../accountTransactions';
import Voting from '../voting';
import Forging from '../forging';
import SingleTransaction from './../singleTransaction';
Expand Down Expand Up @@ -49,7 +49,7 @@ const App = () => (
<Route path='/explorer' render={ ({ match }) => (
<main>
<Route path={`${match.url}${routes.search.short}/:dialog?`} component={Search} />
<Route path={`${match.url}${routes.account.short}/:address?`} component={accountTransactions} />
<Route path={`${match.url}${routes.account.short}/:address?`} component={AccountTransactions} />
<Route path={`${match.url}${routes.transaction.short}/:id`} component={SingleTransaction} />
</main>
)} />
Expand Down
5 changes: 3 additions & 2 deletions src/components/transactionDashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ class TransactionsDashboard extends React.Component {
<Send/>
</div>
<div className={`${grid['col-sm-12']} ${styles.transactions} ${grid['col-md-8']}`}>
<Transactions address={this.props.accountAddress} />
<Transactions {...this.props} />
</div>
</div>;
}
}

const mapStateToProps = state => ({
accountAddress: state.account.address,
address: state.account.address,
balance: state.account.balance,
});

export default connect(mapStateToProps)(TransactionsDashboard);
2 changes: 0 additions & 2 deletions src/components/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { transactionsRequested, transactionsFilterSet } from '../../actions/tran
import Transactions from './transactions';

const mapStateToProps = state => ({
balance: state.transactions.account ? state.transactions.account.balance : null,
accountAddress: state.account.address,
activePeer: state.peers.data,
transactions: [...state.transactions.pending, ...state.transactions.confirmed],
count: state.transactions.count,
Expand Down
1 change: 0 additions & 1 deletion src/components/transactions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('TransactionsHOC', () => {

it('should mount Transactions with appropriate properties', () => {
const props = wrapper.find('Transactions').first().props();
expect(props.accountAddress).to.be.equal(account.address);
expect(props.activePeer).to.be.equal(peers.data);
expect(props.transactions).to.deep.equal([...transactions, ...pending]);
expect(props.count).to.be.equal(transactions.count);
Expand Down
16 changes: 9 additions & 7 deletions src/store/middlewares/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import transactionTypes from '../../constants/transactionTypes';
const { lockDuration } = accountConfig;

const updateTransactions = (store, peers) => {
const filter = store.getState().transactions.filter;
const address = store.getState().transactions.address;
getTransactions({ activePeer: peers.data, address, limit: 25, filter })
.then(response => store.dispatch(transactionsUpdated({
confirmed: response.transactions,
count: parseInt(response.count, 10),
})));
const state = store.getState();
const { filter } = state.transactions;
const address = state.transactions.address ? state.transactions.address : state.account.address;
getTransactions({
activePeer: peers.data, address, limit: 25, filter,
}).then(response => store.dispatch(transactionsUpdated({
confirmed: response.transactions,
count: parseInt(response.count, 10),
})));
};

const hasRecentTransactions = txs => (
Expand Down