typecast to generic PaynymWalletInterface

This commit is contained in:
julian 2023-01-26 10:59:15 -06:00
parent 5de22ca858
commit 26c57b5456
7 changed files with 54 additions and 55 deletions

View file

@ -14,8 +14,7 @@ import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
@ -62,10 +61,10 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
),
);
final wallet = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
final manager =
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
final wallet = manager.wallet as PaynymWalletInterface;
if (await wallet.hasConnected(widget.accountLite.code)) {
canPop = true;
@ -74,7 +73,7 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
return;
}
final rates = await wallet.fees;
final rates = await manager.fees;
Map<String, dynamic> preparedTx;
@ -116,7 +115,7 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
Navigator.of(context).push(
RouteGenerator.getRoute(
builder: (_) => ConfirmTransactionView(
walletId: wallet.walletId,
walletId: manager.walletId,
routeOnSuccessName: PaynymHomeView.routeName,
isPaynymNotificationTransaction: true,
transactionInfo: {
@ -132,7 +131,7 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
);
},
amount: (preparedTx["amount"] as int) + (preparedTx["fee"] as int),
coin: wallet.coin,
coin: manager.coin,
),
);
}
@ -140,8 +139,10 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
@override
Widget build(BuildContext context) {
final wallet = ref.watch(walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).wallet as DogecoinWallet));
final manager = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(widget.walletId)));
final wallet = manager.wallet as PaynymWalletInterface;
return DesktopDialog(
maxWidth: MediaQuery.of(context).size.width - 32,

View file

@ -9,8 +9,7 @@ import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
@ -160,17 +159,18 @@ class _PaynymClaimViewState extends ConsumerState<PaynymClaimView> {
).then((value) => shouldCancel = value == true),
);
// get wallet to access paynym calls
final wallet = ref
final manager = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
.getManager(widget.walletId);
// get wallet to access paynym calls
final wallet = manager.wallet as PaynymWalletInterface;
if (shouldCancel) return;
// get payment code
final pCode = await wallet.getPaymentCode(
DerivePathTypeExt.primaryFor(wallet.coin));
DerivePathTypeExt.primaryFor(manager.coin));
if (shouldCancel) return;

View file

@ -12,8 +12,7 @@ import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.d
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
@ -58,10 +57,10 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
),
);
final wallet = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
final manager =
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
final wallet = manager.wallet as PaynymWalletInterface;
if (await wallet.hasConnected(widget.accountLite.code)) {
canPop = true;
@ -70,7 +69,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
return;
}
final rates = await wallet.fees;
final rates = await manager.fees;
Map<String, dynamic> preparedTx;
@ -113,7 +112,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
maxHeight: double.infinity,
maxWidth: 580,
child: ConfirmTransactionView(
walletId: wallet.walletId,
walletId: manager.walletId,
isPaynymNotificationTransaction: true,
transactionInfo: {
"hex": preparedTx["hex"],
@ -142,7 +141,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
);
},
amount: (preparedTx["amount"] as int) + (preparedTx["fee"] as int),
coin: wallet.coin,
coin: manager.coin,
),
);
}
@ -154,10 +153,11 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
@override
Widget build(BuildContext context) {
final wallet = ref
.watch(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
final manager = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(widget.walletId)));
final wallet = manager.wallet as PaynymWalletInterface;
return RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: Column(

View file

@ -12,10 +12,9 @@ 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/coin_paynym_extension.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -92,7 +91,7 @@ class _ConfirmTransactionViewState
try {
String txid;
if (widget.isPaynymNotificationTransaction) {
txid = await (manager.wallet as DogecoinWallet)
txid = await (manager.wallet as PaynymWalletInterface)
.broadcastNotificationTx(preparedTx: transactionInfo);
} else if (widget.isPaynymTransaction) {
//

View file

@ -19,10 +19,10 @@ import 'package:stackwallet/providers/global/paynym_api_provider.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.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/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -209,14 +209,13 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
),
);
// todo make generic and not doge specific
final wallet = (ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet);
final manager =
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
final wallet = manager.wallet as PaynymWalletInterface;
final code =
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(wallet.coin));
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin));
final account = await ref.read(paynymAPIProvider).nym(code.toString());

View file

@ -9,8 +9,7 @@ import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/providers/global/paynym_api_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart';
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
@ -59,17 +58,18 @@ class _PaynymFollowToggleButtonState
),
);
final wallet = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
final manager =
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
// get wallet to access paynym calls
final wallet = manager.wallet as PaynymWalletInterface;
final followedAccount = await ref
.read(paynymAPIProvider)
.nym(widget.paymentCodeStringToFollow, true);
final myPCode =
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(wallet.coin));
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin));
PaynymResponse<String> token =
await ref.read(paynymAPIProvider).token(myPCode.toString());
@ -160,17 +160,17 @@ class _PaynymFollowToggleButtonState
),
);
final wallet = ref
.read(walletsChangeNotifierProvider)
.getManager(widget.walletId)
.wallet as DogecoinWallet;
final manager =
ref.read(walletsChangeNotifierProvider).getManager(widget.walletId);
final wallet = manager.wallet as PaynymWalletInterface;
final followedAccount = await ref
.read(paynymAPIProvider)
.nym(widget.paymentCodeStringToFollow, true);
final myPCode =
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(wallet.coin));
await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin));
PaynymResponse<String> token =
await ref.read(paynymAPIProvider).token(myPCode.toString());

View file

@ -1408,8 +1408,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "93e2687bcc10fc7258c7dab038c363fc9ff8ba5d"
resolved-ref: "93e2687bcc10fc7258c7dab038c363fc9ff8ba5d"
ref: e4b08d2b8965a5ae49bd57f598fa9011dd0c25e9
resolved-ref: e4b08d2b8965a5ae49bd57f598fa9011dd0c25e9
url: "https://github.com/cypherstack/stack_wallet_backup.git"
source: git
version: "0.0.1"