From 1a7439f6a60f5657f224688abbf4ec8cbe773254 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 21:16:45 -0600 Subject: [PATCH] isar model updates --- lib/models/isar/models/address/address.dart | 1 + lib/models/isar/models/address/address.g.dart | 2 + .../models/blockchain_data/transaction.dart | 10 +- .../models/blockchain_data/transaction.g.dart | 121 ++++++++++++++---- 4 files changed, 105 insertions(+), 29 deletions(-) diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 367a3fab4..d40305be9 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -49,6 +49,7 @@ enum AddressType { p2pkh, p2sh, p2wpkh, + cryptonote, } enum AddressSubType { diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 44d5c1d71..808b182f9 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -171,11 +171,13 @@ const _AddresstypeEnumValueMap = { 'p2pkh': 0, 'p2sh': 1, 'p2wpkh': 2, + 'cryptonote': 3, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, 1: AddressType.p2sh, 2: AddressType.p2wpkh, + 3: AddressType.cryptonote, }; Id _addressGetId(Address object) { diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 7c984b96a..4c87f8302 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -36,6 +36,8 @@ class Transaction { late bool isCancelled; + late bool? isLelantus; + late String? slateId; late String? otherData; @@ -65,9 +67,7 @@ enum TransactionType { outgoing, incoming, sentToSelf, // should we keep this? - unknown, - anonymize; // firo specific - + unknown; } // Used in Isar db and stored there as int indexes so adding/removing values @@ -76,6 +76,6 @@ enum TransactionSubType { // TODO: add more types before prod release? none, bip47Notification, // bip47 payment code notification transaction flag - mint; // firo specific - + mint, // firo specific + join; // firo specific } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 42261d9e0..b12911d1d 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -42,34 +42,39 @@ const TransactionSchema = CollectionSchema( name: r'isCancelled', type: IsarType.bool, ), - r'otherData': PropertySchema( + r'isLelantus': PropertySchema( id: 5, + name: r'isLelantus', + type: IsarType.bool, + ), + r'otherData': PropertySchema( + id: 6, name: r'otherData', type: IsarType.string, ), r'slateId': PropertySchema( - id: 6, + id: 7, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 7, + id: 8, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 8, + id: 9, name: r'timestamp', type: IsarType.long, ), r'txid': PropertySchema( - id: 9, + id: 10, name: r'txid', type: IsarType.string, ), r'type': PropertySchema( - id: 10, + id: 11, name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, @@ -170,12 +175,13 @@ void _transactionSerialize( writer.writeLong(offsets[2], object.fee); writer.writeLong(offsets[3], object.height); writer.writeBool(offsets[4], object.isCancelled); - writer.writeString(offsets[5], object.otherData); - writer.writeString(offsets[6], object.slateId); - writer.writeByte(offsets[7], object.subType.index); - writer.writeLong(offsets[8], object.timestamp); - writer.writeString(offsets[9], object.txid); - writer.writeByte(offsets[10], object.type.index); + writer.writeBool(offsets[5], object.isLelantus); + writer.writeString(offsets[6], object.otherData); + writer.writeString(offsets[7], object.slateId); + writer.writeByte(offsets[8], object.subType.index); + writer.writeLong(offsets[9], object.timestamp); + writer.writeString(offsets[10], object.txid); + writer.writeByte(offsets[11], object.type.index); } Transaction _transactionDeserialize( @@ -191,15 +197,16 @@ Transaction _transactionDeserialize( object.height = reader.readLongOrNull(offsets[3]); object.id = id; object.isCancelled = reader.readBool(offsets[4]); - object.otherData = reader.readStringOrNull(offsets[5]); - object.slateId = reader.readStringOrNull(offsets[6]); + object.isLelantus = reader.readBoolOrNull(offsets[5]); + object.otherData = reader.readStringOrNull(offsets[6]); + object.slateId = reader.readStringOrNull(offsets[7]); object.subType = - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ?? TransactionSubType.none; - object.timestamp = reader.readLong(offsets[8]); - object.txid = reader.readString(offsets[9]); + object.timestamp = reader.readLong(offsets[9]); + object.txid = reader.readString(offsets[10]); object.type = - _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ?? + _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? TransactionType.outgoing; return object; } @@ -222,17 +229,19 @@ P _transactionDeserializeProp

( case 4: return (reader.readBool(offset)) as P; case 5: - return (reader.readStringOrNull(offset)) as P; + return (reader.readBoolOrNull(offset)) as P; case 6: return (reader.readStringOrNull(offset)) as P; case 7: + return (reader.readStringOrNull(offset)) as P; + case 8: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 8: - return (reader.readLong(offset)) as P; case 9: - return (reader.readString(offset)) as P; + return (reader.readLong(offset)) as P; case 10: + return (reader.readString(offset)) as P; + case 11: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; default: @@ -244,25 +253,25 @@ const _TransactionsubTypeEnumValueMap = { 'none': 0, 'bip47Notification': 1, 'mint': 2, + 'join': 3, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, + 3: TransactionSubType.join, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, 'incoming': 1, 'sentToSelf': 2, 'unknown': 3, - 'anonymize': 4, }; const _TransactiontypeValueEnumMap = { 0: TransactionType.outgoing, 1: TransactionType.incoming, 2: TransactionType.sentToSelf, 3: TransactionType.unknown, - 4: TransactionType.anonymize, }; Id _transactionGetId(Transaction object) { @@ -935,6 +944,34 @@ extension TransactionQueryFilter }); } + QueryBuilder + isLelantusIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'isLelantus', + )); + }); + } + + QueryBuilder + isLelantusIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'isLelantus', + )); + }); + } + + QueryBuilder + isLelantusEqualTo(bool? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isLelantus', + value: value, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1739,6 +1776,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.asc); + }); + } + + QueryBuilder sortByIsLelantusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1886,6 +1935,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.asc); + }); + } + + QueryBuilder thenByIsLelantusDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isLelantus', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -1992,6 +2053,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByIsLelantus() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isLelantus'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2070,6 +2137,12 @@ extension TransactionQueryProperty }); } + QueryBuilder isLelantusProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isLelantus'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData');