mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-15 16:12:16 +00:00
db refactor and added address labels
This commit is contained in:
parent
7f15c1e6f4
commit
b0c00d8ec7
53 changed files with 8242 additions and 4365 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/exceptions/main_db/main_db_exception.dart';
|
||||
import 'package:stackwallet/exceptions/sw_exception.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -24,10 +25,9 @@ class MainDB {
|
|||
[
|
||||
TransactionSchema,
|
||||
TransactionNoteSchema,
|
||||
InputSchema,
|
||||
OutputSchema,
|
||||
UTXOSchema,
|
||||
AddressSchema,
|
||||
AddressLabelSchema,
|
||||
],
|
||||
directory: (await StackFileSystem.applicationIsarDirectory()).path,
|
||||
inspector: kDebugMode,
|
||||
|
@ -141,6 +141,13 @@ class MainDB {
|
|||
return isar.transactions.getByTxidWalletId(txid, walletId);
|
||||
}
|
||||
|
||||
Stream<Transaction?> watchTransaction({
|
||||
required Id id,
|
||||
bool fireImmediately = false,
|
||||
}) {
|
||||
return isar.transactions.watchObject(id, fireImmediately: fireImmediately);
|
||||
}
|
||||
|
||||
// utxos
|
||||
QueryBuilder<UTXO, UTXO, QAfterWhereClause> getUTXOs(String walletId) =>
|
||||
isar.utxos.where().walletIdEqualTo(walletId);
|
||||
|
@ -153,30 +160,6 @@ class MainDB {
|
|||
await isar.utxos.putAll(utxos);
|
||||
});
|
||||
|
||||
// inputs
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> getInputs(String walletId) =>
|
||||
isar.inputs.where().walletIdEqualTo(walletId);
|
||||
|
||||
Future<void> putInput(Input input) => isar.writeTxn(() async {
|
||||
await isar.inputs.put(input);
|
||||
});
|
||||
|
||||
Future<void> putInputs(List<Input> inputs) => isar.writeTxn(() async {
|
||||
await isar.inputs.putAll(inputs);
|
||||
});
|
||||
|
||||
// outputs
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> getOutputs(String walletId) =>
|
||||
isar.outputs.where().walletIdEqualTo(walletId);
|
||||
|
||||
Future<void> putOutput(Output output) => isar.writeTxn(() async {
|
||||
await isar.outputs.put(output);
|
||||
});
|
||||
|
||||
Future<void> putOutputs(List<Output> outputs) => isar.writeTxn(() async {
|
||||
await isar.outputs.putAll(outputs);
|
||||
});
|
||||
|
||||
// transaction notes
|
||||
QueryBuilder<TransactionNote, TransactionNote, QAfterWhereClause>
|
||||
getTransactionNotes(String walletId) =>
|
||||
|
@ -192,13 +175,82 @@ class MainDB {
|
|||
await isar.transactionNotes.putAll(transactionNotes);
|
||||
});
|
||||
|
||||
Future<TransactionNote?> getTransactionNote(
|
||||
String walletId, String txid) async {
|
||||
return isar.transactionNotes.getByTxidWalletId(
|
||||
txid,
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
Stream<TransactionNote?> watchTransactionNote({
|
||||
required Id id,
|
||||
bool fireImmediately = false,
|
||||
}) {
|
||||
return isar.transactionNotes
|
||||
.watchObject(id, fireImmediately: fireImmediately);
|
||||
}
|
||||
|
||||
// address labels
|
||||
QueryBuilder<AddressLabel, AddressLabel, QAfterWhereClause> getAddressLabels(
|
||||
String walletId) =>
|
||||
isar.addressLabels.where().walletIdEqualTo(walletId);
|
||||
|
||||
Future<int> putAddressLabel(AddressLabel addressLabel) =>
|
||||
isar.writeTxn(() async {
|
||||
return await isar.addressLabels.put(addressLabel);
|
||||
});
|
||||
|
||||
int putAddressLabelSync(AddressLabel addressLabel) => isar.writeTxnSync(() {
|
||||
return isar.addressLabels.putSync(addressLabel);
|
||||
});
|
||||
|
||||
Future<void> putAddressLabels(List<AddressLabel> addressLabels) =>
|
||||
isar.writeTxn(() async {
|
||||
await isar.addressLabels.putAll(addressLabels);
|
||||
});
|
||||
|
||||
Future<AddressLabel?> getAddressLabel(
|
||||
String walletId, String addressString) async {
|
||||
return isar.addressLabels.getByAddressStringWalletId(
|
||||
addressString,
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
AddressLabel? getAddressLabelSync(String walletId, String addressString) {
|
||||
return isar.addressLabels.getByAddressStringWalletIdSync(
|
||||
addressString,
|
||||
walletId,
|
||||
);
|
||||
}
|
||||
|
||||
Stream<AddressLabel?> watchAddressLabel({
|
||||
required Id id,
|
||||
bool fireImmediately = false,
|
||||
}) {
|
||||
return isar.addressLabels.watchObject(id, fireImmediately: fireImmediately);
|
||||
}
|
||||
|
||||
Future<int> updateAddressLabel(AddressLabel addressLabel) async {
|
||||
try {
|
||||
return await isar.writeTxn(() async {
|
||||
final deleted = await isar.addresses.delete(addressLabel.id);
|
||||
if (!deleted) {
|
||||
throw SWException("Failed to delete $addressLabel before updating");
|
||||
}
|
||||
return await isar.addressLabels.put(addressLabel);
|
||||
});
|
||||
} catch (e) {
|
||||
throw MainDBException("failed updateAddressLabel", e);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Future<void> deleteWalletBlockchainData(String walletId) async {
|
||||
final transactionCount = await getTransactions(walletId).count();
|
||||
final addressCount = await getAddresses(walletId).count();
|
||||
final utxoCount = await getUTXOs(walletId).count();
|
||||
final inputCount = await getInputs(walletId).count();
|
||||
final outputCount = await getOutputs(walletId).count();
|
||||
|
||||
await isar.writeTxn(() async {
|
||||
const paginateLimit = 50;
|
||||
|
@ -230,28 +282,11 @@ class MainDB {
|
|||
await isar.utxos
|
||||
.deleteAll(utxos.map((e) => e.id).toList(growable: false));
|
||||
}
|
||||
|
||||
// inputs
|
||||
for (int i = 0; i < inputCount; i += paginateLimit) {
|
||||
final inputs =
|
||||
await getInputs(walletId).offset(i).limit(paginateLimit).findAll();
|
||||
await isar.inputs
|
||||
.deleteAll(inputs.map((e) => e.id).toList(growable: false));
|
||||
}
|
||||
|
||||
// outputs
|
||||
for (int i = 0; i < outputCount; i += paginateLimit) {
|
||||
final outputs =
|
||||
await getOutputs(walletId).offset(i).limit(paginateLimit).findAll();
|
||||
await isar.outputs
|
||||
.deleteAll(outputs.map((e) => e.id).toList(growable: false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addNewTransactionData(
|
||||
List<Tuple4<Transaction, List<Output>, List<Input>, Address?>>
|
||||
transactionsData,
|
||||
List<Tuple2<Transaction, Address?>> transactionsData,
|
||||
String walletId,
|
||||
) async {
|
||||
try {
|
||||
|
@ -259,10 +294,10 @@ class MainDB {
|
|||
for (final data in transactionsData) {
|
||||
final tx = data.item1;
|
||||
|
||||
final potentiallyUnconfirmedTx = await getTransactions(walletId)
|
||||
.filter()
|
||||
.txidEqualTo(tx.txid)
|
||||
.findFirst();
|
||||
final potentiallyUnconfirmedTx = await getTransaction(
|
||||
walletId,
|
||||
tx.txid,
|
||||
);
|
||||
if (potentiallyUnconfirmedTx != null) {
|
||||
// update use id to replace tx
|
||||
tx.id = potentiallyUnconfirmedTx.id;
|
||||
|
@ -271,33 +306,16 @@ class MainDB {
|
|||
// save transaction
|
||||
await isar.transactions.put(tx);
|
||||
|
||||
// link and save outputs
|
||||
if (data.item2.isNotEmpty) {
|
||||
await isar.outputs.putAll(data.item2);
|
||||
tx.outputs.addAll(data.item2);
|
||||
await tx.outputs.save();
|
||||
}
|
||||
|
||||
// link and save inputs
|
||||
if (data.item3.isNotEmpty) {
|
||||
await isar.inputs.putAll(data.item3);
|
||||
tx.inputs.addAll(data.item3);
|
||||
await tx.inputs.save();
|
||||
}
|
||||
|
||||
if (data.item4 != null) {
|
||||
final address = await getAddresses(walletId)
|
||||
.filter()
|
||||
.valueEqualTo(data.item4!.value)
|
||||
.findFirst();
|
||||
if (data.item2 != null) {
|
||||
final address = await getAddress(walletId, data.item2!.value);
|
||||
|
||||
// check if address exists in db and add if it does not
|
||||
if (address == null) {
|
||||
await isar.addresses.put(data.item4!);
|
||||
await isar.addresses.put(data.item2!);
|
||||
}
|
||||
|
||||
// link and save address
|
||||
tx.address.value = address ?? data.item4!;
|
||||
tx.address.value = address ?? data.item2!;
|
||||
await tx.address.save();
|
||||
}
|
||||
}
|
||||
|
|
32
lib/models/isar/models/address_label.dart
Normal file
32
lib/models/isar/models/address_label.dart
Normal file
|
@ -0,0 +1,32 @@
|
|||
import 'package:isar/isar.dart';
|
||||
|
||||
part 'address_label.g.dart';
|
||||
|
||||
@Collection()
|
||||
class AddressLabel {
|
||||
AddressLabel({
|
||||
required this.walletId,
|
||||
required this.addressString,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
@Index()
|
||||
late final String walletId;
|
||||
|
||||
@Index(unique: true, composite: [CompositeIndex("walletId")])
|
||||
late final String addressString;
|
||||
|
||||
late final String value;
|
||||
|
||||
AddressLabel copyWith({String? label, Id? id}) {
|
||||
final addressLabel = AddressLabel(
|
||||
walletId: walletId,
|
||||
addressString: addressString,
|
||||
value: label ?? value,
|
||||
);
|
||||
addressLabel.id = id ?? this.id;
|
||||
return addressLabel;
|
||||
}
|
||||
}
|
1071
lib/models/isar/models/address_label.g.dart
Normal file
1071
lib/models/isar/models/address_label.g.dart
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,7 @@
|
|||
import 'package:equatable/equatable.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/exceptions/address/address_exception.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/crypto_currency_address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/crypto_currency_address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
part 'address.g.dart';
|
||||
|
@ -12,6 +13,7 @@ class Address extends CryptoCurrencyAddress {
|
|||
required this.value,
|
||||
required this.publicKey,
|
||||
required this.derivationIndex,
|
||||
// required this.derivationPath,
|
||||
required this.type,
|
||||
required this.subType,
|
||||
this.otherData,
|
||||
|
@ -36,6 +38,8 @@ class Address extends CryptoCurrencyAddress {
|
|||
@enumerated
|
||||
late final AddressSubType subType;
|
||||
|
||||
late final DerivationPath? derivationPath;
|
||||
|
||||
late final String? otherData;
|
||||
|
||||
final transactions = IsarLinks<Transaction>();
|
||||
|
@ -65,6 +69,7 @@ class Address extends CryptoCurrencyAddress {
|
|||
"type: ${type.name}, "
|
||||
"subType: ${subType.name}, "
|
||||
"transactionsLength: ${transactions.length} "
|
||||
"derivationPath: $derivationPath, "
|
||||
"otherData: $otherData, "
|
||||
"}";
|
||||
}
|
||||
|
@ -90,3 +95,19 @@ enum AddressSubType {
|
|||
unknown,
|
||||
nonWallet,
|
||||
}
|
||||
|
||||
@Embedded(inheritance: false)
|
||||
class DerivationPath extends Equatable {
|
||||
late final String value;
|
||||
|
||||
List<String> getComponents() => value.split("/");
|
||||
|
||||
String getPurpose() => getComponents()[1];
|
||||
|
||||
@override
|
||||
toString() => value;
|
||||
|
||||
@ignore
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
|
@ -22,35 +22,41 @@ const AddressSchema = CollectionSchema(
|
|||
name: r'derivationIndex',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'otherData': PropertySchema(
|
||||
r'derivationPath': PropertySchema(
|
||||
id: 1,
|
||||
name: r'derivationPath',
|
||||
type: IsarType.object,
|
||||
target: r'DerivationPath',
|
||||
),
|
||||
r'otherData': PropertySchema(
|
||||
id: 2,
|
||||
name: r'otherData',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'publicKey': PropertySchema(
|
||||
id: 2,
|
||||
id: 3,
|
||||
name: r'publicKey',
|
||||
type: IsarType.byteList,
|
||||
),
|
||||
r'subType': PropertySchema(
|
||||
id: 3,
|
||||
id: 4,
|
||||
name: r'subType',
|
||||
type: IsarType.byte,
|
||||
enumMap: _AddresssubTypeEnumValueMap,
|
||||
),
|
||||
r'type': PropertySchema(
|
||||
id: 4,
|
||||
id: 5,
|
||||
name: r'type',
|
||||
type: IsarType.byte,
|
||||
enumMap: _AddresstypeEnumValueMap,
|
||||
),
|
||||
r'value': PropertySchema(
|
||||
id: 5,
|
||||
id: 6,
|
||||
name: r'value',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'walletId': PropertySchema(
|
||||
id: 6,
|
||||
id: 7,
|
||||
name: r'walletId',
|
||||
type: IsarType.string,
|
||||
)
|
||||
|
@ -114,7 +120,7 @@ const AddressSchema = CollectionSchema(
|
|||
single: false,
|
||||
)
|
||||
},
|
||||
embeddedSchemas: {},
|
||||
embeddedSchemas: {r'DerivationPath': DerivationPathSchema},
|
||||
getId: _addressGetId,
|
||||
getLinks: _addressGetLinks,
|
||||
attach: _addressAttach,
|
||||
|
@ -127,6 +133,14 @@ int _addressEstimateSize(
|
|||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
{
|
||||
final value = object.derivationPath;
|
||||
if (value != null) {
|
||||
bytesCount += 3 +
|
||||
DerivationPathSchema.estimateSize(
|
||||
value, allOffsets[DerivationPath]!, allOffsets);
|
||||
}
|
||||
}
|
||||
{
|
||||
final value = object.otherData;
|
||||
if (value != null) {
|
||||
|
@ -146,12 +160,18 @@ void _addressSerialize(
|
|||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeLong(offsets[0], object.derivationIndex);
|
||||
writer.writeString(offsets[1], object.otherData);
|
||||
writer.writeByteList(offsets[2], object.publicKey);
|
||||
writer.writeByte(offsets[3], object.subType.index);
|
||||
writer.writeByte(offsets[4], object.type.index);
|
||||
writer.writeString(offsets[5], object.value);
|
||||
writer.writeString(offsets[6], object.walletId);
|
||||
writer.writeObject<DerivationPath>(
|
||||
offsets[1],
|
||||
allOffsets,
|
||||
DerivationPathSchema.serialize,
|
||||
object.derivationPath,
|
||||
);
|
||||
writer.writeString(offsets[2], object.otherData);
|
||||
writer.writeByteList(offsets[3], object.publicKey);
|
||||
writer.writeByte(offsets[4], object.subType.index);
|
||||
writer.writeByte(offsets[5], object.type.index);
|
||||
writer.writeString(offsets[6], object.value);
|
||||
writer.writeString(offsets[7], object.walletId);
|
||||
}
|
||||
|
||||
Address _addressDeserialize(
|
||||
|
@ -162,14 +182,19 @@ Address _addressDeserialize(
|
|||
) {
|
||||
final object = Address(
|
||||
derivationIndex: reader.readLong(offsets[0]),
|
||||
otherData: reader.readStringOrNull(offsets[1]),
|
||||
publicKey: reader.readByteList(offsets[2]) ?? [],
|
||||
subType: _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[3])] ??
|
||||
otherData: reader.readStringOrNull(offsets[2]),
|
||||
publicKey: reader.readByteList(offsets[3]) ?? [],
|
||||
subType: _AddresssubTypeValueEnumMap[reader.readByteOrNull(offsets[4])] ??
|
||||
AddressSubType.receiving,
|
||||
type: _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[4])] ??
|
||||
type: _AddresstypeValueEnumMap[reader.readByteOrNull(offsets[5])] ??
|
||||
AddressType.p2pkh,
|
||||
value: reader.readString(offsets[5]),
|
||||
walletId: reader.readString(offsets[6]),
|
||||
value: reader.readString(offsets[6]),
|
||||
walletId: reader.readString(offsets[7]),
|
||||
);
|
||||
object.derivationPath = reader.readObjectOrNull<DerivationPath>(
|
||||
offsets[1],
|
||||
DerivationPathSchema.deserialize,
|
||||
allOffsets,
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
|
@ -185,19 +210,25 @@ P _addressDeserializeProp<P>(
|
|||
case 0:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
return (reader.readObjectOrNull<DerivationPath>(
|
||||
offset,
|
||||
DerivationPathSchema.deserialize,
|
||||
allOffsets,
|
||||
)) as P;
|
||||
case 2:
|
||||
return (reader.readByteList(offset) ?? []) as P;
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 3:
|
||||
return (reader.readByteList(offset) ?? []) as P;
|
||||
case 4:
|
||||
return (_AddresssubTypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||
AddressSubType.receiving) as P;
|
||||
case 4:
|
||||
case 5:
|
||||
return (_AddresstypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||
AddressType.p2pkh) as P;
|
||||
case 5:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 6:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 7:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
|
@ -705,6 +736,23 @@ extension AddressQueryFilter
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Address, Address, QAfterFilterCondition> derivationPathIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNull(
|
||||
property: r'derivationPath',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Address, Address, QAfterFilterCondition>
|
||||
derivationPathIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNotNull(
|
||||
property: r'derivationPath',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Address, Address, QAfterFilterCondition> idEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
|
@ -1411,7 +1459,14 @@ extension AddressQueryFilter
|
|||
}
|
||||
|
||||
extension AddressQueryObject
|
||||
on QueryBuilder<Address, Address, QFilterCondition> {}
|
||||
on QueryBuilder<Address, Address, QFilterCondition> {
|
||||
QueryBuilder<Address, Address, QAfterFilterCondition> derivationPath(
|
||||
FilterQuery<DerivationPath> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.object(q, r'derivationPath');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension AddressQueryLinks
|
||||
on QueryBuilder<Address, Address, QFilterCondition> {
|
||||
|
@ -1699,6 +1754,13 @@ extension AddressQueryProperty
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Address, DerivationPath?, QQueryOperations>
|
||||
derivationPathProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'derivationPath');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Address, String?, QQueryOperations> otherDataProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'otherData');
|
||||
|
@ -1735,3 +1797,212 @@ extension AddressQueryProperty
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// IsarEmbeddedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters
|
||||
|
||||
const DerivationPathSchema = Schema(
|
||||
name: r'DerivationPath',
|
||||
id: -7377061614393881103,
|
||||
properties: {
|
||||
r'value': PropertySchema(
|
||||
id: 0,
|
||||
name: r'value',
|
||||
type: IsarType.string,
|
||||
)
|
||||
},
|
||||
estimateSize: _derivationPathEstimateSize,
|
||||
serialize: _derivationPathSerialize,
|
||||
deserialize: _derivationPathDeserialize,
|
||||
deserializeProp: _derivationPathDeserializeProp,
|
||||
);
|
||||
|
||||
int _derivationPathEstimateSize(
|
||||
DerivationPath object,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.value.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
void _derivationPathSerialize(
|
||||
DerivationPath object,
|
||||
IsarWriter writer,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
writer.writeString(offsets[0], object.value);
|
||||
}
|
||||
|
||||
DerivationPath _derivationPathDeserialize(
|
||||
Id id,
|
||||
IsarReader reader,
|
||||
List<int> offsets,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
final object = DerivationPath();
|
||||
object.value = reader.readString(offsets[0]);
|
||||
return object;
|
||||
}
|
||||
|
||||
P _derivationPathDeserializeProp<P>(
|
||||
IsarReader reader,
|
||||
int propertyId,
|
||||
int offset,
|
||||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
switch (propertyId) {
|
||||
case 0:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
extension DerivationPathQueryFilter
|
||||
on QueryBuilder<DerivationPath, DerivationPath, QFilterCondition> {
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueBetween(
|
||||
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'value',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueContains(String value, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'value',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueMatches(String pattern, {bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'value',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'value',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<DerivationPath, DerivationPath, QAfterFilterCondition>
|
||||
valueIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'value',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension DerivationPathQueryObject
|
||||
on QueryBuilder<DerivationPath, DerivationPath, QFilterCondition> {}
|
|
@ -1,27 +1,19 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
part 'input.g.dart';
|
||||
|
||||
@Collection()
|
||||
@embedded
|
||||
class Input {
|
||||
Input({
|
||||
required this.walletId,
|
||||
required this.txid,
|
||||
required this.vout,
|
||||
required this.scriptSig,
|
||||
required this.scriptSigAsm,
|
||||
required this.isCoinbase,
|
||||
required this.sequence,
|
||||
required this.innerRedeemScriptAsm,
|
||||
this.txid = "error",
|
||||
this.vout = -1,
|
||||
this.scriptSig,
|
||||
this.scriptSigAsm,
|
||||
this.isCoinbase,
|
||||
this.sequence,
|
||||
this.innerRedeemScriptAsm,
|
||||
});
|
||||
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
@Index()
|
||||
late final String walletId;
|
||||
|
||||
late final String txid;
|
||||
|
||||
late final int vout;
|
||||
|
@ -30,17 +22,11 @@ class Input {
|
|||
|
||||
late final String? scriptSigAsm;
|
||||
|
||||
// TODO: find witness type // is it even used?
|
||||
// late List<dynamic>? witness;
|
||||
late final String? witness;
|
||||
|
||||
late final bool? isCoinbase;
|
||||
|
||||
late final int? sequence;
|
||||
|
||||
late final String? innerRedeemScriptAsm;
|
||||
|
||||
final prevOut = IsarLink<Output>();
|
||||
|
||||
@Backlink(to: 'inputs')
|
||||
final transaction = IsarLink<Transaction>();
|
||||
}
|
||||
|
|
|
@ -3,17 +3,13 @@
|
|||
part of 'input.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// IsarEmbeddedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters
|
||||
|
||||
extension GetInputCollection on Isar {
|
||||
IsarCollection<Input> get inputs => this.collection();
|
||||
}
|
||||
|
||||
const InputSchema = CollectionSchema(
|
||||
const InputSchema = Schema(
|
||||
name: r'Input',
|
||||
id: 1962449150546623042,
|
||||
properties: {
|
||||
|
@ -52,9 +48,9 @@ const InputSchema = CollectionSchema(
|
|||
name: r'vout',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'walletId': PropertySchema(
|
||||
r'witness': PropertySchema(
|
||||
id: 7,
|
||||
name: r'walletId',
|
||||
name: r'witness',
|
||||
type: IsarType.string,
|
||||
)
|
||||
},
|
||||
|
@ -62,42 +58,6 @@ const InputSchema = CollectionSchema(
|
|||
serialize: _inputSerialize,
|
||||
deserialize: _inputDeserialize,
|
||||
deserializeProp: _inputDeserializeProp,
|
||||
idName: r'id',
|
||||
indexes: {
|
||||
r'walletId': IndexSchema(
|
||||
id: -1783113319798776304,
|
||||
name: r'walletId',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'walletId',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: true,
|
||||
)
|
||||
],
|
||||
)
|
||||
},
|
||||
links: {
|
||||
r'prevOut': LinkSchema(
|
||||
id: 2963704715567457192,
|
||||
name: r'prevOut',
|
||||
target: r'Output',
|
||||
single: true,
|
||||
),
|
||||
r'transaction': LinkSchema(
|
||||
id: -7488914266019463608,
|
||||
name: r'transaction',
|
||||
target: r'Transaction',
|
||||
single: true,
|
||||
linkName: r'inputs',
|
||||
)
|
||||
},
|
||||
embeddedSchemas: {},
|
||||
getId: _inputGetId,
|
||||
getLinks: _inputGetLinks,
|
||||
attach: _inputAttach,
|
||||
version: '3.0.5',
|
||||
);
|
||||
|
||||
int _inputEstimateSize(
|
||||
|
@ -125,7 +85,12 @@ int _inputEstimateSize(
|
|||
}
|
||||
}
|
||||
bytesCount += 3 + object.txid.length * 3;
|
||||
bytesCount += 3 + object.walletId.length * 3;
|
||||
{
|
||||
final value = object.witness;
|
||||
if (value != null) {
|
||||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
|
@ -142,7 +107,7 @@ void _inputSerialize(
|
|||
writer.writeLong(offsets[4], object.sequence);
|
||||
writer.writeString(offsets[5], object.txid);
|
||||
writer.writeLong(offsets[6], object.vout);
|
||||
writer.writeString(offsets[7], object.walletId);
|
||||
writer.writeString(offsets[7], object.witness);
|
||||
}
|
||||
|
||||
Input _inputDeserialize(
|
||||
|
@ -157,11 +122,10 @@ Input _inputDeserialize(
|
|||
scriptSig: reader.readStringOrNull(offsets[2]),
|
||||
scriptSigAsm: reader.readStringOrNull(offsets[3]),
|
||||
sequence: reader.readLongOrNull(offsets[4]),
|
||||
txid: reader.readString(offsets[5]),
|
||||
vout: reader.readLong(offsets[6]),
|
||||
walletId: reader.readString(offsets[7]),
|
||||
txid: reader.readStringOrNull(offsets[5]) ?? "error",
|
||||
vout: reader.readLongOrNull(offsets[6]) ?? -1,
|
||||
);
|
||||
object.id = id;
|
||||
object.witness = reader.readStringOrNull(offsets[7]);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -183,204 +147,17 @@ P _inputDeserializeProp<P>(
|
|||
case 4:
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 5:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readStringOrNull(offset) ?? "error") as P;
|
||||
case 6:
|
||||
return (reader.readLong(offset)) as P;
|
||||
return (reader.readLongOrNull(offset) ?? -1) as P;
|
||||
case 7:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _inputGetId(Input object) {
|
||||
return object.id;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _inputGetLinks(Input object) {
|
||||
return [object.prevOut, object.transaction];
|
||||
}
|
||||
|
||||
void _inputAttach(IsarCollection<dynamic> col, Id id, Input object) {
|
||||
object.id = id;
|
||||
object.prevOut.attach(col, col.isar.collection<Output>(), r'prevOut', id);
|
||||
object.transaction
|
||||
.attach(col, col.isar.collection<Transaction>(), r'transaction', id);
|
||||
}
|
||||
|
||||
extension InputQueryWhereSort on QueryBuilder<Input, Input, QWhere> {
|
||||
QueryBuilder<Input, Input, QAfterWhere> anyId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQueryWhere on QueryBuilder<Input, Input, QWhereClause> {
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> idEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(
|
||||
lower: id,
|
||||
upper: id,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> idNotEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> idGreaterThan(Id id,
|
||||
{bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> idLessThan(Id id,
|
||||
{bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> idBetween(
|
||||
Id lowerId,
|
||||
Id upperId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(
|
||||
lower: lowerId,
|
||||
includeLower: includeLower,
|
||||
upper: upperId,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> walletIdEqualTo(
|
||||
String walletId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IndexWhereClause.equalTo(
|
||||
indexName: r'walletId',
|
||||
value: [walletId],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterWhereClause> walletIdNotEqualTo(
|
||||
String walletId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [],
|
||||
upper: [walletId],
|
||||
includeUpper: false,
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [walletId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
));
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [walletId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [],
|
||||
upper: [walletId],
|
||||
includeUpper: false,
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQueryFilter on QueryBuilder<Input, Input, QFilterCondition> {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> idEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> idGreaterThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> idLessThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> idBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition>
|
||||
innerRedeemScriptAsmIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1101,59 +878,75 @@ extension InputQueryFilter on QueryBuilder<Input, Input, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdEqualTo(
|
||||
String value, {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNull(
|
||||
property: r'witness',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNotNull(
|
||||
property: r'witness',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessEqualTo(
|
||||
String? value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdGreaterThan(
|
||||
String value, {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessGreaterThan(
|
||||
String? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdLessThan(
|
||||
String value, {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessLessThan(
|
||||
String? value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdBetween(
|
||||
String lower,
|
||||
String upper, {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessBetween(
|
||||
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'walletId',
|
||||
property: r'witness',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
|
@ -1163,69 +956,69 @@ extension InputQueryFilter on QueryBuilder<Input, Input, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdStartsWith(
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdEndsWith(
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdContains(
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdMatches(
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdIsEmpty() {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> walletIdIsNotEmpty() {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> witnessIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'walletId',
|
||||
property: r'witness',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
|
@ -1233,352 +1026,3 @@ extension InputQueryFilter on QueryBuilder<Input, Input, QFilterCondition> {
|
|||
}
|
||||
|
||||
extension InputQueryObject on QueryBuilder<Input, Input, QFilterCondition> {}
|
||||
|
||||
extension InputQueryLinks on QueryBuilder<Input, Input, QFilterCondition> {
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> prevOut(
|
||||
FilterQuery<Output> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.link(q, r'prevOut');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> prevOutIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'prevOut', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> transaction(
|
||||
FilterQuery<Transaction> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.link(q, r'transaction');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterFilterCondition> transactionIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'transaction', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQuerySortBy on QueryBuilder<Input, Input, QSortBy> {
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByInnerRedeemScriptAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'innerRedeemScriptAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByInnerRedeemScriptAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'innerRedeemScriptAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByIsCoinbase() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isCoinbase', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByIsCoinbaseDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isCoinbase', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByScriptSig() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSig', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByScriptSigDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSig', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByScriptSigAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSigAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByScriptSigAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSigAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortBySequence() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'sequence', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortBySequenceDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'sequence', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByTxid() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByTxidDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByVout() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'vout', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByVoutDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'vout', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByWalletId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> sortByWalletIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQuerySortThenBy on QueryBuilder<Input, Input, QSortThenBy> {
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByInnerRedeemScriptAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'innerRedeemScriptAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByInnerRedeemScriptAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'innerRedeemScriptAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByIsCoinbase() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isCoinbase', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByIsCoinbaseDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'isCoinbase', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByScriptSig() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSig', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByScriptSigDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSig', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByScriptSigAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSigAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByScriptSigAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptSigAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenBySequence() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'sequence', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenBySequenceDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'sequence', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByTxid() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByTxidDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByVout() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'vout', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByVoutDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'vout', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByWalletId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QAfterSortBy> thenByWalletIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQueryWhereDistinct on QueryBuilder<Input, Input, QDistinct> {
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByInnerRedeemScriptAsm(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'innerRedeemScriptAsm',
|
||||
caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByIsCoinbase() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'isCoinbase');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByScriptSig(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptSig', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByScriptSigAsm(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptSigAsm', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctBySequence() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'sequence');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByTxid(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'txid', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByVout() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'vout');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, Input, QDistinct> distinctByWalletId(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension InputQueryProperty on QueryBuilder<Input, Input, QQueryProperty> {
|
||||
QueryBuilder<Input, int, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, String?, QQueryOperations>
|
||||
innerRedeemScriptAsmProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'innerRedeemScriptAsm');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, bool?, QQueryOperations> isCoinbaseProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isCoinbase');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, String?, QQueryOperations> scriptSigProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptSig');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, String?, QQueryOperations> scriptSigAsmProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptSigAsm');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, int?, QQueryOperations> sequenceProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'sequence');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, String, QQueryOperations> txidProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'txid');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, int, QQueryOperations> voutProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'vout');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Input, String, QQueryOperations> walletIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'walletId');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,17 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
|
||||
part 'output.g.dart';
|
||||
|
||||
@Collection()
|
||||
@embedded
|
||||
class Output {
|
||||
Output({
|
||||
required this.walletId,
|
||||
required this.scriptPubKey,
|
||||
required this.scriptPubKeyAsm,
|
||||
required this.scriptPubKeyType,
|
||||
required this.scriptPubKeyAddress,
|
||||
required this.value,
|
||||
this.scriptPubKey,
|
||||
this.scriptPubKeyAsm,
|
||||
this.scriptPubKeyType,
|
||||
this.scriptPubKeyAddress = "",
|
||||
this.value = 0,
|
||||
});
|
||||
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
@Index()
|
||||
late final String walletId;
|
||||
|
||||
late final String? scriptPubKey;
|
||||
|
||||
late final String? scriptPubKeyAsm;
|
||||
|
@ -28,7 +21,4 @@ class Output {
|
|||
late final String scriptPubKeyAddress;
|
||||
|
||||
late final int value;
|
||||
|
||||
@Backlink(to: 'outputs')
|
||||
final transaction = IsarLink<Transaction>();
|
||||
}
|
||||
|
|
|
@ -3,17 +3,13 @@
|
|||
part of 'output.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// IsarCollectionGenerator
|
||||
// IsarEmbeddedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters
|
||||
|
||||
extension GetOutputCollection on Isar {
|
||||
IsarCollection<Output> get outputs => this.collection();
|
||||
}
|
||||
|
||||
const OutputSchema = CollectionSchema(
|
||||
const OutputSchema = Schema(
|
||||
name: r'Output',
|
||||
id: 3359341097909611106,
|
||||
properties: {
|
||||
|
@ -41,47 +37,12 @@ const OutputSchema = CollectionSchema(
|
|||
id: 4,
|
||||
name: r'value',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'walletId': PropertySchema(
|
||||
id: 5,
|
||||
name: r'walletId',
|
||||
type: IsarType.string,
|
||||
)
|
||||
},
|
||||
estimateSize: _outputEstimateSize,
|
||||
serialize: _outputSerialize,
|
||||
deserialize: _outputDeserialize,
|
||||
deserializeProp: _outputDeserializeProp,
|
||||
idName: r'id',
|
||||
indexes: {
|
||||
r'walletId': IndexSchema(
|
||||
id: -1783113319798776304,
|
||||
name: r'walletId',
|
||||
unique: false,
|
||||
replace: false,
|
||||
properties: [
|
||||
IndexPropertySchema(
|
||||
name: r'walletId',
|
||||
type: IndexType.hash,
|
||||
caseSensitive: true,
|
||||
)
|
||||
],
|
||||
)
|
||||
},
|
||||
links: {
|
||||
r'transaction': LinkSchema(
|
||||
id: -2089310750171432135,
|
||||
name: r'transaction',
|
||||
target: r'Transaction',
|
||||
single: true,
|
||||
linkName: r'outputs',
|
||||
)
|
||||
},
|
||||
embeddedSchemas: {},
|
||||
getId: _outputGetId,
|
||||
getLinks: _outputGetLinks,
|
||||
attach: _outputAttach,
|
||||
version: '3.0.5',
|
||||
);
|
||||
|
||||
int _outputEstimateSize(
|
||||
|
@ -109,7 +70,6 @@ int _outputEstimateSize(
|
|||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
bytesCount += 3 + object.walletId.length * 3;
|
||||
return bytesCount;
|
||||
}
|
||||
|
||||
|
@ -124,7 +84,6 @@ void _outputSerialize(
|
|||
writer.writeString(offsets[2], object.scriptPubKeyAsm);
|
||||
writer.writeString(offsets[3], object.scriptPubKeyType);
|
||||
writer.writeLong(offsets[4], object.value);
|
||||
writer.writeString(offsets[5], object.walletId);
|
||||
}
|
||||
|
||||
Output _outputDeserialize(
|
||||
|
@ -135,13 +94,11 @@ Output _outputDeserialize(
|
|||
) {
|
||||
final object = Output(
|
||||
scriptPubKey: reader.readStringOrNull(offsets[0]),
|
||||
scriptPubKeyAddress: reader.readString(offsets[1]),
|
||||
scriptPubKeyAddress: reader.readStringOrNull(offsets[1]) ?? "",
|
||||
scriptPubKeyAsm: reader.readStringOrNull(offsets[2]),
|
||||
scriptPubKeyType: reader.readStringOrNull(offsets[3]),
|
||||
value: reader.readLong(offsets[4]),
|
||||
walletId: reader.readString(offsets[5]),
|
||||
value: reader.readLongOrNull(offsets[4]) ?? 0,
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -155,207 +112,19 @@ P _outputDeserializeProp<P>(
|
|||
case 0:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 1:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readStringOrNull(offset) ?? "") as P;
|
||||
case 2:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 3:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 4:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 5:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readLongOrNull(offset) ?? 0) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
}
|
||||
}
|
||||
|
||||
Id _outputGetId(Output object) {
|
||||
return object.id;
|
||||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _outputGetLinks(Output object) {
|
||||
return [object.transaction];
|
||||
}
|
||||
|
||||
void _outputAttach(IsarCollection<dynamic> col, Id id, Output object) {
|
||||
object.id = id;
|
||||
object.transaction
|
||||
.attach(col, col.isar.collection<Transaction>(), r'transaction', id);
|
||||
}
|
||||
|
||||
extension OutputQueryWhereSort on QueryBuilder<Output, Output, QWhere> {
|
||||
QueryBuilder<Output, Output, QAfterWhere> anyId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(const IdWhereClause.any());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQueryWhere on QueryBuilder<Output, Output, QWhereClause> {
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> idEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(
|
||||
lower: id,
|
||||
upper: id,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> idNotEqualTo(Id id) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
);
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: false),
|
||||
)
|
||||
.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: false),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> idGreaterThan(Id id,
|
||||
{bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.greaterThan(lower: id, includeLower: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> idLessThan(Id id,
|
||||
{bool include = false}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(
|
||||
IdWhereClause.lessThan(upper: id, includeUpper: include),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> idBetween(
|
||||
Id lowerId,
|
||||
Id upperId, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IdWhereClause.between(
|
||||
lower: lowerId,
|
||||
includeLower: includeLower,
|
||||
upper: upperId,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> walletIdEqualTo(
|
||||
String walletId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addWhereClause(IndexWhereClause.equalTo(
|
||||
indexName: r'walletId',
|
||||
value: [walletId],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterWhereClause> walletIdNotEqualTo(
|
||||
String walletId) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
if (query.whereSort == Sort.asc) {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [],
|
||||
upper: [walletId],
|
||||
includeUpper: false,
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [walletId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
));
|
||||
} else {
|
||||
return query
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [walletId],
|
||||
includeLower: false,
|
||||
upper: [],
|
||||
))
|
||||
.addWhereClause(IndexWhereClause.between(
|
||||
indexName: r'walletId',
|
||||
lower: [],
|
||||
upper: [walletId],
|
||||
includeUpper: false,
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQueryFilter on QueryBuilder<Output, Output, QFilterCondition> {
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> idEqualTo(Id value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> idGreaterThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> idLessThan(
|
||||
Id value, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'id',
|
||||
value: value,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> idBetween(
|
||||
Id lower,
|
||||
Id upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.between(
|
||||
property: r'id',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> scriptPubKeyIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNull(
|
||||
|
@ -989,401 +758,6 @@ extension OutputQueryFilter on QueryBuilder<Output, Output, QFilterCondition> {
|
|||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdGreaterThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
include: include,
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdLessThan(
|
||||
String value, {
|
||||
bool include = false,
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.lessThan(
|
||||
include: include,
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdBetween(
|
||||
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'walletId',
|
||||
lower: lower,
|
||||
includeLower: includeLower,
|
||||
upper: upper,
|
||||
includeUpper: includeUpper,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'walletId',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'walletId',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'walletId',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> walletIdIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'walletId',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQueryObject on QueryBuilder<Output, Output, QFilterCondition> {}
|
||||
|
||||
extension OutputQueryLinks on QueryBuilder<Output, Output, QFilterCondition> {
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> transaction(
|
||||
FilterQuery<Transaction> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.link(q, r'transaction');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterFilterCondition> transactionIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'transaction', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQuerySortBy on QueryBuilder<Output, Output, QSortBy> {
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKey() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKey', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKey', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyAddress() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAddress', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyAddressDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAddress', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByScriptPubKeyTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'value', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'value', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByWalletId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> sortByWalletIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQuerySortThenBy on QueryBuilder<Output, Output, QSortThenBy> {
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenById() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'id', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKey() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKey', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKey', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyAddress() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAddress', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyAddressDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAddress', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyAsm() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAsm', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyAsmDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyAsm', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyType() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyType', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByScriptPubKeyTypeDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'scriptPubKeyType', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'value', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByValueDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'value', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByWalletId() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QAfterSortBy> thenByWalletIdDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'walletId', Sort.desc);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQueryWhereDistinct on QueryBuilder<Output, Output, QDistinct> {
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByScriptPubKey(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptPubKey', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByScriptPubKeyAddress(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptPubKeyAddress',
|
||||
caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByScriptPubKeyAsm(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptPubKeyAsm',
|
||||
caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByScriptPubKeyType(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'scriptPubKeyType',
|
||||
caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByValue() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'value');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, Output, QDistinct> distinctByWalletId(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension OutputQueryProperty on QueryBuilder<Output, Output, QQueryProperty> {
|
||||
QueryBuilder<Output, int, QQueryOperations> idProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'id');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, String?, QQueryOperations> scriptPubKeyProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptPubKey');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, String, QQueryOperations> scriptPubKeyAddressProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptPubKeyAddress');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, String?, QQueryOperations> scriptPubKeyAsmProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptPubKeyAsm');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, String?, QQueryOperations> scriptPubKeyTypeProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'scriptPubKeyType');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, int, QQueryOperations> valueProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'value');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Output, String, QQueryOperations> walletIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'walletId');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/input.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
part 'transaction.g.dart';
|
||||
|
||||
|
@ -22,8 +23,49 @@ class Transaction {
|
|||
required this.isLelantus,
|
||||
required this.slateId,
|
||||
required this.otherData,
|
||||
required this.inputs,
|
||||
required this.outputs,
|
||||
});
|
||||
|
||||
Tuple2<Transaction, Address?> copyWith({
|
||||
String? walletId,
|
||||
String? txid,
|
||||
int? timestamp,
|
||||
TransactionType? type,
|
||||
TransactionSubType? subType,
|
||||
int? amount,
|
||||
int? fee,
|
||||
int? height,
|
||||
bool? isCancelled,
|
||||
bool? isLelantus,
|
||||
String? slateId,
|
||||
String? otherData,
|
||||
List<Input>? inputs,
|
||||
List<Output>? outputs,
|
||||
Id? id,
|
||||
Address? address,
|
||||
}) {
|
||||
return Tuple2(
|
||||
Transaction(
|
||||
walletId: walletId ?? this.walletId,
|
||||
txid: txid ?? this.txid,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
type: type ?? this.type,
|
||||
subType: subType ?? this.subType,
|
||||
amount: amount ?? this.amount,
|
||||
fee: fee ?? this.fee,
|
||||
height: height ?? this.height,
|
||||
isCancelled: isCancelled ?? this.isCancelled,
|
||||
isLelantus: isLelantus ?? this.isLelantus,
|
||||
slateId: slateId ?? this.slateId,
|
||||
otherData: otherData ?? this.otherData,
|
||||
inputs: inputs ?? this.inputs,
|
||||
outputs: outputs ?? this.outputs)
|
||||
..id = id ?? this.id,
|
||||
address ?? this.address.value,
|
||||
);
|
||||
}
|
||||
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
@Index()
|
||||
|
@ -55,13 +97,13 @@ class Transaction {
|
|||
|
||||
late final String? otherData;
|
||||
|
||||
late final List<Input> inputs;
|
||||
|
||||
late final List<Output> outputs;
|
||||
|
||||
@Backlink(to: "transactions")
|
||||
final address = IsarLink<Address>();
|
||||
|
||||
final inputs = IsarLinks<Input>();
|
||||
|
||||
final outputs = IsarLinks<Output>();
|
||||
|
||||
int getConfirmations(int currentChainHeight) {
|
||||
if (height == null || height! <= 0) return 0;
|
||||
return max(0, currentChainHeight - (height! - 1));
|
||||
|
|
|
@ -32,50 +32,62 @@ const TransactionSchema = CollectionSchema(
|
|||
name: r'height',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'isCancelled': PropertySchema(
|
||||
r'inputs': PropertySchema(
|
||||
id: 3,
|
||||
name: r'inputs',
|
||||
type: IsarType.objectList,
|
||||
target: r'Input',
|
||||
),
|
||||
r'isCancelled': PropertySchema(
|
||||
id: 4,
|
||||
name: r'isCancelled',
|
||||
type: IsarType.bool,
|
||||
),
|
||||
r'isLelantus': PropertySchema(
|
||||
id: 4,
|
||||
id: 5,
|
||||
name: r'isLelantus',
|
||||
type: IsarType.bool,
|
||||
),
|
||||
r'otherData': PropertySchema(
|
||||
id: 5,
|
||||
id: 6,
|
||||
name: r'otherData',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'outputs': PropertySchema(
|
||||
id: 7,
|
||||
name: r'outputs',
|
||||
type: IsarType.objectList,
|
||||
target: r'Output',
|
||||
),
|
||||
r'slateId': PropertySchema(
|
||||
id: 6,
|
||||
id: 8,
|
||||
name: r'slateId',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'subType': PropertySchema(
|
||||
id: 7,
|
||||
id: 9,
|
||||
name: r'subType',
|
||||
type: IsarType.byte,
|
||||
enumMap: _TransactionsubTypeEnumValueMap,
|
||||
),
|
||||
r'timestamp': PropertySchema(
|
||||
id: 8,
|
||||
id: 10,
|
||||
name: r'timestamp',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'txid': PropertySchema(
|
||||
id: 9,
|
||||
id: 11,
|
||||
name: r'txid',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'type': PropertySchema(
|
||||
id: 10,
|
||||
id: 12,
|
||||
name: r'type',
|
||||
type: IsarType.byte,
|
||||
enumMap: _TransactiontypeEnumValueMap,
|
||||
),
|
||||
r'walletId': PropertySchema(
|
||||
id: 11,
|
||||
id: 13,
|
||||
name: r'walletId',
|
||||
type: IsarType.string,
|
||||
)
|
||||
|
@ -138,21 +150,9 @@ const TransactionSchema = CollectionSchema(
|
|||
target: r'Address',
|
||||
single: true,
|
||||
linkName: r'transactions',
|
||||
),
|
||||
r'inputs': LinkSchema(
|
||||
id: 4634425919890543640,
|
||||
name: r'inputs',
|
||||
target: r'Input',
|
||||
single: false,
|
||||
),
|
||||
r'outputs': LinkSchema(
|
||||
id: 1341997944984495532,
|
||||
name: r'outputs',
|
||||
target: r'Output',
|
||||
single: false,
|
||||
)
|
||||
},
|
||||
embeddedSchemas: {},
|
||||
embeddedSchemas: {r'Input': InputSchema, r'Output': OutputSchema},
|
||||
getId: _transactionGetId,
|
||||
getLinks: _transactionGetLinks,
|
||||
attach: _transactionAttach,
|
||||
|
@ -165,12 +165,28 @@ int _transactionEstimateSize(
|
|||
Map<Type, List<int>> allOffsets,
|
||||
) {
|
||||
var bytesCount = offsets.last;
|
||||
bytesCount += 3 + object.inputs.length * 3;
|
||||
{
|
||||
final offsets = allOffsets[Input]!;
|
||||
for (var i = 0; i < object.inputs.length; i++) {
|
||||
final value = object.inputs[i];
|
||||
bytesCount += InputSchema.estimateSize(value, offsets, allOffsets);
|
||||
}
|
||||
}
|
||||
{
|
||||
final value = object.otherData;
|
||||
if (value != null) {
|
||||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
bytesCount += 3 + object.outputs.length * 3;
|
||||
{
|
||||
final offsets = allOffsets[Output]!;
|
||||
for (var i = 0; i < object.outputs.length; i++) {
|
||||
final value = object.outputs[i];
|
||||
bytesCount += OutputSchema.estimateSize(value, offsets, allOffsets);
|
||||
}
|
||||
}
|
||||
{
|
||||
final value = object.slateId;
|
||||
if (value != null) {
|
||||
|
@ -191,15 +207,27 @@ void _transactionSerialize(
|
|||
writer.writeLong(offsets[0], object.amount);
|
||||
writer.writeLong(offsets[1], object.fee);
|
||||
writer.writeLong(offsets[2], object.height);
|
||||
writer.writeBool(offsets[3], object.isCancelled);
|
||||
writer.writeBool(offsets[4], object.isLelantus);
|
||||
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.writeString(offsets[11], object.walletId);
|
||||
writer.writeObjectList<Input>(
|
||||
offsets[3],
|
||||
allOffsets,
|
||||
InputSchema.serialize,
|
||||
object.inputs,
|
||||
);
|
||||
writer.writeBool(offsets[4], object.isCancelled);
|
||||
writer.writeBool(offsets[5], object.isLelantus);
|
||||
writer.writeString(offsets[6], object.otherData);
|
||||
writer.writeObjectList<Output>(
|
||||
offsets[7],
|
||||
allOffsets,
|
||||
OutputSchema.serialize,
|
||||
object.outputs,
|
||||
);
|
||||
writer.writeString(offsets[8], object.slateId);
|
||||
writer.writeByte(offsets[9], object.subType.index);
|
||||
writer.writeLong(offsets[10], object.timestamp);
|
||||
writer.writeString(offsets[11], object.txid);
|
||||
writer.writeByte(offsets[12], object.type.index);
|
||||
writer.writeString(offsets[13], object.walletId);
|
||||
}
|
||||
|
||||
Transaction _transactionDeserialize(
|
||||
|
@ -212,18 +240,32 @@ Transaction _transactionDeserialize(
|
|||
amount: reader.readLong(offsets[0]),
|
||||
fee: reader.readLong(offsets[1]),
|
||||
height: reader.readLongOrNull(offsets[2]),
|
||||
isCancelled: reader.readBool(offsets[3]),
|
||||
isLelantus: reader.readBoolOrNull(offsets[4]),
|
||||
otherData: reader.readStringOrNull(offsets[5]),
|
||||
slateId: reader.readStringOrNull(offsets[6]),
|
||||
inputs: reader.readObjectList<Input>(
|
||||
offsets[3],
|
||||
InputSchema.deserialize,
|
||||
allOffsets,
|
||||
Input(),
|
||||
) ??
|
||||
[],
|
||||
isCancelled: reader.readBool(offsets[4]),
|
||||
isLelantus: reader.readBoolOrNull(offsets[5]),
|
||||
otherData: reader.readStringOrNull(offsets[6]),
|
||||
outputs: reader.readObjectList<Output>(
|
||||
offsets[7],
|
||||
OutputSchema.deserialize,
|
||||
allOffsets,
|
||||
Output(),
|
||||
) ??
|
||||
[],
|
||||
slateId: reader.readStringOrNull(offsets[8]),
|
||||
subType:
|
||||
_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[7])] ??
|
||||
_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ??
|
||||
TransactionSubType.none,
|
||||
timestamp: reader.readLong(offsets[8]),
|
||||
txid: reader.readString(offsets[9]),
|
||||
type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[10])] ??
|
||||
timestamp: reader.readLong(offsets[10]),
|
||||
txid: reader.readString(offsets[11]),
|
||||
type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[12])] ??
|
||||
TransactionType.outgoing,
|
||||
walletId: reader.readString(offsets[11]),
|
||||
walletId: reader.readString(offsets[13]),
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
|
@ -243,24 +285,40 @@ P _transactionDeserializeProp<P>(
|
|||
case 2:
|
||||
return (reader.readLongOrNull(offset)) as P;
|
||||
case 3:
|
||||
return (reader.readBool(offset)) as P;
|
||||
return (reader.readObjectList<Input>(
|
||||
offset,
|
||||
InputSchema.deserialize,
|
||||
allOffsets,
|
||||
Input(),
|
||||
) ??
|
||||
[]) as P;
|
||||
case 4:
|
||||
return (reader.readBoolOrNull(offset)) as P;
|
||||
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.readObjectList<Output>(
|
||||
offset,
|
||||
OutputSchema.deserialize,
|
||||
allOffsets,
|
||||
Output(),
|
||||
) ??
|
||||
[]) as P;
|
||||
case 8:
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 9:
|
||||
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;
|
||||
case 10:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 11:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 12:
|
||||
return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ??
|
||||
TransactionType.outgoing) as P;
|
||||
case 11:
|
||||
case 13:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
|
@ -297,15 +355,13 @@ Id _transactionGetId(Transaction object) {
|
|||
}
|
||||
|
||||
List<IsarLinkBase<dynamic>> _transactionGetLinks(Transaction object) {
|
||||
return [object.address, object.inputs, object.outputs];
|
||||
return [object.address];
|
||||
}
|
||||
|
||||
void _transactionAttach(
|
||||
IsarCollection<dynamic> col, Id id, Transaction object) {
|
||||
object.id = id;
|
||||
object.address.attach(col, col.isar.collection<Address>(), r'address', id);
|
||||
object.inputs.attach(col, col.isar.collection<Input>(), r'inputs', id);
|
||||
object.outputs.attach(col, col.isar.collection<Output>(), r'outputs', id);
|
||||
}
|
||||
|
||||
extension TransactionByIndex on IsarCollection<Transaction> {
|
||||
|
@ -940,6 +996,95 @@ extension TransactionQueryFilter
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
length,
|
||||
true,
|
||||
length,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
0,
|
||||
true,
|
||||
0,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
0,
|
||||
false,
|
||||
999999,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthLessThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
0,
|
||||
true,
|
||||
length,
|
||||
include,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthGreaterThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
length,
|
||||
include,
|
||||
999999,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'inputs',
|
||||
lower,
|
||||
includeLower,
|
||||
upper,
|
||||
includeUpper,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
isCancelledEqualTo(bool value) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1132,6 +1277,95 @@ extension TransactionQueryFilter
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
length,
|
||||
true,
|
||||
length,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
0,
|
||||
true,
|
||||
0,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
0,
|
||||
false,
|
||||
999999,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthLessThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
0,
|
||||
true,
|
||||
length,
|
||||
include,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthGreaterThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
length,
|
||||
include,
|
||||
999999,
|
||||
true,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.listLength(
|
||||
r'outputs',
|
||||
lower,
|
||||
includeLower,
|
||||
upper,
|
||||
includeUpper,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
slateIdIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1715,7 +1949,21 @@ extension TransactionQueryFilter
|
|||
}
|
||||
|
||||
extension TransactionQueryObject
|
||||
on QueryBuilder<Transaction, Transaction, QFilterCondition> {}
|
||||
on QueryBuilder<Transaction, Transaction, QFilterCondition> {
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition> inputsElement(
|
||||
FilterQuery<Input> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.object(q, r'inputs');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition> outputsElement(
|
||||
FilterQuery<Output> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.object(q, r'outputs');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension TransactionQueryLinks
|
||||
on QueryBuilder<Transaction, Transaction, QFilterCondition> {
|
||||
|
@ -1732,128 +1980,6 @@ extension TransactionQueryLinks
|
|||
return query.linkLength(r'address', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition> inputs(
|
||||
FilterQuery<Input> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.link(q, r'inputs');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'inputs', length, true, length, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'inputs', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'inputs', 0, false, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthLessThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'inputs', 0, true, length, include);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthGreaterThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'inputs', length, include, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
inputsLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(
|
||||
r'inputs', lower, includeLower, upper, includeUpper);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition> outputs(
|
||||
FilterQuery<Output> q) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.link(q, r'outputs');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthEqualTo(int length) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'outputs', length, true, length, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'outputs', 0, true, 0, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'outputs', 0, false, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthLessThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'outputs', 0, true, length, include);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthGreaterThan(
|
||||
int length, {
|
||||
bool include = false,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(r'outputs', length, include, 999999, true);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
|
||||
outputsLengthBetween(
|
||||
int lower,
|
||||
int upper, {
|
||||
bool includeLower = true,
|
||||
bool includeUpper = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.linkLength(
|
||||
r'outputs', lower, includeLower, upper, includeUpper);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extension TransactionQuerySortBy
|
||||
|
@ -2267,6 +2393,12 @@ extension TransactionQueryProperty
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, List<Input>, QQueryOperations> inputsProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'inputs');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, bool, QQueryOperations> isCancelledProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'isCancelled');
|
||||
|
@ -2285,6 +2417,12 @@ extension TransactionQueryProperty
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, List<Output>, QQueryOperations> outputsProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'outputs');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<Transaction, String?, QQueryOperations> slateIdProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'slateId');
|
||||
|
|
|
@ -52,23 +52,28 @@ const UTXOSchema = CollectionSchema(
|
|||
name: r'name',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'txid': PropertySchema(
|
||||
r'otherData': PropertySchema(
|
||||
id: 7,
|
||||
name: r'otherData',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'txid': PropertySchema(
|
||||
id: 8,
|
||||
name: r'txid',
|
||||
type: IsarType.string,
|
||||
),
|
||||
r'value': PropertySchema(
|
||||
id: 8,
|
||||
id: 9,
|
||||
name: r'value',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'vout': PropertySchema(
|
||||
id: 9,
|
||||
id: 10,
|
||||
name: r'vout',
|
||||
type: IsarType.long,
|
||||
),
|
||||
r'walletId': PropertySchema(
|
||||
id: 10,
|
||||
id: 11,
|
||||
name: r'walletId',
|
||||
type: IsarType.string,
|
||||
)
|
||||
|
@ -151,6 +156,12 @@ int _uTXOEstimateSize(
|
|||
}
|
||||
}
|
||||
bytesCount += 3 + object.name.length * 3;
|
||||
{
|
||||
final value = object.otherData;
|
||||
if (value != null) {
|
||||
bytesCount += 3 + value.length * 3;
|
||||
}
|
||||
}
|
||||
bytesCount += 3 + object.txid.length * 3;
|
||||
bytesCount += 3 + object.walletId.length * 3;
|
||||
return bytesCount;
|
||||
|
@ -169,10 +180,11 @@ void _uTXOSerialize(
|
|||
writer.writeBool(offsets[4], object.isBlocked);
|
||||
writer.writeBool(offsets[5], object.isCoinbase);
|
||||
writer.writeString(offsets[6], object.name);
|
||||
writer.writeString(offsets[7], object.txid);
|
||||
writer.writeLong(offsets[8], object.value);
|
||||
writer.writeLong(offsets[9], object.vout);
|
||||
writer.writeString(offsets[10], object.walletId);
|
||||
writer.writeString(offsets[7], object.otherData);
|
||||
writer.writeString(offsets[8], object.txid);
|
||||
writer.writeLong(offsets[9], object.value);
|
||||
writer.writeLong(offsets[10], object.vout);
|
||||
writer.writeString(offsets[11], object.walletId);
|
||||
}
|
||||
|
||||
UTXO _uTXODeserialize(
|
||||
|
@ -189,10 +201,11 @@ UTXO _uTXODeserialize(
|
|||
isBlocked: reader.readBool(offsets[4]),
|
||||
isCoinbase: reader.readBool(offsets[5]),
|
||||
name: reader.readString(offsets[6]),
|
||||
txid: reader.readString(offsets[7]),
|
||||
value: reader.readLong(offsets[8]),
|
||||
vout: reader.readLong(offsets[9]),
|
||||
walletId: reader.readString(offsets[10]),
|
||||
otherData: reader.readStringOrNull(offsets[7]),
|
||||
txid: reader.readString(offsets[8]),
|
||||
value: reader.readLong(offsets[9]),
|
||||
vout: reader.readLong(offsets[10]),
|
||||
walletId: reader.readString(offsets[11]),
|
||||
);
|
||||
object.id = id;
|
||||
return object;
|
||||
|
@ -220,12 +233,14 @@ P _uTXODeserializeProp<P>(
|
|||
case 6:
|
||||
return (reader.readString(offset)) as P;
|
||||
case 7:
|
||||
return (reader.readString(offset)) as P;
|
||||
return (reader.readStringOrNull(offset)) as P;
|
||||
case 8:
|
||||
return (reader.readLong(offset)) as P;
|
||||
return (reader.readString(offset)) as P;
|
||||
case 9:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 10:
|
||||
return (reader.readLong(offset)) as P;
|
||||
case 11:
|
||||
return (reader.readString(offset)) as P;
|
||||
default:
|
||||
throw IsarError('Unknown property with id $propertyId');
|
||||
|
@ -1221,6 +1236,152 @@ extension UTXOQueryFilter on QueryBuilder<UTXO, UTXO, QFilterCondition> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataIsNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNull(
|
||||
property: r'otherData',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataIsNotNull() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(const FilterCondition.isNotNull(
|
||||
property: r'otherData',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataEqualTo(
|
||||
String? value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'otherData',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> 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<UTXO, UTXO, QAfterFilterCondition> 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<UTXO, UTXO, QAfterFilterCondition> 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<UTXO, UTXO, QAfterFilterCondition> otherDataStartsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.startsWith(
|
||||
property: r'otherData',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataEndsWith(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.endsWith(
|
||||
property: r'otherData',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataContains(
|
||||
String value,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.contains(
|
||||
property: r'otherData',
|
||||
value: value,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataMatches(
|
||||
String pattern,
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.matches(
|
||||
property: r'otherData',
|
||||
wildcard: pattern,
|
||||
caseSensitive: caseSensitive,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataIsEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.equalTo(
|
||||
property: r'otherData',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> otherDataIsNotEmpty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addFilterCondition(FilterCondition.greaterThan(
|
||||
property: r'otherData',
|
||||
value: '',
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> txidEqualTo(
|
||||
String value, {
|
||||
bool caseSensitive = true,
|
||||
|
@ -1672,6 +1833,18 @@ extension UTXOQuerySortBy on QueryBuilder<UTXO, UTXO, QSortBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByOtherData() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'otherData', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByOtherDataDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'otherData', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByTxid() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.asc);
|
||||
|
@ -1818,6 +1991,18 @@ extension UTXOQuerySortThenBy on QueryBuilder<UTXO, UTXO, QSortThenBy> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByOtherData() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'otherData', Sort.asc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByOtherDataDesc() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'otherData', Sort.desc);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByTxid() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addSortBy(r'txid', Sort.asc);
|
||||
|
@ -1914,6 +2099,13 @@ extension UTXOQueryWhereDistinct on QueryBuilder<UTXO, UTXO, QDistinct> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QDistinct> distinctByOtherData(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addDistinctBy(r'otherData', caseSensitive: caseSensitive);
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, UTXO, QDistinct> distinctByTxid(
|
||||
{bool caseSensitive = true}) {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
|
@ -1990,6 +2182,12 @@ extension UTXOQueryProperty on QueryBuilder<UTXO, UTXO, QQueryProperty> {
|
|||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, String?, QQueryOperations> otherDataProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'otherData');
|
||||
});
|
||||
}
|
||||
|
||||
QueryBuilder<UTXO, String, QQueryOperations> txidProperty() {
|
||||
return QueryBuilder.apply(this, (query) {
|
||||
return query.addPropertyName(r'txid');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export 'address/address.dart';
|
||||
export 'address_label.dart';
|
||||
export 'blockchain_data/address.dart';
|
||||
export 'blockchain_data/input.dart';
|
||||
export 'blockchain_data/output.dart';
|
||||
export 'blockchain_data/transaction.dart';
|
||||
|
|
|
@ -2,6 +2,8 @@ import 'dart:async';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/pages/receive_view/addresses/address_qr_popup.dart';
|
||||
|
@ -15,9 +17,8 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
|||
import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class AddressCard extends StatelessWidget {
|
||||
class AddressCard extends StatefulWidget {
|
||||
const AddressCard({
|
||||
Key? key,
|
||||
required this.address,
|
||||
|
@ -31,102 +32,134 @@ class AddressCard extends StatelessWidget {
|
|||
final Coin coin;
|
||||
final ClipboardInterface clipboard;
|
||||
|
||||
@override
|
||||
State<AddressCard> createState() => _AddressCardState();
|
||||
}
|
||||
|
||||
class _AddressCardState extends State<AddressCard> {
|
||||
late Stream<AddressLabel?> stream;
|
||||
|
||||
AddressLabel? label;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
label = MainDB.instance
|
||||
.getAddressLabelSync(widget.walletId, widget.address.value);
|
||||
Id? id = label?.id;
|
||||
if (id == null) {
|
||||
label = AddressLabel(
|
||||
walletId: widget.walletId,
|
||||
addressString: widget.address.value,
|
||||
value: "",
|
||||
);
|
||||
id = MainDB.instance.putAddressLabelSync(label!);
|
||||
}
|
||||
stream = MainDB.instance.watchAddressLabel(id: id);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RoundedWhiteContainer(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"TODO: label",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
CustomTextButton(
|
||||
text: "Edit label",
|
||||
textSize: 14,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
EditAddressLabelView.routeName,
|
||||
arguments: Tuple2(
|
||||
address,
|
||||
walletId,
|
||||
child: StreamBuilder<AddressLabel?>(
|
||||
stream: stream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
label = snapshot.data!;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label!.value,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SelectableText(
|
||||
address.value,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
CustomTextButton(
|
||||
text: "Edit label",
|
||||
textSize: 14,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
EditAddressLabelView.routeName,
|
||||
arguments: label!,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Copy address",
|
||||
icon: CopyIcon(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
),
|
||||
onPressed: () async {
|
||||
await clipboard.setData(
|
||||
ClipboardData(
|
||||
text: address.value,
|
||||
),
|
||||
);
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
message: "Copied to clipboard",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
},
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Show QR Code",
|
||||
icon: QrCodeIcon(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AddressQrPopup(
|
||||
address: address,
|
||||
coin: coin,
|
||||
clipboard: clipboard,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SelectableText(
|
||||
widget.address.value,
|
||||
style: STextStyles.itemSubtitle12(context),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Copy address",
|
||||
icon: CopyIcon(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
),
|
||||
onPressed: () async {
|
||||
await widget.clipboard.setData(
|
||||
ClipboardData(
|
||||
text: widget.address.value,
|
||||
),
|
||||
);
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
message: "Copied to clipboard",
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Show QR Code",
|
||||
icon: QrCodeIcon(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AddressQrPopup(
|
||||
addressString: widget.address.value,
|
||||
coin: widget.coin,
|
||||
clipboard: widget.clipboard,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -26,12 +25,12 @@ import 'package:stackwallet/widgets/stack_dialog.dart';
|
|||
class AddressQrPopup extends StatefulWidget {
|
||||
const AddressQrPopup({
|
||||
Key? key,
|
||||
required this.address,
|
||||
required this.addressString,
|
||||
required this.coin,
|
||||
this.clipboard = const ClipboardWrapper(),
|
||||
}) : super(key: key);
|
||||
|
||||
final Address address;
|
||||
final String addressString;
|
||||
final Coin coin;
|
||||
final ClipboardInterface clipboard;
|
||||
|
||||
|
@ -118,7 +117,7 @@ class _AddressQrPopupState extends State<AddressQrPopup> {
|
|||
height: 8,
|
||||
),
|
||||
Text(
|
||||
widget.address.value,
|
||||
widget.addressString,
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -130,7 +129,7 @@ class _AddressQrPopupState extends State<AddressQrPopup> {
|
|||
child: QrImage(
|
||||
data: AddressUtils.buildUriString(
|
||||
widget.coin,
|
||||
widget.address.value,
|
||||
widget.addressString,
|
||||
{},
|
||||
),
|
||||
size: 220,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/address.dart';
|
||||
import 'package:stackwallet/db/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/address_label.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
|
@ -17,14 +18,12 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
|||
class EditAddressLabelView extends ConsumerStatefulWidget {
|
||||
const EditAddressLabelView({
|
||||
Key? key,
|
||||
required this.address,
|
||||
required this.walletId,
|
||||
required this.addressLabel,
|
||||
}) : super(key: key);
|
||||
|
||||
static const String routeName = "/editAddressLabel";
|
||||
|
||||
final Address address;
|
||||
final String walletId;
|
||||
final AddressLabel addressLabel;
|
||||
|
||||
@override
|
||||
ConsumerState<EditAddressLabelView> createState() =>
|
||||
|
@ -41,7 +40,7 @@ class _EditAddressLabelViewState extends ConsumerState<EditAddressLabelView> {
|
|||
void initState() {
|
||||
isDesktop = Util.isDesktop;
|
||||
_labelFieldController = TextEditingController();
|
||||
_labelFieldController.text = "todo: address.label";
|
||||
_labelFieldController.text = widget.addressLabel.value;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -195,34 +194,28 @@ class _EditAddressLabelViewState extends ConsumerState<EditAddressLabelView> {
|
|||
child: PrimaryButton(
|
||||
label: "Save",
|
||||
onPressed: () async {
|
||||
// todo: update address
|
||||
// await ref
|
||||
// .read(notesServiceChangeNotifierProvider(
|
||||
// widget.walletId))
|
||||
// .editOrAddNote(
|
||||
// txid: widget.txid,
|
||||
// note: _labelFieldController.text,
|
||||
// );
|
||||
// if (mounted) {
|
||||
// Navigator.of(context).pop();
|
||||
// }
|
||||
await MainDB.instance.updateAddressLabel(
|
||||
widget.addressLabel.copyWith(
|
||||
label: _labelFieldController.text,
|
||||
),
|
||||
);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
if (!isDesktop)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// todo: update address
|
||||
// await ref
|
||||
// .read(
|
||||
// notesServiceChangeNotifierProvider(widget.walletId))
|
||||
// .editOrAddNote(
|
||||
// txid: widget.txid,
|
||||
// note: _labelFieldController.text,
|
||||
// );
|
||||
// if (mounted) {
|
||||
// Navigator.of(context).pop();
|
||||
// }
|
||||
await MainDB.instance.updateAddressLabel(
|
||||
widget.addressLabel.copyWith(
|
||||
label: _labelFieldController.text,
|
||||
),
|
||||
);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
|||
import 'package:stackwallet/models/contact_address_entry.dart';
|
||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||
import 'package:stackwallet/models/send_view_auto_fill_data.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
|
@ -477,12 +477,11 @@ class RouteGenerator {
|
|||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case EditAddressLabelView.routeName:
|
||||
if (args is Tuple2<Address, String>) {
|
||||
if (args is AddressLabel) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => EditAddressLabelView(
|
||||
address: args.item1,
|
||||
walletId: args.item2,
|
||||
addressLabel: args,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
|
|
|
@ -1280,6 +1280,8 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1288,7 +1290,7 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2214,9 +2216,8 @@ class BitcoinWallet extends CoinServiceAPI
|
|||
// }
|
||||
// await fastFetch(vHashes.toList());
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
for (final txObject in allTransactions) {
|
||||
final data = await parseTransaction(
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'package:stackwallet/db/main_db.dart';
|
|||
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||
import 'package:stackwallet/models/balance.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
|
||||
import 'package:stackwallet/models/paymint/fee_object_model.dart';
|
||||
import 'package:stackwallet/services/coins/coin_service.dart';
|
||||
|
@ -1213,6 +1213,8 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1221,7 +1223,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2110,9 +2112,7 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// Logging.instance.log("allTransactions length: ${allTransactions.length}",
|
||||
// level: LogLevel.Info);
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txns = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txns = [];
|
||||
|
||||
for (final txData in allTransactions) {
|
||||
Set<String> inputAddresses = {};
|
||||
|
@ -2237,29 +2237,12 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
amount = amountReceivedInWallet;
|
||||
}
|
||||
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: txData["blocktime"] as int? ??
|
||||
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
|
||||
type: type,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
height: txData["height"] as int?,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
);
|
||||
|
||||
List<isar_models.Input> inputs = [];
|
||||
List<isar_models.Output> outputs = [];
|
||||
|
||||
for (final json in txData["vin"] as List) {
|
||||
bool isCoinBase = json['coinbase'] != null;
|
||||
final input = isar_models.Input(
|
||||
walletId: walletId,
|
||||
txid: json['txid'] as String,
|
||||
vout: json['vout'] as int? ?? -1,
|
||||
scriptSig: json['scriptSig']?['hex'] as String?,
|
||||
|
@ -2273,7 +2256,6 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
|
||||
for (final json in txData["vout"] as List) {
|
||||
final output = isar_models.Output(
|
||||
walletId: walletId,
|
||||
scriptPubKey: json['scriptPubKey']?['hex'] as String?,
|
||||
scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?,
|
||||
scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
|
||||
|
@ -2288,7 +2270,25 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
outputs.add(output);
|
||||
}
|
||||
|
||||
txns.add(Tuple4(tx, outputs, inputs, transactionAddress));
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txData["txid"] as String,
|
||||
timestamp: txData["blocktime"] as int? ??
|
||||
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
|
||||
type: type,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
height: txData["height"] as int?,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
);
|
||||
|
||||
txns.add(Tuple2(tx, transactionAddress));
|
||||
}
|
||||
|
||||
await db.addNewTransactionData(txns, walletId);
|
||||
|
|
|
@ -1072,6 +1072,8 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1080,7 +1082,7 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -1990,9 +1992,7 @@ class DogecoinWallet extends CoinServiceAPI
|
|||
}
|
||||
await fastFetch(vHashes.toList());
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txns = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txns = [];
|
||||
|
||||
for (final txObject in allTransactions) {
|
||||
final txn = await parseTransaction(
|
||||
|
|
|
@ -2034,9 +2034,8 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
final String transactions = message['result'] as String;
|
||||
final jsonTransactions = json.decode(transactions) as List;
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
// int latestTxnBlockHeight =
|
||||
// DB.instance.get<dynamic>(boxName: walletId, key: "storedTxnDataHeight")
|
||||
|
@ -2102,6 +2101,8 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
slateId: slateId,
|
||||
otherData: tx["id"].toString(),
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
// txn.address =
|
||||
|
@ -2125,7 +2126,7 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
// latestTxnBlockHeight = txHeight;
|
||||
// }
|
||||
|
||||
txnsData.add(Tuple4(txn, [], [], transactionAddress));
|
||||
txnsData.add(Tuple2(txn, transactionAddress));
|
||||
// cachedMap?.remove(tx["id"].toString());
|
||||
// cachedMap?.remove(commitId);
|
||||
// Logging.instance.log("cmap: $cachedMap", level: LogLevel.Info);
|
||||
|
|
|
@ -427,10 +427,9 @@ Future<Map<dynamic, dynamic>> staticProcessRestore(
|
|||
isLelantus: true,
|
||||
slateId: null,
|
||||
otherData: txid,
|
||||
)
|
||||
..inputs.addAll(element.inputs)
|
||||
..outputs.addAll(element.outputs)
|
||||
..address.value = element.address.value;
|
||||
inputs: element.inputs,
|
||||
outputs: element.outputs,
|
||||
)..address.value = element.address.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -831,6 +830,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -839,7 +840,7 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2852,9 +2853,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
|
||||
// TODO: optimize this whole lelantus process
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
for (final value in data.values) {
|
||||
// allow possible null address on mints as we don't display address
|
||||
|
@ -2869,7 +2869,9 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
value.item2.outputs.where((_) => true).toList(growable: false);
|
||||
final ins = value.item2.inputs.where((_) => true).toList(growable: false);
|
||||
|
||||
txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress));
|
||||
txnsData.add(Tuple2(
|
||||
value.item2.copyWith(inputs: ins, outputs: outs).item1,
|
||||
transactionAddress));
|
||||
}
|
||||
|
||||
await db.addNewTransactionData(txnsData, walletId);
|
||||
|
@ -2992,6 +2994,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
isLelantus: true,
|
||||
slateId: null,
|
||||
otherData: transactionInfo["otherData"] as String?,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final transactionAddress = await db
|
||||
|
@ -3008,11 +3012,10 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
publicKey: [],
|
||||
);
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>>
|
||||
txnsData = [];
|
||||
|
||||
txnsData.add(Tuple4(transaction, [], [], transactionAddress));
|
||||
txnsData.add(Tuple2(transaction, transactionAddress));
|
||||
|
||||
await db.addNewTransactionData(txnsData, walletId);
|
||||
|
||||
|
@ -3344,9 +3347,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
}
|
||||
}
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
Set<String> changeAddresses = allAddresses
|
||||
.where((e) => e.subType == isar_models.AddressSubType.change)
|
||||
|
@ -3499,29 +3501,12 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
publicKey: [],
|
||||
));
|
||||
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txObject["txid"] as String,
|
||||
timestamp: txObject["blocktime"] as int? ??
|
||||
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
|
||||
type: type,
|
||||
subType: subType,
|
||||
amount: amount,
|
||||
fee: fees,
|
||||
height: txObject["height"] as int? ?? 0,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
);
|
||||
|
||||
List<isar_models.Output> outs = [];
|
||||
List<isar_models.Input> ins = [];
|
||||
|
||||
for (final json in txObject["vin"] as List) {
|
||||
bool isCoinBase = json['coinbase'] != null;
|
||||
final input = isar_models.Input(
|
||||
walletId: walletId,
|
||||
txid: json['txid'] as String? ?? "",
|
||||
vout: json['vout'] as int? ?? -1,
|
||||
scriptSig: json['scriptSig']?['hex'] as String?,
|
||||
|
@ -3535,7 +3520,6 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
|
||||
for (final json in txObject["vout"] as List) {
|
||||
final output = isar_models.Output(
|
||||
walletId: walletId,
|
||||
scriptPubKey: json['scriptPubKey']?['hex'] as String?,
|
||||
scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?,
|
||||
scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
|
||||
|
@ -3550,7 +3534,25 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
outs.add(output);
|
||||
}
|
||||
|
||||
txnsData.add(Tuple4(tx, outs, ins, transactionAddress));
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: txObject["txid"] as String,
|
||||
timestamp: txObject["blocktime"] as int? ??
|
||||
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
|
||||
type: type,
|
||||
subType: subType,
|
||||
amount: amount,
|
||||
fee: fees,
|
||||
height: txObject["height"] as int? ?? 0,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: ins,
|
||||
outputs: outs,
|
||||
);
|
||||
|
||||
txnsData.add(Tuple2(tx, transactionAddress));
|
||||
}
|
||||
|
||||
await db.addNewTransactionData(txnsData, walletId);
|
||||
|
@ -4373,9 +4375,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
data[element.value.txid] = Tuple2(address, element.value);
|
||||
}
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
for (final value in data.values) {
|
||||
final transactionAddress = value.item1!;
|
||||
|
@ -4383,7 +4384,9 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
value.item2.outputs.where((_) => true).toList(growable: false);
|
||||
final ins = value.item2.inputs.where((_) => true).toList(growable: false);
|
||||
|
||||
txnsData.add(Tuple4(value.item2, outs, ins, transactionAddress));
|
||||
txnsData.add(Tuple2(
|
||||
value.item2.copyWith(inputs: ins, outputs: outs).item1,
|
||||
transactionAddress));
|
||||
}
|
||||
|
||||
await db.addNewTransactionData(txnsData, walletId);
|
||||
|
@ -4813,6 +4816,8 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
|
|||
isLelantus: true,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = await db
|
||||
|
|
|
@ -1227,6 +1227,8 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1235,7 +1237,7 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2188,9 +2190,8 @@ class LitecoinWallet extends CoinServiceAPI
|
|||
}
|
||||
await fastFetch(vHashes.toList());
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
for (final txObject in allTransactions) {
|
||||
final data = await parseTransaction(
|
||||
|
|
|
@ -875,9 +875,8 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
//
|
||||
// final Set<String> cachedTxids = Set<String>.from(txidsList);
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
if (transactions != null) {
|
||||
for (var tx in transactions.entries) {
|
||||
|
@ -926,9 +925,11 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
txnsData.add(Tuple4(txn, [], [], address));
|
||||
txnsData.add(Tuple2(txn, address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1216,6 +1216,8 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1224,7 +1226,7 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2180,9 +2182,8 @@ class NamecoinWallet extends CoinServiceAPI
|
|||
}
|
||||
await fastFetch(vHashes.toList());
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address>> txnsData =
|
||||
[];
|
||||
|
||||
for (final txObject in allTransactions) {
|
||||
final data = await parseTransaction(
|
||||
|
|
|
@ -1144,6 +1144,8 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
isLelantus: false,
|
||||
otherData: null,
|
||||
slateId: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
final address = txData["address"] is String
|
||||
|
@ -1152,7 +1154,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
|
||||
await db.addNewTransactionData(
|
||||
[
|
||||
Tuple4(transaction, [], [], address),
|
||||
Tuple2(transaction, address),
|
||||
],
|
||||
walletId,
|
||||
);
|
||||
|
@ -2070,9 +2072,7 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
}
|
||||
await fastFetch(vHashes.toList());
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txns = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txns = [];
|
||||
|
||||
for (final txObject in allTransactions) {
|
||||
List<String> sendersArray = [];
|
||||
|
@ -2300,21 +2300,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
amount = outputAmtAddressedToWallet;
|
||||
}
|
||||
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: midSortedTx["txid"] as String,
|
||||
timestamp: midSortedTx["timestamp"] as int,
|
||||
type: type,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
height: txObject["height"] as int,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
);
|
||||
|
||||
isar_models.Address transactionAddress =
|
||||
midSortedTx["address"] as isar_models.Address;
|
||||
|
||||
|
@ -2324,7 +2309,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
for (final json in txObject["vin"] as List) {
|
||||
bool isCoinBase = json['coinbase'] != null;
|
||||
final input = isar_models.Input(
|
||||
walletId: walletId,
|
||||
txid: json['txid'] as String,
|
||||
vout: json['vout'] as int? ?? -1,
|
||||
scriptSig: json['scriptSig']?['hex'] as String?,
|
||||
|
@ -2338,7 +2322,6 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
|
||||
for (final json in txObject["vout"] as List) {
|
||||
final output = isar_models.Output(
|
||||
walletId: walletId,
|
||||
scriptPubKey: json['scriptPubKey']?['hex'] as String?,
|
||||
scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?,
|
||||
scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
|
||||
|
@ -2354,7 +2337,24 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
outputs.add(output);
|
||||
}
|
||||
|
||||
txns.add(Tuple4(tx, outputs, inputs, transactionAddress));
|
||||
final tx = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: midSortedTx["txid"] as String,
|
||||
timestamp: midSortedTx["timestamp"] as int,
|
||||
type: type,
|
||||
subType: isar_models.TransactionSubType.none,
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
height: txObject["height"] as int,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
isCancelled: false,
|
||||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
);
|
||||
|
||||
txns.add(Tuple2(tx, transactionAddress));
|
||||
}
|
||||
|
||||
await db.addNewTransactionData(txns, walletId);
|
||||
|
|
|
@ -901,9 +901,8 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
// }
|
||||
// }
|
||||
|
||||
final List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> txnsData = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
[];
|
||||
|
||||
if (transactions != null) {
|
||||
for (var tx in transactions.entries) {
|
||||
|
@ -994,9 +993,11 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
|||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
|
||||
txnsData.add(Tuple4(txn, [], [], address));
|
||||
txnsData.add(Tuple2(txn, address));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,7 @@ import 'package:stackwallet/utilities/format.dart';
|
|||
import 'package:tuple/tuple.dart';
|
||||
|
||||
mixin ElectrumXParsing {
|
||||
Future<Tuple4<Transaction, List<Output>, List<Input>, Address>>
|
||||
parseTransaction(
|
||||
Future<Tuple2<Transaction, Address>> parseTransaction(
|
||||
Map<String, dynamic> txData,
|
||||
dynamic electrumxClient,
|
||||
List<Address> myAddresses,
|
||||
|
@ -157,7 +156,6 @@ mixin ElectrumXParsing {
|
|||
for (final json in txData["vin"] as List) {
|
||||
bool isCoinBase = json['coinbase'] != null;
|
||||
final input = Input(
|
||||
walletId: walletId,
|
||||
txid: json['txid'] as String,
|
||||
vout: json['vout'] as int? ?? -1,
|
||||
scriptSig: json['scriptSig']?['hex'] as String?,
|
||||
|
@ -171,7 +169,6 @@ mixin ElectrumXParsing {
|
|||
|
||||
for (final json in txData["vout"] as List) {
|
||||
final output = Output(
|
||||
walletId: walletId,
|
||||
scriptPubKey: json['scriptPubKey']?['hex'] as String?,
|
||||
scriptPubKeyAsm: json['scriptPubKey']?['asm'] as String?,
|
||||
scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
|
||||
|
@ -217,8 +214,10 @@ mixin ElectrumXParsing {
|
|||
isLelantus: false,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: ins,
|
||||
outputs: outs,
|
||||
);
|
||||
|
||||
return Tuple4(tx, outs, ins, transactionAddress);
|
||||
return Tuple2(tx, transactionAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,12 +391,8 @@ class DbVersionMigrator with WalletDB {
|
|||
walletBox.get("latest_lelantus_tx_model") as TransactionData?;
|
||||
final txnsLelantus = txnDataLelantus?.getAllTransactions().values ?? [];
|
||||
|
||||
final List<
|
||||
Tuple4<
|
||||
isar_models.Transaction,
|
||||
List<isar_models.Output>,
|
||||
List<isar_models.Input>,
|
||||
isar_models.Address?>> newTransactions = [];
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>>
|
||||
newTransactions = [];
|
||||
|
||||
newTransactions
|
||||
.addAll(_parseTransactions(txns, walletId, false, newAddresses));
|
||||
|
@ -425,17 +421,15 @@ class DbVersionMigrator with WalletDB {
|
|||
}
|
||||
}
|
||||
|
||||
List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> _parseTransactions(
|
||||
List<Tuple2<isar_models.Transaction, isar_models.Address?>>
|
||||
_parseTransactions(
|
||||
Iterable<Transaction> txns,
|
||||
String walletId,
|
||||
bool isLelantus,
|
||||
List<isar_models.Address> parsedAddresses,
|
||||
) {
|
||||
List<
|
||||
Tuple4<isar_models.Transaction, List<isar_models.Output>,
|
||||
List<isar_models.Input>, isar_models.Address?>> transactions = [];
|
||||
List<Tuple2<isar_models.Transaction, isar_models.Address?>> transactions =
|
||||
[];
|
||||
for (final tx in txns) {
|
||||
final type = tx.txType.toLowerCase() == "received"
|
||||
? isar_models.TransactionType.incoming
|
||||
|
@ -446,6 +440,32 @@ class DbVersionMigrator with WalletDB {
|
|||
? isar_models.TransactionSubType.join
|
||||
: isar_models.TransactionSubType.none;
|
||||
|
||||
final List<isar_models.Input> inputs = [];
|
||||
final List<isar_models.Output> outputs = [];
|
||||
|
||||
for (final inp in tx.inputs) {
|
||||
final input = isar_models.Input(
|
||||
txid: inp.txid,
|
||||
vout: inp.vout,
|
||||
scriptSig: inp.scriptsig,
|
||||
scriptSigAsm: inp.scriptsigAsm,
|
||||
isCoinbase: inp.isCoinbase,
|
||||
sequence: inp.sequence,
|
||||
innerRedeemScriptAsm: inp.innerRedeemscriptAsm,
|
||||
);
|
||||
inputs.add(input);
|
||||
}
|
||||
for (final out in tx.outputs) {
|
||||
final output = isar_models.Output(
|
||||
scriptPubKey: out.scriptpubkey,
|
||||
scriptPubKeyAsm: out.scriptpubkeyAsm,
|
||||
scriptPubKeyType: out.scriptpubkeyType,
|
||||
scriptPubKeyAddress: out.scriptpubkeyAddress,
|
||||
value: out.value,
|
||||
);
|
||||
outputs.add(output);
|
||||
}
|
||||
|
||||
final transaction = isar_models.Transaction(
|
||||
walletId: walletId,
|
||||
txid: tx.txid,
|
||||
|
@ -459,36 +479,10 @@ class DbVersionMigrator with WalletDB {
|
|||
isLelantus: false,
|
||||
slateId: tx.slateId,
|
||||
otherData: tx.otherData,
|
||||
inputs: inputs,
|
||||
outputs: outputs,
|
||||
);
|
||||
|
||||
final List<isar_models.Input> inputs = [];
|
||||
final List<isar_models.Output> outputs = [];
|
||||
|
||||
for (final inp in tx.inputs) {
|
||||
final input = isar_models.Input(
|
||||
walletId: walletId,
|
||||
txid: inp.txid,
|
||||
vout: inp.vout,
|
||||
scriptSig: inp.scriptsig,
|
||||
scriptSigAsm: inp.scriptsigAsm,
|
||||
isCoinbase: inp.isCoinbase,
|
||||
sequence: inp.sequence,
|
||||
innerRedeemScriptAsm: inp.innerRedeemscriptAsm,
|
||||
);
|
||||
inputs.add(input);
|
||||
}
|
||||
for (final out in tx.outputs) {
|
||||
final output = isar_models.Output(
|
||||
walletId: walletId,
|
||||
scriptPubKey: out.scriptpubkey,
|
||||
scriptPubKeyAsm: out.scriptpubkeyAsm,
|
||||
scriptPubKeyType: out.scriptpubkeyType,
|
||||
scriptPubKeyAddress: out.scriptpubkeyAddress,
|
||||
value: out.value,
|
||||
);
|
||||
outputs.add(output);
|
||||
}
|
||||
|
||||
isar_models.Address? address;
|
||||
if (tx.address.isNotEmpty) {
|
||||
final addresses = parsedAddresses.where((e) => e.value == tx.address);
|
||||
|
@ -508,7 +502,7 @@ class DbVersionMigrator with WalletDB {
|
|||
}
|
||||
}
|
||||
|
||||
transactions.add(Tuple4(transaction, outputs, inputs, address));
|
||||
transactions.add(Tuple2(transaction, address));
|
||||
}
|
||||
return transactions;
|
||||
}
|
||||
|
|
|
@ -452,6 +452,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.1"
|
||||
equatable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: equatable
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
event_bus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -139,6 +139,7 @@ dependencies:
|
|||
isar_flutter_libs: 3.0.5 # contains the binaries
|
||||
dropdown_button2: 1.7.2
|
||||
string_validator: ^0.3.0
|
||||
equatable: ^2.0.5
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -699,6 +699,24 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs {
|
|||
returnValue: _i4.Future<bool>.value(false),
|
||||
) as _i4.Future<bool>);
|
||||
@override
|
||||
_i4.Future<void> saveUserID(String? userId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveUserID,
|
||||
[userId],
|
||||
),
|
||||
returnValue: _i4.Future<void>.value(),
|
||||
returnValueForMissingStub: _i4.Future<void>.value(),
|
||||
) as _i4.Future<void>);
|
||||
@override
|
||||
_i4.Future<void> saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveSignupEpoch,
|
||||
[signupEpoch],
|
||||
),
|
||||
returnValue: _i4.Future<void>.value(),
|
||||
returnValueForMissingStub: _i4.Future<void>.value(),
|
||||
) as _i4.Future<void>);
|
||||
@override
|
||||
void addListener(_i9.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
|
|
|
@ -420,6 +420,24 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs {
|
|||
returnValue: _i3.Future<bool>.value(false),
|
||||
) as _i3.Future<bool>);
|
||||
@override
|
||||
_i3.Future<void> saveUserID(String? userId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveUserID,
|
||||
[userId],
|
||||
),
|
||||
returnValue: _i3.Future<void>.value(),
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
) as _i3.Future<void>);
|
||||
@override
|
||||
_i3.Future<void> saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveSignupEpoch,
|
||||
[signupEpoch],
|
||||
),
|
||||
returnValue: _i3.Future<void>.value(),
|
||||
returnValueForMissingStub: _i3.Future<void>.value(),
|
||||
) as _i3.Future<void>);
|
||||
@override
|
||||
void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -371,6 +371,24 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs {
|
|||
returnValue: _i7.Future<bool>.value(false),
|
||||
) as _i7.Future<bool>);
|
||||
@override
|
||||
_i7.Future<void> saveUserID(String? userId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveUserID,
|
||||
[userId],
|
||||
),
|
||||
returnValue: _i7.Future<void>.value(),
|
||||
returnValueForMissingStub: _i7.Future<void>.value(),
|
||||
) as _i7.Future<void>);
|
||||
@override
|
||||
_i7.Future<void> saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveSignupEpoch,
|
||||
[signupEpoch],
|
||||
),
|
||||
returnValue: _i7.Future<void>.value(),
|
||||
returnValueForMissingStub: _i7.Future<void>.value(),
|
||||
) as _i7.Future<void>);
|
||||
@override
|
||||
void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -102,6 +102,8 @@ void main() {
|
|||
isLelantus: null,
|
||||
slateId: t.slateId,
|
||||
otherData: t.otherData,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,8 @@ void main() {
|
|||
isLelantus: true,
|
||||
slateId: null,
|
||||
otherData: null,
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
);
|
||||
when(wallet.transactions).thenAnswer((_) async => [
|
||||
tx,
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -573,4 +573,13 @@ class MockTransactionNotificationTracker extends _i1.Mock
|
|||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
@override
|
||||
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#deleteTransaction,
|
||||
[txid],
|
||||
),
|
||||
returnValue: _i5.Future<void>.value(),
|
||||
returnValueForMissingStub: _i5.Future<void>.value(),
|
||||
) as _i5.Future<void>);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,11 @@ class MockSecureStorageWrapper extends _i1.Mock
|
|||
_i1.throwOnMissingStub(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_i3.Future<List<String>> get keys => (super.noSuchMethod(
|
||||
Invocation.getter(#keys),
|
||||
returnValue: _i3.Future<List<String>>.value(<String>[]),
|
||||
) as _i3.Future<List<String>>);
|
||||
@override
|
||||
_i3.Future<String?> read({
|
||||
required String? key,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -604,6 +604,24 @@ class MockPrefs extends _i1.Mock implements _i11.Prefs {
|
|||
returnValue: _i10.Future<bool>.value(false),
|
||||
) as _i10.Future<bool>);
|
||||
@override
|
||||
_i10.Future<void> saveUserID(String? userId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveUserID,
|
||||
[userId],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
@override
|
||||
_i10.Future<void> saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveSignupEpoch,
|
||||
[signupEpoch],
|
||||
),
|
||||
returnValue: _i10.Future<void>.value(),
|
||||
returnValueForMissingStub: _i10.Future<void>.value(),
|
||||
) as _i10.Future<void>);
|
||||
@override
|
||||
void addListener(_i12.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||
import 'package:mockingjay/mockingjay.dart' as mockingjay;
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:stackwallet/models/isar/models/address/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
|
@ -47,25 +47,27 @@ void main() {
|
|||
final mockPriceService = MockPriceService();
|
||||
|
||||
final tx = Transaction(
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '')
|
||||
..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
)..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
|
||||
final CoinServiceAPI wallet = MockFiroWallet();
|
||||
|
||||
|
@ -145,25 +147,27 @@ void main() {
|
|||
final mockPriceService = MockPriceService();
|
||||
|
||||
final tx = Transaction(
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 9659,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.mint,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '')
|
||||
..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 9659,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.mint,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
)..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
|
||||
final CoinServiceAPI wallet = MockFiroWallet();
|
||||
|
||||
|
@ -240,25 +244,27 @@ void main() {
|
|||
final mockPriceService = MockPriceService();
|
||||
|
||||
final tx = Transaction(
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.incoming,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '')
|
||||
..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.incoming,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
)..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
|
||||
final CoinServiceAPI wallet = MockFiroWallet();
|
||||
|
||||
|
@ -329,25 +335,27 @@ void main() {
|
|||
final navigator = mockingjay.MockNavigator();
|
||||
|
||||
final tx = Transaction(
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '')
|
||||
..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
txid: "some txid",
|
||||
timestamp: 1648595998,
|
||||
type: TransactionType.outgoing,
|
||||
amount: 100000000,
|
||||
fee: 3794,
|
||||
height: 450123,
|
||||
subType: TransactionSubType.none,
|
||||
isCancelled: false,
|
||||
walletId: '',
|
||||
isLelantus: null,
|
||||
slateId: '',
|
||||
otherData: '',
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
)..address.value = Address(
|
||||
walletId: "walletId",
|
||||
value: "",
|
||||
publicKey: [],
|
||||
derivationIndex: 0,
|
||||
type: AddressType.p2pkh,
|
||||
subType: AddressSubType.receiving);
|
||||
|
||||
final CoinServiceAPI wallet = MockFiroWallet();
|
||||
|
||||
|
|
|
@ -2317,6 +2317,24 @@ class MockPrefs extends _i1.Mock implements _i19.Prefs {
|
|||
returnValue: _i18.Future<bool>.value(false),
|
||||
) as _i18.Future<bool>);
|
||||
@override
|
||||
_i18.Future<void> saveUserID(String? userId) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveUserID,
|
||||
[userId],
|
||||
),
|
||||
returnValue: _i18.Future<void>.value(),
|
||||
returnValueForMissingStub: _i18.Future<void>.value(),
|
||||
) as _i18.Future<void>);
|
||||
@override
|
||||
_i18.Future<void> saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#saveSignupEpoch,
|
||||
[signupEpoch],
|
||||
),
|
||||
returnValue: _i18.Future<void>.value(),
|
||||
returnValueForMissingStub: _i18.Future<void>.value(),
|
||||
) as _i18.Future<void>);
|
||||
@override
|
||||
void addListener(_i20.VoidCallback? listener) => super.noSuchMethod(
|
||||
Invocation.method(
|
||||
#addListener,
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue