isar lelantus coin schema

This commit is contained in:
julian 2023-07-24 09:06:48 -06:00
parent 6ff4c5d49a
commit baa34ca9f2
3 changed files with 1647 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/exceptions/main_db/main_db_exception.dart'; import 'package:stackwallet/exceptions/main_db/main_db_exception.dart';
import 'package:stackwallet/models/isar/models/block_explorer.dart'; import 'package:stackwallet/models/isar/models/block_explorer.dart';
import 'package:stackwallet/models/isar/models/contact_entry.dart'; import 'package:stackwallet/models/isar/models/contact_entry.dart';
import 'package:stackwallet/models/isar/models/firo_specific/lelantus_coin.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount.dart';
@ -54,6 +55,7 @@ class MainDB {
TransactionBlockExplorerSchema, TransactionBlockExplorerSchema,
StackThemeSchema, StackThemeSchema,
ContactEntrySchema, ContactEntrySchema,
LelantusCoinSchema,
], ],
directory: (await StackFileSystem.applicationIsarDirectory()).path, directory: (await StackFileSystem.applicationIsarDirectory()).path,
// inspector: kDebugMode, // inspector: kDebugMode,

View file

@ -0,0 +1,75 @@
import 'package:isar/isar.dart';
part 'lelantus_coin.g.dart';
@collection
class LelantusCoin {
Id id = Isar.autoIncrement;
@Index()
final String walletId;
@Index(
unique: true,
composite: [
CompositeIndex("walletId"),
CompositeIndex("txid"),
],
replace: false,
)
final String publicCoin;
final String txid;
final String value; // can't use BigInt in isar :shrug:
final int index;
final int anonymitySetId;
final bool isUsed;
LelantusCoin({
required this.walletId,
required this.publicCoin,
required this.txid,
required this.value,
required this.index,
required this.anonymitySetId,
required this.isUsed,
});
LelantusCoin copyWith({
String? walletId,
String? publicCoin,
String? txid,
String? value,
int? index,
int? anonymitySetId,
bool? isUsed,
}) {
return LelantusCoin(
walletId: walletId ?? this.walletId,
publicCoin: publicCoin ?? this.publicCoin,
txid: txid ?? this.txid,
value: value ?? this.value,
index: index ?? this.index,
anonymitySetId: anonymitySetId ?? this.anonymitySetId,
isUsed: isUsed ?? this.isUsed,
);
}
@override
String toString() {
return 'LelantusCoin{'
'id: $id, '
'walletId: $walletId, '
'publicCoin: $publicCoin, '
'txid: $txid, '
'value: $value, '
'index: $index, '
'anonymitySetId: $anonymitySetId, '
'isUsed: $isUsed'
'}';
}
}

File diff suppressed because it is too large Load diff