mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 08:45:05 +00:00
Fix stub creation
This commit is contained in:
parent
a3aebbdb78
commit
dbc005dcf3
4 changed files with 9 additions and 14 deletions
|
@ -111,7 +111,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
|||
@override
|
||||
Future<void> startSync() async {
|
||||
await super.startSync();
|
||||
final stub = CwMweb.stub();
|
||||
final stub = await CwMweb.stub();
|
||||
Timer.periodic(
|
||||
const Duration(milliseconds: 1500), (timer) async {
|
||||
final height = await electrumClient.getCurrentBlockChainTip() ?? 0;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:io';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||
|
@ -11,7 +10,6 @@ import 'package:cw_core/pathForWallet.dart';
|
|||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_mweb/cw_mweb.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class LitecoinWalletService extends WalletService<
|
||||
|
@ -28,8 +26,6 @@ class LitecoinWalletService extends WalletService<
|
|||
|
||||
@override
|
||||
Future<LitecoinWallet> create(BitcoinNewWalletCredentials credentials, {bool? isTestnet}) async {
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
await CwMweb.start(appDir.path);
|
||||
final wallet = await LitecoinWalletBase.create(
|
||||
mnemonic: await generateMnemonic(),
|
||||
password: credentials.password!,
|
||||
|
@ -47,8 +43,6 @@ class LitecoinWalletService extends WalletService<
|
|||
|
||||
@override
|
||||
Future<LitecoinWallet> openWallet(String name, String password) async {
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
await CwMweb.start(appDir.path);
|
||||
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||
(info) => info.id == WalletBase.idFor(name, getType()))!;
|
||||
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import 'package:grpc/grpc.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'cw_mweb_platform_interface.dart';
|
||||
import 'mwebd.pbgrpc.dart';
|
||||
|
||||
class CwMweb {
|
||||
static var port;
|
||||
static Future<int?>? port;
|
||||
|
||||
static start(String dataDir) async {
|
||||
port = port ?? await CwMwebPlatform.instance.start(dataDir);
|
||||
}
|
||||
|
||||
static stub() {
|
||||
static Future<RpcClient> stub() async {
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
port ??= CwMwebPlatform.instance.start(appDir.path);
|
||||
return RpcClient(ClientChannel('127.0.0.1',
|
||||
port: port,
|
||||
port: await port ?? 0,
|
||||
options: const ChannelOptions(
|
||||
credentials: ChannelCredentials.insecure())));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
grpc: ^3.2.4
|
||||
path_provider: ^2.1.2
|
||||
plugin_platform_interface: ^2.0.2
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue