| 1 | import 'dart:io'; |
| 2 | |
| 3 | import 'package:cw_core/balance.dart'; |
| 4 | import 'package:cw_core/pathForWallet.dart'; |
| 5 | import 'package:cw_core/transaction_history.dart'; |
| 6 | import 'package:cw_core/transaction_info.dart'; |
| 7 | import 'package:cw_core/wallet_base.dart'; |
| 8 | import 'package:cw_core/wallet_credentials.dart'; |
| 9 | import 'package:cw_core/wallet_info.dart'; |
| 10 | import 'package:cw_core/wallet_service.dart'; |
| 11 | import 'package:cw_core/wallet_type.dart'; |
| 12 | import 'package:hive/hive.dart'; |
| 13 | |
| 14 | class HavenWalletService extends WalletService { |
| 15 | HavenWalletService(); |
| 16 | |
| 17 | @override |
| 18 | WalletType getType() => WalletType.haven; |
| 19 | |
| 20 | @override |
| 21 | Future<void> remove(String wallet) async { |
| 22 | final path = await pathForWalletDir(name: wallet, type: getType()); |
| 23 | |
| 24 | final file = Directory(path); |
| 25 | final isExist = file.existsSync(); |
| 26 | |
| 27 | if (isExist) { |
| 28 | await file.delete(recursive: true); |
| 29 | } |
| 30 | |
| 31 | final walletInfo = await WalletInfo.get(wallet, getType()); |
| 32 | if (walletInfo == null) { |
| 33 | throw Exception('Wallet not found'); |
| 34 | } |
| 35 | await WalletInfo.delete(walletInfo); |
| 36 | } |
| 37 | |
| 38 | @override |
| 39 | Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> create( |
| 40 | WalletCredentials credentials, |
| 41 | {bool? isTestnet}) { |
| 42 | throw UnimplementedError(); |
| 43 | } |
| 44 | |
| 45 | @override |
| 46 | Future<bool> isWalletExit(String name) { |
| 47 | throw UnimplementedError(); |
| 48 | } |
| 49 | |
| 50 | @override |
| 51 | Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> openWallet( |
| 52 | String name, String password) { |
| 53 | throw UnimplementedError(); |
| 54 | } |
| 55 | |
| 56 | @override |
| 57 | Future<void> rename(String currentName, String password, String newName) { |
| 58 | throw UnimplementedError(); |
| 59 | } |
| 60 | |
| 61 | @override |
| 62 | Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> |
| 63 | restoreFromHardwareWallet(WalletCredentials credentials) { |
| 64 | throw UnimplementedError(); |
| 65 | } |
| 66 | |
| 67 | @override |
| 68 | Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> |
| 69 | restoreFromKeys(WalletCredentials credentials, {bool? isTestnet}) { |
| 70 | throw UnimplementedError(); |
| 71 | } |
| 72 | |
| 73 | @override |
| 74 | Future<WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>> |
| 75 | restoreFromSeed(WalletCredentials credentials, {bool? isTestnet}) { |
| 76 | throw UnimplementedError(); |
| 77 | } |
| 78 | } |