diff --git a/cw_lightning/lib/lightning_wallet.dart b/cw_lightning/lib/lightning_wallet.dart index ca60d00f4..a407a2a0e 100644 --- a/cw_lightning/lib/lightning_wallet.dart +++ b/cw_lightning/lib/lightning_wallet.dart @@ -126,7 +126,11 @@ abstract class LightningWalletBase extends ElectrumWallet with Store { required String password, }) async { final snp = await ElectrumWalletSnapshot.load( - name, walletInfo.type, password, BitcoinCashNetwork.mainnet); + name, + walletInfo.type, + password, + BitcoinNetwork.mainnet + ); return LightningWallet( mnemonic: snp.mnemonic, password: password, diff --git a/lib/di.dart b/lib/di.dart index afe9f92fe..f47410cb6 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -1209,32 +1209,32 @@ Future<void> setup({ settingsStore: getIt.get<SettingsStore>(), fiatConversionStore: getIt.get<FiatConversionStore>(), )); - getIt.registerFactoryParam<LightningInvoicePageViewModel, List<dynamic>, void>((args, _) { - final pageOption = args.first as ReceivePageOption; + + getIt.registerFactoryParam<LightningInvoicePageViewModel, void, void>((_, __) { return LightningInvoicePageViewModel( getIt.get<SettingsStore>(), getIt.get<AppStore>().wallet!, getIt.get<SharedPreferences>(), getIt.get<LightningViewModel>(), - pageOption, ); }); - getIt.registerFactoryParam<LightningReceiveOnchainPage, List<dynamic>, void>( - (List<dynamic> args, _) { - final pageOption = args.last as ReceivePageOption; + getIt.registerFactoryParam<LightningReceiveOnchainPage, void, void>((_, __) { return LightningReceiveOnchainPage( - addressListViewModel: getIt.get<WalletAddressListViewModel>(), - lightningViewModel: getIt.get<LightningViewModel>(), - receiveOptionViewModel: getIt.get<ReceiveOptionViewModel>(param1: pageOption)); + addressListViewModel: getIt.get<WalletAddressListViewModel>(), + lightningViewModel: getIt.get<LightningViewModel>(), + receiveOptionViewModel: + getIt.get<ReceiveOptionViewModel>(param1: lightning!.getOptionOnchain()), + ); }); - getIt.registerFactoryParam<LightningInvoicePage, List<dynamic>, void>((List<dynamic> args, _) { - final pageOption = args.last as ReceivePageOption; + getIt.registerFactoryParam<LightningInvoicePage, void, void>((_, __) { return LightningInvoicePage( - lightningInvoicePageViewModel: getIt.get<LightningInvoicePageViewModel>(param1: args), - lightningViewModel: getIt.get<LightningViewModel>(), - receiveOptionViewModel: getIt.get<ReceiveOptionViewModel>(param1: pageOption)); + lightningInvoicePageViewModel: getIt.get<LightningInvoicePageViewModel>(), + lightningViewModel: getIt.get<LightningViewModel>(), + receiveOptionViewModel: + getIt.get<ReceiveOptionViewModel>(param1: lightning!.getOptionInvoice()), + ); }); getIt.registerFactory<LightningSendPage>(() { diff --git a/lib/entities/main_actions.dart b/lib/entities/main_actions.dart index 57ba57583..21f07e05b 100644 --- a/lib/entities/main_actions.dart +++ b/lib/entities/main_actions.dart @@ -57,11 +57,7 @@ class MainActions { image: 'assets/images/received.png', onTap: (BuildContext context, DashboardViewModel viewModel) async { if (viewModel.wallet.type == WalletType.lightning) { - Navigator.pushNamed( - context, - Routes.lightningInvoice, - arguments: [lightning!.getOptionInvoice()], - ); + Navigator.pushNamed(context, Routes.lightningInvoice); return; } Navigator.pushNamed(context, Routes.addressPage); diff --git a/lib/lightning/cw_lightning.dart b/lib/lightning/cw_lightning.dart index 491f54395..74a2a0acd 100644 --- a/lib/lightning/cw_lightning.dart +++ b/lib/lightning/cw_lightning.dart @@ -1,49 +1,6 @@ part of 'lightning.dart'; class CWLightning extends Lightning { - @override - WalletCredentials createLightningRestoreWalletFromSeedCredentials( - {required String name, required String mnemonic, required String password}) => - BitcoinRestoreWalletFromSeedCredentials(name: name, mnemonic: mnemonic, password: password); - - @override - WalletCredentials createLightningRestoreWalletFromWIFCredentials( - {required String name, - required String password, - required String wif, - WalletInfo? walletInfo}) => - BitcoinRestoreWalletFromWIFCredentials( - name: name, password: password, wif: wif, walletInfo: walletInfo); - - @override - WalletCredentials createLightningNewWalletCredentials( - {required String name, WalletInfo? walletInfo}) => - BitcoinNewWalletCredentials(name: name, walletInfo: walletInfo); - - @override - Object createLightningTransactionCredentials(List<Output> outputs, - {required TransactionPriority priority, int? feeRate}) => - BitcoinTransactionCredentials( - outputs - .map((out) => OutputInfo( - fiatAmount: out.fiatAmount, - cryptoAmount: out.cryptoAmount, - address: out.address, - note: out.note, - sendAll: out.sendAll, - extractedAddress: out.extractedAddress, - isParsedAddress: out.isParsedAddress, - formattedCryptoAmount: out.formattedCryptoAmount)) - .toList(), - priority: priority as BitcoinTransactionPriority, - feeRate: feeRate); - - @override - Object createLightningTransactionCredentialsRaw(List<OutputInfo> outputs, - {TransactionPriority? priority, required int feeRate}) => - BitcoinTransactionCredentials(outputs, - priority: priority != null ? priority as BitcoinTransactionPriority : null, - feeRate: feeRate); @override String formatterLightningAmountToString({required int amount}) => diff --git a/lib/router.dart b/lib/router.dart index cb7960b1a..1d184c957 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -659,9 +659,8 @@ Route<dynamic> createRoute(RouteSettings settings) { builder: (_) => getIt.get<LightningReceiveOnchainPage>(param1: args)); case Routes.lightningInvoice: - final args = settings.arguments as List; return CupertinoPageRoute<void>( - fullscreenDialog: true, builder: (_) => getIt.get<LightningInvoicePage>(param1: args)); + fullscreenDialog: true, builder: (_) => getIt.get<LightningInvoicePage>()); default: return MaterialPageRoute<void>( diff --git a/lib/view_model/lightning_invoice_page_view_model.dart b/lib/view_model/lightning_invoice_page_view_model.dart index 8978310e1..399654a9f 100644 --- a/lib/view_model/lightning_invoice_page_view_model.dart +++ b/lib/view_model/lightning_invoice_page_view_model.dart @@ -21,7 +21,6 @@ abstract class LightningInvoicePageViewModelBase with Store { this._wallet, this.sharedPreferences, this.lightningViewModel, - this.pageOption, ) : description = '', amount = '', state = InitialExecutionState(), @@ -34,7 +33,6 @@ abstract class LightningInvoicePageViewModelBase with Store { final SettingsStore settingsStore; final WalletBase _wallet; final SharedPreferences sharedPreferences; - final ReceivePageOption pageOption; final LightningViewModel lightningViewModel; @observable diff --git a/tool/configure.dart b/tool/configure.dart index f36f07c53..b1816fea2 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -750,20 +750,6 @@ import 'package:cw_lightning/lightning_receive_page_option.dart'; const lightningCwPart = "part 'cw_lightning.dart';"; const lightningContent = """ abstract class Lightning { - WalletCredentials createLightningRestoreWalletFromSeedCredentials( - {required String name, required String mnemonic, required String password}); - WalletCredentials createLightningRestoreWalletFromWIFCredentials( - {required String name, - required String password, - required String wif, - WalletInfo? walletInfo}); - WalletCredentials createLightningNewWalletCredentials( - {required String name, WalletInfo? walletInfo}); - Object createLightningTransactionCredentials(List<Output> outputs, - {required TransactionPriority priority, int? feeRate}); - Object createLightningTransactionCredentialsRaw(List<OutputInfo> outputs, - {TransactionPriority? priority, required int feeRate}); - String formatterLightningAmountToString({required int amount}); double formatterLightningAmountToDouble({required int amount}); int formatterStringDoubleToLightningAmount(String amount);