mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
add number of confirmations to transactions
This commit is contained in:
parent
ef0c7e3ada
commit
c10105872c
5 changed files with 46 additions and 9 deletions
|
@ -8,7 +8,8 @@ import 'package:cw_haven/api/transaction_history.dart';
|
||||||
|
|
||||||
class HavenTransactionInfo extends TransactionInfo {
|
class HavenTransactionInfo extends TransactionInfo {
|
||||||
HavenTransactionInfo(this.id, this.height, this.direction, this.date,
|
HavenTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||||
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee);
|
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
|
||||||
|
this.confirmations);
|
||||||
|
|
||||||
HavenTransactionInfo.fromMap(Map<String, Object> map)
|
HavenTransactionInfo.fromMap(Map<String, Object> map)
|
||||||
: id = (map['hash'] ?? '') as String,
|
: id = (map['hash'] ?? '') as String,
|
||||||
|
@ -22,6 +23,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
amount = map['amount'] as int,
|
amount = map['amount'] as int,
|
||||||
accountIndex = int.parse(map['accountIndex'] as String),
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
addressIndex = map['addressIndex'] as int,
|
addressIndex = map['addressIndex'] as int,
|
||||||
|
confirmations = map['confirmations'] as int,
|
||||||
key = getTxKey((map['hash'] ?? '') as String),
|
key = getTxKey((map['hash'] ?? '') as String),
|
||||||
fee = map['fee'] as int? ?? 0;
|
fee = map['fee'] as int? ?? 0;
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
|
confirmations = row.confirmations,
|
||||||
key = null, //getTxKey(row.getHash()),
|
key = null, //getTxKey(row.getHash()),
|
||||||
fee = row.fee,
|
fee = row.fee,
|
||||||
assetType = row.getAssetType();
|
assetType = row.getAssetType();
|
||||||
|
@ -48,6 +51,7 @@ class HavenTransactionInfo extends TransactionInfo {
|
||||||
final int amount;
|
final int amount;
|
||||||
final int fee;
|
final int fee;
|
||||||
final int addressIndex;
|
final int addressIndex;
|
||||||
|
final int confirmations;
|
||||||
late String recipientAddress;
|
late String recipientAddress;
|
||||||
late String assetType;
|
late String assetType;
|
||||||
String? _fiatAmount;
|
String? _fiatAmount;
|
||||||
|
|
|
@ -8,7 +8,8 @@ import 'package:cw_monero/api/transaction_history.dart';
|
||||||
|
|
||||||
class MoneroTransactionInfo extends TransactionInfo {
|
class MoneroTransactionInfo extends TransactionInfo {
|
||||||
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
|
||||||
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee);
|
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
|
||||||
|
this.confirmations);
|
||||||
|
|
||||||
MoneroTransactionInfo.fromMap(Map<String, Object?> map)
|
MoneroTransactionInfo.fromMap(Map<String, Object?> map)
|
||||||
: id = (map['hash'] ?? '') as String,
|
: id = (map['hash'] ?? '') as String,
|
||||||
|
@ -22,6 +23,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
amount = map['amount'] as int,
|
amount = map['amount'] as int,
|
||||||
accountIndex = int.parse(map['accountIndex'] as String),
|
accountIndex = int.parse(map['accountIndex'] as String),
|
||||||
addressIndex = map['addressIndex'] as int,
|
addressIndex = map['addressIndex'] as int,
|
||||||
|
confirmations = map['confirmations'] as int,
|
||||||
key = getTxKey((map['hash'] ?? '') as String),
|
key = getTxKey((map['hash'] ?? '') as String),
|
||||||
fee = map['fee'] as int ?? 0 {
|
fee = map['fee'] as int ?? 0 {
|
||||||
additionalInfo = <String, dynamic>{
|
additionalInfo = <String, dynamic>{
|
||||||
|
@ -41,6 +43,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
amount = row.getAmount(),
|
amount = row.getAmount(),
|
||||||
accountIndex = row.subaddrAccount,
|
accountIndex = row.subaddrAccount,
|
||||||
addressIndex = row.subaddrIndex,
|
addressIndex = row.subaddrIndex,
|
||||||
|
confirmations = row.confirmations,
|
||||||
key = getTxKey(row.getHash()),
|
key = getTxKey(row.getHash()),
|
||||||
fee = row.fee {
|
fee = row.fee {
|
||||||
additionalInfo = <String, dynamic>{
|
additionalInfo = <String, dynamic>{
|
||||||
|
@ -59,6 +62,7 @@ class MoneroTransactionInfo extends TransactionInfo {
|
||||||
final int amount;
|
final int amount;
|
||||||
final int fee;
|
final int fee;
|
||||||
final int addressIndex;
|
final int addressIndex;
|
||||||
|
final int confirmations;
|
||||||
String? recipientAddress;
|
String? recipientAddress;
|
||||||
String? key;
|
String? key;
|
||||||
String? _fiatAmount;
|
String? _fiatAmount;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cw_core/transaction_direction.dart';
|
import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
|
||||||
|
|
||||||
class TransactionRow extends StatelessWidget {
|
class TransactionRow extends StatelessWidget {
|
||||||
TransactionRow(
|
TransactionRow(
|
||||||
|
@ -9,6 +8,7 @@ class TransactionRow extends StatelessWidget {
|
||||||
required this.formattedAmount,
|
required this.formattedAmount,
|
||||||
required this.formattedFiatAmount,
|
required this.formattedFiatAmount,
|
||||||
required this.isPending,
|
required this.isPending,
|
||||||
|
required this.title,
|
||||||
required this.onTap});
|
required this.onTap});
|
||||||
|
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
@ -17,6 +17,7 @@ class TransactionRow extends StatelessWidget {
|
||||||
final String formattedAmount;
|
final String formattedAmount;
|
||||||
final String formattedFiatAmount;
|
final String formattedFiatAmount;
|
||||||
final bool isPending;
|
final bool isPending;
|
||||||
|
final String title;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -49,11 +50,7 @@ class TransactionRow extends StatelessWidget {
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(title,
|
||||||
(direction == TransactionDirection.incoming
|
|
||||||
? S.of(context).received
|
|
||||||
: S.of(context).sent) +
|
|
||||||
(isPending ? S.of(context).pending : ''),
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
|
|
|
@ -60,7 +60,8 @@ class TransactionsPage extends StatelessWidget {
|
||||||
formattedFiatAmount:
|
formattedFiatAmount:
|
||||||
dashboardViewModel.balanceViewModel.isFiatDisabled
|
dashboardViewModel.balanceViewModel.isFiatDisabled
|
||||||
? '' : item.formattedFiatAmount,
|
? '' : item.formattedFiatAmount,
|
||||||
isPending: transaction.isPending));
|
isPending: transaction.isPending,
|
||||||
|
title: item.formattedTitle + item.formattedStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is TradeListItem) {
|
if (item is TradeListItem) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||||
|
import 'package:cw_core/transaction_direction.dart';
|
||||||
import 'package:cw_core/transaction_info.dart';
|
import 'package:cw_core/transaction_info.dart';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
|
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
|
||||||
|
@ -11,6 +12,8 @@ import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||||
import 'package:cw_core/keyable.dart';
|
import 'package:cw_core/keyable.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
|
||||||
|
import '../../generated/i18n.dart';
|
||||||
|
|
||||||
class TransactionListItem extends ActionListItem with Keyable {
|
class TransactionListItem extends ActionListItem with Keyable {
|
||||||
TransactionListItem(
|
TransactionListItem(
|
||||||
{required this.transaction,
|
{required this.transaction,
|
||||||
|
@ -35,6 +38,34 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||||
? '---'
|
? '---'
|
||||||
: transaction.amountFormatted();
|
: transaction.amountFormatted();
|
||||||
}
|
}
|
||||||
|
String get formattedTitle {
|
||||||
|
if (transaction.direction == TransactionDirection.incoming) {
|
||||||
|
return S.current.received;
|
||||||
|
}
|
||||||
|
|
||||||
|
return S.current.sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get formattedPendingStatus {
|
||||||
|
if (transaction.confirmations == 0) {
|
||||||
|
return S.current.pending;
|
||||||
|
}
|
||||||
|
if (transaction.confirmations > 0 && transaction.height < 10) {
|
||||||
|
return ' (${transaction.confirmations}/10)';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
String get formattedStatus {
|
||||||
|
if (transaction.direction == TransactionDirection.incoming) {
|
||||||
|
if (balanceViewModel.wallet.type == WalletType.monero ||
|
||||||
|
balanceViewModel.wallet.type == WalletType.haven) {
|
||||||
|
return transaction.isPending ? formattedPendingStatus : '';
|
||||||
|
}
|
||||||
|
return transaction.isPending ? S.current.pending : '';
|
||||||
|
}
|
||||||
|
return transaction.isPending ? S.current.pending : '';
|
||||||
|
}
|
||||||
|
|
||||||
String get formattedFiatAmount {
|
String get formattedFiatAmount {
|
||||||
var amount = '';
|
var amount = '';
|
||||||
|
|
Loading…
Reference in a new issue