isar model updates

This commit is contained in:
julian 2023-01-11 21:16:45 -06:00
parent 3a185ead9a
commit 1a7439f6a6
4 changed files with 105 additions and 29 deletions

View file

@ -49,6 +49,7 @@ enum AddressType {
p2pkh,
p2sh,
p2wpkh,
cryptonote,
}
enum AddressSubType {

View file

@ -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) {

View file

@ -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
}

View file

@ -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<P>(
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<Transaction, Transaction, QAfterFilterCondition>
isLelantusIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'isLelantus',
));
});
}
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
isLelantusIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'isLelantus',
));
});
}
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
isLelantusEqualTo(bool? value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'isLelantus',
value: value,
));
});
}
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
otherDataIsNull() {
return QueryBuilder.apply(this, (query) {
@ -1739,6 +1776,18 @@ extension TransactionQuerySortBy
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByIsLelantus() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isLelantus', Sort.asc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByIsLelantusDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isLelantus', Sort.desc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByOtherData() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc);
@ -1886,6 +1935,18 @@ extension TransactionQuerySortThenBy
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByIsLelantus() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isLelantus', Sort.asc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByIsLelantusDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isLelantus', Sort.desc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByOtherData() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc);
@ -1992,6 +2053,12 @@ extension TransactionQueryWhereDistinct
});
}
QueryBuilder<Transaction, Transaction, QDistinct> distinctByIsLelantus() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'isLelantus');
});
}
QueryBuilder<Transaction, Transaction, QDistinct> distinctByOtherData(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
@ -2070,6 +2137,12 @@ extension TransactionQueryProperty
});
}
QueryBuilder<Transaction, bool?, QQueryOperations> isLelantusProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'isLelantus');
});
}
QueryBuilder<Transaction, String?, QQueryOperations> otherDataProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'otherData');