mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-25 04:49:36 +00:00
61 lines
1 KiB
Dart
61 lines
1 KiB
Dart
import 'package:isar/isar.dart';
|
|
|
|
part 'pair.g.dart';
|
|
|
|
// embedded enum // no not modify
|
|
enum SupportedRateType { fixed, estimated, both }
|
|
|
|
@collection
|
|
class Pair {
|
|
Pair({
|
|
required this.exchangeName,
|
|
required this.from,
|
|
required this.to,
|
|
required this.rateType,
|
|
});
|
|
|
|
Id? id;
|
|
|
|
@Index()
|
|
final String exchangeName;
|
|
|
|
@Index(composite: [
|
|
CompositeIndex("exchangeName"),
|
|
CompositeIndex("to"),
|
|
])
|
|
final String from;
|
|
|
|
final String to;
|
|
|
|
@enumerated
|
|
final SupportedRateType rateType;
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
"id": id,
|
|
"exchangeName": exchangeName,
|
|
"from": from,
|
|
"to": to,
|
|
"rateType": rateType,
|
|
};
|
|
}
|
|
|
|
@override
|
|
bool operator ==(other) =>
|
|
other is Pair &&
|
|
exchangeName == other.exchangeName &&
|
|
from == other.from &&
|
|
to == other.to &&
|
|
rateType == other.rateType;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
exchangeName,
|
|
from,
|
|
to,
|
|
rateType,
|
|
);
|
|
|
|
@override
|
|
String toString() => "Pair: ${toMap()}";
|
|
}
|