diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero index 66c311b9c..8e3afd002 160000 --- a/crypto_plugins/flutter_libmonero +++ b/crypto_plugins/flutter_libmonero @@ -1 +1 @@ -Subproject commit 66c311b9c9799d3d81e2297a9982797603ee989f +Subproject commit 8e3afd002968d21a3de788569356587a70818022 diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index 9aa9dc341..83dc43933 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -59,7 +59,9 @@ class _NewWalletRecoveryPhraseWarningViewState final _numberOfPhraseWords = coin == Coin.monero ? Constants.seedPhraseWordCountMonero - : Constants.seedPhraseWordCountBip39; + : coin == Coin.wownero + ? 14 + : Constants.seedPhraseWordCountBip39; return MasterScaffold( isDesktop: isDesktop, diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index 7528dacc8..586ffc0da 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -85,7 +85,7 @@ class _SendFromViewState extends ConsumerState { height: 8, ), Text( - "You need to send ${amount.toStringAsFixed(coin == Coin.monero || coin == Coin.wownero ? 12 : 8)} ${coin.ticker}", + "You need to send ${amount.toStringAsFixed(coin == Coin.monero ? Constants.satsPerCoinMonero : coin == Coin.wownero ? Constants.satsPerCoinWownero : Constants.satsPerCoin)} ${coin.ticker}", style: STextStyles.itemSubtitle(context), ), const SizedBox( @@ -307,10 +307,11 @@ class _SendFromCardState extends ConsumerState { "${Format.localizedStringAsFixed( value: snapshot.data!, locale: locale, - decimalPlaces: - coin == Coin.monero || coin == Coin.wownero - ? 12 - : 8, + decimalPlaces: coin == Coin.monero + ? Constants.satsPerCoinMonero + : coin == Coin.wownero + ? Constants.satsPerCoinWownero + : Constants.satsPerCoin, )} ${coin.ticker}", style: STextStyles.itemSubtitle(context), ); diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index f68a72c3c..fdb8bf1a9 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -239,9 +239,11 @@ class _TransactionDetailsViewState children: [ SelectableText( "$amountPrefix${Format.localizedStringAsFixed( - value: coin == Coin.monero || coin == Coin.wownero + value: coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() - : amount, + : coin == Coin.wownero + ? (amount / 1000.toDecimal()).toDecimal() + : amount, locale: ref.watch( localeServiceChangeNotifierProvider .select((value) => value.locale), @@ -254,7 +256,7 @@ class _TransactionDetailsViewState height: 2, ), SelectableText( - "${Format.localizedStringAsFixed(value: (coin == Coin.monero || coin == Coin.wownero ? (amount / 10000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch( + "${Format.localizedStringAsFixed(value: (coin == Coin.monero ? (amount / 10000.toDecimal()).toDecimal() : coin == Coin.wownero ? (amount / 1000.toDecimal()).toDecimal() : amount) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1)), locale: ref.watch( localeServiceChangeNotifierProvider .select((value) => value.locale), ), decimalPlaces: 2)} ${ref.watch( @@ -462,18 +464,23 @@ class _TransactionDetailsViewState showFeePending ? _transaction.confirmedStatus ? Format.localizedStringAsFixed( - value: coin == Coin.monero || coin == Coin.wownero + value: coin == Coin.monero ? (fee / 10000.toDecimal()).toDecimal() - : fee, + : coin == Coin.wownero + ? (fee / 1000.toDecimal()) + .toDecimal() + : fee, locale: ref.watch( localeServiceChangeNotifierProvider .select((value) => value.locale)), decimalPlaces: Constants.decimalPlaces) : "Pending" : Format.localizedStringAsFixed( - value: coin == Coin.monero || coin == Coin.wownero + value: coin == Coin.monero ? (fee / 10000.toDecimal()).toDecimal() - : fee, + : coin == Coin.wownero + ? (fee / 1000.toDecimal()).toDecimal() + : fee, locale: ref.watch( localeServiceChangeNotifierProvider .select((value) => value.locale)), diff --git a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart index 028c04416..8175597f6 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart @@ -750,11 +750,16 @@ class _TransactionSearchViewState } int? amount; if (amountDecimal != null) { - if (widget.coin == Coin.monero || widget.coin == Coin.wownero) { + if (widget.coin == Coin.monero) { amount = (amountDecimal * Decimal.fromInt(Constants.satsPerCoinMonero)) .floor() .toBigInt() .toInt(); + } else if (widget.coin == Coin.wownero) { + amount = (amountDecimal * Decimal.fromInt(Constants.satsPerCoinWownero)) + .floor() + .toBigInt() + .toInt(); } else { amount = (amountDecimal * Decimal.fromInt(Constants.satsPerCoin)) .floor() diff --git a/lib/services/coins/wownero/wownero_wallet.dart b/lib/services/coins/wownero/wownero_wallet.dart index 857b89031..7114269ec 100644 --- a/lib/services/coins/wownero/wownero_wallet.dart +++ b/lib/services/coins/wownero/wownero_wallet.dart @@ -1452,7 +1452,7 @@ class WowneroWallet extends CoinServiceAPI { try { Logging.instance .log("$toAddress $amount $args", level: LogLevel.Info); - String amountToSend = wowneroAmountToString(amount: amount * 10000); + String amountToSend = wowneroAmountToString(amount: amount * 1000); Logging.instance.log("$amount $amountToSend", level: LogLevel.Info); wownero_output.Output output = wownero_output.Output(walletBase!); diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 0700950a4..b30f9e9e5 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_libmonero/monero/monero.dart'; +import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; @@ -367,8 +368,13 @@ class WalletsService extends ChangeNotifier { await DB.instance.delete( boxName: DB.boxNameAllWalletsData, key: "${walletId}_mnemonicHasBeenVerified"); - - if (coinFromPrettyName(shell['coin'] as String) == Coin.monero) { + if (coinFromPrettyName(shell['coin'] as String) == Coin.wownero) { + final wowService = + wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); + await wowService.remove(walletId); + Logging.instance + .log("monero wallet: $walletId deleted", level: LogLevel.Info); + } else if (coinFromPrettyName(shell['coin'] as String) == Coin.monero) { final xmrService = monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); await xmrService.remove(walletId); diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 5684577b1..f5139477c 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -18,6 +18,7 @@ abstract class Constants { //TODO: correct for monero? static const int satsPerCoinMonero = 1000000000000; + static const int satsPerCoinWownero = 100000000000; static const int satsPerCoin = 100000000; static const int decimalPlaces = 8; diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 468e96dc9..b2feaca7a 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -170,9 +170,11 @@ class _TransactionCardState extends ConsumerState { fit: BoxFit.scaleDown, child: Builder( builder: (_) { - final amount = coin == Coin.monero || coin == Coin.wownero + final amount = coin == Coin.monero ? (_transaction.amount ~/ 10000) - : _transaction.amount; + : coin == Coin.wownero + ? (_transaction.amount ~/ 1000) + : _transaction.amount; return Text( "${Format.satoshiAmountToPrettyString(amount, locale)} ${coin.ticker}", style: @@ -210,8 +212,10 @@ class _TransactionCardState extends ConsumerState { builder: (_) { // TODO: modify Format. to take optional Coin parameter so this type oif check isn't done in ui int value = _transaction.amount; - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin == Coin.monero) { value = (value ~/ 10000); + } else if (coin == Coin.wownero) { + value = (value ~/ 1000); } return Text( diff --git a/pubspec.lock b/pubspec.lock index 71145aef4..2cc67f611 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -317,6 +317,13 @@ packages: relative: true source: path version: "0.0.1" + cw_wownero: + dependency: "direct main" + description: + path: "crypto_plugins/flutter_libmonero/cw_wownero" + relative: true + source: path + version: "0.0.1" dart_numerics: dependency: "direct main" description: