From e99ef7497ccace909a8ee9da158ed2eb679a4702 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 Mar 2023 09:38:17 -0600 Subject: [PATCH] update eth contract isar model class --- .../isar/models/ethereum/eth_contract.dart | 9 +- .../isar/models/ethereum/eth_contract.g.dart | 488 +----------------- 2 files changed, 16 insertions(+), 481 deletions(-) diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart index 391c2364a..d969cd503 100644 --- a/lib/models/isar/models/ethereum/eth_contract.dart +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -11,9 +11,7 @@ class EthContract extends Contract { required this.symbol, required this.decimals, required this.type, - required this.walletIds, this.abi, - this.otherData, }); Id id = Isar.autoIncrement; @@ -29,13 +27,9 @@ class EthContract extends Contract { late final String? abi; - late final List walletIds; - @enumerated late final EthContractType type; - late final String? otherData; - EthContract copyWith({ Id? id, String? address, @@ -53,15 +47,14 @@ class EthContract extends Contract { symbol: symbol ?? this.symbol, decimals: decimals ?? this.decimals, type: type ?? this.type, - walletIds: walletIds ?? this.walletIds, abi: abi ?? this.abi, - otherData: otherData ?? this.otherData, )..id = id ?? this.id; } // Used in Isar db and stored there as int indexes so adding/removing values // in this definition should be done extremely carefully in production enum EthContractType { + unknown, erc20, erc721; } diff --git a/lib/models/isar/models/ethereum/eth_contract.g.dart b/lib/models/isar/models/ethereum/eth_contract.g.dart index d5bf8f0fe..bc9548e8d 100644 --- a/lib/models/isar/models/ethereum/eth_contract.g.dart +++ b/lib/models/isar/models/ethereum/eth_contract.g.dart @@ -37,26 +37,16 @@ const EthContractSchema = CollectionSchema( name: r'name', type: IsarType.string, ), - r'otherData': PropertySchema( - id: 4, - name: r'otherData', - type: IsarType.string, - ), r'symbol': PropertySchema( - id: 5, + id: 4, name: r'symbol', type: IsarType.string, ), r'type': PropertySchema( - id: 6, + id: 5, name: r'type', type: IsarType.byte, enumMap: _EthContracttypeEnumValueMap, - ), - r'walletIds': PropertySchema( - id: 7, - name: r'walletIds', - type: IsarType.stringList, ) }, estimateSize: _ethContractEstimateSize, @@ -101,20 +91,7 @@ int _ethContractEstimateSize( } bytesCount += 3 + object.address.length * 3; bytesCount += 3 + object.name.length * 3; - { - final value = object.otherData; - if (value != null) { - bytesCount += 3 + value.length * 3; - } - } bytesCount += 3 + object.symbol.length * 3; - bytesCount += 3 + object.walletIds.length * 3; - { - for (var i = 0; i < object.walletIds.length; i++) { - final value = object.walletIds[i]; - bytesCount += value.length * 3; - } - } return bytesCount; } @@ -128,10 +105,8 @@ void _ethContractSerialize( writer.writeString(offsets[1], object.address); writer.writeLong(offsets[2], object.decimals); writer.writeString(offsets[3], object.name); - writer.writeString(offsets[4], object.otherData); - writer.writeString(offsets[5], object.symbol); - writer.writeByte(offsets[6], object.type.index); - writer.writeStringList(offsets[7], object.walletIds); + writer.writeString(offsets[4], object.symbol); + writer.writeByte(offsets[5], object.type.index); } EthContract _ethContractDeserialize( @@ -145,11 +120,9 @@ EthContract _ethContractDeserialize( address: reader.readString(offsets[1]), decimals: reader.readLong(offsets[2]), name: reader.readString(offsets[3]), - otherData: reader.readStringOrNull(offsets[4]), - symbol: reader.readString(offsets[5]), - type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[6])] ?? - EthContractType.erc20, - walletIds: reader.readStringList(offsets[7]) ?? [], + symbol: reader.readString(offsets[4]), + type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[5])] ?? + EthContractType.unknown, ); object.id = id; return object; @@ -171,26 +144,24 @@ P _ethContractDeserializeProp

( case 3: return (reader.readString(offset)) as P; case 4: - return (reader.readStringOrNull(offset)) as P; - case 5: return (reader.readString(offset)) as P; - case 6: + case 5: return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? - EthContractType.erc20) as P; - case 7: - return (reader.readStringList(offset) ?? []) as P; + EthContractType.unknown) as P; default: throw IsarError('Unknown property with id $propertyId'); } } const _EthContracttypeEnumValueMap = { - 'erc20': 0, - 'erc721': 1, + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, }; const _EthContracttypeValueEnumMap = { - 0: EthContractType.erc20, - 1: EthContractType.erc721, + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, }; Id _ethContractGetId(EthContract object) { @@ -906,160 +877,6 @@ extension EthContractQueryFilter }); } - QueryBuilder - otherDataIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNull( - property: r'otherData', - )); - }); - } - - QueryBuilder - otherDataIsNotNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'otherData', - )); - }); - } - - QueryBuilder - otherDataEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataGreaterThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataLessThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataBetween( - String? lower, - String? upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'otherData', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataContains(String value, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataMatches(String pattern, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'otherData', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'otherData', - value: '', - )); - }); - } - - QueryBuilder - otherDataIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'otherData', - value: '', - )); - }); - } - QueryBuilder symbolEqualTo( String value, { bool caseSensitive = true, @@ -1246,231 +1063,6 @@ extension EthContractQueryFilter )); }); } - - QueryBuilder - walletIdsElementEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'walletIds', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementContains(String value, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'walletIds', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementMatches(String pattern, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'walletIds', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdsElementIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'walletIds', - value: '', - )); - }); - } - - QueryBuilder - walletIdsElementIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'walletIds', - value: '', - )); - }); - } - - QueryBuilder - walletIdsLengthEqualTo(int length) { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - length, - true, - length, - true, - ); - }); - } - - QueryBuilder - walletIdsIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - 0, - true, - 0, - true, - ); - }); - } - - QueryBuilder - walletIdsIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - 0, - false, - 999999, - true, - ); - }); - } - - QueryBuilder - walletIdsLengthLessThan( - int length, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - 0, - true, - length, - include, - ); - }); - } - - QueryBuilder - walletIdsLengthGreaterThan( - int length, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - length, - include, - 999999, - true, - ); - }); - } - - QueryBuilder - walletIdsLengthBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.listLength( - r'walletIds', - lower, - includeLower, - upper, - includeUpper, - ); - }); - } } extension EthContractQueryObject @@ -1529,18 +1121,6 @@ extension EthContractQuerySortBy }); } - QueryBuilder sortByOtherData() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.asc); - }); - } - - QueryBuilder sortByOtherDataDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.desc); - }); - } - QueryBuilder sortBySymbol() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'symbol', Sort.asc); @@ -1628,18 +1208,6 @@ extension EthContractQuerySortThenBy }); } - QueryBuilder thenByOtherData() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.asc); - }); - } - - QueryBuilder thenByOtherDataDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.desc); - }); - } - QueryBuilder thenBySymbol() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'symbol', Sort.asc); @@ -1694,13 +1262,6 @@ extension EthContractQueryWhereDistinct }); } - QueryBuilder distinctByOtherData( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'otherData', caseSensitive: caseSensitive); - }); - } - QueryBuilder distinctBySymbol( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -1713,12 +1274,6 @@ extension EthContractQueryWhereDistinct return query.addDistinctBy(r'type'); }); } - - QueryBuilder distinctByWalletIds() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'walletIds'); - }); - } } extension EthContractQueryProperty @@ -1753,12 +1308,6 @@ extension EthContractQueryProperty }); } - QueryBuilder otherDataProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'otherData'); - }); - } - QueryBuilder symbolProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'symbol'); @@ -1770,11 +1319,4 @@ extension EthContractQueryProperty return query.addPropertyName(r'type'); }); } - - QueryBuilder, QQueryOperations> - walletIdsProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'walletIds'); - }); - } }