feat(confirmations): add confirmed flaf
- add confirmed flag - add confirmations number in transactions list
This commit is contained in:
parent
23bc7ad3a6
commit
7ca6f2b3e3
|
@ -36,6 +36,8 @@ describe('<TransactionItem />', () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<ThemeProvider theme={appTheme}>
|
<ThemeProvider theme={appTheme}>
|
||||||
<TransactionItemComponent
|
<TransactionItemComponent
|
||||||
|
confirmed
|
||||||
|
confirmations={10}
|
||||||
type='send'
|
type='send'
|
||||||
address='123456789123456789123456789123456789'
|
address='123456789123456789123456789123456789'
|
||||||
transactionId='a0s9dujo23j0'
|
transactionId='a0s9dujo23j0'
|
||||||
|
|
|
@ -49,6 +49,8 @@ describe('<TransactionDailyComponent />', () => {
|
||||||
date: '2019-02-20T19:31:57.117Z',
|
date: '2019-02-20T19:31:57.117Z',
|
||||||
theme: appTheme,
|
theme: appTheme,
|
||||||
fees: 0.001,
|
fees: 0.001,
|
||||||
|
confirmations: 10,
|
||||||
|
confirmed: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'send',
|
type: 'send',
|
||||||
|
@ -59,6 +61,8 @@ describe('<TransactionDailyComponent />', () => {
|
||||||
date: '2019-02-20T19:31:57.117Z',
|
date: '2019-02-20T19:31:57.117Z',
|
||||||
theme: appTheme,
|
theme: appTheme,
|
||||||
fees: 0.001,
|
fees: 0.001,
|
||||||
|
confirmed: false,
|
||||||
|
confirmations: 3,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -38,21 +38,25 @@ export const TransactionDailyComponent = ({ transactionsDate, transactions, zecP
|
||||||
<Wrapper data-testid='TransactionsDaily'>
|
<Wrapper data-testid='TransactionsDaily'>
|
||||||
<Day value={transactionsDate} />
|
<Day value={transactionsDate} />
|
||||||
<TransactionsWrapper>
|
<TransactionsWrapper>
|
||||||
{transactions.map(({
|
{transactions.map(
|
||||||
date, type, address, amount, transactionId, fees,
|
({
|
||||||
}) => (
|
date, type, address, amount, transactionId, fees, confirmed, confirmations,
|
||||||
<Fragment key={`${address}-${type}-${amount}-${date}`}>
|
}) => (
|
||||||
<TransactionItemComponent
|
<Fragment key={`${address}-${type}-${amount}-${date}`}>
|
||||||
transactionId={transactionId}
|
<TransactionItemComponent
|
||||||
type={type}
|
confirmations={confirmations}
|
||||||
date={date}
|
confirmed={confirmed}
|
||||||
address={address || 'N/A'}
|
transactionId={transactionId}
|
||||||
amount={amount}
|
type={type}
|
||||||
zecPrice={zecPrice}
|
date={date}
|
||||||
fees={fees}
|
address={address || 'N/A'}
|
||||||
/>
|
amount={amount}
|
||||||
</Fragment>
|
zecPrice={zecPrice}
|
||||||
))}
|
fees={fees}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
|
),
|
||||||
|
)}
|
||||||
</TransactionsWrapper>
|
</TransactionsWrapper>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|
|
@ -71,6 +71,8 @@ const TransactionColumn = styled(ColumnComponent)`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export type Transaction = {
|
export type Transaction = {
|
||||||
|
confirmed: boolean, // eslint-disable-line
|
||||||
|
confirmations: number, // eslint-disable-line
|
||||||
type: 'send' | 'receive',
|
type: 'send' | 'receive',
|
||||||
date: string,
|
date: string,
|
||||||
address: string,
|
address: string,
|
||||||
|
@ -82,6 +84,8 @@ export type Transaction = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Component = ({
|
const Component = ({
|
||||||
|
// confirmed,
|
||||||
|
// confirmations,
|
||||||
type,
|
type,
|
||||||
date,
|
date,
|
||||||
address,
|
address,
|
||||||
|
|
|
@ -8,3 +8,5 @@ export const TESTNET = 'TESTNET';
|
||||||
|
|
||||||
export const SPROUT = 'sprout';
|
export const SPROUT = 'sprout';
|
||||||
export const SAPLING = 'sapling';
|
export const SAPLING = 'sapling';
|
||||||
|
|
||||||
|
export const MIN_CONFIRMATIONS_NUMBER = 12;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { DashboardView } from '../views/dashboard';
|
||||||
|
|
||||||
import rpc from '../../services/api';
|
import rpc from '../../services/api';
|
||||||
import store from '../../config/electron-store';
|
import store from '../../config/electron-store';
|
||||||
import { SAPLING } from '../constants/zcash-network';
|
import { SAPLING, MIN_CONFIRMATIONS_NUMBER } from '../constants/zcash-network';
|
||||||
import { listShieldedTransactions } from '../../services/shielded-transactions';
|
import { listShieldedTransactions } from '../../services/shielded-transactions';
|
||||||
import { sortByDescend } from '../utils/sort-by-descend';
|
import { sortByDescend } from '../utils/sort-by-descend';
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
|
||||||
|
|
||||||
const formattedTransactions: Array<Object> = flow([
|
const formattedTransactions: Array<Object> = flow([
|
||||||
arr => arr.map(transaction => ({
|
arr => arr.map(transaction => ({
|
||||||
|
confirmed: transaction.confirmations >= MIN_CONFIRMATIONS_NUMBER,
|
||||||
|
confirmations: transaction.confirmations,
|
||||||
transactionId: transaction.txid,
|
transactionId: transaction.txid,
|
||||||
type: transaction.category,
|
type: transaction.category,
|
||||||
date: new Date(transaction.time * 1000).toISOString(),
|
date: new Date(transaction.time * 1000).toISOString(),
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
import rpc from '../../services/api';
|
import rpc from '../../services/api';
|
||||||
import { listShieldedTransactions } from '../../services/shielded-transactions';
|
import { listShieldedTransactions } from '../../services/shielded-transactions';
|
||||||
import store from '../../config/electron-store';
|
import store from '../../config/electron-store';
|
||||||
|
import { MIN_CONFIRMATIONS_NUMBER } from '../constants/zcash-network';
|
||||||
|
|
||||||
import { sortByDescend } from '../utils/sort-by-descend';
|
import { sortByDescend } from '../utils/sort-by-descend';
|
||||||
|
|
||||||
|
@ -64,6 +65,11 @@ const mapDispatchToProps = (dispatch: Dispatch): MapDispatchToProps => ({
|
||||||
...transactions,
|
...transactions,
|
||||||
...listShieldedTransactions({ count, offset: shieldedTransactionsCount }),
|
...listShieldedTransactions({ count, offset: shieldedTransactionsCount }),
|
||||||
].map(transaction => ({
|
].map(transaction => ({
|
||||||
|
confirmations: transaction.confirmations !== undefined ? transaction.confirmations : 0,
|
||||||
|
confirmed:
|
||||||
|
transaction.confirmations !== undefined
|
||||||
|
? transaction.confirmations >= MIN_CONFIRMATIONS_NUMBER
|
||||||
|
: true,
|
||||||
transactionId: transaction.txid,
|
transactionId: transaction.txid,
|
||||||
type: transaction.category,
|
type: transaction.category,
|
||||||
date: new Date(transaction.time * 1000).toISOString(),
|
date: new Date(transaction.time * 1000).toISOString(),
|
||||||
|
|
|
@ -37,8 +37,7 @@ const RoundedTransactionWrapper = styled.div`
|
||||||
: `
|
: `
|
||||||
border-bottom-left-radius: ${props.theme.boxBorderRadius};
|
border-bottom-left-radius: ${props.theme.boxBorderRadius};
|
||||||
border-bottom-right-radius: ${props.theme.boxBorderRadius};
|
border-bottom-right-radius: ${props.theme.boxBorderRadius};
|
||||||
`
|
`)}
|
||||||
)}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ListWrapper = styled.div`
|
const ListWrapper = styled.div`
|
||||||
|
@ -109,6 +108,8 @@ export class TransactionsView extends PureComponent<Props> {
|
||||||
nextTransactionDate: nextTransaction ? new Date(nextTransaction.date) : null,
|
nextTransactionDate: nextTransaction ? new Date(nextTransaction.date) : null,
|
||||||
component: (
|
component: (
|
||||||
<TransactionItemComponent
|
<TransactionItemComponent
|
||||||
|
confirmed={transaction.confirmed}
|
||||||
|
confirmations={transaction.confirmations}
|
||||||
address={transaction.address}
|
address={transaction.address}
|
||||||
amount={transaction.amount}
|
amount={transaction.amount}
|
||||||
fees={transaction.fees}
|
fees={transaction.fees}
|
||||||
|
@ -136,14 +137,9 @@ export class TransactionsView extends PureComponent<Props> {
|
||||||
return transactionItem;
|
return transactionItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
renderRow = (
|
renderRow = ({ index, key, style }: { index: number, key: string, style: Object }) => (
|
||||||
{ index, key, style }: { index: number, key: string, style: Object },
|
|
||||||
) => (
|
|
||||||
<div key={key} style={style}>
|
<div key={key} style={style}>
|
||||||
{this.isRowLoaded({ index })
|
{this.isRowLoaded({ index }) ? this.renderTransactions({ index }) : 'Loading...'}
|
||||||
? this.renderTransactions({ index })
|
|
||||||
: 'Loading...'
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ export type APIMethods = {
|
||||||
bytes: string,
|
bytes: string,
|
||||||
usage: string,
|
usage: string,
|
||||||
}>,
|
}>,
|
||||||
getrawmempool: () => Promise<string>,
|
getrawmempool: (verbose?: number) => Promise<string[]>,
|
||||||
gettxout: (
|
gettxout: (
|
||||||
txid: string,
|
txid: string,
|
||||||
n: number,
|
n: number,
|
||||||
|
|
Loading…
Reference in New Issue