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

Feature/Show pending transactions from appstore until they return from qubic live #190

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b133ad9
feat: Show pending transactions from appstore until they return from …
ahmed-tarek-salem Oct 28, 2024
858368e
feat: Add ignoredTransaction functionality to ApplicationStore
ahmed-tarek-salem Oct 30, 2024
d827138
feat: Convert pending and ignored transactions validation to be by th…
ahmed-tarek-salem Oct 30, 2024
a1d7c6e
feat: Add ability to resend transaction if the origin is one of user …
ahmed-tarek-salem Nov 1, 2024
162cf44
feat: Delete failure transactions
ahmed-tarek-salem Nov 2, 2024
281ab55
feat: Make the resend option only for non pending transactions
ahmed-tarek-salem Nov 3, 2024
db4827b
feat: Add hive database
ahmed-tarek-salem Nov 5, 2024
f384ad4
feat: Implement HiveStorage class with functions and TransactionVmAda…
ahmed-tarek-salem Nov 5, 2024
d5341fa
feat: Use HiveStorage class for pending and ignored transations
ahmed-tarek-salem Nov 5, 2024
a0e1183
refactor: Remove unused code
ahmed-tarek-salem Nov 7, 2024
e9b2d97
feat: Insert transactions considering the order of tick number
ahmed-tarek-salem Nov 11, 2024
0f7ba8d
chore: Remove failed from resend dialog title
ahmed-tarek-salem Nov 11, 2024
9998c0e
feat: Make the igonred transaction invalid instead of failed
ahmed-tarek-salem Nov 11, 2024
5db626c
feat: Remove Confirmed status and its relevant code
ahmed-tarek-salem Nov 11, 2024
76761a7
Updating translations for non english languages to remove 'failed' in…
sallymoc Nov 14, 2024
fbe7533
feat: Show pending transaction after asset transfer
ahmed-tarek-salem Nov 15, 2024
895c05d
feat: Add delete option for only invalid transactions
ahmed-tarek-salem Nov 15, 2024
abbead1
fix: Fix accessing hive boxes after closing them error when importing…
ahmed-tarek-salem Nov 15, 2024
6304139
refactor: Fix typo
ahmed-tarek-salem Nov 15, 2024
ab14b29
refactor: Use constant transferAssetFee & remove unused imports
ahmed-tarek-salem Nov 15, 2024
0a9fd47
feat: Remove view in explorer from invalid transactions
ahmed-tarek-salem Nov 16, 2024
db62a41
Removing trx fields that do not exist in archiver service
sallymoc Nov 26, 2024
dfe35d2
hiding temporarily the Resend action
sallymoc Nov 26, 2024
eaa080b
Updating translations for trx timestamp and removing translations not…
sallymoc Nov 26, 2024
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
15 changes: 0 additions & 15 deletions lib/components/transaction_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,6 @@ class TransactionDetails extends StatelessWidget {
? l10n.generalLabelYes
: l10n.generalLabelNo),
ThemedControls.spacerVerticalSmall(),
getCopyableDetails(
context,
l10n.transactionItemLabelCreatedDate,
item.broadcasted != null
? formatter.format(item.created!.toLocal())
: l10n.generalLabelUnknown),
ThemedControls.spacerVerticalSmall(),
getCopyableDetails(
context,
l10n.transactionItemLabelBroadcastedDate,
item.broadcasted != null
? formatter
.format(item.broadcasted!.toLocal())
: l10n.generalLabelUnknown),
ThemedControls.spacerVerticalSmall(),
getCopyableDetails(
context,
l10n.transactionItemLabelConfirmedDate,
Expand Down
27 changes: 17 additions & 10 deletions lib/components/transaction_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ import 'package:qubic_wallet/extensions/asThousands.dart';
import 'package:qubic_wallet/l10n/l10n.dart';
import 'package:qubic_wallet/helpers/target_tick.dart';

enum CardItem {
details,
resend,
explorer,
clipboardCopy,
}
enum CardItem { details, resend, explorer, clipboardCopy, delete }

class TransactionItem extends StatelessWidget {
final TransactionVm item;
Expand Down Expand Up @@ -134,13 +129,17 @@ class TransactionItem extends StatelessWidget {
if (menuItem == CardItem.details) {
showDetails(context);
}
if (menuItem == CardItem.delete) {
appStore.removeIgnoredTransactions(item.id);
}
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<CardItem>>[
PopupMenuItem<CardItem>(
value: CardItem.details,
child: Text(l10n.transactionItemButtonViewDetails),
),
if (appStore.currentTick >= item.targetTick)
if (appStore.currentTick >= item.targetTick &&
item.getStatus() != ComputedTransactionStatus.invalid)
PopupMenuItem<CardItem>(
value: CardItem.explorer,
child: Text(l10n.transactionItemButtonViewInExplorer),
Expand All @@ -149,10 +148,18 @@ class TransactionItem extends StatelessWidget {
value: CardItem.clipboardCopy,
child: Text(l10n.transactionItemButtonCopyToClipboard),
),
if ((item.getStatus() == ComputedTransactionStatus.failure))
// sally: commenting this temporary until we improve the resend to support all transfers
//if (appStore.currentQubicIDs
// .any((e) => e.publicId == item.sourceId) &&
//item.getStatus() != ComputedTransactionStatus.pending)
//PopupMenuItem<CardItem>(
//value: CardItem.resend,
//child: Text(l10n.transactionItemButtonResend),
//),
if (item.getStatus() == ComputedTransactionStatus.invalid)
PopupMenuItem<CardItem>(
ahmed-tarek-salem marked this conversation as resolved.
Show resolved Hide resolved
value: CardItem.resend,
child: Text(l10n.transactionItemButtonResend),
value: CardItem.delete,
child: Text(l10n.generalButtonDelete),
)
]);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/di.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:get_it/get_it.dart';
import 'package:qubic_wallet/helpers/global_snack_bar.dart';
import 'package:qubic_wallet/resources/apis/archive/qubic_archive_api.dart';
import 'package:qubic_wallet/resources/apis/live/qubic_live_api.dart';
import 'package:qubic_wallet/resources/hive_storage.dart';
import 'package:qubic_wallet/resources/qubic_cmd.dart';
import 'package:qubic_wallet/resources/qubic_hub.dart';
import 'package:qubic_wallet/resources/qubic_li.dart';
Expand All @@ -27,6 +28,7 @@ void setupDI() {
getIt.registerSingleton<ExplorerStore>(ExplorerStore());
getIt.registerSingleton<QubicHubStore>(QubicHubStore());
getIt.registerSingleton<SecureStorage>(SecureStorage());
getIt.registerSingleton<HiveStorage>(HiveStorage());

//Providers
getIt.registerSingleton<GlobalSnackBar>(GlobalSnackBar());
Expand Down
29 changes: 26 additions & 3 deletions lib/helpers/sendTransaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import 'package:qubic_wallet/di.dart';
import 'package:qubic_wallet/helpers/platform_helpers.dart';
import 'package:qubic_wallet/helpers/show_alert_dialog.dart';
import 'package:qubic_wallet/l10n/l10n.dart';
import 'package:qubic_wallet/models/transaction_vm.dart';
import 'package:qubic_wallet/resources/apis/live/qubic_live_api.dart';
import 'package:qubic_wallet/resources/qubic_cmd.dart';
import 'package:qubic_wallet/resources/qubic_li.dart';
import 'package:qubic_wallet/smart_contracts/qx_info.dart';
import 'package:qubic_wallet/stores/application_store.dart';

void showTamperedWalletAlert(BuildContext context) {
Expand Down Expand Up @@ -39,7 +40,18 @@ Future<bool> sendAssetTransferTransactionDialog(
try {
transactionKey = await qubicCmd.createAssetTransferTransaction(seed,
destinationId, assetName, issuer, numberOfAssets, destinationTick);
await getIt.get<QubicLiveApi>().submitTransaction(transactionKey);
final transactionId =
await getIt.get<QubicLiveApi>().submitTransaction(transactionKey);
final pendingTransaction = TransactionVm(
id: transactionId,
sourceId: sourceId,
destId: destinationId,
amount: QxInfo.transferAssetFee,
status: ComputedTransactionStatus.pending.name,
ahmed-tarek-salem marked this conversation as resolved.
Show resolved Hide resolved
targetTick: destinationTick,
isPending: true,
moneyFlow: true);
getIt.get<ApplicationStore>().addPendingTransaction(pendingTransaction);
return true;
} catch (e) {
if (e.toString().startsWith("Exception: CRITICAL:")) {
Expand Down Expand Up @@ -80,7 +92,18 @@ Future<bool> sendTransactionDialog(BuildContext context, String sourceId,

//We have the transaction, now let's call the API
try {
await getIt.get<QubicLiveApi>().submitTransaction(transactionKey);
final transactionId =
await getIt.get<QubicLiveApi>().submitTransaction(transactionKey);
final pendingTransaction = TransactionVm(
id: transactionId,
sourceId: sourceId,
destId: destinationId,
amount: value,
status: ComputedTransactionStatus.pending.name,
targetTick: destinationTick,
isPending: true,
moneyFlow: value > 0);
getIt.get<ApplicationStore>().addPendingTransaction(pendingTransaction);
} catch (e) {
showAlertDialog(
context, l10n.sendItemDialogErrorGeneralTitle, e.toString());
Expand Down
6 changes: 0 additions & 6 deletions lib/helpers/transaction_UI_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ Widget getEmptyTransactionsWidget(

IconData getTransactionStatusIcon(ComputedTransactionStatus status) {
switch (status) {
case ComputedTransactionStatus.confirmed:
return Icons.check_circle;
case ComputedTransactionStatus.failure:
return Icons.highlight_remove_outlined;
case ComputedTransactionStatus.invalid:
Expand All @@ -85,8 +83,6 @@ IconData getTransactionStatusIcon(ComputedTransactionStatus status) {

Color getTransactionStatusColor(ComputedTransactionStatus status) {
switch (status) {
case ComputedTransactionStatus.confirmed:
return Colors.blue;
case ComputedTransactionStatus.failure:
return LightThemeColors.error;
case ComputedTransactionStatus.invalid:
Expand All @@ -102,8 +98,6 @@ String getTransactionStatusText(
ComputedTransactionStatus status, BuildContext context) {
final l10n = l10nOf(context);
switch (status) {
case ComputedTransactionStatus.confirmed:
return l10n.transactionLabelStatusConfirmed;
case ComputedTransactionStatus.failure:
return l10n.transactionLabelStatusFailed;
case ComputedTransactionStatus.invalid:
Expand Down
8 changes: 3 additions & 5 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"explorerTickResultLabelTickLeader": "Tick-Leader",
"explorerTickResultLabelNoTransactionsFound": "Keine Transaktionen in diesem Tick",
"explorerTickResultLabelTransactionsFound": "{count, plural, =1{1 Transaktion im Tick} other{{count} Transaktionen im Tick}}",
"explorerTickResultLabelShowingOneTransaction": "{count, plural, =1{Zeigt 1 von 1 Transaktion im Tick} other{Zeigt 1 von {count} Transaktionen im Tick}}}",
"explorerTickResultLabelShowingOneTransaction": "{count, plural, =1{Zeigt 1 von 1 Transaktion im Tick} other{Zeigt 1 von {count} Transaktionen im Tick}}",
"settingsTitle": "Einstellungen",
"settingsHeaderAccountsAndData": "Konten und Daten",
"settingsLockWallet": "Wallet sperren",
Expand Down Expand Up @@ -398,9 +398,7 @@
"transactionItemButtonViewDetails": "Details anzeigen",
"transactionItemButtonResend": "Erneut senden",
"transactionItemLabelLeadToMoneyFlow": "Führen zu Geldfluss",
"transactionItemLabelCreatedDate": "Erstellungsdatum",
"transactionItemLabelBroadcastedDate": "Sendedatum",
"transactionItemLabelConfirmedDate": "Bestätigungsdatum",
"transactionItemLabelConfirmedDate": "Zeitstempel",
"transactionItemLabelDetails": "Überweisungsdetails",
"sendItemLabelTargetTick": "Ziel-Tick",
"sendItemLabelTargetTickAutomatic": "Automatisch: Aktuell + {addingTicks}",
Expand All @@ -414,7 +412,7 @@
"sendItemLabelTargetTickManual": "Manuelles Überschreiben",
"sendItemLabelDetermineTargetTick": "Ziel-Tick bestimmen",
"sendItemDialogErrorGeneralTitle": "Fehler beim Generieren der Transaktion.",
"sendItemDialogResendTitle": "Fehlgeschlagene Transaktion erneut senden?",
"sendItemDialogResendTitle": "Transaktion erneut senden?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (aktuell {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
8 changes: 3 additions & 5 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
"explorerTickResultLabelTickLeader": "Tick Leader",
"explorerTickResultLabelNoTransactionsFound": "No transactions in this tick",
"explorerTickResultLabelTransactionsFound": "{count, plural, =1{1 transaction in tick} other{{count} transactions in tick}}",
"explorerTickResultLabelShowingOneTransaction": "{count, plural, =1{Showing 1 of 1 transaction in tick} other{Showing 1 of {count} transactions in tick}}}",
"explorerTickResultLabelShowingOneTransaction": "{count, plural, =1{Showing 1 of 1 transaction in tick} other{Showing 1 of {count} transactions in tick}}",
"settingsTitle": "Settings",
"settingsHeaderAccountsAndData": "Accounts and Data",
"settingsLockWallet": "Lock Wallet",
Expand Down Expand Up @@ -408,9 +408,7 @@
"transactionItemButtonViewDetails": "View Details",
"transactionItemButtonResend": "Resend",
"transactionItemLabelLeadToMoneyFlow": "Lead to Money Flow",
"transactionItemLabelCreatedDate": "Created Date",
"transactionItemLabelBroadcastedDate": "Broadcasted Date",
"transactionItemLabelConfirmedDate": "Confirmed Date",
"transactionItemLabelConfirmedDate": "Timestamp",
"transactionItemLabelDetails": "Transfer Details",
"sendItemLabelTargetTick": "Target Tick",
"sendItemLabelTargetTickAutomatic": "Automatically: Current + {addingTicks}",
Expand All @@ -424,7 +422,7 @@
"sendItemLabelTargetTickManual": "Manual Override",
"sendItemLabelDetermineTargetTick": "Determine Target Tick",
"sendItemDialogErrorGeneralTitle": "Error while generating transaction",
"sendItemDialogResendTitle": "Resend failed transaction?",
"sendItemDialogResendTitle": "Resend transaction?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (current {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
6 changes: 2 additions & 4 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@
"transactionItemButtonViewDetails": "Ver Detalles",
"transactionItemButtonResend": "Reenviar",
"transactionItemLabelLeadToMoneyFlow": "Conduce a un Flujo de Dinero",
"transactionItemLabelCreatedDate": "Fecha de Creación",
"transactionItemLabelBroadcastedDate": "Fecha de Transmisión",
"transactionItemLabelConfirmedDate": "Fecha de Confirmación",
"transactionItemLabelConfirmedDate": "Fecha y hora",
"transactionItemLabelDetails": "Detalles de la Transferencia",
"sendItemLabelTargetTick": "Tick de Ejecución",
"sendItemLabelTargetTickAutomatic": "Automáticamente: Actual + {addingTicks}",
Expand All @@ -413,7 +411,7 @@
"sendItemLabelTargetTickManual": "Sobreescribir manualmente",
"sendItemLabelDetermineTargetTick": "Determinar el Target de Ejecución",
"sendItemDialogErrorGeneralTitle": "Error al generar la transacción",
"sendItemDialogResendTitle": "¿Deseas reenviar la transacción fallida?",
"sendItemDialogResendTitle": "¿Deseas reenviar la transacción?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (actual {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
6 changes: 2 additions & 4 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@
"transactionItemButtonViewDetails": "Voir les Détails",
"transactionItemButtonResend": "Renvoyer",
"transactionItemLabelLeadToMoneyFlow": "Conduit à un Flux Monétaire",
"transactionItemLabelCreatedDate": "Date de Création",
"transactionItemLabelBroadcastedDate": "Date de Diffusion",
"transactionItemLabelConfirmedDate": "Date de Confirmation",
"transactionItemLabelConfirmedDate": "Horodatage",
"transactionItemLabelDetails": "Détails du Transfert",
"sendItemLabelTargetTick": "Tick Cible",
"sendItemLabelTargetTickAutomatic": "Automatiquement: Actuel + {addingTicks}",
Expand All @@ -414,7 +412,7 @@
"sendItemLabelTargetTickManual": "Remplacement Manuel",
"sendItemLabelDetermineTargetTick": "Déterminer le Tick Cible",
"sendItemDialogErrorGeneralTitle": "Erreur lors de la génération de la transaction",
"sendItemDialogResendTitle": "Renvoyer la transaction échouée?",
"sendItemDialogResendTitle": "Renvoyer la transaction?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (actuel {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
6 changes: 2 additions & 4 deletions lib/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@
"transactionItemButtonViewDetails": "Детали",
"transactionItemButtonResend": "Переслать",
"transactionItemLabelLeadToMoneyFlow": "Lead to Money Flow",
"transactionItemLabelCreatedDate": "Создать дату",
"transactionItemLabelBroadcastedDate": "Дата выхода",
"transactionItemLabelConfirmedDate": "Дата подтверждения",
"transactionItemLabelConfirmedDate": "Метка времени",
"transactionItemLabelDetails": "Детали транзакции",
"sendItemLabelTargetTick": "На каком тике",
"sendItemLabelTargetTickAutomatic": "Автоматически: этот тик + {addingTicks}",
Expand All @@ -413,7 +411,7 @@
"sendItemLabelTargetTickManual": "Ручное управление",
"sendItemLabelDetermineTargetTick": "Определите целевой тик",
"sendItemDialogErrorGeneralTitle": "Ошибка при генерации транзакции",
"sendItemDialogResendTitle": "Повторно отправить неудачную транзакцию?",
"sendItemDialogResendTitle": "Повторно отправить транзакцию?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (current {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
6 changes: 2 additions & 4 deletions lib/l10n/app_tr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,7 @@
"transactionItemButtonViewDetails": "Detayları Göster",
"transactionItemButtonResend": "Yeniden Gönder",
"transactionItemLabelLeadToMoneyFlow": "Para Akışını Yönlendir",
"transactionItemLabelCreatedDate": "Oluşturulma Tarihi",
"transactionItemLabelBroadcastedDate": "Yayınlanma Tarihi",
"transactionItemLabelConfirmedDate": "Onaylanma Tarihi",
"transactionItemLabelConfirmedDate": "Zaman damgası",
"transactionItemLabelDetails": "Transfer Detayları",
"sendItemLabelTargetTick": "Hedef Tick",
"sendItemLabelTargetTickAutomatic": "Otomatik olarak: Mevcut + {addingTicks}",
Expand All @@ -413,7 +411,7 @@
"sendItemLabelTargetTickManual": "Manuel Geçersiz Kılma",
"sendItemLabelDetermineTargetTick": "Hedef Tick'i Belirle",
"sendItemDialogErrorGeneralTitle": "Transfer oluşturulurken bir hata oluştu",
"sendItemDialogResendTitle": "Başarısız olan işlem yeniden gönderilsin mi?",
"sendItemDialogResendTitle": "Işlem yeniden gönderilsin mi?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (current {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
6 changes: 2 additions & 4 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@
"transactionItemButtonViewDetails": "查看详情",
"transactionItemButtonResend": "重新发送",
"transactionItemLabelLeadToMoneyFlow": "Lead to Money Flow",
"transactionItemLabelCreatedDate": "创建日期",
"transactionItemLabelBroadcastedDate": "广播日期",
"transactionItemLabelConfirmedDate": "确认日期",
"transactionItemLabelConfirmedDate": "时间戳",
"transactionItemLabelDetails": "转账详情",
"sendItemLabelTargetTick": "目标刻度",
"sendItemLabelTargetTickAutomatic": "自动:当前刻度 + {addingTicks}",
Expand All @@ -414,7 +412,7 @@
"sendItemLabelTargetTickManual": "手动调整",
"sendItemLabelDetermineTargetTick": "确定目标刻度",
"sendItemDialogErrorGeneralTitle": "生成交易时出现错误",
"sendItemDialogResendTitle": "重新发送失败的交易?",
"sendItemDialogResendTitle": "重新发送交易?",
"sendItemLabelResendTargetTickValue": "{formattedTargetTick} (当前 {formattedCurrentTick})",
"@sendItemLabelResendTargetTickValue": {
"placeholders": {
Expand Down
Loading