Skip to content

Commit 025404b

Browse files
committed
WIP extract some kind of CryptonoteWallet interface
1 parent a260a93 commit 025404b

File tree

26 files changed

+1626
-1536
lines changed

26 files changed

+1626
-1536
lines changed

lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart

Lines changed: 274 additions & 308 deletions
Large diffs are not rendered by default.

lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ import '../../../wallets/wallet/impl/epiccash_wallet.dart';
3737
import '../../../wallets/wallet/impl/monero_wallet.dart';
3838
import '../../../wallets/wallet/impl/wownero_wallet.dart';
3939
import '../../../wallets/wallet/impl/xelis_wallet.dart';
40-
import '../../../wallets/wallet/intermediate/lib_monero_wallet.dart';
41-
import '../../../wallets/wallet/intermediate/lib_salvium_wallet.dart';
40+
import '../../../wallets/wallet/intermediate/cryptonote_wallet.dart';
4241
import '../../../wallets/wallet/wallet.dart';
4342
import '../../../wallets/wallet/wallet_mixin_interfaces/extended_keys_interface.dart';
4443
import '../../../wallets/wallet/wallet_mixin_interfaces/view_only_option_interface.dart';
@@ -112,8 +111,7 @@ class _VerifyRecoveryPhraseViewState
112111
final ViewOnlyWalletType viewOnlyWalletType;
113112
if (widget.wallet is ExtendedKeysInterface) {
114113
viewOnlyWalletType = ViewOnlyWalletType.xPub;
115-
} else if (widget.wallet is LibMoneroWallet ||
116-
widget.wallet is LibSalviumWallet) {
114+
} else if (widget.wallet is CryptonoteWallet) {
117115
if (widget.wallet.cryptoCurrency is Monero) {
118116
height = csMonero.getHeightByDate(
119117
DateTime.now().subtract(const Duration(days: 7)),
@@ -174,23 +172,8 @@ class _VerifyRecoveryPhraseViewState
174172
walletId: voInfo.walletId,
175173
xPubs: [xPub],
176174
);
177-
} else if (widget.wallet is LibMoneroWallet) {
178-
final w = widget.wallet as LibMoneroWallet;
179-
180-
final info = await w
181-
.hackToCreateNewViewOnlyWalletDataFromNewlyCreatedWalletThisFunctionShouldNotBeCalledUnlessYouKnowWhatYouAreDoing();
182-
final address = info.$1;
183-
final privateViewKey = info.$2;
184-
185-
await w.exit();
186-
187-
viewOnlyData = CryptonoteViewOnlyWalletData(
188-
walletId: voInfo.walletId,
189-
address: address,
190-
privateViewKey: privateViewKey,
191-
);
192-
} else if (widget.wallet is LibSalviumWallet) {
193-
final w = widget.wallet as LibSalviumWallet;
175+
} else if (widget.wallet is CryptonoteWallet) {
176+
final w = widget.wallet as CryptonoteWallet;
194177

195178
final info = await w
196179
.hackToCreateNewViewOnlyWalletDataFromNewlyCreatedWalletThisFunctionShouldNotBeCalledUnlessYouKnowWhatYouAreDoing();

lib/pages/send_view/send_view.dart

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ import '../../utilities/show_loading.dart';
4949
import '../../utilities/text_styles.dart';
5050
import '../../utilities/util.dart';
5151
import '../../wallets/crypto_currency/crypto_currency.dart';
52+
import '../../wallets/crypto_currency/intermediate/cryptonote_currency.dart';
5253
import '../../wallets/crypto_currency/intermediate/nano_currency.dart';
5354
import '../../wallets/isar/providers/wallet_info_provider.dart';
5455
import '../../wallets/models/tx_data.dart';
5556
import '../../wallets/wallet/impl/firo_wallet.dart';
5657
import '../../wallets/wallet/impl/mimblewimblecoin_wallet.dart';
58+
import '../../wallets/wallet/intermediate/cryptonote_wallet.dart';
5759
import '../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart';
5860
import '../../wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart';
5961
import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
@@ -74,8 +76,6 @@ import '../../widgets/rounded_white_container.dart';
7476
import '../../widgets/stack_dialog.dart';
7577
import '../../widgets/stack_text_field.dart';
7678
import '../../widgets/textfield_icon_button.dart';
77-
import '../../wl_gen/interfaces/cs_monero_interface.dart';
78-
import '../../wl_gen/interfaces/cs_wownero_interface.dart';
7979
import '../address_book_views/address_book_view.dart';
8080
import '../coin_control/coin_control_view.dart';
8181
import 'confirm_transaction_view.dart';
@@ -560,39 +560,17 @@ class _SendViewState extends ConsumerState<SendView> {
560560
}
561561

562562
Amount fee;
563-
if (coin is Monero) {
563+
if (coin is CryptonoteCurrency) {
564564
final int specialMoneroId;
565565
switch (ref.read(feeRateTypeMobileStateProvider.state).state) {
566566
case FeeRateType.fast:
567-
specialMoneroId = csMonero.getTxPriorityHigh();
567+
specialMoneroId = (wallet as CryptonoteWallet).getTxPriorityHigh();
568568
break;
569569
case FeeRateType.average:
570-
specialMoneroId = csMonero.getTxPriorityMedium();
570+
specialMoneroId = (wallet as CryptonoteWallet).getTxPriorityMedium();
571571
break;
572572
case FeeRateType.slow:
573-
specialMoneroId = csMonero.getTxPriorityNormal();
574-
break;
575-
default:
576-
throw ArgumentError("custom fee not available for monero");
577-
}
578-
579-
fee = await wallet.estimateFeeFor(amount, BigInt.from(specialMoneroId));
580-
cachedFees[amount] = ref
581-
.read(pAmountFormatter(coin))
582-
.format(fee, withUnitName: true, indicatePrecisionLoss: false);
583-
584-
return cachedFees[amount]!;
585-
} else if (coin is Wownero) {
586-
final int specialMoneroId;
587-
switch (ref.read(feeRateTypeMobileStateProvider.state).state) {
588-
case FeeRateType.fast:
589-
specialMoneroId = csWownero.getTxPriorityHigh();
590-
break;
591-
case FeeRateType.average:
592-
specialMoneroId = csWownero.getTxPriorityMedium();
593-
break;
594-
case FeeRateType.slow:
595-
specialMoneroId = csWownero.getTxPriorityNormal();
573+
specialMoneroId = (wallet as CryptonoteWallet).getTxPriorityNormal();
596574
break;
597575
default:
598576
throw ArgumentError("custom fee not available for monero");

lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import '../../../utilities/enums/fee_rate_type_enum.dart';
2323
import '../../../utilities/logger.dart';
2424
import '../../../utilities/text_styles.dart';
2525
import '../../../wallets/crypto_currency/crypto_currency.dart';
26+
import '../../../wallets/crypto_currency/intermediate/cryptonote_currency.dart';
2627
import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart';
2728
import '../../../wallets/isar/providers/wallet_info_provider.dart';
2829
import '../../../wallets/wallet/impl/firo_wallet.dart';
30+
import '../../../wallets/wallet/intermediate/cryptonote_wallet.dart';
2931
import '../../../wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart';
3032
import '../../../widgets/animated_text.dart';
31-
import '../../../wl_gen/interfaces/cs_monero_interface.dart';
32-
import '../../../wl_gen/interfaces/cs_wownero_interface.dart';
3333

3434
final feeSheetSessionCacheProvider =
3535
ChangeNotifierProvider<FeeSheetSessionCache>((ref) {
@@ -89,16 +89,10 @@ class _TransactionFeeSelectionSheetState
8989
if (widget.isToken == false) {
9090
final wallet = ref.read(pWallets).getWallet(walletId);
9191

92-
if (coin is Monero) {
92+
if (coin is CryptonoteCurrency) {
9393
final fee = await wallet.estimateFeeFor(
9494
amount,
95-
BigInt.from(csMonero.getTxPriorityHigh()),
96-
);
97-
ref.read(feeSheetSessionCacheProvider).fast[amount] = fee;
98-
} else if (coin is Wownero) {
99-
final fee = await wallet.estimateFeeFor(
100-
amount,
101-
BigInt.from(csWownero.getTxPriorityHigh()),
95+
BigInt.from((wallet as CryptonoteWallet).getTxPriorityHigh()),
10296
);
10397
ref.read(feeSheetSessionCacheProvider).fast[amount] = fee;
10498
} else if (coin is Firo) {
@@ -132,16 +126,10 @@ class _TransactionFeeSelectionSheetState
132126
if (ref.read(feeSheetSessionCacheProvider).average[amount] == null) {
133127
if (widget.isToken == false) {
134128
final wallet = ref.read(pWallets).getWallet(walletId);
135-
if (coin is Monero) {
136-
final fee = await wallet.estimateFeeFor(
137-
amount,
138-
BigInt.from(csMonero.getTxPriorityMedium()),
139-
);
140-
ref.read(feeSheetSessionCacheProvider).average[amount] = fee;
141-
} else if (coin is Wownero) {
129+
if (coin is CryptonoteCurrency) {
142130
final fee = await wallet.estimateFeeFor(
143131
amount,
144-
BigInt.from(csWownero.getTxPriorityMedium()),
132+
BigInt.from((wallet as CryptonoteWallet).getTxPriorityMedium()),
145133
);
146134
ref.read(feeSheetSessionCacheProvider).average[amount] = fee;
147135
} else if (coin is Firo) {
@@ -174,16 +162,10 @@ class _TransactionFeeSelectionSheetState
174162
if (ref.read(feeSheetSessionCacheProvider).slow[amount] == null) {
175163
if (widget.isToken == false) {
176164
final wallet = ref.read(pWallets).getWallet(walletId);
177-
if (coin is Monero) {
178-
final fee = await wallet.estimateFeeFor(
179-
amount,
180-
BigInt.from(csMonero.getTxPriorityNormal()),
181-
);
182-
ref.read(feeSheetSessionCacheProvider).slow[amount] = fee;
183-
} else if (coin is Wownero) {
165+
if (coin is CryptonoteCurrency) {
184166
final fee = await wallet.estimateFeeFor(
185167
amount,
186-
BigInt.from(csWownero.getTxPriorityNormal()),
168+
BigInt.from((wallet as CryptonoteWallet).getTxPriorityNormal()),
187169
);
188170
ref.read(feeSheetSessionCacheProvider).slow[amount] = fee;
189171
} else if (coin is Firo) {

0 commit comments

Comments
 (0)