This commit is contained in:
Matthew Fosse 2024-03-06 21:26:43 -08:00
parent 452ff1e82b
commit 8828262ee0
7 changed files with 21 additions and 81 deletions

View file

@ -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,

View file

@ -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>(() {

View file

@ -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);

View file

@ -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}) =>

View file

@ -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>(

View file

@ -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

View file

@ -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);