various firo related clean up and fixes

This commit is contained in:
julian 2023-11-24 11:56:38 -06:00
parent e78af049ee
commit 430882cb6a
8 changed files with 48 additions and 157 deletions

View file

@ -32,6 +32,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -109,11 +110,8 @@ class _ConfirmChangeNowSendViewState
final String note = widget.txData.note ?? ""; final String note = widget.txData.note ?? "";
try { try {
if (widget.shouldSendPublicFiroFunds == true) { if (wallet is FiroWallet && widget.shouldSendPublicFiroFunds == false) {
// TODO: [prio=high] fixme txidFuture = wallet.confirmSendLelantus(txData: widget.txData);
throw UnimplementedError("fixme");
// txidFuture = (wallet as FiroWallet)
// .confirmSendPublic(txData: widget.txData);
} else { } else {
txidFuture = wallet.confirmSend(txData: widget.txData); txidFuture = wallet.confirmSend(txData: widget.txData);
} }

View file

@ -36,6 +36,7 @@ import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -240,17 +241,14 @@ class _Step4ViewState extends ConsumerState<Step4View> {
Future<TxData> txDataFuture; Future<TxData> txDataFuture;
if (firoPublicSend) { if (wallet is FiroWallet && !firoPublicSend) {
// TODO: [prio=high] txDataFuture = wallet.prepareSendLelantus(
throw UnimplementedError(); txData: TxData(
// txDataFuture = (wallet as FiroWallet).prepareSendPublic( recipients: [(address: address, amount: amount)],
// address: address, note: "${model.trade!.payInCurrency.toUpperCase()}/"
// amount: amount, "${model.trade!.payOutCurrency.toUpperCase()} exchange",
// args: { ),
// "feeRate": FeeRateType.average, );
// // ref.read(feeRateTypeStateProvider)
// },
// );
} else { } else {
final memo = wallet.info.coin == Coin.stellar || final memo = wallet.info.coin == Coin.stellar ||
wallet.info.coin == Coin.stellarTestnet wallet.info.coin == Coin.stellarTestnet

View file

@ -38,6 +38,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
// import 'package:stackwallet/wallets/example/libepiccash.dart'; // import 'package:stackwallet/wallets/example/libepiccash.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -139,13 +140,10 @@ class _ConfirmTransactionViewState
} else if (widget.isPaynymTransaction) { } else if (widget.isPaynymTransaction) {
txDataFuture = wallet.confirmSend(txData: widget.txData); txDataFuture = wallet.confirmSend(txData: widget.txData);
} else { } else {
if ((coin == Coin.firo || coin == Coin.firoTestNet) && if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state != ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") { "Private") {
// TODO: [prio=high] fixme txDataFuture = wallet.confirmSendLelantus(txData: widget.txData);
throw UnimplementedError("fixme");
// txidFuture = (wallet as FiroWallet)
// .confirmSendPublic(txData: transactionInfo);
} else { } else {
if (coin == Coin.epicCash) { if (coin == Coin.epicCash) {
txDataFuture = wallet.confirmSend( txDataFuture = wallet.confirmSend(

View file

@ -51,6 +51,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/animated_text.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
@ -491,19 +492,14 @@ class _SendViewState extends ConsumerState<SendView> {
: null, : null,
), ),
); );
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) && } else if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state != ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") { "Private") {
throw UnimplementedError("FIXME"); txDataFuture = wallet.prepareSendLelantus(
// TODO: [prio=high] firo prepare send using TxData txData: TxData(
// txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic( recipients: [(address: _address!, amount: amount)],
// address: _address!, ),
// amount: amount, );
// args: {
// "feeRate": ref.read(feeRateTypeStateProvider),
// "satsPerVByte": isCustomFee ? customFeeRate : null,
// },
// );
} else { } else {
final memo = coin == Coin.stellar || coin == Coin.stellarTestnet final memo = coin == Coin.stellar || coin == Coin.stellarTestnet
? memoController.text ? memoController.text
@ -1437,8 +1433,9 @@ class _SendViewState extends ConsumerState<SendView> {
pAmountFormatter(coin)) pAmountFormatter(coin))
.format( .format(
ref ref
.watch(pWalletBalance( .watch(
walletId)) pWalletBalanceSecondary(
walletId))
.spendable, .spendable,
), ),
style: STextStyles.itemSubtitle( style: STextStyles.itemSubtitle(
@ -1451,9 +1448,8 @@ class _SendViewState extends ConsumerState<SendView> {
pAmountFormatter(coin)) pAmountFormatter(coin))
.format( .format(
ref ref
.watch( .watch(pWalletBalance(
pWalletBalanceSecondary( walletId))
walletId))
.spendable, .spendable,
), ),
style: STextStyles.itemSubtitle( style: STextStyles.itemSubtitle(

View file

@ -35,13 +35,6 @@ class _FiroBalanceSelectionSheetState
extends ConsumerState<FiroBalanceSelectionSheet> { extends ConsumerState<FiroBalanceSelectionSheet> {
late final String walletId; late final String walletId;
final stringsToLoopThrough = [
"Loading balance",
"Loading balance.",
"Loading balance..",
"Loading balance...",
];
@override @override
void initState() { void initState() {
walletId = widget.walletId; walletId = widget.walletId;

View file

@ -50,6 +50,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/models/tx_data.dart'; import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/animated_text.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -67,8 +68,6 @@ import 'package:stackwallet/widgets/rounded_container.dart';
import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:stackwallet/widgets/textfield_icon_button.dart';
import '../../../../wallets/isar/models/wallet_info.dart';
class DesktopSend extends ConsumerStatefulWidget { class DesktopSend extends ConsumerStatefulWidget {
const DesktopSend({ const DesktopSend({
Key? key, Key? key,
@ -117,9 +116,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Amount? _cachedAmountToSend; Amount? _cachedAmountToSend;
String? _address; String? _address;
String? _privateBalanceString;
String? _publicBalanceString;
bool _addressToggleFlag = false; bool _addressToggleFlag = false;
bool _cryptoAmountChangeLock = false; bool _cryptoAmountChangeLock = false;
@ -316,24 +312,14 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
: null, : null,
), ),
); );
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) && } else if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state != ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") { "Private") {
throw UnimplementedError("FIXME"); txDataFuture = wallet.prepareSendLelantus(
// TODO: [prio=high] firo prepare send using TxData txData: TxData(
// txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic( recipients: [(address: _address!, amount: amount)],
// address: _address!, ),
// amount: amount, );
// args: {
// "feeRate": ref.read(feeRateTypeStateProvider),
// "satsPerVByte": isCustomFee ? customFeeRate : null,
// "UTXOs": (wallet is CoinControlInterface &&
// coinControlEnabled &&
// ref.read(desktopUseUTXOs).isNotEmpty)
// ? ref.read(desktopUseUTXOs)
// : null,
// },
// );
} else { } else {
final memo = isStellar ? memoController.text : null; final memo = isStellar ? memoController.text : null;
txDataFuture = wallet.prepareSend( txDataFuture = wallet.prepareSend(
@ -545,56 +531,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
} }
} }
Future<String?> _firoBalanceFuture(
WalletInfo info,
String locale,
bool private,
) async {
if (info.coin == Coin.firo || info.coin == Coin.firoTestNet) {
final Amount balance;
if (private) {
balance = info.cachedBalance.spendable;
// balance = wallet.availablePrivateBalance();
} else {
balance = info.cachedBalanceSecondary.spendable;
// balance = wallet.availablePublicBalance();
}
return ref.read(pAmountFormatter(coin)).format(balance);
}
return null;
}
Widget firoBalanceFutureBuilder(
BuildContext context,
AsyncSnapshot<String?> snapshot,
bool private,
) {
if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
if (private) {
_privateBalanceString = snapshot.data!;
} else {
_publicBalanceString = snapshot.data!;
}
}
if (private && _privateBalanceString != null) {
return Text(
"$_privateBalanceString",
style: STextStyles.itemSubtitle(context),
);
} else if (!private && _publicBalanceString != null) {
return Text(
"$_publicBalanceString",
style: STextStyles.itemSubtitle(context),
);
} else {
return AnimatedText(
stringsToLoopThrough: stringsToLoopThrough,
style: STextStyles.itemSubtitle(context),
);
}
}
Future<void> scanQr() async { Future<void> scanQr() async {
try { try {
if (FocusScope.of(context).hasFocus) { if (FocusScope.of(context).hasFocus) {
@ -936,18 +872,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
FutureBuilder( Text(
future: _firoBalanceFuture( ref.watch(pAmountFormatter(coin)).format(ref
ref.watch(pWalletInfo(walletId)), .watch(pWalletBalanceSecondary(walletId))
locale, .spendable),
true, style: STextStyles.itemSubtitle(context),
),
builder: (context, AsyncSnapshot<String?> snapshot) =>
firoBalanceFutureBuilder(
context,
snapshot,
true,
),
), ),
], ],
), ),
@ -963,18 +892,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
FutureBuilder( Text(
future: _firoBalanceFuture( ref.watch(pAmountFormatter(coin)).format(ref
ref.watch(pWalletInfo(walletId)), .watch(pWalletBalanceSecondary(walletId))
locale, .spendable),
false, style: STextStyles.itemSubtitle(context),
),
builder: (context, AsyncSnapshot<String?> snapshot) =>
firoBalanceFutureBuilder(
context,
snapshot,
false,
),
), ),
], ],
), ),

View file

@ -8,7 +8,6 @@
* *
*/ */
import 'dart:async';
import 'dart:core' as core; import 'dart:core' as core;
import 'dart:core'; import 'dart:core';
import 'dart:io'; import 'dart:io';
@ -36,19 +35,6 @@ class Logging {
this.isar = isar; this.isar = isar;
} }
Future<void> initInIsolate() async {
if (isTestEnv || isArmLinux) {
// do this for now until we mock Isar properly for testing
isar = null;
return;
}
isar = await Isar.open(
[LogSchema],
inspector: false,
maxSizeMiB: 512,
);
}
void log( void log(
core.Object? object, { core.Object? object, {
required LogLevel level, required LogLevel level,

View file

@ -809,7 +809,7 @@ class FiroWallet extends Bip39HDWallet
await recoverLelantusWallet( await recoverLelantusWallet(
latestSetId: latestSetId, latestSetId: latestSetId,
setDataMap: futureResults[1] as Map<dynamic, dynamic>, setDataMap: futureResults[1] as Map<dynamic, dynamic>,
usedSerialNumbers: futureResults[1] as List<String>, usedSerialNumbers: futureResults[0] as List<String>,
); );
await updateBalance(); await updateBalance();