spark send to self hide spark change amount on tx card

This commit is contained in:
julian 2024-01-05 08:41:22 -06:00
parent 4de6670a7d
commit 3cf0d82085
4 changed files with 38 additions and 1 deletions

View file

@ -31,10 +31,12 @@ import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/format.dart';
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/wallet/wallet_mixin_interfaces/spark_interface.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
@ -903,6 +905,17 @@ class _DesktopTransactionCardRowState
case TransactionType.sentToSelf:
if (_transaction.subType == TransactionSubType.sparkMint) {
amount = _transaction.getAmountSparkSelfMinted(coin: coin);
} else if (_transaction.subType == TransactionSubType.sparkSpend) {
final changeAddress =
(ref.watch(pWallets).getWallet(walletId) as SparkInterface)
.sparkChangeAddress;
amount = Amount(
rawValue: _transaction.outputs
.where((e) =>
e.walletOwns && !e.addresses.contains(changeAddress))
.fold(BigInt.zero, (p, e) => p + e.value),
fractionDigits: coin.decimals,
);
} else {
amount = _transaction.getAmountReceivedInThisWallet(coin: coin);
}

View file

@ -19,6 +19,7 @@ import 'package:stackwallet/utilities/format.dart';
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/wallet/wallet_mixin_interfaces/spark_interface.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
class TransactionCardV2 extends ConsumerStatefulWidget {
@ -103,6 +104,17 @@ class _TransactionCardStateV2 extends ConsumerState<TransactionCardV2> {
case TransactionType.sentToSelf:
if (_transaction.subType == TransactionSubType.sparkMint) {
amount = _transaction.getAmountSparkSelfMinted(coin: coin);
} else if (_transaction.subType == TransactionSubType.sparkSpend) {
final changeAddress =
(ref.watch(pWallets).getWallet(walletId) as SparkInterface)
.sparkChangeAddress;
amount = Amount(
rawValue: _transaction.outputs
.where((e) =>
e.walletOwns && !e.addresses.contains(changeAddress))
.fold(BigInt.zero, (p, e) => p + e.value),
fractionDigits: coin.decimals,
);
} else {
amount = _transaction.getAmountReceivedInThisWallet(coin: coin);
}

View file

@ -34,6 +34,7 @@ import 'package:stackwallet/utilities/logger.dart';
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/wallet/wallet_mixin_interfaces/spark_interface.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';
@ -138,6 +139,17 @@ class _TransactionV2DetailsViewState
case TransactionType.sentToSelf:
if (_transaction.subType == TransactionSubType.sparkMint) {
amount = _transaction.getAmountSparkSelfMinted(coin: coin);
} else if (_transaction.subType == TransactionSubType.sparkSpend) {
final changeAddress =
(ref.read(pWallets).getWallet(walletId) as SparkInterface)
.sparkChangeAddress;
amount = Amount(
rawValue: _transaction.outputs
.where((e) =>
e.walletOwns && !e.addresses.contains(changeAddress))
.fold(BigInt.zero, (p, e) => p + e.value),
fractionDigits: coin.decimals,
);
} else {
amount = _transaction.getAmountReceivedInThisWallet(coin: coin);
}

View file

@ -426,7 +426,7 @@ class FiroWallet extends Bip39HDWallet
TransactionType type;
TransactionSubType subType = TransactionSubType.none;
// TODO integrate the following with the next bit
// TODO integrate the following with the next bit (maybe)
if (isSparkSpend) {
subType = TransactionSubType.sparkSpend;
} else if (isSparkMint) {