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/wallets/isar/providers/wallet_info_provider.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/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -109,11 +110,8 @@ class _ConfirmChangeNowSendViewState
final String note = widget.txData.note ?? "";
try {
if (widget.shouldSendPublicFiroFunds == true) {
// TODO: [prio=high] fixme
throw UnimplementedError("fixme");
// txidFuture = (wallet as FiroWallet)
// .confirmSendPublic(txData: widget.txData);
if (wallet is FiroWallet && widget.shouldSendPublicFiroFunds == false) {
txidFuture = wallet.confirmSendLelantus(txData: widget.txData);
} else {
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/wallets/isar/providers/wallet_info_provider.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/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -240,17 +241,14 @@ class _Step4ViewState extends ConsumerState<Step4View> {
Future<TxData> txDataFuture;
if (firoPublicSend) {
// TODO: [prio=high]
throw UnimplementedError();
// txDataFuture = (wallet as FiroWallet).prepareSendPublic(
// address: address,
// amount: amount,
// args: {
// "feeRate": FeeRateType.average,
// // ref.read(feeRateTypeStateProvider)
// },
// );
if (wallet is FiroWallet && !firoPublicSend) {
txDataFuture = wallet.prepareSendLelantus(
txData: TxData(
recipients: [(address: address, amount: amount)],
note: "${model.trade!.payInCurrency.toUpperCase()}/"
"${model.trade!.payOutCurrency.toUpperCase()} exchange",
),
);
} else {
final memo = wallet.info.coin == Coin.stellar ||
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/wallets/isar/providers/wallet_info_provider.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/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
@ -139,13 +140,10 @@ class _ConfirmTransactionViewState
} else if (widget.isPaynymTransaction) {
txDataFuture = wallet.confirmSend(txData: widget.txData);
} else {
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.read(publicPrivateBalanceStateProvider.state).state !=
if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") {
// TODO: [prio=high] fixme
throw UnimplementedError("fixme");
// txidFuture = (wallet as FiroWallet)
// .confirmSendPublic(txData: transactionInfo);
txDataFuture = wallet.confirmSendLelantus(txData: widget.txData);
} else {
if (coin == Coin.epicCash) {
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/wallets/isar/providers/wallet_info_provider.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/widgets/animated_text.dart';
import 'package:stackwallet/widgets/background.dart';
@ -491,19 +492,14 @@ class _SendViewState extends ConsumerState<SendView> {
: null,
),
);
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.read(publicPrivateBalanceStateProvider.state).state !=
} else if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") {
throw UnimplementedError("FIXME");
// TODO: [prio=high] firo prepare send using TxData
// txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic(
// address: _address!,
// amount: amount,
// args: {
// "feeRate": ref.read(feeRateTypeStateProvider),
// "satsPerVByte": isCustomFee ? customFeeRate : null,
// },
// );
txDataFuture = wallet.prepareSendLelantus(
txData: TxData(
recipients: [(address: _address!, amount: amount)],
),
);
} else {
final memo = coin == Coin.stellar || coin == Coin.stellarTestnet
? memoController.text
@ -1437,8 +1433,9 @@ class _SendViewState extends ConsumerState<SendView> {
pAmountFormatter(coin))
.format(
ref
.watch(pWalletBalance(
walletId))
.watch(
pWalletBalanceSecondary(
walletId))
.spendable,
),
style: STextStyles.itemSubtitle(
@ -1451,9 +1448,8 @@ class _SendViewState extends ConsumerState<SendView> {
pAmountFormatter(coin))
.format(
ref
.watch(
pWalletBalanceSecondary(
walletId))
.watch(pWalletBalance(
walletId))
.spendable,
),
style: STextStyles.itemSubtitle(

View file

@ -35,13 +35,6 @@ class _FiroBalanceSelectionSheetState
extends ConsumerState<FiroBalanceSelectionSheet> {
late final String walletId;
final stringsToLoopThrough = [
"Loading balance",
"Loading balance.",
"Loading balance..",
"Loading balance...",
];
@override
void initState() {
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/wallets/isar/providers/wallet_info_provider.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/widgets/animated_text.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/textfield_icon_button.dart';
import '../../../../wallets/isar/models/wallet_info.dart';
class DesktopSend extends ConsumerStatefulWidget {
const DesktopSend({
Key? key,
@ -117,9 +116,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Amount? _cachedAmountToSend;
String? _address;
String? _privateBalanceString;
String? _publicBalanceString;
bool _addressToggleFlag = false;
bool _cryptoAmountChangeLock = false;
@ -316,24 +312,14 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
: null,
),
);
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
ref.read(publicPrivateBalanceStateProvider.state).state !=
} else if (wallet is FiroWallet &&
ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") {
throw UnimplementedError("FIXME");
// TODO: [prio=high] firo prepare send using TxData
// txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic(
// 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,
// },
// );
txDataFuture = wallet.prepareSendLelantus(
txData: TxData(
recipients: [(address: _address!, amount: amount)],
),
);
} else {
final memo = isStellar ? memoController.text : null;
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 {
try {
if (FocusScope.of(context).hasFocus) {
@ -936,18 +872,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
const SizedBox(
width: 10,
),
FutureBuilder(
future: _firoBalanceFuture(
ref.watch(pWalletInfo(walletId)),
locale,
true,
),
builder: (context, AsyncSnapshot<String?> snapshot) =>
firoBalanceFutureBuilder(
context,
snapshot,
true,
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalanceSecondary(walletId))
.spendable),
style: STextStyles.itemSubtitle(context),
),
],
),
@ -963,18 +892,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
const SizedBox(
width: 10,
),
FutureBuilder(
future: _firoBalanceFuture(
ref.watch(pWalletInfo(walletId)),
locale,
false,
),
builder: (context, AsyncSnapshot<String?> snapshot) =>
firoBalanceFutureBuilder(
context,
snapshot,
false,
),
Text(
ref.watch(pAmountFormatter(coin)).format(ref
.watch(pWalletBalanceSecondary(walletId))
.spendable),
style: STextStyles.itemSubtitle(context),
),
],
),

View file

@ -8,7 +8,6 @@
*
*/
import 'dart:async';
import 'dart:core' as core;
import 'dart:core';
import 'dart:io';
@ -36,19 +35,6 @@ class Logging {
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(
core.Object? object, {
required LogLevel level,

View file

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