mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 12:44:31 +00:00
commit
b204d8b22e
4 changed files with 64 additions and 23 deletions
|
@ -147,17 +147,15 @@ class _ConfirmChangeNowSendViewState
|
|||
);
|
||||
|
||||
// pop back to wallet
|
||||
if (mounted) {
|
||||
if (context.mounted) {
|
||||
if (Util.isDesktop) {
|
||||
// pop sending dialog
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
|
||||
// stupid hack
|
||||
// one day we'll do routing right
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
if (widget.fromDesktopStep4) {
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import '../providers/desktop/current_desktop_menu_item.dart';
|
|||
import '../themes/stack_colors.dart';
|
||||
import '../utilities/assets.dart';
|
||||
import '../utilities/text_styles.dart';
|
||||
import '../wallets/crypto_currency/crypto_currency.dart';
|
||||
import '../widgets/desktop/desktop_tor_status_button.dart';
|
||||
import '../widgets/desktop/living_stack_icon.dart';
|
||||
import 'desktop_menu_item.dart';
|
||||
|
@ -278,8 +279,14 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
|||
value: 7,
|
||||
onChanged: (_) {
|
||||
// todo: save stuff/ notify before exit?
|
||||
// exit(0);
|
||||
SystemNavigator.pop();
|
||||
if (AppConfig.coins
|
||||
.where((e) => e is Monero || e is Wownero)
|
||||
.isNotEmpty) {
|
||||
// hack to insta kill because xmr/wow native lib code sucks
|
||||
exit(0);
|
||||
} else {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
},
|
||||
controller: controllers[8],
|
||||
),
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
import '../models/isar/models/log.dart';
|
||||
import 'constants.dart';
|
||||
import 'enums/log_level_enum.dart';
|
||||
|
@ -30,8 +31,10 @@ class Logging {
|
|||
static const core.int defaultPrintLength = 1020;
|
||||
|
||||
late final Isar? isar;
|
||||
late final _AsyncLogWriterQueue _queue;
|
||||
|
||||
Future<void> init(Isar isar) async {
|
||||
_queue = _AsyncLogWriterQueue();
|
||||
this.isar = isar;
|
||||
}
|
||||
|
||||
|
@ -62,7 +65,11 @@ class Logging {
|
|||
printFullLength = true;
|
||||
}
|
||||
|
||||
isar!.writeTxnSync(() => log.id = isar!.logs.putSync(log));
|
||||
_queue.add(
|
||||
() async => isar!.writeTxn(
|
||||
() async => await isar!.logs.put(log),
|
||||
),
|
||||
);
|
||||
|
||||
if (printToConsole) {
|
||||
final core.String logStr = "Log: ${log.toString()}";
|
||||
|
@ -129,3 +136,33 @@ abstract class Logger {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// basic async queue for writing logs in the [Logging] to isar
|
||||
class _AsyncLogWriterQueue {
|
||||
final List<Future<void> Function()> _queue = [];
|
||||
bool _runningLock = false;
|
||||
|
||||
void add(Future<void> Function() futureFunction) {
|
||||
_queue.add(futureFunction);
|
||||
_run();
|
||||
}
|
||||
|
||||
void _run() async {
|
||||
if (_runningLock) {
|
||||
return;
|
||||
}
|
||||
_runningLock = true;
|
||||
try {
|
||||
while (_queue.isNotEmpty) {
|
||||
final futureFunction = _queue.removeAt(0);
|
||||
try {
|
||||
await futureFunction.call();
|
||||
} catch (e, s) {
|
||||
debugPrint("$e\n$s");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
_runningLock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import 'package:cw_core/wallet_credentials.dart';
|
|||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_monero/api/exceptions/creation_transaction_exception.dart';
|
||||
import 'package:cw_wownero/api/account_list.dart';
|
||||
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
||||
import 'package:cw_wownero/wownero_wallet.dart';
|
||||
import 'package:decimal/decimal.dart';
|
||||
|
@ -20,6 +21,7 @@ import 'package:flutter_libmonero/view_model/send/output.dart'
|
|||
as wownero_output;
|
||||
import 'package:flutter_libmonero/wownero/wownero.dart' as wow_dart;
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:monero/wownero.dart' as wownerodart;
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
|
@ -383,19 +385,11 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
|
|||
_walletCreationService.type = WalletType.wownero;
|
||||
// To restore from a seed
|
||||
final wallet = await _walletCreationService.create(credentials);
|
||||
//
|
||||
// final bufferedCreateHeight = (seedWordsLength == 14)
|
||||
// ? getSeedHeightSync(wallet?.seed.trim() as String)
|
||||
// : wownero.getHeightByDate(
|
||||
// date: DateTime.now().subtract(const Duration(
|
||||
// days:
|
||||
// 2))); // subtract a couple days to ensure we have a buffer for SWB
|
||||
// TODO(mrcyjanek): implement
|
||||
const bufferedCreateHeight =
|
||||
1; //getSeedHeightSync(wallet!.seed.trim());
|
||||
|
||||
final height = wownerodart.Wallet_getRefreshFromBlockHeight(wptr!);
|
||||
|
||||
await info.updateRestoreHeight(
|
||||
newRestoreHeight: bufferedCreateHeight,
|
||||
newRestoreHeight: height,
|
||||
isar: mainDB.isar,
|
||||
);
|
||||
|
||||
|
@ -410,7 +404,7 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
|
|||
value: "",
|
||||
);
|
||||
|
||||
walletInfo.restoreHeight = bufferedCreateHeight;
|
||||
walletInfo.restoreHeight = height;
|
||||
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
await DB.instance
|
||||
|
@ -515,8 +509,7 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
|
|||
|
||||
// extract seed height from 14 word seed
|
||||
if (seedLength == 14) {
|
||||
// TODO(mrcyjanek): implement
|
||||
height = 1; // getSeedHeightSync(mnemonic.trim());
|
||||
height = 0;
|
||||
} else {
|
||||
height = max(height, 0);
|
||||
}
|
||||
|
@ -563,7 +556,13 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
|
|||
// To restore from a seed
|
||||
final wallet = await cwWalletCreationService
|
||||
.restoreFromSeed(credentials) as WowneroWalletBase;
|
||||
height = wownerodart.Wallet_getRefreshFromBlockHeight(wptr!);
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
walletInfo.restoreHeight = height;
|
||||
await info.updateRestoreHeight(
|
||||
newRestoreHeight: height,
|
||||
isar: mainDB.isar,
|
||||
);
|
||||
await DB.instance
|
||||
.add<WalletInfo>(boxName: WalletInfo.boxName, value: walletInfo);
|
||||
CwBasedInterface.cwWalletBase?.close();
|
||||
|
|
Loading…
Reference in a new issue