2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-02-04 15:16:05 +00:00
|
|
|
import 'package:decimal/decimal.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import 'mb_object.dart';
|
2023-02-04 15:16:05 +00:00
|
|
|
|
|
|
|
enum MBOrderType {
|
|
|
|
fixed,
|
|
|
|
floating,
|
|
|
|
}
|
|
|
|
|
|
|
|
class MBOrder extends MBObject {
|
|
|
|
MBOrder({
|
|
|
|
required this.orderId,
|
|
|
|
required this.fromCurrency,
|
|
|
|
required this.fromAmount,
|
|
|
|
required this.receiveCurrency,
|
|
|
|
required this.receiveAmount,
|
|
|
|
required this.address,
|
|
|
|
required this.orderType,
|
|
|
|
required this.expiration,
|
|
|
|
required this.createdAt,
|
|
|
|
});
|
|
|
|
|
|
|
|
final String orderId;
|
|
|
|
final String fromCurrency;
|
|
|
|
final Decimal fromAmount;
|
|
|
|
final String receiveCurrency;
|
|
|
|
final String address;
|
|
|
|
final Decimal receiveAmount;
|
|
|
|
final MBOrderType orderType;
|
|
|
|
|
|
|
|
/// minutes
|
|
|
|
final int expiration;
|
|
|
|
|
|
|
|
final DateTime createdAt;
|
|
|
|
|
|
|
|
bool isExpired() =>
|
|
|
|
(DateTime.now().difference(createdAt) >= Duration(minutes: expiration));
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
// todo: full toString
|
|
|
|
return orderId;
|
|
|
|
}
|
|
|
|
}
|