7
import 'package:cake_wallet/store/yat/yat_store.dart';
8
import 'package:cake_wallet/utils/exception_handler.dart';
9
import 'package:cake_wallet/utils/responsive_layout_util.dart';
10
+import 'package:cw_core/hive_type_ids.dart';
11
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
13
import 'package:flutter/services.dart';
39
import 'package:cw_core/unspent_coins_info.dart';
40
import 'package:cake_wallet/monero/monero.dart';
41
import 'package:cake_wallet/wallet_type_utils.dart';
42
+import 'package:cw_core/cake_hive.dart';
43
44
final navigatorKey = GlobalKey<NavigatorState>();
45
final rootKey = GlobalKey<RootState>();
59
return true;
60
};
61
60
- await Hive.close();
62
+ await CakeHive.close();
63
64
await initializeAppConfigs();
65
71
72
Future<void> initializeAppConfigs() async {
73
final appDir = await getApplicationDocumentsDirectory();
72
- Hive.init(appDir.path);
74
+ CakeHive.init(appDir.path);
75
74
- if (!Hive.isAdapterRegistered(Contact.typeId)) {
75
- Hive.registerAdapter(ContactAdapter());
76
+ if (!CakeHive.isAdapterRegistered(Contact.typeId)) {
77
+ CakeHive.registerAdapter(ContactAdapter());
78
}
79
78
- if (!Hive.isAdapterRegistered(Node.typeId)) {
79
- Hive.registerAdapter(NodeAdapter());
80
+ if (!CakeHive.isAdapterRegistered(Node.typeId)) {
81
+ CakeHive.registerAdapter(NodeAdapter());
82
}
83
82
- if (!Hive.isAdapterRegistered(TransactionDescription.typeId)) {
83
- Hive.registerAdapter(TransactionDescriptionAdapter());
84
+ if (!CakeHive.isAdapterRegistered(TransactionDescription.typeId)) {
85
+ CakeHive.registerAdapter(TransactionDescriptionAdapter());
86
}
87
86
- if (!Hive.isAdapterRegistered(Trade.typeId)) {
87
- Hive.registerAdapter(TradeAdapter());
88
+ if (!CakeHive.isAdapterRegistered(Trade.typeId)) {
89
+ CakeHive.registerAdapter(TradeAdapter());
90
}
91
90
- if (!Hive.isAdapterRegistered(WalletInfo.typeId)) {
91
- Hive.registerAdapter(WalletInfoAdapter());
92
+ if (!CakeHive.isAdapterRegistered(WalletInfo.typeId)) {
93
+ CakeHive.registerAdapter(WalletInfoAdapter());
94
}
95
94
- if (!Hive.isAdapterRegistered(walletTypeTypeId)) {
95
- Hive.registerAdapter(WalletTypeAdapter());
96
+ if (!CakeHive.isAdapterRegistered(WALLET_TYPE_TYPE_ID)) {
97
+ CakeHive.registerAdapter(WalletTypeAdapter());
98
}
99
98
- if (!Hive.isAdapterRegistered(Template.typeId)) {
99
- Hive.registerAdapter(TemplateAdapter());
100
+ if (!CakeHive.isAdapterRegistered(Template.typeId)) {
101
+ CakeHive.registerAdapter(TemplateAdapter());
102
}
103
102
- if (!Hive.isAdapterRegistered(ExchangeTemplate.typeId)) {
103
- Hive.registerAdapter(ExchangeTemplateAdapter());
104
+ if (!CakeHive.isAdapterRegistered(ExchangeTemplate.typeId)) {
105
+ CakeHive.registerAdapter(ExchangeTemplateAdapter());
106
}
107
106
- if (!Hive.isAdapterRegistered(Order.typeId)) {
107
- Hive.registerAdapter(OrderAdapter());
108
+ if (!CakeHive.isAdapterRegistered(Order.typeId)) {
109
+ CakeHive.registerAdapter(OrderAdapter());
110
}
111
110
- if (!isMoneroOnly && !Hive.isAdapterRegistered(UnspentCoinsInfo.typeId)) {
111
- Hive.registerAdapter(UnspentCoinsInfoAdapter());
112
+ if (!isMoneroOnly && !CakeHive.isAdapterRegistered(UnspentCoinsInfo.typeId)) {
113
+ CakeHive.registerAdapter(UnspentCoinsInfoAdapter());
114
}
115
114
- if (!Hive.isAdapterRegistered(AnonpayInvoiceInfo.typeId)) {
115
- Hive.registerAdapter(AnonpayInvoiceInfoAdapter());
116
+ if (!CakeHive.isAdapterRegistered(AnonpayInvoiceInfo.typeId)) {
117
+ CakeHive.registerAdapter(AnonpayInvoiceInfoAdapter());
118
}
119
120
final secureStorage = FlutterSecureStorage();
122
await getEncryptionKey(secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
123
final tradesBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Trade.boxKey);
124
final ordersBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Order.boxKey);
123
- final contacts = await Hive.openBox<Contact>(Contact.boxName);
124
- final nodes = await Hive.openBox<Node>(Node.boxName);
125
- final transactionDescriptions = await Hive.openBox<TransactionDescription>(
125
+ final contacts = await CakeHive.openBox<Contact>(Contact.boxName);
126
+ final nodes = await CakeHive.openBox<Node>(Node.boxName);
127
+ final transactionDescriptions = await CakeHive.openBox<TransactionDescription>(
128
TransactionDescription.boxName,
129
encryptionKey: transactionDescriptionsBoxKey);
128
- final trades = await Hive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
129
- final orders = await Hive.openBox<Order>(Order.boxName, encryptionKey: ordersBoxKey);
130
- final walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
131
- final templates = await Hive.openBox<Template>(Template.boxName);
132
- final exchangeTemplates = await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
133
- final anonpayInvoiceInfo = await Hive.openBox<AnonpayInvoiceInfo>(AnonpayInvoiceInfo.boxName);
130
+ final trades = await CakeHive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
131
+ final orders = await CakeHive.openBox<Order>(Order.boxName, encryptionKey: ordersBoxKey);
132
+ final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
133
+ final templates = await CakeHive.openBox<Template>(Template.boxName);
134
+ final exchangeTemplates = await CakeHive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
135
+ final anonpayInvoiceInfo = await CakeHive.openBox<AnonpayInvoiceInfo>(AnonpayInvoiceInfo.boxName);
136
Box<UnspentCoinsInfo>? unspentCoinsInfoSource;
137
138
if (!isMoneroOnly) {
137
- unspentCoinsInfoSource = await Hive.openBox<UnspentCoinsInfo>(UnspentCoinsInfo.boxName);
139
+ unspentCoinsInfoSource = await CakeHive.openBox<UnspentCoinsInfo>(UnspentCoinsInfo.boxName);
140
}
141
142
await initialSetup(