57
return true;
58
};
59
60
- final appDir = await getApplicationDocumentsDirectory();
60
await Hive.close();
62
- Hive.init(appDir.path);
61
64
- if (!Hive.isAdapterRegistered(Contact.typeId)) {
65
- Hive.registerAdapter(ContactAdapter());
66
- }
62
+ await initializeAppConfigs();
63
68
- if (!Hive.isAdapterRegistered(Node.typeId)) {
69
- Hive.registerAdapter(NodeAdapter());
70
- }
64
+ runApp(App());
65
+ }, (error, stackTrace) async {
66
+ ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stackTrace));
67
+ });
68
+}
69
72
- if (!Hive.isAdapterRegistered(TransactionDescription.typeId)) {
73
- Hive.registerAdapter(TransactionDescriptionAdapter());
74
- }
70
+Future<void> initializeAppConfigs() async {
71
+ final appDir = await getApplicationDocumentsDirectory();
72
+ Hive.init(appDir.path);
73
76
- if (!Hive.isAdapterRegistered(Trade.typeId)) {
77
- Hive.registerAdapter(TradeAdapter());
78
- }
74
+ if (!Hive.isAdapterRegistered(Contact.typeId)) {
75
+ Hive.registerAdapter(ContactAdapter());
76
+ }
77
80
- if (!Hive.isAdapterRegistered(WalletInfo.typeId)) {
81
- Hive.registerAdapter(WalletInfoAdapter());
82
- }
78
+ if (!Hive.isAdapterRegistered(Node.typeId)) {
79
+ Hive.registerAdapter(NodeAdapter());
80
+ }
81
84
- if (!Hive.isAdapterRegistered(walletTypeTypeId)) {
85
- Hive.registerAdapter(WalletTypeAdapter());
86
- }
82
+ if (!Hive.isAdapterRegistered(TransactionDescription.typeId)) {
83
+ Hive.registerAdapter(TransactionDescriptionAdapter());
84
+ }
85
88
- if (!Hive.isAdapterRegistered(Template.typeId)) {
89
- Hive.registerAdapter(TemplateAdapter());
90
- }
86
+ if (!Hive.isAdapterRegistered(Trade.typeId)) {
87
+ Hive.registerAdapter(TradeAdapter());
88
+ }
89
92
- if (!Hive.isAdapterRegistered(ExchangeTemplate.typeId)) {
93
- Hive.registerAdapter(ExchangeTemplateAdapter());
94
- }
90
+ if (!Hive.isAdapterRegistered(WalletInfo.typeId)) {
91
+ Hive.registerAdapter(WalletInfoAdapter());
92
+ }
93
96
- if (!Hive.isAdapterRegistered(Order.typeId)) {
97
- Hive.registerAdapter(OrderAdapter());
98
- }
94
+ if (!Hive.isAdapterRegistered(walletTypeTypeId)) {
95
+ Hive.registerAdapter(WalletTypeAdapter());
96
+ }
97
100
- if (!isMoneroOnly && !Hive.isAdapterRegistered(UnspentCoinsInfo.typeId)) {
101
- Hive.registerAdapter(UnspentCoinsInfoAdapter());
102
- }
98
+ if (!Hive.isAdapterRegistered(Template.typeId)) {
99
+ Hive.registerAdapter(TemplateAdapter());
100
+ }
101
104
- if (!Hive.isAdapterRegistered(AnonpayInvoiceInfo.typeId)) {
105
- Hive.registerAdapter(AnonpayInvoiceInfoAdapter());
106
- }
102
+ if (!Hive.isAdapterRegistered(ExchangeTemplate.typeId)) {
103
+ Hive.registerAdapter(ExchangeTemplateAdapter());
104
+ }
105
108
- final secureStorage = FlutterSecureStorage();
109
- final transactionDescriptionsBoxKey =
110
- await getEncryptionKey(secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
111
- final tradesBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Trade.boxKey);
112
- final ordersBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Order.boxKey);
113
- final contacts = await Hive.openBox<Contact>(Contact.boxName);
114
- final nodes = await Hive.openBox<Node>(Node.boxName);
115
- final transactionDescriptions = await Hive.openBox<TransactionDescription>(
116
- TransactionDescription.boxName,
117
- encryptionKey: transactionDescriptionsBoxKey);
118
- final trades = await Hive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
119
- final orders = await Hive.openBox<Order>(Order.boxName, encryptionKey: ordersBoxKey);
120
- final walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
121
- final templates = await Hive.openBox<Template>(Template.boxName);
122
- final exchangeTemplates = await Hive.openBox<ExchangeTemplate>(ExchangeTemplate.boxName);
123
- final anonpayInvoiceInfo = await Hive.openBox<AnonpayInvoiceInfo>(AnonpayInvoiceInfo.boxName);
124
- Box<UnspentCoinsInfo>? unspentCoinsInfoSource;
125
-
126
- if (!isMoneroOnly) {
127
- unspentCoinsInfoSource = await Hive.openBox<UnspentCoinsInfo>(UnspentCoinsInfo.boxName);
128
- }
106
+ if (!Hive.isAdapterRegistered(Order.typeId)) {
107
+ Hive.registerAdapter(OrderAdapter());
108
+ }
109
130
- await initialSetup(
131
- sharedPreferences: await SharedPreferences.getInstance(),
132
- nodes: nodes,
133
- walletInfoSource: walletInfoSource,
134
- contactSource: contacts,
135
- tradesSource: trades,
136
- ordersSource: orders,
137
- unspentCoinsInfoSource: unspentCoinsInfoSource,
138
- // fiatConvertationService: fiatConvertationService,
139
- templates: templates,
140
- exchangeTemplates: exchangeTemplates,
141
- transactionDescriptions: transactionDescriptions,
142
- secureStorage: secureStorage,
143
- anonpayInvoiceInfo: anonpayInvoiceInfo,
144
- initialMigrationVersion: 21);
145
- runApp(App());
146
- }, (error, stackTrace) async {
147
- ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stackTrace));
148
- });
149
-}
110
+ if (!isMoneroOnly && !Hive.isAdapterRegistered(UnspentCoinsInfo.typeId)) {
111
+ Hive.registerAdapter(UnspentCoinsInfoAdapter());
112
+ }
113
+
114
+ if (!Hive.isAdapterRegistered(AnonpayInvoiceInfo.typeId)) {
115
+ Hive.registerAdapter(AnonpayInvoiceInfoAdapter());
116
+ }
117
+
118
+ final secureStorage = FlutterSecureStorage();
119
+ final transactionDescriptionsBoxKey =
120
+ await getEncryptionKey(secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
121
+ final tradesBoxKey = await getEncryptionKey(secureStorage: secureStorage, forKey: Trade.boxKey);
122
+ 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>(
126
+ TransactionDescription.boxName,
127
+ 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);
134
+ Box<UnspentCoinsInfo>? unspentCoinsInfoSource;
135
+
136
+ if (!isMoneroOnly) {
137
+ unspentCoinsInfoSource = await Hive.openBox<UnspentCoinsInfo>(UnspentCoinsInfo.boxName);
138
+ }
139
+
140
+ await initialSetup(
141
+ sharedPreferences: await SharedPreferences.getInstance(),
142
+ nodes: nodes,
143
+ walletInfoSource: walletInfoSource,
144
+ contactSource: contacts,
145
+ tradesSource: trades,
146
+ ordersSource: orders,
147
+ unspentCoinsInfoSource: unspentCoinsInfoSource,
148
+ // fiatConvertationService: fiatConvertationService,
149
+ templates: templates,
150
+ exchangeTemplates: exchangeTemplates,
151
+ transactionDescriptions: transactionDescriptions,
152
+ secureStorage: secureStorage,
153
+ anonpayInvoiceInfo: anonpayInvoiceInfo,
154
+ initialMigrationVersion: 21);
155
+ }
156
157
Future<void> initialSetup(
158
{required SharedPreferences sharedPreferences,
325
}
326
327
}
322
-
328
+
329
@override
330
Widget build(BuildContext context) {
331
return const SizedBox.shrink();