2021-04-12 18:22:22 +00:00
|
|
|
import 'package:cake_wallet/buy/buy_provider_description.dart';
|
2021-03-12 19:04:37 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:cake_wallet/exchange/trade_state.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/format_amount.dart';
|
2021-03-12 19:04:37 +00:00
|
|
|
|
|
|
|
part 'order.g.dart';
|
|
|
|
|
|
|
|
@HiveType(typeId: Order.typeId)
|
|
|
|
class Order extends HiveObject {
|
|
|
|
Order(
|
|
|
|
{this.id,
|
2021-04-12 18:22:22 +00:00
|
|
|
BuyProviderDescription provider,
|
2021-03-12 19:04:37 +00:00
|
|
|
this.transferId,
|
|
|
|
this.from,
|
|
|
|
this.to,
|
|
|
|
TradeState state,
|
|
|
|
this.createdAt,
|
|
|
|
this.amount,
|
|
|
|
this.receiveAddress,
|
|
|
|
this.walletId})
|
2021-04-12 18:22:22 +00:00
|
|
|
: providerRaw = provider?.raw,
|
|
|
|
stateRaw = state?.raw;
|
2021-03-12 19:04:37 +00:00
|
|
|
|
|
|
|
static const typeId = 8;
|
|
|
|
static const boxName = 'Orders';
|
|
|
|
static const boxKey = 'ordersBoxKey';
|
|
|
|
|
|
|
|
@HiveField(0)
|
|
|
|
String id;
|
|
|
|
|
|
|
|
@HiveField(1)
|
|
|
|
String transferId;
|
|
|
|
|
|
|
|
@HiveField(2)
|
|
|
|
String from;
|
|
|
|
|
|
|
|
@HiveField(3)
|
|
|
|
String to;
|
|
|
|
|
|
|
|
@HiveField(4)
|
|
|
|
String stateRaw;
|
|
|
|
|
|
|
|
TradeState get state => TradeState.deserialize(raw: stateRaw);
|
|
|
|
|
|
|
|
@HiveField(5)
|
|
|
|
DateTime createdAt;
|
|
|
|
|
|
|
|
@HiveField(6)
|
|
|
|
String amount;
|
|
|
|
|
|
|
|
@HiveField(7)
|
|
|
|
String receiveAddress;
|
|
|
|
|
|
|
|
@HiveField(8)
|
|
|
|
String walletId;
|
|
|
|
|
2021-04-12 18:22:22 +00:00
|
|
|
@HiveField(9)
|
|
|
|
int providerRaw;
|
|
|
|
|
|
|
|
BuyProviderDescription get provider =>
|
|
|
|
BuyProviderDescription.deserialize(raw: providerRaw);
|
|
|
|
|
2021-03-12 19:04:37 +00:00
|
|
|
String amountFormatted() => formatAmount(amount);
|
|
|
|
}
|