mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
remove unneeded buy type and buys service
no history needed at this time
This commit is contained in:
parent
7bfcaffc01
commit
79edf1292d
4 changed files with 1 additions and 280 deletions
|
@ -1,207 +0,0 @@
|
|||
import 'package:hive/hive.dart';
|
||||
|
||||
// part 'buy.g.dart';
|
||||
|
||||
@HiveType(typeId: Buy.typeId)
|
||||
class Buy {
|
||||
static const typeId = 22;
|
||||
|
||||
@HiveField(0)
|
||||
final String uuid;
|
||||
|
||||
@HiveField(1)
|
||||
final String buyId;
|
||||
|
||||
@HiveField(2)
|
||||
final String rateType;
|
||||
|
||||
@HiveField(3)
|
||||
final String direction;
|
||||
|
||||
@HiveField(4)
|
||||
final DateTime timestamp;
|
||||
|
||||
@HiveField(5)
|
||||
final DateTime updatedAt;
|
||||
|
||||
@HiveField(6)
|
||||
final String payInCurrency;
|
||||
|
||||
@HiveField(7)
|
||||
final String payInAmount;
|
||||
|
||||
@HiveField(8)
|
||||
final String payInAddress;
|
||||
|
||||
@HiveField(9)
|
||||
final String payInNetwork;
|
||||
|
||||
@HiveField(10)
|
||||
final String payInExtraId;
|
||||
|
||||
@HiveField(11)
|
||||
final String payInTxid;
|
||||
|
||||
@HiveField(12)
|
||||
final String payOutCurrency;
|
||||
|
||||
@HiveField(13)
|
||||
final String payOutAmount;
|
||||
|
||||
@HiveField(14)
|
||||
final String payOutAddress;
|
||||
|
||||
@HiveField(15)
|
||||
final String payOutNetwork;
|
||||
|
||||
@HiveField(16)
|
||||
final String payOutExtraId;
|
||||
|
||||
@HiveField(17)
|
||||
final String payOutTxid;
|
||||
|
||||
@HiveField(18)
|
||||
final String refundAddress;
|
||||
|
||||
@HiveField(19)
|
||||
final String refundExtraId;
|
||||
|
||||
@HiveField(20)
|
||||
final String status;
|
||||
|
||||
@HiveField(21)
|
||||
final String exchangeName;
|
||||
|
||||
const Buy({
|
||||
required this.uuid,
|
||||
required this.buyId,
|
||||
required this.rateType,
|
||||
required this.direction,
|
||||
required this.timestamp,
|
||||
required this.updatedAt,
|
||||
required this.payInCurrency,
|
||||
required this.payInAmount,
|
||||
required this.payInAddress,
|
||||
required this.payInNetwork,
|
||||
required this.payInExtraId,
|
||||
required this.payInTxid,
|
||||
required this.payOutCurrency,
|
||||
required this.payOutAmount,
|
||||
required this.payOutAddress,
|
||||
required this.payOutNetwork,
|
||||
required this.payOutExtraId,
|
||||
required this.payOutTxid,
|
||||
required this.refundAddress,
|
||||
required this.refundExtraId,
|
||||
required this.status,
|
||||
required this.exchangeName,
|
||||
});
|
||||
|
||||
Buy copyWith({
|
||||
String? buyId,
|
||||
String? rateType,
|
||||
String? direction,
|
||||
DateTime? timestamp,
|
||||
DateTime? updatedAt,
|
||||
String? payInCurrency,
|
||||
String? payInAmount,
|
||||
String? payInAddress,
|
||||
String? payInNetwork,
|
||||
String? payInExtraId,
|
||||
String? payInTxid,
|
||||
String? payOutCurrency,
|
||||
String? payOutAmount,
|
||||
String? payOutAddress,
|
||||
String? payOutNetwork,
|
||||
String? payOutExtraId,
|
||||
String? payOutTxid,
|
||||
String? refundAddress,
|
||||
String? refundExtraId,
|
||||
String? status,
|
||||
String? exchangeName,
|
||||
}) {
|
||||
return Buy(
|
||||
uuid: uuid,
|
||||
buyId: buyId ?? this.buyId,
|
||||
rateType: rateType ?? this.rateType,
|
||||
direction: direction ?? this.direction,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
payInCurrency: payInCurrency ?? this.payInCurrency,
|
||||
payInAmount: payInAmount ?? this.payInAmount,
|
||||
payInAddress: payInAddress ?? this.payInAddress,
|
||||
payInNetwork: payInNetwork ?? this.payInNetwork,
|
||||
payInExtraId: payInExtraId ?? this.payInExtraId,
|
||||
payInTxid: payInTxid ?? this.payInTxid,
|
||||
payOutCurrency: payOutCurrency ?? this.payOutCurrency,
|
||||
payOutAmount: payOutAmount ?? this.payOutAmount,
|
||||
payOutAddress: payOutAddress ?? this.payOutAddress,
|
||||
payOutNetwork: payOutNetwork ?? this.payOutNetwork,
|
||||
payOutExtraId: payOutExtraId ?? this.payOutExtraId,
|
||||
payOutTxid: payOutTxid ?? this.payOutTxid,
|
||||
refundAddress: refundAddress ?? this.refundAddress,
|
||||
refundExtraId: refundExtraId ?? this.refundExtraId,
|
||||
status: status ?? this.status,
|
||||
exchangeName: exchangeName ?? this.exchangeName,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, String> toMap() {
|
||||
return {
|
||||
"uuid": uuid,
|
||||
"buyId": buyId,
|
||||
"rateType": rateType,
|
||||
"direction": direction,
|
||||
"timestamp": timestamp.toIso8601String(),
|
||||
"updatedAt": updatedAt.toIso8601String(),
|
||||
"payInCurrency": payInCurrency,
|
||||
"payInAmount": payInAmount,
|
||||
"payInAddress": payInAddress,
|
||||
"payInNetwork": payInNetwork,
|
||||
"payInExtraId": payInExtraId,
|
||||
"payInTxid": payInTxid,
|
||||
"payOutCurrency": payOutCurrency,
|
||||
"payOutAmount": payOutAmount,
|
||||
"payOutAddress": payOutAddress,
|
||||
"payOutNetwork": payOutNetwork,
|
||||
"payOutExtraId": payOutExtraId,
|
||||
"payOutTxid": payOutTxid,
|
||||
"refundAddress": refundAddress,
|
||||
"refundExtraId": refundExtraId,
|
||||
"status": status,
|
||||
"exchangeName": exchangeName,
|
||||
};
|
||||
}
|
||||
|
||||
factory Buy.fromMap(Map<String, dynamic> map) {
|
||||
return Buy(
|
||||
uuid: map["uuid"] as String,
|
||||
buyId: map["buyId"] as String,
|
||||
rateType: map["rateType"] as String,
|
||||
direction: map["direction"] as String,
|
||||
timestamp: DateTime.parse(map["timestamp"] as String),
|
||||
updatedAt: DateTime.parse(map["updatedAt"] as String),
|
||||
payInCurrency: map["payInCurrency"] as String,
|
||||
payInAmount: map["payInAmount"] as String,
|
||||
payInAddress: map["payInAddress"] as String,
|
||||
payInNetwork: map["payInNetwork"] as String,
|
||||
payInExtraId: map["payInExtraId"] as String,
|
||||
payInTxid: map["payInTxid"] as String,
|
||||
payOutCurrency: map["payOutCurrency"] as String,
|
||||
payOutAmount: map["payOutAmount"] as String,
|
||||
payOutAddress: map["payOutAddress"] as String,
|
||||
payOutNetwork: map["payOutNetwork"] as String,
|
||||
payOutExtraId: map["payOutExtraId"] as String,
|
||||
payOutTxid: map["payOutTxid"] as String,
|
||||
refundAddress: map["refundAddress"] as String,
|
||||
refundExtraId: map["refundExtraId"] as String,
|
||||
status: map["status"] as String,
|
||||
exchangeName: map["exchangeName"] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return toMap().toString();
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/services/buys_service.dart';
|
||||
|
||||
final buysServiceProvider =
|
||||
ChangeNotifierProvider<BuysService>((ref) => BuysService());
|
|
@ -1,6 +1,6 @@
|
|||
export './buy/simplex_supported_currencies_provider.dart';
|
||||
export './buy/buy_form_state_provider.dart';
|
||||
export './buy/simplex_initial_load_status.dart';
|
||||
export './buy/simplex_supported_currencies_provider.dart';
|
||||
export './exchange/available_changenow_currencies_provider.dart';
|
||||
export './exchange/available_simpleswap_currencies_provider.dart';
|
||||
export './exchange/changenow_initial_load_status.dart';
|
||||
|
@ -11,7 +11,6 @@ export './exchange/exchange_provider.dart';
|
|||
export './exchange/exchange_send_from_wallet_id_provider.dart';
|
||||
export './exchange/trade_note_service_provider.dart';
|
||||
export './exchange/trade_sent_from_stack_lookup_provider.dart';
|
||||
export './global/buys_service_provider.dart';
|
||||
export './global/favorites_provider.dart';
|
||||
export './global/locale_provider.dart';
|
||||
export './global/node_service_provider.dart';
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/hive/db.dart';
|
||||
import 'package:stackwallet/models/buy/response_objects/buy.dart';
|
||||
|
||||
class BuysService extends ChangeNotifier {
|
||||
List<Buy> get Buys {
|
||||
final list = DB.instance.values<Buy>(boxName: DB.boxNameBuys);
|
||||
list.sort((a, b) =>
|
||||
b.timestamp.millisecondsSinceEpoch -
|
||||
a.timestamp.millisecondsSinceEpoch);
|
||||
return list;
|
||||
}
|
||||
|
||||
Buy? get(String buyId) {
|
||||
try {
|
||||
return DB.instance
|
||||
.values<Buy>(boxName: DB.boxNameBuys)
|
||||
.firstWhere((e) => e.buyId == buyId);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> add({
|
||||
required Buy buy,
|
||||
required bool shouldNotifyListeners,
|
||||
}) async {
|
||||
await DB.instance
|
||||
.put<Buy>(boxName: DB.boxNameBuys, key: buy.uuid, value: buy);
|
||||
|
||||
if (shouldNotifyListeners) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> edit({
|
||||
required Buy buy,
|
||||
required bool shouldNotifyListeners,
|
||||
}) async {
|
||||
if (DB.instance.get<Buy>(boxName: DB.boxNameBuys, key: buy.uuid) == null) {
|
||||
throw Exception("Attempted to edit a Buy that does not exist in Hive!");
|
||||
}
|
||||
|
||||
// add overwrites so this edit function is just a wrapper with an extra check
|
||||
await add(buy: buy, shouldNotifyListeners: shouldNotifyListeners);
|
||||
}
|
||||
|
||||
Future<void> delete({
|
||||
required Buy buy,
|
||||
required bool shouldNotifyListeners,
|
||||
}) async {
|
||||
await deleteByUuid(
|
||||
uuid: buy.uuid, shouldNotifyListeners: shouldNotifyListeners);
|
||||
}
|
||||
|
||||
Future<void> deleteByUuid({
|
||||
required String uuid,
|
||||
required bool shouldNotifyListeners,
|
||||
}) async {
|
||||
await DB.instance.delete<Buy>(boxName: DB.boxNameBuys, key: uuid);
|
||||
|
||||
if (shouldNotifyListeners) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue