add blocked status to incoming transactions

This commit is contained in:
Serhii 2023-02-07 18:39:41 +02:00
parent 3fc1263ad4
commit 964e51a546
27 changed files with 119 additions and 51 deletions

View file

@ -237,4 +237,7 @@ class ElectrumTransactionInfo extends TransactionInfo {
}
@override
String? unlockTimeFormatted() => null;
@override
bool get isLocked => false;
}

View file

@ -16,6 +16,7 @@ abstract class TransactionInfo extends Object with Keyable {
String? feeFormatted();
void changeFiatAmount(String amount);
String? unlockTimeFormatted();
bool get isLocked;
@override
dynamic get keyIndex => id;

View file

@ -14,6 +14,9 @@ class TransactionInfoRow extends Struct {
@Uint64()
external int confirmations;
@Uint64()
external int unlockTime;
@Uint32()
external int subaddrAccount;
@ -41,4 +44,5 @@ class TransactionInfoRow extends Struct {
String getHash() => hash.toDartString();
String getPaymentId() => paymentId.toDartString();
String getAssetType() => assetType.toDartString();
int getUnlockTime() => unlockTime * 2;
}

View file

@ -8,7 +8,7 @@ import 'package:cw_haven/api/transaction_history.dart';
class HavenTransactionInfo extends TransactionInfo {
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.unlockTime);
HavenTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(),
@ -19,6 +19,7 @@ class HavenTransactionInfo extends TransactionInfo {
amount = row.getAmount(),
accountIndex = row.subaddrAccount,
addressIndex = row.subaddrIndex,
unlockTime = row.getUnlockTime(),
key = null, //getTxKey(row.getHash()),
fee = row.fee,
assetType = row.getAssetType();
@ -34,6 +35,7 @@ class HavenTransactionInfo extends TransactionInfo {
final int addressIndex;
late String recipientAddress;
late String assetType;
final int unlockTime;
String? _fiatAmount;
String? key;
@ -52,5 +54,17 @@ class HavenTransactionInfo extends TransactionInfo {
'${formatAmount(moneroAmountToString(amount: fee))} $assetType';
@override
String? unlockTimeFormatted() => null;
String? unlockTimeFormatted() {
if (direction == TransactionDirection.outgoing || unlockTime == 0) {
return null;
}
if (unlockTime > 500000) {
return '>1 year';
}
return '~ $unlockTime minutes';
}
@override
bool get isLocked => direction == TransactionDirection.incoming && unlockTime > 0;
}

View file

@ -22,12 +22,12 @@ class MoneroTransactionInfo extends TransactionInfo {
unlockTime = row.getUnlockTime(),
key = getTxKey(row.getHash()),
fee = row.fee {
additionalInfo = <String, dynamic>{
'key': key,
'accountIndex': accountIndex,
'addressIndex': addressIndex
};
}
additionalInfo = <String, dynamic>{
'key': key,
'accountIndex': accountIndex,
'addressIndex': addressIndex
};
}
final String id;
final int height;
@ -68,4 +68,7 @@ class MoneroTransactionInfo extends TransactionInfo {
}
return '~ $unlockTime minutes';
}
@override
bool get isLocked => direction == TransactionDirection.incoming && unlockTime > 0;
}

View file

@ -1,22 +1,21 @@
import 'package:flutter/material.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:cake_wallet/generated/i18n.dart';
class TransactionRow extends StatelessWidget {
TransactionRow(
{required this.direction,
{required this.icon,
required this.formattedDate,
required this.formattedAmount,
required this.formattedFiatAmount,
required this.isPending,
required this.title,
required this.onTap});
final VoidCallback onTap;
final TransactionDirection direction;
final String icon;
final String formattedDate;
final String formattedAmount;
final String formattedFiatAmount;
final bool isPending;
final String title;
@override
Widget build(BuildContext context) {
@ -36,8 +35,7 @@ class TransactionRow extends StatelessWidget {
shape: BoxShape.circle,
color: Theme.of(context).textTheme!.overline!.decorationColor!
),
child: Image.asset(
direction.iconPath ?? ''),
child: Image.asset(icon),
),
SizedBox(width: 12),
Expanded(
@ -47,11 +45,7 @@ class TransactionRow extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
(direction == TransactionDirection.incoming
? S.of(context).received
: S.of(context).sent) +
(isPending ? S.of(context).pending : ''),
Text(title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/src/screens/dashboard/widgets/order_row.dart';
import 'package:cake_wallet/view_model/dashboard/order_list_item.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
@ -50,17 +51,23 @@ class TransactionsPage extends StatelessWidget {
return Observer(
builder: (_) => TransactionRow(
onTap: () => Navigator.of(context).pushNamed(
Routes.transactionDetails,
arguments: transaction),
direction: transaction.direction,
formattedDate: DateFormat('HH:mm')
.format(transaction.date),
formattedAmount: item.formattedCryptoAmount,
formattedFiatAmount:
dashboardViewModel.balanceViewModel.isFiatDisabled
? '' : item.formattedFiatAmount,
isPending: transaction.isPending));
onTap: () => Navigator.of(context)
.pushNamed(Routes.transactionDetails, arguments: transaction),
icon: transaction.direction.iconPath ?? '',
formattedDate: DateFormat('HH:mm').format(transaction.date),
formattedAmount: item.formattedCryptoAmount,
formattedFiatAmount:
dashboardViewModel.balanceViewModel.isFiatDisabled
? ''
: item.formattedFiatAmount,
title: (transaction.direction == TransactionDirection.incoming
? S.of(context).received
: S.of(context).sent) +
(transaction.isLocked
? ' ' + S.of(context).locked
: (transaction.isPending
? S.of(context).pending
: ''))));
}
if (item is TradeListItem) {

View file

@ -42,7 +42,7 @@ abstract class TransactionDetailsViewModelBase with Store {
final _items = [
if (unlockTimeFormatted != null)
StandartListItem(
title: 'Unlock time', value: unlockTimeFormatted),
title: S.current.unlock_time, value: unlockTimeFormatted),
StandartListItem(
title: S.current.transaction_details_transaction_id, value: tx.id),
StandartListItem(
@ -116,7 +116,11 @@ abstract class TransactionDetailsViewModelBase with Store {
}
if (wallet.type == WalletType.haven) {
final unlockTimeFormatted = tx.unlockTimeFormatted();
items.addAll([
if (unlockTimeFormatted != null)
StandartListItem(
title: S.current.unlock_time, value: unlockTimeFormatted),
StandartListItem(
title: S.current.transaction_details_transaction_id, value: tx.id),
StandartListItem(

View file

@ -682,5 +682,7 @@
"send_to_this_address" : "أرسل ${currency} ${tag}إلى هذا العنوان",
"arrive_in_this_address" : "سيصل ${currency} ${tag}إلى هذا العنوان",
"do_not_send": "لا ترسل",
"error_dialog_content": "عفوًا ، لقد حصلنا على بعض الخطأ.\n\nيرجى إرسال تقرير التعطل إلى فريق الدعم لدينا لتحسين التطبيق."
"error_dialog_content": "عفوًا ، لقد حصلنا على بعض الخطأ.\n\nيرجى إرسال تقرير التعطل إلى فريق الدعم لدينا لتحسين التطبيق.",
"unlock_time": "فتح الوقت",
"locked": "(مقفل)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Senden Sie ${currency} ${tag}an diese Adresse",
"arrive_in_this_address" : "${currency} ${tag}wird an dieser Adresse ankommen",
"do_not_send": "Nicht senden",
"error_dialog_content": "Hoppla, wir haben einen Fehler.\n\nBitte senden Sie den Absturzbericht an unser Support-Team, um die Anwendung zu verbessern."
"error_dialog_content": "Hoppla, wir haben einen Fehler.\n\nBitte senden Sie den Absturzbericht an unser Support-Team, um die Anwendung zu verbessern.",
"unlock_time": "Zeit entsperren",
"locked": "(gesperrt)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Send ${currency} ${tag}to this address",
"arrive_in_this_address" : "${currency} ${tag}will arrive in this address",
"do_not_send": "Don't send",
"error_dialog_content": "Oops, we got some error.\n\nPlease send the crash report to our support team to make the application better."
"error_dialog_content": "Oops, we got some error.\n\nPlease send the crash report to our support team to make the application better.",
"unlock_time": "Unlock time",
"locked": "(locked)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Enviar ${currency} ${tag}a esta dirección",
"arrive_in_this_address" : "${currency} ${tag}llegará a esta dirección",
"do_not_send": "no enviar",
"error_dialog_content": "Vaya, tenemos un error.\n\nEnvíe el informe de bloqueo a nuestro equipo de soporte para mejorar la aplicación."
"error_dialog_content": "Vaya, tenemos un error.\n\nEnvíe el informe de bloqueo a nuestro equipo de soporte para mejorar la aplicación.",
"unlock_time": "Tiempo de desbloqueo",
"locked": "(bloqueado)"
}

View file

@ -682,5 +682,7 @@
"send_to_this_address" : "Envoyez ${currency} ${tag}à cette adresse",
"arrive_in_this_address" : "${currency} ${tag}arrivera à cette adresse",
"do_not_send": "N'envoyez pas",
"error_dialog_content": "Oups, nous avons eu une erreur.\n\nVeuillez envoyer le rapport de plantage à notre équipe d'assistance pour améliorer l'application."
"error_dialog_content": "Oups, nous avons eu une erreur.\n\nVeuillez envoyer le rapport de plantage à notre équipe d'assistance pour améliorer l'application.",
"unlock_time": "Temps de déverrouillage",
"locked": "(fermé à clé)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "इस पते पर ${currency} ${tag}भेजें",
"arrive_in_this_address" : "${currency} ${tag}इस पते पर पहुंचेंगे",
"do_not_send": "मत भेजो",
"error_dialog_content": "ओह, हमसे कुछ गड़बड़ी हुई है.\n\nएप्लिकेशन को बेहतर बनाने के लिए कृपया क्रैश रिपोर्ट हमारी सहायता टीम को भेजें।"
"error_dialog_content": "ओह, हमसे कुछ गड़बड़ी हुई है.\n\nएप्लिकेशन को बेहतर बनाने के लिए कृपया क्रैश रिपोर्ट हमारी सहायता टीम को भेजें।",
"unlock_time": "अनलॉक समय",
"locked": "(बंद)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Pošaljite ${currency} ${tag}na ovu adresu",
"arrive_in_this_address" : "${currency} ${tag}će stići na ovu adresu",
"do_not_send": "Ne šalji",
"error_dialog_content": "Ups, imamo grešku.\n\nPošaljite izvješće o padu našem timu za podršku kako bismo poboljšali aplikaciju."
"error_dialog_content": "Ups, imamo grešku.\n\nPošaljite izvješće o padu našem timu za podršku kako bismo poboljšali aplikaciju.",
"unlock_time": "Vrijeme otključavanja",
"locked": "(zaključan)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Invia ${currency} ${tag}a questo indirizzo",
"arrive_in_this_address" : "${currency} ${tag}arriverà a questo indirizzo",
"do_not_send": "Non inviare",
"error_dialog_content": "Ups, imamo grešku.\n\nPošaljite izvješće o padu našem timu za podršku kako bismo poboljšali aplikaciju."
"error_dialog_content": "Ups, imamo grešku.\n\nPošaljite izvješće o padu našem timu za podršku kako bismo poboljšali aplikaciju.",
"unlock_time": "Tempo di sblocco",
"locked": "(bloccato)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "${currency} ${tag}をこのアドレスに送金",
"arrive_in_this_address" : "${currency} ${tag}はこの住所に到着します",
"do_not_send": "送信しない",
"error_dialog_content": "Spiacenti, abbiamo riscontrato un errore.\n\nSi prega di inviare il rapporto sull'arresto anomalo al nostro team di supporto per migliorare l'applicazione."
"error_dialog_content": "Spiacenti, abbiamo riscontrato un errore.\n\nSi prega di inviare il rapporto sull'arresto anomalo al nostro team di supporto per migliorare l'applicazione.",
"unlock_time": "ロック解除時間",
"locked": "(ロックされた)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "이 주소로 ${currency} ${tag}송금",
"arrive_in_this_address" : "${currency} ${tag}이(가) 이 주소로 도착합니다",
"do_not_send": "보내지 마세요",
"error_dialog_content": "죄송합니다. 오류가 발생했습니다.\n\n응용 프로그램을 개선하려면 지원 팀에 충돌 보고서를 보내주십시오."
"error_dialog_content": "죄송합니다. 오류가 발생했습니다.\n\n응용 프로그램을 개선하려면 지원 팀에 충돌 보고서를 보내주십시오.",
"unlock_time": "잠금 해제 시간",
"locked": "(잠긴)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "ဤလိပ်စာသို့ ${currency} ${tag}သို့ ပို့ပါ။",
"arrive_in_this_address" : "${currency} ${tag}ဤလိပ်စာသို့ ရောက်ရှိပါမည်။",
"do_not_send": "မပို့ပါနှင့်",
"error_dialog_content": "အိုး၊ ကျွန်ုပ်တို့တွင် အမှားအယွင်းအချို့ရှိသည်။\n\nအပလီကေးရှင်းကို ပိုမိုကောင်းမွန်စေရန်အတွက် ပျက်စီးမှုအစီရင်ခံစာကို ကျွန်ုပ်တို့၏ပံ့ပိုးကူညီရေးအဖွဲ့ထံ ပေးပို့ပါ။"
"error_dialog_content": "အိုး၊ ကျွန်ုပ်တို့တွင် အမှားအယွင်းအချို့ရှိသည်။\n\nအပလီကေးရှင်းကို ပိုမိုကောင်းမွန်စေရန်အတွက် ပျက်စီးမှုအစီရင်ခံစာကို ကျွန်ုပ်တို့၏ပံ့ပိုးကူညီရေးအဖွဲ့ထံ ပေးပို့ပါ။",
"unlock_time": "လော့ခ်ဖွင့်ချိန်",
"locked": "(သော့ခတ်ထားသည်။)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Stuur ${currency} ${tag}naar dit adres",
"arrive_in_this_address" : "${currency} ${tag}komt aan op dit adres",
"do_not_send": "Niet sturen",
"error_dialog_content": "Oeps, er is een fout opgetreden.\n\nStuur het crashrapport naar ons ondersteuningsteam om de applicatie te verbeteren."
"error_dialog_content": "Oeps, er is een fout opgetreden.\n\nStuur het crashrapport naar ons ondersteuningsteam om de applicatie te verbeteren.",
"unlock_time": "Ontgrendel de tijd",
"locked": "(op slot)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Wyślij ${currency} ${tag}na ten adres",
"arrive_in_this_address" : "${currency} ${tag}dotrze na ten adres",
"do_not_send": "Nie wysyłaj",
"error_dialog_content": "Ups, wystąpił błąd.\n\nPrześlij raport o awarii do naszego zespołu wsparcia, aby ulepszyć aplikację."
"error_dialog_content": "Ups, wystąpił błąd.\n\nPrześlij raport o awarii do naszego zespołu wsparcia, aby ulepszyć aplikację.",
"unlock_time": "Czas odblokowania",
"locked": "(zablokowany)"
}

View file

@ -683,5 +683,7 @@
"send_to_this_address" : "Envie ${currency} ${tag}para este endereço",
"arrive_in_this_address" : "${currency} ${tag}chegará neste endereço",
"do_not_send": "não envie",
"error_dialog_content": "Ops, houve algum erro.\n\nPor favor, envie o relatório de falha para nossa equipe de suporte para melhorar o aplicativo."
"error_dialog_content": "Ops, houve algum erro.\n\nPor favor, envie o relatório de falha para nossa equipe de suporte para melhorar o aplicativo.",
"unlock_time": "Tempo de desbloqueio",
"locked": "(bloqueado)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Отправить ${currency} ${tag}на этот адрес",
"arrive_in_this_address" : "${currency} ${tag}придет на этот адрес",
"do_not_send": "Не отправлять",
"error_dialog_content": "Ой, у нас какая-то ошибка.\n\nПожалуйста, отправьте отчет о сбое в нашу службу поддержки, чтобы сделать приложение лучше."
"error_dialog_content": "Ой, у нас какая-то ошибка.\n\nПожалуйста, отправьте отчет о сбое в нашу службу поддержки, чтобы сделать приложение лучше.",
"unlock_time": "Время разблокирования",
"locked": "(заблокировано)"
}

View file

@ -682,5 +682,7 @@
"send_to_this_address" : "ส่ง ${currency} ${tag}ไปยังที่อยู่นี้",
"arrive_in_this_address" : "${currency} ${tag}จะมาถึงที่อยู่นี้",
"do_not_send": "อย่าส่ง",
"error_dialog_content": "อ๊ะ เราพบข้อผิดพลาดบางอย่าง\n\nโปรดส่งรายงานข้อขัดข้องไปยังทีมสนับสนุนของเราเพื่อปรับปรุงแอปพลิเคชันให้ดียิ่งขึ้น"
"error_dialog_content": "อ๊ะ เราพบข้อผิดพลาดบางอย่าง\n\nโปรดส่งรายงานข้อขัดข้องไปยังทีมสนับสนุนของเราเพื่อปรับปรุงแอปพลิเคชันให้ดียิ่งขึ้น",
"unlock_time": "ปลดล็อกเวลา",
"locked": "(ล็อค)"
}

View file

@ -684,5 +684,7 @@
"send_to_this_address" : "Bu adrese ${currency} ${tag}gönder",
"arrive_in_this_address" : "${currency} ${tag}bu adrese ulaşacak",
"do_not_send": "Gönderme",
"error_dialog_content": "Hay aksi, bir hatamız var.\n\nUygulamayı daha iyi hale getirmek için lütfen kilitlenme raporunu destek ekibimize gönderin."
"error_dialog_content": "Hay aksi, bir hatamız var.\n\nUygulamayı daha iyi hale getirmek için lütfen kilitlenme raporunu destek ekibimize gönderin.",
"unlock_time": "Kilit açma zamanı",
"locked": "(kilitli)"
}

View file

@ -683,5 +683,7 @@
"send_to_this_address" : "Надіслати ${currency} ${tag}на цю адресу",
"arrive_in_this_address" : "${currency} ${tag}надійде на цю адресу",
"do_not_send": "Не надсилайте",
"error_dialog_content": "На жаль, ми отримали помилку.\n\nБудь ласка, надішліть звіт про збій нашій команді підтримки, щоб покращити додаток."
"error_dialog_content": "На жаль, ми отримали помилку.\n\nБудь ласка, надішліть звіт про збій нашій команді підтримки, щоб покращити додаток.",
"unlock_time": "Час розблокування",
"locked": "(заблоковано)"
}

View file

@ -682,5 +682,7 @@
"send_to_this_address" : "发送 ${currency} ${tag}到这个地址",
"arrive_in_this_address" : "${currency} ${tag}将到达此地址",
"do_not_send": "不要发送",
"error_dialog_content": "糟糕,我们遇到了一些错误。\n\n请将崩溃报告发送给我们的支持团队以改进应用程序。"
"error_dialog_content": "糟糕,我们遇到了一些错误。\n\n请将崩溃报告发送给我们的支持团队以改进应用程序。",
"unlock_time": "解锁时间",
"locked": "(锁定)"
}