mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-22 15:19:11 +00:00
isar model updates
This commit is contained in:
parent
3a185ead9a
commit
1a7439f6a6
4 changed files with 105 additions and 29 deletions
|
@ -49,6 +49,7 @@ enum AddressType {
|
||||||
p2pkh,
|
p2pkh,
|
||||||
p2sh,
|
p2sh,
|
||||||
p2wpkh,
|
p2wpkh,
|
||||||
|
cryptonote,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AddressSubType {
|
enum AddressSubType {
|
||||||
|
|
|
@ -171,11 +171,13 @@ const _AddresstypeEnumValueMap = {
|
||||||
'p2pkh': 0,
|
'p2pkh': 0,
|
||||||
'p2sh': 1,
|
'p2sh': 1,
|
||||||
'p2wpkh': 2,
|
'p2wpkh': 2,
|
||||||
|
'cryptonote': 3,
|
||||||
};
|
};
|
||||||
const _AddresstypeValueEnumMap = {
|
const _AddresstypeValueEnumMap = {
|
||||||
0: AddressType.p2pkh,
|
0: AddressType.p2pkh,
|
||||||
1: AddressType.p2sh,
|
1: AddressType.p2sh,
|
||||||
2: AddressType.p2wpkh,
|
2: AddressType.p2wpkh,
|
||||||
|
3: AddressType.cryptonote,
|
||||||
};
|
};
|
||||||
|
|
||||||
Id _addressGetId(Address object) {
|
Id _addressGetId(Address object) {
|
||||||
|
|
|
@ -36,6 +36,8 @@ class Transaction {
|
||||||
|
|
||||||
late bool isCancelled;
|
late bool isCancelled;
|
||||||
|
|
||||||
|
late bool? isLelantus;
|
||||||
|
|
||||||
late String? slateId;
|
late String? slateId;
|
||||||
|
|
||||||
late String? otherData;
|
late String? otherData;
|
||||||
|
@ -65,9 +67,7 @@ enum TransactionType {
|
||||||
outgoing,
|
outgoing,
|
||||||
incoming,
|
incoming,
|
||||||
sentToSelf, // should we keep this?
|
sentToSelf, // should we keep this?
|
||||||
unknown,
|
unknown;
|
||||||
anonymize; // firo specific
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used in Isar db and stored there as int indexes so adding/removing values
|
// 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?
|
// TODO: add more types before prod release?
|
||||||
none,
|
none,
|
||||||
bip47Notification, // bip47 payment code notification transaction flag
|
bip47Notification, // bip47 payment code notification transaction flag
|
||||||
mint; // firo specific
|
mint, // firo specific
|
||||||
|
join; // firo specific
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,34 +42,39 @@ const TransactionSchema = CollectionSchema(
|
||||||
name: r'isCancelled',
|
name: r'isCancelled',
|
||||||
type: IsarType.bool,
|
type: IsarType.bool,
|
||||||
),
|
),
|
||||||
r'otherData': PropertySchema(
|
r'isLelantus': PropertySchema(
|
||||||
id: 5,
|
id: 5,
|
||||||
|
name: r'isLelantus',
|
||||||
|
type: IsarType.bool,
|
||||||
|
),
|
||||||
|
r'otherData': PropertySchema(
|
||||||
|
id: 6,
|
||||||
name: r'otherData',
|
name: r'otherData',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'slateId': PropertySchema(
|
r'slateId': PropertySchema(
|
||||||
id: 6,
|
id: 7,
|
||||||
name: r'slateId',
|
name: r'slateId',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'subType': PropertySchema(
|
r'subType': PropertySchema(
|
||||||
id: 7,
|
id: 8,
|
||||||
name: r'subType',
|
name: r'subType',
|
||||||
type: IsarType.byte,
|
type: IsarType.byte,
|
||||||
enumMap: _TransactionsubTypeEnumValueMap,
|
enumMap: _TransactionsubTypeEnumValueMap,
|
||||||
),
|
),
|
||||||
r'timestamp': PropertySchema(
|
r'timestamp': PropertySchema(
|
||||||
id: 8,
|
id: 9,
|
||||||
name: r'timestamp',
|
name: r'timestamp',
|
||||||
type: IsarType.long,
|
type: IsarType.long,
|
||||||
),
|
),
|
||||||
r'txid': PropertySchema(
|
r'txid': PropertySchema(
|
||||||
id: 9,
|
id: 10,
|
||||||
name: r'txid',
|
name: r'txid',
|
||||||
type: IsarType.string,
|
type: IsarType.string,
|
||||||
),
|
),
|
||||||
r'type': PropertySchema(
|
r'type': PropertySchema(
|
||||||
id: 10,
|
id: 11,
|
||||||
name: r'type',
|
name: r'type',
|
||||||
type: IsarType.byte,
|
type: IsarType.byte,
|
||||||
enumMap: _TransactiontypeEnumValueMap,
|
enumMap: _TransactiontypeEnumValueMap,
|
||||||
|
@ -170,12 +175,13 @@ void _transactionSerialize(
|
||||||
writer.writeLong(offsets[2], object.fee);
|
writer.writeLong(offsets[2], object.fee);
|
||||||
writer.writeLong(offsets[3], object.height);
|
writer.writeLong(offsets[3], object.height);
|
||||||
writer.writeBool(offsets[4], object.isCancelled);
|
writer.writeBool(offsets[4], object.isCancelled);
|
||||||
writer.writeString(offsets[5], object.otherData);
|
writer.writeBool(offsets[5], object.isLelantus);
|
||||||
writer.writeString(offsets[6], object.slateId);
|
writer.writeString(offsets[6], object.otherData);
|
||||||
writer.writeByte(offsets[7], object.subType.index);
|
writer.writeString(offsets[7], object.slateId);
|
||||||
writer.writeLong(offsets[8], object.timestamp);
|
writer.writeByte(offsets[8], object.subType.index);
|
||||||
writer.writeString(offsets[9], object.txid);
|
writer.writeLong(offsets[9], object.timestamp);
|
||||||
writer.writeByte(offsets[10], object.type.index);
|
writer.writeString(offsets[10], object.txid);
|
||||||
|
writer.writeByte(offsets[11], object.type.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction _transactionDeserialize(
|
Transaction _transactionDeserialize(
|
||||||
|
@ -191,15 +197,16 @@ Transaction _transactionDeserialize(
|
||||||
object.height = reader.readLongOrNull(offsets[3]);
|
object.height = reader.readLongOrNull(offsets[3]);
|
||||||
object.id = id;
|
object.id = id;
|
||||||
object.isCancelled = reader.readBool(offsets[4]);
|
object.isCancelled = reader.readBool(offsets[4]);
|
||||||
object.otherData = reader.readStringOrNull(offsets[5]);
|
object.isLelantus = reader.readBoolOrNull(offsets[5]);
|
||||||
object.slateId = reader.readStringOrNull(offsets[6]);
|
object.otherData = reader.readStringOrNull(offsets[6]);
|
||||||
|
object.slateId = reader.readStringOrNull(offsets[7]);
|
||||||
object.subType =
|
object.subType =
|
||||||
_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ??
|
_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ??
|
||||||
TransactionSubType.none;
|
TransactionSubType.none;
|
||||||
object.timestamp = reader.readLong(offsets[8]);
|
object.timestamp = reader.readLong(offsets[9]);
|
||||||
object.txid = reader.readString(offsets[9]);
|
object.txid = reader.readString(offsets[10]);
|
||||||
object.type =
|
object.type =
|
||||||
_TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ??
|
_TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[11])] ??
|
||||||
TransactionType.outgoing;
|
TransactionType.outgoing;
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -222,17 +229,19 @@ P _transactionDeserializeProp<P>(
|
||||||
case 4:
|
case 4:
|
||||||
return (reader.readBool(offset)) as P;
|
return (reader.readBool(offset)) as P;
|
||||||
case 5:
|
case 5:
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readBoolOrNull(offset)) as P;
|
||||||
case 6:
|
case 6:
|
||||||
return (reader.readStringOrNull(offset)) as P;
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
case 7:
|
case 7:
|
||||||
|
return (reader.readStringOrNull(offset)) as P;
|
||||||
|
case 8:
|
||||||
return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||||
TransactionSubType.none) as P;
|
TransactionSubType.none) as P;
|
||||||
case 8:
|
|
||||||
return (reader.readLong(offset)) as P;
|
|
||||||
case 9:
|
case 9:
|
||||||
return (reader.readString(offset)) as P;
|
return (reader.readLong(offset)) as P;
|
||||||
case 10:
|
case 10:
|
||||||
|
return (reader.readString(offset)) as P;
|
||||||
|
case 11:
|
||||||
return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||||
TransactionType.outgoing) as P;
|
TransactionType.outgoing) as P;
|
||||||
default:
|
default:
|
||||||
|
@ -244,25 +253,25 @@ const _TransactionsubTypeEnumValueMap = {
|
||||||
'none': 0,
|
'none': 0,
|
||||||
'bip47Notification': 1,
|
'bip47Notification': 1,
|
||||||
'mint': 2,
|
'mint': 2,
|
||||||
|
'join': 3,
|
||||||
};
|
};
|
||||||
const _TransactionsubTypeValueEnumMap = {
|
const _TransactionsubTypeValueEnumMap = {
|
||||||
0: TransactionSubType.none,
|
0: TransactionSubType.none,
|
||||||
1: TransactionSubType.bip47Notification,
|
1: TransactionSubType.bip47Notification,
|
||||||
2: TransactionSubType.mint,
|
2: TransactionSubType.mint,
|
||||||
|
3: TransactionSubType.join,
|
||||||
};
|
};
|
||||||
const _TransactiontypeEnumValueMap = {
|
const _TransactiontypeEnumValueMap = {
|
||||||
'outgoing': 0,
|
'outgoing': 0,
|
||||||
'incoming': 1,
|
'incoming': 1,
|
||||||
'sentToSelf': 2,
|
'sentToSelf': 2,
|
||||||
'unknown': 3,
|
'unknown': 3,
|
||||||
'anonymize': 4,
|
|
||||||
};
|
};
|
||||||
const _TransactiontypeValueEnumMap = {
|
const _TransactiontypeValueEnumMap = {
|
||||||
0: TransactionType.outgoing,
|
0: TransactionType.outgoing,
|
||||||
1: TransactionType.incoming,
|
1: TransactionType.incoming,
|
||||||
2: TransactionType.sentToSelf,
|
2: TransactionType.sentToSelf,
|
||||||
3: TransactionType.unknown,
|
3: TransactionType.unknown,
|
||||||
4: TransactionType.anonymize,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Id _transactionGetId(Transaction object) {
|
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>
|
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||||
otherDataIsNull() {
|
otherDataIsNull() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
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() {
|
QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByOtherData() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
return QueryBuilder.apply(this, (query) {
|
||||||
return query.addSortBy(r'otherData', Sort.asc);
|
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() {
|
QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByOtherData() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
return QueryBuilder.apply(this, (query) {
|
||||||
return query.addSortBy(r'otherData', Sort.asc);
|
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(
|
QueryBuilder<Transaction, Transaction, QDistinct> distinctByOtherData(
|
||||||
{bool caseSensitive = true}) {
|
{bool caseSensitive = true}) {
|
||||||
return QueryBuilder.apply(this, (query) {
|
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() {
|
QueryBuilder<Transaction, String?, QQueryOperations> otherDataProperty() {
|
||||||
return QueryBuilder.apply(this, (query) {
|
return QueryBuilder.apply(this, (query) {
|
||||||
return query.addPropertyName(r'otherData');
|
return query.addPropertyName(r'otherData');
|
||||||
|
|
Loading…
Reference in a new issue