mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 09:17:37 +00:00
mostly (roughly) refactored with new wallet providers as well as using a TxData object in place of dynamic Maps
This commit is contained in:
parent
be39ad2cd7
commit
5ba29b7299
190 changed files with 3262 additions and 2963 deletions
|
@ -21,7 +21,7 @@ import 'package:stackwallet/models/isar/stack_theme.dart';
|
|||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||
import 'package:stackwallet/wallets/isar_models/wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
part '../queries/queries.dart';
|
||||
|
|
|
@ -31,6 +31,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/default_eth_tokens.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -99,7 +100,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
|||
.toList();
|
||||
|
||||
final ethWallet =
|
||||
ref.read(pWallets).getManager(widget.walletId).wallet as EthereumWallet;
|
||||
ref.read(pWallets).getWallet(widget.walletId) as EthereumWallet;
|
||||
|
||||
await ethWallet.updateTokenContracts(selectedTokens);
|
||||
if (mounted) {
|
||||
|
@ -179,11 +180,9 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
|||
|
||||
tokenEntities.addAll(contracts.map((e) => AddTokenListElementData(e)));
|
||||
|
||||
final walletContracts = (ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as EthereumWallet)
|
||||
.getWalletTokenContractAddresses();
|
||||
final walletContracts =
|
||||
(ref.read(pWallets).getWallet(widget.walletId) as EthereumWallet)
|
||||
.getWalletTokenContractAddresses();
|
||||
|
||||
final shouldMarkAsSelectedContracts = [
|
||||
...walletContracts,
|
||||
|
@ -207,8 +206,7 @@ class _EditWalletTokensViewState extends ConsumerState<EditWalletTokensView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final walletName = ref.watch(pWallets
|
||||
.select((value) => value.getManager(widget.walletId).walletName));
|
||||
final walletName = ref.watch(pWalletName(widget.walletId));
|
||||
|
||||
if (isDesktop) {
|
||||
return ConditionalParent(
|
||||
|
|
|
@ -12,22 +12,22 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/name_generator.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
|
@ -81,10 +81,15 @@ class _NameYourWalletViewState extends ConsumerState<NameYourWalletView> {
|
|||
void initState() {
|
||||
isDesktop = Util.isDesktop;
|
||||
|
||||
ref.read(walletsServiceChangeNotifierProvider).walletNames.then(
|
||||
(value) => namesToExclude.addAll(
|
||||
value.values.map((e) => e.name),
|
||||
),
|
||||
ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.walletInfo
|
||||
.where()
|
||||
.nameProperty()
|
||||
.findAll()
|
||||
.then(
|
||||
(values) => namesToExclude.addAll(values),
|
||||
);
|
||||
generator = NameGenerator();
|
||||
addWalletType = widget.addWalletType;
|
||||
|
@ -333,64 +338,48 @@ class _NameYourWalletViewState extends ConsumerState<NameYourWalletView> {
|
|||
child: TextButton(
|
||||
onPressed: _nextEnabled
|
||||
? () async {
|
||||
final walletsService =
|
||||
ref.read(walletsServiceChangeNotifierProvider);
|
||||
final name = textEditingController.text;
|
||||
|
||||
final hasDuplicateName =
|
||||
await walletsService.checkForDuplicate(name);
|
||||
|
||||
if (mounted) {
|
||||
if (hasDuplicateName) {
|
||||
unawaited(showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Wallet name already in use.",
|
||||
iconAsset: Assets.svg.circleAlert,
|
||||
context: context,
|
||||
));
|
||||
} else {
|
||||
// hide keyboard if has focus
|
||||
if (FocusScope.of(context).hasFocus) {
|
||||
FocusScope.of(context).unfocus();
|
||||
await Future<void>.delayed(
|
||||
const Duration(milliseconds: 50));
|
||||
}
|
||||
// hide keyboard if has focus
|
||||
if (FocusScope.of(context).hasFocus) {
|
||||
FocusScope.of(context).unfocus();
|
||||
await Future<void>.delayed(
|
||||
const Duration(milliseconds: 50));
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
ref
|
||||
.read(mnemonicWordCountStateProvider.state)
|
||||
.state =
|
||||
Constants.possibleLengthsForCoin(coin).last;
|
||||
ref.read(pNewWalletOptions.notifier).state = null;
|
||||
if (mounted) {
|
||||
ref.read(mnemonicWordCountStateProvider.state).state =
|
||||
Constants.possibleLengthsForCoin(coin).last;
|
||||
ref.read(pNewWalletOptions.notifier).state = null;
|
||||
|
||||
switch (widget.addWalletType) {
|
||||
case AddWalletType.New:
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
coin.hasMnemonicPassphraseSupport
|
||||
? NewWalletOptionsView.routeName
|
||||
: NewWalletRecoveryPhraseWarningView
|
||||
.routeName,
|
||||
arguments: Tuple2(
|
||||
name,
|
||||
coin,
|
||||
),
|
||||
switch (widget.addWalletType) {
|
||||
case AddWalletType.New:
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
coin.hasMnemonicPassphraseSupport
|
||||
? NewWalletOptionsView.routeName
|
||||
: NewWalletRecoveryPhraseWarningView
|
||||
.routeName,
|
||||
arguments: Tuple2(
|
||||
name,
|
||||
coin,
|
||||
),
|
||||
);
|
||||
break;
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
case AddWalletType.Restore:
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
RestoreOptionsView.routeName,
|
||||
arguments: Tuple2(
|
||||
name,
|
||||
coin,
|
||||
),
|
||||
case AddWalletType.Restore:
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
RestoreOptionsView.routeName,
|
||||
arguments: Tuple2(
|
||||
name,
|
||||
coin,
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,14 @@ import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/v
|
|||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/constants.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.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -37,14 +38,14 @@ import 'package:tuple/tuple.dart';
|
|||
class NewWalletRecoveryPhraseView extends ConsumerStatefulWidget {
|
||||
const NewWalletRecoveryPhraseView({
|
||||
Key? key,
|
||||
required this.manager,
|
||||
required this.wallet,
|
||||
required this.mnemonic,
|
||||
this.clipboardInterface = const ClipboardWrapper(),
|
||||
}) : super(key: key);
|
||||
|
||||
static const routeName = "/newWalletRecoveryPhrase";
|
||||
|
||||
final Manager manager;
|
||||
final Wallet wallet;
|
||||
final List<String> mnemonic;
|
||||
|
||||
final ClipboardInterface clipboardInterface;
|
||||
|
@ -58,14 +59,14 @@ class _NewWalletRecoveryPhraseViewState
|
|||
extends ConsumerState<NewWalletRecoveryPhraseView>
|
||||
// with WidgetsBindingObserver
|
||||
{
|
||||
late Manager _manager;
|
||||
late Wallet _wallet;
|
||||
late List<String> _mnemonic;
|
||||
late ClipboardInterface _clipboardInterface;
|
||||
late final bool isDesktop;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_manager = widget.manager;
|
||||
_wallet = widget.wallet;
|
||||
_mnemonic = widget.mnemonic;
|
||||
_clipboardInterface = widget.clipboardInterface;
|
||||
isDesktop = Util.isDesktop;
|
||||
|
@ -78,14 +79,12 @@ class _NewWalletRecoveryPhraseViewState
|
|||
}
|
||||
|
||||
Future<void> delete() async {
|
||||
await ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.deleteWallet(_manager.walletName, false);
|
||||
await _manager.exitCurrentWallet();
|
||||
await _wallet.exit();
|
||||
await ref.read(pWallets).deleteWallet(_wallet.walletId);
|
||||
}
|
||||
|
||||
Future<void> _copy() async {
|
||||
final words = await _manager.mnemonic;
|
||||
final words = _mnemonic;
|
||||
await _clipboardInterface.setData(ClipboardData(text: words.join(" ")));
|
||||
unawaited(showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
|
@ -191,7 +190,7 @@ class _NewWalletRecoveryPhraseViewState
|
|||
),
|
||||
if (!isDesktop)
|
||||
Text(
|
||||
_manager.walletName,
|
||||
ref.watch(pWalletName(_wallet.walletId)),
|
||||
textAlign: TextAlign.center,
|
||||
style: STextStyles.label(context).copyWith(
|
||||
fontSize: 12,
|
||||
|
@ -305,7 +304,7 @@ class _NewWalletRecoveryPhraseViewState
|
|||
|
||||
unawaited(Navigator.of(context).pushNamed(
|
||||
VerifyRecoveryPhraseView.routeName,
|
||||
arguments: Tuple2(_manager, _mnemonic),
|
||||
arguments: Tuple2(_wallet, _mnemonic),
|
||||
));
|
||||
},
|
||||
style: Theme.of(context)
|
||||
|
|
|
@ -17,10 +17,9 @@ import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet
|
|||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/coin_service.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/services/transaction_notification_tracker.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -30,6 +29,9 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/wallet/bip39_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/wallet.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';
|
||||
|
@ -453,14 +455,9 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
},
|
||||
));
|
||||
|
||||
final walletsService = ref.read(
|
||||
walletsServiceChangeNotifierProvider);
|
||||
|
||||
final walletId =
|
||||
await walletsService.addNewWallet(
|
||||
name: walletName,
|
||||
coin: coin,
|
||||
shouldNotifyListeners: false,
|
||||
final info = WalletInfo.createNew(
|
||||
coin: widget.coin,
|
||||
name: widget.walletName,
|
||||
);
|
||||
|
||||
var node = ref
|
||||
|
@ -480,43 +477,45 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
|
||||
final txTracker =
|
||||
TransactionNotificationTracker(
|
||||
walletId: walletId!);
|
||||
walletId: info.walletId,
|
||||
);
|
||||
|
||||
final failovers = ref
|
||||
.read(nodeServiceChangeNotifierProvider)
|
||||
.failoverNodesFor(coin: widget.coin);
|
||||
|
||||
final wallet = CoinServiceAPI.from(
|
||||
coin,
|
||||
walletId,
|
||||
walletName,
|
||||
ref.read(secureStoreProvider),
|
||||
node,
|
||||
txTracker,
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers,
|
||||
final wallet = await Wallet.create(
|
||||
walletInfo: info,
|
||||
mainDB: ref.read(mainDBProvider),
|
||||
secureStorageInterface:
|
||||
ref.read(secureStoreProvider),
|
||||
nodeService: ref.read(
|
||||
nodeServiceChangeNotifierProvider),
|
||||
prefs:
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
);
|
||||
|
||||
final manager = Manager(wallet);
|
||||
await wallet.init();
|
||||
|
||||
if (coin.hasMnemonicPassphraseSupport &&
|
||||
ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.state !=
|
||||
null) {
|
||||
await manager.initializeNew((
|
||||
mnemonicPassphrase: ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.state!
|
||||
.mnemonicPassphrase,
|
||||
wordCount: ref
|
||||
.read(pNewWalletOptions.state)
|
||||
.state!
|
||||
.mnemonicWordsCount,
|
||||
));
|
||||
} else {
|
||||
await manager.initializeNew(null);
|
||||
}
|
||||
// TODO: [prio=high] finish fleshing this out
|
||||
// if (coin.hasMnemonicPassphraseSupport &&
|
||||
// ref
|
||||
// .read(pNewWalletOptions.state)
|
||||
// .state !=
|
||||
// null) {
|
||||
// await manager.initializeNew((
|
||||
// mnemonicPassphrase: ref
|
||||
// .read(pNewWalletOptions.state)
|
||||
// .state!
|
||||
// .mnemonicPassphrase,
|
||||
// wordCount: ref
|
||||
// .read(pNewWalletOptions.state)
|
||||
// .state!
|
||||
// .mnemonicWordsCount,
|
||||
// ));
|
||||
// } else {
|
||||
// await manager.initializeNew(null);
|
||||
// }
|
||||
|
||||
// pop progress dialog
|
||||
if (mounted) {
|
||||
|
@ -531,8 +530,9 @@ class _NewWalletRecoveryPhraseWarningViewState
|
|||
unawaited(Navigator.of(context).pushNamed(
|
||||
NewWalletRecoveryPhraseView.routeName,
|
||||
arguments: Tuple2(
|
||||
manager,
|
||||
await manager.mnemonic,
|
||||
wallet.walletId,
|
||||
await (wallet as Bip39Wallet)
|
||||
.getMnemonicAsWords(),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -32,10 +32,9 @@ import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/v
|
|||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/coin_service.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/services/transaction_notification_tracker.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
|
@ -50,6 +49,8 @@ import 'package:stackwallet/utilities/enums/form_input_status_enum.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -239,13 +240,13 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
));
|
||||
} else {
|
||||
if (!Platform.isLinux) await Wakelock.enable();
|
||||
final walletsService = ref.read(walletsServiceChangeNotifierProvider);
|
||||
|
||||
final walletId = await walletsService.addNewWallet(
|
||||
name: widget.walletName,
|
||||
coin: widget.coin,
|
||||
shouldNotifyListeners: false,
|
||||
);
|
||||
final info = WalletInfo.createNew(
|
||||
coin: widget.coin,
|
||||
name: widget.walletName,
|
||||
);
|
||||
|
||||
|
||||
bool isRestoring = true;
|
||||
// show restoring in progress
|
||||
unawaited(showDialog<dynamic>(
|
||||
|
@ -256,12 +257,10 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
return RestoringDialog(
|
||||
onCancel: () async {
|
||||
isRestoring = false;
|
||||
ref.read(pWallets.notifier).removeWallet(walletId: walletId!);
|
||||
|
||||
await walletsService.deleteWallet(
|
||||
widget.walletName,
|
||||
false,
|
||||
);
|
||||
await ref.read(pWallets).deleteWallet(
|
||||
info.walletId,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
@ -279,49 +278,29 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
);
|
||||
}
|
||||
|
||||
final txTracker = TransactionNotificationTracker(walletId: walletId!);
|
||||
|
||||
final failovers = ref
|
||||
.read(nodeServiceChangeNotifierProvider)
|
||||
.failoverNodesFor(coin: widget.coin);
|
||||
|
||||
final wallet = CoinServiceAPI.from(
|
||||
widget.coin,
|
||||
walletId,
|
||||
widget.walletName,
|
||||
ref.read(secureStoreProvider),
|
||||
node,
|
||||
txTracker,
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers,
|
||||
);
|
||||
|
||||
final manager = Manager(wallet);
|
||||
final txTracker =
|
||||
TransactionNotificationTracker(walletId: info.walletId);
|
||||
|
||||
try {
|
||||
// TODO GUI option to set maxUnusedAddressGap?
|
||||
// default is 20 but it may miss some transactions if
|
||||
// the previous wallet software generated many addresses
|
||||
// without using them
|
||||
await manager.recoverFromMnemonic(
|
||||
mnemonic: mnemonic,
|
||||
final wallet = await Wallet.create(
|
||||
walletInfo: info,
|
||||
mainDB: ref.read(mainDBProvider),
|
||||
secureStorageInterface: ref.read(secureStoreProvider),
|
||||
nodeService: ref.read(nodeServiceChangeNotifierProvider),
|
||||
prefs: ref.read(prefsChangeNotifierProvider),
|
||||
mnemonicPassphrase: widget.mnemonicPassphrase,
|
||||
maxUnusedAddressGap: widget.coin == Coin.firo ? 50 : 20,
|
||||
maxNumberOfIndexesToCheck: 1000,
|
||||
height: height,
|
||||
mnemonic: mnemonic,
|
||||
);
|
||||
|
||||
await wallet.recover(isRescan: false);
|
||||
|
||||
// check if state is still active before continuing
|
||||
if (mounted) {
|
||||
await ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.setMnemonicVerified(
|
||||
walletId: manager.walletId,
|
||||
);
|
||||
await wallet.info.setMnemonicVerified(
|
||||
isar: ref.read(mainDBProvider).isar,
|
||||
);
|
||||
|
||||
ref
|
||||
.read(pWallets.notifier)
|
||||
.addWallet(walletId: manager.walletId, manager: manager);
|
||||
ref.read(pWallets).addWallet(wallet);
|
||||
|
||||
final isCreateSpecialEthWallet =
|
||||
ref.read(createSpecialEthWalletRoutingFlag);
|
||||
|
@ -358,11 +337,11 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
(route) => false,
|
||||
),
|
||||
);
|
||||
if (manager.coin == Coin.ethereum) {
|
||||
if (info.coin == Coin.ethereum) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
EditWalletTokensView.routeName,
|
||||
arguments: manager.walletId,
|
||||
arguments: wallet.walletId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -408,8 +387,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
builder: (context) {
|
||||
return RestoreFailedDialog(
|
||||
errorMessage: e.toString(),
|
||||
walletId: wallet.walletId,
|
||||
walletName: wallet.walletName,
|
||||
walletId: info.walletId,
|
||||
walletName: info.name,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -63,12 +63,8 @@ class _RestoreFailedDialogState extends ConsumerState<RestoreFailedDialog> {
|
|||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
onPressed: () async {
|
||||
ref.read(pWallets.notifier).removeWallet(walletId: walletId);
|
||||
await ref.read(pWallets).deleteWallet(walletId);
|
||||
|
||||
await ref.read(walletsServiceChangeNotifierProvider).deleteWallet(
|
||||
walletName,
|
||||
false,
|
||||
);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
|
|
@ -16,11 +16,10 @@ import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_
|
|||
import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_service_provider.dart';
|
||||
import 'package:stackwallet/services/wallets_service.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.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';
|
||||
|
@ -54,8 +53,6 @@ class SelectWalletForTokenView extends ConsumerStatefulWidget {
|
|||
class _SelectWalletForTokenViewState
|
||||
extends ConsumerState<SelectWalletForTokenView> {
|
||||
final isDesktop = Util.isDesktop;
|
||||
late final List<String> ethWalletIds;
|
||||
bool _hasEthWallets = false;
|
||||
|
||||
String? _selectedWalletId;
|
||||
|
||||
|
@ -77,18 +74,19 @@ class _SelectWalletForTokenViewState
|
|||
);
|
||||
}
|
||||
|
||||
late int _cachedWalletCount;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ethWalletInfos = ref
|
||||
.watch(pAllWalletsInfo)
|
||||
.where((e) => e.coin == widget.entity.coin)
|
||||
.toList();
|
||||
|
||||
void _updateWalletsList(Map<String, WalletInfo> walletsData) {
|
||||
_cachedWalletCount = walletsData.length;
|
||||
final _hasEthWallets = ethWalletInfos.isNotEmpty;
|
||||
|
||||
walletsData.removeWhere((key, value) => value.coin != widget.entity.coin);
|
||||
ethWalletIds.clear();
|
||||
|
||||
_hasEthWallets = walletsData.isNotEmpty;
|
||||
final List<String> ethWalletIds = [];
|
||||
|
||||
// TODO: proper wallet data class instead of this Hive silliness
|
||||
for (final walletId in walletsData.values.map((e) => e.walletId).toList()) {
|
||||
for (final walletId in ethWalletInfos.map((e) => e.walletId).toList()) {
|
||||
final walletContracts = DB.instance.get<dynamic>(
|
||||
boxName: walletId,
|
||||
key: DBKeys.ethTokenContracts,
|
||||
|
@ -98,28 +96,6 @@ class _SelectWalletForTokenViewState
|
|||
ethWalletIds.add(walletId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
ethWalletIds = [];
|
||||
|
||||
final walletsData =
|
||||
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
||||
_updateWalletsList(walletsData);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// dumb hack
|
||||
ref.watch(newEthWalletTriggerTempUntilHiveCompletelyDeleted);
|
||||
final walletsData =
|
||||
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
||||
if (walletsData.length != _cachedWalletCount) {
|
||||
_updateWalletsList(walletsData);
|
||||
}
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
|
|
|
@ -24,14 +24,16 @@ import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/v
|
|||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.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/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.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -42,13 +44,13 @@ final createSpecialEthWalletRoutingFlag = StateProvider((ref) => false);
|
|||
class VerifyRecoveryPhraseView extends ConsumerStatefulWidget {
|
||||
const VerifyRecoveryPhraseView({
|
||||
Key? key,
|
||||
required this.manager,
|
||||
required this.wallet,
|
||||
required this.mnemonic,
|
||||
}) : super(key: key);
|
||||
|
||||
static const routeName = "/verifyRecoveryPhrase";
|
||||
|
||||
final Manager manager;
|
||||
final Wallet wallet;
|
||||
final List<String> mnemonic;
|
||||
|
||||
@override
|
||||
|
@ -60,13 +62,13 @@ class _VerifyRecoveryPhraseViewState
|
|||
extends ConsumerState<VerifyRecoveryPhraseView>
|
||||
// with WidgetsBindingObserver
|
||||
{
|
||||
late Manager _manager;
|
||||
late Wallet _wallet;
|
||||
late List<String> _mnemonic;
|
||||
late final bool isDesktop;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_manager = widget.manager;
|
||||
_wallet = widget.wallet;
|
||||
_mnemonic = widget.mnemonic;
|
||||
isDesktop = Util.isDesktop;
|
||||
// WidgetsBinding.instance?.addObserver(this);
|
||||
|
@ -119,13 +121,11 @@ class _VerifyRecoveryPhraseViewState
|
|||
}
|
||||
}
|
||||
|
||||
await ref.read(walletsServiceChangeNotifierProvider).setMnemonicVerified(
|
||||
walletId: _manager.walletId,
|
||||
await ref.read(pWalletInfo(_wallet.walletId)).setMnemonicVerified(
|
||||
isar: ref.read(mainDBProvider).isar,
|
||||
);
|
||||
|
||||
ref
|
||||
.read(pWallets.notifier)
|
||||
.addWallet(walletId: _manager.walletId, manager: _manager);
|
||||
ref.read(pWallets).addWallet(_wallet);
|
||||
|
||||
final isCreateSpecialEthWallet =
|
||||
ref.read(createSpecialEthWalletRoutingFlag);
|
||||
|
@ -153,11 +153,11 @@ class _VerifyRecoveryPhraseViewState
|
|||
DesktopHomeView.routeName,
|
||||
),
|
||||
);
|
||||
if (widget.manager.coin == Coin.ethereum) {
|
||||
if (widget.wallet.info.coin == Coin.ethereum) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
EditWalletTokensView.routeName,
|
||||
arguments: widget.manager.walletId,
|
||||
arguments: widget.wallet.walletId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -176,11 +176,11 @@ class _VerifyRecoveryPhraseViewState
|
|||
(route) => false,
|
||||
),
|
||||
);
|
||||
if (widget.manager.coin == Coin.ethereum) {
|
||||
if (widget.wallet.info.coin == Coin.ethereum) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
EditWalletTokensView.routeName,
|
||||
arguments: widget.manager.walletId,
|
||||
arguments: widget.wallet.walletId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -260,10 +260,8 @@ class _VerifyRecoveryPhraseViewState
|
|||
}
|
||||
|
||||
Future<void> delete() async {
|
||||
await ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.deleteWallet(_manager.walletName, false);
|
||||
await _manager.exitCurrentWallet();
|
||||
await _wallet.exit();
|
||||
await ref.read(pWallets).deleteWallet(_wallet.walletId);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -79,14 +79,14 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
|
|||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
List<ContactAddressEntry> addresses = [];
|
||||
final managers = ref.read(pWallets).managers;
|
||||
for (final manager in managers) {
|
||||
final wallets = ref.read(pWallets).wallets;
|
||||
for (final wallet in wallets) {
|
||||
addresses.add(
|
||||
ContactAddressEntry()
|
||||
..coinName = manager.coin.name
|
||||
..address = await manager.currentReceivingAddress
|
||||
..coinName = wallet.info.coin.name
|
||||
..address = (await wallet.getCurrentReceivingAddress())!.value
|
||||
..label = "Current Receiving"
|
||||
..other = manager.walletName,
|
||||
..other = wallet.info.name,
|
||||
);
|
||||
}
|
||||
final self = ContactEntry(
|
||||
|
|
|
@ -15,16 +15,14 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -63,29 +61,33 @@ class _ContactDetailsViewState extends ConsumerState<ContactDetailsView> {
|
|||
|
||||
List<Tuple2<String, Transaction>> _cachedTransactions = [];
|
||||
|
||||
Future<List<Tuple2<String, Transaction>>> _filteredTransactionsByContact(
|
||||
List<Manager> managers,
|
||||
) async {
|
||||
Future<List<Tuple2<String, Transaction>>>
|
||||
_filteredTransactionsByContact() async {
|
||||
final contact =
|
||||
ref.read(addressBookServiceProvider).getContactById(_contactId);
|
||||
|
||||
// TODO: optimise
|
||||
|
||||
List<Tuple2<String, Transaction>> result = [];
|
||||
for (final manager in managers) {
|
||||
final transactions = await MainDB.instance
|
||||
.getTransactions(manager.walletId)
|
||||
.filter()
|
||||
.anyOf(contact.addresses.map((e) => e.address),
|
||||
(q, String e) => q.address((q) => q.valueEqualTo(e)))
|
||||
.sortByTimestampDesc()
|
||||
.findAll();
|
||||
final transactions = await ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.transactions
|
||||
.where()
|
||||
.filter()
|
||||
.anyOf(contact.addresses.map((e) => e.address),
|
||||
(q, String e) => q.address((q) => q.valueEqualTo(e)))
|
||||
.sortByTimestampDesc()
|
||||
.findAll();
|
||||
|
||||
for (final tx in transactions) {
|
||||
result.add(Tuple2(manager.walletId, tx));
|
||||
}
|
||||
List<Tuple2<String, Transaction>> result = [];
|
||||
|
||||
for (final tx in transactions) {
|
||||
result.add(Tuple2(tx.walletId, tx));
|
||||
}
|
||||
|
||||
// sort by date
|
||||
result.sort((a, b) => b.item2.timestamp - a.item2.timestamp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -461,8 +463,7 @@ class _ContactDetailsViewState extends ConsumerState<ContactDetailsView> {
|
|||
height: 12,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _filteredTransactionsByContact(
|
||||
ref.watch(pWallets).managers),
|
||||
future: _filteredTransactionsByContact(),
|
||||
builder: (_,
|
||||
AsyncSnapshot<List<Tuple2<String, Transaction>>>
|
||||
snapshot) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:stackwallet/notifications/show_flush_bar.dart';
|
|||
import 'package:stackwallet/pages/address_book_views/subviews/contact_details_view.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart';
|
||||
import 'package:stackwallet/pages/send_view/send_view.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
|
@ -28,6 +29,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -51,21 +53,15 @@ class ContactPopUp extends ConsumerWidget {
|
|||
final contact = ref.watch(addressBookServiceProvider
|
||||
.select((value) => value.getContactById(contactId)));
|
||||
|
||||
final active = ref
|
||||
.read(pWallets)
|
||||
.managers
|
||||
.where((e) => e.isActiveWallet)
|
||||
.toList(growable: false);
|
||||
final active = ref.read(currentWalletIdProvider);
|
||||
|
||||
assert(active.isEmpty || active.length == 1);
|
||||
|
||||
bool hasActiveWallet = active.length == 1;
|
||||
bool hasActiveWallet = active != null;
|
||||
bool isExchangeFlow =
|
||||
ref.watch(exchangeFlowIsActiveStateProvider.state).state;
|
||||
|
||||
final addresses = contact.addressesSorted.where((e) {
|
||||
if (hasActiveWallet && !isExchangeFlow) {
|
||||
return e.coin == active[0].coin;
|
||||
return e.coin == ref.watch(pWalletCoin(active));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -201,7 +197,7 @@ class ContactPopUp extends ConsumerWidget {
|
|||
child: RoundedWhiteContainer(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No ${active[0].coin.prettyName} addresses found",
|
||||
"No ${ref.watch(pWalletCoin(active!)).prettyName} addresses found",
|
||||
style:
|
||||
STextStyles.itemSubtitle(context),
|
||||
),
|
||||
|
@ -372,8 +368,9 @@ class ContactPopUp extends ConsumerWidget {
|
|||
.pushNamed(
|
||||
SendView.routeName,
|
||||
arguments: Tuple3(
|
||||
active[0].walletId,
|
||||
active[0].coin,
|
||||
active,
|
||||
ref.read(
|
||||
pWalletCoin(active)),
|
||||
SendViewAutoFillData(
|
||||
address: address,
|
||||
contactLabel:
|
||||
|
|
|
@ -1160,14 +1160,14 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
|||
)
|
||||
.then((value) async {
|
||||
if (value is String) {
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(value);
|
||||
final wallet = ref.read(pWallets).getWallet(value);
|
||||
|
||||
// _toController.text = manager.walletName;
|
||||
// model.recipientAddress =
|
||||
// await manager.currentReceivingAddress;
|
||||
_receiveAddressController.text =
|
||||
await manager.currentReceivingAddress;
|
||||
(await wallet.getCurrentReceivingAddress())!
|
||||
.value;
|
||||
|
||||
setState(() {
|
||||
_addressToggleFlag =
|
||||
|
|
|
@ -61,8 +61,8 @@ class _CashFusionViewState extends ConsumerState<CashFusionView> {
|
|||
FusionOption _option = FusionOption.continuous;
|
||||
|
||||
Future<void> _startFusion() async {
|
||||
final fusionWallet = ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
as FusionWalletInterface;
|
||||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as FusionWalletInterface;
|
||||
|
||||
try {
|
||||
fusionWallet.uiState = ref.read(
|
||||
|
|
|
@ -67,7 +67,7 @@ class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
|||
);
|
||||
|
||||
if (shouldCancel == true && mounted) {
|
||||
final fusionWallet = ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
final fusionWallet = ref.read(pWallets).getWallet(widget.walletId)
|
||||
as FusionWalletInterface;
|
||||
|
||||
await showLoading(
|
||||
|
@ -223,8 +223,8 @@ class _FusionProgressViewState extends ConsumerState<FusionProgressView> {
|
|||
|
||||
/// Fuse again.
|
||||
void _fuseAgain() async {
|
||||
final fusionWallet = ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
as FusionWalletInterface;
|
||||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as FusionWalletInterface;
|
||||
|
||||
final fusionInfo = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
|
||||
import 'package:stackwallet/widgets/app_bar_field.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
|
@ -82,10 +83,8 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
|||
final Set<UTXO> _selectedBlocked = {};
|
||||
|
||||
Future<void> _refreshBalance() async {
|
||||
final coinControlInterface = ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as CoinControlInterface;
|
||||
final coinControlInterface =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as CoinControlInterface;
|
||||
await coinControlInterface.refreshBalance(notify: true);
|
||||
}
|
||||
|
||||
|
@ -113,25 +112,8 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final coin = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value
|
||||
.getManager(
|
||||
widget.walletId,
|
||||
)
|
||||
.coin,
|
||||
),
|
||||
);
|
||||
|
||||
final currentChainHeight = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value
|
||||
.getManager(
|
||||
widget.walletId,
|
||||
)
|
||||
.currentHeight,
|
||||
),
|
||||
);
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(widget.walletId));
|
||||
|
||||
if (_sort == CCSortDescriptor.address && !_isSearching) {
|
||||
_list = null;
|
||||
|
@ -357,7 +339,7 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
|||
(widget.type == CoinControlViewType.use &&
|
||||
!utxo.isBlocked &&
|
||||
utxo.isConfirmed(
|
||||
currentChainHeight,
|
||||
currentHeight,
|
||||
coin.requiredConfirmations,
|
||||
)),
|
||||
initialSelectedState: isSelected,
|
||||
|
@ -420,7 +402,7 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
|||
CoinControlViewType.use &&
|
||||
!_showBlocked &&
|
||||
utxo.isConfirmed(
|
||||
currentChainHeight,
|
||||
currentHeight,
|
||||
coin.requiredConfirmations,
|
||||
)),
|
||||
initialSelectedState: isSelected,
|
||||
|
@ -562,7 +544,7 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
|
|||
.use &&
|
||||
!utxo.isBlocked &&
|
||||
utxo.isConfirmed(
|
||||
currentChainHeight,
|
||||
currentHeight,
|
||||
coin.requiredConfirmations,
|
||||
)),
|
||||
initialSelectedState: isSelected,
|
||||
|
|
|
@ -12,12 +12,13 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/utxo_status_icon.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
|
@ -63,11 +64,8 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
|
||||
final currentChainHeight = ref.watch(pWallets
|
||||
.select((value) => value.getManager(widget.walletId).currentHeight));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(widget.walletId));
|
||||
|
||||
return ConditionalParent(
|
||||
condition: widget.onPressed != null,
|
||||
|
@ -112,7 +110,7 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
|
|||
child: UTXOStatusIcon(
|
||||
blocked: utxo.isBlocked,
|
||||
status: utxo.isConfirmed(
|
||||
currentChainHeight,
|
||||
currentHeight,
|
||||
coin.requiredConfirmations,
|
||||
)
|
||||
? UTXOStatusIconStatus.confirmed
|
||||
|
|
|
@ -16,12 +16,13 @@ import 'package:isar/isar.dart';
|
|||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -90,17 +91,8 @@ class _UtxoDetailsViewState extends ConsumerState<UtxoDetailsView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(widget.walletId).coin,
|
||||
),
|
||||
);
|
||||
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(widget.walletId).currentHeight,
|
||||
),
|
||||
);
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(widget.walletId));
|
||||
|
||||
final confirmed = utxo!.isConfirmed(
|
||||
currentHeight,
|
||||
|
|
|
@ -15,6 +15,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -48,7 +49,11 @@ class _ChooseFromStackViewState extends ConsumerState<ChooseFromStackView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final walletIds = ref
|
||||
.watch(pWallets.select((value) => value.getWalletIdsFor(coin: coin)));
|
||||
.watch(pWallets)
|
||||
.wallets
|
||||
.where((e) => e.info.coin == coin)
|
||||
.map((e) => e.walletId)
|
||||
.toList();
|
||||
|
||||
return Background(
|
||||
child: Scaffold(
|
||||
|
@ -78,8 +83,7 @@ class _ChooseFromStackViewState extends ConsumerState<ChooseFromStackView> {
|
|||
: ListView.builder(
|
||||
itemCount: walletIds.length,
|
||||
itemBuilder: (context, index) {
|
||||
final manager = ref.watch(pWallets
|
||||
.select((value) => value.getManager(walletIds[index])));
|
||||
final walletId = walletIds[index];
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
|
@ -98,7 +102,7 @@ class _ChooseFromStackViewState extends ConsumerState<ChooseFromStackView> {
|
|||
elevation: 0,
|
||||
onPressed: () async {
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop(manager.walletId);
|
||||
Navigator.of(context).pop(walletId);
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
|
@ -115,7 +119,7 @@ class _ChooseFromStackViewState extends ConsumerState<ChooseFromStackView> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
manager.walletName,
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.titleBold12(context),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
|
|
@ -20,14 +20,16 @@ import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
|||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
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/models/tx_data.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';
|
||||
|
@ -43,7 +45,7 @@ import 'package:uuid/uuid.dart';
|
|||
class ConfirmChangeNowSendView extends ConsumerStatefulWidget {
|
||||
const ConfirmChangeNowSendView({
|
||||
Key? key,
|
||||
required this.transactionInfo,
|
||||
required this.txData,
|
||||
required this.walletId,
|
||||
this.routeOnSuccessName = WalletView.routeName,
|
||||
required this.trade,
|
||||
|
@ -53,7 +55,7 @@ class ConfirmChangeNowSendView extends ConsumerStatefulWidget {
|
|||
|
||||
static const String routeName = "/confirmChangeNowSend";
|
||||
|
||||
final Map<String, dynamic> transactionInfo;
|
||||
final TxData txData;
|
||||
final String walletId;
|
||||
final String routeOnSuccessName;
|
||||
final Trade trade;
|
||||
|
@ -67,7 +69,6 @@ class ConfirmChangeNowSendView extends ConsumerStatefulWidget {
|
|||
|
||||
class _ConfirmChangeNowSendViewState
|
||||
extends ConsumerState<ConfirmChangeNowSendView> {
|
||||
late final Map<String, dynamic> transactionInfo;
|
||||
late final String walletId;
|
||||
late final String routeOnSuccessName;
|
||||
late final Trade trade;
|
||||
|
@ -75,7 +76,8 @@ class _ConfirmChangeNowSendViewState
|
|||
final isDesktop = Util.isDesktop;
|
||||
|
||||
Future<void> _attemptSend(BuildContext context) async {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
final coin = wallet.info.coin;
|
||||
|
||||
final sendProgressController = ProgressAndSuccessController();
|
||||
|
||||
|
@ -86,7 +88,7 @@ class _ConfirmChangeNowSendViewState
|
|||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return SendingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
controller: sendProgressController,
|
||||
);
|
||||
},
|
||||
|
@ -100,19 +102,21 @@ class _ConfirmChangeNowSendViewState
|
|||
);
|
||||
|
||||
late String txid;
|
||||
Future<String> txidFuture;
|
||||
Future<TxData> txidFuture;
|
||||
|
||||
final String note = transactionInfo["note"] as String? ?? "";
|
||||
final String note = widget.txData.note ?? "";
|
||||
|
||||
try {
|
||||
if (widget.shouldSendPublicFiroFunds == true) {
|
||||
txidFuture = (manager.wallet as FiroWallet)
|
||||
.confirmSendPublic(txData: transactionInfo);
|
||||
// TODO: [prio=high] fixme
|
||||
throw UnimplementedError("fixme");
|
||||
// txidFuture = (wallet as FiroWallet)
|
||||
// .confirmSendPublic(txData: widget.txData);
|
||||
} else {
|
||||
txidFuture = manager.confirmSend(txData: transactionInfo);
|
||||
txidFuture = wallet.confirmSend(txData: widget.txData);
|
||||
}
|
||||
|
||||
unawaited(manager.refresh());
|
||||
unawaited(wallet.refresh());
|
||||
|
||||
final results = await Future.wait([
|
||||
txidFuture,
|
||||
|
@ -122,7 +126,7 @@ class _ConfirmChangeNowSendViewState
|
|||
sendProgressController.triggerSuccess?.call();
|
||||
await Future<void>.delayed(const Duration(seconds: 5));
|
||||
|
||||
txid = results.first as String;
|
||||
txid = (results.first as TxData).txid!;
|
||||
|
||||
// save note
|
||||
await ref
|
||||
|
@ -197,7 +201,7 @@ class _ConfirmChangeNowSendViewState
|
|||
Future<void> _confirmSend() async {
|
||||
final dynamic unlocked;
|
||||
|
||||
final coin = ref.read(pWallets).getManager(walletId).coin;
|
||||
final coin = ref.read(pWalletCoin(walletId));
|
||||
|
||||
if (Util.isDesktop) {
|
||||
unlocked = await showDialog<bool?>(
|
||||
|
@ -254,7 +258,6 @@ class _ConfirmChangeNowSendViewState
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
transactionInfo = widget.transactionInfo;
|
||||
walletId = widget.walletId;
|
||||
routeOnSuccessName = widget.routeOnSuccessName;
|
||||
trade = widget.trade;
|
||||
|
@ -263,9 +266,6 @@ class _ConfirmChangeNowSendViewState
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final managerProvider = ref
|
||||
.watch(pWallets.select((value) => value.getManagerProvider(walletId)));
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) {
|
||||
|
@ -337,7 +337,7 @@ class _ConfirmChangeNowSendViewState
|
|||
width: 12,
|
||||
),
|
||||
Text(
|
||||
"Confirm ${ref.watch(managerProvider.select((value) => value.coin)).ticker} transaction",
|
||||
"Confirm ${ref.watch(pWalletCoin(walletId)).ticker} transaction",
|
||||
style: STextStyles.desktopH3(context),
|
||||
)
|
||||
],
|
||||
|
@ -381,18 +381,9 @@ class _ConfirmChangeNowSendViewState
|
|||
children: [
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(ref.watch(
|
||||
managerProvider.select((value) => value.coin),
|
||||
)))
|
||||
.format(transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int)
|
||||
.toAmountAsRaw(
|
||||
fractionDigits: ref.watch(
|
||||
managerProvider.select(
|
||||
(value) => value.coin.decimals),
|
||||
),
|
||||
)),
|
||||
.watch(pAmountFormatter(
|
||||
ref.watch(pWalletCoin(walletId))))
|
||||
.format(widget.txData.fee!),
|
||||
style:
|
||||
STextStyles.desktopTextExtraExtraSmall(context)
|
||||
.copyWith(
|
||||
|
@ -424,17 +415,9 @@ class _ConfirmChangeNowSendViewState
|
|||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final coin = ref.watch(
|
||||
managerProvider.select((value) => value.coin),
|
||||
);
|
||||
final fee = transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int)
|
||||
.toAmountAsRaw(
|
||||
fractionDigits: coin.decimals,
|
||||
);
|
||||
final amount =
|
||||
transactionInfo["recipientAmt"] as Amount;
|
||||
final coin = ref.read(pWalletCoin(walletId));
|
||||
final fee = widget.txData.fee!;
|
||||
final amount = widget.txData.amount!;
|
||||
final total = amount + fee;
|
||||
|
||||
return Text(
|
||||
|
@ -506,7 +489,7 @@ class _ConfirmChangeNowSendViewState
|
|||
),
|
||||
),
|
||||
child: Text(
|
||||
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
|
||||
"Send ${ref.watch(pWalletCoin(walletId)).ticker}",
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextMedium(context)
|
||||
: STextStyles.pageTitleH1(context),
|
||||
|
@ -533,7 +516,7 @@ class _ConfirmChangeNowSendViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
ref.watch(pWallets).getManager(walletId).walletName,
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
|
@ -560,7 +543,7 @@ class _ConfirmChangeNowSendViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
"${transactionInfo["address"] ?? "ERROR"}",
|
||||
widget.txData.recipients!.first.address,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
|
@ -589,13 +572,11 @@ class _ConfirmChangeNowSendViewState
|
|||
children: [
|
||||
child,
|
||||
Builder(builder: (context) {
|
||||
final coin = ref.watch(pWallets.select(
|
||||
(value) => value.getManager(walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
final price = ref.watch(
|
||||
priceAnd24hChangeNotifierProvider
|
||||
.select((value) => value.getPrice(coin)));
|
||||
final amount =
|
||||
transactionInfo["recipientAmt"] as Amount;
|
||||
final amount = widget.txData.amount!;
|
||||
final value = (price.item1 * amount.decimal)
|
||||
.toAmount(fractionDigits: 2);
|
||||
final currency = ref.watch(prefsChangeNotifierProvider
|
||||
|
@ -621,9 +602,9 @@ class _ConfirmChangeNowSendViewState
|
|||
),
|
||||
child: Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(ref.watch(pWallets.select(
|
||||
(value) => value.getManager(walletId).coin))))
|
||||
.format((transactionInfo["recipientAmt"] as Amount)),
|
||||
.watch(pAmountFormatter(
|
||||
ref.watch(pWalletCoin(walletId))))
|
||||
.format((widget.txData.amount!)),
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
|
@ -650,18 +631,10 @@ class _ConfirmChangeNowSendViewState
|
|||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(ref.watch(
|
||||
managerProvider.select((value) => value.coin),
|
||||
)))
|
||||
.watch(
|
||||
pAmountFormatter(ref.read(pWalletCoin(walletId))))
|
||||
.format(
|
||||
(transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int).toAmountAsRaw(
|
||||
fractionDigits: ref.watch(
|
||||
managerProvider.select(
|
||||
(value) => value.coin.decimals,
|
||||
),
|
||||
))),
|
||||
widget.txData.fee!,
|
||||
),
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
textAlign: TextAlign.right,
|
||||
|
@ -690,7 +663,7 @@ class _ConfirmChangeNowSendViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
transactionInfo["note"] as String? ?? "",
|
||||
widget.txData.note ?? "",
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
|
@ -743,16 +716,9 @@ class _ConfirmChangeNowSendViewState
|
|||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final coin = ref.watch(
|
||||
managerProvider.select((value) => value.coin),
|
||||
);
|
||||
final fee = transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int).toAmountAsRaw(
|
||||
fractionDigits: coin.decimals,
|
||||
);
|
||||
final amount =
|
||||
transactionInfo["recipientAmt"] as Amount;
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
final fee = widget.txData.fee!;
|
||||
final amount = widget.txData.amount!;
|
||||
final total = amount + fee;
|
||||
|
||||
return Text(
|
||||
|
|
|
@ -97,10 +97,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
tuple.item2.ticker.toLowerCase()) {
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManager(tuple.item1)
|
||||
.currentReceivingAddress
|
||||
.getWallet(tuple.item1)
|
||||
.getCurrentReceivingAddress()
|
||||
.then((value) {
|
||||
_toController.text = value;
|
||||
_toController.text = value!.value;
|
||||
model.recipientAddress = _toController.text;
|
||||
});
|
||||
} else {
|
||||
|
@ -108,10 +108,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
tuple.item2.ticker.toUpperCase()) {
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManager(tuple.item1)
|
||||
.currentReceivingAddress
|
||||
.getWallet(tuple.item1)
|
||||
.getCurrentReceivingAddress()
|
||||
.then((value) {
|
||||
_refundController.text = value;
|
||||
_refundController.text = value!.value;
|
||||
model.refundAddress = _refundController.text;
|
||||
});
|
||||
}
|
||||
|
@ -218,14 +218,14 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
)
|
||||
.then((value) async {
|
||||
if (value is String) {
|
||||
final manager = ref
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.getManager(value);
|
||||
.getWallet(value);
|
||||
|
||||
_toController.text =
|
||||
manager.walletName;
|
||||
model.recipientAddress = await manager
|
||||
.currentReceivingAddress;
|
||||
_toController.text = wallet.info.name;
|
||||
model.recipientAddress = (await wallet
|
||||
.getCurrentReceivingAddress())!
|
||||
.value;
|
||||
|
||||
setState(() {
|
||||
enableNext =
|
||||
|
@ -489,14 +489,15 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
)
|
||||
.then((value) async {
|
||||
if (value is String) {
|
||||
final manager = ref
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.getManager(value);
|
||||
.getWallet(value);
|
||||
|
||||
_refundController.text =
|
||||
manager.walletName;
|
||||
model.refundAddress = await manager
|
||||
.currentReceivingAddress;
|
||||
wallet.info.name;
|
||||
model.refundAddress = (await wallet
|
||||
.getCurrentReceivingAddress())!
|
||||
.value;
|
||||
}
|
||||
setState(() {
|
||||
enableNext =
|
||||
|
|
|
@ -35,6 +35,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/models/tx_data.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';
|
||||
|
@ -72,8 +73,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
final coin = coinFromTickerCaseInsensitive(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.managers
|
||||
.where((element) => element.coin == coin)
|
||||
.wallets
|
||||
.where((e) => e.info.coin == coin)
|
||||
.isNotEmpty;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
@ -134,8 +135,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
}
|
||||
|
||||
Future<bool?> _showSendFromFiroBalanceSelectSheet(String walletId) async {
|
||||
final firoWallet =
|
||||
ref.read(pWallets).getManager(walletId).wallet as FiroWallet;
|
||||
final firoWallet = ref.read(pWallets).getWallet(walletId) as FiroWallet;
|
||||
final locale = ref.read(localeServiceChangeNotifierProvider).locale;
|
||||
|
||||
return await showModalBottomSheet<bool?>(
|
||||
|
@ -204,10 +204,10 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
firoPublicSend = false;
|
||||
}
|
||||
|
||||
final manager = ref.read(pWallets).getManager(tuple.item1);
|
||||
final wallet = ref.read(pWallets).getWallet(tuple.item1);
|
||||
|
||||
final Amount amount = model.sendAmount.toAmount(
|
||||
fractionDigits: manager.coin.decimals,
|
||||
fractionDigits: wallet.info.coin.decimals,
|
||||
);
|
||||
final address = model.trade!.payInAddress;
|
||||
|
||||
|
@ -222,7 +222,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return BuildingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: wallet.info.coin,
|
||||
onCancel: () {
|
||||
wasCancelled = true;
|
||||
},
|
||||
|
@ -237,32 +237,36 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
),
|
||||
);
|
||||
|
||||
Future<Map<String, dynamic>> txDataFuture;
|
||||
Future<TxData> txDataFuture;
|
||||
|
||||
if (firoPublicSend) {
|
||||
txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic(
|
||||
address: address,
|
||||
amount: amount,
|
||||
args: {
|
||||
"feeRate": FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
);
|
||||
// TODO: [prio=high]
|
||||
throw UnimplementedError();
|
||||
// txDataFuture = (wallet as FiroWallet).prepareSendPublic(
|
||||
// address: address,
|
||||
// amount: amount,
|
||||
// args: {
|
||||
// "feeRate": FeeRateType.average,
|
||||
// // ref.read(feeRateTypeStateProvider)
|
||||
// },
|
||||
// );
|
||||
} else {
|
||||
final memo =
|
||||
manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet
|
||||
? model.trade!.payInExtraId.isNotEmpty
|
||||
? model.trade!.payInExtraId
|
||||
: null
|
||||
: null;
|
||||
txDataFuture = manager.prepareSend(
|
||||
address: address,
|
||||
amount: amount,
|
||||
args: {
|
||||
"memo": memo,
|
||||
"feeRate": FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
final memo = wallet.info.coin == Coin.stellar ||
|
||||
wallet.info.coin == Coin.stellarTestnet
|
||||
? model.trade!.payInExtraId.isNotEmpty
|
||||
? model.trade!.payInExtraId
|
||||
: null
|
||||
: null;
|
||||
txDataFuture = wallet.prepareSend(
|
||||
txData: TxData(
|
||||
recipients: [
|
||||
(address: address, amount: amount),
|
||||
],
|
||||
memo: memo,
|
||||
feeRateType: FeeRateType.average,
|
||||
note: "${model.trade!.payInCurrency.toUpperCase()}/"
|
||||
"${model.trade!.payOutCurrency.toUpperCase()} exchange",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -271,7 +275,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
time,
|
||||
]);
|
||||
|
||||
final txData = results.first as Map<String, dynamic>;
|
||||
final txData = results.first as TxData;
|
||||
|
||||
if (!wasCancelled) {
|
||||
// pop building dialog
|
||||
|
@ -280,17 +284,13 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
txData["note"] =
|
||||
"${model.trade!.payInCurrency.toUpperCase()}/${model.trade!.payOutCurrency.toUpperCase()} exchange";
|
||||
txData["address"] = address;
|
||||
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmChangeNowSendView(
|
||||
transactionInfo: txData,
|
||||
txData: txData,
|
||||
walletId: tuple.item1,
|
||||
routeOnSuccessName: HomeView.routeName,
|
||||
trade: model.trade!,
|
||||
|
@ -813,8 +813,9 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
tuple.item2.ticker.toLowerCase()) {
|
||||
final walletName = ref
|
||||
.read(pWallets)
|
||||
.getManager(tuple.item1)
|
||||
.walletName;
|
||||
.getWallet(tuple.item1)
|
||||
.info
|
||||
.name;
|
||||
buttonTitle = "Send from $walletName";
|
||||
}
|
||||
|
||||
|
|
|
@ -195,9 +195,9 @@ class _ExchangeViewState extends ConsumerState<ExchangeView> {
|
|||
if (txid != null &&
|
||||
walletIds != null &&
|
||||
walletIds.isNotEmpty) {
|
||||
final manager = ref
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.getManager(walletIds.first);
|
||||
.getWallet(walletIds.first);
|
||||
|
||||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
@ -212,7 +212,7 @@ class _ExchangeViewState extends ConsumerState<ExchangeView> {
|
|||
unawaited(Navigator.of(context).pushNamed(
|
||||
TradeDetailsView.routeName,
|
||||
arguments: Tuple4(tradeId, tx,
|
||||
walletIds.first, manager.walletName),
|
||||
walletIds.first, wallet.info.name),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,6 @@ import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exch
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -33,6 +32,8 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.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/models/tx_data.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';
|
||||
|
@ -86,7 +87,11 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
|
|||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final walletIds = ref
|
||||
.watch(pWallets.select((value) => value.getWalletIdsFor(coin: coin)));
|
||||
.watch(pWallets)
|
||||
.wallets
|
||||
.where((e) => e.info.coin == coin)
|
||||
.map((e) => e.walletId)
|
||||
.toList();
|
||||
|
||||
final isDesktop = Util.isDesktop;
|
||||
|
||||
|
@ -224,7 +229,9 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
late final String address;
|
||||
late final Trade trade;
|
||||
|
||||
Future<void> _send(Manager manager, {bool? shouldSendPublicFiroFunds}) async {
|
||||
Future<void> _send({bool? shouldSendPublicFiroFunds}) async {
|
||||
final coin = ref.read(pWalletCoin(walletId));
|
||||
|
||||
try {
|
||||
bool wasCancelled = false;
|
||||
|
||||
|
@ -245,7 +252,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
),
|
||||
),
|
||||
child: BuildingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
onCancel: () {
|
||||
wasCancelled = true;
|
||||
|
||||
|
@ -263,46 +270,54 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> txData;
|
||||
Future<Map<String, dynamic>> txDataFuture;
|
||||
TxData txData;
|
||||
Future<TxData> txDataFuture;
|
||||
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
|
||||
// if not firo then do normal send
|
||||
if (shouldSendPublicFiroFunds == null) {
|
||||
final memo =
|
||||
manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet
|
||||
? trade.payInExtraId.isNotEmpty
|
||||
? trade.payInExtraId
|
||||
: null
|
||||
: null;
|
||||
txDataFuture = manager.prepareSend(
|
||||
address: address,
|
||||
amount: amount,
|
||||
args: {
|
||||
"memo": memo,
|
||||
"feeRate": FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
final memo = coin == Coin.stellar || coin == Coin.stellarTestnet
|
||||
? trade.payInExtraId.isNotEmpty
|
||||
? trade.payInExtraId
|
||||
: null
|
||||
: null;
|
||||
txDataFuture = wallet.prepareSend(
|
||||
txData: TxData(
|
||||
recipients: [
|
||||
(
|
||||
address: address,
|
||||
amount: amount,
|
||||
),
|
||||
],
|
||||
memo: memo,
|
||||
feeRateType: FeeRateType.average,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final firoWallet = manager.wallet as FiroWallet;
|
||||
final firoWallet = wallet as FiroWallet;
|
||||
// otherwise do firo send based on balance selected
|
||||
if (shouldSendPublicFiroFunds) {
|
||||
txDataFuture = firoWallet.prepareSendPublic(
|
||||
address: address,
|
||||
amount: amount,
|
||||
args: {
|
||||
"feeRate": FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
);
|
||||
throw UnimplementedError();
|
||||
// txDataFuture = firoWallet.prepareSendPublic(
|
||||
// address: address,
|
||||
// amount: amount,
|
||||
// args: {
|
||||
// "feeRate": FeeRateType.average,
|
||||
// // ref.read(feeRateTypeStateProvider)
|
||||
// },
|
||||
// );
|
||||
} else {
|
||||
txDataFuture = firoWallet.prepareSend(
|
||||
address: address,
|
||||
amount: amount,
|
||||
args: {
|
||||
"feeRate": FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
txDataFuture = wallet.prepareSend(
|
||||
txData: TxData(
|
||||
recipients: [
|
||||
(
|
||||
address: address,
|
||||
amount: amount,
|
||||
),
|
||||
],
|
||||
feeRateType: FeeRateType.average,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +327,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
time,
|
||||
]);
|
||||
|
||||
txData = results.first as Map<String, dynamic>;
|
||||
txData = results.first as TxData;
|
||||
|
||||
if (!wasCancelled) {
|
||||
// pop building dialog
|
||||
|
@ -324,16 +339,17 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
).pop();
|
||||
}
|
||||
|
||||
txData["note"] =
|
||||
"${trade.payInCurrency.toUpperCase()}/${trade.payOutCurrency.toUpperCase()} exchange";
|
||||
txData["address"] = address;
|
||||
txData = txData.copyWith(
|
||||
note: "${trade.payInCurrency.toUpperCase()}/"
|
||||
"${trade.payOutCurrency.toUpperCase()} exchange",
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
await Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmChangeNowSendView(
|
||||
transactionInfo: txData,
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
routeOnSuccessName: Util.isDesktop
|
||||
? DesktopExchangeView.routeName
|
||||
|
@ -396,13 +412,12 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager =
|
||||
ref.watch(ref.watch(pWallets.notifier).getManagerProvider(walletId));
|
||||
final wallet = ref.watch(pWallets).getWallet(walletId);
|
||||
|
||||
final locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
||||
final coin = manager.coin;
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final isFiro = coin == Coin.firoTestNet || coin == Coin.firo;
|
||||
|
||||
|
@ -437,7 +452,6 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
if (mounted) {
|
||||
unawaited(
|
||||
_send(
|
||||
manager,
|
||||
shouldSendPublicFiroFunds: false,
|
||||
),
|
||||
);
|
||||
|
@ -464,10 +478,9 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
Text(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePrivateBalance(),
|
||||
),
|
||||
ref.watch(pAmountFormatter(coin)).format(ref
|
||||
.watch(pWalletBalance(walletId))
|
||||
.spendable),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
],
|
||||
|
@ -500,7 +513,6 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
if (mounted) {
|
||||
unawaited(
|
||||
_send(
|
||||
manager,
|
||||
shouldSendPublicFiroFunds: true,
|
||||
),
|
||||
);
|
||||
|
@ -528,8 +540,11 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
),
|
||||
Text(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePublicBalance()),
|
||||
ref
|
||||
.watch(
|
||||
pWalletBalanceSecondary(walletId))
|
||||
.spendable,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
],
|
||||
|
@ -568,7 +583,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
onPressed: () async {
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
_send(manager),
|
||||
_send(),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -580,7 +595,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.colorForCoin(manager.coin)
|
||||
.colorForCoin(coin)
|
||||
.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
|
@ -608,7 +623,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
manager.walletName,
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.titleBold12(context),
|
||||
),
|
||||
if (!isFiro)
|
||||
|
@ -617,9 +632,8 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
|
|||
),
|
||||
if (!isFiro)
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(manager.balance.spendable),
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
ref.watch(pWalletBalance(walletId)).spendable),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/favourite_wallets_provider.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -61,8 +63,17 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
body: isDesktop
|
||||
? Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final favorites = ref.watch(favoritesProvider);
|
||||
final nonFavorites = ref.watch(nonFavoritesProvider);
|
||||
final favorites = ref.watch(pFavouriteWalletInfos);
|
||||
print(
|
||||
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
|
||||
// todo [prio=??] do this differently
|
||||
final nonFavorites = ref
|
||||
.watch(pWallets)
|
||||
.wallets
|
||||
.map((e) => e.info)
|
||||
.where((e) => !e.isFavourite)
|
||||
.toList();
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
|
@ -108,8 +119,7 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
key: key,
|
||||
itemCount: favorites.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final walletId =
|
||||
ref.read(favorites[index]).walletId;
|
||||
final walletId = favorites[index].walletId;
|
||||
return Padding(
|
||||
key: Key(
|
||||
"manageFavoriteWalletsItem_$walletId",
|
||||
|
@ -127,14 +137,43 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.moveFavorite(
|
||||
fromIndex: oldIndex, toIndex: newIndex);
|
||||
final isar = ref.read(mainDBProvider).isar;
|
||||
|
||||
ref
|
||||
.read(favoritesProvider)
|
||||
.reorder(oldIndex, newIndex, true);
|
||||
final actualIndex =
|
||||
favorites[oldIndex].favouriteOrderIndex;
|
||||
if (oldIndex > newIndex) {
|
||||
for (int i = oldIndex - 1; i >= newIndex; i--) {
|
||||
final next = favorites[i];
|
||||
next.updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
next.favouriteOrderIndex + 1,
|
||||
);
|
||||
}
|
||||
favorites[oldIndex].updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
actualIndex - (oldIndex - newIndex),
|
||||
);
|
||||
} else {
|
||||
for (int i = oldIndex + 1; i <= newIndex; i++) {
|
||||
final next = favorites[i];
|
||||
next.updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
next.favouriteOrderIndex - 1,
|
||||
);
|
||||
}
|
||||
favorites[oldIndex].updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
actualIndex + (newIndex - oldIndex),
|
||||
);
|
||||
}
|
||||
},
|
||||
proxyDecorator: (child, index, animation) {
|
||||
return Material(
|
||||
|
@ -176,8 +215,7 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
itemBuilder: (buildContext, index) {
|
||||
// final walletId = ref.watch(
|
||||
// nonFavorites[index].select((value) => value.walletId));
|
||||
final walletId =
|
||||
ref.read(nonFavorites[index]).walletId;
|
||||
final walletId = nonFavorites[index].walletId;
|
||||
return Padding(
|
||||
key: Key(
|
||||
"manageNonFavoriteWalletsItem_$walletId",
|
||||
|
@ -236,13 +274,12 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final favorites = ref.watch(favoritesProvider);
|
||||
final favorites = ref.watch(pFavouriteWalletInfos);
|
||||
return ReorderableListView.builder(
|
||||
key: key,
|
||||
itemCount: favorites.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final walletId =
|
||||
ref.read(favorites[index]).walletId;
|
||||
final walletId = favorites[index].walletId;
|
||||
return Padding(
|
||||
key: Key(
|
||||
"manageFavoriteWalletsItem_$walletId",
|
||||
|
@ -254,14 +291,43 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.moveFavorite(
|
||||
fromIndex: oldIndex, toIndex: newIndex);
|
||||
final isar = ref.read(mainDBProvider).isar;
|
||||
|
||||
ref
|
||||
.read(favoritesProvider)
|
||||
.reorder(oldIndex, newIndex, true);
|
||||
final actualIndex =
|
||||
favorites[oldIndex].favouriteOrderIndex;
|
||||
if (oldIndex > newIndex) {
|
||||
for (int i = oldIndex - 1; i >= newIndex; i--) {
|
||||
final next = favorites[i];
|
||||
next.updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
next.favouriteOrderIndex + 1,
|
||||
);
|
||||
}
|
||||
favorites[oldIndex].updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
actualIndex - (oldIndex - newIndex),
|
||||
);
|
||||
} else {
|
||||
for (int i = oldIndex + 1; i <= newIndex; i++) {
|
||||
final next = favorites[i];
|
||||
next.updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
next.favouriteOrderIndex - 1,
|
||||
);
|
||||
}
|
||||
favorites[oldIndex].updateIsFavourite(
|
||||
true,
|
||||
isar: isar,
|
||||
customIndexOverride:
|
||||
actualIndex + (newIndex - oldIndex),
|
||||
);
|
||||
}
|
||||
},
|
||||
proxyDecorator: (child, index, animation) {
|
||||
return Material(
|
||||
|
@ -301,15 +367,20 @@ class ManageFavoritesView extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final nonFavorites = ref.watch(nonFavoritesProvider);
|
||||
// todo [prio=??] do this differently
|
||||
final nonFavorites = ref
|
||||
.watch(pWallets)
|
||||
.wallets
|
||||
.map((e) => e.info)
|
||||
.where((e) => !e.isFavourite)
|
||||
.toList();
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: nonFavorites.length,
|
||||
itemBuilder: (buildContext, index) {
|
||||
// final walletId = ref.watch(
|
||||
// nonFavorites[index].select((value) => value.walletId));
|
||||
final walletId =
|
||||
ref.read(nonFavorites[index]).walletId;
|
||||
final walletId = nonFavorites[index].walletId;
|
||||
return Padding(
|
||||
key: Key(
|
||||
"manageNonFavoriteWalletsItem_$walletId",
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
// final address = await ref
|
||||
// .read(walletsChangeNotifierProvider)
|
||||
// .getManager(walletId)
|
||||
// .getWallet(walletId)
|
||||
// .currentReceivingAddress;
|
||||
// setState(() {
|
||||
// receivingAddress = address;
|
||||
|
@ -164,8 +164,8 @@
|
|||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final Coin coin = ref.watch(managerProvider.select((value) => value.coin));
|
||||
// final manager = ref.watch(walletsChangeNotifierProvider
|
||||
// .select((value) => value.getManager(widget.walletId)));
|
||||
// final wallet = ref.watch(walletsChangeNotifierProvider
|
||||
// .select((value) => value.getWallet(widget.walletId)));
|
||||
//
|
||||
// List<int>? imageBytes;
|
||||
// imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
||||
|
|
|
@ -13,10 +13,10 @@ import 'package:stackwallet/services/monkey_service.dart';
|
|||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/show_loading.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -48,8 +48,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
List<int>? imageBytes;
|
||||
|
||||
Future<void> _updateWalletMonKey(Uint8List monKeyBytes) async {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
await (manager.wallet as BananoWallet)
|
||||
await (ref.read(pWallets).getWallet(walletId) as BananoWallet)
|
||||
.updateMonkeyImageBytes(monKeyBytes.toList());
|
||||
}
|
||||
|
||||
|
@ -81,8 +80,10 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
throw Exception("Failed to get documents directory to save monKey image");
|
||||
}
|
||||
|
||||
final address =
|
||||
await ref.read(pWallets).getManager(walletId).currentReceivingAddress;
|
||||
final address = await ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId)
|
||||
.getCurrentReceivingAddress();
|
||||
final docPath = dir.path;
|
||||
String filePath = "$docPath/monkey_$address";
|
||||
|
||||
|
@ -107,13 +108,12 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final Coin coin = manager.coin;
|
||||
final wallet = ref.watch(pWallets).getWallet(widget.walletId);
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
final bool isDesktop = Util.isDesktop;
|
||||
|
||||
imageBytes ??= (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
||||
imageBytes ??= (wallet as BananoWallet).getMonkeyImageBytes();
|
||||
|
||||
return Background(
|
||||
child: ConditionalParent(
|
||||
|
@ -341,7 +341,7 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
whileFuture: Future.wait([
|
||||
_saveMonKeyToFile(
|
||||
bytes: Uint8List.fromList(
|
||||
(manager.wallet as BananoWallet)
|
||||
(wallet as BananoWallet)
|
||||
.getMonkeyImageBytes()!),
|
||||
),
|
||||
Future<void>.delayed(
|
||||
|
@ -383,21 +383,21 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
bool didError = false;
|
||||
await showLoading(
|
||||
whileFuture: Future.wait([
|
||||
manager.currentReceivingAddress.then(
|
||||
(address) async => await ref
|
||||
.read(pMonKeyService)
|
||||
.fetchMonKey(
|
||||
address: address,
|
||||
png: true,
|
||||
)
|
||||
.then(
|
||||
(monKeyBytes) async =>
|
||||
await _saveMonKeyToFile(
|
||||
bytes: monKeyBytes,
|
||||
isPNG: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
wallet.getCurrentReceivingAddress().then(
|
||||
(address) async => await ref
|
||||
.read(pMonKeyService)
|
||||
.fetchMonKey(
|
||||
address: address!.value,
|
||||
png: true,
|
||||
)
|
||||
.then(
|
||||
(monKeyBytes) async =>
|
||||
await _saveMonKeyToFile(
|
||||
bytes: monKeyBytes,
|
||||
isPNG: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
Future<void>.delayed(
|
||||
const Duration(seconds: 2)),
|
||||
]),
|
||||
|
@ -486,17 +486,17 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
onPressed: () async {
|
||||
await showLoading(
|
||||
whileFuture: Future.wait([
|
||||
manager.currentReceivingAddress.then(
|
||||
(address) async => await ref
|
||||
.read(pMonKeyService)
|
||||
.fetchMonKey(address: address)
|
||||
.then(
|
||||
(monKeyBytes) async =>
|
||||
await _updateWalletMonKey(
|
||||
monKeyBytes,
|
||||
),
|
||||
),
|
||||
),
|
||||
wallet.getCurrentReceivingAddress().then(
|
||||
(address) async => await ref
|
||||
.read(pMonKeyService)
|
||||
.fetchMonKey(address: address!.value)
|
||||
.then(
|
||||
(monKeyBytes) async =>
|
||||
await _updateWalletMonKey(
|
||||
monKeyBytes,
|
||||
),
|
||||
),
|
||||
),
|
||||
Future<void>.delayed(const Duration(seconds: 2)),
|
||||
]),
|
||||
context: context,
|
||||
|
@ -517,8 +517,8 @@ class _MonkeyViewState extends ConsumerState<MonkeyView> {
|
|||
},
|
||||
);
|
||||
|
||||
imageBytes = (manager.wallet as BananoWallet)
|
||||
.getMonkeyImageBytes();
|
||||
imageBytes =
|
||||
(wallet as BananoWallet).getMonkeyImageBytes();
|
||||
|
||||
if (imageBytes != null) {
|
||||
setState(() {});
|
||||
|
|
|
@ -13,15 +13,16 @@ import 'package:stackwallet/networking/http.dart';
|
|||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/tor_service.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
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/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.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';
|
||||
|
@ -56,8 +57,7 @@ class _OrdinalDetailsViewState extends ConsumerState<OrdinalDetailsView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
return Background(
|
||||
child: SafeArea(
|
||||
|
|
|
@ -89,7 +89,7 @@ class _OrdinalsViewState extends ConsumerState<OrdinalsView> {
|
|||
await showLoading(
|
||||
whileFuture: Future.wait<void>([
|
||||
Future.delayed(const Duration(seconds: 2)),
|
||||
(ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
(ref.read(pWallets).getWallet(widget.walletId)
|
||||
as OrdinalsInterface)
|
||||
.refreshInscriptions()
|
||||
]),
|
||||
|
|
|
@ -28,9 +28,11 @@ import 'package:stackwallet/providers/global/wallets_provider.dart';
|
|||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_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/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
|
@ -58,12 +60,12 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
bool _showInsufficientFundsInfo = false;
|
||||
|
||||
Future<void> _onSend() async {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
await Navigator.of(context).pushNamed(
|
||||
SendView.routeName,
|
||||
arguments: Tuple3(
|
||||
manager.walletId,
|
||||
manager.coin,
|
||||
wallet.walletId,
|
||||
wallet.info.coin,
|
||||
widget.accountLite,
|
||||
),
|
||||
);
|
||||
|
@ -83,9 +85,9 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
),
|
||||
);
|
||||
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as PaynymWalletInterface;
|
||||
final coin = ref.read(pWalletCoin(widget.walletId));
|
||||
|
||||
if (await wallet.hasConnected(widget.accountLite.code)) {
|
||||
canPop = true;
|
||||
|
@ -94,9 +96,9 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
return;
|
||||
}
|
||||
|
||||
final rates = await manager.fees;
|
||||
final rates = await ref.read(pWallets).getWallet(widget.walletId).fees;
|
||||
|
||||
Map<String, dynamic> preparedTx;
|
||||
TxData preparedTx;
|
||||
|
||||
try {
|
||||
preparedTx = await wallet.prepareNotificationTx(
|
||||
|
@ -145,32 +147,19 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
nymName: widget.accountLite.nymName,
|
||||
locale: ref.read(localeServiceChangeNotifierProvider).locale,
|
||||
onConfirmPressed: () {
|
||||
//
|
||||
print("CONFIRM NOTIF TX: $preparedTx");
|
||||
|
||||
Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
walletId: manager.walletId,
|
||||
walletId: widget.walletId,
|
||||
routeOnSuccessName: PaynymHomeView.routeName,
|
||||
isPaynymNotificationTransaction: true,
|
||||
transactionInfo: {
|
||||
"hex": preparedTx["hex"],
|
||||
"address": preparedTx["recipientPaynym"],
|
||||
"recipientAmt": preparedTx["amount"],
|
||||
"fee": preparedTx["fee"],
|
||||
"vSize": preparedTx["vSize"],
|
||||
"note": "PayNym connect"
|
||||
},
|
||||
txData: preparedTx,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
amount: (preparedTx["amount"] as Amount) +
|
||||
(preparedTx["fee"] as int).toAmountAsRaw(
|
||||
fractionDigits: manager.coin.decimals,
|
||||
),
|
||||
coin: manager.coin,
|
||||
amount: preparedTx.amount! + preparedTx.fee!,
|
||||
coin: coin,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -178,10 +167,8 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet =
|
||||
ref.watch(pWallets).getWallet(widget.walletId) as PaynymWalletInterface;
|
||||
|
||||
return DesktopDialog(
|
||||
maxWidth: MediaQuery.of(context).size.width - 32,
|
||||
|
@ -313,7 +300,7 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
"Adding a PayNym to your contacts requires a one-time "
|
||||
"transaction fee for creating the record on the "
|
||||
"blockchain. Please deposit more "
|
||||
"${ref.read(pWallets).getManager(widget.walletId).wallet.coin.ticker} "
|
||||
"${ref.watch(pWalletCoin(widget.walletId)).ticker} "
|
||||
"into your wallet and try again.",
|
||||
style: STextStyles.infoSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
|
|
|
@ -47,10 +47,8 @@ class PaynymClaimView extends ConsumerStatefulWidget {
|
|||
|
||||
class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
||||
Future<bool> _addSegwitCode(PaynymAccount myAccount) async {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
// get wallet to access paynym calls
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as PaynymWalletInterface;
|
||||
|
||||
final token = await ref
|
||||
.read(paynymAPIProvider)
|
||||
|
@ -189,11 +187,8 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
|
|||
).then((value) => shouldCancel = value == true),
|
||||
);
|
||||
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
// get wallet to access paynym calls
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId)
|
||||
as PaynymWalletInterface;
|
||||
|
||||
if (shouldCancel) return;
|
||||
|
||||
|
|
|
@ -26,9 +26,11 @@ import 'package:stackwallet/providers/global/locale_provider.dart';
|
|||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_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/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
|
@ -69,9 +71,8 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
),
|
||||
);
|
||||
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as PaynymWalletInterface;
|
||||
|
||||
if (await wallet.hasConnected(widget.accountLite.code)) {
|
||||
canPop = true;
|
||||
|
@ -80,9 +81,9 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
return;
|
||||
}
|
||||
|
||||
final rates = await manager.fees;
|
||||
final rates = await ref.read(pWallets).getWallet(widget.walletId).fees;
|
||||
|
||||
Map<String, dynamic> preparedTx;
|
||||
TxData preparedTx;
|
||||
|
||||
try {
|
||||
preparedTx = await wallet.prepareNotificationTx(
|
||||
|
@ -122,16 +123,9 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
maxHeight: double.infinity,
|
||||
maxWidth: 580,
|
||||
child: ConfirmTransactionView(
|
||||
walletId: manager.walletId,
|
||||
walletId: widget.walletId,
|
||||
isPaynymNotificationTransaction: true,
|
||||
transactionInfo: {
|
||||
"hex": preparedTx["hex"],
|
||||
"address": preparedTx["recipientPaynym"],
|
||||
"recipientAmt": preparedTx["amount"],
|
||||
"fee": preparedTx["fee"],
|
||||
"vSize": preparedTx["vSize"],
|
||||
"note": "PayNym connect"
|
||||
},
|
||||
txData: preparedTx,
|
||||
onSuccessInsteadOfRouteOnSuccess: () {
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
|
@ -150,11 +144,8 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
),
|
||||
);
|
||||
},
|
||||
amount: (preparedTx["amount"] as Amount) +
|
||||
(preparedTx["fee"] as int).toAmountAsRaw(
|
||||
fractionDigits: manager.coin.decimals,
|
||||
),
|
||||
coin: manager.coin,
|
||||
amount: preparedTx.amount! + preparedTx.fee!,
|
||||
coin: ref.read(pWalletCoin(widget.walletId)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -172,10 +163,9 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final wallet = ref.watch(pWallets).getWallet(widget.walletId);
|
||||
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final paynymWallet = wallet as PaynymWalletInterface;
|
||||
|
||||
return RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
|
@ -203,7 +193,8 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
style: STextStyles.desktopTextSmall(context),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: wallet.hasConnected(widget.accountLite.code),
|
||||
future: paynymWallet
|
||||
.hasConnected(widget.accountLite.code),
|
||||
builder: (context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
|
@ -241,7 +232,8 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
children: [
|
||||
Expanded(
|
||||
child: FutureBuilder(
|
||||
future: wallet.hasConnected(widget.accountLite.code),
|
||||
future:
|
||||
paynymWallet.hasConnected(widget.accountLite.code),
|
||||
builder: (context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
|
@ -313,7 +305,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
"Adding a PayNym to your contacts requires a one-time "
|
||||
"transaction fee for creating the record on the "
|
||||
"blockchain. Please deposit more "
|
||||
"${ref.read(pWallets).getManager(widget.walletId).wallet.coin.ticker} "
|
||||
"${ref.watch(pWalletCoin(widget.walletId)).ticker} "
|
||||
"into your wallet and try again.",
|
||||
style: STextStyles.desktopTextExtraExtraSmall(context)
|
||||
.copyWith(
|
||||
|
|
|
@ -75,10 +75,8 @@ class _PaynymFollowersListState extends ConsumerState<PaynymFollowersList> {
|
|||
child: child,
|
||||
onRefresh: () async {
|
||||
try {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
// get wallet to access paynym calls
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId)
|
||||
as PaynymWalletInterface;
|
||||
|
||||
// get payment code
|
||||
final pCode = await wallet.getPaymentCode(
|
||||
|
|
|
@ -75,10 +75,8 @@ class _PaynymFollowingListState extends ConsumerState<PaynymFollowingList> {
|
|||
child: child,
|
||||
onRefresh: () async {
|
||||
try {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
|
||||
// get wallet to access paynym calls
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId)
|
||||
as PaynymWalletInterface;
|
||||
|
||||
// get payment code
|
||||
final pCode = await wallet.getPaymentCode(
|
||||
|
|
|
@ -32,7 +32,6 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart';
|
||||
import 'package:stackwallet/widgets/shake/shake.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class LockscreenView extends ConsumerStatefulWidget {
|
||||
const LockscreenView({
|
||||
|
@ -98,13 +97,13 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
|
|||
if (loadIntoWallet) {
|
||||
final walletId = widget.routeOnSuccessArguments as String;
|
||||
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
if (manager.coin == Coin.monero) {
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
if (wallet.info.coin == Coin.monero) {
|
||||
await showLoading(
|
||||
opaqueBG: true,
|
||||
whileFuture: manager.initializeExisting(),
|
||||
whileFuture: wallet.init(),
|
||||
context: context,
|
||||
message: "Loading ${manager.coin.prettyName} wallet...",
|
||||
message: "Loading ${wallet.info.coin.prettyName} wallet...",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -123,10 +122,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
|
|||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
walletId,
|
||||
ref.read(pWallets).getManagerProvider(walletId),
|
||||
),
|
||||
arguments: walletId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.
|
|||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -95,8 +95,7 @@ class _AddressDetailsViewState extends ConsumerState<AddressDetailsView> {
|
|||
key: _qrKey,
|
||||
child: QrImageView(
|
||||
data: AddressUtils.buildUriString(
|
||||
ref.watch(pWallets.select((value) =>
|
||||
value.getManager(widget.walletId).coin)),
|
||||
ref.watch(pWalletCoin(widget.walletId)),
|
||||
address.value,
|
||||
{},
|
||||
),
|
||||
|
@ -150,8 +149,7 @@ class _AddressDetailsViewState extends ConsumerState<AddressDetailsView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Background(
|
||||
|
@ -291,8 +289,7 @@ class _AddressDetailsViewState extends ConsumerState<AddressDetailsView> {
|
|||
key: _qrKey,
|
||||
child: QrImageView(
|
||||
data: AddressUtils.buildUriString(
|
||||
ref.watch(pWallets.select((value) =>
|
||||
value.getManager(widget.walletId).coin)),
|
||||
coin,
|
||||
address.value,
|
||||
{},
|
||||
),
|
||||
|
|
|
@ -16,11 +16,11 @@ import 'package:stackwallet/db/isar/main_db.dart';
|
|||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/receive_view/addresses/address_card.dart';
|
||||
import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -135,8 +135,8 @@ class _WalletAddressesViewState extends ConsumerState<WalletAddressesView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Background(
|
||||
|
|
|
@ -28,6 +28,8 @@ import 'package:stackwallet/utilities/clipboard_interface.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/wallets/wallet/bip39_hd_wallet.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
|
@ -58,54 +60,49 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
|
|||
late final ClipboardInterface clipboard;
|
||||
|
||||
Future<void> generateNewAddress() async {
|
||||
bool shouldPop = false;
|
||||
unawaited(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => shouldPop,
|
||||
child: Container(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.overlay
|
||||
.withOpacity(0.5),
|
||||
child: const CustomLoadingOverlay(
|
||||
message: "Generating address",
|
||||
eventBus: null,
|
||||
// TODO: [prio=med] handle other wallet cases
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
|
||||
if (wallet is Bip39HDWallet) {
|
||||
bool shouldPop = false;
|
||||
unawaited(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => shouldPop,
|
||||
child: Container(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.overlay
|
||||
.withOpacity(0.5),
|
||||
child: const CustomLoadingOverlay(
|
||||
message: "Generating address",
|
||||
eventBus: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await ref.read(pWallets).getManager(walletId).generateNewAddress();
|
||||
await wallet.generateNewReceivingAddress();
|
||||
|
||||
shouldPop = true;
|
||||
shouldPop = true;
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context)
|
||||
.popUntil(ModalRoute.withName(ReceiveView.routeName));
|
||||
if (mounted) {
|
||||
Navigator.of(context)
|
||||
.popUntil(ModalRoute.withName(ReceiveView.routeName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String receivingAddress = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
walletId = widget.walletId;
|
||||
coin = ref.read(pWallets).getManager(walletId).coin;
|
||||
coin = ref.read(pWalletCoin(walletId));
|
||||
clipboard = widget.clipboard;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final address =
|
||||
await ref.read(pWallets).getManager(walletId).currentReceivingAddress;
|
||||
setState(() {
|
||||
receivingAddress = address;
|
||||
});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -113,16 +110,7 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
ref.listen(
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManagerProvider(walletId)
|
||||
.select((value) => value.currentReceivingAddress),
|
||||
(previous, next) {
|
||||
if (next is Future<String>) {
|
||||
next.then((value) => setState(() => receivingAddress = value));
|
||||
}
|
||||
});
|
||||
final receivingAddress = ref.watch(pWalletReceivingAddress(walletId));
|
||||
|
||||
final ticker = widget.tokenContract?.symbol ?? coin.ticker;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_libepiccash/lib.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
||||
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
|
||||
|
@ -27,8 +26,6 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -37,6 +34,8 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.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/models/tx_data.dart';
|
||||
// import 'package:stackwallet/wallets/example/libepiccash.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
|
@ -54,7 +53,7 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
|||
class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||
const ConfirmTransactionView({
|
||||
Key? key,
|
||||
required this.transactionInfo,
|
||||
required this.txData,
|
||||
required this.walletId,
|
||||
this.routeOnSuccessName = WalletView.routeName,
|
||||
this.isTradeTransaction = false,
|
||||
|
@ -66,7 +65,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|||
|
||||
static const String routeName = "/confirmTransactionView";
|
||||
|
||||
final Map<String, dynamic> transactionInfo;
|
||||
final TxData txData;
|
||||
final String walletId;
|
||||
final String routeOnSuccessName;
|
||||
final bool isTradeTransaction;
|
||||
|
@ -82,7 +81,6 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|||
|
||||
class _ConfirmTransactionViewState
|
||||
extends ConsumerState<ConfirmTransactionView> {
|
||||
late final Map<String, dynamic> transactionInfo;
|
||||
late final String walletId;
|
||||
late final String routeOnSuccessName;
|
||||
late final bool isDesktop;
|
||||
|
@ -94,7 +92,8 @@ class _ConfirmTransactionViewState
|
|||
late final TextEditingController onChainNoteController;
|
||||
|
||||
Future<void> _attemptSend(BuildContext context) async {
|
||||
pWalletsf.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
final coin = wallet.info.coin;
|
||||
|
||||
final sendProgressController = ProgressAndSuccessController();
|
||||
|
||||
|
@ -105,7 +104,7 @@ class _ConfirmTransactionViewState
|
|||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return SendingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
controller: sendProgressController,
|
||||
);
|
||||
},
|
||||
|
@ -119,32 +118,42 @@ class _ConfirmTransactionViewState
|
|||
);
|
||||
|
||||
late String txid;
|
||||
Future<String> txidFuture;
|
||||
Future<TxData> txidFuture;
|
||||
|
||||
final note = noteController.text;
|
||||
|
||||
try {
|
||||
if (widget.isTokenTx) {
|
||||
txidFuture = ref
|
||||
.read(tokenServiceProvider)!
|
||||
.confirmSend(txData: transactionInfo);
|
||||
// TODO: [prio=high] fixme
|
||||
throw UnimplementedError("fixme");
|
||||
// txidFuture = ref
|
||||
// .read(tokenServiceProvider)!
|
||||
// .confirmSend(txData: transactionInfo);
|
||||
} else if (widget.isPaynymNotificationTransaction) {
|
||||
txidFuture = (manager.wallet as PaynymWalletInterface)
|
||||
.broadcastNotificationTx(preparedTx: transactionInfo);
|
||||
// TODO: [prio=high] fixme
|
||||
throw UnimplementedError("fixme");
|
||||
// txidFuture = (wallet as PaynymWalletInterface)
|
||||
// .broadcastNotificationTx(preparedTx: transactionInfo);
|
||||
} else if (widget.isPaynymTransaction) {
|
||||
txidFuture = manager.confirmSend(txData: transactionInfo);
|
||||
txidFuture = wallet.confirmSend(txData: widget.txData);
|
||||
} else {
|
||||
final coin = manager.coin;
|
||||
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
||||
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
||||
"Private") {
|
||||
txidFuture = (manager.wallet as FiroWallet)
|
||||
.confirmSendPublic(txData: transactionInfo);
|
||||
// TODO: [prio=high] fixme
|
||||
throw UnimplementedError("fixme");
|
||||
// txidFuture = (wallet as FiroWallet)
|
||||
// .confirmSendPublic(txData: transactionInfo);
|
||||
} else {
|
||||
if (coin == Coin.epicCash) {
|
||||
transactionInfo["onChainNote"] = onChainNoteController.text;
|
||||
txidFuture = wallet.confirmSend(
|
||||
txData: widget.txData.copyWith(
|
||||
noteOnChain: onChainNoteController.text,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
txidFuture = wallet.confirmSend(txData: widget.txData);
|
||||
}
|
||||
txidFuture = manager.confirmSend(txData: transactionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +176,7 @@ class _ConfirmTransactionViewState
|
|||
if (widget.isTokenTx) {
|
||||
unawaited(ref.read(tokenServiceProvider)!.refresh());
|
||||
} else {
|
||||
unawaited(manager.refresh());
|
||||
unawaited(wallet.refresh());
|
||||
}
|
||||
|
||||
// pop back to wallet
|
||||
|
@ -272,17 +281,15 @@ class _ConfirmTransactionViewState
|
|||
@override
|
||||
void initState() {
|
||||
isDesktop = Util.isDesktop;
|
||||
transactionInfo = widget.transactionInfo;
|
||||
walletId = widget.walletId;
|
||||
routeOnSuccessName = widget.routeOnSuccessName;
|
||||
_noteFocusNode = FocusNode();
|
||||
noteController = TextEditingController();
|
||||
noteController.text = transactionInfo["note"] as String? ?? "";
|
||||
noteController.text = widget.txData.note ?? "";
|
||||
|
||||
_onChainNoteFocusNode = FocusNode();
|
||||
onChainNoteController = TextEditingController();
|
||||
onChainNoteController.text =
|
||||
transactionInfo["onChainNote"] as String? ?? "";
|
||||
onChainNoteController.text = widget.txData.noteOnChain ?? "";
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
@ -298,9 +305,8 @@ class _ConfirmTransactionViewState
|
|||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext contepWalletser = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManagerProvidpWalletsin = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId).coin));
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final String unit;
|
||||
if (widget.isTokenTx) {
|
||||
|
@ -309,7 +315,6 @@ class _ConfirmTransactionViewState
|
|||
} else {
|
||||
unit = coin.ticker;
|
||||
}
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
builder: (child) => Background(
|
||||
|
@ -414,10 +419,8 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
Text(
|
||||
widget.isPaynymTransaction
|
||||
? (transactionInfo["paynymAccountLite"]
|
||||
as PaynymAccountLite)
|
||||
.nymName
|
||||
: "${transactionInfo["address"] ?? "ERROR"}",
|
||||
? widget.txData.paynymAccountLite!.nymName
|
||||
: widget.txData.recipients!.first.address,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
|
@ -436,7 +439,7 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
Text(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
transactionInfo["recipientAmt"] as Amount,
|
||||
widget.txData.amount!,
|
||||
ethContract: ref
|
||||
.watch(tokenServiceProvider)
|
||||
?.tokenContract,
|
||||
|
@ -461,31 +464,20 @@ class _ConfirmTransactionViewState
|
|||
style: STextStyles.smallMed12(context),
|
||||
),
|
||||
Text(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
(transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int)
|
||||
.toAmountAsRaw(
|
||||
fractionDigits: ref.watch(
|
||||
managerProvider.select(
|
||||
(value) => value.coin.decimals,
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(widget.txData.fee!),
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (transactionInfo["fee"] is int &&
|
||||
transactionInfo["vSize"] is int)
|
||||
if (widget.txData.fee != null && widget.txData.vSize != null)
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (transactionInfo["fee"] is int &&
|
||||
transactionInfo["vSize"] is int)
|
||||
if (widget.txData.fee != null && widget.txData.vSize != null)
|
||||
RoundedWhiteContainer(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
@ -498,19 +490,19 @@ class _ConfirmTransactionViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
"~${(transactionInfo["fee"] / transactionInfo["vSize"]).toInt()}",
|
||||
"~${widget.txData.fee!.raw.toInt() ~/ widget.txData.vSize!}",
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (coin == Coin.epicCash &&
|
||||
(transactionInfo["onChainNote"] as String).isNotEmpty)
|
||||
widget.txData.noteOnChain!.isNotEmpty)
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if (coin == Coin.epicCash &&
|
||||
(transactionInfo["onChainNote"] as String).isNotEmpty)
|
||||
widget.txData.noteOnChain!.isNotEmpty)
|
||||
RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
@ -523,17 +515,17 @@ class _ConfirmTransactionViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
transactionInfo["onChainNote"] as String,
|
||||
widget.txData.noteOnChain!,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if ((transactionInfo["note"] as String).isNotEmpty)
|
||||
if (widget.txData.note!.isNotEmpty)
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
if ((transactionInfo["note"] as String).isNotEmpty)
|
||||
if (widget.txData.note!.isNotEmpty)
|
||||
RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
@ -546,7 +538,7 @@ class _ConfirmTransactionViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
transactionInfo["note"] as String,
|
||||
widget.txData.note!,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
],
|
||||
|
@ -629,13 +621,7 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final coin = ref.watch(
|
||||
managerProvider.select(
|
||||
(value) => value.coin,
|
||||
),
|
||||
);
|
||||
final amount =
|
||||
transactionInfo["recipientAmt"] as Amount;
|
||||
final amount = widget.txData.amount!;
|
||||
final externalCalls = ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) => value.externalCalls));
|
||||
|
@ -734,10 +720,8 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
Text(
|
||||
widget.isPaynymTransaction
|
||||
? (transactionInfo["paynymAccountLite"]
|
||||
as PaynymAccountLite)
|
||||
.nymName
|
||||
: "${transactionInfo["address"] ?? "ERROR"}",
|
||||
? widget.txData.paynymAccountLite!.nymName
|
||||
: widget.txData.recipients!.first.address,
|
||||
style: STextStyles.desktopTextExtraExtraSmall(
|
||||
context)
|
||||
.copyWith(
|
||||
|
@ -773,18 +757,7 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final coin = ref
|
||||
pWallets .watch(walletsChangeNotifierProvider
|
||||
.select((value) =>
|
||||
value.getManager(walletId)))
|
||||
.coin;
|
||||
|
||||
final fee = transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int)
|
||||
.toAmountAsRaw(
|
||||
fractionDigits: coin.decimals,
|
||||
);
|
||||
final fee = widget.txData.fee!;
|
||||
|
||||
return Text(
|
||||
ref
|
||||
|
@ -1004,17 +977,9 @@ class _ConfirmTransactionViewState
|
|||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
pWallets builder: (context) {
|
||||
final coin = ref
|
||||
.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(walletId)))
|
||||
.coin;
|
||||
|
||||
final fee = transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int).toAmountAsRaw(
|
||||
fractionDigits: coin.decimals,
|
||||
);
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final fee = widget.txData.fee!;
|
||||
|
||||
return Text(
|
||||
ref.watch(pAmountFormatter(coin)).format(fee),
|
||||
|
@ -1026,8 +991,8 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
if (isDesktop &&
|
||||
!widget.isPaynymTransaction &&
|
||||
transactionInfo["fee"] is int &&
|
||||
transactionInfo["vSize"] is int)
|
||||
widget.txData.fee != null &&
|
||||
widget.txData.vSize != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32,
|
||||
|
@ -1039,8 +1004,8 @@ class _ConfirmTransactionViewState
|
|||
),
|
||||
if (isDesktop &&
|
||||
!widget.isPaynymTransaction &&
|
||||
transactionInfo["fee"] is int &&
|
||||
transactionInfo["vSize"] is int)
|
||||
widget.txData.fee != null &&
|
||||
widget.txData.vSize != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10,
|
||||
|
@ -1056,7 +1021,7 @@ class _ConfirmTransactionViewState
|
|||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
child: Text(
|
||||
"~${(transactionInfo["fee"] / transactionInfo["vSize"]).toInt()}",
|
||||
"~${widget.txData.fee!.raw.toInt() ~/ widget.txData.vSize!}",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
),
|
||||
|
@ -1099,17 +1064,11 @@ class _ConfirmTransactionViewState
|
|||
.extension<StackColors>()!
|
||||
.textConfirmTotalAmount,
|
||||
),
|
||||
pWallets Builder(builder: (context) {
|
||||
final coin = ref.watch(
|
||||
walletsChangeNotifierProvider.select(
|
||||
(value) => value.getManager(walletId).coin));
|
||||
final fee = transactionInfo["fee"] is Amount
|
||||
? transactionInfo["fee"] as Amount
|
||||
: (transactionInfo["fee"] as int)
|
||||
.toAmountAsRaw(fractionDigits: coin.decimals);
|
||||
),
|
||||
Builder(builder: (context) {
|
||||
final fee = widget.txData.fee!;
|
||||
|
||||
final amount =
|
||||
transactionInfo["recipientAmt"] as Amount;
|
||||
final amount = widget.txData.amount!;
|
||||
return Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
|
@ -1145,14 +1104,9 @@ class _ConfirmTransactionViewState
|
|||
child: PrimaryButton(
|
||||
label: "Send",
|
||||
buttonHeight: isDesktop ? ButtonHeight.l : null,
|
||||
pWallets
|
||||
onPressed: () async {
|
||||
final dynamic unlocked;
|
||||
|
||||
final coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(walletId)
|
||||
.coin;
|
||||
|
||||
if (isDesktop) {
|
||||
unlocked = await showDialog<bool?>(
|
||||
context: context,
|
||||
|
@ -1162,9 +1116,9 @@ class _ConfirmTransactionViewState
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: const [
|
||||
children: [
|
||||
DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -32,8 +32,7 @@ import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart';
|
|||
import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart';
|
||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/services/mixins/coin_control_interface.dart';
|
||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
|
@ -52,6 +51,8 @@ import 'package:stackwallet/utilities/logger.dart';
|
|||
import 'package:stackwallet/utilities/prefs.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/models/tx_data.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -120,16 +121,11 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
Amount? _cachedAmountToSend;
|
||||
String? _address;
|
||||
|
||||
String? _privateBalanceString;
|
||||
String? _publicBalanceString;
|
||||
|
||||
bool _addressToggleFlag = false;
|
||||
|
||||
bool _cryptoAmountChangeLock = false;
|
||||
late VoidCallback onCryptoAmountChanged;
|
||||
|
||||
Amount? _cachedBalance;
|
||||
|
||||
Set<UTXO> selectedUTXOs = {};
|
||||
|
||||
void _cryptoAmountChanged() async {
|
||||
|
@ -225,11 +221,16 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
}
|
||||
}
|
||||
|
||||
String? _updateInvalidAddressText(String address, Manager manager) {
|
||||
String? _updateInvalidAddressText(String address) {
|
||||
if (_data != null && _data!.contactLabel == address) {
|
||||
return null;
|
||||
}
|
||||
if (address.isNotEmpty && !manager.validateAddress(address)) {
|
||||
if (address.isNotEmpty &&
|
||||
!ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(address)) {
|
||||
return "Invalid address";
|
||||
}
|
||||
return null;
|
||||
|
@ -242,7 +243,8 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
} else {
|
||||
final isValidAddress = ref
|
||||
.read(pWallets)
|
||||
.getManager(walletId)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(address ?? "");
|
||||
ref.read(previewTxButtonStateProvider.state).state =
|
||||
(isValidAddress && amount != null && amount > Amount.zero);
|
||||
|
@ -275,9 +277,8 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
return cachedFees[amount]!;
|
||||
}
|
||||
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(walletId);
|
||||
final feeObject = await manager.fees;
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
final feeObject = await wallet.fees;
|
||||
|
||||
late final int feeRate;
|
||||
|
||||
|
@ -312,7 +313,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
throw ArgumentError("custom fee not available for monero");
|
||||
}
|
||||
|
||||
fee = await manager.estimateFeeFor(amount, specialMoneroId.raw!);
|
||||
fee = await wallet.estimateFeeFor(amount, specialMoneroId.raw!);
|
||||
cachedFees[amount] = ref.read(pAmountFormatter(coin)).format(
|
||||
fee,
|
||||
withUnitName: true,
|
||||
|
@ -323,7 +324,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
} else if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
if (ref.read(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private") {
|
||||
fee = await manager.estimateFeeFor(amount, feeRate);
|
||||
fee = await wallet.estimateFeeFor(amount, feeRate);
|
||||
|
||||
cachedFiroPrivateFees[amount] = ref.read(pAmountFormatter(coin)).format(
|
||||
fee,
|
||||
|
@ -333,19 +334,21 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
|
||||
return cachedFiroPrivateFees[amount]!;
|
||||
} else {
|
||||
fee = await (manager.wallet as FiroWallet)
|
||||
.estimateFeeForPublic(amount, feeRate);
|
||||
|
||||
cachedFiroPublicFees[amount] = ref.read(pAmountFormatter(coin)).format(
|
||||
fee,
|
||||
withUnitName: true,
|
||||
indicatePrecisionLoss: false,
|
||||
);
|
||||
|
||||
return cachedFiroPublicFees[amount]!;
|
||||
// TODO: [prio=high] firo public send fees refactor or something...
|
||||
throw UnimplementedError("Firo pub fees todo");
|
||||
// fee = await (manager.wallet as FiroWallet)
|
||||
// .estimateFeeForPublic(amount, feeRate);
|
||||
//
|
||||
// cachedFiroPublicFees[amount] = ref.read(pAmountFormatter(coin)).format(
|
||||
// fee,
|
||||
// withUnitName: true,
|
||||
// indicatePrecisionLoss: false,
|
||||
// );
|
||||
//
|
||||
// return cachedFiroPublicFees[amount]!;
|
||||
}
|
||||
} else {
|
||||
fee = await manager.estimateFeeFor(amount, feeRate);
|
||||
fee = await wallet.estimateFeeFor(amount, feeRate);
|
||||
cachedFees[amount] = ref.read(pAmountFormatter(coin)).format(
|
||||
fee,
|
||||
withUnitName: true,
|
||||
|
@ -356,57 +359,34 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<String?> _firoBalanceFuture(
|
||||
ChangeNotifierProvider<Manager> provider, String locale) async {
|
||||
final wallet = ref.read(provider).wallet as FiroWallet?;
|
||||
|
||||
if (wallet != null) {
|
||||
Amount? balance;
|
||||
if (ref.read(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private") {
|
||||
balance = wallet.availablePrivateBalance();
|
||||
} else {
|
||||
balance = wallet.availablePublicBalance();
|
||||
}
|
||||
|
||||
return ref.read(pAmountFormatter(coin)).format(
|
||||
balance,
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> _previewTransaction() async {
|
||||
// wait for keyboard to disappear
|
||||
FocusScope.of(context).unfocus();
|
||||
await Future<void>.delayed(
|
||||
const Duration(milliseconds: 100),
|
||||
);
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
|
||||
final Amount amount = _amountToSend!;
|
||||
final Amount availableBalance;
|
||||
if ((coin == Coin.firo || coin == Coin.firoTestNet)) {
|
||||
if (ref.read(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private") {
|
||||
availableBalance =
|
||||
(manager.wallet as FiroWallet).availablePrivateBalance();
|
||||
availableBalance = ref.read(pWalletBalance(walletId)).spendable;
|
||||
} else {
|
||||
availableBalance =
|
||||
(manager.wallet as FiroWallet).availablePublicBalance();
|
||||
ref.read(pWalletBalanceSecondary(walletId)).spendable;
|
||||
}
|
||||
} else {
|
||||
availableBalance = manager.balance.spendable;
|
||||
availableBalance = ref.read(pWalletBalance(walletId)).spendable;
|
||||
}
|
||||
|
||||
final coinControlEnabled =
|
||||
ref.read(prefsChangeNotifierProvider).enableCoinControl;
|
||||
|
||||
if (coin != Coin.ethereum &&
|
||||
!(manager.hasCoinControlSupport && coinControlEnabled) ||
|
||||
(manager.hasCoinControlSupport &&
|
||||
!(wallet is CoinControlInterface && coinControlEnabled) ||
|
||||
(wallet is CoinControlInterface &&
|
||||
coinControlEnabled &&
|
||||
selectedUTXOs.isEmpty)) {
|
||||
// confirm send all
|
||||
|
@ -472,7 +452,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return BuildingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: wallet.info.coin,
|
||||
onCancel: () {
|
||||
wasCancelled = true;
|
||||
|
||||
|
@ -490,59 +470,59 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> txData;
|
||||
Future<Map<String, dynamic>> txDataFuture;
|
||||
Future<TxData> txDataFuture;
|
||||
|
||||
if (isPaynymSend) {
|
||||
final wallet = manager.wallet as PaynymWalletInterface;
|
||||
final paymentCode = PaymentCode.fromPaymentCode(
|
||||
widget.accountLite!.code,
|
||||
networkType: wallet.networkType,
|
||||
);
|
||||
final feeRate = ref.read(feeRateTypeStateProvider);
|
||||
txDataFuture = wallet.preparePaymentCodeSend(
|
||||
paymentCode: paymentCode,
|
||||
isSegwit: widget.accountLite!.segwit,
|
||||
amount: amount,
|
||||
args: {
|
||||
"satsPerVByte": isCustomFee ? customFeeRate : null,
|
||||
"feeRate": feeRate,
|
||||
"UTXOs": (manager.hasCoinControlSupport &&
|
||||
coinControlEnabled &&
|
||||
selectedUTXOs.isNotEmpty)
|
||||
? selectedUTXOs
|
||||
: null,
|
||||
},
|
||||
networkType: (wallet as PaynymWalletInterface).networkType,
|
||||
);
|
||||
throw UnimplementedError("FIXME");
|
||||
// TODO: [prio=high] paynym prepare send using TxData
|
||||
// final feeRate = ref.read(feeRateTypeStateProvider);
|
||||
// txDataFuture = (wallet as PaynymWalletInterface).preparePaymentCodeSend(
|
||||
// paymentCode: paymentCode,
|
||||
// isSegwit: widget.accountLite!.segwit,
|
||||
// amount: amount,
|
||||
// args: {
|
||||
// "satsPerVByte": isCustomFee ? customFeeRate : null,
|
||||
// "feeRate": feeRate,
|
||||
// "UTXOs": (wallet is CoinControlInterface &&
|
||||
// coinControlEnabled &&
|
||||
// selectedUTXOs.isNotEmpty)
|
||||
// ? selectedUTXOs
|
||||
// : null,
|
||||
// },
|
||||
// );
|
||||
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
||||
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
||||
"Private") {
|
||||
txDataFuture = (manager.wallet as FiroWallet).prepareSendPublic(
|
||||
address: _address!,
|
||||
amount: amount,
|
||||
args: {
|
||||
"feeRate": ref.read(feeRateTypeStateProvider),
|
||||
"satsPerVByte": isCustomFee ? customFeeRate : null,
|
||||
},
|
||||
);
|
||||
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,
|
||||
// },
|
||||
// );
|
||||
} else {
|
||||
final memo =
|
||||
manager.coin == Coin.stellar || manager.coin == Coin.stellarTestnet
|
||||
? memoController.text
|
||||
: null;
|
||||
txDataFuture = manager.prepareSend(
|
||||
address: _address!,
|
||||
amount: amount,
|
||||
args: {
|
||||
"memo": memo,
|
||||
"feeRate": ref.read(feeRateTypeStateProvider),
|
||||
"satsPerVByte": isCustomFee ? customFeeRate : null,
|
||||
"UTXOs": (manager.hasCoinControlSupport &&
|
||||
final memo = coin == Coin.stellar || coin == Coin.stellarTestnet
|
||||
? memoController.text
|
||||
: null;
|
||||
txDataFuture = wallet.prepareSend(
|
||||
txData: TxData(
|
||||
recipients: [(address: _address!, amount: amount)],
|
||||
memo: memo,
|
||||
feeRateType: ref.read(feeRateTypeStateProvider),
|
||||
satsPerVByte: isCustomFee ? customFeeRate : null,
|
||||
utxos: (wallet is CoinControlInterface &&
|
||||
coinControlEnabled &&
|
||||
selectedUTXOs.isNotEmpty)
|
||||
? selectedUTXOs
|
||||
: null,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -551,24 +531,22 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
time,
|
||||
]);
|
||||
|
||||
txData = results.first as Map<String, dynamic>;
|
||||
TxData txData = results.first as TxData;
|
||||
|
||||
if (!wasCancelled && mounted) {
|
||||
// pop building dialog
|
||||
Navigator.of(context).pop();
|
||||
txData["note"] = noteController.text;
|
||||
txData["onChainNote"] = onChainNoteController.text;
|
||||
txData = txData.copyWith(note: noteController.text);
|
||||
txData = txData.copyWith(noteOnChain: onChainNoteController.text);
|
||||
if (isPaynymSend) {
|
||||
txData["paynymAccountLite"] = widget.accountLite!;
|
||||
} else {
|
||||
txData["address"] = _address;
|
||||
txData = txData.copyWith(paynymAccountLite: widget.accountLite!);
|
||||
}
|
||||
|
||||
unawaited(Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
transactionInfo: txData,
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
isPaynymTransaction: isPaynymSend,
|
||||
),
|
||||
|
@ -729,16 +707,11 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final provider = ref.watch(pWallets
|
||||
.select((value) => value.getManagerProvider(walletId)));
|
||||
final wallet = ref.watch(pWallets).getWallet(walletId);
|
||||
final String locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
||||
final showCoinControl = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(walletId).hasCoinControlSupport,
|
||||
),
|
||||
) &&
|
||||
final showCoinControl = wallet is CoinControlInterface &&
|
||||
ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) => value.enableCoinControl,
|
||||
|
@ -848,8 +821,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
ref.watch(provider.select(
|
||||
(value) => value.walletName)),
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.titleBold12(context)
|
||||
.copyWith(fontSize: 14),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
@ -875,116 +847,75 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
],
|
||||
),
|
||||
const Spacer(),
|
||||
FutureBuilder(
|
||||
// TODO redo this widget now that its not actually a future
|
||||
future: (coin != Coin.firo &&
|
||||
coin != Coin.firoTestNet)
|
||||
? Future(() => ref.watch(
|
||||
provider.select((value) =>
|
||||
value.balance.spendable)))
|
||||
: ref.watch(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private"
|
||||
? Future(() => (ref
|
||||
.watch(provider)
|
||||
.wallet as FiroWallet)
|
||||
.availablePrivateBalance())
|
||||
: Future(() => (ref
|
||||
.watch(provider)
|
||||
.wallet as FiroWallet)
|
||||
.availablePublicBalance()),
|
||||
builder:
|
||||
(_, AsyncSnapshot<Amount> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
_cachedBalance = snapshot.data!;
|
||||
}
|
||||
|
||||
if (_cachedBalance != null) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
_cachedBalance!,
|
||||
withUnitName: false,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(
|
||||
coin))
|
||||
.format(_cachedBalance!),
|
||||
style:
|
||||
STextStyles.titleBold12(
|
||||
context)
|
||||
.copyWith(
|
||||
fontSize: 10,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
Text(
|
||||
"${(_cachedBalance!.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(
|
||||
fractionDigits: 2,
|
||||
).fiatString(
|
||||
locale: locale,
|
||||
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
|
||||
style: STextStyles.subtitle(
|
||||
context)
|
||||
.copyWith(
|
||||
fontSize: 8,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Builder(builder: (context) {
|
||||
final Amount amount;
|
||||
if (coin != Coin.firo &&
|
||||
coin != Coin.firoTestNet) {
|
||||
if (ref
|
||||
.watch(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Private") {
|
||||
amount = ref
|
||||
.read(pWalletBalance(walletId))
|
||||
.spendable;
|
||||
} else {
|
||||
return Column(
|
||||
amount = ref
|
||||
.read(pWalletBalanceSecondary(
|
||||
walletId))
|
||||
.spendable;
|
||||
}
|
||||
} else {
|
||||
amount = ref
|
||||
.read(pWalletBalance(walletId))
|
||||
.spendable;
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
amount,
|
||||
withUnitName: false,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
AnimatedText(
|
||||
stringsToLoopThrough: const [
|
||||
"Loading balance ",
|
||||
"Loading balance. ",
|
||||
"Loading balance.. ",
|
||||
"Loading balance...",
|
||||
],
|
||||
style: STextStyles.itemSubtitle(
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(amount),
|
||||
style: STextStyles.titleBold12(
|
||||
context)
|
||||
.copyWith(
|
||||
fontSize: 10,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
AnimatedText(
|
||||
stringsToLoopThrough: const [
|
||||
"Loading balance ",
|
||||
"Loading balance. ",
|
||||
"Loading balance.. ",
|
||||
"Loading balance...",
|
||||
],
|
||||
style: STextStyles.itemSubtitle(
|
||||
context)
|
||||
.copyWith(
|
||||
Text(
|
||||
"${(amount.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(
|
||||
fractionDigits: 2,
|
||||
).fiatString(
|
||||
locale: locale,
|
||||
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
|
||||
style:
|
||||
STextStyles.subtitle(context)
|
||||
.copyWith(
|
||||
fontSize: 8,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -1269,9 +1200,9 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
|
||||
// now check for non standard encoded basic address
|
||||
} else if (ref
|
||||
.read(
|
||||
pWallets)
|
||||
.getManager(walletId)
|
||||
.read(pWallets)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(qrResult
|
||||
.rawContent)) {
|
||||
_address = qrResult
|
||||
|
@ -1397,9 +1328,6 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
builder: (_) {
|
||||
final error = _updateInvalidAddressText(
|
||||
_address ?? "",
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManager(walletId),
|
||||
);
|
||||
|
||||
if (error == null || error.isEmpty) {
|
||||
|
@ -1493,68 +1421,40 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _firoBalanceFuture(
|
||||
provider, locale),
|
||||
builder: (context,
|
||||
AsyncSnapshot<String?>
|
||||
snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
if (ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Private") {
|
||||
_privateBalanceString =
|
||||
snapshot.data!;
|
||||
} else {
|
||||
_publicBalanceString =
|
||||
snapshot.data!;
|
||||
}
|
||||
}
|
||||
if (ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Private" &&
|
||||
_privateBalanceString !=
|
||||
null) {
|
||||
return Text(
|
||||
"$_privateBalanceString",
|
||||
style: STextStyles
|
||||
.itemSubtitle(context),
|
||||
);
|
||||
} else if (ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Public" &&
|
||||
_publicBalanceString !=
|
||||
null) {
|
||||
return Text(
|
||||
"$_publicBalanceString",
|
||||
style: STextStyles
|
||||
.itemSubtitle(context),
|
||||
);
|
||||
} else {
|
||||
return AnimatedText(
|
||||
stringsToLoopThrough: const [
|
||||
"Loading balance",
|
||||
"Loading balance.",
|
||||
"Loading balance..",
|
||||
"Loading balance...",
|
||||
],
|
||||
style: STextStyles
|
||||
.itemSubtitle(context),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Private")
|
||||
Text(
|
||||
ref
|
||||
.watch(
|
||||
pAmountFormatter(coin))
|
||||
.format(
|
||||
ref
|
||||
.watch(pWalletBalance(
|
||||
walletId))
|
||||
.spendable,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(
|
||||
context),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
ref
|
||||
.watch(
|
||||
pAmountFormatter(coin))
|
||||
.format(
|
||||
ref
|
||||
.watch(
|
||||
pWalletBalanceSecondary(
|
||||
walletId))
|
||||
.spendable,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(
|
||||
context),
|
||||
),
|
||||
],
|
||||
),
|
||||
SvgPicture.asset(
|
||||
|
@ -1586,40 +1486,29 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
CustomTextButton(
|
||||
text: "Send all ${coin.ticker}",
|
||||
onTap: () async {
|
||||
if (coin == Coin.firo ||
|
||||
coin == Coin.firoTestNet) {
|
||||
final firoWallet = ref
|
||||
.read(provider)
|
||||
.wallet as FiroWallet;
|
||||
if (ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Private") {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
firoWallet
|
||||
.availablePrivateBalance(),
|
||||
withUnitName: false,
|
||||
);
|
||||
} else {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
firoWallet
|
||||
.availablePublicBalance(),
|
||||
withUnitName: false,
|
||||
);
|
||||
}
|
||||
if ((coin == Coin.firo ||
|
||||
coin == Coin.firoTestNet) &&
|
||||
ref
|
||||
.read(
|
||||
publicPrivateBalanceStateProvider
|
||||
.state)
|
||||
.state ==
|
||||
"Public") {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
ref
|
||||
.read(pWalletBalanceSecondary(
|
||||
walletId))
|
||||
.spendable,
|
||||
withUnitName: false,
|
||||
);
|
||||
} else {
|
||||
cryptoAmountController.text = ref
|
||||
.read(pAmountFormatter(coin))
|
||||
.format(
|
||||
ref
|
||||
.read(provider)
|
||||
.balance
|
||||
.read(pWalletBalance(walletId))
|
||||
.spendable,
|
||||
withUnitName: false,
|
||||
);
|
||||
|
@ -1853,9 +1742,7 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
|
||||
if (mounted) {
|
||||
final spendable = ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.balance
|
||||
.read(pWalletBalance(walletId))
|
||||
.spendable;
|
||||
|
||||
Amount? amount;
|
||||
|
|
|
@ -52,9 +52,11 @@ class _FiroBalanceSelectionSheetState
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final manager =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId)));
|
||||
final firoWallet = manager.wallet as FiroWallet;
|
||||
final wallet =
|
||||
ref.watch(pWallets.select((value) => value.getWallet(walletId)));
|
||||
final firoWallet = wallet as FiroWallet;
|
||||
|
||||
final coin = wallet.info.coin;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
@ -162,9 +164,7 @@ class _FiroBalanceSelectionSheetState
|
|||
width: 2,
|
||||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(manager.coin))
|
||||
.format(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
firoWallet.availablePrivateBalance(),
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
|
@ -240,9 +240,7 @@ class _FiroBalanceSelectionSheetState
|
|||
width: 2,
|
||||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(manager.coin))
|
||||
.format(
|
||||
ref.watch(pAmountFormatter(coin)).format(
|
||||
firoWallet.availablePublicBalance(),
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
|
||||
final feeSheetSessionCacheProvider =
|
||||
|
@ -83,21 +84,21 @@ class _TransactionFeeSelectionSheetState
|
|||
case FeeRateType.fast:
|
||||
if (ref.read(feeSheetSessionCacheProvider).fast[amount] == null) {
|
||||
if (widget.isToken == false) {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
final fee = await manager.estimateFeeFor(
|
||||
final fee = await wallet.estimateFeeFor(
|
||||
amount, MoneroTransactionPriority.fast.raw!);
|
||||
ref.read(feeSheetSessionCacheProvider).fast[amount] = fee;
|
||||
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
||||
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
||||
"Private") {
|
||||
ref.read(feeSheetSessionCacheProvider).fast[amount] =
|
||||
await (manager.wallet as FiroWallet)
|
||||
await (wallet as FiroWallet)
|
||||
.estimateFeeForPublic(amount, feeRate);
|
||||
} else {
|
||||
ref.read(feeSheetSessionCacheProvider).fast[amount] =
|
||||
await manager.estimateFeeFor(amount, feeRate);
|
||||
await wallet.estimateFeeFor(amount, feeRate);
|
||||
}
|
||||
} else {
|
||||
final tokenWallet = ref.read(tokenServiceProvider)!;
|
||||
|
@ -110,20 +111,20 @@ class _TransactionFeeSelectionSheetState
|
|||
case FeeRateType.average:
|
||||
if (ref.read(feeSheetSessionCacheProvider).average[amount] == null) {
|
||||
if (widget.isToken == false) {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
final fee = await manager.estimateFeeFor(
|
||||
final fee = await wallet.estimateFeeFor(
|
||||
amount, MoneroTransactionPriority.regular.raw!);
|
||||
ref.read(feeSheetSessionCacheProvider).average[amount] = fee;
|
||||
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
||||
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
||||
"Private") {
|
||||
ref.read(feeSheetSessionCacheProvider).average[amount] =
|
||||
await (manager.wallet as FiroWallet)
|
||||
await (wallet as FiroWallet)
|
||||
.estimateFeeForPublic(amount, feeRate);
|
||||
} else {
|
||||
ref.read(feeSheetSessionCacheProvider).average[amount] =
|
||||
await manager.estimateFeeFor(amount, feeRate);
|
||||
await wallet.estimateFeeFor(amount, feeRate);
|
||||
}
|
||||
} else {
|
||||
final tokenWallet = ref.read(tokenServiceProvider)!;
|
||||
|
@ -136,20 +137,20 @@ class _TransactionFeeSelectionSheetState
|
|||
case FeeRateType.slow:
|
||||
if (ref.read(feeSheetSessionCacheProvider).slow[amount] == null) {
|
||||
if (widget.isToken == false) {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
final fee = await manager.estimateFeeFor(
|
||||
final fee = await wallet.estimateFeeFor(
|
||||
amount, MoneroTransactionPriority.slow.raw!);
|
||||
ref.read(feeSheetSessionCacheProvider).slow[amount] = fee;
|
||||
} else if ((coin == Coin.firo || coin == Coin.firoTestNet) &&
|
||||
ref.read(publicPrivateBalanceStateProvider.state).state !=
|
||||
"Private") {
|
||||
ref.read(feeSheetSessionCacheProvider).slow[amount] =
|
||||
await (manager.wallet as FiroWallet)
|
||||
await (wallet as FiroWallet)
|
||||
.estimateFeeForPublic(amount, feeRate);
|
||||
} else {
|
||||
ref.read(feeSheetSessionCacheProvider).slow[amount] =
|
||||
await manager.estimateFeeFor(amount, feeRate);
|
||||
await wallet.estimateFeeFor(amount, feeRate);
|
||||
}
|
||||
} else {
|
||||
final tokenWallet = ref.read(tokenServiceProvider)!;
|
||||
|
@ -200,8 +201,9 @@ class _TransactionFeeSelectionSheetState
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final manager =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId)));
|
||||
final wallet = ref.watch(pWallets).getWallet(walletId);
|
||||
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
@ -241,7 +243,7 @@ class _TransactionFeeSelectionSheetState
|
|||
FutureBuilder(
|
||||
future: widget.isToken
|
||||
? ref.read(tokenServiceProvider)!.fees
|
||||
: manager.fees,
|
||||
: wallet.fees,
|
||||
builder: (context, AsyncSnapshot<FeeObject> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
@ -267,7 +269,8 @@ class _TransactionFeeSelectionSheetState
|
|||
ref.read(feeRateTypeStateProvider.state).state =
|
||||
FeeRateType.fast;
|
||||
}
|
||||
String? fee = getAmount(FeeRateType.fast, manager.coin);
|
||||
String? fee =
|
||||
getAmount(FeeRateType.fast, wallet.info.coin);
|
||||
if (fee != null) {
|
||||
widget.updateChosen(fee);
|
||||
}
|
||||
|
@ -330,7 +333,7 @@ class _TransactionFeeSelectionSheetState
|
|||
if (feeObject != null)
|
||||
FutureBuilder(
|
||||
future: feeFor(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
feeRateType: FeeRateType.fast,
|
||||
feeRate: feeObject!.fast,
|
||||
amount: amount,
|
||||
|
@ -343,7 +346,7 @@ class _TransactionFeeSelectionSheetState
|
|||
return Text(
|
||||
"(~${ref.watch(
|
||||
pAmountFormatter(
|
||||
manager.coin,
|
||||
coin,
|
||||
),
|
||||
).format(
|
||||
snapshot.data!,
|
||||
|
@ -370,18 +373,18 @@ class _TransactionFeeSelectionSheetState
|
|||
height: 2,
|
||||
),
|
||||
if (feeObject == null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
AnimatedText(
|
||||
stringsToLoopThrough:
|
||||
stringsToLoopThrough,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
if (feeObject != null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
Text(
|
||||
estimatedTimeToBeIncludedInNextBlock(
|
||||
Constants.targetBlockTimeInSeconds(
|
||||
manager.coin),
|
||||
coin),
|
||||
feeObject!.numberOfBlocksFast,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
|
@ -405,8 +408,7 @@ class _TransactionFeeSelectionSheetState
|
|||
ref.read(feeRateTypeStateProvider.state).state =
|
||||
FeeRateType.average;
|
||||
}
|
||||
String? fee =
|
||||
getAmount(FeeRateType.average, manager.coin);
|
||||
String? fee = getAmount(FeeRateType.average, coin);
|
||||
if (fee != null) {
|
||||
widget.updateChosen(fee);
|
||||
}
|
||||
|
@ -467,7 +469,7 @@ class _TransactionFeeSelectionSheetState
|
|||
if (feeObject != null)
|
||||
FutureBuilder(
|
||||
future: feeFor(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
feeRateType: FeeRateType.average,
|
||||
feeRate: feeObject!.medium,
|
||||
amount: amount,
|
||||
|
@ -480,7 +482,7 @@ class _TransactionFeeSelectionSheetState
|
|||
return Text(
|
||||
"(~${ref.watch(
|
||||
pAmountFormatter(
|
||||
manager.coin,
|
||||
coin,
|
||||
),
|
||||
).format(
|
||||
snapshot.data!,
|
||||
|
@ -507,18 +509,18 @@ class _TransactionFeeSelectionSheetState
|
|||
height: 2,
|
||||
),
|
||||
if (feeObject == null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
AnimatedText(
|
||||
stringsToLoopThrough:
|
||||
stringsToLoopThrough,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
if (feeObject != null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
Text(
|
||||
estimatedTimeToBeIncludedInNextBlock(
|
||||
Constants.targetBlockTimeInSeconds(
|
||||
manager.coin),
|
||||
coin),
|
||||
feeObject!.numberOfBlocksAverage,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
|
@ -542,7 +544,7 @@ class _TransactionFeeSelectionSheetState
|
|||
ref.read(feeRateTypeStateProvider.state).state =
|
||||
FeeRateType.slow;
|
||||
}
|
||||
String? fee = getAmount(FeeRateType.slow, manager.coin);
|
||||
String? fee = getAmount(FeeRateType.slow, coin);
|
||||
if (fee != null) {
|
||||
widget.updateChosen(fee);
|
||||
}
|
||||
|
@ -603,7 +605,7 @@ class _TransactionFeeSelectionSheetState
|
|||
if (feeObject != null)
|
||||
FutureBuilder(
|
||||
future: feeFor(
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
feeRateType: FeeRateType.slow,
|
||||
feeRate: feeObject!.slow,
|
||||
amount: amount,
|
||||
|
@ -616,7 +618,7 @@ class _TransactionFeeSelectionSheetState
|
|||
return Text(
|
||||
"(~${ref.watch(
|
||||
pAmountFormatter(
|
||||
manager.coin,
|
||||
coin,
|
||||
),
|
||||
).format(
|
||||
snapshot.data!,
|
||||
|
@ -643,18 +645,18 @@ class _TransactionFeeSelectionSheetState
|
|||
height: 2,
|
||||
),
|
||||
if (feeObject == null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
AnimatedText(
|
||||
stringsToLoopThrough:
|
||||
stringsToLoopThrough,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
if (feeObject != null &&
|
||||
manager.coin != Coin.ethereum)
|
||||
coin != Coin.ethereum)
|
||||
Text(
|
||||
estimatedTimeToBeIncludedInNextBlock(
|
||||
Constants.targetBlockTimeInSeconds(
|
||||
manager.coin),
|
||||
coin),
|
||||
feeObject!.numberOfBlocksSlow,
|
||||
),
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
|
@ -670,7 +672,7 @@ class _TransactionFeeSelectionSheetState
|
|||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
if (manager.coin.isElectrumXCoin)
|
||||
if (coin.isElectrumXCoin)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
final state =
|
||||
|
@ -739,7 +741,7 @@ class _TransactionFeeSelectionSheetState
|
|||
),
|
||||
),
|
||||
),
|
||||
if (manager.coin.isElectrumXCoin)
|
||||
if (coin.isElectrumXCoin)
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
|
|
|
@ -26,7 +26,6 @@ import 'package:stackwallet/providers/providers.dart';
|
|||
import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -42,6 +41,8 @@ import 'package:stackwallet/utilities/logger.dart';
|
|||
import 'package:stackwallet/utilities/prefs.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/models/tx_data.dart';
|
||||
import 'package:stackwallet/widgets/animated_text.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -194,7 +195,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
// now check for non standard encoded basic address
|
||||
} else if (ref
|
||||
.read(pWallets)
|
||||
.getManager(walletId)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(qrResult.rawContent)) {
|
||||
_address = qrResult.rawContent.trim();
|
||||
sendToController.text = _address ?? "";
|
||||
|
@ -325,19 +327,27 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
});
|
||||
}
|
||||
|
||||
String? _updateInvalidAddressText(String address, Manager manager) {
|
||||
String? _updateInvalidAddressText(String address) {
|
||||
if (_data != null && _data!.contactLabel == address) {
|
||||
return null;
|
||||
}
|
||||
if (address.isNotEmpty && !manager.validateAddress(address)) {
|
||||
if (address.isNotEmpty &&
|
||||
!ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(address)) {
|
||||
return "Invalid address";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void _updatePreviewButtonState(String? address, Amount? amount) {
|
||||
final isValidAddress =
|
||||
ref.read(pWallets).getManager(walletId).validateAddress(address ?? "");
|
||||
final isValidAddress = ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId)
|
||||
.cryptoCurrency
|
||||
.validateAddress(address ?? "");
|
||||
ref.read(previewTxButtonStateProvider.state).state =
|
||||
(isValidAddress && amount != null && amount > Amount.zero);
|
||||
}
|
||||
|
@ -378,7 +388,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
await Future<void>.delayed(
|
||||
const Duration(milliseconds: 100),
|
||||
);
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
final tokenWallet = ref.read(tokenServiceProvider)!;
|
||||
|
||||
final Amount amount = _amountToSend!;
|
||||
|
@ -445,7 +455,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return BuildingTransactionDialog(
|
||||
coin: manager.coin,
|
||||
coin: wallet.info.coin,
|
||||
onCancel: () {
|
||||
wasCancelled = true;
|
||||
|
||||
|
@ -463,15 +473,20 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> txData;
|
||||
Future<Map<String, dynamic>> txDataFuture;
|
||||
TxData txData;
|
||||
Future<TxData> txDataFuture;
|
||||
|
||||
txDataFuture = tokenWallet.prepareSend(
|
||||
address: _address!,
|
||||
amount: amount,
|
||||
args: {
|
||||
"feeRate": ref.read(feeRateTypeStateProvider),
|
||||
},
|
||||
txData: TxData(
|
||||
recipients: [
|
||||
(
|
||||
address: _address!,
|
||||
amount: amount,
|
||||
)
|
||||
],
|
||||
feeRateType: ref.read(feeRateTypeStateProvider),
|
||||
note: noteController.text,
|
||||
),
|
||||
);
|
||||
|
||||
final results = await Future.wait([
|
||||
|
@ -479,20 +494,17 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
time,
|
||||
]);
|
||||
|
||||
txData = results.first as Map<String, dynamic>;
|
||||
txData = results.first as TxData;
|
||||
|
||||
if (!wasCancelled && mounted) {
|
||||
// pop building dialog
|
||||
Navigator.of(context).pop();
|
||||
txData["note"] = noteController.text;
|
||||
|
||||
txData["address"] = _address;
|
||||
|
||||
unawaited(Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
transactionInfo: txData,
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
isTokenTx: true,
|
||||
),
|
||||
|
@ -595,8 +607,6 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final provider = ref
|
||||
.watch(pWallets.select((value) => value.getManagerProvider(walletId)));
|
||||
final String locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
||||
|
@ -664,8 +674,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
ref.watch(provider.select(
|
||||
(value) => value.walletName)),
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.titleBold12(context)
|
||||
.copyWith(fontSize: 14),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
@ -857,7 +866,6 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
builder: (_) {
|
||||
final error = _updateInvalidAddressText(
|
||||
_address ?? "",
|
||||
ref.read(pWallets).getManager(walletId),
|
||||
);
|
||||
|
||||
if (error == null || error.isEmpty) {
|
||||
|
|
|
@ -359,7 +359,7 @@ abstract class SWB {
|
|||
StackRestoringUIState? uiState,
|
||||
WalletsService walletsService,
|
||||
) async {
|
||||
final manager = tuple.item2;
|
||||
final wallet = tuple.item2;
|
||||
final walletbackup = tuple.item1;
|
||||
|
||||
List<String> mnemonicList = (walletbackup['mnemonic'] as List<dynamic>)
|
||||
|
@ -705,7 +705,7 @@ abstract class SWB {
|
|||
failovers,
|
||||
);
|
||||
|
||||
final manager = Manager(wallet);
|
||||
final wallet = Manager(wallet);
|
||||
|
||||
managers.add(Tuple2(walletbackup, manager));
|
||||
// check if cancel was requested and restore previous state
|
||||
|
|
|
@ -105,10 +105,10 @@ class _RestoringWalletCardState extends ConsumerState<RestoringWalletCard> {
|
|||
),
|
||||
onRightTapped: restoringStatus == StackRestoringStatus.failed
|
||||
? () async {
|
||||
final manager = ref.read(provider).manager!;
|
||||
final wallet = ref.read(provider).manager!;
|
||||
|
||||
ref.read(stackRestoringUIStateProvider).update(
|
||||
walletId: manager.walletId,
|
||||
walletId: wallet.walletId,
|
||||
restoringStatus: StackRestoringStatus.restoring);
|
||||
|
||||
try {
|
||||
|
@ -250,7 +250,7 @@ class _RestoringWalletCardState extends ConsumerState<RestoringWalletCard> {
|
|||
),
|
||||
onRightTapped: restoringStatus == StackRestoringStatus.failed
|
||||
? () async {
|
||||
final manager = ref.read(provider).manager!;
|
||||
final wallet = ref.read(provider).manager!;
|
||||
|
||||
ref.read(stackRestoringUIStateProvider).update(
|
||||
walletId: manager.walletId,
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
|
|||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -45,7 +46,7 @@ class _StartupPreferencesViewState
|
|||
// check if wallet exists (hasn't been deleted or otherwise missing)
|
||||
if (possibleWalletId != null) {
|
||||
try {
|
||||
ref.read(pWallets).getManager(possibleWalletId);
|
||||
ref.read(pWallets).getWallet(possibleWalletId);
|
||||
} catch (_) {
|
||||
safe = false;
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
|
@ -252,19 +253,14 @@ class _StartupPreferencesViewState
|
|||
File(
|
||||
ref.watch(
|
||||
coinIconProvider(
|
||||
ref
|
||||
.watch(
|
||||
pWallets
|
||||
.select(
|
||||
(value) =>
|
||||
value.getManager(
|
||||
ref.watch(
|
||||
prefsChangeNotifierProvider.select((value) => value.startupWalletId!),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.coin,
|
||||
ref.watch(
|
||||
pWalletCoin(
|
||||
ref.watch(
|
||||
prefsChangeNotifierProvider.select((value) =>
|
||||
value.startupWalletId!),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -273,21 +269,15 @@ class _StartupPreferencesViewState
|
|||
width: 10,
|
||||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(
|
||||
pWallets
|
||||
.select(
|
||||
(value) =>
|
||||
value
|
||||
.getManager(
|
||||
ref.watch(
|
||||
prefsChangeNotifierProvider.select((value) =>
|
||||
value.startupWalletId!),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.walletName,
|
||||
ref.watch(
|
||||
pWalletName(
|
||||
ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) =>
|
||||
value.startupWalletId!),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: STextStyles
|
||||
.itemSubtitle(
|
||||
context),
|
||||
|
|
|
@ -18,6 +18,7 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
|
|||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
|
||||
|
@ -38,10 +39,10 @@ class _StartupWalletSelectionViewState
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final managers = ref.watch(pWallets.select((value) => value.managers));
|
||||
final wallets = ref.watch(pWallets).wallets;
|
||||
|
||||
_controllers.clear();
|
||||
for (final manager in managers) {
|
||||
for (final manager in wallets) {
|
||||
_controllers[manager.walletId] = DSBController();
|
||||
}
|
||||
|
||||
|
@ -94,18 +95,21 @@ class _StartupWalletSelectionViewState
|
|||
padding: const EdgeInsets.all(0),
|
||||
child: Column(
|
||||
children: [
|
||||
...managers.map(
|
||||
(manager) => Padding(
|
||||
...wallets.map(
|
||||
(wallet) => Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
key: Key(
|
||||
"startupWalletSelectionGroupKey_${manager.walletId}"),
|
||||
"startupWalletSelectionGroupKey_${wallet.walletId}"),
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.colorForCoin(manager.coin)
|
||||
.colorForCoin(
|
||||
ref.watch(pWalletCoin(
|
||||
wallet.walletId)),
|
||||
)
|
||||
.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
|
@ -116,7 +120,10 @@ class _StartupWalletSelectionViewState
|
|||
child: SvgPicture.file(
|
||||
File(
|
||||
ref.watch(
|
||||
coinIconProvider(manager.coin),
|
||||
coinIconProvider(
|
||||
ref.watch(pWalletCoin(
|
||||
wallet.walletId)),
|
||||
),
|
||||
),
|
||||
),
|
||||
width: 20,
|
||||
|
@ -135,7 +142,8 @@ class _StartupWalletSelectionViewState
|
|||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
manager.walletName,
|
||||
ref.watch(
|
||||
pWalletName(wallet.walletId)),
|
||||
style: STextStyles.titleBold12(
|
||||
context),
|
||||
),
|
||||
|
@ -183,7 +191,7 @@ class _StartupWalletSelectionViewState
|
|||
activeColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.radioButtonIconEnabled,
|
||||
value: manager.walletId,
|
||||
value: wallet.walletId,
|
||||
groupValue: ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) =>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -95,8 +96,8 @@ class SyncingOptionsView extends ConsumerWidget {
|
|||
SyncingType.currentWalletOnly;
|
||||
|
||||
// disable auto sync on all wallets that aren't active/current
|
||||
ref.read(pWallets).managers.forEach((e) {
|
||||
if (!e.isActiveWallet) {
|
||||
ref.read(pWallets).wallets.forEach((e) {
|
||||
if (e.walletId != ref.read(currentWalletIdProvider)) {
|
||||
e.shouldAutoSync = false;
|
||||
}
|
||||
});
|
||||
|
@ -176,7 +177,7 @@ class SyncingOptionsView extends ConsumerWidget {
|
|||
// enable auto sync on all wallets
|
||||
ref
|
||||
.read(pWallets)
|
||||
.managers
|
||||
.wallets
|
||||
.forEach((e) => e.shouldAutoSync = true);
|
||||
}
|
||||
},
|
||||
|
@ -256,7 +257,7 @@ class SyncingOptionsView extends ConsumerWidget {
|
|||
.walletIdsSyncOnStartup;
|
||||
|
||||
// enable auto sync on selected wallets only
|
||||
ref.read(pWallets).managers.forEach(
|
||||
ref.read(pWallets).wallets.forEach(
|
||||
(e) => e.shouldAutoSync = ids.contains(e.walletId));
|
||||
}
|
||||
},
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
|
@ -21,6 +22,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/sync_type_enum.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -34,7 +36,7 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final managers = ref.watch(pWallets.select((value) => value.managers));
|
||||
final walletInfos = ref.watch(pWallets).wallets.map((e) => e.info);
|
||||
|
||||
final isDesktop = Util.isDesktop;
|
||||
return ConditionalParent(
|
||||
|
@ -73,7 +75,7 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
condition: isDesktop,
|
||||
builder: (child) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 32),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
|
@ -108,18 +110,18 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
.background,
|
||||
child: Column(
|
||||
children: [
|
||||
...managers.map(
|
||||
(manager) => Padding(
|
||||
...walletInfos.map(
|
||||
(info) => Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
key: Key(
|
||||
"syncingPrefsSelectedWalletIdGroupKey_${manager.walletId}"),
|
||||
"syncingPrefsSelectedWalletIdGroupKey_${info.walletId}"),
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.colorForCoin(manager.coin)
|
||||
.colorForCoin(info.coin)
|
||||
.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
|
@ -130,7 +132,7 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
child: SvgPicture.file(
|
||||
File(
|
||||
ref.watch(
|
||||
coinIconProvider(manager.coin),
|
||||
coinIconProvider(info.coin),
|
||||
),
|
||||
),
|
||||
width: 20,
|
||||
|
@ -148,7 +150,7 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
manager.walletName,
|
||||
info.name,
|
||||
style:
|
||||
STextStyles.titleBold12(context),
|
||||
),
|
||||
|
@ -157,9 +159,12 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(pAmountFormatter(
|
||||
manager.coin))
|
||||
.format(manager.balance.total),
|
||||
.watch(
|
||||
pAmountFormatter(info.coin))
|
||||
.format(ref
|
||||
.watch(pWalletBalance(
|
||||
info.walletId))
|
||||
.total),
|
||||
style:
|
||||
STextStyles.itemSubtitle(context),
|
||||
)
|
||||
|
@ -174,7 +179,7 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
.watch(prefsChangeNotifierProvider
|
||||
.select((value) => value
|
||||
.walletIdsSyncOnStartup))
|
||||
.contains(manager.walletId),
|
||||
.contains(info.walletId),
|
||||
onValueChanged: (value) {
|
||||
final syncType = ref
|
||||
.read(prefsChangeNotifierProvider)
|
||||
|
@ -184,22 +189,28 @@ class WalletSyncingOptionsView extends ConsumerWidget {
|
|||
.walletIdsSyncOnStartup
|
||||
.toList();
|
||||
if (value) {
|
||||
ids.add(manager.walletId);
|
||||
ids.add(info.walletId);
|
||||
} else {
|
||||
ids.remove(manager.walletId);
|
||||
ids.remove(info.walletId);
|
||||
}
|
||||
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.getWallet(info.walletId);
|
||||
|
||||
switch (syncType) {
|
||||
case SyncingType.currentWalletOnly:
|
||||
if (manager.isActiveWallet) {
|
||||
manager.shouldAutoSync = value;
|
||||
if (info.walletId ==
|
||||
ref.read(
|
||||
currentWalletIdProvider)) {
|
||||
wallet.shouldAutoSync = value;
|
||||
}
|
||||
break;
|
||||
case SyncingType
|
||||
.selectedWalletsAtStartup:
|
||||
case SyncingType
|
||||
.allWalletsOnStartup:
|
||||
manager.shouldAutoSync = value;
|
||||
wallet.shouldAutoSync = value;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
@ -98,10 +98,7 @@ class WalletBackupView extends ConsumerWidget {
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
ref
|
||||
.watch(
|
||||
pWallets.select((value) => value.getManager(walletId)))
|
||||
.walletName,
|
||||
ref.watch(pWalletName(walletId)),
|
||||
textAlign: TextAlign.center,
|
||||
style: STextStyles.label(context).copyWith(
|
||||
fontSize: 12,
|
||||
|
|
|
@ -38,6 +38,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/animated_text.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
|
@ -136,12 +137,10 @@ class _WalletNetworkSettingsViewState
|
|||
);
|
||||
|
||||
try {
|
||||
if (ref.read(pWallets).getManager(widget.walletId).coin == Coin.firo) {
|
||||
maxUnusedAddressGap = 50;
|
||||
}
|
||||
await ref.read(pWallets).getManager(widget.walletId).fullRescan(
|
||||
maxUnusedAddressGap,
|
||||
maxNumberOfIndexesToCheck,
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
|
||||
await wallet.recover(isRescan: true
|
||||
,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
|
@ -250,7 +249,7 @@ class _WalletNetworkSettingsViewState
|
|||
},
|
||||
);
|
||||
|
||||
final coin = ref.read(pWallets).getManager(widget.walletId).coin;
|
||||
final coin = ref.read(pWalletCoin(widget.walletId));
|
||||
|
||||
if (coin == Coin.monero || coin == Coin.wownero || coin == Coin.epicCash) {
|
||||
_blocksRemainingSubscription = eventBus.on<BlocksRemainingEvent>().listen(
|
||||
|
@ -309,36 +308,36 @@ class _WalletNetworkSettingsViewState
|
|||
? 430.0
|
||||
: screenWidth - (_padding * 2) - (_boxPadding * 3) - _iconSize;
|
||||
|
||||
final coin = ref.read(pWallets).getManager(widget.walletId).coin;
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
if (coin == Coin.monero) {
|
||||
double highestPercent = (ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as MoneroWallet)
|
||||
.highestPercentCached;
|
||||
if (_percent < highestPercent) {
|
||||
_percent = highestPercent.clamp(0.0, 1.0);
|
||||
}
|
||||
} else if (coin == Coin.wownero) {
|
||||
double highestPercent = (ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as WowneroWallet)
|
||||
.highestPercentCached;
|
||||
if (_percent < highestPercent) {
|
||||
_percent = highestPercent.clamp(0.0, 1.0);
|
||||
}
|
||||
} else if (coin == Coin.epicCash) {
|
||||
double highestPercent = (ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as EpicCashWallet)
|
||||
.highestPercent;
|
||||
if (_percent < highestPercent) {
|
||||
_percent = highestPercent.clamp(0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: [prio=high] sync percent for certain wallets
|
||||
// if (coin == Coin.monero) {
|
||||
// double highestPercent =
|
||||
// (ref.read(pWallets).getWallet(widget.walletId).wallet as MoneroWallet)
|
||||
// .highestPercentCached;
|
||||
// if (_percent < highestPercent) {
|
||||
// _percent = highestPercent.clamp(0.0, 1.0);
|
||||
// }
|
||||
// } else if (coin == Coin.wownero) {
|
||||
// double highestPercent = (ref
|
||||
// .watch(pWallets)
|
||||
// .getWallet(widget.walletId)
|
||||
// .wallet as WowneroWallet)
|
||||
// .highestPercentCached;
|
||||
// if (_percent < highestPercent) {
|
||||
// _percent = highestPercent.clamp(0.0, 1.0);
|
||||
// }
|
||||
// } else if (coin == Coin.epicCash) {
|
||||
// double highestPercent = (ref
|
||||
// .watch(pWallets)
|
||||
// .getWallet(widget.walletId)
|
||||
// .wallet as EpicCashWallet)
|
||||
// .highestPercent;
|
||||
// if (_percent < highestPercent) {
|
||||
// _percent = highestPercent.clamp(0.0, 1.0);
|
||||
// }
|
||||
// }
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
|
@ -358,7 +357,7 @@ class _WalletNetworkSettingsViewState
|
|||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
actions: [
|
||||
if (ref.read(pWallets).getManager(widget.walletId).coin !=
|
||||
if (ref.watch(pWalletCoin(widget.walletId)) !=
|
||||
Coin.epicCash)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
@ -483,7 +482,7 @@ class _WalletNetworkSettingsViewState
|
|||
CustomTextButton(
|
||||
text: "Resync",
|
||||
onTap: () {
|
||||
ref.read(pWallets).getManager(widget.walletId).refresh();
|
||||
ref.read(pWallets).getWallet(widget.walletId).refresh();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -886,7 +885,7 @@ class _WalletNetworkSettingsViewState
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"${ref.watch(pWallets.select((value) => value.getManager(widget.walletId).coin)).prettyName} nodes",
|
||||
"${ref.watch(pWalletCoin(widget.walletId)).prettyName} nodes",
|
||||
textAlign: TextAlign.left,
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextExtraExtraSmall(context)
|
||||
|
@ -899,7 +898,7 @@ class _WalletNetworkSettingsViewState
|
|||
AddEditNodeView.routeName,
|
||||
arguments: Tuple4(
|
||||
AddEditNodeViewType.add,
|
||||
ref.read(pWallets).getManager(widget.walletId).coin,
|
||||
ref.read(pWalletCoin(widget.walletId)),
|
||||
null,
|
||||
WalletNetworkSettingsView.routeName,
|
||||
),
|
||||
|
@ -912,18 +911,17 @@ class _WalletNetworkSettingsViewState
|
|||
height: isDesktop ? 12 : 8,
|
||||
),
|
||||
NodesList(
|
||||
coin: ref.watch(pWallets
|
||||
.select((value) => value.getManager(widget.walletId).coin)),
|
||||
coin: ref.watch(pWalletCoin(widget.walletId)),
|
||||
popBackToRoute: WalletNetworkSettingsView.routeName,
|
||||
),
|
||||
if (isDesktop &&
|
||||
ref.read(pWallets).getManager(widget.walletId).coin !=
|
||||
ref.watch(pWalletCoin(widget.walletId)) !=
|
||||
Coin.epicCash)
|
||||
const SizedBox(
|
||||
height: 32,
|
||||
),
|
||||
if (isDesktop &&
|
||||
ref.read(pWallets).getManager(widget.walletId).coin !=
|
||||
ref.watch(pWalletCoin(widget.walletId)) !=
|
||||
Coin.epicCash)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
|
@ -941,7 +939,7 @@ class _WalletNetworkSettingsViewState
|
|||
),
|
||||
),
|
||||
if (isDesktop &&
|
||||
ref.read(pWallets).getManager(widget.walletId).coin !=
|
||||
ref.watch(pWalletCoin(widget.walletId)) !=
|
||||
Coin.epicCash)
|
||||
RoundedWhiteContainer(
|
||||
borderColor: isDesktop
|
||||
|
|
|
@ -40,6 +40,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/wallet/bip39_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';
|
||||
|
@ -88,7 +89,9 @@ class _WalletSettingsViewState extends ConsumerState<WalletSettingsView> {
|
|||
void initState() {
|
||||
walletId = widget.walletId;
|
||||
coin = widget.coin;
|
||||
xPubEnabled = ref.read(pWallets).getManager(walletId).hasXPub;
|
||||
// TODO: [prio=low] xpubs
|
||||
// xPubEnabled = ref.read(pWallets).getWallet(walletId).hasXPub;
|
||||
xPubEnabled = false;
|
||||
xpub = "";
|
||||
|
||||
_currentSyncStatus = widget.initialSyncStatus;
|
||||
|
@ -229,36 +232,42 @@ class _WalletSettingsViewState extends ConsumerState<WalletSettingsView> {
|
|||
iconSize: 16,
|
||||
title: "Wallet backup",
|
||||
onPressed: () async {
|
||||
final mnemonic = await ref
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.getManager(walletId)
|
||||
.mnemonic;
|
||||
.getWallet(widget.walletId);
|
||||
// TODO: [prio=high] take wallets that don't have amnemonic into account
|
||||
if (wallet is Bip39Wallet) {
|
||||
final mnemonic =
|
||||
await wallet.getMnemonicAsWords();
|
||||
|
||||
if (mounted) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute:
|
||||
RouteGenerator
|
||||
.useMaterialPageRoute,
|
||||
builder: (_) => LockscreenView(
|
||||
routeOnSuccessArguments:
|
||||
Tuple2(walletId, mnemonic),
|
||||
showBackButton: true,
|
||||
routeOnSuccess:
|
||||
WalletBackupView.routeName,
|
||||
biometricsCancelButtonString:
|
||||
"CANCEL",
|
||||
biometricsLocalizedReason:
|
||||
"Authenticate to view recovery phrase",
|
||||
biometricsAuthenticationTitle:
|
||||
"View recovery phrase",
|
||||
if (mounted) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute:
|
||||
RouteGenerator
|
||||
.useMaterialPageRoute,
|
||||
builder: (_) => LockscreenView(
|
||||
routeOnSuccessArguments:
|
||||
Tuple2(
|
||||
walletId, mnemonic),
|
||||
showBackButton: true,
|
||||
routeOnSuccess:
|
||||
WalletBackupView
|
||||
.routeName,
|
||||
biometricsCancelButtonString:
|
||||
"CANCEL",
|
||||
biometricsLocalizedReason:
|
||||
"Authenticate to view recovery phrase",
|
||||
biometricsAuthenticationTitle:
|
||||
"View recovery phrase",
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name:
|
||||
"/viewRecoverPhraseLockscreen"),
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name:
|
||||
"/viewRecoverPhraseLockscreen"),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -405,10 +414,11 @@ class _WalletSettingsViewState extends ConsumerState<WalletSettingsView> {
|
|||
builder: (_, ref, __) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManager(walletId)
|
||||
.isActiveWallet = false;
|
||||
// TODO: [prio=med] needs more thought if this is still required
|
||||
// ref
|
||||
// .read(pWallets)
|
||||
// .getWallet(walletId)
|
||||
// .isActiveWallet = false;
|
||||
ref
|
||||
.read(transactionFilterProvider.state)
|
||||
.state = null;
|
||||
|
@ -464,8 +474,7 @@ class _EpiBoxInfoFormState extends ConsumerState<EpicBoxInfoForm> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
wallet =
|
||||
ref.read(pWallets).getManager(widget.walletId).wallet as EpicCashWallet;
|
||||
wallet = ref.read(pWallets).getWallet(widget.walletId) as EpicCashWallet;
|
||||
|
||||
wallet.getEpicBoxConfig().then((EpicBoxConfigModel epicBoxConfig) {
|
||||
hostController.text = epicBoxConfig.host;
|
||||
|
|
|
@ -64,22 +64,24 @@ class _XPubViewState extends ConsumerState<ChangeRepresentativeView> {
|
|||
String? representative;
|
||||
|
||||
Future<String> loadRepresentative() async {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
final coin = wallet.info.coin;
|
||||
|
||||
if (manager.coin == Coin.nano) {
|
||||
return (manager.wallet as NanoWallet).getCurrentRepresentative();
|
||||
} else if (manager.coin == Coin.banano) {
|
||||
return (manager.wallet as BananoWallet).getCurrentRepresentative();
|
||||
if (coin == Coin.nano) {
|
||||
return (wallet as NanoWallet).getCurrentRepresentative();
|
||||
} else if (coin == Coin.banano) {
|
||||
return (wallet as BananoWallet).getCurrentRepresentative();
|
||||
}
|
||||
throw Exception("Unsupported wallet attempted to show representative!");
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
final manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
final coin = wallet.info.coin;
|
||||
|
||||
final changeFuture = manager.coin == Coin.nano
|
||||
? (manager.wallet as NanoWallet).changeRepresentative
|
||||
: (manager.wallet as BananoWallet).changeRepresentative;
|
||||
final changeFuture = coin == Coin.nano
|
||||
? (wallet as NanoWallet).changeRepresentative
|
||||
: (wallet as BananoWallet).changeRepresentative;
|
||||
|
||||
final result = await showLoading(
|
||||
whileFuture: changeFuture(_textController.text),
|
||||
|
|
|
@ -8,20 +8,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart';
|
||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
@ -29,14 +29,14 @@ import 'package:stackwallet/widgets/stack_dialog.dart';
|
|||
class DeleteWalletRecoveryPhraseView extends ConsumerStatefulWidget {
|
||||
const DeleteWalletRecoveryPhraseView({
|
||||
Key? key,
|
||||
required this.manager,
|
||||
required this.walletId,
|
||||
required this.mnemonic,
|
||||
this.clipboardInterface = const ClipboardWrapper(),
|
||||
}) : super(key: key);
|
||||
|
||||
static const routeName = "/deleteWalletRecoveryPhrase";
|
||||
|
||||
final Manager manager;
|
||||
final String walletId;
|
||||
final List<String> mnemonic;
|
||||
|
||||
final ClipboardInterface clipboardInterface;
|
||||
|
@ -48,13 +48,11 @@ class DeleteWalletRecoveryPhraseView extends ConsumerStatefulWidget {
|
|||
|
||||
class _DeleteWalletRecoveryPhraseViewState
|
||||
extends ConsumerState<DeleteWalletRecoveryPhraseView> {
|
||||
late Manager _manager;
|
||||
late List<String> _mnemonic;
|
||||
late ClipboardInterface _clipboardInterface;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_manager = widget.manager;
|
||||
_mnemonic = widget.mnemonic;
|
||||
_clipboardInterface = widget.clipboardInterface;
|
||||
super.initState();
|
||||
|
@ -90,15 +88,18 @@ class _DeleteWalletRecoveryPhraseViewState
|
|||
.topNavIconPrimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
final words = await _manager.mnemonic;
|
||||
await _clipboardInterface
|
||||
.setData(ClipboardData(text: words.join(" ")));
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
message: "Copied to clipboard",
|
||||
iconAsset: Assets.svg.copy,
|
||||
context: context,
|
||||
);
|
||||
.setData(ClipboardData(text: _mnemonic.join(" ")));
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
message: "Copied to clipboard",
|
||||
iconAsset: Assets.svg.copy,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -114,7 +115,7 @@ class _DeleteWalletRecoveryPhraseViewState
|
|||
height: 4,
|
||||
),
|
||||
Text(
|
||||
_manager.walletName,
|
||||
ref.watch(pWalletName(widget.walletId)),
|
||||
textAlign: TextAlign.center,
|
||||
style: STextStyles.label(context).copyWith(
|
||||
fontSize: 12,
|
||||
|
@ -192,22 +193,23 @@ class _DeleteWalletRecoveryPhraseViewState
|
|||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonStyle(context),
|
||||
onPressed: () async {
|
||||
final walletId = _manager.walletId;
|
||||
final walletsInstance =
|
||||
ref.read(pWallets);
|
||||
await ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.deleteWallet(_manager.walletName, true);
|
||||
// TODO: [prio=high] wallet deletion
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(HomeView.routeName));
|
||||
}
|
||||
|
||||
// wait for widget tree to dispose of any widgets watching the manager
|
||||
await Future<void>.delayed(
|
||||
const Duration(seconds: 1));
|
||||
walletsInstance.removeWallet(walletId: walletId);
|
||||
// final walletId = _manager.walletId;
|
||||
// final walletsInstance = ref.read(pWallets);
|
||||
// await ref
|
||||
// .read(walletsServiceChangeNotifierProvider)
|
||||
// .deleteWallet(_manager.walletName, true);
|
||||
//
|
||||
// if (mounted) {
|
||||
// Navigator.of(context).popUntil(
|
||||
// ModalRoute.withName(HomeView.routeName));
|
||||
// }
|
||||
//
|
||||
// // wait for widget tree to dispose of any widgets watching the manager
|
||||
// await Future<void>.delayed(
|
||||
// const Duration(seconds: 1));
|
||||
// walletsInstance.removeWallet(walletId: walletId);
|
||||
},
|
||||
child: Text(
|
||||
"Ok",
|
||||
|
|
|
@ -14,10 +14,10 @@ import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_set
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/wallet/bip39_wallet.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class DeleteWalletWarningView extends ConsumerWidget {
|
||||
const DeleteWalletWarningView({
|
||||
|
@ -99,15 +99,18 @@ class DeleteWalletWarningView extends ConsumerWidget {
|
|||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonStyle(context),
|
||||
onPressed: () async {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final mnemonic = await manager.mnemonic;
|
||||
Navigator.of(context).pushNamed(
|
||||
DeleteWalletRecoveryPhraseView.routeName,
|
||||
arguments: Tuple2(
|
||||
manager,
|
||||
mnemonic,
|
||||
),
|
||||
);
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
final mnemonic =
|
||||
await (wallet as Bip39Wallet).getMnemonicAsWords();
|
||||
if (context.mounted) {
|
||||
await Navigator.of(context).pushNamed(
|
||||
DeleteWalletRecoveryPhraseView.routeName,
|
||||
arguments: (
|
||||
walletId: walletId,
|
||||
mnemonicWords: mnemonic,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
"View Backup Key",
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||
|
@ -47,7 +50,7 @@ class _RenameWalletViewState extends ConsumerState<RenameWalletView> {
|
|||
void initState() {
|
||||
_controller = TextEditingController();
|
||||
walletId = widget.walletId;
|
||||
originalName = ref.read(pWallets).getManager(walletId).walletName;
|
||||
originalName = ref.read(pWalletName(walletId));
|
||||
_controller.text = originalName;
|
||||
super.initState();
|
||||
}
|
||||
|
@ -125,29 +128,42 @@ class _RenameWalletViewState extends ConsumerState<RenameWalletView> {
|
|||
.getPrimaryEnabledButtonStyle(context),
|
||||
onPressed: () async {
|
||||
final newName = _controller.text;
|
||||
final success = await ref
|
||||
.read(walletsServiceChangeNotifierProvider)
|
||||
.renameWallet(
|
||||
from: originalName,
|
||||
to: newName,
|
||||
shouldNotifyListeners: true,
|
||||
);
|
||||
|
||||
if (success) {
|
||||
ref.read(pWallets).getManager(walletId).walletName =
|
||||
newName;
|
||||
Navigator.of(context).pop();
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
message: "Wallet renamed",
|
||||
context: context,
|
||||
);
|
||||
} else {
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Wallet named \"$newName\" already exists",
|
||||
context: context,
|
||||
);
|
||||
String? errMessage;
|
||||
try {
|
||||
await ref.read(pWalletInfo(walletId)).updateName(
|
||||
newName: newName,
|
||||
isar: ref.read(mainDBProvider).isar,
|
||||
);
|
||||
} catch (e) {
|
||||
if (e
|
||||
.toString()
|
||||
.contains("Empty wallet name not allowed!")) {
|
||||
errMessage = "Empty wallet name not allowed.";
|
||||
} else {
|
||||
errMessage = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
if (errMessage == null) {
|
||||
Navigator.of(context).pop();
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.success,
|
||||
message: "Wallet renamed",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.warning,
|
||||
message: "Wallet named \"$newName\" already exists",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
|
|
|
@ -13,11 +13,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -111,7 +111,7 @@ class WalletSettingsWalletSettingsView extends ConsumerWidget {
|
|||
context: context,
|
||||
builder: (_) => StackDialog(
|
||||
title:
|
||||
"Do you want to delete ${ref.read(pWallets).getManager(walletId).walletName}?",
|
||||
"Do you want to delete ${ref.read(pWalletName(walletId))}?",
|
||||
leftButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
|
|
@ -17,12 +17,12 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/wallet/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';
|
||||
|
@ -53,14 +53,14 @@ class _XPubViewState extends ConsumerState<XPubView> {
|
|||
final bool isDesktop = Util.isDesktop;
|
||||
|
||||
late ClipboardInterface _clipboardInterface;
|
||||
late final Manager manager;
|
||||
late final Wallet wallet;
|
||||
|
||||
String? xpub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_clipboardInterface = widget.clipboardInterface;
|
||||
manager = ref.read(pWallets).getManager(widget.walletId);
|
||||
wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class _XPubViewState extends ConsumerState<XPubView> {
|
|||
left: 32,
|
||||
),
|
||||
child: Text(
|
||||
"${manager.walletName} xPub",
|
||||
"${wallet.info.name} xPub",
|
||||
style: STextStyles.desktopH2(context),
|
||||
),
|
||||
),
|
||||
|
@ -185,7 +185,8 @@ class _XPubViewState extends ConsumerState<XPubView> {
|
|||
child: child,
|
||||
),
|
||||
child: FutureBuilder(
|
||||
future: manager.xpub,
|
||||
future: Future(() => "fixme"),
|
||||
// future: wallet.xpub,
|
||||
builder: (context, AsyncSnapshot<String> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
|
|
@ -12,6 +12,8 @@ import 'package:stackwallet/themes/stack_colors.dart';
|
|||
import 'package:stackwallet/utilities/assets.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/bip39_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';
|
||||
|
@ -131,12 +133,13 @@ class _FiroRescanRecoveryErrorViewState
|
|||
.topNavIconPrimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
final walletName =
|
||||
ref.read(pWalletName(widget.walletId));
|
||||
await showDialog<void>(
|
||||
barrierDismissible: true,
|
||||
context: context,
|
||||
builder: (_) => StackDialog(
|
||||
title:
|
||||
"Do you want to delete ${ref.read(pWallets).getManager(widget.walletId).walletName}?",
|
||||
title: "Do you want to delete $walletName?",
|
||||
leftButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -253,32 +256,34 @@ class _FiroRescanRecoveryErrorViewState
|
|||
),
|
||||
);
|
||||
} else {
|
||||
final mnemonic = await ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.mnemonic;
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId);
|
||||
// TODO: [prio=high] take wallets that don't have amnemonic into account
|
||||
if (wallet is Bip39Wallet) {
|
||||
final mnemonic = await wallet.getMnemonicAsWords();
|
||||
|
||||
if (mounted) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute:
|
||||
RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => LockscreenView(
|
||||
routeOnSuccessArguments:
|
||||
Tuple2(widget.walletId, mnemonic),
|
||||
showBackButton: true,
|
||||
routeOnSuccess: WalletBackupView.routeName,
|
||||
biometricsCancelButtonString: "CANCEL",
|
||||
biometricsLocalizedReason:
|
||||
"Authenticate to view recovery phrase",
|
||||
biometricsAuthenticationTitle:
|
||||
"View recovery phrase",
|
||||
if (mounted) {
|
||||
await Navigator.push(
|
||||
context,
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute:
|
||||
RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => LockscreenView(
|
||||
routeOnSuccessArguments:
|
||||
Tuple2(widget.walletId, mnemonic),
|
||||
showBackButton: true,
|
||||
routeOnSuccess: WalletBackupView.routeName,
|
||||
biometricsCancelButtonString: "CANCEL",
|
||||
biometricsLocalizedReason:
|
||||
"Authenticate to view recovery phrase",
|
||||
biometricsAuthenticationTitle:
|
||||
"View recovery phrase",
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name: "/viewRecoverPhraseLockscreen"),
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name: "/viewRecoverPhraseLockscreen"),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -22,6 +22,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -89,8 +90,7 @@ class _MyTokensViewState extends ConsumerState<MyTokensView> {
|
|||
),
|
||||
title: Text(
|
||||
"${ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(widget.walletId).walletName),
|
||||
pWalletName(widget.walletId),
|
||||
)} Tokens",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
|
@ -234,9 +234,8 @@ class _MyTokensViewState extends ConsumerState<MyTokensView> {
|
|||
walletId: widget.walletId,
|
||||
searchTerm: _searchString,
|
||||
tokenContracts: ref
|
||||
.watch(pWallets.select((value) => value
|
||||
.getManager(widget.walletId)
|
||||
.wallet as EthereumWallet))
|
||||
.watch(pWallets.select((value) =>
|
||||
value.getWallet(widget.walletId) as EthereumWallet))
|
||||
.getWalletTokenContractAddresses(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -26,6 +26,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/utilities/show_loading.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/widgets/desktop/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/dialogs/basic_dialog.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart';
|
||||
|
@ -84,10 +85,8 @@ class _MyTokenSelectItemState extends ConsumerState<MyTokenSelectItem> {
|
|||
ref.read(tokenServiceStateProvider.state).state = EthTokenWallet(
|
||||
token: widget.token,
|
||||
secureStore: ref.read(secureStoreProvider),
|
||||
ethWallet: ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as EthereumWallet,
|
||||
ethWallet:
|
||||
ref.read(pWallets).getWallet(widget.walletId) as EthereumWallet,
|
||||
tracker: TransactionNotificationTracker(
|
||||
walletId: widget.walletId,
|
||||
),
|
||||
|
@ -117,10 +116,7 @@ class _MyTokenSelectItemState extends ConsumerState<MyTokenSelectItem> {
|
|||
cachedBalance = CachedEthTokenBalance(widget.walletId, widget.token);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final address = await ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.currentReceivingAddress;
|
||||
final address = ref.read(pWalletReceivingAddress(widget.walletId));
|
||||
await cachedBalance.fetchAndUpdateCachedBalance(address);
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
|
|
|
@ -24,7 +24,6 @@ import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_refresh_button.
|
|||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/global/price_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
|
@ -34,6 +33,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -78,9 +78,7 @@ class TokenSummary extends ConsumerWidget {
|
|||
),
|
||||
Text(
|
||||
ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(walletId).walletName,
|
||||
),
|
||||
pWalletName(walletId),
|
||||
),
|
||||
style: STextStyles.w500_12(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
|
@ -366,9 +364,11 @@ class CoinTickerTag extends ConsumerWidget {
|
|||
radiusMultiplier: 0.25,
|
||||
color: Theme.of(context).extension<StackColors>()!.ethTagBG,
|
||||
child: Text(
|
||||
ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).coin.ticker),
|
||||
),
|
||||
ref
|
||||
.watch(
|
||||
pWalletCoin(walletId),
|
||||
)
|
||||
.ticker,
|
||||
style: STextStyles.w600_12(context).copyWith(
|
||||
color: Theme.of(context).extension<StackColors>()!.ethTagText,
|
||||
),
|
||||
|
|
|
@ -24,6 +24,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||
|
@ -95,8 +96,7 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
TransactionCard(
|
||||
// this may mess with combined firo transactions
|
||||
key: tx.isConfirmed(
|
||||
ref.watch(pWallets.select((value) =>
|
||||
value.getManager(widget.walletId).currentHeight)),
|
||||
ref.watch(pWalletChainHeight(widget.walletId)),
|
||||
coin.requiredConfirmations)
|
||||
? Key(tx.txid + tx.type.name + tx.address.value.toString())
|
||||
: UniqueKey(), //
|
||||
|
@ -111,8 +111,7 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
trade.uuid), //
|
||||
trade: trade,
|
||||
onTap: () async {
|
||||
final walletName =
|
||||
ref.read(pWallets).getManager(widget.walletId).walletName;
|
||||
final walletName = ref.read(pWalletName(widget.walletId));
|
||||
if (Util.isDesktop) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
|
@ -195,9 +194,7 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
),
|
||||
child: TransactionCard(
|
||||
// this may mess with combined firo transactions
|
||||
key: tx.isConfirmed(
|
||||
ref.watch(pWallets.select((value) =>
|
||||
value.getManager(widget.walletId).currentHeight)),
|
||||
key: tx.isConfirmed(ref.watch(pWalletChainHeight(widget.walletId)),
|
||||
coin.requiredConfirmations)
|
||||
? Key(tx.txid + tx.type.name + tx.address.value.toString())
|
||||
: UniqueKey(),
|
||||
|
@ -210,8 +207,8 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final wallet =
|
||||
ref.watch(pWallets.select((value) => value.getWallet(widget.walletId)));
|
||||
|
||||
return FutureBuilder(
|
||||
future: ref
|
||||
|
@ -262,7 +259,12 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
radius = _borderRadiusFirst;
|
||||
}
|
||||
final tx = _transactions2[index];
|
||||
return itemBuilder(context, tx, radius, manager.coin);
|
||||
return itemBuilder(
|
||||
context,
|
||||
tx,
|
||||
radius,
|
||||
wallet.info.coin,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Container(
|
||||
|
@ -289,7 +291,12 @@ class _TransactionsListState extends ConsumerState<TokenTransactionsList> {
|
|||
radius = _borderRadiusFirst;
|
||||
}
|
||||
final tx = _transactions2[index];
|
||||
return itemBuilder(context, tx, radius, manager.coin);
|
||||
return itemBuilder(
|
||||
context,
|
||||
tx,
|
||||
radius,
|
||||
wallet.info.coin,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -12,19 +12,21 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||
|
@ -36,11 +38,9 @@ class TransactionsList extends ConsumerStatefulWidget {
|
|||
const TransactionsList({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
required this.managerProvider,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
final ChangeNotifierProvider<Manager> managerProvider;
|
||||
|
||||
@override
|
||||
ConsumerState<TransactionsList> createState() => _TransactionsListState();
|
||||
|
@ -51,7 +51,8 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
bool _hasLoaded = false;
|
||||
List<Transaction> _transactions2 = [];
|
||||
|
||||
late final ChangeNotifierProvider<Manager> managerProvider;
|
||||
late final StreamSubscription<List<Transaction>> _subscription;
|
||||
late final QueryBuilder<Transaction, Transaction, QAfterSortBy> _query;
|
||||
|
||||
BorderRadius get _borderRadiusFirst {
|
||||
return BorderRadius.only(
|
||||
|
@ -80,17 +81,13 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
Transaction tx,
|
||||
BorderRadius? radius,
|
||||
Coin coin,
|
||||
int chainHeight,
|
||||
) {
|
||||
final matchingTrades = ref
|
||||
.read(tradesServiceProvider)
|
||||
.trades
|
||||
.where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid);
|
||||
|
||||
final isConfirmed = tx.isConfirmed(
|
||||
ref.watch(
|
||||
widget.managerProvider.select((value) => value.currentHeight)),
|
||||
coin.requiredConfirmations);
|
||||
|
||||
if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) {
|
||||
final trade = matchingTrades.first;
|
||||
return Container(
|
||||
|
@ -115,6 +112,8 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
trade.uuid), //
|
||||
trade: trade,
|
||||
onTap: () async {
|
||||
final walletName = ref.read(pWalletName(widget.walletId));
|
||||
|
||||
if (Util.isDesktop) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
|
@ -156,8 +155,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
child: TradeDetailsView(
|
||||
tradeId: trade.tradeId,
|
||||
transactionIfSentFromStack: tx,
|
||||
walletName:
|
||||
ref.read(managerProvider).walletName,
|
||||
walletName: walletName,
|
||||
walletId: widget.walletId,
|
||||
),
|
||||
),
|
||||
|
@ -180,7 +178,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
trade.tradeId,
|
||||
tx,
|
||||
widget.walletId,
|
||||
ref.read(managerProvider).walletName,
|
||||
walletName,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -208,17 +206,39 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
managerProvider = widget.managerProvider;
|
||||
_query = ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.transactions
|
||||
.where()
|
||||
.walletIdEqualTo(widget.walletId)
|
||||
.sortByTimestampDesc();
|
||||
|
||||
_subscription = _query.watch().listen((event) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_transactions2 = event;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final walletInfo = ref.watch(pWallets).getWallet(widget.walletId).info;
|
||||
final height = walletInfo.cachedChainHeight;
|
||||
final coin = walletInfo.coin;
|
||||
|
||||
return FutureBuilder(
|
||||
future: manager.transactions,
|
||||
future: _query.findAll(),
|
||||
builder: (fbContext, AsyncSnapshot<List<Transaction>> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
@ -226,8 +246,8 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
_hasLoaded = true;
|
||||
}
|
||||
if (!_hasLoaded) {
|
||||
return Column(
|
||||
children: const [
|
||||
return const Column(
|
||||
children: [
|
||||
Spacer(),
|
||||
Center(
|
||||
child: LoadingIndicator(
|
||||
|
@ -247,13 +267,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
_transactions2.sort((a, b) => b.timestamp - a.timestamp);
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
//todo: check if print needed
|
||||
// debugPrint("pulled down to refresh on transaction list");
|
||||
final managerProvider =
|
||||
ref.read(pWallets).getManagerProvider(widget.walletId);
|
||||
if (!ref.read(managerProvider).isRefreshing) {
|
||||
unawaited(ref.read(managerProvider).refresh());
|
||||
}
|
||||
await ref.read(pWallets).getWallet(widget.walletId).refresh();
|
||||
},
|
||||
child: Util.isDesktop
|
||||
? ListView.separated(
|
||||
|
@ -270,7 +284,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
radius = _borderRadiusFirst;
|
||||
}
|
||||
final tx = _transactions2[index];
|
||||
return itemBuilder(context, tx, radius, manager.coin);
|
||||
return itemBuilder(context, tx, radius, coin, height);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Container(
|
||||
|
@ -302,14 +316,14 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
|
|||
if (shouldWrap) {
|
||||
return Column(
|
||||
children: [
|
||||
itemBuilder(context, tx, radius, manager.coin),
|
||||
itemBuilder(context, tx, radius, coin, height),
|
||||
const SizedBox(
|
||||
height: WalletView.navBarHeight + 14,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return itemBuilder(context, tx, radius, manager.coin);
|
||||
return itemBuilder(context, tx, radius, coin, height);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
|
@ -11,10 +11,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
|
@ -22,6 +20,7 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
|
||||
enum _BalanceType {
|
||||
available,
|
||||
|
@ -42,11 +41,9 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final maxHeight = MediaQuery.of(context).size.height * 0.60;
|
||||
|
||||
final coin =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final balance = ref
|
||||
.watch(pWallets.select((value) => value.getManager(walletId).balance));
|
||||
Balance balance = ref.watch(pWalletBalance(walletId));
|
||||
|
||||
_BalanceType _bal =
|
||||
ref.watch(walletBalanceToggleStateProvider.state).state ==
|
||||
|
@ -56,13 +53,11 @@ class WalletBalanceToggleSheet extends ConsumerWidget {
|
|||
|
||||
Balance? balanceSecondary;
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
balanceSecondary = ref
|
||||
.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(walletId).wallet as FiroWallet?,
|
||||
),
|
||||
)
|
||||
?.balancePrivate;
|
||||
balanceSecondary = ref.watch(pWalletBalanceSecondary(walletId));
|
||||
|
||||
final temp = balance;
|
||||
balance = balanceSecondary!;
|
||||
balanceSecondary = temp;
|
||||
|
||||
if (ref.watch(publicPrivateBalanceStateProvider.state).state ==
|
||||
"Private") {
|
||||
|
|
|
@ -133,15 +133,11 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton> {
|
|||
splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
||||
onPressed: () {
|
||||
if (widget.tokenContractAddress == null) {
|
||||
final managerProvider =
|
||||
ref.read(pWallets).getManagerProvider(widget.walletId);
|
||||
final isRefreshing = ref.read(managerProvider).isRefreshing;
|
||||
final wallet = ref.read(pWallets).getWallet(widget.walletId);
|
||||
final isRefreshing = wallet.refreshMutex.isLocked;
|
||||
if (!isRefreshing) {
|
||||
_spinController.repeat?.call();
|
||||
ref
|
||||
.read(managerProvider)
|
||||
.refresh()
|
||||
.then((_) => _spinController.stop?.call());
|
||||
wallet.refresh().then((_) => _spinController.stop?.call());
|
||||
}
|
||||
} else {
|
||||
if (!ref.read(tokenServiceProvider)!.isRefreshing) {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
|
@ -20,11 +19,7 @@ import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_refresh_button.
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart';
|
||||
import 'package:stackwallet/services/coins/banano/banano_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/balance_refreshed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -33,9 +28,10 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
|
||||
class WalletSummaryInfo extends ConsumerStatefulWidget {
|
||||
class WalletSummaryInfo extends ConsumerWidget {
|
||||
const WalletSummaryInfo({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
|
@ -45,16 +41,7 @@ class WalletSummaryInfo extends ConsumerStatefulWidget {
|
|||
final String walletId;
|
||||
final WalletSyncStatus initialSyncStatus;
|
||||
|
||||
@override
|
||||
ConsumerState<WalletSummaryInfo> createState() => _WalletSummaryInfoState();
|
||||
}
|
||||
|
||||
class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
||||
late StreamSubscription<BalanceRefreshedEvent> _balanceUpdated;
|
||||
|
||||
String receivingAddress = "";
|
||||
|
||||
void showSheet() {
|
||||
void showSheet(BuildContext context) {
|
||||
showModalBottomSheet<dynamic>(
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
|
@ -63,54 +50,22 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
|||
top: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
builder: (_) => WalletBalanceToggleSheet(walletId: widget.walletId),
|
||||
builder: (_) => WalletBalanceToggleSheet(walletId: walletId),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_balanceUpdated =
|
||||
GlobalEventBus.instance.on<BalanceRefreshedEvent>().listen(
|
||||
(event) async {
|
||||
if (event.walletId == widget.walletId) {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// managerProvider = widget.managerProvider;
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final address = await ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.currentReceivingAddress;
|
||||
setState(() {
|
||||
receivingAddress = address;
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_balanceUpdated.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
bool isMonkey = true;
|
||||
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final receivingAddress = ref.watch(pWalletReceivingAddress(walletId));
|
||||
|
||||
final externalCalls = ref.watch(
|
||||
prefsChangeNotifierProvider.select((value) => value.externalCalls));
|
||||
final coin = manager.coin;
|
||||
final balance = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).balance));
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
final balance = ref.watch(pWalletBalance(walletId));
|
||||
|
||||
final locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
@ -132,10 +87,9 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
|||
final _showPrivate =
|
||||
ref.watch(publicPrivateBalanceStateProvider.state).state == "Private";
|
||||
|
||||
final firoWallet = ref.watch(pWallets.select(
|
||||
(value) => value.getManager(widget.walletId).wallet)) as FiroWallet;
|
||||
final secondaryBal = ref.watch(pWalletBalanceSecondary(walletId));
|
||||
|
||||
final bal = _showPrivate ? firoWallet.balancePrivate : firoWallet.balance;
|
||||
final bal = _showPrivate ? balance : secondaryBal;
|
||||
|
||||
balanceToShow = _showAvailable ? bal.spendable : bal.total;
|
||||
title = _showAvailable ? "Available" : "Full";
|
||||
|
@ -148,7 +102,8 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
|||
List<int>? imageBytes;
|
||||
|
||||
if (coin == Coin.banano) {
|
||||
imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
||||
// TODO: [prio=high] fix this and uncomment:
|
||||
// imageBytes = (manager.wallet as BananoWallet).getMonkeyImageBytes();
|
||||
}
|
||||
|
||||
return ConditionalParent(
|
||||
|
@ -171,7 +126,9 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: showSheet,
|
||||
onTap: () {
|
||||
showSheet(context);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
|
@ -236,8 +193,8 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
|
|||
),
|
||||
const Spacer(),
|
||||
WalletRefreshButton(
|
||||
walletId: widget.walletId,
|
||||
initialSyncStatus: widget.initialSyncStatus,
|
||||
walletId: walletId,
|
||||
initialSyncStatus: initialSyncStatus,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'dart:async';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/models/isar/models/contact_entry.dart';
|
||||
import 'package:stackwallet/models/transaction_filter.dart';
|
||||
|
@ -21,6 +22,7 @@ import 'package:stackwallet/pages/token_view/token_view.dart';
|
|||
import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||
|
@ -33,6 +35,7 @@ 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/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
|
@ -307,7 +310,7 @@ class _TransactionDetailsViewState extends ConsumerState<AllTransactionsView> {
|
|||
Navigator.of(context).pushNamed(
|
||||
TransactionSearchFilterView.routeName,
|
||||
arguments:
|
||||
ref.read(pWallets).getManager(walletId).coin,
|
||||
ref.read(pWallets).getWallet(walletId).info.coin,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -422,7 +425,7 @@ class _TransactionDetailsViewState extends ConsumerState<AllTransactionsView> {
|
|||
),
|
||||
onPressed: () {
|
||||
final coin =
|
||||
ref.read(pWallets).getManager(walletId).coin;
|
||||
ref.read(pWallets).getWallet(walletId).info.coin;
|
||||
if (isDesktop) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
|
@ -465,21 +468,44 @@ class _TransactionDetailsViewState extends ConsumerState<AllTransactionsView> {
|
|||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final managerProvider = ref.watch(pWallets
|
||||
.select((value) => value.getManagerProvider(walletId)));
|
||||
|
||||
final criteria =
|
||||
ref.watch(transactionFilterProvider.state).state;
|
||||
|
||||
//todo: check if print needed
|
||||
// debugPrint("Consumer build called");
|
||||
|
||||
final WhereClause ww;
|
||||
|
||||
return FutureBuilder(
|
||||
future: widget.isTokens
|
||||
? ref.watch(tokenServiceProvider
|
||||
.select((value) => value!.transactions))
|
||||
: ref.watch(managerProvider
|
||||
.select((value) => value.transactions)),
|
||||
? ref
|
||||
.watch(mainDBProvider)
|
||||
.getTransactions(walletId)
|
||||
.filter()
|
||||
.otherDataEqualTo(ref
|
||||
.watch(tokenServiceProvider)!
|
||||
.tokenContract
|
||||
.address)
|
||||
.sortByTimestampDesc()
|
||||
.findAll()
|
||||
: ref.watch(mainDBProvider).isar.transactions.buildQuery<
|
||||
Transaction>(
|
||||
whereClauses: [
|
||||
IndexWhereClause.equalTo(
|
||||
indexName: 'walletId',
|
||||
value: [widget.walletId],
|
||||
)
|
||||
],
|
||||
// TODO: [prio=high] add filters to wallet or cryptocurrency class
|
||||
// filter: [
|
||||
// // todo
|
||||
// ],
|
||||
sortBy: [
|
||||
const SortProperty(
|
||||
property: "timestamp",
|
||||
sort: Sort.desc,
|
||||
),
|
||||
]).findAll(),
|
||||
builder: (_, AsyncSnapshot<List<Transaction>> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
@ -851,13 +877,11 @@ class _DesktopTransactionCardRowState
|
|||
Widget build(BuildContext context) {
|
||||
final locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
final manager =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId)));
|
||||
|
||||
final baseCurrency = ref
|
||||
.watch(prefsChangeNotifierProvider.select((value) => value.currency));
|
||||
|
||||
final coin = manager.coin;
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final price = ref
|
||||
.watch(priceAnd24hChangeNotifierProvider
|
||||
|
@ -877,8 +901,7 @@ class _DesktopTransactionCardRowState
|
|||
prefix = "";
|
||||
}
|
||||
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
|
|
|
@ -39,6 +39,7 @@ import 'package:stackwallet/utilities/format.dart';
|
|||
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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -355,8 +356,7 @@ class _TransactionDetailsViewState
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
|
@ -1597,10 +1597,10 @@ class _TransactionDetailsViewState
|
|||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
final Manager manager =
|
||||
ref.read(pWallets).getManager(walletId);
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(walletId);
|
||||
|
||||
if (manager.wallet is EpicCashWallet) {
|
||||
if (wallet is EpicCashWallet) {
|
||||
final String? id = _transaction.slateId;
|
||||
if (id == null) {
|
||||
unawaited(showFloatingFlushBar(
|
||||
|
@ -1618,7 +1618,7 @@ class _TransactionDetailsViewState
|
|||
const CancellingTransactionProgressDialog(),
|
||||
));
|
||||
|
||||
final result = await (manager.wallet as EpicCashWallet)
|
||||
final result = await (wallet as EpicCashWallet)
|
||||
.cancelPendingTransactionAndPost(id);
|
||||
if (mounted) {
|
||||
// pop progress dialog
|
||||
|
@ -1630,7 +1630,7 @@ class _TransactionDetailsViewState
|
|||
builder: (_) => StackOkDialog(
|
||||
title: "Transaction cancelled",
|
||||
onOkPressed: (_) {
|
||||
manager.refresh();
|
||||
wallet.refresh();
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
WalletView.routeName));
|
||||
|
|
|
@ -35,6 +35,7 @@ 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/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
|
@ -308,8 +309,7 @@ class _AllTransactionsV2ViewState extends ConsumerState<AllTransactionsV2View> {
|
|||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
TransactionSearchFilterView.routeName,
|
||||
arguments:
|
||||
ref.read(pWallets).getManager(walletId).coin,
|
||||
arguments: ref.read(pWalletCoin(walletId)),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -423,21 +423,19 @@ class _AllTransactionsV2ViewState extends ConsumerState<AllTransactionsV2View> {
|
|||
height: 20,
|
||||
),
|
||||
onPressed: () {
|
||||
final coin =
|
||||
ref.read(pWallets).getManager(walletId).coin;
|
||||
if (isDesktop) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return TransactionSearchFilterView(
|
||||
coin: coin,
|
||||
coin: ref.read(pWalletCoin(walletId)),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(
|
||||
TransactionSearchFilterView.routeName,
|
||||
arguments: coin,
|
||||
arguments: ref.read(pWalletCoin(walletId)),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -467,9 +465,6 @@ class _AllTransactionsV2ViewState extends ConsumerState<AllTransactionsV2View> {
|
|||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final managerProvider = ref.watch(pWallets
|
||||
.select((value) => value.getManagerProvider(walletId)));
|
||||
|
||||
final criteria =
|
||||
ref.watch(transactionFilterProvider.state).state;
|
||||
|
||||
|
@ -481,10 +476,23 @@ class _AllTransactionsV2ViewState extends ConsumerState<AllTransactionsV2View> {
|
|||
.watch(mainDBProvider)
|
||||
.isar
|
||||
.transactionV2s
|
||||
.where()
|
||||
.walletIdEqualTo(walletId)
|
||||
.sortByTimestampDesc()
|
||||
.findAll(),
|
||||
.buildQuery<TransactionV2>(
|
||||
whereClauses: [
|
||||
IndexWhereClause.equalTo(
|
||||
indexName: 'walletId',
|
||||
value: [widget.walletId],
|
||||
)
|
||||
],
|
||||
// TODO: [prio=high] add filters to wallet or cryptocurrency class
|
||||
// filter: [
|
||||
// // todo
|
||||
// ],
|
||||
sortBy: [
|
||||
const SortProperty(
|
||||
property: "timestamp",
|
||||
sort: Sort.desc,
|
||||
),
|
||||
]).findAll(),
|
||||
builder: (_, AsyncSnapshot<List<TransactionV2>> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
|
@ -852,13 +860,11 @@ class _DesktopTransactionCardRowState
|
|||
Widget build(BuildContext context) {
|
||||
final locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
final manager =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId)));
|
||||
|
||||
final baseCurrency = ref
|
||||
.watch(prefsChangeNotifierProvider.select((value) => value.currency));
|
||||
|
||||
final coin = manager.coin;
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final price = ref
|
||||
.watch(priceAnd24hChangeNotifierProvider
|
||||
|
@ -878,8 +884,7 @@ class _DesktopTransactionCardRowState
|
|||
prefix = "";
|
||||
}
|
||||
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
final Amount amount;
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.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/widgets/desktop/desktop_dialog.dart';
|
||||
|
||||
class FusionTxGroup {
|
||||
|
@ -27,11 +27,9 @@ class FusionTxGroupCard extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final walletId = group.transactions.first.walletId;
|
||||
|
||||
final coin =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
|
|
|
@ -9,7 +9,6 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transactio
|
|||
import 'package:stackwallet/providers/global/locale_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/providers/global/price_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
|
@ -18,6 +17,7 @@ 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/widgets/desktop/desktop_dialog.dart';
|
||||
|
||||
class TransactionCardV2 extends ConsumerStatefulWidget {
|
||||
|
@ -96,7 +96,7 @@ class _TransactionCardStateV2 extends ConsumerState<TransactionCardV2> {
|
|||
} else {
|
||||
prefix = "";
|
||||
}
|
||||
coin = ref.read(pWallets).getManager(walletId).coin;
|
||||
coin = ref.read(pWalletCoin(walletId));
|
||||
|
||||
unit = coin.ticker;
|
||||
super.initState();
|
||||
|
@ -115,8 +115,7 @@ class _TransactionCardStateV2 extends ConsumerState<TransactionCardV2> {
|
|||
.select((value) => value.getPrice(coin)))
|
||||
.item1;
|
||||
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
final Amount amount;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import 'package:stackwallet/utilities/format.dart';
|
|||
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/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -397,8 +398,7 @@ class _TransactionV2DetailsViewState
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currentHeight = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).currentHeight));
|
||||
final currentHeight = ref.watch(pWalletChainHeight(walletId));
|
||||
|
||||
final String outputLabel;
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
@ -66,8 +64,7 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final coin = ref.watch(pWallets).getWallet(widget.walletId).info.coin;
|
||||
|
||||
return FutureBuilder(
|
||||
future: ref
|
||||
|
@ -145,11 +142,7 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
final managerProvider =
|
||||
ref.read(pWallets).getManagerProvider(widget.walletId);
|
||||
if (!ref.read(managerProvider).isRefreshing) {
|
||||
unawaited(ref.read(managerProvider).refresh());
|
||||
}
|
||||
await ref.read(pWallets).getWallet(widget.walletId).refresh();
|
||||
},
|
||||
child: Util.isDesktop
|
||||
? ListView.separated(
|
||||
|
@ -168,7 +161,7 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
final tx = _txns[index];
|
||||
return TxListItem(
|
||||
tx: tx,
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
radius: radius,
|
||||
);
|
||||
},
|
||||
|
@ -204,7 +197,7 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
children: [
|
||||
TxListItem(
|
||||
tx: tx,
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
radius: radius,
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -215,7 +208,7 @@ class _TransactionsV2ListState extends ConsumerState<TransactionsV2List> {
|
|||
} else {
|
||||
return TxListItem(
|
||||
tx: tx,
|
||||
coin: manager.coin,
|
||||
coin: coin,
|
||||
radius: radius,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
|||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/trade_card.dart';
|
||||
|
@ -103,16 +103,11 @@ class TxListItem extends ConsumerWidget {
|
|||
Flexible(
|
||||
child: TradeDetailsView(
|
||||
tradeId: trade.tradeId,
|
||||
// TODO
|
||||
// TODO: [prio:med]
|
||||
// transactionIfSentFromStack: tx,
|
||||
transactionIfSentFromStack: null,
|
||||
walletName: ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value
|
||||
.getManager(_tx.walletId)
|
||||
.walletName,
|
||||
),
|
||||
),
|
||||
walletName: ref
|
||||
.watch(pWalletName(_tx.walletId)),
|
||||
walletId: _tx.walletId,
|
||||
),
|
||||
),
|
||||
|
@ -135,10 +130,7 @@ class TxListItem extends ConsumerWidget {
|
|||
trade.tradeId,
|
||||
_tx,
|
||||
_tx.walletId,
|
||||
ref
|
||||
.read(pWallets)
|
||||
.getManager(_tx.walletId)
|
||||
.walletName,
|
||||
ref.read(pWalletName(_tx.walletId)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -39,6 +39,7 @@ import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_summary.dart';
|
|||
import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
|
@ -48,11 +49,13 @@ import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.da
|
|||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||
import 'package:stackwallet/services/mixins/coin_control_interface.dart';
|
||||
import 'package:stackwallet/services/mixins/fusion_wallet_interface.dart';
|
||||
import 'package:stackwallet/services/mixins/ordinals_interface.dart';
|
||||
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
|
@ -67,6 +70,7 @@ import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.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';
|
||||
|
@ -94,7 +98,6 @@ class WalletView extends ConsumerStatefulWidget {
|
|||
const WalletView({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
required this.managerProvider,
|
||||
this.eventBus,
|
||||
this.clipboardInterface = const ClipboardWrapper(),
|
||||
}) : super(key: key);
|
||||
|
@ -103,7 +106,6 @@ class WalletView extends ConsumerStatefulWidget {
|
|||
static const double navBarHeight = 65.0;
|
||||
|
||||
final String walletId;
|
||||
final ChangeNotifierProvider<Manager> managerProvider;
|
||||
final EventBus? eventBus;
|
||||
|
||||
final ClipboardInterface clipboardInterface;
|
||||
|
@ -115,7 +117,7 @@ class WalletView extends ConsumerStatefulWidget {
|
|||
class _WalletViewState extends ConsumerState<WalletView> {
|
||||
late final EventBus eventBus;
|
||||
late final String walletId;
|
||||
late final ChangeNotifierProvider<Manager> managerProvider;
|
||||
late final Coin coin;
|
||||
|
||||
late final bool _shouldDisableAutoSyncOnLogOut;
|
||||
|
||||
|
@ -129,7 +131,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
bool _lelantusRescanRecovery = false;
|
||||
|
||||
Future<void> _firoRescanRecovery() async {
|
||||
final success = await (ref.read(managerProvider).wallet as FiroWallet)
|
||||
final success = await (ref.read(pWallets).getWallet(walletId) as FiroWallet)
|
||||
.firoRescanRecovery();
|
||||
|
||||
if (success) {
|
||||
|
@ -160,43 +162,45 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
@override
|
||||
void initState() {
|
||||
walletId = widget.walletId;
|
||||
managerProvider = widget.managerProvider;
|
||||
final wallet = ref.read(pWallets).getWallet(walletId);
|
||||
coin = wallet.info.coin;
|
||||
|
||||
ref.read(managerProvider).isActiveWallet = true;
|
||||
if (!ref.read(managerProvider).shouldAutoSync) {
|
||||
ref.read(currentWalletIdProvider.notifier).state = wallet.walletId;
|
||||
|
||||
if (!wallet.shouldAutoSync) {
|
||||
// enable auto sync if it wasn't enabled when loading wallet
|
||||
ref.read(managerProvider).shouldAutoSync = true;
|
||||
wallet.shouldAutoSync = true;
|
||||
_shouldDisableAutoSyncOnLogOut = true;
|
||||
} else {
|
||||
_shouldDisableAutoSyncOnLogOut = false;
|
||||
}
|
||||
|
||||
if (ref.read(managerProvider).coin == Coin.firo &&
|
||||
(ref.read(managerProvider).wallet as FiroWallet)
|
||||
.lelantusCoinIsarRescanRequired) {
|
||||
if (coin == Coin.firo &&
|
||||
(wallet as FiroWallet).lelantusCoinIsarRescanRequired) {
|
||||
_rescanningOnOpen = true;
|
||||
_lelantusRescanRecovery = true;
|
||||
_firoRescanRecovery();
|
||||
} else if (ref.read(managerProvider).rescanOnOpenVersion ==
|
||||
Constants.rescanV1) {
|
||||
_rescanningOnOpen = true;
|
||||
ref.read(managerProvider).fullRescan(20, 1000).then(
|
||||
(_) => ref.read(managerProvider).resetRescanOnOpen().then(
|
||||
(_) => WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => setState(() => _rescanningOnOpen = false),
|
||||
),
|
||||
),
|
||||
);
|
||||
// } else if (ref.read(managerProvider).rescanOnOpenVersion ==
|
||||
// TODO: [prio=high]
|
||||
// Constants.rescanV1) {
|
||||
// _rescanningOnOpen = true;
|
||||
// ref.read(managerProvider).fullRescan(20, 1000).then(
|
||||
// (_) => ref.read(managerProvider).resetRescanOnOpen().then(
|
||||
// (_) => WidgetsBinding.instance.addPostFrameCallback(
|
||||
// (_) => setState(() => _rescanningOnOpen = false),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
} else {
|
||||
ref.read(managerProvider).refresh();
|
||||
wallet.refresh();
|
||||
}
|
||||
|
||||
if (ref.read(managerProvider).isRefreshing) {
|
||||
if (wallet.refreshMutex.isLocked) {
|
||||
_currentSyncStatus = WalletSyncStatus.syncing;
|
||||
_currentNodeStatus = NodeConnectionStatus.connected;
|
||||
} else {
|
||||
_currentSyncStatus = WalletSyncStatus.synced;
|
||||
if (ref.read(managerProvider).isConnected) {
|
||||
if (wallet.isConnected) {
|
||||
_currentNodeStatus = NodeConnectionStatus.connected;
|
||||
} else {
|
||||
_currentNodeStatus = NodeConnectionStatus.disconnected;
|
||||
|
@ -290,9 +294,10 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
void _logout() async {
|
||||
if (_shouldDisableAutoSyncOnLogOut) {
|
||||
// disable auto sync if it was enabled only when loading wallet
|
||||
ref.read(managerProvider).shouldAutoSync = false;
|
||||
ref.read(pWallets).getWallet(walletId).shouldAutoSync = false;
|
||||
}
|
||||
ref.read(managerProvider.notifier).isActiveWallet = false;
|
||||
|
||||
ref.read(currentWalletIdProvider.notifier).state = null;
|
||||
ref.read(transactionFilterProvider.state).state = null;
|
||||
if (ref.read(prefsChangeNotifierProvider).isAutoBackupEnabled &&
|
||||
ref.read(prefsChangeNotifierProvider).backupFrequencyType ==
|
||||
|
@ -328,7 +333,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
}
|
||||
|
||||
void _onExchangePressed(BuildContext context) async {
|
||||
final Coin coin = ref.read(managerProvider).coin;
|
||||
final Coin coin = ref.read(pWalletCoin(walletId));
|
||||
|
||||
if (coin.isTestNet) {
|
||||
await showDialog<void>(
|
||||
|
@ -373,7 +378,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
}
|
||||
|
||||
void _onBuyPressed(BuildContext context) async {
|
||||
final coin = ref.read(managerProvider).coin;
|
||||
final Coin coin = ref.read(pWalletCoin(walletId));
|
||||
|
||||
if (coin.isTestNet) {
|
||||
await showDialog<void>(
|
||||
|
@ -408,7 +413,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
),
|
||||
),
|
||||
);
|
||||
final firoWallet = ref.read(managerProvider).wallet as FiroWallet;
|
||||
final firoWallet = ref.read(pWallets).getWallet(walletId) as FiroWallet;
|
||||
|
||||
final Amount publicBalance = firoWallet.availablePublicBalance();
|
||||
if (publicBalance <= Amount.zero) {
|
||||
|
@ -464,7 +469,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final Coin coin = ref.watch(managerProvider.select((value) => value.coin));
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
|
||||
return ConditionalParent(
|
||||
condition: _rescanningOnOpen,
|
||||
|
@ -549,8 +554,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
ref.watch(managerProvider
|
||||
.select((value) => value.walletName)),
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.navBarTitle(context),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
@ -721,7 +725,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
WalletSettingsView.routeName,
|
||||
arguments: Tuple4(
|
||||
walletId,
|
||||
ref.read(managerProvider).coin,
|
||||
coin,
|
||||
_currentSyncStatus,
|
||||
_currentNodeStatus,
|
||||
),
|
||||
|
@ -747,8 +751,11 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
child: WalletSummary(
|
||||
walletId: walletId,
|
||||
aspectRatio: 1.75,
|
||||
initialSyncStatus: ref.watch(managerProvider
|
||||
.select((value) => value.isRefreshing))
|
||||
initialSyncStatus: ref
|
||||
.watch(pWallets)
|
||||
.getWallet(walletId)
|
||||
.refreshMutex
|
||||
.isLocked
|
||||
? WalletSyncStatus.syncing
|
||||
: WalletSyncStatus.synced,
|
||||
),
|
||||
|
@ -907,8 +914,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
walletId: widget.walletId,
|
||||
)
|
||||
: TransactionsList(
|
||||
managerProvider:
|
||||
managerProvider,
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
|
@ -944,8 +949,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
label: "Send",
|
||||
icon: const SendNavIcon(),
|
||||
onTap: () {
|
||||
final walletId = ref.read(managerProvider).walletId;
|
||||
final coin = ref.read(managerProvider).coin;
|
||||
switch (ref
|
||||
.read(walletBalanceToggleStateProvider.state)
|
||||
.state) {
|
||||
|
@ -985,8 +988,10 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
moreItems: [
|
||||
if (ref.watch(
|
||||
pWallets.select(
|
||||
(value) =>
|
||||
value.getManager(widget.walletId).hasTokenSupport,
|
||||
(value) => value
|
||||
.getWallet(widget.walletId)
|
||||
.cryptoCurrency
|
||||
.hasTokenSupport,
|
||||
),
|
||||
))
|
||||
WalletNavigationBarItemData(
|
||||
|
@ -1018,9 +1023,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
}),
|
||||
if (ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value
|
||||
.getManager(widget.walletId)
|
||||
.hasCoinControlSupport,
|
||||
(value) => value.getWallet(widget.walletId)
|
||||
is CoinControlInterface,
|
||||
),
|
||||
) &&
|
||||
ref.watch(
|
||||
|
@ -1041,8 +1045,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
);
|
||||
},
|
||||
),
|
||||
if (ref.watch(pWallets.select((value) =>
|
||||
value.getManager(widget.walletId).hasPaynymSupport)))
|
||||
if (ref.watch(pWallets.select((value) => value
|
||||
.getWallet(widget.walletId) is PaynymWalletInterface)))
|
||||
WalletNavigationBarItemData(
|
||||
label: "PayNym",
|
||||
icon: const PaynymNavIcon(),
|
||||
|
@ -1056,12 +1060,10 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
),
|
||||
);
|
||||
|
||||
final manager = ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId);
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId);
|
||||
|
||||
final paynymInterface =
|
||||
manager.wallet as PaynymWalletInterface;
|
||||
final paynymInterface = wallet as PaynymWalletInterface;
|
||||
|
||||
final code = await paynymInterface.getPaymentCode(
|
||||
isSegwit: false,
|
||||
|
@ -1102,7 +1104,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
if (ref.watch(
|
||||
pWallets.select(
|
||||
(value) =>
|
||||
value.getManager(widget.walletId).hasOrdinalsSupport,
|
||||
value.getWallet(widget.walletId) is OrdinalsInterface,
|
||||
),
|
||||
))
|
||||
WalletNavigationBarItemData(
|
||||
|
@ -1117,8 +1119,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
|||
),
|
||||
if (ref.watch(
|
||||
pWallets.select(
|
||||
(value) =>
|
||||
value.getManager(widget.walletId).hasFusionSupport,
|
||||
(value) => value.getWallet(widget.walletId)
|
||||
is FusionWalletInterface,
|
||||
),
|
||||
))
|
||||
WalletNavigationBarItemData(
|
||||
|
|
|
@ -48,14 +48,13 @@ class AllWallets extends StatelessWidget {
|
|||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (_, ref, __) {
|
||||
final providersByCoin = ref.watch(pWallets
|
||||
.select((value) => value.getManagerProvidersByCoin()));
|
||||
final walletsByCoin = ref.watch(pWallets).walletsByCoin;
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: providersByCoin.length,
|
||||
itemCount: walletsByCoin.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final coin = providersByCoin[index].item1;
|
||||
final int walletCount = providersByCoin[index].item2.length;
|
||||
final coin = walletsByCoin[index].coin;
|
||||
final int walletCount = walletsByCoin[index].wallets.length;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: WalletListItem(
|
||||
|
|
|
@ -16,7 +16,6 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -25,9 +24,9 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.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/widgets/coin_card.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class FavoriteCard extends ConsumerStatefulWidget {
|
||||
const FavoriteCard({
|
||||
|
@ -59,9 +58,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(walletId).coin),
|
||||
);
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
final externalCalls = ref.watch(
|
||||
prefsChangeNotifierProvider.select((value) => value.externalCalls),
|
||||
);
|
||||
|
@ -116,7 +113,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
await ref.read(pWallets).getManager(walletId).initializeExisting();
|
||||
await ref.read(pWallets).getWallet(walletId).init();
|
||||
}
|
||||
if (mounted) {
|
||||
if (Util.isDesktop) {
|
||||
|
@ -127,10 +124,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
} else {
|
||||
await Navigator.of(context).pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
walletId,
|
||||
ref.read(pWallets).getManagerProvider(walletId),
|
||||
),
|
||||
arguments: walletId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -157,12 +151,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
ref.watch(
|
||||
pWallets.select(
|
||||
(value) =>
|
||||
value.getManager(walletId).walletName,
|
||||
),
|
||||
),
|
||||
ref.watch(pWalletName(walletId)),
|
||||
style: STextStyles.itemSubtitle12(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
@ -184,22 +173,16 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
|
|||
Builder(
|
||||
builder: (context) {
|
||||
final balance = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManager(walletId).balance,
|
||||
),
|
||||
pWalletBalance(walletId),
|
||||
);
|
||||
|
||||
Amount total = balance.total;
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
final balancePrivate = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => (value.getManager(walletId).wallet
|
||||
as FiroWallet)
|
||||
.balancePrivate,
|
||||
),
|
||||
);
|
||||
|
||||
total += balancePrivate.total;
|
||||
total += ref
|
||||
.watch(
|
||||
pWalletBalanceSecondary(walletId),
|
||||
)
|
||||
.total;
|
||||
}
|
||||
|
||||
Amount fiatTotal = Amount.zero;
|
||||
|
|
|
@ -15,12 +15,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart';
|
||||
import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_card.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/favourite_wallets_provider.dart';
|
||||
import 'package:stackwallet/widgets/custom_page_view/custom_page_view.dart'
|
||||
as cpv;
|
||||
|
||||
|
@ -74,10 +73,10 @@ class _FavoriteWalletsState extends ConsumerState<FavoriteWallets> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final favorites = ref.watch(favoritesProvider);
|
||||
final favorites = ref.watch(pFavouriteWalletInfos);
|
||||
_favLength = favorites.length;
|
||||
|
||||
bool hasFavorites = favorites.length > 0;
|
||||
bool hasFavorites = favorites.isNotEmpty;
|
||||
|
||||
final remaining = ((screenWidth - cardWidth) / cardWidth).ceil();
|
||||
|
||||
|
@ -192,12 +191,9 @@ class _FavoriteWalletsState extends ConsumerState<FavoriteWallets> {
|
|||
}),
|
||||
itemBuilder: (_, index) {
|
||||
String? walletId;
|
||||
ChangeNotifierProvider<Manager>? managerProvider;
|
||||
|
||||
if (index < favorites.length) {
|
||||
walletId = ref.read(favorites[index]).walletId;
|
||||
managerProvider =
|
||||
ref.read(pWallets).getManagerProvider(walletId);
|
||||
walletId = favorites[index].walletId;
|
||||
}
|
||||
|
||||
const double scaleDown = 0.95;
|
||||
|
|
|
@ -24,7 +24,6 @@ import 'package:stackwallet/utilities/constants.dart';
|
|||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class WalletListItem extends ConsumerWidget {
|
||||
const WalletListItem({
|
||||
|
@ -57,25 +56,18 @@ class WalletListItem extends ConsumerWidget {
|
|||
),
|
||||
onPressed: () async {
|
||||
if (walletCount == 1 && coin != Coin.ethereum) {
|
||||
final providersByCoin = ref
|
||||
.watch(pWallets
|
||||
.select((value) => value.getManagerProvidersByCoin()))
|
||||
.where((e) => e.item1 == coin)
|
||||
.map((e) => e.item2)
|
||||
.expand((e) => e)
|
||||
.toList();
|
||||
final manager = ref.read(providersByCoin.first);
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
.firstWhere((e) => e.info.coin == coin);
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
await wallet.init();
|
||||
}
|
||||
if (context.mounted) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
manager.walletId,
|
||||
providersByCoin.first,
|
||||
),
|
||||
arguments: wallet.walletId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/coin_entity.dart';
|
||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
|
@ -18,13 +19,14 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/dialogs/desktop
|
|||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.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/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
|
||||
import 'package:stackwallet/wallets/wallet/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';
|
||||
|
@ -60,22 +62,22 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
|
||||
String _searchString = "";
|
||||
|
||||
final List<Tuple2<Manager, List<EthContract>>> wallets = [];
|
||||
final List<Tuple2<Wallet, List<EthContract>>> wallets = [];
|
||||
|
||||
List<Tuple2<Manager, List<EthContract>>> _filter(String searchTerm) {
|
||||
List<Tuple2<Wallet, List<EthContract>>> _filter(String searchTerm) {
|
||||
if (searchTerm.isEmpty) {
|
||||
return wallets;
|
||||
}
|
||||
|
||||
final List<Tuple2<Manager, List<EthContract>>> results = [];
|
||||
final List<Tuple2<Wallet, List<EthContract>>> results = [];
|
||||
final term = searchTerm.toLowerCase();
|
||||
|
||||
for (final tuple in wallets) {
|
||||
bool includeManager = false;
|
||||
// search wallet name and total balance
|
||||
includeManager |= _elementContains(tuple.item1.walletName, term);
|
||||
includeManager |= _elementContains(tuple.item1.info.name, term);
|
||||
includeManager |= _elementContains(
|
||||
tuple.item1.balance.total.decimal.toString(),
|
||||
tuple.item1.info.cachedBalance.total.decimal.toString(),
|
||||
term,
|
||||
);
|
||||
|
||||
|
@ -111,15 +113,15 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
searchFieldFocusNode = FocusNode();
|
||||
|
||||
final walletsData =
|
||||
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
||||
walletsData.removeWhere((key, value) => value.coin != widget.coin);
|
||||
ref.read(mainDBProvider).isar.walletInfo.where().findAllSync();
|
||||
walletsData.removeWhere((e) => e.coin != widget.coin);
|
||||
|
||||
if (widget.coin == Coin.ethereum) {
|
||||
for (final data in walletsData.values) {
|
||||
for (final data in walletsData) {
|
||||
final List<EthContract> contracts = [];
|
||||
final manager = ref.read(pWallets).getManager(data.walletId);
|
||||
final contractAddresses = (manager.wallet as EthereumWallet)
|
||||
.getWalletTokenContractAddresses();
|
||||
final wallet = ref.read(pWallets).getWallet(data.walletId);
|
||||
final contractAddresses =
|
||||
(wallet as EthereumWallet).getWalletTokenContractAddresses();
|
||||
|
||||
// fetch each contract
|
||||
for (final contractAddress in contractAddresses) {
|
||||
|
@ -140,7 +142,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
// add tuple to list
|
||||
wallets.add(
|
||||
Tuple2(
|
||||
ref.read(pWallets).getManager(
|
||||
ref.read(pWallets).getWallet(
|
||||
data.walletId,
|
||||
),
|
||||
contracts,
|
||||
|
@ -149,10 +151,10 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
}
|
||||
} else {
|
||||
// add non token wallet tuple to list
|
||||
for (final data in walletsData.values) {
|
||||
for (final data in walletsData) {
|
||||
wallets.add(
|
||||
Tuple2(
|
||||
ref.read(pWallets).getManager(
|
||||
ref.read(pWallets).getWallet(
|
||||
data.walletId,
|
||||
),
|
||||
[],
|
||||
|
@ -290,11 +292,11 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
itemBuilder: (_, index) {
|
||||
final element = data[index];
|
||||
|
||||
if (element.item1.hasTokenSupport) {
|
||||
if (element.item1.cryptoCurrency.hasTokenSupport) {
|
||||
if (isDesktop) {
|
||||
return DesktopExpandingWalletCard(
|
||||
key: Key(
|
||||
"${element.item1.walletName}_${element.item2.map((e) => e.address).join()}"),
|
||||
"${element.item1.info.name}_${element.item2.map((e) => e.address).join()}"),
|
||||
data: element,
|
||||
navigatorState: widget.navigatorState!,
|
||||
);
|
||||
|
|
|
@ -111,14 +111,14 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
|
|||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
List<ContactAddressEntry> addresses = [];
|
||||
final managers = ref.read(pWallets).managers;
|
||||
for (final manager in managers) {
|
||||
final wallets = ref.read(pWallets).wallets;
|
||||
for (final wallet in wallets) {
|
||||
addresses.add(
|
||||
ContactAddressEntry()
|
||||
..coinName = manager.coin.name
|
||||
..address = await manager.currentReceivingAddress
|
||||
..coinName = wallet.info.coin.name
|
||||
..address = wallet.info.cachedReceivingAddress
|
||||
..label = "Current Receiving"
|
||||
..other = manager.walletName,
|
||||
..other = wallet.info.name,
|
||||
);
|
||||
}
|
||||
final self = ContactEntry(
|
||||
|
|
|
@ -14,16 +14,14 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/contact_entry.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/address_book_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -53,28 +51,30 @@ class DesktopContactDetails extends ConsumerStatefulWidget {
|
|||
class _DesktopContactDetailsState extends ConsumerState<DesktopContactDetails> {
|
||||
List<Tuple2<String, Transaction>> _cachedTransactions = [];
|
||||
|
||||
Future<List<Tuple2<String, Transaction>>> _filteredTransactionsByContact(
|
||||
List<Manager> managers,
|
||||
) async {
|
||||
Future<List<Tuple2<String, Transaction>>>
|
||||
_filteredTransactionsByContact() async {
|
||||
final contact =
|
||||
ref.read(addressBookServiceProvider).getContactById(widget.contactId);
|
||||
|
||||
// TODO: optimise
|
||||
|
||||
List<Tuple2<String, Transaction>> result = [];
|
||||
for (final manager in managers) {
|
||||
final transactions = await MainDB.instance
|
||||
.getTransactions(manager.walletId)
|
||||
.filter()
|
||||
.anyOf(contact.addresses.map((e) => e.address),
|
||||
(q, String e) => q.address((q) => q.valueEqualTo(e)))
|
||||
.sortByTimestampDesc()
|
||||
.findAll();
|
||||
final transactions = await ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.transactions
|
||||
.where()
|
||||
.filter()
|
||||
.anyOf(contact.addresses.map((e) => e.address),
|
||||
(q, String e) => q.address((q) => q.valueEqualTo(e)))
|
||||
.sortByTimestampDesc()
|
||||
.findAll();
|
||||
|
||||
for (final tx in transactions) {
|
||||
result.add(Tuple2(manager.walletId, tx));
|
||||
}
|
||||
List<Tuple2<String, Transaction>> result = [];
|
||||
|
||||
for (final tx in transactions) {
|
||||
result.add(Tuple2(tx.walletId, tx));
|
||||
}
|
||||
|
||||
// sort by date
|
||||
result.sort((a, b) => b.item2.timestamp - a.item2.timestamp);
|
||||
|
||||
|
@ -287,8 +287,7 @@ class _DesktopContactDetailsState extends ConsumerState<DesktopContactDetails> {
|
|||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _filteredTransactionsByContact(
|
||||
ref.watch(pWallets).managers),
|
||||
future: _filteredTransactionsByContact(),
|
||||
builder: (_,
|
||||
AsyncSnapshot<List<Tuple2<String, Transaction>>>
|
||||
snapshot) {
|
||||
|
|
|
@ -16,12 +16,12 @@ import 'package:stackwallet/models/isar/models/isar_models.dart';
|
|||
import 'package:stackwallet/pages/receive_view/addresses/address_card.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.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/widgets/icon_widgets/x_icon.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
|
@ -132,8 +132,7 @@ class _DesktopAddressListState extends ConsumerState<DesktopAddressList> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
final ids = _search(_searchString);
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ class _DesktopCashFusion extends ConsumerState<DesktopCashFusionView> {
|
|||
FusionOption _roundType = FusionOption.continuous;
|
||||
|
||||
Future<void> _startFusion() async {
|
||||
final fusionWallet = ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
as FusionWalletInterface;
|
||||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as FusionWalletInterface;
|
||||
|
||||
try {
|
||||
fusionWallet.uiState = ref.read(
|
||||
|
|
|
@ -119,10 +119,8 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
);
|
||||
|
||||
if (shouldCancel == true && mounted) {
|
||||
final fusionWallet = ref
|
||||
.read(pWallets)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FusionWalletInterface;
|
||||
final fusionWallet = ref.read(pWallets).getWallet(widget.walletId)
|
||||
as FusionWalletInterface;
|
||||
|
||||
await showLoading(
|
||||
whileFuture: Future.wait([
|
||||
|
@ -283,8 +281,8 @@ class _FusionDialogViewState extends ConsumerState<FusionDialogView> {
|
|||
|
||||
/// Fuse again.
|
||||
void _fuseAgain() async {
|
||||
final fusionWallet = ref.read(pWallets).getManager(widget.walletId).wallet
|
||||
as FusionWalletInterface;
|
||||
final fusionWallet =
|
||||
ref.read(pWallets).getWallet(widget.walletId) as FusionWalletInterface;
|
||||
|
||||
final fusionInfo = ref.read(prefsChangeNotifierProvider).fusionServerInfo;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:isar/isar.dart';
|
|||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/coin_control/utxo_row.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
|
@ -25,6 +24,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
|
@ -81,7 +81,7 @@ class _DesktopCoinControlUseDialogState
|
|||
@override
|
||||
void initState() {
|
||||
_searchController = TextEditingController();
|
||||
coin = ref.read(pWallets).getManager(widget.walletId).coin;
|
||||
coin = ref.read(pWalletCoin(widget.walletId));
|
||||
|
||||
for (final utxo in ref.read(desktopUseUTXOs)) {
|
||||
final data = UtxoRowData(utxo.id, true);
|
||||
|
|
|
@ -18,13 +18,13 @@ import 'package:stackwallet/db/isar/main_db.dart';
|
|||
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/coin_control/freeze_button.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/coin_control/utxo_row.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.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/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/dropdown_button.dart';
|
||||
|
@ -71,7 +71,7 @@ class _DesktopCoinControlViewState
|
|||
@override
|
||||
void initState() {
|
||||
_searchController = TextEditingController();
|
||||
coin = ref.read(pWallets).getManager(widget.walletId).coin;
|
||||
coin = ref.read(pWalletCoin(widget.walletId));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,12 @@ import 'package:isar/isar.dart';
|
|||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/pages/coin_control/utxo_details_view.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
|
@ -96,11 +97,7 @@ class _UtxoRowState extends ConsumerState<UtxoRow> {
|
|||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final coin = ref.watch(
|
||||
pWallets.select((value) => value.getManager(widget.walletId).coin));
|
||||
|
||||
final currentChainHeight = ref.watch(pWallets
|
||||
.select((value) => value.getManager(widget.walletId).currentHeight));
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
return StreamBuilder<UTXO?>(
|
||||
stream: stream,
|
||||
|
@ -138,7 +135,7 @@ class _UtxoRowState extends ConsumerState<UtxoRow> {
|
|||
UTXOStatusIcon(
|
||||
blocked: utxo.isBlocked,
|
||||
status: utxo.isConfirmed(
|
||||
currentChainHeight,
|
||||
ref.watch(pWalletChainHeight(widget.walletId)),
|
||||
coin.requiredConfirmations,
|
||||
)
|
||||
? UTXOStatusIconStatus.confirmed
|
||||
|
|
|
@ -24,7 +24,6 @@ import 'package:stackwallet/models/isar/stack_theme.dart';
|
|||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
|
@ -32,6 +31,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/format.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
|
@ -367,8 +367,6 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
|
|||
),
|
||||
onPressed: () async {
|
||||
if (txid != null && walletIds != null && walletIds.isNotEmpty) {
|
||||
final manager = ref.read(pWallets).getManager(walletIds.first);
|
||||
|
||||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
||||
|
@ -378,19 +376,21 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
|
|||
.txidEqualTo(txid)
|
||||
.findFirst();
|
||||
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxHeight: MediaQuery.of(context).size.height - 64,
|
||||
maxWidth: 580,
|
||||
child: TradeDetailsView(
|
||||
tradeId: tradeId,
|
||||
transactionIfSentFromStack: tx,
|
||||
walletName: manager.walletName,
|
||||
walletId: walletIds.first,
|
||||
if (mounted) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => DesktopDialog(
|
||||
maxHeight: MediaQuery.of(context).size.height - 64,
|
||||
maxWidth: 580,
|
||||
child: TradeDetailsView(
|
||||
tradeId: tradeId,
|
||||
transactionIfSentFromStack: tx,
|
||||
walletName: ref.read(pWalletName(walletIds.first)),
|
||||
walletId: walletIds.first,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
|
@ -436,7 +436,8 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
|
|||
child: TradeDetailsView(
|
||||
tradeId: tradeId,
|
||||
transactionIfSentFromStack: tx,
|
||||
walletName: manager.walletName,
|
||||
walletName: ref
|
||||
.read(pWalletName(walletIds.first)),
|
||||
walletId: walletIds.first,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -238,27 +238,24 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
|
|||
if (tuple != null) {
|
||||
if (ref.read(desktopExchangeModelProvider)!.receiveTicker.toLowerCase() ==
|
||||
tuple.item2.ticker.toLowerCase()) {
|
||||
ref
|
||||
_toController.text = ref
|
||||
.read(pWallets)
|
||||
.getManager(tuple.item1)
|
||||
.currentReceivingAddress
|
||||
.then((value) {
|
||||
_toController.text = value;
|
||||
ref.read(desktopExchangeModelProvider)!.recipientAddress =
|
||||
_toController.text;
|
||||
});
|
||||
.getWallet(tuple.item1)
|
||||
.info
|
||||
.cachedReceivingAddress;
|
||||
|
||||
ref.read(desktopExchangeModelProvider)!.recipientAddress =
|
||||
_toController.text;
|
||||
} else {
|
||||
if (ref.read(desktopExchangeModelProvider)!.sendTicker.toUpperCase() ==
|
||||
tuple.item2.ticker.toUpperCase()) {
|
||||
ref
|
||||
_refundController.text = ref
|
||||
.read(pWallets)
|
||||
.getManager(tuple.item1)
|
||||
.currentReceivingAddress
|
||||
.then((value) {
|
||||
_refundController.text = value;
|
||||
ref.read(desktopExchangeModelProvider)!.refundAddress =
|
||||
_refundController.text;
|
||||
});
|
||||
.getWallet(tuple.item1)
|
||||
.info
|
||||
.cachedReceivingAddress;
|
||||
ref.read(desktopExchangeModelProvider)!.refundAddress =
|
||||
_refundController.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
|
|||
final coin = coinFromTickerCaseInsensitive(ticker);
|
||||
return ref
|
||||
.read(pWallets)
|
||||
.managers
|
||||
.where((element) => element.coin == coin)
|
||||
.wallets
|
||||
.where((e) => e.info.coin == coin)
|
||||
.isNotEmpty;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -12,7 +12,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
|
@ -20,6 +19,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||
|
@ -56,9 +56,9 @@ class _DesktopChooseFromStackState
|
|||
|
||||
final List<String> result = [];
|
||||
for (final walletId in walletIds) {
|
||||
final manager = ref.read(pWallets).getManager(walletId);
|
||||
final name = ref.read(pWalletName(walletId));
|
||||
|
||||
if (manager.walletName.toLowerCase().contains(searchTerm.toLowerCase())) {
|
||||
if (name.toLowerCase().contains(searchTerm.toLowerCase())) {
|
||||
result.add(walletId);
|
||||
}
|
||||
}
|
||||
|
@ -158,13 +158,13 @@ class _DesktopChooseFromStackState
|
|||
Flexible(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
List<String> walletIds = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getWalletIdsFor(coin: widget.coin),
|
||||
),
|
||||
);
|
||||
final wallets = ref
|
||||
.watch(pWallets)
|
||||
.walletsByCoin
|
||||
.where((e) => e.coin == widget.coin)
|
||||
.map((e) => e.wallets);
|
||||
|
||||
if (walletIds.isEmpty) {
|
||||
if (wallets.isEmpty) {
|
||||
return Column(
|
||||
children: [
|
||||
RoundedWhiteContainer(
|
||||
|
@ -183,6 +183,9 @@ class _DesktopChooseFromStackState
|
|||
);
|
||||
}
|
||||
|
||||
List<String> walletIds =
|
||||
wallets.first.map((e) => e.walletId).toList();
|
||||
|
||||
walletIds = filter(walletIds, _searchTerm);
|
||||
|
||||
return ListView.separated(
|
||||
|
@ -192,8 +195,8 @@ class _DesktopChooseFromStackState
|
|||
height: 5,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final manager = ref.watch(pWallets
|
||||
.select((value) => value.getManager(walletIds[index])));
|
||||
final wallet = ref.watch(pWallets
|
||||
.select((value) => value.getWallet(walletIds[index])));
|
||||
|
||||
return RoundedWhiteContainer(
|
||||
borderColor:
|
||||
|
@ -212,7 +215,7 @@ class _DesktopChooseFromStackState
|
|||
width: 12,
|
||||
),
|
||||
Text(
|
||||
manager.walletName,
|
||||
wallet.info.name,
|
||||
style: STextStyles.desktopTextExtraExtraSmall(
|
||||
context)
|
||||
.copyWith(
|
||||
|
@ -233,13 +236,12 @@ class _DesktopChooseFromStackState
|
|||
CustomTextButton(
|
||||
text: "Select wallet",
|
||||
onTap: () async {
|
||||
final address =
|
||||
await manager.currentReceivingAddress;
|
||||
final address = wallet.info.cachedReceivingAddress;
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop(
|
||||
Tuple2(
|
||||
manager.walletName,
|
||||
wallet.info.name,
|
||||
address,
|
||||
),
|
||||
);
|
||||
|
@ -287,17 +289,14 @@ class _BalanceDisplay extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final manager =
|
||||
ref.watch(pWallets.select((value) => value.getManager(walletId)));
|
||||
|
||||
Amount total = manager.balance.total;
|
||||
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
|
||||
final firoWallet = manager.wallet as FiroWallet;
|
||||
total += firoWallet.balancePrivate.total;
|
||||
final coin = ref.watch(pWalletCoin(walletId));
|
||||
Amount total = ref.watch(pWalletBalance(walletId)).total;
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
total += ref.watch(pWalletBalanceSecondary(walletId)).total;
|
||||
}
|
||||
|
||||
return Text(
|
||||
ref.watch(pAmountFormatter(manager.coin)).format(total),
|
||||
ref.watch(pAmountFormatter(coin)).format(total),
|
||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
|
||||
),
|
||||
|
|
|
@ -17,11 +17,11 @@ import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'
|
|||
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
|
||||
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -117,9 +117,6 @@ class _DesktopTradeHistoryState extends ConsumerState<DesktopTradeHistory> {
|
|||
if (txid != null &&
|
||||
walletIds != null &&
|
||||
walletIds.isNotEmpty) {
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(walletIds.first);
|
||||
|
||||
//todo: check if print needed
|
||||
// debugPrint("name: ${manager.walletName}");
|
||||
|
||||
|
@ -175,7 +172,9 @@ class _DesktopTradeHistoryState extends ConsumerState<DesktopTradeHistory> {
|
|||
child: TradeDetailsView(
|
||||
tradeId: tradeId,
|
||||
transactionIfSentFromStack: tx,
|
||||
walletName: manager.walletName,
|
||||
walletName: ref.read(
|
||||
pWalletName(
|
||||
walletIds.first)),
|
||||
walletId: walletIds.first,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -20,6 +20,7 @@ import 'package:stackwallet/pages_desktop_specific/settings/desktop_settings_vie
|
|||
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart';
|
||||
import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
||||
import 'package:stackwallet/providers/global/notifications_provider.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
|
@ -32,8 +33,6 @@ import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
|||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
|
||||
|
||||
final currentWalletIdProvider = StateProvider<String?>((_) => null);
|
||||
|
||||
class DesktopHomeView extends ConsumerStatefulWidget {
|
||||
const DesktopHomeView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -113,11 +112,11 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
|
|||
Navigator.of(myStackViewNavKey.currentContext!)
|
||||
.popUntil(ModalRoute.withName(MyStackView.routeName));
|
||||
if (ref.read(currentWalletIdProvider.state).state != null) {
|
||||
final managerProvider = ref
|
||||
.read(pWallets)
|
||||
.getManagerProvider(ref.read(currentWalletIdProvider.state).state!);
|
||||
if (ref.read(managerProvider).shouldAutoSync) {
|
||||
ref.read(managerProvider).shouldAutoSync = false;
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(ref.read(currentWalletIdProvider)!);
|
||||
|
||||
if (wallet.shouldAutoSync) {
|
||||
wallet.shouldAutoSync = false;
|
||||
}
|
||||
ref.read(transactionFilterProvider.state).state = null;
|
||||
if (ref.read(prefsChangeNotifierProvider).isAutoBackupEnabled &&
|
||||
|
@ -125,7 +124,10 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
|
|||
BackupFrequencyType.afterClosingAWallet) {
|
||||
ref.read(autoSWBServiceProvider).doBackup();
|
||||
}
|
||||
ref.read(managerProvider.notifier).isActiveWallet = false;
|
||||
|
||||
// ref.read(managerProvider.notifier).isActiveWallet = false;
|
||||
// TODO: call exit here?
|
||||
// wallet.exit(); ??
|
||||
}
|
||||
}
|
||||
ref.read(prevDesktopMenuItemProvider.state).state = newKey;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||
import 'package:stackwallet/providers/global/active_wallet_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -30,7 +30,11 @@ class CoinWalletsTable extends ConsumerWidget {
|
|||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final walletIds = ref
|
||||
.watch(pWallets.select((value) => value.getWalletIdsFor(coin: coin)));
|
||||
.watch(pWallets)
|
||||
.wallets
|
||||
.where((e) => e.info.coin == coin)
|
||||
.map((e) => e.walletId)
|
||||
.toList();
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
@ -71,11 +75,12 @@ class CoinWalletsTable extends ConsumerWidget {
|
|||
ref.read(currentWalletIdProvider.state).state =
|
||||
walletIds[i];
|
||||
|
||||
final manager =
|
||||
ref.read(pWallets).getManager(walletIds[i]);
|
||||
if (manager.coin == Coin.monero ||
|
||||
manager.coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
final wallet =
|
||||
ref.read(pWallets).getWallet(walletIds[i]);
|
||||
if (wallet.info.coin == Coin.monero ||
|
||||
wallet.info.coin == Coin.wownero) {
|
||||
// TODO: this can cause ui lag
|
||||
await wallet.init();
|
||||
}
|
||||
|
||||
await Navigator.of(context).pushNamed(
|
||||
|
|
|
@ -13,12 +13,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart';
|
||||
import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_card.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/db_watchers/favourite_wallets_watcher.dart';
|
||||
|
||||
class DesktopFavoriteWallets extends ConsumerWidget {
|
||||
const DesktopFavoriteWallets({Key? key}) : super(key: key);
|
||||
|
@ -31,117 +31,116 @@ class DesktopFavoriteWallets extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
|
||||
final favorites = ref.watch(favoritesProvider);
|
||||
bool hasFavorites = favorites.length > 0;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
return FavouriteWalletsWatcher(
|
||||
builder: (context, favourites) {
|
||||
bool hasFavorites = favourites.isNotEmpty;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Favorite wallets",
|
||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldActiveSearchIconRight,
|
||||
),
|
||||
),
|
||||
CustomTextButton(
|
||||
text: "Edit",
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(ManageFavoritesView.routeName);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: (cardHeight * 2) + standardPadding,
|
||||
minHeight: cardHeight,
|
||||
),
|
||||
child: hasFavorites
|
||||
? SingleChildScrollView(
|
||||
primary: false,
|
||||
child: Wrap(
|
||||
spacing: 16,
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
...favorites.map((p0) {
|
||||
final walletId = ref.read(p0).walletId;
|
||||
final walletName = ref.read(p0).walletName;
|
||||
final managerProvider =
|
||||
ref.read(pWallets).getManagerProvider(walletId);
|
||||
|
||||
return FavoriteCard(
|
||||
walletId: walletId,
|
||||
key: Key(walletName),
|
||||
width: cardWidth,
|
||||
height: cardHeight,
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: cardHeight,
|
||||
width: cardWidth,
|
||||
decoration: BoxDecoration(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Favorite wallets",
|
||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
child: MaterialButton(
|
||||
splashColor:
|
||||
Theme.of(context).extension<StackColors>()!.highlight,
|
||||
key: const Key("favoriteWalletsAddFavoriteButtonKey"),
|
||||
padding: const EdgeInsets.all(12),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed(ManageFavoritesView.routeName);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.plus,
|
||||
width: 14,
|
||||
height: 14,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
"Add a favorite",
|
||||
style: STextStyles.itemSubtitle(context).copyWith(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
.textFieldActiveSearchIconRight,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
],
|
||||
CustomTextButton(
|
||||
text: "Edit",
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed(ManageFavoritesView.routeName);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: (cardHeight * 2) + standardPadding,
|
||||
minHeight: cardHeight,
|
||||
),
|
||||
child: hasFavorites
|
||||
? SingleChildScrollView(
|
||||
primary: false,
|
||||
child: Wrap(
|
||||
spacing: 16,
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
...favourites.map((e) {
|
||||
return FavoriteCard(
|
||||
walletId: e.walletId,
|
||||
key: Key(e.name),
|
||||
width: cardWidth,
|
||||
height: cardHeight,
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: cardHeight,
|
||||
width: cardWidth,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
child: MaterialButton(
|
||||
splashColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.highlight,
|
||||
key: const Key("favoriteWalletsAddFavoriteButtonKey"),
|
||||
padding: const EdgeInsets.all(12),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed(ManageFavoritesView.routeName);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.plus,
|
||||
width: 14,
|
||||
height: 14,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
"Add a favorite",
|
||||
style: STextStyles.itemSubtitle(context).copyWith(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/wallet/wallet.dart';
|
||||
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
|
||||
import 'package:stackwallet/widgets/expandable.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -32,7 +32,7 @@ class DesktopExpandingWalletCard extends StatefulWidget {
|
|||
required this.navigatorState,
|
||||
}) : super(key: key);
|
||||
|
||||
final Tuple2<Manager, List<EthContract>> data;
|
||||
final Tuple2<Wallet, List<EthContract>> data;
|
||||
final NavigatorState navigatorState;
|
||||
|
||||
@override
|
||||
|
@ -48,7 +48,7 @@ class _DesktopExpandingWalletCardState
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.data.item1.hasTokenSupport) {
|
||||
if (widget.data.item1.cryptoCurrency.hasTokenSupport) {
|
||||
tokenContractAddresses.addAll(
|
||||
widget.data.item2.map((e) => e.address),
|
||||
);
|
||||
|
@ -63,7 +63,7 @@ class _DesktopExpandingWalletCardState
|
|||
padding: EdgeInsets.zero,
|
||||
borderColor: Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
||||
child: Expandable(
|
||||
initialState: widget.data.item1.hasTokenSupport
|
||||
initialState: widget.data.item1.cryptoCurrency.hasTokenSupport
|
||||
? ExpandableState.expanded
|
||||
: ExpandableState.collapsed,
|
||||
controller: expandableController,
|
||||
|
@ -89,13 +89,13 @@ class _DesktopExpandingWalletCardState
|
|||
child: Row(
|
||||
children: [
|
||||
WalletInfoCoinIcon(
|
||||
coin: widget.data.item1.coin,
|
||||
coin: widget.data.item1.info.coin,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
widget.data.item1.walletName,
|
||||
widget.data.item1.info.name,
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
|
|
|
@ -21,14 +21,15 @@ import 'package:stackwallet/providers/global/prefs_provider.dart';
|
|||
import 'package:stackwallet/providers/global/price_provider.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||
import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
@ -58,12 +59,12 @@ class _DesktopPaynymSendDialogState
|
|||
extends ConsumerState<DesktopPaynymSendDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = ref
|
||||
.watch(pWallets.select((value) => value.getManager(widget.walletId)));
|
||||
final wallet =
|
||||
ref.watch(pWallets.select((value) => value.getWallet(widget.walletId)));
|
||||
final String locale = ref.watch(
|
||||
localeServiceChangeNotifierProvider.select((value) => value.locale));
|
||||
|
||||
final coin = manager.coin;
|
||||
final coin = ref.watch(pWalletCoin(widget.walletId));
|
||||
|
||||
final isFiro = coin == Coin.firo || coin == Coin.firoTestNet;
|
||||
|
||||
|
@ -78,7 +79,7 @@ class _DesktopPaynymSendDialogState
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(left: 32),
|
||||
child: Text(
|
||||
"Send ${manager.coin.ticker.toUpperCase()}",
|
||||
"Send ${coin.ticker.toUpperCase()}",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
),
|
||||
|
@ -107,7 +108,7 @@ class _DesktopPaynymSendDialogState
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
manager.walletName,
|
||||
ref.watch(pWalletName(widget.walletId)),
|
||||
style: STextStyles.titleBold12(context),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
|
@ -135,9 +136,9 @@ class _DesktopPaynymSendDialogState
|
|||
children: [
|
||||
Text(
|
||||
!isFiro
|
||||
? ref
|
||||
.watch(pAmountFormatter(coin))
|
||||
.format(manager.balance.spendable)
|
||||
? ref.watch(pAmountFormatter(coin)).format(ref
|
||||
.watch(pWalletBalance(widget.walletId))
|
||||
.spendable)
|
||||
: ref
|
||||
.watch(
|
||||
publicPrivateBalanceStateProvider
|
||||
|
@ -146,12 +147,24 @@ class _DesktopPaynymSendDialogState
|
|||
.state ==
|
||||
"Private"
|
||||
? ref.watch(pAmountFormatter(coin)).format(
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePrivateBalance())
|
||||
ref
|
||||
.watch(
|
||||
pWalletBalance(widget.walletId))
|
||||
.spendable,
|
||||
)
|
||||
: ref.watch(pAmountFormatter(coin)).format(
|
||||
(manager.wallet as FiroWallet)
|
||||
.availablePublicBalance(),
|
||||
ref
|
||||
.watch(pWalletBalanceSecondary(
|
||||
widget.walletId))
|
||||
.spendable,
|
||||
),
|
||||
// ? ref.watch(pAmountFormatter(coin)).format(
|
||||
// (manager.wallet as FiroWallet)
|
||||
// .availablePrivateBalance())
|
||||
// : ref.watch(pAmountFormatter(coin)).format(
|
||||
// (manager.wallet as FiroWallet)
|
||||
// .availablePublicBalance(),
|
||||
// ),
|
||||
style: STextStyles.titleBold12(context),
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
|
@ -159,7 +172,7 @@ class _DesktopPaynymSendDialogState
|
|||
height: 2,
|
||||
),
|
||||
Text(
|
||||
"${((!isFiro ? manager.balance.spendable.decimal : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" ? (manager.wallet as FiroWallet).availablePrivateBalance().decimal : (manager.wallet as FiroWallet).availablePublicBalance().decimal) * ref.watch(
|
||||
"${((!isFiro ? ref.watch(pWalletBalance(widget.walletId)).spendable.decimal : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" ? ref.watch(pWalletBalance(widget.walletId)).spendable.decimal : ref.watch(pWalletBalanceSecondary(widget.walletId)).spendable.decimal) * ref.watch(
|
||||
priceAnd24hChangeNotifierProvider.select(
|
||||
(value) => value.getPrice(coin).item1,
|
||||
),
|
||||
|
@ -192,7 +205,7 @@ class _DesktopPaynymSendDialogState
|
|||
bottom: 32,
|
||||
),
|
||||
child: DesktopSend(
|
||||
walletId: manager.walletId,
|
||||
walletId: widget.walletId,
|
||||
accountLite: widget.accountLite,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -36,19 +36,14 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final providersByCoin = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getManagerProvidersByCoin(),
|
||||
),
|
||||
);
|
||||
final walletsByCoin = ref.watch(pWallets).walletsByCoin;
|
||||
|
||||
return ListView.separated(
|
||||
itemBuilder: (_, index) {
|
||||
final providers = providersByCoin[index].item2;
|
||||
final coin = providersByCoin[index].item1;
|
||||
final coin = walletsByCoin[index].coin;
|
||||
|
||||
return ConditionalParent(
|
||||
condition: index + 1 == providersByCoin.length,
|
||||
condition: index + 1 == walletsByCoin.length,
|
||||
builder: (child) => Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 16,
|
||||
|
@ -58,14 +53,14 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
child: DesktopWalletSummaryRow(
|
||||
key: Key("DesktopWalletSummaryRow_key_${coin.name}"),
|
||||
coin: coin,
|
||||
walletCount: providers.length,
|
||||
walletCount: walletsByCoin[index].wallets.length,
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) => const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemCount: providersByCoin.length,
|
||||
itemCount: walletsByCoin.length,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue