Merge remote-tracking branch 'origin/wallets_refactor' into namecoin

This commit is contained in:
sneurlax 2024-01-09 17:25:41 -06:00
commit 5fdcb522ca
17 changed files with 2086 additions and 3005 deletions

View file

@ -8,6 +8,7 @@ import 'package:stackwallet/models/isar/models/transaction_note.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart';
import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart';
Future<void> migrateWalletsToIsar({ Future<void> migrateWalletsToIsar({
@ -47,7 +48,7 @@ Future<void> migrateWalletsToIsar({
final List<String> favourites = final List<String> favourites =
(await Hive.openBox<String>(DB.boxNameFavoriteWallets)).values.toList(); (await Hive.openBox<String>(DB.boxNameFavoriteWallets)).values.toList();
final List<WalletInfo> newInfo = []; final List<(WalletInfo, WalletInfoMeta)> newInfo = [];
final List<TransactionNote> migratedNotes = []; final List<TransactionNote> migratedNotes = [];
// //
@ -113,15 +114,19 @@ Future<void> migrateWalletsToIsar({
// //
otherData.removeWhere((key, value) => value == null); otherData.removeWhere((key, value) => value == null);
final infoMeta = WalletInfoMeta(
walletId: old.walletId,
isMnemonicVerified: allWalletsBox
.get("${old.walletId}_mnemonicHasBeenVerified") as bool? ??
false,
);
final info = WalletInfo( final info = WalletInfo(
coinName: old.coin.name, coinName: old.coin.name,
walletId: old.walletId, walletId: old.walletId,
name: old.name, name: old.name,
mainAddressType: old.coin.primaryAddressType, mainAddressType: old.coin.primaryAddressType,
favouriteOrderIndex: favourites.indexOf(old.walletId), favouriteOrderIndex: favourites.indexOf(old.walletId),
isMnemonicVerified: allWalletsBox
.get("${old.walletId}_mnemonicHasBeenVerified") as bool? ??
false,
cachedChainHeight: walletBox.get( cachedChainHeight: walletBox.get(
DBKeys.storedChainHeight, DBKeys.storedChainHeight,
) as int? ?? ) as int? ??
@ -135,7 +140,7 @@ Future<void> migrateWalletsToIsar({
otherDataJsonString: jsonEncode(otherData), otherDataJsonString: jsonEncode(otherData),
); );
newInfo.add(info); newInfo.add((info, infoMeta));
} }
if (migratedNotes.isNotEmpty) { if (migratedNotes.isNotEmpty) {
@ -145,10 +150,14 @@ Future<void> migrateWalletsToIsar({
} }
await MainDB.instance.isar.writeTxn(() async { await MainDB.instance.isar.writeTxn(() async {
await MainDB.instance.isar.walletInfo.putAll(newInfo); await MainDB.instance.isar.walletInfo
.putAll(newInfo.map((e) => e.$1).toList());
await MainDB.instance.isar.walletInfoMeta
.putAll(newInfo.map((e) => e.$2).toList());
}); });
await _cleanupOnSuccess(walletIds: newInfo.map((e) => e.walletId).toList()); await _cleanupOnSuccess(
walletIds: newInfo.map((e) => e.$1.walletId).toList());
} }
Future<void> _cleanupOnSuccess({required List<String> walletIds}) async { Future<void> _cleanupOnSuccess({required List<String> walletIds}) async {

View file

@ -57,6 +57,14 @@ class TransactionV2 {
required this.otherData, required this.otherData,
}); });
bool get isEpiccashTransaction =>
_getFromOtherData(key: "isEpiccashTransaction") == true;
int? get numberOfMessages =>
_getFromOtherData(key: "numberOfMessages") as int?;
String? get slateId => _getFromOtherData(key: "slateId") as String?;
String? get onChainNote => _getFromOtherData(key: "onChainNote") as String?;
bool get isCancelled => _getFromOtherData(key: "isCancelled") == true;
int getConfirmations(int currentChainHeight) { int getConfirmations(int currentChainHeight) {
if (height == null || height! <= 0) return 0; if (height == null || height! <= 0) return 0;
return max(0, currentChainHeight - (height! - 1)); return max(0, currentChainHeight - (height! - 1));
@ -146,35 +154,39 @@ class TransactionV2 {
} }
} }
// if (coin == Coin.epicCash) { if (isEpiccashTransaction) {
// if (_transaction.isCancelled) { if (slateId == null) {
// return "Cancelled"; return "Restored Funds";
// } else if (type == TransactionType.incoming) { }
// if (isConfirmed(height, minConfirms)) {
// return "Received"; if (isCancelled) {
// } else { return "Cancelled";
// if (_transaction.numberOfMessages == 1) { } else if (type == TransactionType.incoming) {
// return "Receiving (waiting for sender)"; if (isConfirmed(currentChainHeight, minConfirms)) {
// } else if ((_transaction.numberOfMessages ?? 0) > 1) { return "Received";
// return "Receiving (waiting for confirmations)"; // TODO test if the sender still has to open again after the receiver has 2 messages present, ie. sender->receiver->sender->node (yes) vs. sender->receiver->node (no) } else {
// } else { if (numberOfMessages == 1) {
// return "Receiving"; return "Receiving (waiting for sender)";
// } } else if ((numberOfMessages ?? 0) > 1) {
// } return "Receiving (waiting for confirmations)"; // TODO test if the sender still has to open again after the receiver has 2 messages present, ie. sender->receiver->sender->node (yes) vs. sender->receiver->node (no)
// } else if (type == TransactionType.outgoing) { } else {
// if (isConfirmed(height, minConfirms)) { return "Receiving";
// return "Sent (confirmed)"; }
// } else { }
// if (_transaction.numberOfMessages == 1) { } else if (type == TransactionType.outgoing) {
// return "Sending (waiting for receiver)"; if (isConfirmed(currentChainHeight, minConfirms)) {
// } else if ((_transaction.numberOfMessages ?? 0) > 1) { return "Sent (confirmed)";
// return "Sending (waiting for confirmations)"; } else {
// } else { if (numberOfMessages == 1) {
// return "Sending"; return "Sending (waiting for receiver)";
// } } else if ((numberOfMessages ?? 0) > 1) {
// } return "Sending (waiting for confirmations)";
// } } else {
// } return "Sending";
}
}
}
}
if (type == TransactionType.incoming) { if (type == TransactionType.incoming) {
// if (_transaction.isMinting) { // if (_transaction.isMinting) {
@ -198,6 +210,14 @@ class TransactionV2 {
} }
} }
dynamic _getFromOtherData({required dynamic key}) {
if (otherData == null) {
return null;
}
final map = jsonDecode(otherData!);
return map[key];
}
@override @override
String toString() { String toString() {
return 'TransactionV2(\n' return 'TransactionV2(\n'

View file

@ -38,46 +38,71 @@ const TransactionV2Schema = CollectionSchema(
type: IsarType.objectList, type: IsarType.objectList,
target: r'InputV2', target: r'InputV2',
), ),
r'otherData': PropertySchema( r'isCancelled': PropertySchema(
id: 4, id: 4,
name: r'isCancelled',
type: IsarType.bool,
),
r'isEpiccashTransaction': PropertySchema(
id: 5,
name: r'isEpiccashTransaction',
type: IsarType.bool,
),
r'numberOfMessages': PropertySchema(
id: 6,
name: r'numberOfMessages',
type: IsarType.long,
),
r'onChainNote': PropertySchema(
id: 7,
name: r'onChainNote',
type: IsarType.string,
),
r'otherData': PropertySchema(
id: 8,
name: r'otherData', name: r'otherData',
type: IsarType.string, type: IsarType.string,
), ),
r'outputs': PropertySchema( r'outputs': PropertySchema(
id: 5, id: 9,
name: r'outputs', name: r'outputs',
type: IsarType.objectList, type: IsarType.objectList,
target: r'OutputV2', target: r'OutputV2',
), ),
r'slateId': PropertySchema(
id: 10,
name: r'slateId',
type: IsarType.string,
),
r'subType': PropertySchema( r'subType': PropertySchema(
id: 6, id: 11,
name: r'subType', name: r'subType',
type: IsarType.byte, type: IsarType.byte,
enumMap: _TransactionV2subTypeEnumValueMap, enumMap: _TransactionV2subTypeEnumValueMap,
), ),
r'timestamp': PropertySchema( r'timestamp': PropertySchema(
id: 7, id: 12,
name: r'timestamp', name: r'timestamp',
type: IsarType.long, type: IsarType.long,
), ),
r'txid': PropertySchema( r'txid': PropertySchema(
id: 8, id: 13,
name: r'txid', name: r'txid',
type: IsarType.string, type: IsarType.string,
), ),
r'type': PropertySchema( r'type': PropertySchema(
id: 9, id: 14,
name: r'type', name: r'type',
type: IsarType.byte, type: IsarType.byte,
enumMap: _TransactionV2typeEnumValueMap, enumMap: _TransactionV2typeEnumValueMap,
), ),
r'version': PropertySchema( r'version': PropertySchema(
id: 10, id: 15,
name: r'version', name: r'version',
type: IsarType.long, type: IsarType.long,
), ),
r'walletId': PropertySchema( r'walletId': PropertySchema(
id: 11, id: 16,
name: r'walletId', name: r'walletId',
type: IsarType.string, type: IsarType.string,
) )
@ -166,6 +191,12 @@ int _transactionV2EstimateSize(
bytesCount += InputV2Schema.estimateSize(value, offsets, allOffsets); bytesCount += InputV2Schema.estimateSize(value, offsets, allOffsets);
} }
} }
{
final value = object.onChainNote;
if (value != null) {
bytesCount += 3 + value.length * 3;
}
}
{ {
final value = object.otherData; final value = object.otherData;
if (value != null) { if (value != null) {
@ -180,6 +211,12 @@ int _transactionV2EstimateSize(
bytesCount += OutputV2Schema.estimateSize(value, offsets, allOffsets); bytesCount += OutputV2Schema.estimateSize(value, offsets, allOffsets);
} }
} }
{
final value = object.slateId;
if (value != null) {
bytesCount += 3 + value.length * 3;
}
}
bytesCount += 3 + object.txid.length * 3; bytesCount += 3 + object.txid.length * 3;
bytesCount += 3 + object.walletId.length * 3; bytesCount += 3 + object.walletId.length * 3;
return bytesCount; return bytesCount;
@ -200,19 +237,24 @@ void _transactionV2Serialize(
InputV2Schema.serialize, InputV2Schema.serialize,
object.inputs, object.inputs,
); );
writer.writeString(offsets[4], object.otherData); writer.writeBool(offsets[4], object.isCancelled);
writer.writeBool(offsets[5], object.isEpiccashTransaction);
writer.writeLong(offsets[6], object.numberOfMessages);
writer.writeString(offsets[7], object.onChainNote);
writer.writeString(offsets[8], object.otherData);
writer.writeObjectList<OutputV2>( writer.writeObjectList<OutputV2>(
offsets[5], offsets[9],
allOffsets, allOffsets,
OutputV2Schema.serialize, OutputV2Schema.serialize,
object.outputs, object.outputs,
); );
writer.writeByte(offsets[6], object.subType.index); writer.writeString(offsets[10], object.slateId);
writer.writeLong(offsets[7], object.timestamp); writer.writeByte(offsets[11], object.subType.index);
writer.writeString(offsets[8], object.txid); writer.writeLong(offsets[12], object.timestamp);
writer.writeByte(offsets[9], object.type.index); writer.writeString(offsets[13], object.txid);
writer.writeLong(offsets[10], object.version); writer.writeByte(offsets[14], object.type.index);
writer.writeString(offsets[11], object.walletId); writer.writeLong(offsets[15], object.version);
writer.writeString(offsets[16], object.walletId);
} }
TransactionV2 _transactionV2Deserialize( TransactionV2 _transactionV2Deserialize(
@ -232,23 +274,23 @@ TransactionV2 _transactionV2Deserialize(
InputV2(), InputV2(),
) ?? ) ??
[], [],
otherData: reader.readStringOrNull(offsets[4]), otherData: reader.readStringOrNull(offsets[8]),
outputs: reader.readObjectList<OutputV2>( outputs: reader.readObjectList<OutputV2>(
offsets[5], offsets[9],
OutputV2Schema.deserialize, OutputV2Schema.deserialize,
allOffsets, allOffsets,
OutputV2(), OutputV2(),
) ?? ) ??
[], [],
subType: subType:
_TransactionV2subTypeValueEnumMap[reader.readByteOrNull(offsets[6])] ?? _TransactionV2subTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ??
TransactionSubType.none, TransactionSubType.none,
timestamp: reader.readLong(offsets[7]), timestamp: reader.readLong(offsets[12]),
txid: reader.readString(offsets[8]), txid: reader.readString(offsets[13]),
type: _TransactionV2typeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? type: _TransactionV2typeValueEnumMap[reader.readByteOrNull(offsets[14])] ??
TransactionType.outgoing, TransactionType.outgoing,
version: reader.readLong(offsets[10]), version: reader.readLong(offsets[15]),
walletId: reader.readString(offsets[11]), walletId: reader.readString(offsets[16]),
); );
object.id = id; object.id = id;
return object; return object;
@ -276,8 +318,16 @@ P _transactionV2DeserializeProp<P>(
) ?? ) ??
[]) as P; []) as P;
case 4: case 4:
return (reader.readStringOrNull(offset)) as P; return (reader.readBool(offset)) as P;
case 5: case 5:
return (reader.readBool(offset)) as P;
case 6:
return (reader.readLongOrNull(offset)) as P;
case 7:
return (reader.readStringOrNull(offset)) as P;
case 8:
return (reader.readStringOrNull(offset)) as P;
case 9:
return (reader.readObjectList<OutputV2>( return (reader.readObjectList<OutputV2>(
offset, offset,
OutputV2Schema.deserialize, OutputV2Schema.deserialize,
@ -285,20 +335,22 @@ P _transactionV2DeserializeProp<P>(
OutputV2(), OutputV2(),
) ?? ) ??
[]) as P; []) as P;
case 6: case 10:
return (reader.readStringOrNull(offset)) as P;
case 11:
return (_TransactionV2subTypeValueEnumMap[ return (_TransactionV2subTypeValueEnumMap[
reader.readByteOrNull(offset)] ?? reader.readByteOrNull(offset)] ??
TransactionSubType.none) as P; TransactionSubType.none) as P;
case 7: case 12:
return (reader.readLong(offset)) as P; return (reader.readLong(offset)) as P;
case 8: case 13:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
case 9: case 14:
return (_TransactionV2typeValueEnumMap[reader.readByteOrNull(offset)] ?? return (_TransactionV2typeValueEnumMap[reader.readByteOrNull(offset)] ??
TransactionType.outgoing) as P; TransactionType.outgoing) as P;
case 10: case 15:
return (reader.readLong(offset)) as P; return (reader.readLong(offset)) as P;
case 11: case 16:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
default: default:
throw IsarError('Unknown property with id $propertyId'); throw IsarError('Unknown property with id $propertyId');
@ -1263,6 +1315,254 @@ extension TransactionV2QueryFilter
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
isCancelledEqualTo(bool value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'isCancelled',
value: value,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
isEpiccashTransactionEqualTo(bool value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'isEpiccashTransaction',
value: value,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'numberOfMessages',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'numberOfMessages',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesEqualTo(int? value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'numberOfMessages',
value: value,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesGreaterThan(
int? value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'numberOfMessages',
value: value,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesLessThan(
int? value, {
bool include = false,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'numberOfMessages',
value: value,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
numberOfMessagesBetween(
int? lower,
int? upper, {
bool includeLower = true,
bool includeUpper = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.between(
property: r'numberOfMessages',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'onChainNote',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'onChainNote',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteGreaterThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteLessThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteBetween(
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'onChainNote',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteStartsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.startsWith(
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteEndsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.endsWith(
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteContains(String value, {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.contains(
property: r'onChainNote',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteMatches(String pattern, {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.matches(
property: r'onChainNote',
wildcard: pattern,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteIsEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'onChainNote',
value: '',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
onChainNoteIsNotEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
property: r'onChainNote',
value: '',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition> QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
otherDataIsNull() { otherDataIsNull() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -1506,6 +1806,160 @@ extension TransactionV2QueryFilter
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'slateId',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'slateId',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdGreaterThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
include: include,
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdLessThan(
String? value, {
bool include = false,
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.lessThan(
include: include,
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdBetween(
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'slateId',
lower: lower,
includeLower: includeLower,
upper: upper,
includeUpper: includeUpper,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdStartsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.startsWith(
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdEndsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.endsWith(
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdContains(String value, {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.contains(
property: r'slateId',
value: value,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdMatches(String pattern, {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.matches(
property: r'slateId',
wildcard: pattern,
caseSensitive: caseSensitive,
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdIsEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'slateId',
value: '',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
slateIdIsNotEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.greaterThan(
property: r'slateId',
value: '',
));
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition> QueryBuilder<TransactionV2, TransactionV2, QAfterFilterCondition>
subTypeEqualTo(TransactionSubType value) { subTypeEqualTo(TransactionSubType value) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -2060,6 +2514,60 @@ extension TransactionV2QuerySortBy
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortByIsCancelled() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isCancelled', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByIsCancelledDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isCancelled', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByIsEpiccashTransaction() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isEpiccashTransaction', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByIsEpiccashTransactionDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isEpiccashTransaction', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByNumberOfMessagesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortByOnChainNote() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'onChainNote', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
sortByOnChainNoteDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'onChainNote', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortByOtherData() { QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortByOtherData() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc); return query.addSortBy(r'otherData', Sort.asc);
@ -2073,6 +2581,18 @@ extension TransactionV2QuerySortBy
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortBySlateId() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'slateId', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortBySlateIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'slateId', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortBySubType() { QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> sortBySubType() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'subType', Sort.asc); return query.addSortBy(r'subType', Sort.asc);
@ -2199,6 +2719,60 @@ extension TransactionV2QuerySortThenBy
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenByIsCancelled() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isCancelled', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByIsCancelledDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isCancelled', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByIsEpiccashTransaction() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isEpiccashTransaction', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByIsEpiccashTransactionDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'isEpiccashTransaction', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByNumberOfMessagesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenByOnChainNote() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'onChainNote', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy>
thenByOnChainNoteDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'onChainNote', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenByOtherData() { QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenByOtherData() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc); return query.addSortBy(r'otherData', Sort.asc);
@ -2212,6 +2786,18 @@ extension TransactionV2QuerySortThenBy
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenBySlateId() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'slateId', Sort.asc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenBySlateIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'slateId', Sort.desc);
});
}
QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenBySubType() { QueryBuilder<TransactionV2, TransactionV2, QAfterSortBy> thenBySubType() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'subType', Sort.asc); return query.addSortBy(r'subType', Sort.asc);
@ -2309,6 +2895,34 @@ extension TransactionV2QueryWhereDistinct
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QDistinct>
distinctByIsCancelled() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'isCancelled');
});
}
QueryBuilder<TransactionV2, TransactionV2, QDistinct>
distinctByIsEpiccashTransaction() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'isEpiccashTransaction');
});
}
QueryBuilder<TransactionV2, TransactionV2, QDistinct>
distinctByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'numberOfMessages');
});
}
QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctByOnChainNote(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'onChainNote', caseSensitive: caseSensitive);
});
}
QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctByOtherData( QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctByOtherData(
{bool caseSensitive = true}) { {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -2316,6 +2930,13 @@ extension TransactionV2QueryWhereDistinct
}); });
} }
QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctBySlateId(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'slateId', caseSensitive: caseSensitive);
});
}
QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctBySubType() { QueryBuilder<TransactionV2, TransactionV2, QDistinct> distinctBySubType() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'subType'); return query.addDistinctBy(r'subType');
@ -2388,6 +3009,32 @@ extension TransactionV2QueryProperty
}); });
} }
QueryBuilder<TransactionV2, bool, QQueryOperations> isCancelledProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'isCancelled');
});
}
QueryBuilder<TransactionV2, bool, QQueryOperations>
isEpiccashTransactionProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'isEpiccashTransaction');
});
}
QueryBuilder<TransactionV2, int?, QQueryOperations>
numberOfMessagesProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'numberOfMessages');
});
}
QueryBuilder<TransactionV2, String?, QQueryOperations> onChainNoteProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'onChainNote');
});
}
QueryBuilder<TransactionV2, String?, QQueryOperations> otherDataProperty() { QueryBuilder<TransactionV2, String?, QQueryOperations> otherDataProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'otherData'); return query.addPropertyName(r'otherData');
@ -2401,6 +3048,12 @@ extension TransactionV2QueryProperty
}); });
} }
QueryBuilder<TransactionV2, String?, QQueryOperations> slateIdProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'slateId');
});
}
QueryBuilder<TransactionV2, TransactionSubType, QQueryOperations> QueryBuilder<TransactionV2, TransactionSubType, QQueryOperations>
subTypeProperty() { subTypeProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {

View file

@ -10,6 +10,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
@ -50,6 +51,8 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart'; import 'package:stackwallet/wallets/wallet/wallet.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
@ -202,6 +205,7 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
mnemonic = mnemonic.trim(); mnemonic = mnemonic.trim();
int height = 0; int height = 0;
String? otherDataJsonString;
if (widget.coin == Coin.monero) { if (widget.coin == Coin.monero) {
height = monero.getHeigthByDate(date: widget.restoreFromDate); height = monero.getHeigthByDate(date: widget.restoreFromDate);
@ -228,6 +232,22 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
if (height < 0) { if (height < 0) {
height = 0; height = 0;
} }
otherDataJsonString = jsonEncode(
{
WalletInfoKeys.epiccashData: jsonEncode(
ExtraEpiccashWalletInfo(
receivingIndex: 0,
changeIndex: 0,
slatesToAddresses: {},
slatesToCommits: {},
lastScannedBlock: height,
restoreHeight: height,
creationHeight: height,
).toMap(),
),
},
);
} }
// TODO: do actual check to make sure it is a valid mnemonic for monero // TODO: do actual check to make sure it is a valid mnemonic for monero
@ -244,6 +264,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
final info = WalletInfo.createNew( final info = WalletInfo.createNew(
coin: widget.coin, coin: widget.coin,
name: widget.walletName, name: widget.walletName,
restoreHeight: height,
otherDataJsonString: otherDataJsonString,
); );
bool isRestoring = true; bool isRestoring = true;
@ -292,7 +314,12 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
mnemonic: mnemonic, mnemonic: mnemonic,
); );
await wallet.init(); if (wallet is EpiccashWallet) {
await wallet.init(isRestore: true);
} else {
await wallet.init();
}
await wallet.recover(isRescan: false); await wallet.recover(isRescan: false);
// check if state is still active before continuing // check if state is still active before continuing

View file

@ -30,7 +30,6 @@ import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_set
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart';
@ -40,6 +39,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/show_loading.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -470,11 +470,11 @@ class _EpiBoxInfoFormState extends ConsumerState<EpicBoxInfoForm> {
final hostController = TextEditingController(); final hostController = TextEditingController();
final portController = TextEditingController(); final portController = TextEditingController();
late EpicCashWallet wallet; late EpiccashWallet wallet;
@override @override
void initState() { void initState() {
wallet = ref.read(pWallets).getWallet(widget.walletId) as EpicCashWallet; wallet = ref.read(pWallets).getWallet(widget.walletId) as EpiccashWallet;
wallet.getEpicBoxConfig().then((EpicBoxConfigModel epicBoxConfig) { wallet.getEpicBoxConfig().then((EpicBoxConfigModel epicBoxConfig) {
hostController.text = epicBoxConfig.host; hostController.text = epicBoxConfig.host;

View file

@ -26,7 +26,6 @@ import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/providers/db/main_db_provider.dart'; import 'package:stackwallet/providers/db/main_db_provider.dart';
import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart'; import 'package:stackwallet/utilities/amount/amount_formatter.dart';
@ -39,6 +38,7 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -1592,7 +1592,7 @@ class _TransactionDetailsViewState
onPressed: () async { onPressed: () async {
final wallet = ref.read(pWallets).getWallet(walletId); final wallet = ref.read(pWallets).getWallet(walletId);
if (wallet is EpicCashWallet) { if (wallet is EpiccashWallet) {
final String? id = _transaction.slateId; final String? id = _transaction.slateId;
if (id == null) { if (id == null) {
unawaited(showFloatingFlushBar( unawaited(showFloatingFlushBar(
@ -1610,8 +1610,8 @@ class _TransactionDetailsViewState
const CancellingTransactionProgressDialog(), const CancellingTransactionProgressDialog(),
)); ));
final result = await (wallet as EpicCashWallet) final result =
.cancelPendingTransactionAndPost(id); await wallet.cancelPendingTransactionAndPost(id);
if (mounted) { if (mounted) {
// pop progress dialog // pop progress dialog
Navigator.of(context).pop(); Navigator.of(context).pop();

View file

@ -19,7 +19,9 @@ import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
@ -34,6 +36,7 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -107,7 +110,25 @@ class _TransactionV2DetailsViewState
unit = coin.ticker; unit = coin.ticker;
if (_transaction.subType == TransactionSubType.cashFusion) { if (_transaction.isEpiccashTransaction) {
switch (_transaction.type) {
case TransactionType.outgoing:
case TransactionType.unknown:
amount = _transaction.getAmountSentFromThisWallet(coin: coin);
break;
case TransactionType.incoming:
case TransactionType.sentToSelf:
amount = _transaction.getAmountReceivedInThisWallet(coin: coin);
break;
}
data = _transaction.outputs
.map((e) => (
addresses: e.addresses,
amount: Amount(rawValue: e.value, fractionDigits: coin.decimals)
))
.toList();
} else if (_transaction.subType == TransactionSubType.cashFusion) {
amount = _transaction.getAmountReceivedInThisWallet(coin: coin); amount = _transaction.getAmountReceivedInThisWallet(coin: coin);
data = _transaction.outputs data = _transaction.outputs
.where((e) => e.walletOwns) .where((e) => e.walletOwns)
@ -1448,7 +1469,68 @@ class _TransactionV2DetailsViewState
// ], // ],
// ), // ),
// ), // ),
if (coin == Coin.epicCash)
isDesktop
? const _Divider()
: const SizedBox(
height: 12,
),
if (coin == Coin.epicCash)
RoundedWhiteContainer(
padding: isDesktop
? const EdgeInsets.all(16)
: const EdgeInsets.all(12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Slate ID",
style: isDesktop
? STextStyles
.desktopTextExtraExtraSmall(
context)
: STextStyles.itemSubtitle(
context),
),
// Flexible(
// child: FittedBox(
// fit: BoxFit.scaleDown,
// child:
SelectableText(
_transaction.slateId ?? "Unknown",
style: isDesktop
? STextStyles
.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
)
: STextStyles.itemSubtitle12(
context),
),
// ),
// ),
],
),
if (isDesktop)
const SizedBox(
width: 12,
),
if (isDesktop)
IconCopyButton(
data: _transaction.slateId ?? "Unknown",
),
],
),
),
if (!isDesktop) if (!isDesktop)
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -1463,6 +1545,98 @@ class _TransactionV2DetailsViewState
], ],
), ),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: (coin == Coin.epicCash &&
_transaction.getConfirmations(currentHeight) < 1 &&
_transaction.isCancelled == false)
? ConditionalParent(
condition: isDesktop,
builder: (child) => Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32,
vertical: 16,
),
child: child,
),
child: SizedBox(
width: MediaQuery.of(context).size.width - 32,
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).extension<StackColors>()!.textError,
),
),
onPressed: () async {
final wallet = ref.read(pWallets).getWallet(walletId);
if (wallet is EpiccashWallet) {
final String? id = _transaction.slateId;
if (id == null) {
unawaited(showFloatingFlushBar(
type: FlushBarType.warning,
message: "Could not find Epic transaction ID",
context: context,
));
return;
}
unawaited(
showDialog<void>(
barrierDismissible: false,
context: context,
builder: (_) =>
const CancellingTransactionProgressDialog(),
),
);
final result =
await wallet.cancelPendingTransactionAndPost(id);
if (mounted) {
// pop progress dialog
Navigator.of(context).pop();
if (result.isEmpty) {
await showDialog<dynamic>(
context: context,
builder: (_) => StackOkDialog(
title: "Transaction cancelled",
onOkPressed: (_) {
wallet.refresh();
Navigator.of(context).popUntil(
ModalRoute.withName(
WalletView.routeName,
),
);
},
),
);
} else {
await showDialog<dynamic>(
context: context,
builder: (_) => StackOkDialog(
title: "Failed to cancel transaction",
message: result,
),
);
}
}
} else {
unawaited(showFloatingFlushBar(
type: FlushBarType.warning,
message: "ERROR: Wallet type is not Epic Cash",
context: context,
));
return;
}
},
child: Text(
"Cancel Transaction",
style: STextStyles.button(context),
),
),
),
)
: null,
), ),
); );
} }

View file

@ -14,7 +14,6 @@ import 'package:stackwallet/models/balance.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models;
import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart'; import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart';
import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart';
@ -101,13 +100,7 @@ abstract class CoinServiceAPI {
throw UnimplementedError("moved"); throw UnimplementedError("moved");
case Coin.epicCash: case Coin.epicCash:
return EpicCashWallet( throw UnimplementedError("moved");
walletId: walletId,
walletName: walletName,
coin: coin,
secureStore: secureStorageInterface,
// tracker: tracker,
);
case Coin.ethereum: case Coin.ethereum:
return EthereumWallet( return EthereumWallet(

File diff suppressed because it is too large Load diff

View file

@ -1,122 +0,0 @@
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:stackwallet/db/hive/db.dart';
mixin EpicCashHive {
late final String _walletId;
void initEpicCashHive(String walletId) {
_walletId = walletId;
}
// receiving index
int? epicGetReceivingIndex() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "receivingIndex")
as int?;
}
Future<void> epicUpdateReceivingIndex(int index) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "receivingIndex",
value: index,
);
}
// change index
int? epicGetChangeIndex() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "changeIndex")
as int?;
}
Future<void> epicUpdateChangeIndex(int index) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "changeIndex",
value: index,
);
}
// slateToAddresses
Map epicGetSlatesToAddresses() {
return DB.instance.get<dynamic>(
boxName: _walletId,
key: "slate_to_address",
) as Map? ??
{};
}
Future<void> epicUpdateSlatesToAddresses(Map map) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "slate_to_address",
value: map,
);
}
// slatesToCommits
Map? epicGetSlatesToCommits() {
return DB.instance.get<dynamic>(
boxName: _walletId,
key: "slatesToCommits",
) as Map?;
}
Future<void> epicUpdateSlatesToCommits(Map map) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "slatesToCommits",
value: map,
);
}
// last scanned block
int? epicGetLastScannedBlock() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "lastScannedBlock")
as int?;
}
Future<void> epicUpdateLastScannedBlock(int blockHeight) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "lastScannedBlock",
value: blockHeight,
);
}
// epic restore height
int? epicGetRestoreHeight() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "restoreHeight")
as int?;
}
Future<void> epicUpdateRestoreHeight(int height) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "restoreHeight",
value: height,
);
}
// epic creation height
int? epicGetCreationHeight() {
return DB.instance.get<dynamic>(boxName: _walletId, key: "creationHeight")
as int?;
}
Future<void> epicUpdateCreationHeight(int height) async {
await DB.instance.put<dynamic>(
boxName: _walletId,
key: "creationHeight",
value: height,
);
}
}

View file

@ -13,7 +13,6 @@ import 'package:flutter_libmonero/wownero/wownero.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/notifications_service.dart'; import 'package:stackwallet/services/notifications_service.dart';
import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; import 'package:stackwallet/services/trade_sent_from_stack_service.dart';
@ -24,6 +23,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet.dart'; import 'package:stackwallet/wallets/wallet/wallet.dart';
class Wallets { class Wallets {

View file

@ -15,12 +15,12 @@ import 'package:flutter_libmonero/monero/monero.dart';
import 'package:flutter_libmonero/wownero/wownero.dart'; import 'package:flutter_libmonero/wownero/wownero.dart';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/notifications_service.dart'; import 'package:stackwallet/services/notifications_service.dart';
import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; import 'package:stackwallet/services/trade_sent_from_stack_service.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
class WalletInfo { class WalletInfo {

View file

@ -259,7 +259,6 @@ abstract class Constants {
case Coin.litecoinTestNet: case Coin.litecoinTestNet:
case Coin.firo: case Coin.firo:
case Coin.firoTestNet: case Coin.firoTestNet:
case Coin.epicCash:
case Coin.namecoin: case Coin.namecoin:
case Coin.particl: case Coin.particl:
case Coin.ethereum: case Coin.ethereum:
@ -270,6 +269,7 @@ abstract class Constants {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.epicCash:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestnet:
case Coin.tezos: case Coin.tezos:

View file

@ -353,7 +353,6 @@ class WalletInfo implements IsarId {
int favouriteOrderIndex = -1, int favouriteOrderIndex = -1,
int cachedChainHeight = 0, int cachedChainHeight = 0,
int restoreHeight = 0, int restoreHeight = 0,
bool isMnemonicVerified = false,
String? cachedBalanceString, String? cachedBalanceString,
String? cachedBalanceSecondaryString, String? cachedBalanceSecondaryString,
String? cachedBalanceTertiaryString, String? cachedBalanceTertiaryString,

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:isar/isar.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; import 'package:stackwallet/wallets/isar/models/wallet_info.dart';
@ -23,6 +24,18 @@ extension EpiccashWalletInfoExtension on WalletInfo {
return null; return null;
} }
} }
Future<void> updateExtraEpiccashWalletInfo({
required ExtraEpiccashWalletInfo epicData,
required Isar isar,
}) async {
await updateOtherData(
newEntries: {
WalletInfoKeys.epiccashData: jsonEncode(epicData.toMap()),
},
isar: isar,
);
}
} }
/// Holds data previously stored in hive /// Holds data previously stored in hive

File diff suppressed because it is too large Load diff