Merge branch 'amount_display_precision' into add_nano

# Conflicts:
#	lib/pages/pinpad_views/create_pin_view.dart
#	lib/widgets/custom_pin_put/custom_pin_put_state.dart
This commit is contained in:
julian 2023-05-30 09:11:41 -06:00
commit 1449814e35
99 changed files with 3790 additions and 2325 deletions

View file

@ -14,43 +14,23 @@ import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:string_validator/string_validator.dart'; import 'package:string_validator/string_validator.dart';
class CachedElectrumX { class CachedElectrumX {
final ElectrumX? electrumXClient; final ElectrumX electrumXClient;
final String server;
final int port;
final bool useSSL;
final Prefs prefs;
final List<ElectrumXNode> failovers;
static const minCacheConfirms = 30; static const minCacheConfirms = 30;
const CachedElectrumX({ const CachedElectrumX({
required this.server, required this.electrumXClient,
required this.port,
required this.useSSL,
required this.prefs,
required this.failovers,
this.electrumXClient,
}); });
factory CachedElectrumX.from({ factory CachedElectrumX.from({
required ElectrumXNode node, required ElectrumX electrumXClient,
required Prefs prefs,
required List<ElectrumXNode> failovers,
ElectrumX? electrumXClient,
}) => }) =>
CachedElectrumX( CachedElectrumX(
server: node.address, electrumXClient: electrumXClient,
port: node.port, );
useSSL: node.useSSL,
prefs: prefs,
failovers: failovers,
electrumXClient: electrumXClient);
Future<Map<String, dynamic>> getAnonymitySet({ Future<Map<String, dynamic>> getAnonymitySet({
required String groupId, required String groupId,
@ -76,16 +56,7 @@ class CachedElectrumX {
set = Map<String, dynamic>.from(cachedSet); set = Map<String, dynamic>.from(cachedSet);
} }
final client = electrumXClient ?? final newSet = await electrumXClient.getAnonymitySet(
ElectrumX(
host: server,
port: port,
useSSL: useSSL,
prefs: prefs,
failovers: failovers,
);
final newSet = await client.getAnonymitySet(
groupId: groupId, groupId: groupId,
blockhash: set["blockHash"] as String, blockhash: set["blockHash"] as String,
); );
@ -162,16 +133,8 @@ class CachedElectrumX {
final cachedTx = DB.instance.get<dynamic>( final cachedTx = DB.instance.get<dynamic>(
boxName: DB.instance.boxNameTxCache(coin: coin), key: txHash) as Map?; boxName: DB.instance.boxNameTxCache(coin: coin), key: txHash) as Map?;
if (cachedTx == null) { if (cachedTx == null) {
final client = electrumXClient ?? final Map<String, dynamic> result = await electrumXClient
ElectrumX( .getTransaction(txHash: txHash, verbose: verbose);
host: server,
port: port,
useSSL: useSSL,
prefs: prefs,
failovers: failovers,
);
final Map<String, dynamic> result =
await client.getTransaction(txHash: txHash, verbose: verbose);
result.remove("hex"); result.remove("hex");
result.remove("lelantusData"); result.remove("lelantusData");
@ -212,16 +175,8 @@ class CachedElectrumX {
final startNumber = cachedSerials.length; final startNumber = cachedSerials.length;
final client = electrumXClient ?? final serials =
ElectrumX( await electrumXClient.getUsedCoinSerials(startNumber: startNumber);
host: server,
port: port,
useSSL: useSSL,
prefs: prefs,
failovers: failovers,
);
final serials = await client.getUsedCoinSerials(startNumber: startNumber);
List<String> newSerials = []; List<String> newSerials = [];
for (final element in (serials["serials"] as List)) { for (final element in (serials["serials"] as List)) {

View file

@ -142,8 +142,12 @@ class ElectrumX {
final response = await _rpcClient!.request(jsonRequestString); final response = await _rpcClient!.request(jsonRequestString);
if (response["error"] != null) { if (response.exception != null) {
if (response["error"] throw response.exception!;
}
if (response.data["error"] != null) {
if (response.data["error"]
.toString() .toString()
.contains("No such mempool or blockchain transaction")) { .contains("No such mempool or blockchain transaction")) {
throw NoSuchTransactionException( throw NoSuchTransactionException(
@ -153,11 +157,15 @@ class ElectrumX {
} }
throw Exception( throw Exception(
"JSONRPC response \ncommand: $command \nargs: $args \nerror: $response"); "JSONRPC response\n"
" command: $command\n"
" args: $args\n"
" error: $response.data",
);
} }
currentFailoverIndex = -1; currentFailoverIndex = -1;
return response; return response.data;
} on WifiOnlyException { } on WifiOnlyException {
rethrow; rethrow;
} on SocketException { } on SocketException {
@ -238,7 +246,13 @@ class ElectrumX {
// Logging.instance.log("batch request: $request"); // Logging.instance.log("batch request: $request");
// send batch request // send batch request
final response = (await _rpcClient!.request(request)) as List<dynamic>; final jsonRpcResponse = (await _rpcClient!.request(request));
if (jsonRpcResponse.exception != null) {
throw jsonRpcResponse.exception!;
}
final response = jsonRpcResponse.data as List;
// check for errors, format and throw if there are any // check for errors, format and throw if there are any
final List<String> errors = []; final List<String> errors = [];
@ -320,6 +334,13 @@ class ElectrumX {
requestID: requestID, requestID: requestID,
command: 'blockchain.headers.subscribe', command: 'blockchain.headers.subscribe',
); );
if (response["result"] == null) {
Logging.instance.log(
"getBlockHeadTip returned null response",
level: LogLevel.Error,
);
throw 'getBlockHeadTip returned null response';
}
return Map<String, dynamic>.from(response["result"] as Map); return Map<String, dynamic>.from(response["result"] as Map);
} catch (e) { } catch (e) {
rethrow; rethrow;
@ -556,8 +577,9 @@ class ElectrumX {
bool verbose = true, bool verbose = true,
String? requestID, String? requestID,
}) async { }) async {
dynamic response;
try { try {
final response = await request( response = await request(
requestID: requestID, requestID: requestID,
command: 'blockchain.transaction.get', command: 'blockchain.transaction.get',
args: [ args: [
@ -571,6 +593,10 @@ class ElectrumX {
return Map<String, dynamic>.from(response["result"] as Map); return Map<String, dynamic>.from(response["result"] as Map);
} catch (e) { } catch (e) {
Logging.instance.log(
"getTransaction($txHash) response: $response",
level: LogLevel.Error,
);
rethrow; rethrow;
} }
} }

View file

@ -12,9 +12,11 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:mutex/mutex.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
// hacky fix to receive large jsonrpc responses // Json RPC class to handle connecting to electrumx servers
class JsonRPC { class JsonRPC {
JsonRPC({ JsonRPC({
required this.host, required this.host,
@ -22,65 +24,267 @@ class JsonRPC {
this.useSSL = false, this.useSSL = false,
this.connectionTimeout = const Duration(seconds: 60), this.connectionTimeout = const Duration(seconds: 60),
}); });
bool useSSL; final bool useSSL;
String host; final String host;
int port; final int port;
Duration connectionTimeout; final Duration connectionTimeout;
Future<dynamic> request(String jsonRpcRequest) async { final _requestMutex = Mutex();
Socket? socket; final _JsonRPCRequestQueue _requestQueue = _JsonRPCRequestQueue();
final completer = Completer<dynamic>(); Socket? _socket;
final List<int> responseData = []; StreamSubscription<Uint8List>? _subscription;
void dataHandler(List<int> data) { void _dataHandler(List<int> data) {
responseData.addAll(data); _requestQueue.nextIncompleteReq.then((req) {
if (req != null) {
req.appendDataAndCheckIfComplete(data);
// 0x0A is newline if (req.isComplete) {
// https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html _onReqCompleted(req);
if (data.last == 0x0A) {
try {
final response = json.decode(String.fromCharCodes(responseData));
completer.complete(response);
} catch (e, s) {
Logging.instance
.log("JsonRPC json.decode: $e\n$s", level: LogLevel.Error);
completer.completeError(e, s);
} finally {
socket?.destroy();
} }
} else {
Logging.instance.log(
"_dataHandler found a null req!",
level: LogLevel.Warning,
);
} }
} });
}
void errorHandler(Object error, StackTrace trace) { void _errorHandler(Object error, StackTrace trace) {
Logging.instance _requestQueue.nextIncompleteReq.then((req) {
.log("JsonRPC errorHandler: $error\n$trace", level: LogLevel.Error); if (req != null) {
completer.completeError(error, trace); req.completer.completeError(error, trace);
socket?.destroy(); _onReqCompleted(req);
} }
});
}
void doneHandler() { void _doneHandler() {
socket?.destroy(); disconnect(reason: "JsonRPC _doneHandler() called");
}
void _onReqCompleted(_JsonRPCRequest req) {
_requestQueue.remove(req).then((_) {
// attempt to send next request
_sendNextAvailableRequest();
});
}
void _sendNextAvailableRequest() {
_requestQueue.nextIncompleteReq.then((req) {
if (req != null) {
// \r\n required by electrumx server
_socket!.write('${req.jsonRequest}\r\n');
// TODO different timeout length?
req.initiateTimeout(
const Duration(seconds: 10),
onTimedOut: () {
_requestQueue.remove(req);
},
);
}
});
}
Future<JsonRPCResponse> request(String jsonRpcRequest) async {
await _requestMutex.protect(() async {
if (_socket == null) {
Logging.instance.log(
"JsonRPC request: opening socket $host:$port",
level: LogLevel.Info,
);
await connect();
}
});
final req = _JsonRPCRequest(
jsonRequest: jsonRpcRequest,
completer: Completer<JsonRPCResponse>(),
);
final future = req.completer.future.onError(
(error, stackTrace) async {
await disconnect(
reason: "return req.completer.future.onError: $error\n$stackTrace",
);
return JsonRPCResponse(
exception: error is Exception
? error
: Exception(
"req.completer.future.onError: $error\n$stackTrace",
),
);
},
);
// if this is the only/first request then send it right away
await _requestQueue.add(
req,
onInitialRequestAdded: _sendNextAvailableRequest,
);
return future;
}
Future<void> disconnect({required String reason}) async {
await _requestMutex.protect(() async {
await _subscription?.cancel();
_subscription = null;
_socket?.destroy();
_socket = null;
// clean up remaining queue
await _requestQueue.completeRemainingWithError(
"JsonRPC disconnect() called with reason: \"$reason\"",
);
});
}
Future<void> connect() async {
if (_socket != null) {
throw Exception(
"JsonRPC attempted to connect to an already existing socket!",
);
} }
if (useSSL) { if (useSSL) {
await SecureSocket.connect(host, port, _socket = await SecureSocket.connect(
timeout: connectionTimeout, host,
onBadCertificate: (_) => true).then((Socket sock) { port,
socket = sock; timeout: connectionTimeout,
socket?.listen(dataHandler, onBadCertificate: (_) => true,
onError: errorHandler, onDone: doneHandler, cancelOnError: true); ); // TODO do not automatically trust bad certificates
});
} else { } else {
await Socket.connect(host, port, timeout: connectionTimeout) _socket = await Socket.connect(
.then((Socket sock) { host,
socket = sock; port,
socket?.listen(dataHandler, timeout: connectionTimeout,
onError: errorHandler, onDone: doneHandler, cancelOnError: true); );
});
} }
socket?.write('$jsonRpcRequest\r\n'); _subscription = _socket!.listen(
_dataHandler,
return completer.future; onError: _errorHandler,
onDone: _doneHandler,
cancelOnError: true,
);
} }
} }
class _JsonRPCRequestQueue {
final _lock = Mutex();
final List<_JsonRPCRequest> _rq = [];
Future<void> add(
_JsonRPCRequest req, {
VoidCallback? onInitialRequestAdded,
}) async {
return await _lock.protect(() async {
_rq.add(req);
if (_rq.length == 1) {
onInitialRequestAdded?.call();
}
});
}
Future<bool> remove(_JsonRPCRequest req) async {
return await _lock.protect(() async {
final result = _rq.remove(req);
return result;
});
}
Future<_JsonRPCRequest?> get nextIncompleteReq async {
return await _lock.protect(() async {
int removeCount = 0;
_JsonRPCRequest? returnValue;
for (final req in _rq) {
if (req.isComplete) {
removeCount++;
} else {
returnValue = req;
break;
}
}
_rq.removeRange(0, removeCount);
return returnValue;
});
}
Future<void> completeRemainingWithError(
String error, {
StackTrace? stackTrace,
}) async {
await _lock.protect(() async {
for (final req in _rq) {
if (!req.isComplete) {
req.completer.completeError(Exception(error), stackTrace);
}
}
_rq.clear();
});
}
Future<bool> get isEmpty async {
return await _lock.protect(() async {
return _rq.isEmpty;
});
}
}
class _JsonRPCRequest {
// 0x0A is newline
// https://electrumx-spesmilo.readthedocs.io/en/latest/protocol-basics.html
static const int separatorByte = 0x0A;
final String jsonRequest;
final Completer<JsonRPCResponse> completer;
final List<int> _responseData = [];
_JsonRPCRequest({required this.jsonRequest, required this.completer});
void appendDataAndCheckIfComplete(List<int> data) {
_responseData.addAll(data);
if (data.last == separatorByte) {
try {
final response = json.decode(String.fromCharCodes(_responseData));
completer.complete(JsonRPCResponse(data: response));
} catch (e, s) {
Logging.instance.log(
"JsonRPC json.decode: $e\n$s",
level: LogLevel.Error,
);
completer.completeError(e, s);
}
}
}
void initiateTimeout(
Duration timeout, {
VoidCallback? onTimedOut,
}) {
Future<void>.delayed(timeout).then((_) {
if (!isComplete) {
try {
throw Exception("_JsonRPCRequest timed out: $jsonRequest");
} catch (e, s) {
completer.completeError(e, s);
onTimedOut?.call();
}
}
});
}
bool get isComplete => completer.isCompleted;
}
class JsonRPCResponse {
final dynamic data;
final Exception? exception;
JsonRPCResponse({this.data, this.exception});
}

View file

@ -22,6 +22,7 @@ part 'transaction.g.dart';
@Collection() @Collection()
class Transaction { class Transaction {
Transaction({ Transaction({
required this.walletId, required this.walletId,
required this.txid, required this.txid,
@ -39,6 +40,7 @@ class Transaction {
required this.inputs, required this.inputs,
required this.outputs, required this.outputs,
required this.nonce, required this.nonce,
required this.numberOfMessages,
}); });
Tuple2<Transaction, Address?> copyWith({ Tuple2<Transaction, Address?> copyWith({
@ -60,6 +62,7 @@ class Transaction {
int? nonce, int? nonce,
Id? id, Id? id,
Address? address, Address? address,
int? numberOfMessages,
}) { }) {
return Tuple2( return Tuple2(
Transaction( Transaction(
@ -78,7 +81,8 @@ class Transaction {
otherData: otherData ?? this.otherData, otherData: otherData ?? this.otherData,
nonce: nonce ?? this.nonce, nonce: nonce ?? this.nonce,
inputs: inputs ?? this.inputs, inputs: inputs ?? this.inputs,
outputs: outputs ?? this.outputs) outputs: outputs ?? this.outputs,
numberOfMessages: numberOfMessages ?? this.numberOfMessages)
..id = id ?? this.id, ..id = id ?? this.id,
address ?? this.address.value, address ?? this.address.value,
); );
@ -124,6 +128,8 @@ class Transaction {
late final List<Output> outputs; late final List<Output> outputs;
late final int? numberOfMessages;
@Backlink(to: "transactions") @Backlink(to: "transactions")
final address = IsarLink<Address>(); final address = IsarLink<Address>();
@ -164,6 +170,7 @@ class Transaction {
"address: ${address.value}, " "address: ${address.value}, "
"inputsLength: ${inputs.length}, " "inputsLength: ${inputs.length}, "
"outputsLength: ${outputs.length}, " "outputsLength: ${outputs.length}, "
"numberOfMessages: $numberOfMessages, "
"}"; "}";
String toJsonString() { String toJsonString() {
@ -185,6 +192,7 @@ class Transaction {
"address": address.value?.toJsonString(), "address": address.value?.toJsonString(),
"inputs": inputs.map((e) => e.toJsonString()).toList(), "inputs": inputs.map((e) => e.toJsonString()).toList(),
"outputs": outputs.map((e) => e.toJsonString()).toList(), "outputs": outputs.map((e) => e.toJsonString()).toList(),
"numberOfMessages": numberOfMessages,
}; };
return jsonEncode(result); return jsonEncode(result);
} }
@ -215,6 +223,7 @@ class Transaction {
outputs: List<String>.from(json["outputs"] as List) outputs: List<String>.from(json["outputs"] as List)
.map((e) => Output.fromJsonString(e)) .map((e) => Output.fromJsonString(e))
.toList(), .toList(),
numberOfMessages: json["numberOfMessages"] as int,
); );
if (json["address"] == null) { if (json["address"] == null) {
return Tuple2(transaction, null); return Tuple2(transaction, null);

View file

@ -58,46 +58,51 @@ const TransactionSchema = CollectionSchema(
name: r'nonce', name: r'nonce',
type: IsarType.long, type: IsarType.long,
), ),
r'otherData': PropertySchema( r'numberOfMessages': PropertySchema(
id: 8, id: 8,
name: r'numberOfMessages',
type: IsarType.long,
),
r'otherData': PropertySchema(
id: 9,
name: r'otherData', name: r'otherData',
type: IsarType.string, type: IsarType.string,
), ),
r'outputs': PropertySchema( r'outputs': PropertySchema(
id: 9, id: 10,
name: r'outputs', name: r'outputs',
type: IsarType.objectList, type: IsarType.objectList,
target: r'Output', target: r'Output',
), ),
r'slateId': PropertySchema( r'slateId': PropertySchema(
id: 10, id: 11,
name: r'slateId', name: r'slateId',
type: IsarType.string, type: IsarType.string,
), ),
r'subType': PropertySchema( r'subType': PropertySchema(
id: 11, id: 12,
name: r'subType', name: r'subType',
type: IsarType.byte, type: IsarType.byte,
enumMap: _TransactionsubTypeEnumValueMap, enumMap: _TransactionsubTypeEnumValueMap,
), ),
r'timestamp': PropertySchema( r'timestamp': PropertySchema(
id: 12, id: 13,
name: r'timestamp', name: r'timestamp',
type: IsarType.long, type: IsarType.long,
), ),
r'txid': PropertySchema( r'txid': PropertySchema(
id: 13, id: 14,
name: r'txid', name: r'txid',
type: IsarType.string, type: IsarType.string,
), ),
r'type': PropertySchema( r'type': PropertySchema(
id: 14, id: 15,
name: r'type', name: r'type',
type: IsarType.byte, type: IsarType.byte,
enumMap: _TransactiontypeEnumValueMap, enumMap: _TransactiontypeEnumValueMap,
), ),
r'walletId': PropertySchema( r'walletId': PropertySchema(
id: 15, id: 16,
name: r'walletId', name: r'walletId',
type: IsarType.string, type: IsarType.string,
) )
@ -233,19 +238,20 @@ void _transactionSerialize(
writer.writeBool(offsets[5], object.isCancelled); writer.writeBool(offsets[5], object.isCancelled);
writer.writeBool(offsets[6], object.isLelantus); writer.writeBool(offsets[6], object.isLelantus);
writer.writeLong(offsets[7], object.nonce); writer.writeLong(offsets[7], object.nonce);
writer.writeString(offsets[8], object.otherData); writer.writeLong(offsets[8], object.numberOfMessages);
writer.writeString(offsets[9], object.otherData);
writer.writeObjectList<Output>( writer.writeObjectList<Output>(
offsets[9], offsets[10],
allOffsets, allOffsets,
OutputSchema.serialize, OutputSchema.serialize,
object.outputs, object.outputs,
); );
writer.writeString(offsets[10], object.slateId); writer.writeString(offsets[11], object.slateId);
writer.writeByte(offsets[11], object.subType.index); writer.writeByte(offsets[12], object.subType.index);
writer.writeLong(offsets[12], object.timestamp); writer.writeLong(offsets[13], object.timestamp);
writer.writeString(offsets[13], object.txid); writer.writeString(offsets[14], object.txid);
writer.writeByte(offsets[14], object.type.index); writer.writeByte(offsets[15], object.type.index);
writer.writeString(offsets[15], object.walletId); writer.writeString(offsets[16], object.walletId);
} }
Transaction _transactionDeserialize( Transaction _transactionDeserialize(
@ -269,23 +275,24 @@ Transaction _transactionDeserialize(
isCancelled: reader.readBool(offsets[5]), isCancelled: reader.readBool(offsets[5]),
isLelantus: reader.readBoolOrNull(offsets[6]), isLelantus: reader.readBoolOrNull(offsets[6]),
nonce: reader.readLongOrNull(offsets[7]), nonce: reader.readLongOrNull(offsets[7]),
otherData: reader.readStringOrNull(offsets[8]), numberOfMessages: reader.readLongOrNull(offsets[8]),
otherData: reader.readStringOrNull(offsets[9]),
outputs: reader.readObjectList<Output>( outputs: reader.readObjectList<Output>(
offsets[9], offsets[10],
OutputSchema.deserialize, OutputSchema.deserialize,
allOffsets, allOffsets,
Output(), Output(),
) ?? ) ??
[], [],
slateId: reader.readStringOrNull(offsets[10]), slateId: reader.readStringOrNull(offsets[11]),
subType: subType:
_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[12])] ??
TransactionSubType.none, TransactionSubType.none,
timestamp: reader.readLong(offsets[12]), timestamp: reader.readLong(offsets[13]),
txid: reader.readString(offsets[13]), txid: reader.readString(offsets[14]),
type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[14])] ?? type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[15])] ??
TransactionType.outgoing, TransactionType.outgoing,
walletId: reader.readString(offsets[15]), walletId: reader.readString(offsets[16]),
); );
object.id = id; object.id = id;
return object; return object;
@ -321,8 +328,10 @@ P _transactionDeserializeProp<P>(
case 7: case 7:
return (reader.readLongOrNull(offset)) as P; return (reader.readLongOrNull(offset)) as P;
case 8: case 8:
return (reader.readStringOrNull(offset)) as P; return (reader.readLongOrNull(offset)) as P;
case 9: case 9:
return (reader.readStringOrNull(offset)) as P;
case 10:
return (reader.readObjectList<Output>( return (reader.readObjectList<Output>(
offset, offset,
OutputSchema.deserialize, OutputSchema.deserialize,
@ -330,19 +339,19 @@ P _transactionDeserializeProp<P>(
Output(), Output(),
) ?? ) ??
[]) as P; []) as P;
case 10:
return (reader.readStringOrNull(offset)) as P;
case 11: case 11:
return (reader.readStringOrNull(offset)) as P;
case 12:
return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ??
TransactionSubType.none) as P; TransactionSubType.none) as P;
case 12:
return (reader.readLong(offset)) as P;
case 13: case 13:
return (reader.readString(offset)) as P; return (reader.readLong(offset)) as P;
case 14: case 14:
return (reader.readString(offset)) as P;
case 15:
return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ??
TransactionType.outgoing) as P; TransactionType.outgoing) as P;
case 15: 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');
@ -1374,6 +1383,80 @@ extension TransactionQueryFilter
}); });
} }
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
numberOfMessagesIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'numberOfMessages',
));
});
}
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
numberOfMessagesIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'numberOfMessages',
));
});
}
QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
numberOfMessagesEqualTo(int? value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'numberOfMessages',
value: value,
));
});
}
QueryBuilder<Transaction, Transaction, 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<Transaction, Transaction, 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<Transaction, Transaction, 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<Transaction, Transaction, QAfterFilterCondition> QueryBuilder<Transaction, Transaction, QAfterFilterCondition>
otherDataIsNull() { otherDataIsNull() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -2320,6 +2403,20 @@ extension TransactionQuerySortBy
}); });
} }
QueryBuilder<Transaction, Transaction, QAfterSortBy>
sortByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.asc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy>
sortByNumberOfMessagesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.desc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByOtherData() { QueryBuilder<Transaction, Transaction, QAfterSortBy> sortByOtherData() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc); return query.addSortBy(r'otherData', Sort.asc);
@ -2504,6 +2601,20 @@ extension TransactionQuerySortThenBy
}); });
} }
QueryBuilder<Transaction, Transaction, QAfterSortBy>
thenByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.asc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy>
thenByNumberOfMessagesDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'numberOfMessages', Sort.desc);
});
}
QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByOtherData() { QueryBuilder<Transaction, Transaction, QAfterSortBy> thenByOtherData() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'otherData', Sort.asc); return query.addSortBy(r'otherData', Sort.asc);
@ -2634,6 +2745,13 @@ extension TransactionQueryWhereDistinct
}); });
} }
QueryBuilder<Transaction, Transaction, QDistinct>
distinctByNumberOfMessages() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'numberOfMessages');
});
}
QueryBuilder<Transaction, Transaction, QDistinct> distinctByOtherData( QueryBuilder<Transaction, Transaction, QDistinct> distinctByOtherData(
{bool caseSensitive = true}) { {bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
@ -2737,6 +2855,12 @@ extension TransactionQueryProperty
}); });
} }
QueryBuilder<Transaction, int?, QQueryOperations> numberOfMessagesProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'numberOfMessages');
});
}
QueryBuilder<Transaction, String?, QQueryOperations> otherDataProperty() { QueryBuilder<Transaction, String?, QQueryOperations> otherDataProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'otherData'); return query.addPropertyName(r'otherData');

View file

@ -165,6 +165,9 @@ class Transaction {
// @HiveField(18) // @HiveField(18)
final String? otherData; final String? otherData;
// @HiveField(16)
final int? numberOfMessages;
Transaction({ Transaction({
required this.txid, required this.txid,
required this.confirmedStatus, required this.confirmedStatus,
@ -186,6 +189,7 @@ class Transaction {
this.isCancelled = false, this.isCancelled = false,
this.slateId, this.slateId,
this.otherData, this.otherData,
this.numberOfMessages,
}); });
factory Transaction.fromJson(Map<String, dynamic> json) { factory Transaction.fromJson(Map<String, dynamic> json) {
@ -221,6 +225,7 @@ class Transaction {
isCancelled: json["isCancelled"] as bool? ?? false, isCancelled: json["isCancelled"] as bool? ?? false,
slateId: json["slateId"] as String?, slateId: json["slateId"] as String?,
otherData: json["otherData"] as String?, otherData: json["otherData"] as String?,
numberOfMessages: json["numberOfMessages"] as int?,
); );
} }
@ -279,6 +284,7 @@ class Transaction {
bool? isCancelled, bool? isCancelled,
String? slateId, String? slateId,
String? otherData, String? otherData,
int? numberOfMessages,
}) { }) {
return Transaction( return Transaction(
txid: txid ?? this.txid, txid: txid ?? this.txid,
@ -302,13 +308,14 @@ class Transaction {
isCancelled: isCancelled ?? this.isCancelled, isCancelled: isCancelled ?? this.isCancelled,
slateId: slateId ?? this.slateId, slateId: slateId ?? this.slateId,
otherData: otherData ?? this.otherData, otherData: otherData ?? this.otherData,
numberOfMessages: numberOfMessages ?? this.numberOfMessages,
); );
} }
@override @override
String toString() { String toString() {
String transaction = String transaction =
"{txid: $txid, type: $txType, subType: $subType, value: $amount, fee: $fees, height: $height, confirm: $confirmedStatus, confirmations: $confirmations, address: $address, timestamp: $timestamp, worthNow: $worthNow, inputs: $inputs, slateid: $slateId }"; "{txid: $txid, type: $txType, subType: $subType, value: $amount, fee: $fees, height: $height, confirm: $confirmedStatus, confirmations: $confirmations, address: $address, timestamp: $timestamp, worthNow: $worthNow, inputs: $inputs, slateid: $slateId, numberOfMessages: $numberOfMessages }";
return transaction; return transaction;
} }
} }

View file

@ -18,11 +18,11 @@ import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/coin_control/utxo_card.dart'; import 'package:stackwallet/pages/coin_control/utxo_card.dart';
import 'package:stackwallet/pages/coin_control/utxo_details_view.dart'; import 'package:stackwallet/pages/coin_control/utxo_details_view.dart';
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/services/mixins/coin_control_interface.dart'; import 'package:stackwallet/services/mixins/coin_control_interface.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -697,14 +697,9 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
fractionDigits: coin.decimals, fractionDigits: coin.decimals,
); );
return Text( return Text(
"${selectedSum.localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(coin))
localeServiceChangeNotifierProvider .format(selectedSum),
.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: widget.requestedTotal == null style: widget.requestedTotal == null
? STextStyles.w600_14(context) ? STextStyles.w600_14(context)
: STextStyles.w600_14(context).copyWith( : STextStyles.w600_14(context).copyWith(
@ -745,14 +740,9 @@ class _CoinControlViewState extends ConsumerState<CoinControlView> {
style: STextStyles.w600_14(context), style: STextStyles.w600_14(context),
), ),
Text( Text(
"${widget.requestedTotal!.localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(coin))
localeServiceChangeNotifierProvider .format(widget.requestedTotal!),
.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: STextStyles.w600_14(context), style: STextStyles.w600_14(context),
), ),
], ],

View file

@ -12,10 +12,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -134,15 +134,11 @@ class _UtxoCardState extends ConsumerState<UtxoCard> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
"${utxo.value.toAmountAsRaw( ref.watch(pAmountFormatter(coin)).format(
fractionDigits: coin.decimals, utxo.value.toAmountAsRaw(
).localizedStringAsFixed( fractionDigits: coin.decimals,
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
), ),
)} ${coin.ticker}", ),
style: STextStyles.w600_14(context), style: STextStyles.w600_14(context),
), ),
const SizedBox( const SizedBox(

View file

@ -16,10 +16,10 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.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/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.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';
@ -250,13 +250,11 @@ class _UtxoDetailsViewState extends ConsumerState<UtxoDetailsView> {
width: 16, width: 16,
), ),
Text( Text(
"${utxo!.value.toAmountAsRaw(fractionDigits: coin.decimals).localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(
locale: ref.watch( utxo!.value.toAmountAsRaw(
localeServiceChangeNotifierProvider.select( fractionDigits: coin.decimals,
(value) => value.locale,
),
), ),
)} ${coin.ticker}", ),
style: STextStyles.pageTitleH2(context), style: STextStyles.pageTitleH2(context),
), ),
], ],

View file

@ -23,6 +23,7 @@ import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -376,20 +377,19 @@ class _ConfirmChangeNowSendViewState
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text( Text(
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw( ref
fractionDigits: ref.watch( .watch(pAmountFormatter(ref.watch(
managerProvider
.select((value) => value.coin.decimals),
),
)).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin), managerProvider.select((value) => value.coin),
).ticker}", )))
.format(transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals),
),
)),
style: style:
STextStyles.desktopTextExtraExtraSmall(context) STextStyles.desktopTextExtraExtraSmall(context)
.copyWith( .copyWith(
@ -433,16 +433,9 @@ class _ConfirmChangeNowSendViewState
final amount = final amount =
transactionInfo["recipientAmt"] as Amount; transactionInfo["recipientAmt"] as Amount;
final total = amount + fee; final total = amount + fee;
final locale = ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
);
return Text( return Text(
"${total.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(total),
locale: locale,
)}"
" ${coin.ticker}",
style: STextStyles.itemSubtitle12(context) style: STextStyles.itemSubtitle12(context)
.copyWith( .copyWith(
color: Theme.of(context) color: Theme.of(context)
@ -615,7 +608,7 @@ class _ConfirmChangeNowSendViewState
); );
return Text( return Text(
" | ${value.localizedStringAsFixed(locale: locale)} $currency", " | ${value.fiatString(locale: locale)} $currency",
style: style:
STextStyles.desktopTextExtraExtraSmall(context) STextStyles.desktopTextExtraExtraSmall(context)
.copyWith( .copyWith(
@ -628,15 +621,11 @@ class _ConfirmChangeNowSendViewState
], ],
), ),
child: Text( child: Text(
"${(transactionInfo["recipientAmt"] as Amount).localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(ref.watch(
localeServiceChangeNotifierProvider.select( walletsChangeNotifierProvider.select(
(value) => value.locale, (value) => value.getManager(walletId).coin))))
), .format((transactionInfo["recipientAmt"] as Amount)),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -662,19 +651,20 @@ class _ConfirmChangeNowSendViewState
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
Text( Text(
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(fractionDigits: ref.watch( ref
managerProvider.select( .watch(pAmountFormatter(ref.watch(
(value) => value.coin.decimals,
),
))).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin), managerProvider.select((value) => value.coin),
).ticker}", )))
.format(
(transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
))),
),
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -766,16 +756,9 @@ class _ConfirmChangeNowSendViewState
final amount = final amount =
transactionInfo["recipientAmt"] as Amount; transactionInfo["recipientAmt"] as Amount;
final total = amount + fee; final total = amount + fee;
final locale = ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
);
return Text( return Text(
"${total.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(total),
locale: locale,
)}"
" ${coin.ticker}",
style: STextStyles.itemSubtitle12(context).copyWith( style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!

View file

@ -28,6 +28,7 @@ import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
@ -171,18 +172,15 @@ class _Step4ViewState extends ConsumerState<Step4View> {
), ),
SecondaryButton( SecondaryButton(
label: label:
"${firoWallet.balancePrivate.spendable.localizedStringAsFixed( "${ref.watch(pAmountFormatter(firoWallet.coin)).format(firoWallet.balancePrivate.spendable)} (private)",
locale: locale,
)} (private)",
onPressed: () => Navigator.of(context).pop(false), onPressed: () => Navigator.of(context).pop(false),
), ),
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
SecondaryButton( SecondaryButton(
label: "${firoWallet.balance.spendable.localizedStringAsFixed( label:
locale: locale, "${ref.watch(pAmountFormatter(firoWallet.coin)).format(firoWallet.balance.spendable)} (public)",
)} (public)",
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
), ),
const SizedBox( const SizedBox(

View file

@ -26,6 +26,7 @@ import 'package:stackwallet/services/coins/manager.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -157,13 +158,7 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
Row( Row(
children: [ children: [
Text( Text(
"You need to send ${amount.localizedStringAsFixed( "You need to send ${ref.watch(pAmountFormatter(coin)).format(amount)}",
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: isDesktop style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context) ? STextStyles.desktopTextExtraExtraSmall(context)
: STextStyles.itemSubtitle(context), : STextStyles.itemSubtitle(context),
@ -463,9 +458,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
Text( Text(
"${(manager.wallet as FiroWallet).availablePrivateBalance().localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(
locale: locale, (manager.wallet as FiroWallet)
)} ${coin.ticker}", .availablePrivateBalance(),
),
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
], ],
@ -525,9 +521,9 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
Text( Text(
"${(manager.wallet as FiroWallet).availablePublicBalance().localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(
locale: locale, (manager.wallet as FiroWallet)
)} ${coin.ticker}", .availablePublicBalance()),
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
], ],
@ -615,9 +611,9 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
), ),
if (!isFiro) if (!isFiro)
Text( Text(
"${manager.balance.spendable.localizedStringAsFixed( ref
locale: locale, .watch(pAmountFormatter(coin))
)} ${coin.ticker}", .format(manager.balance.spendable),
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
], ],

View file

@ -18,6 +18,8 @@ import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/services/exchange/exchange.dart'; import 'package:stackwallet/services/exchange/exchange.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_unit.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
@ -107,13 +109,32 @@ class _ExchangeOptionState extends ConsumerState<ExchangeOption> {
.toAmount(fractionDigits: decimals); .toAmount(fractionDigits: decimals);
} }
final rateString = Coin? coin;
"1 ${sendCurrency.ticker.toUpperCase()} ~ ${rate.localizedStringAsFixed( try {
locale: ref.watch( coin = coinFromTickerCaseInsensitive(
localeServiceChangeNotifierProvider receivingCurrency.ticker);
.select((value) => value.locale), } catch (_) {
), coin = null;
)} ${receivingCurrency.ticker.toUpperCase()}"; }
final String rateString;
if (coin != null) {
rateString = "1 ${sendCurrency.ticker.toUpperCase()} "
"~ ${ref.watch(pAmountFormatter(coin)).format(rate)}";
} else {
final formatter = AmountFormatter(
unit: AmountUnit.normal,
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
coin: Coin.bitcoin, // some sane default
maxDecimals: 8, // some sane default
);
rateString = "1 ${sendCurrency.ticker.toUpperCase()} "
"~ ${formatter.format(rate, withUnitName: false)}"
" ${receivingCurrency.ticker.toUpperCase()}";
}
return ConditionalParent( return ConditionalParent(
condition: i > 0, condition: i > 0,

View file

@ -36,6 +36,7 @@ import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_providers.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
@ -366,13 +367,9 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
trade.payInCurrency); trade.payInCurrency);
final amount = sendAmount.toAmount( final amount = sendAmount.toAmount(
fractionDigits: coin.decimals); fractionDigits: coin.decimals);
text = amount.localizedStringAsFixed( text = ref
locale: ref.watch( .watch(pAmountFormatter(coin))
localeServiceChangeNotifierProvider.select( .format(amount);
(value) => value.locale,
),
),
);
} catch (_) { } catch (_) {
text = sendAmount.toStringAsFixed( text = sendAmount.toStringAsFixed(
trade.payInCurrency.toLowerCase() == "xmr" trade.payInCurrency.toLowerCase() == "xmr"

View file

@ -9,9 +9,11 @@
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -22,7 +24,7 @@ import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
class ConfirmPaynymConnectDialog extends StatelessWidget { class ConfirmPaynymConnectDialog extends ConsumerWidget {
const ConfirmPaynymConnectDialog({ const ConfirmPaynymConnectDialog({
Key? key, Key? key,
required this.nymName, required this.nymName,
@ -40,14 +42,14 @@ class ConfirmPaynymConnectDialog extends StatelessWidget {
String get title => "Connect to $nymName"; String get title => "Connect to $nymName";
String get message => "A one-time connection fee of " String message(String amountString) => "A one-time connection fee of "
"${amount.localizedStringAsFixed(locale: locale)} ${coin.ticker} " "$amountString "
"will be charged to connect to this PayNym.\n\nThis fee " "will be charged to connect to this PayNym.\n\nThis fee "
"covers the cost of creating a one-time transaction to create a " "covers the cost of creating a one-time transaction to create a "
"record on the blockchain. This keeps PayNyms decentralized."; "record on the blockchain. This keeps PayNyms decentralized.";
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context, WidgetRef ref) {
if (Util.isDesktop) { if (Util.isDesktop) {
return DesktopDialog( return DesktopDialog(
maxHeight: double.infinity, maxHeight: double.infinity,
@ -86,7 +88,7 @@ class ConfirmPaynymConnectDialog extends StatelessWidget {
right: 40, right: 40,
), ),
child: Text( child: Text(
message, message(ref.watch(pAmountFormatter(coin)).format(amount)),
style: STextStyles.desktopTextMedium(context).copyWith( style: STextStyles.desktopTextMedium(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textDark3, color: Theme.of(context).extension<StackColors>()!.textDark3,
), ),
@ -133,7 +135,7 @@ class ConfirmPaynymConnectDialog extends StatelessWidget {
width: 24, width: 24,
height: 24, height: 24,
), ),
message: message, message: message(ref.watch(pAmountFormatter(coin)).format(amount)),
leftButton: SecondaryButton( leftButton: SecondaryButton(
buttonHeight: ButtonHeight.xl, buttonHeight: ButtonHeight.xl,
label: "Cancel", label: "Cancel",

View file

@ -8,6 +8,7 @@
* *
*/ */
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -19,7 +20,6 @@ import 'package:stackwallet/providers/global/secure_store_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/biometrics.dart'; import 'package:stackwallet/utilities/biometrics.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
@ -45,10 +45,11 @@ class CreatePinView extends ConsumerStatefulWidget {
class _CreatePinViewState extends ConsumerState<CreatePinView> { class _CreatePinViewState extends ConsumerState<CreatePinView> {
BoxDecoration get _pinPutDecoration { BoxDecoration get _pinPutDecoration {
return BoxDecoration( return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle3, color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all( border: Border.all(
width: 1, width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3), color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
); );
} }
@ -67,10 +68,13 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
late SecureStorageInterface _secureStore; late SecureStorageInterface _secureStore;
late Biometrics biometrics; late Biometrics biometrics;
int pinCount = 1;
@override @override
initState() { initState() {
_secureStore = ref.read(secureStoreProvider); _secureStore = ref.read(secureStoreProvider);
biometrics = widget.biometrics; biometrics = widget.biometrics;
super.initState(); super.initState();
} }
@ -81,11 +85,13 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
_pinPutController2.dispose(); _pinPutController2.dispose();
_pinPutFocusNode1.dispose(); _pinPutFocusNode1.dispose();
_pinPutFocusNode2.dispose(); _pinPutFocusNode2.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// int pinCount = 1;
return Background( return Background(
child: Scaffold( child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background, backgroundColor: Theme.of(context).extension<StackColors>()!.background,
@ -126,7 +132,7 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
height: 36, height: 36,
), ),
CustomPinPut( CustomPinPut(
fieldsCount: Constants.pinLength, fieldsCount: pinCount,
eachFieldHeight: 12, eachFieldHeight: 12,
eachFieldWidth: 12, eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith( textStyle: STextStyles.label(context).copyWith(
@ -150,21 +156,23 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
), ),
isRandom: isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN, ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith( submittedFieldDecoration: _pinPutDecoration,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
selectedFieldDecoration: _pinPutDecoration, selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration, followingFieldDecoration: _pinPutDecoration,
onPinLengthChanged: (newLength) {
setState(() {
pinCount = newLength;
});
},
onSubmit: (String pin) { onSubmit: (String pin) {
if (pin.length == Constants.pinLength) { if (pin.length < 4) {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "PIN not long enough!",
iconAsset: Assets.svg.alertCircle,
context: context,
);
} else {
_pageController.nextPage( _pageController.nextPage(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
curve: Curves.linear, curve: Curves.linear,
@ -194,7 +202,7 @@ class _CreatePinViewState extends ConsumerState<CreatePinView> {
height: 36, height: 36,
), ),
CustomPinPut( CustomPinPut(
fieldsCount: Constants.pinLength, fieldsCount: pinCount,
eachFieldHeight: 12, eachFieldHeight: 12,
eachFieldWidth: 12, eachFieldWidth: 12,
textStyle: STextStyles.infoSmall(context).copyWith( textStyle: STextStyles.infoSmall(context).copyWith(

View file

@ -23,7 +23,6 @@ import 'package:stackwallet/themes/stack_colors.dart';
// import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart'; // import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/biometrics.dart'; import 'package:stackwallet/utilities/biometrics.dart';
import 'package:stackwallet/utilities/constants.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/show_loading.dart'; import 'package:stackwallet/utilities/show_loading.dart';
@ -199,10 +198,11 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
BoxDecoration get _pinPutDecoration { BoxDecoration get _pinPutDecoration {
return BoxDecoration( return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle2, color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all( border: Border.all(
width: 1, width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle2), color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
); );
} }
@ -212,6 +212,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
late SecureStorageInterface _secureStore; late SecureStorageInterface _secureStore;
late Biometrics biometrics; late Biometrics biometrics;
int pinCount = 1;
Widget get _body => Background( Widget get _body => Background(
child: SafeArea( child: SafeArea(
@ -284,13 +285,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
height: 52, height: 52,
), ),
CustomPinPut( CustomPinPut(
// customKey: CustomKey( fieldsCount: pinCount,
// onPressed: _checkUseBiometrics,
// iconAssetName: Platform.isIOS
// ? Assets.svg.faceId
// : Assets.svg.fingerprint,
// ),
fieldsCount: Constants.pinLength,
eachFieldHeight: 12, eachFieldHeight: 12,
eachFieldWidth: 12, eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith( textStyle: STextStyles.label(context).copyWith(
@ -312,19 +307,7 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
.background, .background,
counterText: "", counterText: "",
), ),
submittedFieldDecoration: _pinPutDecoration.copyWith( submittedFieldDecoration: _pinPutDecoration,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration,
isRandom: ref isRandom: ref
.read(prefsChangeNotifierProvider) .read(prefsChangeNotifierProvider)
.randomizePIN, .randomizePIN,

View file

@ -160,6 +160,7 @@ class _GenerateUriQrCodeViewState extends State<GenerateUriQrCodeView> {
String receivingAddress = widget.receivingAddress; String receivingAddress = widget.receivingAddress;
if ((widget.coin == Coin.bitcoincash || if ((widget.coin == Coin.bitcoincash ||
widget.coin == Coin.eCash ||
widget.coin == Coin.bitcoincashTestnet) && widget.coin == Coin.bitcoincashTestnet) &&
receivingAddress.contains(":")) { receivingAddress.contains(":")) {
// remove cash addr prefix // remove cash addr prefix
@ -256,6 +257,7 @@ class _GenerateUriQrCodeViewState extends State<GenerateUriQrCodeView> {
String receivingAddress = widget.receivingAddress; String receivingAddress = widget.receivingAddress;
if ((widget.coin == Coin.bitcoincash || if ((widget.coin == Coin.bitcoincash ||
widget.coin == Coin.eCash ||
widget.coin == Coin.bitcoincashTestnet) && widget.coin == Coin.bitcoincashTestnet) &&
receivingAddress.contains(":")) { receivingAddress.contains(":")) {
// remove cash addr prefix // remove cash addr prefix

View file

@ -32,6 +32,7 @@ import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_providers.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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -287,13 +288,15 @@ class _ConfirmTransactionViewState
final managerProvider = ref.watch(walletsChangeNotifierProvider final managerProvider = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManagerProvider(walletId))); .select((value) => value.getManagerProvider(walletId)));
final coin = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).coin));
final String unit; final String unit;
if (widget.isTokenTx) { if (widget.isTokenTx) {
unit = ref.watch( unit = ref.watch(
tokenServiceProvider.select((value) => value!.tokenContract.symbol)); tokenServiceProvider.select((value) => value!.tokenContract.symbol));
} else { } else {
unit = ref.watch(walletsChangeNotifierProvider unit = coin.ticker;
.select((value) => value.getManager(walletId).coin.ticker));
} }
return ConditionalParent( return ConditionalParent(
@ -421,12 +424,12 @@ class _ConfirmTransactionViewState
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
Text( Text(
"${(transactionInfo["recipientAmt"] as Amount).localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(
locale: ref.watch( transactionInfo["recipientAmt"] as Amount,
localeServiceChangeNotifierProvider ethContract: ref
.select((value) => value.locale), .watch(tokenServiceProvider)
), ?.tokenContract,
)} $unit", ),
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -445,20 +448,18 @@ class _ConfirmTransactionViewState
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
Text( Text(
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw( ref.watch(pAmountFormatter(coin)).format(
fractionDigits: ref.watch( (transactionInfo["fee"] is Amount
managerProvider.select( ? transactionInfo["fee"] as Amount
(value) => value.coin.decimals, : (transactionInfo["fee"] as int)
), .toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
),
)),
), ),
)).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -595,7 +596,7 @@ class _ConfirmTransactionViewState
if (price > Decimal.zero) { if (price > Decimal.zero) {
fiatAmount = (amount.decimal * price) fiatAmount = (amount.decimal * price)
.toAmount(fractionDigits: 2) .toAmount(fractionDigits: 2)
.localizedStringAsFixed( .fiatString(
locale: ref locale: ref
.read( .read(
localeServiceChangeNotifierProvider) localeServiceChangeNotifierProvider)
@ -607,12 +608,11 @@ class _ConfirmTransactionViewState
return Row( return Row(
children: [ children: [
Text( Text(
"${amount.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(
locale: ref.watch( amount,
localeServiceChangeNotifierProvider ethContract: ref
.select((value) => value.locale), .read(tokenServiceProvider)
), ?.tokenContract),
)} $unit",
style: STextStyles style: STextStyles
.desktopTextExtraExtraSmall( .desktopTextExtraExtraSmall(
context) context)
@ -722,14 +722,9 @@ class _ConfirmTransactionViewState
); );
return Text( return Text(
"${fee.localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(coin))
localeServiceChangeNotifierProvider .format(fee),
.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: style:
STextStyles.desktopTextExtraExtraSmall( STextStyles.desktopTextExtraExtraSmall(
context) context)
@ -902,13 +897,7 @@ class _ConfirmTransactionViewState
); );
return Text( return Text(
"${fee.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(fee),
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
); );
}, },
@ -962,18 +951,13 @@ class _ConfirmTransactionViewState
? transactionInfo["fee"] as Amount ? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int) : (transactionInfo["fee"] as int)
.toAmountAsRaw(fractionDigits: coin.decimals); .toAmountAsRaw(fractionDigits: coin.decimals);
final locale = ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
);
final amount = final amount =
transactionInfo["recipientAmt"] as Amount; transactionInfo["recipientAmt"] as Amount;
return Text( return Text(
"${(amount + fee).localizedStringAsFixed( ref
locale: locale, .watch(pAmountFormatter(coin))
)} ${ref.watch( .format(amount + fee),
managerProvider.select((value) => value.coin),
).ticker}",
style: isDesktop style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context) ? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith( .copyWith(

View file

@ -40,6 +40,8 @@ import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/address_utils.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_unit.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
@ -125,14 +127,25 @@ class _SendViewState extends ConsumerState<SendView> {
void _cryptoAmountChanged() async { void _cryptoAmountChanged() async {
if (!_cryptoAmountChangeLock) { if (!_cryptoAmountChangeLock) {
final String cryptoAmount = cryptoAmountController.text; String cryptoAmount = cryptoAmountController.text;
if (cryptoAmount.isNotEmpty && if (cryptoAmount.isNotEmpty &&
cryptoAmount != "." && cryptoAmount != "." &&
cryptoAmount != ",") { cryptoAmount != ",") {
if (cryptoAmount.startsWith("~")) {
cryptoAmount = cryptoAmount.substring(1);
}
if (cryptoAmount.contains(" ")) {
cryptoAmount = cryptoAmount.split(" ").first;
}
final shift = ref.read(pAmountUnit(coin)).shift;
_amountToSend = cryptoAmount.contains(",") _amountToSend = cryptoAmount.contains(",")
? Decimal.parse(cryptoAmount.replaceFirst(",", ".")) ? Decimal.parse(cryptoAmount.replaceFirst(",", "."))
.shift(0 - shift)
.toAmount(fractionDigits: coin.decimals) .toAmount(fractionDigits: coin.decimals)
: Decimal.parse(cryptoAmount) : Decimal.parse(cryptoAmount)
.shift(0 - shift)
.toAmount(fractionDigits: coin.decimals); .toAmount(fractionDigits: coin.decimals);
if (_cachedAmountToSend != null && if (_cachedAmountToSend != null &&
_cachedAmountToSend == _amountToSend) { _cachedAmountToSend == _amountToSend) {
@ -150,7 +163,7 @@ class _SendViewState extends ConsumerState<SendView> {
.toAmount( .toAmount(
fractionDigits: 2, fractionDigits: 2,
) )
.localizedStringAsFixed( .fiatString(
locale: ref.read(localeServiceChangeNotifierProvider).locale, locale: ref.read(localeServiceChangeNotifierProvider).locale,
); );
} }
@ -199,6 +212,15 @@ class _SendViewState extends ConsumerState<SendView> {
late Amount _currentFee; late Amount _currentFee;
void _setCurrentFee(String fee, bool shouldSetState) { void _setCurrentFee(String fee, bool shouldSetState) {
fee = fee.trim();
if (fee.startsWith("~")) {
fee = fee.substring(1);
}
if (fee.contains(" ")) {
fee = fee.split(" ").first;
}
final value = fee.contains(",") final value = fee.contains(",")
? Decimal.parse(fee.replaceFirst(",", ".")) ? Decimal.parse(fee.replaceFirst(",", "."))
.toAmount(fractionDigits: coin.decimals) .toAmount(fractionDigits: coin.decimals)
@ -279,7 +301,6 @@ class _SendViewState extends ConsumerState<SendView> {
break; break;
} }
final String locale = ref.read(localeServiceChangeNotifierProvider).locale;
Amount fee; Amount fee;
if (coin == Coin.monero) { if (coin == Coin.monero) {
MoneroTransactionPriority specialMoneroId; MoneroTransactionPriority specialMoneroId;
@ -296,7 +317,11 @@ class _SendViewState extends ConsumerState<SendView> {
} }
fee = await manager.estimateFeeFor(amount, specialMoneroId.raw!); fee = await manager.estimateFeeFor(amount, specialMoneroId.raw!);
cachedFees[amount] = fee.localizedStringAsFixed(locale: locale); cachedFees[amount] = ref.read(pAmountFormatter(coin)).format(
fee,
withUnitName: true,
indicatePrecisionLoss: false,
);
return cachedFees[amount]!; return cachedFees[amount]!;
} else if (coin == Coin.firo || coin == Coin.firoTestNet) { } else if (coin == Coin.firo || coin == Coin.firoTestNet) {
@ -304,22 +329,32 @@ class _SendViewState extends ConsumerState<SendView> {
"Private") { "Private") {
fee = await manager.estimateFeeFor(amount, feeRate); fee = await manager.estimateFeeFor(amount, feeRate);
cachedFiroPrivateFees[amount] = cachedFiroPrivateFees[amount] = ref.read(pAmountFormatter(coin)).format(
fee.localizedStringAsFixed(locale: locale); fee,
withUnitName: true,
indicatePrecisionLoss: false,
);
return cachedFiroPrivateFees[amount]!; return cachedFiroPrivateFees[amount]!;
} else { } else {
fee = await (manager.wallet as FiroWallet) fee = await (manager.wallet as FiroWallet)
.estimateFeeForPublic(amount, feeRate); .estimateFeeForPublic(amount, feeRate);
cachedFiroPublicFees[amount] = cachedFiroPublicFees[amount] = ref.read(pAmountFormatter(coin)).format(
fee.localizedStringAsFixed(locale: locale); fee,
withUnitName: true,
indicatePrecisionLoss: false,
);
return cachedFiroPublicFees[amount]!; return cachedFiroPublicFees[amount]!;
} }
} else { } else {
fee = await manager.estimateFeeFor(amount, feeRate); fee = await manager.estimateFeeFor(amount, feeRate);
cachedFees[amount] = fee.localizedStringAsFixed(locale: locale); cachedFees[amount] = ref.read(pAmountFormatter(coin)).format(
fee,
withUnitName: true,
indicatePrecisionLoss: false,
);
return cachedFees[amount]!; return cachedFees[amount]!;
} }
@ -338,9 +373,9 @@ class _SendViewState extends ConsumerState<SendView> {
balance = wallet.availablePublicBalance(); balance = wallet.availablePublicBalance();
} }
return balance.localizedStringAsFixed( return ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, balance,
); );
} }
return null; return null;
@ -598,7 +633,15 @@ class _SendViewState extends ConsumerState<SendView> {
if (_data != null) { if (_data != null) {
if (_data!.amount != null) { if (_data!.amount != null) {
cryptoAmountController.text = _data!.amount!.toString(); final amount = Amount.fromDecimal(
_data!.amount!,
fractionDigits: coin.decimals,
);
cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
amount,
withUnitName: false,
);
} }
sendToController.text = _data!.contactLabel; sendToController.text = _data!.contactLabel;
_address = _data!.address.trim(); _address = _data!.address.trim();
@ -842,10 +885,12 @@ class _SendViewState extends ConsumerState<SendView> {
if (_cachedBalance != null) { if (_cachedBalance != null) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
cryptoAmountController.text = cryptoAmountController.text = ref
_cachedBalance! .read(pAmountFormatter(coin))
.localizedStringAsFixed( .format(
locale: locale); _cachedBalance!,
withUnitName: false,
);
}, },
child: Container( child: Container(
color: Colors.transparent, color: Colors.transparent,
@ -854,9 +899,10 @@ class _SendViewState extends ConsumerState<SendView> {
CrossAxisAlignment.end, CrossAxisAlignment.end,
children: [ children: [
Text( Text(
"${_cachedBalance!.localizedStringAsFixed( ref
locale: locale, .watch(pAmountFormatter(
)} ${coin.ticker}", coin))
.format(_cachedBalance!),
style: style:
STextStyles.titleBold12( STextStyles.titleBold12(
context) context)
@ -868,7 +914,7 @@ class _SendViewState extends ConsumerState<SendView> {
Text( Text(
"${(_cachedBalance!.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount( "${(_cachedBalance!.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}", )} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
style: STextStyles.subtitle( style: STextStyles.subtitle(
@ -1176,10 +1222,15 @@ class _SendViewState extends ConsumerState<SendView> {
); );
cryptoAmountController cryptoAmountController
.text = .text =
amount ref
.localizedStringAsFixed( .read(
locale: locale, pAmountFormatter(
); coin))
.format(
amount,
withUnitName:
false,
);
_amountToSend = amount; _amountToSend = amount;
} }
@ -1367,7 +1418,7 @@ class _SendViewState extends ConsumerState<SendView> {
_privateBalanceString != _privateBalanceString !=
null) { null) {
return Text( return Text(
"$_privateBalanceString ${coin.ticker}", "$_privateBalanceString",
style: STextStyles style: STextStyles
.itemSubtitle(context), .itemSubtitle(context),
); );
@ -1380,7 +1431,7 @@ class _SendViewState extends ConsumerState<SendView> {
_publicBalanceString != _publicBalanceString !=
null) { null) {
return Text( return Text(
"$_publicBalanceString ${coin.ticker}", "$_publicBalanceString",
style: STextStyles style: STextStyles
.itemSubtitle(context), .itemSubtitle(context),
); );
@ -1440,23 +1491,32 @@ class _SendViewState extends ConsumerState<SendView> {
.state) .state)
.state == .state ==
"Private") { "Private") {
cryptoAmountController.text = firoWallet cryptoAmountController.text = ref
.availablePrivateBalance() .read(pAmountFormatter(coin))
.localizedStringAsFixed( .format(
locale: locale); firoWallet
.availablePrivateBalance(),
withUnitName: false,
);
} else { } else {
cryptoAmountController.text = firoWallet cryptoAmountController.text = ref
.availablePublicBalance() .read(pAmountFormatter(coin))
.localizedStringAsFixed( .format(
locale: locale); firoWallet
.availablePublicBalance(),
withUnitName: false,
);
} }
} else { } else {
cryptoAmountController.text = ref cryptoAmountController.text = ref
.read(provider) .read(pAmountFormatter(coin))
.balance .format(
.spendable ref
.localizedStringAsFixed( .read(provider)
locale: locale); .balance
.spendable,
withUnitName: false,
);
} }
_cryptoAmountChanged(); _cryptoAmountChanged();
}, },
@ -1509,7 +1569,9 @@ class _SendViewState extends ConsumerState<SendView> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: Text( child: Text(
coin.ticker, ref
.watch(pAmountUnit(coin))
.unitForCoin(coin),
style: STextStyles.smallMed14(context) style: STextStyles.smallMed14(context)
.copyWith( .copyWith(
color: Theme.of(context) color: Theme.of(context)
@ -1595,12 +1657,10 @@ class _SendViewState extends ConsumerState<SendView> {
level: LogLevel.Info); level: LogLevel.Info);
final amountString = final amountString =
_amountToSend!.localizedStringAsFixed( ref.read(pAmountFormatter(coin)).format(
locale: ref _amountToSend!,
.read( withUnitName: false,
localeServiceChangeNotifierProvider) );
.locale,
);
_cryptoAmountChangeLock = true; _cryptoAmountChangeLock = true;
cryptoAmountController.text = amountString; cryptoAmountController.text = amountString;
@ -1833,6 +1893,8 @@ class _SendViewState extends ConsumerState<SendView> {
amount: (Decimal.tryParse( amount: (Decimal.tryParse(
cryptoAmountController cryptoAmountController
.text) ?? .text) ??
_amountToSend
?.decimal ??
Decimal.zero) Decimal.zero)
.toAmount( .toAmount(
fractionDigits: coin.decimals, fractionDigits: coin.decimals,
@ -1872,7 +1934,7 @@ class _SendViewState extends ConsumerState<SendView> {
false, false,
); );
return Text( return Text(
"~${snapshot.data! as String} ${coin.ticker}", "~${snapshot.data! as String}",
style: STextStyles style: STextStyles
.itemSubtitle( .itemSubtitle(
context), context),
@ -1929,7 +1991,7 @@ class _SendViewState extends ConsumerState<SendView> {
false, false,
); );
return Text( return Text(
"~${snapshot.data! as String} ${coin.ticker}", "~${snapshot.data! as String}",
style: STextStyles style: STextStyles
.itemSubtitle( .itemSubtitle(
context), context),

View file

@ -14,8 +14,8 @@ import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
class FiroBalanceSelectionSheet extends ConsumerStatefulWidget { class FiroBalanceSelectionSheet extends ConsumerStatefulWidget {
@ -162,14 +162,11 @@ class _FiroBalanceSelectionSheetState
width: 2, width: 2,
), ),
Text( Text(
"${firoWallet.availablePrivateBalance().localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(manager.coin))
localeServiceChangeNotifierProvider .format(
.select( firoWallet.availablePrivateBalance(),
(value) => value.locale, ),
),
),
)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
@ -243,14 +240,11 @@ class _FiroBalanceSelectionSheetState
width: 2, width: 2,
), ),
Text( Text(
"${firoWallet.availablePublicBalance().localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(manager.coin))
localeServiceChangeNotifierProvider .format(
.select( firoWallet.availablePublicBalance(),
(value) => value.locale, ),
),
),
)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),

View file

@ -9,7 +9,6 @@
*/ */
import 'package:cw_core/monero_transaction_priority.dart'; import 'package:cw_core/monero_transaction_priority.dart';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/paymint/fee_object_model.dart'; import 'package:stackwallet/models/paymint/fee_object_model.dart';
@ -20,6 +19,7 @@ import 'package:stackwallet/providers/wallet/public_private_balance_state_provid
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
@ -335,20 +335,21 @@ class _TransactionFeeSelectionSheetState
feeRate: feeObject!.fast, feeRate: feeObject!.fast,
amount: amount, amount: amount,
), ),
// future: manager.estimateFeeFor(
// Format.decimalAmountToSatoshis(
// amount),
// feeObject!.fast),
builder: (_, builder: (_,
AsyncSnapshot<Amount> snapshot) { AsyncSnapshot<Amount> snapshot) {
if (snapshot.connectionState == if (snapshot.connectionState ==
ConnectionState.done && ConnectionState.done &&
snapshot.hasData) { snapshot.hasData) {
return Text( return Text(
"(~${snapshot.data!.decimal.toStringAsFixed( "(~${ref.watch(
manager.coin.decimals, pAmountFormatter(
)}" manager.coin,
" ${manager.coin.ticker})", ),
).format(
snapshot.data!,
indicatePrecisionLoss:
false,
)})",
style: STextStyles.itemSubtitle( style: STextStyles.itemSubtitle(
context), context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
@ -471,18 +472,21 @@ class _TransactionFeeSelectionSheetState
feeRate: feeObject!.medium, feeRate: feeObject!.medium,
amount: amount, amount: amount,
), ),
// future: manager.estimateFeeFor(
// Format.decimalAmountToSatoshis(
// amount),
// feeObject!.fast),
builder: (_, builder: (_,
AsyncSnapshot<Amount> snapshot) { AsyncSnapshot<Amount> snapshot) {
if (snapshot.connectionState == if (snapshot.connectionState ==
ConnectionState.done && ConnectionState.done &&
snapshot.hasData) { snapshot.hasData) {
return Text( return Text(
"(~${snapshot.data!.decimal.toStringAsFixed(manager.coin.decimals)}" "(~${ref.watch(
" ${manager.coin.ticker})", pAmountFormatter(
manager.coin,
),
).format(
snapshot.data!,
indicatePrecisionLoss:
false,
)})",
style: STextStyles.itemSubtitle( style: STextStyles.itemSubtitle(
context), context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
@ -606,17 +610,21 @@ class _TransactionFeeSelectionSheetState
feeRate: feeObject!.slow, feeRate: feeObject!.slow,
amount: amount, amount: amount,
), ),
// future: manager.estimateFeeFor(
// Format.decimalAmountToSatoshis(
// amount),
// feeObject!.fast),
builder: (_, builder: (_,
AsyncSnapshot<Amount> snapshot) { AsyncSnapshot<Amount> snapshot) {
if (snapshot.connectionState == if (snapshot.connectionState ==
ConnectionState.done && ConnectionState.done &&
snapshot.hasData) { snapshot.hasData) {
return Text( return Text(
"(~${snapshot.data!.decimal.toStringAsFixed(manager.coin.decimals)} ${manager.coin.ticker})", "(~${ref.watch(
pAmountFormatter(
manager.coin,
),
).format(
snapshot.data!,
indicatePrecisionLoss:
false,
)})",
style: STextStyles.itemSubtitle( style: STextStyles.itemSubtitle(
context), context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
@ -679,25 +687,31 @@ class _TransactionFeeSelectionSheetState
switch (feeRateType) { switch (feeRateType) {
case FeeRateType.fast: case FeeRateType.fast:
if (ref.read(feeSheetSessionCacheProvider).fast[amount] != null) { if (ref.read(feeSheetSessionCacheProvider).fast[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).fast[amount] return ref.read(pAmountFormatter(coin)).format(
as Decimal) ref.read(feeSheetSessionCacheProvider).fast[amount]!,
.toStringAsFixed(coin.decimals); indicatePrecisionLoss: false,
withUnitName: false,
);
} }
return null; return null;
case FeeRateType.average: case FeeRateType.average:
if (ref.read(feeSheetSessionCacheProvider).average[amount] != null) { if (ref.read(feeSheetSessionCacheProvider).average[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).average[amount] return ref.read(pAmountFormatter(coin)).format(
as Decimal) ref.read(feeSheetSessionCacheProvider).average[amount]!,
.toStringAsFixed(coin.decimals); indicatePrecisionLoss: false,
withUnitName: false,
);
} }
return null; return null;
case FeeRateType.slow: case FeeRateType.slow:
if (ref.read(feeSheetSessionCacheProvider).slow[amount] != null) { if (ref.read(feeSheetSessionCacheProvider).slow[amount] != null) {
return (ref.read(feeSheetSessionCacheProvider).slow[amount] return ref.read(pAmountFormatter(coin)).format(
as Decimal) ref.read(feeSheetSessionCacheProvider).slow[amount]!,
.toStringAsFixed(coin.decimals); indicatePrecisionLoss: false,
withUnitName: false,
);
} }
return null; return null;
} }

View file

@ -30,6 +30,7 @@ import 'package:stackwallet/services/coins/manager.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/address_utils.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
@ -176,9 +177,11 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
final Amount amount = Decimal.parse(results["amount"]!).toAmount( final Amount amount = Decimal.parse(results["amount"]!).toAmount(
fractionDigits: tokenContract.decimals, fractionDigits: tokenContract.decimals,
); );
cryptoAmountController.text = amount.localizedStringAsFixed( cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, amount,
); withUnitName: false,
indicatePrecisionLoss: false,
);
_amountToSend = amount; _amountToSend = amount;
} }
@ -248,9 +251,10 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
level: LogLevel.Info); level: LogLevel.Info);
_cryptoAmountChangeLock = true; _cryptoAmountChangeLock = true;
cryptoAmountController.text = _amountToSend!.localizedStringAsFixed( cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, _amountToSend!,
); withUnitName: false,
);
_cryptoAmountChangeLock = false; _cryptoAmountChangeLock = false;
} else { } else {
_amountToSend = Amount.zero; _amountToSend = Amount.zero;
@ -268,10 +272,17 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
void _cryptoAmountChanged() async { void _cryptoAmountChanged() async {
if (!_cryptoAmountChangeLock) { if (!_cryptoAmountChangeLock) {
final String cryptoAmount = cryptoAmountController.text; String cryptoAmount = cryptoAmountController.text;
if (cryptoAmount.isNotEmpty && if (cryptoAmount.isNotEmpty &&
cryptoAmount != "." && cryptoAmount != "." &&
cryptoAmount != ",") { cryptoAmount != ",") {
if (cryptoAmount.startsWith("~")) {
cryptoAmount = cryptoAmount.substring(1);
}
if (cryptoAmount.contains(" ")) {
cryptoAmount = cryptoAmount.split(" ").first;
}
_amountToSend = Amount.fromDecimal( _amountToSend = Amount.fromDecimal(
cryptoAmount.contains(",") cryptoAmount.contains(",")
? Decimal.parse(cryptoAmount.replaceFirst(",", ".")) ? Decimal.parse(cryptoAmount.replaceFirst(",", "."))
@ -295,7 +306,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
.toAmount( .toAmount(
fractionDigits: 2, fractionDigits: 2,
) )
.localizedStringAsFixed( .fiatString(
locale: ref.read(localeServiceChangeNotifierProvider).locale, locale: ref.read(localeServiceChangeNotifierProvider).locale,
); );
} }
@ -366,9 +377,11 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
} }
final Amount fee = wallet.estimateFeeFor(feeRate); final Amount fee = wallet.estimateFeeFor(feeRate);
cachedFees = fee.localizedStringAsFixed( cachedFees = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, fee,
); withUnitName: true,
indicatePrecisionLoss: false,
);
return cachedFees; return cachedFees;
} }
@ -684,14 +697,15 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
cryptoAmountController.text = ref cryptoAmountController.text = ref
.read(tokenServiceProvider)! .watch(pAmountFormatter(coin))
.balance .format(
.spendable ref
.localizedStringAsFixed( .read(tokenServiceProvider)!
locale: ref .balance
.read( .spendable,
localeServiceChangeNotifierProvider) ethContract: tokenContract,
.locale, withUnitName: false,
indicatePrecisionLoss: true,
); );
}, },
child: Container( child: Container(
@ -701,20 +715,22 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
CrossAxisAlignment.end, CrossAxisAlignment.end,
children: [ children: [
Text( Text(
"${ref.watch( ref
tokenServiceProvider.select( .watch(pAmountFormatter(coin))
(value) => value! .format(
.balance.spendable ref.watch(
.localizedStringAsFixed( tokenServiceProvider.select(
locale: ref.watch( (value) => value!
localeServiceChangeNotifierProvider .balance.spendable,
.select( ),
(value) => value.locale, ),
ethContract: ref.watch(
tokenServiceProvider.select(
(value) =>
value!.tokenContract,
), ),
), ),
), ),
),
)} ${tokenContract.symbol}",
style: style:
STextStyles.titleBold12(context) STextStyles.titleBold12(context)
.copyWith( .copyWith(
@ -725,7 +741,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
Text( Text(
"${(ref.watch(tokenServiceProvider.select((value) => value!.balance.spendable.decimal)) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount( "${(ref.watch(tokenServiceProvider.select((value) => value!.balance.spendable.decimal)) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount(
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}", )} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
style: STextStyles.subtitle(context) style: STextStyles.subtitle(context)
@ -1169,7 +1185,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
ConnectionState.done && ConnectionState.done &&
snapshot.hasData) { snapshot.hasData) {
return Text( return Text(
"~${snapshot.data! as String} ${coin.ticker}", "~${snapshot.data! as String}",
style: style:
STextStyles.itemSubtitle( STextStyles.itemSubtitle(
context), context),

View file

@ -11,6 +11,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart';
import 'package:stackwallet/pages/stack_privacy_calls.dart'; import 'package:stackwallet/pages/stack_privacy_calls.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart';
@ -271,6 +272,41 @@ class AdvancedSettingsView extends StatelessWidget {
), ),
), ),
), ),
const SizedBox(
height: 8,
),
RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: RawMaterialButton(
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
onPressed: () {
Navigator.of(context).pushNamed(
ManageCoinUnitsView.routeName,
);
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 20,
),
child: Row(
children: [
Text(
"Units",
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
],
),
),
),
),
], ],
), ),
), ),

View file

@ -0,0 +1,142 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/amount/amount_unit.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
class ChooseUnitSheet extends ConsumerStatefulWidget {
const ChooseUnitSheet({
Key? key,
required this.coin,
}) : super(key: key);
final Coin coin;
@override
ConsumerState<ChooseUnitSheet> createState() => _ChooseUnitSheetState();
}
class _ChooseUnitSheetState extends ConsumerState<ChooseUnitSheet> {
late AmountUnit _current;
late final List<AmountUnit> values;
@override
void initState() {
values = AmountUnit.valuesForCoin(widget.coin);
_current = ref.read(pAmountUnit(widget.coin));
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(20),
),
),
child: Padding(
padding: const EdgeInsets.only(
left: 24,
right: 24,
top: 10,
bottom: 0,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
width: 60,
height: 4,
),
),
const SizedBox(
height: 36,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Phrase length",
style: STextStyles.pageTitleH2(context),
textAlign: TextAlign.left,
),
const SizedBox(
height: 16,
),
for (int i = 0; i < values.length; i++)
Column(
children: [
GestureDetector(
onTap: () {
setState(() {
_current = values[i];
});
Navigator.of(context).pop(_current);
},
child: Container(
color: Colors.transparent,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 20,
height: 20,
child: Radio(
activeColor: Theme.of(context)
.extension<StackColors>()!
.radioButtonIconEnabled,
value: values[i],
groupValue: _current,
onChanged: (x) {
setState(() {
_current = values[i];
});
Navigator.of(context).pop(_current);
},
),
),
const SizedBox(
width: 12,
),
Text(
values[i].unitForCoin(widget.coin),
style: STextStyles.titleBold12(context),
textAlign: TextAlign.left,
),
],
),
),
),
const SizedBox(
height: 16,
),
],
),
const SizedBox(
height: 8,
),
],
),
],
),
),
);
}
}

View file

@ -0,0 +1,343 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/amount/amount_unit.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:stackwallet/widgets/textfield_icon_button.dart';
class EditCoinUnitsView extends ConsumerStatefulWidget {
const EditCoinUnitsView({
Key? key,
required this.coin,
}) : super(key: key);
final Coin coin;
static const String routeName = "/editCoinUnitsView";
@override
ConsumerState<EditCoinUnitsView> createState() => _EditCoinUnitsViewState();
}
class _EditCoinUnitsViewState extends ConsumerState<EditCoinUnitsView> {
late final TextEditingController _decimalsController;
late final FocusNode _decimalsFocusNode;
late AmountUnit _currentUnit;
void onSave() {
final maxDecimals = int.tryParse(_decimalsController.text);
if (maxDecimals == null) {
// TODO show dialog error thing
return;
}
ref.read(prefsChangeNotifierProvider).updateAmountUnit(
coin: widget.coin,
amountUnit: _currentUnit,
);
ref.read(prefsChangeNotifierProvider).updateMaxDecimals(
coin: widget.coin,
maxDecimals: maxDecimals,
);
Navigator.of(context).pop();
}
Future<void> chooseUnit() async {
final chosenUnit = await showModalBottomSheet<AmountUnit?>(
backgroundColor: Colors.transparent,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
builder: (_) {
return ChooseUnitSheet(
coin: widget.coin,
);
},
);
if (chosenUnit != null) {
setState(() {
_currentUnit = chosenUnit;
});
}
}
@override
void initState() {
_decimalsFocusNode = FocusNode();
_decimalsController = TextEditingController()
..text = ref.read(pMaxDecimals(widget.coin)).toString();
_currentUnit = ref.read(pAmountUnit(widget.coin));
super.initState();
}
@override
void dispose() {
_decimalsFocusNode.dispose();
_decimalsController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopDialog(
maxHeight: 350,
maxWidth: 500,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"Edit ${widget.coin.prettyName} units",
style: STextStyles.desktopH3(context),
),
),
const DesktopDialogCloseButton(),
],
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: child,
),
),
],
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => Background(
child: Scaffold(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
"Edit ${widget.coin.prettyName} units",
style: STextStyles.navBarTitle(context),
),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: child,
),
),
),
child: Column(
children: [
if (Util.isDesktop)
DropdownButtonHideUnderline(
child: DropdownButton2<AmountUnit>(
value: _currentUnit,
items: [
...AmountUnit.valuesForCoin(widget.coin).map(
(e) => DropdownMenuItem(
value: e,
child: Text(
e.unitForCoin(widget.coin),
style: STextStyles.desktopTextMedium(context),
),
),
),
],
onChanged: (value) {
if (value is AmountUnit) {
_currentUnit = value;
}
},
isExpanded: true,
icon: SvgPicture.asset(
Assets.svg.chevronDown,
width: 12,
height: 6,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
buttonPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
buttonDecoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
dropdownDecoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
),
),
if (!Util.isDesktop)
Stack(
children: [
TextField(
autocorrect: Util.isDesktop ? false : true,
enableSuggestions: Util.isDesktop ? false : true,
// controller: _lengthController,
readOnly: true,
textInputAction: TextInputAction.none,
),
Positioned.fill(
child: RawMaterialButton(
splashColor:
Theme.of(context).extension<StackColors>()!.highlight,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
onPressed: chooseUnit,
child: Padding(
padding: const EdgeInsets.only(
left: 12,
right: 17,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_currentUnit.unitForCoin(widget.coin),
style: STextStyles.itemSubtitle12(context),
),
SvgPicture.asset(
Assets.svg.chevronDown,
width: 14,
height: 6,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
],
),
),
),
)
],
),
SizedBox(
height: Util.isDesktop ? 24 : 8,
),
ClipRRect(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
child: TextField(
autocorrect: Util.isDesktop ? false : true,
enableSuggestions: Util.isDesktop ? false : true,
key: const Key("addCustomNodeNodeNameFieldKey"),
controller: _decimalsController,
focusNode: _decimalsFocusNode,
keyboardType: const TextInputType.numberWithOptions(
signed: false,
decimal: false,
),
style: STextStyles.field(context),
decoration: standardInputDecoration(
"Maximum precision",
_decimalsFocusNode,
context,
).copyWith(
labelStyle:
Util.isDesktop ? STextStyles.fieldLabel(context) : null,
suffixIcon: _decimalsController.text.isNotEmpty
? Padding(
padding: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
children: [
TextFieldIconButton(
child: const XIcon(),
onTap: () async {
_decimalsController.text = "";
setState(() {});
},
),
],
),
),
)
: null,
),
),
),
const SizedBox(
height: 24,
),
const Spacer(),
ConditionalParent(
condition: Util.isDesktop,
builder: (child) => Row(
children: [
Expanded(
child: SecondaryButton(
label: "Cancel",
buttonHeight: ButtonHeight.l,
onPressed: Navigator.of(context).pop,
),
),
const SizedBox(
width: 16,
),
Expanded(
child: child,
),
],
),
child: PrimaryButton(
label: "Save",
buttonHeight: Util.isDesktop ? ButtonHeight.l : ButtonHeight.xl,
onPressed: onSave,
),
),
],
),
),
);
}
}

View file

@ -0,0 +1,176 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class ManageCoinUnitsView extends ConsumerWidget {
const ManageCoinUnitsView({Key? key}) : super(key: key);
static const String routeName = "/manageCoinUnitsView";
void onEditPressed(Coin coin, BuildContext context) {
if (Util.isDesktop) {
showDialog<void>(
context: context,
builder: (context) => EditCoinUnitsView(coin: coin),
);
} else {
Navigator.of(context).pushNamed(
EditCoinUnitsView.routeName,
arguments: coin,
);
}
}
@override
Widget build(BuildContext context, WidgetRef ref) {
bool showTestNet = ref.watch(
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
);
final _coins = Coin.values.where((e) => e != Coin.firoTestNet).toList();
List<Coin> coins = showTestNet
? _coins
: _coins.sublist(0, _coins.length - kTestNetCoinCount);
return ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopDialog(
maxHeight: 850,
maxWidth: 600,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"Units",
style: STextStyles.desktopH3(context),
),
),
const DesktopDialogCloseButton(),
],
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: child,
),
),
],
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => Background(
child: Scaffold(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
"Units",
style: STextStyles.navBarTitle(context),
),
),
body: child,
),
),
child: ListView.separated(
itemCount: Util.isDesktop ? coins.length : coins.length + 2,
separatorBuilder: (_, __) => const SizedBox(
height: 12,
),
itemBuilder: (_, index) {
if (!Util.isDesktop) {
if (index == 0) {
return const SizedBox(height: 0);
} else if (index > coins.length) {
return const SizedBox(height: 10);
}
}
final coin = coins[Util.isDesktop ? index : index - 1];
return Padding(
padding: Util.isDesktop
? EdgeInsets.zero
: const EdgeInsets.symmetric(
horizontal: 16,
),
child: RoundedWhiteContainer(
padding: Util.isDesktop
? const EdgeInsets.symmetric(
vertical: 16,
horizontal: 14,
)
: const EdgeInsets.all(12),
borderColor: Util.isDesktop
? Theme.of(context).extension<StackColors>()!.textSubtitle6
: null,
onPressed: () {
onEditPressed(coin, context);
},
child: Row(
children: [
SvgPicture.file(
File(
ref.watch(
coinIconProvider(coin),
),
),
width: 24,
height: 24,
),
const SizedBox(
width: 12,
),
Expanded(
child: Text(
"Edit ${coin.prettyName} units",
style: STextStyles.titleBold12(context),
),
),
const SizedBox(
width: 12,
),
SvgPicture.asset(
Assets.svg.chevronRight,
width: Util.isDesktop ? 20 : 14,
height: Util.isDesktop ? 20 : 14,
),
],
),
),
);
},
),
),
);
}
}

View file

@ -60,6 +60,10 @@ class _CurrencyViewState extends ConsumerState<BaseCurrencySettingsView> {
currenciesWithoutSelected.remove(current); currenciesWithoutSelected.remove(current);
currenciesWithoutSelected.insert(0, current); currenciesWithoutSelected.insert(0, current);
ref.read(prefsChangeNotifierProvider).currency = current; ref.read(prefsChangeNotifierProvider).currency = current;
if (ref.read(prefsChangeNotifierProvider).externalCalls) {
ref.read(priceAnd24hChangeNotifierProvider).updatePrice();
}
} }
} }

View file

@ -160,6 +160,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
case Coin.bitcoincash: case Coin.bitcoincash:
case Coin.litecoin: case Coin.litecoin:
case Coin.dogecoin: case Coin.dogecoin:
case Coin.eCash:
case Coin.firo: case Coin.firo:
case Coin.namecoin: case Coin.namecoin:
case Coin.particl: case Coin.particl:

View file

@ -16,7 +16,6 @@ import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/global/secure_store_provider.dart'; import 'package:stackwallet/providers/global/secure_store_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
@ -37,10 +36,11 @@ class ChangePinView extends ConsumerStatefulWidget {
class _ChangePinViewState extends ConsumerState<ChangePinView> { class _ChangePinViewState extends ConsumerState<ChangePinView> {
BoxDecoration get _pinPutDecoration { BoxDecoration get _pinPutDecoration {
return BoxDecoration( return BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.textSubtitle2, color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
border: Border.all( border: Border.all(
width: 1, width: 1,
color: Theme.of(context).extension<StackColors>()!.textSubtitle2), color: Theme.of(context).extension<StackColors>()!.infoItemIcons,
),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
); );
} }
@ -58,6 +58,8 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
late final SecureStorageInterface _secureStore; late final SecureStorageInterface _secureStore;
int pinCount = 1;
@override @override
void initState() { void initState() {
_secureStore = ref.read(secureStoreProvider); _secureStore = ref.read(secureStoreProvider);
@ -111,7 +113,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
height: 52, height: 52,
), ),
CustomPinPut( CustomPinPut(
fieldsCount: Constants.pinLength, fieldsCount: pinCount,
eachFieldHeight: 12, eachFieldHeight: 12,
eachFieldWidth: 12, eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith( textStyle: STextStyles.label(context).copyWith(
@ -135,21 +137,18 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
), ),
isRandom: isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN, ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith( submittedFieldDecoration: _pinPutDecoration,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
selectedFieldDecoration: _pinPutDecoration, selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration, followingFieldDecoration: _pinPutDecoration,
onSubmit: (String pin) { onSubmit: (String pin) {
if (pin.length == Constants.pinLength) { if (pin.length < 4) {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "PIN not long enough!",
iconAsset: Assets.svg.alertCircle,
context: context,
);
} else {
_pageController.nextPage( _pageController.nextPage(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
curve: Curves.linear, curve: Curves.linear,
@ -175,7 +174,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
height: 52, height: 52,
), ),
CustomPinPut( CustomPinPut(
fieldsCount: Constants.pinLength, fieldsCount: pinCount,
eachFieldHeight: 12, eachFieldHeight: 12,
eachFieldWidth: 12, eachFieldWidth: 12,
textStyle: STextStyles.infoSmall(context).copyWith( textStyle: STextStyles.infoSmall(context).copyWith(
@ -202,17 +201,7 @@ class _ChangePinViewState extends ConsumerState<ChangePinView> {
), ),
isRandom: isRandom:
ref.read(prefsChangeNotifierProvider).randomizePIN, ref.read(prefsChangeNotifierProvider).randomizePIN,
submittedFieldDecoration: _pinPutDecoration.copyWith( submittedFieldDecoration: _pinPutDecoration,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
border: Border.all(
width: 1,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemIcons,
),
),
selectedFieldDecoration: _pinPutDecoration, selectedFieldDecoration: _pinPutDecoration,
followingFieldDecoration: _pinPutDecoration, followingFieldDecoration: _pinPutDecoration,
onSubmit: (String pin) async { onSubmit: (String pin) async {

View file

@ -16,8 +16,8 @@ import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; import 'package:stackwallet/utilities/enums/sync_type_enum.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';
@ -157,14 +157,10 @@ class WalletSyncingOptionsView extends ConsumerWidget {
height: 2, height: 2,
), ),
Text( Text(
"${manager.balance.total.localizedStringAsFixed( ref
locale: ref.watch( .watch(pAmountFormatter(
localeServiceChangeNotifierProvider manager.coin))
.select( .format(manager.balance.total),
(value) => value.locale,
),
),
)} ${manager.coin.ticker}",
style: style:
STextStyles.itemSubtitle(context), STextStyles.itemSubtitle(context),
) )

View file

@ -20,7 +20,9 @@ import 'package:stackwallet/services/ethereum/cached_eth_token_balance.dart';
import 'package:stackwallet/services/ethereum/ethereum_token_service.dart'; import 'package:stackwallet/services/ethereum/ethereum_token_service.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/amount/amount_formatter.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
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';
@ -173,14 +175,10 @@ class _MyTokenSelectItemState extends ConsumerState<MyTokenSelectItem> {
), ),
const Spacer(), const Spacer(),
Text( Text(
"${cachedBalance.getCachedBalance().total.localizedStringAsFixed( ref.watch(pAmountFormatter(Coin.ethereum)).format(
locale: ref.watch( cachedBalance.getCachedBalance().total,
localeServiceChangeNotifierProvider.select( ethContract: widget.token,
(value) => value.locale, ),
),
),
)} "
"${widget.token.symbol}",
style: isDesktop style: isDesktop
? STextStyles.desktopTextExtraSmall(context) ? STextStyles.desktopTextExtraSmall(context)
.copyWith( .copyWith(

View file

@ -29,6 +29,7 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_providers.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -96,14 +97,10 @@ class TokenSummary extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
"${balance.total.localizedStringAsFixed( ref.watch(pAmountFormatter(Coin.ethereum)).format(
locale: ref.watch( balance.total,
localeServiceChangeNotifierProvider.select( ethContract: token,
(value) => value.locale,
), ),
),
)}"
" ${token.symbol}",
style: STextStyles.pageTitleH1(context).copyWith( style: STextStyles.pageTitleH1(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
@ -128,7 +125,7 @@ class TokenSummary extends ConsumerWidget {
), ),
)).toAmount( )).toAmount(
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: ref.watch( locale: ref.watch(
localeServiceChangeNotifierProvider.select( localeServiceChangeNotifierProvider.select(
(value) => value.locale, (value) => value.locale,

View file

@ -103,12 +103,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
children: [ children: [
TransactionCard( TransactionCard(
// this may mess with combined firo transactions // this may mess with combined firo transactions
key: isConfirmed key: UniqueKey(), //
? Key(tx.txid +
tx.type.name +
tx.address.value.toString() +
tx.height.toString())
: UniqueKey(), //
transaction: tx, transaction: tx,
walletId: widget.walletId, walletId: widget.walletId,
), ),
@ -203,12 +198,7 @@ class _TransactionsListState extends ConsumerState<TransactionsList> {
), ),
child: TransactionCard( child: TransactionCard(
// this may mess with combined firo transactions // this may mess with combined firo transactions
key: isConfirmed key: UniqueKey(),
? Key(tx.txid +
tx.type.name +
tx.address.value.toString() +
tx.height.toString())
: UniqueKey(),
transaction: tx, transaction: tx,
walletId: widget.walletId, walletId: widget.walletId,
), ),

View file

@ -17,6 +17,7 @@ import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provide
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
@ -288,13 +289,7 @@ class BalanceSelector<T> extends ConsumerWidget {
height: 2, height: 2,
), ),
Text( Text(
"${balance.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(balance),
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context).copyWith( style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!

View file

@ -26,6 +26,7 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
@ -160,9 +161,7 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
FittedBox( FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
child: SelectableText( child: SelectableText(
"${balanceToShow.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(balanceToShow),
locale: locale,
)} ${coin.ticker}",
style: STextStyles.pageTitleH1(context).copyWith( style: STextStyles.pageTitleH1(context).copyWith(
fontSize: 24, fontSize: 24,
color: Theme.of(context) color: Theme.of(context)
@ -175,7 +174,7 @@ class _WalletSummaryInfoState extends ConsumerState<WalletSummaryInfo> {
Text( Text(
"${(priceTuple.item1 * balanceToShow.decimal).toAmount( "${(priceTuple.item1 * balanceToShow.decimal).toAmount(
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
)} $baseCurrency", )} $baseCurrency",
style: STextStyles.subtitle500(context).copyWith( style: STextStyles.subtitle500(context).copyWith(

View file

@ -25,6 +25,7 @@ import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -968,9 +969,7 @@ class _DesktopTransactionCardRowState
builder: (_) { builder: (_) {
final amount = _transaction.realAmount; final amount = _transaction.realAmount;
return Text( return Text(
"$prefix${amount.localizedStringAsFixed( "$prefix${ref.watch(pAmountFormatter(coin)).format(amount)}",
locale: locale,
)} ${coin.ticker}",
style: STextStyles.desktopTextExtraExtraSmall(context) style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith( .copyWith(
color: Theme.of(context) color: Theme.of(context)
@ -992,7 +991,7 @@ class _DesktopTransactionCardRowState
return Text( return Text(
"$prefix${(amount.decimal * price).toAmount( "$prefix${(amount.decimal * price).toAmount(
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
)} $baseCurrency", )} $baseCurrency",
style: STextStyles.desktopTextExtraExtraSmall(context), style: STextStyles.desktopTextExtraExtraSmall(context),

View file

@ -16,6 +16,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart'; import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart';
@ -29,6 +30,7 @@ import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/coins/manager.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/block_explorers.dart'; import 'package:stackwallet/utilities/block_explorers.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
@ -83,6 +85,7 @@ class _TransactionDetailsViewState
late final String amountPrefix; late final String amountPrefix;
late final String unit; late final String unit;
late final bool isTokenTx; late final bool isTokenTx;
late final EthContract? ethContract;
bool showFeePending = false; bool showFeePending = false;
@ -104,12 +107,11 @@ class _TransactionDetailsViewState
amountPrefix = _transaction.type == TransactionType.outgoing ? "-" : "+"; amountPrefix = _transaction.type == TransactionType.outgoing ? "-" : "+";
} }
unit = isTokenTx ethContract = isTokenTx
? ref ? ref.read(mainDBProvider).getEthContractSync(_transaction.otherData!)
.read(mainDBProvider) : null;
.getEthContractSync(_transaction.otherData!)!
.symbol unit = isTokenTx ? ethContract!.symbol : coin.ticker;
: coin.ticker;
// if (coin == Coin.firo || coin == Coin.firoTestNet) { // if (coin == Coin.firo || coin == Coin.firoTestNet) {
// showFeePending = true; // showFeePending = true;
@ -136,6 +138,37 @@ class _TransactionDetailsViewState
} }
} }
if (coin == Coin.epicCash) {
if (_transaction.isCancelled) {
return "Cancelled";
} else if (type == TransactionType.incoming) {
if (tx.isConfirmed(height, coin.requiredConfirmations)) {
return "Received";
} else {
if (_transaction.numberOfMessages == 1) {
return "Receiving (waiting for sender)";
} else if ((_transaction.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 {
return "Receiving";
}
}
} else if (type == TransactionType.outgoing) {
if (tx.isConfirmed(height, coin.requiredConfirmations)) {
return "Sent (confirmed)";
} else {
if (_transaction.numberOfMessages == 1) {
return "Sending (waiting for receiver)";
} else if ((_transaction.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) {
// return "Minting"; // return "Minting";
@ -456,13 +489,7 @@ class _TransactionDetailsViewState
: CrossAxisAlignment.start, : CrossAxisAlignment.start,
children: [ children: [
SelectableText( SelectableText(
"$amountPrefix${amount.localizedStringAsFixed( "$amountPrefix${ref.watch(pAmountFormatter(coin)).format(amount, ethContract: ethContract)}",
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) =>
value.locale),
),
)} $unit",
style: isDesktop style: isDesktop
? STextStyles ? STextStyles
.desktopTextExtraExtraSmall( .desktopTextExtraExtraSmall(
@ -496,7 +523,7 @@ class _TransactionDetailsViewState
.getPrice( .getPrice(
coin) coin)
.item1), .item1),
)).toAmount(fractionDigits: 2).localizedStringAsFixed( )).toAmount(fractionDigits: 2).fiatString(
locale: ref.watch( locale: ref.watch(
localeServiceChangeNotifierProvider localeServiceChangeNotifierProvider
.select( .select(
@ -951,23 +978,17 @@ class _TransactionDetailsViewState
currentHeight, currentHeight,
coin.requiredConfirmations, coin.requiredConfirmations,
) )
? fee.localizedStringAsFixed( ? ref
locale: ref.watch( .watch(pAmountFormatter(coin))
localeServiceChangeNotifierProvider .format(
.select( fee,
(value) => value.locale), withUnitName: isTokenTx,
), )
)
: "Pending" : "Pending"
: fee.localizedStringAsFixed( : ref.watch(pAmountFormatter(coin)).format(
locale: ref.watch( fee,
localeServiceChangeNotifierProvider withUnitName: isTokenTx,
.select((value) => value.locale), );
),
);
if (isTokenTx) {
feeString += " ${coin.ticker}";
}
return Row( return Row(
mainAxisAlignment: mainAxisAlignment:
@ -1043,6 +1064,7 @@ class _TransactionDetailsViewState
final String height; final String height;
if (widget.coin == Coin.bitcoincash || if (widget.coin == Coin.bitcoincash ||
widget.coin == Coin.eCash ||
widget.coin == Coin.bitcoincashTestnet) { widget.coin == Coin.bitcoincashTestnet) {
height = height =
"${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}";

View file

@ -15,11 +15,11 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart'; import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/models/transaction_filter.dart'; import 'package:stackwallet/models/transaction_filter.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/themes/theme_providers.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -86,11 +86,12 @@ class _TransactionSearchViewState
_toDateString = _toDateString =
_selectedToDate == null ? "" : Format.formatDate(_selectedToDate!); _selectedToDate == null ? "" : Format.formatDate(_selectedToDate!);
final String amount = filterState.amount?.localizedStringAsFixed( final String amount = filterState.amount == null
locale: ref.read(localeServiceChangeNotifierProvider).locale, ? ""
decimalPlaces: widget.coin.decimals, : ref.read(pAmountFormatter(widget.coin)).format(
) ?? filterState.amount!,
""; withUnitName: false,
);
_amountTextEditingController.text = amount; _amountTextEditingController.text = amount;
} }

View file

@ -16,10 +16,11 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -34,13 +35,11 @@ class FavoriteCard extends ConsumerStatefulWidget {
required this.walletId, required this.walletId,
required this.width, required this.width,
required this.height, required this.height,
required this.managerProvider,
}) : super(key: key); }) : super(key: key);
final String walletId; final String walletId;
final double width; final double width;
final double height; final double height;
final ChangeNotifierProvider<Manager> managerProvider;
@override @override
ConsumerState<FavoriteCard> createState() => _FavoriteCardState(); ConsumerState<FavoriteCard> createState() => _FavoriteCardState();
@ -48,15 +47,10 @@ class FavoriteCard extends ConsumerStatefulWidget {
class _FavoriteCardState extends ConsumerState<FavoriteCard> { class _FavoriteCardState extends ConsumerState<FavoriteCard> {
late final String walletId; late final String walletId;
late final ChangeNotifierProvider<Manager> managerProvider;
Amount _cachedBalance = Amount.zero;
Amount _cachedFiatValue = Amount.zero;
@override @override
void initState() { void initState() {
walletId = widget.walletId; walletId = widget.walletId;
managerProvider = widget.managerProvider;
super.initState(); super.initState();
} }
@ -65,9 +59,13 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final coin = ref.watch(managerProvider.select((value) => value.coin)); final coin = ref.watch(
walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).coin),
);
final externalCalls = ref.watch( final externalCalls = ref.watch(
prefsChangeNotifierProvider.select((value) => value.externalCalls)); prefsChangeNotifierProvider.select((value) => value.externalCalls),
);
return ConditionalParent( return ConditionalParent(
condition: Util.isDesktop, condition: Util.isDesktop,
@ -119,7 +117,10 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
child: GestureDetector( child: GestureDetector(
onTap: () async { onTap: () async {
if (coin == Coin.monero || coin == Coin.wownero) { if (coin == Coin.monero || coin == Coin.wownero) {
await ref.read(managerProvider).initializeExisting(); await ref
.read(walletsChangeNotifierProvider)
.getManager(walletId)
.initializeExisting();
} }
if (mounted) { if (mounted) {
if (Util.isDesktop) { if (Util.isDesktop) {
@ -132,7 +133,9 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
WalletView.routeName, WalletView.routeName,
arguments: Tuple2( arguments: Tuple2(
walletId, walletId,
managerProvider, ref
.read(walletsChangeNotifierProvider)
.getManagerProvider(walletId),
), ),
); );
} }
@ -215,8 +218,12 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
ref.watch(managerProvider ref.watch(
.select((value) => value.walletName)), walletsChangeNotifierProvider.select(
(value) =>
value.getManager(walletId).walletName,
),
),
style: STextStyles.itemSubtitle12(context).copyWith( style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
@ -235,42 +242,48 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
], ],
), ),
), ),
FutureBuilder( Builder(
future: Future(() => ref.watch(managerProvider builder: (context) {
.select((value) => value.balance.total))), final balance = ref.watch(
builder: (builderContext, AsyncSnapshot<Amount> snapshot) { walletsChangeNotifierProvider.select(
if (snapshot.connectionState == ConnectionState.done && (value) => value.getManager(walletId).balance,
snapshot.hasData) { ),
if (snapshot.data != null) { );
_cachedBalance = snapshot.data!;
if (externalCalls && _cachedBalance > Amount.zero) { Amount total = balance.total;
_cachedFiatValue = (_cachedBalance.decimal * if (coin == Coin.firo || coin == Coin.firoTestNet) {
ref final balancePrivate = ref.watch(
.watch( walletsChangeNotifierProvider.select(
priceAnd24hChangeNotifierProvider (value) => (value.getManager(walletId).wallet
.select( as FiroWallet)
(value) => value.getPrice(coin), .balancePrivate,
), ),
) );
.item1)
.toAmount(fractionDigits: 2); total += balancePrivate.total;
}
}
} }
Amount fiatTotal = Amount.zero;
if (externalCalls && total > Amount.zero) {
fiatTotal = (total.decimal *
ref
.watch(
priceAnd24hChangeNotifierProvider.select(
(value) => value.getPrice(coin),
),
)
.item1)
.toAmount(fractionDigits: 2);
}
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
FittedBox( FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
child: Text( child: Text(
"${_cachedBalance.localizedStringAsFixed( ref.watch(pAmountFormatter(coin)).format(total),
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
decimalPlaces: ref.watch(managerProvider
.select((value) => value.coin.decimals)),
)} ${coin.ticker}",
style: STextStyles.titleBold12(context).copyWith( style: STextStyles.titleBold12(context).copyWith(
fontSize: 16, fontSize: 16,
color: Theme.of(context) color: Theme.of(context)
@ -285,15 +298,16 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
), ),
if (externalCalls) if (externalCalls)
Text( Text(
"${_cachedFiatValue.localizedStringAsFixed( "${fiatTotal.fiatString(
locale: ref.watch( locale: ref.watch(
localeServiceChangeNotifierProvider localeServiceChangeNotifierProvider.select(
.select((value) => value.locale), (value) => value.locale,
),
), ),
decimalPlaces: 2,
)} ${ref.watch( )} ${ref.watch(
prefsChangeNotifierProvider prefsChangeNotifierProvider.select(
.select((value) => value.currency), (value) => value.currency,
),
)}", )}",
style: style:
STextStyles.itemSubtitle12(context).copyWith( STextStyles.itemSubtitle12(context).copyWith(

View file

@ -221,7 +221,6 @@ class _FavoriteWalletsState extends ConsumerState<FavoriteWallets> {
child: FavoriteCard( child: FavoriteCard(
key: Key("favCard_$walletId"), key: Key("favCard_$walletId"),
walletId: walletId!, walletId: walletId!,
managerProvider: managerProvider!,
width: cardWidth, width: cardWidth,
height: cardHeight, height: cardHeight,
), ),
@ -229,7 +228,6 @@ class _FavoriteWalletsState extends ConsumerState<FavoriteWallets> {
: FavoriteCard( : FavoriteCard(
key: Key("favCard_$walletId"), key: Key("favCard_$walletId"),
walletId: walletId!, walletId: walletId!,
managerProvider: managerProvider!,
width: cardWidth, width: cardWidth,
height: cardHeight, height: cardHeight,
) )

View file

@ -108,12 +108,12 @@ class WalletListItem extends ConsumerWidget {
final calls = final calls =
ref.watch(prefsChangeNotifierProvider).externalCalls; ref.watch(prefsChangeNotifierProvider).externalCalls;
final priceString = tuple.item1 final priceString =
.toAmount(fractionDigits: 2) tuple.item1.toAmount(fractionDigits: 2).fiatString(
.localizedStringAsFixed( locale: ref.watch(
locale: ref.watch(localeServiceChangeNotifierProvider localeServiceChangeNotifierProvider
.select((value) => value.locale)), .select((value) => value.locale)),
); );
final double percentChange = tuple.item2; final double percentChange = tuple.item2;

View file

@ -14,10 +14,10 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/pages/coin_control/utxo_details_view.dart'; import 'package:stackwallet/pages/coin_control/utxo_details_view.dart';
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.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/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
@ -154,16 +154,12 @@ class _UtxoRowState extends ConsumerState<UtxoRow> {
), ),
if (!widget.compact) if (!widget.compact)
Text( Text(
"${Amount( ref.watch(pAmountFormatter(coin)).format(
rawValue: BigInt.from(utxo.value), Amount(
fractionDigits: coin.decimals, rawValue: BigInt.from(utxo.value),
).localizedStringAsFixed( fractionDigits: coin.decimals,
locale: ref.watch( ),
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
), ),
),
)} ${coin.ticker}",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: STextStyles.w600_14(context), style: STextStyles.w600_14(context),
), ),
@ -180,16 +176,12 @@ class _UtxoRowState extends ConsumerState<UtxoRow> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
"${Amount( ref.watch(pAmountFormatter(coin)).format(
rawValue: BigInt.from(utxo.value), Amount(
fractionDigits: coin.decimals, rawValue: BigInt.from(utxo.value),
).localizedStringAsFixed( fractionDigits: coin.decimals,
locale: ref.watch( ),
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
), ),
),
)} ${coin.ticker}",
textAlign: TextAlign.right, textAlign: TextAlign.right,
style: STextStyles.w600_14(context), style: STextStyles.w600_14(context),
), ),

View file

@ -15,6 +15,7 @@ import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -289,8 +290,6 @@ class _BalanceDisplay extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final manager = ref.watch(walletsChangeNotifierProvider final manager = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId))); .select((value) => value.getManager(walletId)));
final locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale));
Amount total = manager.balance.total; Amount total = manager.balance.total;
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) { if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
@ -299,8 +298,7 @@ class _BalanceDisplay extends ConsumerWidget {
} }
return Text( return Text(
"${total.localizedStringAsFixed(locale: locale)} " ref.watch(pAmountFormatter(manager.coin)).format(total),
"${manager.coin.ticker}",
style: STextStyles.desktopTextExtraSmall(context).copyWith( style: STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textSubtitle1, color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
), ),

View file

@ -84,7 +84,6 @@ class DesktopFavoriteWallets extends ConsumerWidget {
key: Key(walletName), key: Key(walletName),
width: cardWidth, width: cardWidth,
height: cardHeight, height: cardHeight,
managerProvider: managerProvider,
); );
}) })
], ],

View file

@ -25,6 +25,7 @@ import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.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/barcode_scanner_interface.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -134,15 +135,24 @@ class _DesktopPaynymSendDialogState
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Text( Text(
"${!isFiro ? manager.balance.spendable.localizedStringAsFixed( !isFiro
locale: locale, ? ref
) : ref.watch( .watch(pAmountFormatter(coin))
publicPrivateBalanceStateProvider.state, .format(manager.balance.spendable)
).state == "Private" ? (manager.wallet as FiroWallet).availablePrivateBalance().localizedStringAsFixed( : ref
locale: locale, .watch(
) : (manager.wallet as FiroWallet).availablePublicBalance().localizedStringAsFixed( publicPrivateBalanceStateProvider
locale: locale, .state,
)} ${coin.ticker}", )
.state ==
"Private"
? ref.watch(pAmountFormatter(coin)).format(
(manager.wallet as FiroWallet)
.availablePrivateBalance())
: ref.watch(pAmountFormatter(coin)).format(
(manager.wallet as FiroWallet)
.availablePublicBalance(),
),
style: STextStyles.titleBold12(context), style: STextStyles.titleBold12(context),
textAlign: TextAlign.right, textAlign: TextAlign.right,
), ),
@ -150,7 +160,15 @@ class _DesktopPaynymSendDialogState
height: 2, height: 2,
), ),
Text( Text(
"${((!isFiro ? manager.balance.spendable.decimal : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" ? (manager.wallet as FiroWallet).availablePrivateBalance().decimal : (manager.wallet as FiroWallet).availablePublicBalance().decimal) * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount(fractionDigits: 2).localizedStringAsFixed(locale: locale)} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}", "${((!isFiro ? manager.balance.spendable.decimal : ref.watch(publicPrivateBalanceStateProvider.state).state == "Private" ? (manager.wallet as FiroWallet).availablePrivateBalance().decimal : (manager.wallet as FiroWallet).availablePublicBalance().decimal) * ref.watch(
priceAnd24hChangeNotifierProvider.select(
(value) => value.getPrice(coin).item1,
),
)).toAmount(fractionDigits: 2).fiatString(
locale: locale,
)} ${ref.watch(prefsChangeNotifierProvider.select(
(value) => value.currency,
))}",
style: STextStyles.baseXS(context).copyWith( style: STextStyles.baseXS(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!

View file

@ -224,13 +224,12 @@ class TablePriceInfo extends ConsumerWidget {
final priceString = Amount.fromDecimal( final priceString = Amount.fromDecimal(
tuple.item1, tuple.item1,
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: ref locale: ref
.watch( .watch(
localeServiceChangeNotifierProvider.notifier, localeServiceChangeNotifierProvider.notifier,
) )
.locale, .locale,
decimalPlaces: 2,
); );
final double percentChange = tuple.item2; final double percentChange = tuple.item2;

View file

@ -22,6 +22,7 @@ import 'package:stackwallet/providers/wallet/public_private_balance_state_provid
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -370,10 +371,10 @@ class FeeDropDownChild extends ConsumerWidget {
children: [ children: [
Text( Text(
"${feeRateType.prettyName} " "${feeRateType.prettyName} "
"(~${snapshot.data!.decimal.toStringAsFixed( "(~${ref.watch(pAmountFormatter(manager.coin)).format(
manager.coin.decimals, snapshot.data!,
)} " indicatePrecisionLoss: false,
"${manager.coin.ticker})", )})",
style: style:
STextStyles.desktopTextExtraExtraSmall(context).copyWith( STextStyles.desktopTextExtraExtraSmall(context).copyWith(
color: Theme.of(context) color: Theme.of(context)

View file

@ -37,6 +37,8 @@ import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/address_utils.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_unit.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
@ -439,14 +441,25 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
void _cryptoAmountChanged() async { void _cryptoAmountChanged() async {
if (!_cryptoAmountChangeLock) { if (!_cryptoAmountChangeLock) {
final String cryptoAmount = cryptoAmountController.text; String cryptoAmount = cryptoAmountController.text;
if (cryptoAmount.isNotEmpty && if (cryptoAmount.isNotEmpty &&
cryptoAmount != "." && cryptoAmount != "." &&
cryptoAmount != ",") { cryptoAmount != ",") {
if (cryptoAmount.startsWith("~")) {
cryptoAmount = cryptoAmount.substring(1);
}
if (cryptoAmount.contains(" ")) {
cryptoAmount = cryptoAmount.split(" ").first;
}
final shift = ref.read(pAmountUnit(coin)).shift;
_amountToSend = cryptoAmount.contains(",") _amountToSend = cryptoAmount.contains(",")
? Decimal.parse(cryptoAmount.replaceFirst(",", ".")) ? Decimal.parse(cryptoAmount.replaceFirst(",", "."))
.shift(0 - shift)
.toAmount(fractionDigits: coin.decimals) .toAmount(fractionDigits: coin.decimals)
: Decimal.parse(cryptoAmount) : Decimal.parse(cryptoAmount)
.shift(0 - shift)
.toAmount(fractionDigits: coin.decimals); .toAmount(fractionDigits: coin.decimals);
if (_cachedAmountToSend != null && if (_cachedAmountToSend != null &&
_cachedAmountToSend == _amountToSend) { _cachedAmountToSend == _amountToSend) {
@ -462,7 +475,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
if (price > Decimal.zero) { if (price > Decimal.zero) {
final String fiatAmountString = (_amountToSend!.decimal * price) final String fiatAmountString = (_amountToSend!.decimal * price)
.toAmount(fractionDigits: 2) .toAmount(fractionDigits: 2)
.localizedStringAsFixed( .fiatString(
locale: ref.read(localeServiceChangeNotifierProvider).locale, locale: ref.read(localeServiceChangeNotifierProvider).locale,
); );
@ -516,10 +529,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
} else { } else {
balance = wallet.availablePublicBalance(); balance = wallet.availablePublicBalance();
} }
return balance.localizedStringAsFixed( return ref.read(pAmountFormatter(coin)).format(balance);
locale: locale,
decimalPlaces: coin.decimals,
);
} }
return null; return null;
@ -539,12 +549,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
} }
if (private && _privateBalanceString != null) { if (private && _privateBalanceString != null) {
return Text( return Text(
"$_privateBalanceString ${coin.ticker}", "$_privateBalanceString",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
); );
} else if (!private && _publicBalanceString != null) { } else if (!private && _publicBalanceString != null) {
return Text( return Text(
"$_publicBalanceString ${coin.ticker}", "$_publicBalanceString",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
); );
} else { } else {
@ -593,11 +603,9 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final amount = Decimal.parse(results["amount"]!).toAmount( final amount = Decimal.parse(results["amount"]!).toAmount(
fractionDigits: coin.decimals, fractionDigits: coin.decimals,
); );
cryptoAmountController.text = amount.localizedStringAsFixed( cryptoAmountController.text = ref
locale: ref.read(localeServiceChangeNotifierProvider).locale, .read(pAmountFormatter(coin))
decimalPlaces: Constants.decimalPlacesForCoin(coin), .format(amount, withUnitName: false);
);
amount.toString();
_amountToSend = amount; _amountToSend = amount;
} }
@ -679,10 +687,10 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info); level: LogLevel.Info);
final amountString = _amountToSend!.localizedStringAsFixed( final amountString = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, _amountToSend!,
decimalPlaces: coin.decimals, withUnitName: false,
); );
_cryptoAmountChangeLock = true; _cryptoAmountChangeLock = true;
cryptoAmountController.text = amountString; cryptoAmountController.text = amountString;
@ -1057,7 +1065,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: Text( child: Text(
coin.ticker, ref.watch(pAmountUnit(coin)).unitForCoin(coin),
style: STextStyles.smallMed14(context).copyWith( style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!

View file

@ -30,6 +30,7 @@ import 'package:stackwallet/services/coins/manager.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/address_utils.dart'; import 'package:stackwallet/utilities/address_utils.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/barcode_scanner_interface.dart'; import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
@ -393,9 +394,8 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
final String fiatAmountString = Amount.fromDecimal( final String fiatAmountString = Amount.fromDecimal(
_amountToSend!.decimal * price, _amountToSend!.decimal * price,
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: ref.read(localeServiceChangeNotifierProvider).locale, locale: ref.read(localeServiceChangeNotifierProvider).locale,
decimalPlaces: 2,
); );
baseAmountController.text = fiatAmountString; baseAmountController.text = fiatAmountString;
@ -463,11 +463,11 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
fractionDigits: fractionDigits:
ref.read(tokenServiceProvider)!.tokenContract.decimals, ref.read(tokenServiceProvider)!.tokenContract.decimals,
); );
cryptoAmountController.text = amount.localizedStringAsFixed( cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, amount,
); withUnitName: false,
);
amount.toString();
_amountToSend = amount; _amountToSend = amount;
} }
@ -551,10 +551,11 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend",
level: LogLevel.Info); level: LogLevel.Info);
final amountString = _amountToSend!.localizedStringAsFixed( final amountString = ref.read(pAmountFormatter(coin)).format(
locale: ref.read(localeServiceChangeNotifierProvider).locale, _amountToSend!,
decimalPlaces: tokenDecimals, withUnitName: false,
); ethContract: ref.read(tokenServiceProvider)!.tokenContract,
);
_cryptoAmountChangeLock = true; _cryptoAmountChangeLock = true;
cryptoAmountController.text = amountString; cryptoAmountController.text = amountString;

View file

@ -20,6 +20,7 @@ import 'package:stackwallet/services/coins/firo/firo_wallet.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/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/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -70,10 +71,14 @@ class _WDesktopWalletSummaryState extends ConsumerState<DesktopWalletSummary> {
final baseCurrency = ref final baseCurrency = ref
.watch(prefsChangeNotifierProvider.select((value) => value.currency)); .watch(prefsChangeNotifierProvider.select((value) => value.currency));
final tokenContract = widget.isToken
? ref
.watch(tokenServiceProvider.select((value) => value!.tokenContract))
: null;
final priceTuple = widget.isToken final priceTuple = widget.isToken
? ref.watch(priceAnd24hChangeNotifierProvider.select((value) => ? ref.watch(priceAnd24hChangeNotifierProvider
value.getTokenPrice(ref.watch(tokenServiceProvider .select((value) => value.getTokenPrice(tokenContract!.address)))
.select((value) => value!.tokenContract.address)))))
: ref.watch(priceAnd24hChangeNotifierProvider : ref.watch(priceAnd24hChangeNotifierProvider
.select((value) => value.getPrice(coin))); .select((value) => value.getPrice(coin)));
@ -81,15 +86,6 @@ class _WDesktopWalletSummaryState extends ConsumerState<DesktopWalletSummary> {
ref.watch(walletBalanceToggleStateProvider.state).state == ref.watch(walletBalanceToggleStateProvider.state).state ==
WalletBalanceToggleState.available; WalletBalanceToggleState.available;
final unit = widget.isToken
? ref.watch(
tokenServiceProvider.select((value) => value!.tokenContract.symbol))
: coin.ticker;
final decimalPlaces = widget.isToken
? ref.watch(tokenServiceProvider
.select((value) => value!.tokenContract.decimals))
: coin.decimals;
Balance balance = widget.isToken Balance balance = widget.isToken
? ref.watch(tokenServiceProvider.select((value) => value!.balance)) ? ref.watch(tokenServiceProvider.select((value) => value!.balance))
: ref.watch(walletsChangeNotifierProvider : ref.watch(walletsChangeNotifierProvider
@ -134,10 +130,9 @@ class _WDesktopWalletSummaryState extends ConsumerState<DesktopWalletSummary> {
FittedBox( FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
child: Text( child: Text(
"${balanceToShow.localizedStringAsFixed( ref
locale: locale, .watch(pAmountFormatter(coin))
decimalPlaces: decimalPlaces, .format(balanceToShow, ethContract: tokenContract),
)} $unit",
style: STextStyles.desktopH3(context), style: STextStyles.desktopH3(context),
), ),
), ),
@ -146,9 +141,8 @@ class _WDesktopWalletSummaryState extends ConsumerState<DesktopWalletSummary> {
"${Amount.fromDecimal( "${Amount.fromDecimal(
priceTuple.item1 * balanceToShow.decimal, priceTuple.item1 * balanceToShow.decimal,
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
decimalPlaces: 2,
)} $baseCurrency", )} $baseCurrency",
style: STextStyles.desktopTextExtraSmall(context).copyWith( style: STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context) color: Theme.of(context)

View file

@ -11,6 +11,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart'; import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart';
@ -288,6 +289,47 @@ class _AdvancedSettings extends ConsumerState<AdvancedSettings> {
], ],
), ),
), ),
const Padding(
padding: EdgeInsets.all(10.0),
child: Divider(
thickness: 0.5,
),
),
Padding(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Units",
style: STextStyles.desktopTextExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark),
textAlign: TextAlign.left,
),
PrimaryButton(
buttonHeight: ButtonHeight.xs,
label: "Edit",
width: 101,
onPressed: () async {
await showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const ManageCoinUnitsView();
},
);
},
),
],
),
),
const SizedBox(
height: 10,
),
], ],
), ),
), ),

View file

@ -72,6 +72,8 @@ import 'package:stackwallet/pages/send_view/token_send_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/about_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/about_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart';
@ -642,6 +644,26 @@ class RouteGenerator {
} }
return _routeError("${settings.name} invalid args: ${args.toString()}"); return _routeError("${settings.name} invalid args: ${args.toString()}");
case ManageCoinUnitsView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => const ManageCoinUnitsView(),
settings: RouteSettings(name: settings.name));
case EditCoinUnitsView.routeName:
if (args is Coin) {
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => EditCoinUnitsView(
coin: args,
),
settings: RouteSettings(
name: settings.name,
),
);
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
case CreateBackupInfoView.routeName: case CreateBackupInfoView.routeName:
return getRoute( return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute, shouldUseMaterialRoute: useMaterialPageRoute,

View file

@ -1211,13 +1211,18 @@ class BitcoinWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1298,6 +1303,7 @@ class BitcoinWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1352,16 +1358,14 @@ class BitcoinWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());

View file

@ -1082,13 +1082,18 @@ class BitcoinCashWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1163,6 +1168,7 @@ class BitcoinCashWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1244,16 +1250,14 @@ class BitcoinCashWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -2149,6 +2153,7 @@ class BitcoinCashWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: inputs, inputs: inputs,
outputs: outputs, outputs: outputs,
numberOfMessages: null,
); );
txns.add(Tuple2(tx, transactionAddress)); txns.add(Tuple2(tx, transactionAddress));

View file

@ -79,17 +79,7 @@ abstract class CoinServiceAPI {
prefs: prefs, prefs: prefs,
); );
final cachedClient = CachedElectrumX.from( final cachedClient = CachedElectrumX.from(
node: electrumxNode, electrumXClient: client,
failovers: failovers
.map((e) => ElectrumXNode(
address: e.host,
port: e.port,
name: e.name,
id: e.id,
useSSL: e.useSSL,
))
.toList(),
prefs: prefs,
); );
switch (coin) { switch (coin) {
case Coin.firo: case Coin.firo:

View file

@ -1068,13 +1068,18 @@ class DogecoinWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1150,6 +1155,7 @@ class DogecoinWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1204,16 +1210,14 @@ class DogecoinWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());

View file

@ -57,7 +57,7 @@ import 'package:stackwallet/widgets/crypto_notifications.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
const int MINIMUM_CONFIRMATIONS = 1; const int MINIMUM_CONFIRMATIONS = 0;
const String GENESIS_HASH_MAINNET = const String GENESIS_HASH_MAINNET =
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
@ -371,9 +371,9 @@ class ECashWallet extends CoinServiceAPI
print("format $format"); print("format $format");
} }
if (_coin == Coin.bitcoincashTestnet) { // if (_coin == Coin.bitcoincashTestnet) {
return true; // return true;
} // }
if (format == bitbox.Address.formatCashAddr) { if (format == bitbox.Address.formatCashAddr) {
return validateCashAddr(address); return validateCashAddr(address);
@ -420,16 +420,14 @@ class ECashWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -1377,6 +1375,7 @@ class ECashWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: inputs, inputs: inputs,
outputs: outputs, outputs: outputs,
numberOfMessages: null,
); );
txns.add(Tuple2(tx, transactionAddress)); txns.add(Tuple2(tx, transactionAddress));
@ -1909,7 +1908,7 @@ class ECashWallet extends CoinServiceAPI
required List<int> satoshiAmounts, required List<int> satoshiAmounts,
}) async { }) async {
final builder = bitbox.Bitbox.transactionBuilder( final builder = bitbox.Bitbox.transactionBuilder(
testnet: coin == Coin.bitcoincashTestnet, testnet: false, //coin == Coin.bitcoincashTestnet,
); );
// retrieve address' utxos from the rest api // retrieve address' utxos from the rest api
@ -2691,13 +2690,18 @@ class ECashWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -2782,6 +2786,7 @@ class ECashWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String

View file

@ -1163,10 +1163,6 @@ class EpicCashWallet extends CoinServiceAPI
Future<bool> startScans() async { Future<bool> startScans() async {
try { try {
if (ListenerManager.pointer != null) { if (ListenerManager.pointer != null) {
Logging.instance
.log("LISTENER HANDLER IS NOT NULL ....", level: LogLevel.Info);
Logging.instance
.log("STOPPING ANY WALLET LISTENER ....", level: LogLevel.Info);
epicboxListenerStop(ListenerManager.pointer!); epicboxListenerStop(ListenerManager.pointer!);
} }
@ -1630,13 +1626,18 @@ class EpicCashWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1653,7 +1654,7 @@ class EpicCashWallet extends CoinServiceAPI
Future<void> _refreshTransactions() async { Future<void> _refreshTransactions() async {
// final currentChainHeight = await chainHeight; // final currentChainHeight = await chainHeight;
final wallet = await _secureStore.read(key: '${_walletId}_wallet'); final wallet = await _secureStore.read(key: '${_walletId}_wallet');
const refreshFromNode = 0; const refreshFromNode = 1;
dynamic message; dynamic message;
await m.protect(() async { await m.protect(() async {
@ -1719,6 +1720,7 @@ class EpicCashWallet extends CoinServiceAPI
?[tx["tx_type"] == "TxReceived" ? "from" : "to"] as String? ?? ?[tx["tx_type"] == "TxReceived" ? "from" : "to"] as String? ??
""; "";
String? commitId = slatesToCommits[slateId]?['commitId'] as String?; String? commitId = slatesToCommits[slateId]?['commitId'] as String?;
tx['numberOfMessages'] = tx['messages']?['messages']?.length;
int? height; int? height;
@ -1731,6 +1733,7 @@ class EpicCashWallet extends CoinServiceAPI
final isIncoming = (tx["tx_type"] == "TxReceived" || final isIncoming = (tx["tx_type"] == "TxReceived" ||
tx["tx_type"] == "TxReceivedCancelled"); tx["tx_type"] == "TxReceivedCancelled");
final txn = isar_models.Transaction( final txn = isar_models.Transaction(
walletId: walletId, walletId: walletId,
txid: commitId ?? tx["id"].toString(), txid: commitId ?? tx["id"].toString(),
@ -1754,6 +1757,7 @@ class EpicCashWallet extends CoinServiceAPI
otherData: tx["id"].toString(), otherData: tx["id"].toString(),
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int,
); );
// txn.address = // txn.address =

View file

@ -954,6 +954,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
response.value?.nonce.toBigIntFromHex.toInt(), response.value?.nonce.toBigIntFromHex.toInt(),
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
Address? address = await db.getAddress( Address? address = await db.getAddress(
@ -1045,6 +1046,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
nonce: tuple.item2, nonce: tuple.item2,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
Address? transactionAddress = await db Address? transactionAddress = await db

View file

@ -459,6 +459,7 @@ Future<Map<dynamic, dynamic>> staticProcessRestore(
nonce: null, nonce: null,
inputs: element.inputs, inputs: element.inputs,
outputs: element.outputs, outputs: element.outputs,
numberOfMessages: null,
)..address.value = element.address.value; )..address.value = element.address.value;
} }
}); });
@ -901,6 +902,7 @@ class FiroWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -995,13 +997,18 @@ class FiroWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1850,16 +1857,14 @@ class FiroWallet extends CoinServiceAPI
) )
.toList(); .toList();
final newNode = await _getCurrentNode(); final newNode = await _getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -3045,6 +3050,7 @@ class FiroWallet extends CoinServiceAPI
otherData: transactionInfo["otherData"] as String?, otherData: transactionInfo["otherData"] as String?,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final transactionAddress = await db final transactionAddress = await db
@ -3371,33 +3377,33 @@ class FiroWallet extends CoinServiceAPI
List<Map<String, dynamic>> allTransactions = []; List<Map<String, dynamic>> allTransactions = [];
final currentHeight = await chainHeight; // final currentHeight = await chainHeight;
for (final txHash in allTxHashes) { for (final txHash in allTxHashes) {
final storedTx = await db // final storedTx = await db
.getTransactions(walletId) // .getTransactions(walletId)
.filter() // .filter()
.txidEqualTo(txHash["tx_hash"] as String) // .txidEqualTo(txHash["tx_hash"] as String)
.findFirst(); // .findFirst();
if (storedTx == null || // if (storedTx == null ||
!storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { // !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) {
final tx = await cachedElectrumXClient.getTransaction( final tx = await cachedElectrumXClient.getTransaction(
txHash: txHash["tx_hash"] as String, txHash: txHash["tx_hash"] as String,
verbose: true, verbose: true,
coin: coin, coin: coin,
); );
if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) {
tx["address"] = await db tx["address"] = await db
.getAddresses(walletId) .getAddresses(walletId)
.filter() .filter()
.valueEqualTo(txHash["address"] as String) .valueEqualTo(txHash["address"] as String)
.findFirst(); .findFirst();
tx["height"] = txHash["height"]; tx["height"] = txHash["height"];
allTransactions.add(tx); allTransactions.add(tx);
}
} }
// }
} }
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData = final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
@ -3525,6 +3531,7 @@ class FiroWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: ins, inputs: ins,
outputs: [], outputs: [],
numberOfMessages: null,
); );
txnsData.add(Tuple2(tx, null)); txnsData.add(Tuple2(tx, null));
@ -3647,6 +3654,7 @@ class FiroWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: ins, inputs: ins,
outputs: outs, outputs: outs,
numberOfMessages: null,
); );
txnsData.add(Tuple2(tx, transactionAddress)); txnsData.add(Tuple2(tx, transactionAddress));
@ -3798,6 +3806,7 @@ class FiroWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: ins, inputs: ins,
outputs: outs, outputs: outs,
numberOfMessages: null,
); );
txnsData.add(Tuple2(tx, transactionAddress)); txnsData.add(Tuple2(tx, transactionAddress));
@ -5077,6 +5086,7 @@ class FiroWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = await db final address = await db

View file

@ -1199,13 +1199,18 @@ class LitecoinWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1281,6 +1286,7 @@ class LitecoinWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1335,16 +1341,14 @@ class LitecoinWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -1803,6 +1807,18 @@ class LitecoinWallet extends CoinServiceAPI
coin: coin, coin: coin,
); );
bool shouldBlock = false;
String? blockReason;
String? label;
final utxoAmount = jsonUTXO["value"] as int;
if (utxoAmount <= 10000) {
shouldBlock = true;
blockReason = "May contain ordinal";
label = "Possible ordinal";
}
final vout = jsonUTXO["tx_pos"] as int; final vout = jsonUTXO["tx_pos"] as int;
final outputs = txn["vout"] as List; final outputs = txn["vout"] as List;
@ -1821,10 +1837,10 @@ class LitecoinWallet extends CoinServiceAPI
walletId: walletId, walletId: walletId,
txid: txn["txid"] as String, txid: txn["txid"] as String,
vout: vout, vout: vout,
value: jsonUTXO["value"] as int, value: utxoAmount,
name: "", name: label ?? "",
isBlocked: false, isBlocked: shouldBlock,
blockedReason: null, blockedReason: blockReason,
isCoinbase: txn["is_coinbase"] as bool? ?? false, isCoinbase: txn["is_coinbase"] as bool? ?? false,
blockHash: txn["blockhash"] as String?, blockHash: txn["blockhash"] as String?,
blockHeight: jsonUTXO["height"] as int?, blockHeight: jsonUTXO["height"] as int?,
@ -1836,16 +1852,20 @@ class LitecoinWallet extends CoinServiceAPI
} }
} }
Logging.instance Logging.instance.log(
.log('Outputs fetched: $outputArray', level: LogLevel.Info); 'Outputs fetched: $outputArray',
level: LogLevel.Info,
);
await db.updateUTXOs(walletId, outputArray); await db.updateUTXOs(walletId, outputArray);
// finally update balance // finally update balance
await _updateBalance(); await _updateBalance();
} catch (e, s) { } catch (e, s) {
Logging.instance Logging.instance.log(
.log("Output fetch unsuccessful: $e\n$s", level: LogLevel.Error); "Output fetch unsuccessful: $e\n$s",
level: LogLevel.Error,
);
} }
} }

View file

@ -964,6 +964,7 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
txnsData.add(Tuple2(txn, address)); txnsData.add(Tuple2(txn, address));

View file

@ -1189,13 +1189,18 @@ class NamecoinWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1270,6 +1275,7 @@ class NamecoinWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1324,16 +1330,14 @@ class NamecoinWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -2813,19 +2817,18 @@ class NamecoinWallet extends CoinServiceAPI
// Add transaction output // Add transaction output
for (var i = 0; i < recipients.length; i++) { for (var i = 0; i < recipients.length; i++) {
txb.addOutput(recipients[i], satoshiAmounts[i], namecoin.bech32!); txb.addOutput(recipients[i], satoshiAmounts[i], _network.bech32!);
} }
try { try {
// Sign the transaction accordingly // Sign the transaction accordingly
for (var i = 0; i < utxoSigningData.length; i++) { for (var i = 0; i < utxoSigningData.length; i++) {
final txid = utxoSigningData[i].utxo.txid; txb.sign(
txb.addInput( vin: i,
txid, keyPair: utxoSigningData[i].keyPair!,
utxoSigningData[i].utxo.vout, witnessValue: utxoSigningData[i].utxo.value,
null, redeemScript: utxoSigningData[i].redeemScript,
utxoSigningData[i].output!, overridePrefix: _network.bech32!,
_network.bech32!,
); );
} }
} catch (e, s) { } catch (e, s) {
@ -2834,7 +2837,7 @@ class NamecoinWallet extends CoinServiceAPI
rethrow; rethrow;
} }
final builtTx = txb.build(namecoin.bech32!); final builtTx = txb.build(_network.bech32!);
final vSize = builtTx.virtualSize(); final vSize = builtTx.virtualSize();
return {"hex": builtTx.toHex(), "vSize": vSize}; return {"hex": builtTx.toHex(), "vSize": vSize};

View file

@ -1116,13 +1116,18 @@ class ParticlWallet extends CoinServiceAPI
void _periodicPingCheck() async { void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection(); bool hasNetwork = await testNetworkConnection();
_isConnected = hasNetwork;
if (_isConnected != hasNetwork) { if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected ? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected; : NodeConnectionStatus.disconnected;
GlobalEventBus.instance GlobalEventBus.instance
.fire(NodeConnectionStatusChangedEvent(status, walletId, coin)); .fire(NodeConnectionStatusChangedEvent(status, walletId, coin));
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
} }
} }
@ -1198,6 +1203,7 @@ class ParticlWallet extends CoinServiceAPI
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
final address = txData["address"] is String final address = txData["address"] is String
@ -1252,16 +1258,14 @@ class ParticlWallet extends CoinServiceAPI
)) ))
.toList(); .toList();
final newNode = await getCurrentNode(); final newNode = await getCurrentNode();
_cachedElectrumXClient = CachedElectrumX.from(
node: newNode,
prefs: _prefs,
failovers: failovers,
);
_electrumXClient = ElectrumX.from( _electrumXClient = ElectrumX.from(
node: newNode, node: newNode,
prefs: _prefs, prefs: _prefs,
failovers: failovers, failovers: failovers,
); );
_cachedElectrumXClient = CachedElectrumX.from(
electrumXClient: _electrumXClient,
);
if (shouldRefresh) { if (shouldRefresh) {
unawaited(refresh()); unawaited(refresh());
@ -2403,6 +2407,7 @@ class ParticlWallet extends CoinServiceAPI
nonce: null, nonce: null,
slateId: null, slateId: null,
otherData: null, otherData: null,
numberOfMessages: null,
); );
txns.add(Tuple2(tx, transactionAddress)); txns.add(Tuple2(tx, transactionAddress));

View file

@ -1051,6 +1051,7 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
txnsData.add(Tuple2(txn, address)); txnsData.add(Tuple2(txn, address));

View file

@ -179,6 +179,7 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
response.value?.nonce.toBigIntFromHex.toInt(), response.value?.nonce.toBigIntFromHex.toInt(),
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
Address? address = await ethWallet.db.getAddress( Address? address = await ethWallet.db.getAddress(
@ -529,6 +530,7 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
otherData: tuple.item1.address, otherData: tuple.item1.address,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
Address? transactionAddress = await ethWallet.db Address? transactionAddress = await ethWallet.db

View file

@ -158,19 +158,31 @@ mixin ElectrumXParsing {
type = TransactionType.outgoing; type = TransactionType.outgoing;
amount = amountSentFromWallet - changeAmount - fee; amount = amountSentFromWallet - changeAmount - fee;
final possible = // non wallet addresses found in tx outputs
outputAddresses.difference(myChangeReceivedOnAddresses).first; final nonWalletOutAddresses = outputAddresses.difference(
myChangeReceivedOnAddresses,
);
if (transactionAddress.value != possible) { if (nonWalletOutAddresses.isNotEmpty) {
transactionAddress = Address( final possible = nonWalletOutAddresses.first;
walletId: walletId,
value: possible, if (transactionAddress.value != possible) {
derivationIndex: -1, transactionAddress = Address(
derivationPath: null, walletId: walletId,
subType: AddressSubType.nonWallet, value: possible,
type: AddressType.nonWallet, derivationIndex: -1,
publicKey: [], derivationPath: null,
); subType: AddressSubType.nonWallet,
type: AddressType.nonWallet,
publicKey: [],
);
}
} else {
// some other type of tx where the receiving address is
// one of my change addresses
type = TransactionType.sentToSelf;
amount = changeAmount;
} }
} else { } else {
// incoming tx // incoming tx
@ -256,6 +268,7 @@ mixin ElectrumXParsing {
nonce: null, nonce: null,
inputs: ins, inputs: ins,
outputs: outs, outputs: outs,
numberOfMessages: null,
); );
return Tuple2(tx, transactionAddress); return Tuple2(tx, transactionAddress);

View file

@ -62,19 +62,11 @@ class Amount {
return jsonEncode(toMap()); return jsonEncode(toMap());
} }
String localizedStringAsFixed({ String fiatString({
required String locale, required String locale,
int? decimalPlaces,
}) { }) {
decimalPlaces ??= fractionDigits;
assert(decimalPlaces >= 0);
final wholeNumber = decimal.truncate(); final wholeNumber = decimal.truncate();
if (decimalPlaces == 0) {
return wholeNumber.toStringAsFixed(0);
}
final String separator = final String separator =
(numberFormatSymbols[locale] as NumberSymbols?)?.DECIMAL_SEP ?? (numberFormatSymbols[locale] as NumberSymbols?)?.DECIMAL_SEP ??
(numberFormatSymbols[locale.substring(0, 2)] as NumberSymbols?) (numberFormatSymbols[locale.substring(0, 2)] as NumberSymbols?)
@ -83,8 +75,31 @@ class Amount {
final fraction = decimal - wholeNumber; final fraction = decimal - wholeNumber;
return "${wholeNumber.toStringAsFixed(0)}$separator${fraction.toStringAsFixed(decimalPlaces).substring(2)}"; return "${wholeNumber.toStringAsFixed(0)}$separator${fraction.toStringAsFixed(2).substring(2)}";
} }
// String localizedStringAsFixed({
// required String locale,
// int? decimalPlaces,
// }) {
// decimalPlaces ??= fractionDigits;
// assert(decimalPlaces >= 0);
//
// final wholeNumber = decimal.truncate();
//
// if (decimalPlaces == 0) {
// return wholeNumber.toStringAsFixed(0);
// }
//
// final String separator =
// (numberFormatSymbols[locale] as NumberSymbols?)?.DECIMAL_SEP ??
// (numberFormatSymbols[locale.substring(0, 2)] as NumberSymbols?)
// ?.DECIMAL_SEP ??
// ".";
//
// final fraction = decimal - wholeNumber;
//
// return "${wholeNumber.toStringAsFixed(0)}$separator${fraction.toStringAsFixed(decimalPlaces).substring(2)}";
// }
// =========================================================================== // ===========================================================================
// ======= Deserialization =================================================== // ======= Deserialization ===================================================

View file

@ -0,0 +1,66 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/providers/global/locale_provider.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/amount/amount_unit.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
final pAmountUnit = Provider.family<AmountUnit, Coin>(
(ref, coin) => ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.amountUnit(coin),
),
),
);
final pMaxDecimals = Provider.family<int, Coin>(
(ref, coin) => ref.watch(
prefsChangeNotifierProvider.select(
(value) => value.maxDecimals(coin),
),
),
);
final pAmountFormatter = Provider.family<AmountFormatter, Coin>((ref, coin) {
return AmountFormatter(
unit: ref.watch(pAmountUnit(coin)),
locale: ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale),
),
coin: coin,
maxDecimals: ref.watch(pMaxDecimals(coin)),
);
});
class AmountFormatter {
final AmountUnit unit;
final String locale;
final Coin coin;
final int maxDecimals;
AmountFormatter({
required this.unit,
required this.locale,
required this.coin,
required this.maxDecimals,
});
String format(
Amount amount, {
String? overrideUnit,
EthContract? ethContract,
bool withUnitName = true,
bool indicatePrecisionLoss = true,
}) {
return unit.displayAmount(
amount: amount,
locale: locale,
coin: coin,
maxDecimalPlaces: maxDecimals,
withUnitName: withUnitName,
indicatePrecisionLoss: indicatePrecisionLoss,
overrideUnit: overrideUnit,
tokenContract: ethContract,
);
}
}

View file

@ -13,9 +13,11 @@ import 'dart:math' as math;
import 'package:decimal/decimal.dart'; import 'package:decimal/decimal.dart';
import 'package:intl/number_symbols.dart'; import 'package:intl/number_symbols.dart';
import 'package:intl/number_symbols_data.dart'; import 'package:intl/number_symbols_data.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
// preserve index order as index is used to store value in preferences
enum AmountUnit { enum AmountUnit {
normal(0), normal(0),
milli(3), milli(3),
@ -28,6 +30,33 @@ enum AmountUnit {
const AmountUnit(this.shift); const AmountUnit(this.shift);
final int shift; final int shift;
static List<AmountUnit> valuesForCoin(Coin coin) {
switch (coin) {
case Coin.firo:
case Coin.litecoin:
case Coin.particl:
case Coin.namecoin:
case Coin.bitcoinTestNet:
case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet:
case Coin.dogecoinTestNet:
case Coin.firoTestNet:
case Coin.bitcoin:
case Coin.bitcoincash:
case Coin.dogecoin:
case Coin.eCash:
case Coin.epicCash:
return AmountUnit.values.sublist(0, 4);
case Coin.monero:
case Coin.wownero:
return AmountUnit.values.sublist(0, 5);
case Coin.ethereum:
return AmountUnit.values;
}
}
} }
extension AmountUnitExt on AmountUnit { extension AmountUnitExt on AmountUnit {
@ -70,13 +99,37 @@ extension AmountUnitExt on AmountUnit {
} }
} }
String unitForContract(EthContract contract) {
switch (this) {
case AmountUnit.normal:
return contract.symbol;
case AmountUnit.milli:
return "m${contract.symbol}";
case AmountUnit.micro:
return "µ${contract.symbol}";
case AmountUnit.nano:
return "gwei";
case AmountUnit.pico:
return "mwei";
case AmountUnit.femto:
return "kwei";
case AmountUnit.atto:
return "wei";
}
}
String displayAmount({ String displayAmount({
required Amount amount, required Amount amount,
required String locale, required String locale,
required Coin coin, required Coin coin,
required int maxDecimalPlaces, required int maxDecimalPlaces,
bool withUnitName = true,
bool indicatePrecisionLoss = true,
String? overrideUnit,
EthContract? tokenContract,
}) { }) {
assert(maxDecimalPlaces >= 0); assert(maxDecimalPlaces >= 0);
// ensure we don't shift past minimum atomic value // ensure we don't shift past minimum atomic value
final realShift = math.min(shift, amount.fractionDigits); final realShift = math.min(shift, amount.fractionDigits);
@ -92,18 +145,44 @@ extension AmountUnitExt on AmountUnit {
// start building the return value with just the whole value // start building the return value with just the whole value
String returnValue = wholeNumber.toString(); String returnValue = wholeNumber.toString();
// if true and withUnitName is true, we will show "~" prepended on amount
bool didLosePrecision = false;
// if any decimal places should be shown continue building the return value // if any decimal places should be shown continue building the return value
if (places > 0) { if (places > 0) {
// get the fractional value // get the fractional value
final Decimal fraction = shifted - shifted.truncate(); final Decimal fraction = shifted - shifted.truncate();
// get final decimal based on max precision wanted // get final decimal based on max precision wanted while ensuring that
final int actualDecimalPlaces = math.min(places, maxDecimalPlaces); // maxDecimalPlaces doesn't exceed the max per coin
final int updatedMax;
if (tokenContract != null) {
updatedMax = maxDecimalPlaces > tokenContract.decimals
? tokenContract.decimals
: maxDecimalPlaces;
} else {
updatedMax =
maxDecimalPlaces > coin.decimals ? coin.decimals : maxDecimalPlaces;
}
final int actualDecimalPlaces = math.min(places, updatedMax);
// get remainder string without the prepending "0." // get remainder string without the prepending "0."
String remainder = fraction.toString().substring(2); final fractionString = fraction.toString();
String remainder;
if (fractionString.length > 2) {
remainder = fraction.toString().substring(2);
} else {
remainder = "0";
}
if (remainder.length > actualDecimalPlaces) { if (remainder.length > actualDecimalPlaces) {
// check for loss of precision
final remainingRemainder =
BigInt.tryParse(remainder.substring(actualDecimalPlaces));
if (remainingRemainder != null) {
didLosePrecision = remainingRemainder > BigInt.zero;
}
// trim unwanted trailing digits // trim unwanted trailing digits
remainder = remainder.substring(0, actualDecimalPlaces); remainder = remainder.substring(0, actualDecimalPlaces);
} else if (remainder.length < actualDecimalPlaces) { } else if (remainder.length < actualDecimalPlaces) {
@ -124,7 +203,23 @@ extension AmountUnitExt on AmountUnit {
returnValue += "$separator$remainder"; returnValue += "$separator$remainder";
} }
if (!withUnitName && !indicatePrecisionLoss) {
return returnValue;
}
if (didLosePrecision && indicatePrecisionLoss) {
returnValue = "~$returnValue";
}
if (!withUnitName && indicatePrecisionLoss) {
return returnValue;
}
// return the value with the proper unit symbol // return the value with the proper unit symbol
return "$returnValue ${unitForCoin(coin)}"; if (tokenContract != null) {
overrideUnit = unitForContract(tokenContract);
}
return "$returnValue ${overrideUnit ?? unitForCoin(coin)}";
} }
} }

View file

@ -52,8 +52,6 @@ abstract class Constants {
static const int notificationsMax = 0xFFFFFFFF; static const int notificationsMax = 0xFFFFFFFF;
static const Duration networkAliveTimerDuration = Duration(seconds: 10); static const Duration networkAliveTimerDuration = Duration(seconds: 10);
static const int pinLength = 4;
// Enable Logger.print statements // Enable Logger.print statements
static const bool disableLogger = false; static const bool disableLogger = false;

View file

@ -407,6 +407,7 @@ class DbVersionMigrator with WalletDB {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: tx.numberOfMessages,
); );
if (tx.address.isEmpty) { if (tx.address.isEmpty) {

View file

@ -74,7 +74,7 @@ extension CoinExt on Coin {
case Coin.epicCash: case Coin.epicCash:
return "Epic Cash"; return "Epic Cash";
case Coin.eCash: case Coin.eCash:
return "E-Cash"; return "eCash";
case Coin.ethereum: case Coin.ethereum:
return "Ethereum"; return "Ethereum";
case Coin.firo: case Coin.firo:

View file

@ -10,8 +10,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/amount/amount_unit.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/languages_enum.dart'; import 'package:stackwallet/utilities/enums/languages_enum.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
@ -56,6 +58,8 @@ class Prefs extends ChangeNotifier {
_themeId = await _getThemeId(); _themeId = await _getThemeId();
_systemBrightnessLightThemeId = await _getSystemBrightnessLightThemeId(); _systemBrightnessLightThemeId = await _getSystemBrightnessLightThemeId();
_systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme(); _systemBrightnessDarkThemeId = await _getSystemBrightnessDarkTheme();
await _setAmountUnits();
await _setMaxDecimals();
_initialized = true; _initialized = true;
} }
@ -806,4 +810,62 @@ class Prefs extends ChangeNotifier {
) as String? ?? ) as String? ??
"dark"; "dark";
} }
// coin amount unit settings
final Map<Coin, AmountUnit> _amountUnits = {};
AmountUnit amountUnit(Coin coin) => _amountUnits[coin] ?? AmountUnit.normal;
void updateAmountUnit({required Coin coin, required AmountUnit amountUnit}) {
if (this.amountUnit(coin) != amountUnit) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "amountUnitFor${coin.name}",
value: amountUnit.index,
);
_amountUnits[coin] = amountUnit;
notifyListeners();
}
}
Future<void> _setAmountUnits() async {
for (final coin in Coin.values) {
final unitIndex = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs,
key: "amountUnitFor${coin.name}",
) as int? ??
0; // 0 is "normal"
_amountUnits[coin] = AmountUnit.values[unitIndex];
}
}
// coin precision setting (max decimal places to show)
final Map<Coin, int> _amountDecimals = {};
int maxDecimals(Coin coin) => _amountDecimals[coin] ?? coin.decimals;
void updateMaxDecimals({required Coin coin, required int maxDecimals}) {
if (this.maxDecimals(coin) != maxDecimals) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs,
key: "maxDecimalsFor${coin.name}",
value: maxDecimals,
);
_amountDecimals[coin] = maxDecimals;
notifyListeners();
}
}
Future<void> _setMaxDecimals() async {
for (final coin in Coin.values) {
final decimals = await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs,
key: "maxDecimalsFor${coin.name}",
) as int? ??
coin.decimals;
_amountDecimals[coin] = decimals;
}
}
} }

View file

@ -63,8 +63,10 @@ class CustomPinPut extends StatefulWidget {
this.mainAxisSize = MainAxisSize.max, this.mainAxisSize = MainAxisSize.max,
this.autofillHints, this.autofillHints,
this.customKey, this.customKey,
}) : assert(fieldsCount > 0), this.onPinLengthChanged,
super(key: key); }) : super(key: key);
final void Function(int)? onPinLengthChanged;
final double? width; final double? width;
final double? height; final double? height;

View file

@ -8,6 +8,8 @@
* *
*/ */
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart';
import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart'; import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart';
@ -20,6 +22,13 @@ class CustomPinPutState extends State<CustomPinPut>
int get selectedIndex => _controller.value.text.length; int get selectedIndex => _controller.value.text.length;
int _pinCount = 0;
int get pinCount => _pinCount;
set pinCount(int newCount) {
_pinCount = newCount;
widget.onPinLengthChanged?.call(newCount);
}
@override @override
void initState() { void initState() {
_controller = widget.controller ?? TextEditingController(); _controller = widget.controller ?? TextEditingController();
@ -60,22 +69,19 @@ class CustomPinPutState extends State<CustomPinPut>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// final bool randomize = ref
// .read(prefsChangeNotifierProvider)
// .randomizePIN;
return SizedBox( return SizedBox(
width: widget.width, width: widget.width,
height: widget.height, height: widget.height,
child: Column( child: Column(
children: [ children: [
SizedBox( SizedBox(
width: (30 * widget.fieldsCount) - 18, width: max((30 * pinCount) - 18, 1),
child: Stack( child: Stack(
children: [ children: [
_hiddenTextField, _hiddenTextField,
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: _fields, child: _fields(pinCount),
), ),
], ],
), ),
@ -85,15 +91,22 @@ class CustomPinPutState extends State<CustomPinPut>
isRandom: widget.isRandom, isRandom: widget.isRandom,
customKey: widget.customKey, customKey: widget.customKey,
onNumberKeyPressed: (number) { onNumberKeyPressed: (number) {
if (_controller.text.length < widget.fieldsCount) { _controller.text += number;
_controller.text += number;
} // add a set state and have the counter increment
setState(() {
pinCount = _controller.text.length;
});
}, },
onBackPressed: () { onBackPressed: () {
final text = _controller.text; final text = _controller.text;
if (text.isNotEmpty) { if (text.isNotEmpty) {
_controller.text = text.substring(0, text.length - 1); _controller.text = text.substring(0, text.length - 1);
setState(() {
pinCount = _controller.text.length;
});
} }
// decrement counter here
}, },
onSubmitPressed: () { onSubmitPressed: () {
final pin = _controller.value.text; final pin = _controller.value.text;
@ -127,7 +140,7 @@ class CustomPinPutState extends State<CustomPinPut>
textCapitalization: widget.textCapitalization, textCapitalization: widget.textCapitalization,
inputFormatters: widget.inputFormatters, inputFormatters: widget.inputFormatters,
enableInteractiveSelection: false, enableInteractiveSelection: false,
maxLength: widget.fieldsCount, maxLength: 10,
showCursor: false, showCursor: false,
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
decoration: widget.inputDecoration, decoration: widget.inputDecoration,
@ -137,21 +150,22 @@ class CustomPinPutState extends State<CustomPinPut>
); );
} }
Widget get _fields { // have it include an int as a param
Widget _fields(int count) {
return ValueListenableBuilder<String>( return ValueListenableBuilder<String>(
valueListenable: _textControllerValue, valueListenable: _textControllerValue,
builder: (BuildContext context, value, Widget? child) { builder: (BuildContext context, value, Widget? child) {
return Row( return Row(
mainAxisSize: widget.mainAxisSize, mainAxisSize: widget.mainAxisSize,
mainAxisAlignment: widget.fieldsAlignment, mainAxisAlignment: widget.fieldsAlignment,
children: _buildFieldsWithSeparator(), children: _buildFieldsWithSeparator(count),
); );
}, },
); );
} }
List<Widget> _buildFieldsWithSeparator() { List<Widget> _buildFieldsWithSeparator(int count) {
final fields = Iterable<int>.generate(widget.fieldsCount).map((index) { final fields = Iterable<int>.generate(count).map((index) {
return _getField(index); return _getField(index);
}).toList(); }).toList();

View file

@ -14,8 +14,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart'; import 'package:stackwallet/themes/coin_icon_provider.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_formatter.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -44,6 +47,28 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
final isDesktop = Util.isDesktop; final isDesktop = Util.isDesktop;
final balance = ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(widget.walletId).balance,
),
);
Amount total = balance.total;
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
final balancePrivate = ref.watch(
walletsChangeNotifierProvider.select(
(value) => (value
.getManager(
widget.walletId,
)
.wallet as FiroWallet)
.balancePrivate,
),
);
total += balancePrivate.total;
}
return RoundedWhiteContainer( return RoundedWhiteContainer(
padding: EdgeInsets.all(isDesktop ? 0 : 4.0), padding: EdgeInsets.all(isDesktop ? 0 : 4.0),
child: RawMaterialButton( child: RawMaterialButton(
@ -117,14 +142,11 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
), ),
Expanded( Expanded(
child: Text( child: Text(
"${manager.balance.total.localizedStringAsFixed( ref
locale: ref.watch( .watch(
localeServiceChangeNotifierProvider.select( pAmountFormatter(manager.coin),
(value) => value.locale, )
), .format(total),
),
decimalPlaces: manager.coin.decimals,
)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
), ),
@ -160,14 +182,11 @@ class _ManagedFavoriteCardState extends ConsumerState<ManagedFavorite> {
height: 2, height: 2,
), ),
Text( Text(
"${manager.balance.total.localizedStringAsFixed( ref
locale: ref.watch( .watch(
localeServiceChangeNotifierProvider.select( pAmountFormatter(manager.coin),
(value) => value.locale, )
), .format(total),
),
decimalPlaces: manager.coin.decimals,
)} ${manager.coin.ticker}",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
], ],

View file

@ -20,6 +20,7 @@ import 'package:stackwallet/providers/db/main_db_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';
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/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/format.dart';
@ -49,6 +50,7 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
late final String prefix; late final String prefix;
late final String unit; late final String unit;
late final Coin coin; late final Coin coin;
late final EthContract? tokenContract;
String whatIsIt( String whatIsIt(
TransactionType type, TransactionType type,
@ -126,12 +128,11 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
.getManager(widget.walletId) .getManager(widget.walletId)
.coin; .coin;
unit = isTokenTx tokenContract = ref
? ref .read(mainDBProvider)
.read(mainDBProvider) .getEthContractSync(_transaction.otherData ?? "");
.getEthContractSync(_transaction.otherData!)!
.symbol unit = isTokenTx ? tokenContract!.symbol : coin.ticker;
: coin.ticker;
super.initState(); super.initState();
} }
@ -250,9 +251,7 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
final amount = _transaction.realAmount; final amount = _transaction.realAmount;
return Text( return Text(
"$prefix${amount.localizedStringAsFixed( "$prefix${ref.watch(pAmountFormatter(coin)).format(amount, ethContract: tokenContract)}",
locale: locale,
)} $unit",
style: STextStyles.itemSubtitle12(context), style: STextStyles.itemSubtitle12(context),
); );
}, },
@ -295,9 +294,8 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
"$prefix${Amount.fromDecimal( "$prefix${Amount.fromDecimal(
amount.decimal * price, amount.decimal * price,
fractionDigits: 2, fractionDigits: 2,
).localizedStringAsFixed( ).fiatString(
locale: locale, locale: locale,
decimalPlaces: 2,
)} $baseCurrency", )} $baseCurrency",
style: STextStyles.label(context), style: STextStyles.label(context),
); );

View file

@ -11,11 +11,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart'; import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_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/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.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';
@ -36,36 +38,25 @@ class WalletInfoRowBalance extends ConsumerWidget {
.watch(walletsChangeNotifierProvider.notifier) .watch(walletsChangeNotifierProvider.notifier)
.getManagerProvider(walletId)); .getManagerProvider(walletId));
final locale = ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
);
Amount totalBalance; Amount totalBalance;
int decimals; EthContract? contract;
String unit;
if (contractAddress == null) { if (contractAddress == null) {
totalBalance = manager.balance.total; totalBalance = manager.balance.total;
if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) { if (manager.coin == Coin.firo || manager.coin == Coin.firoTestNet) {
totalBalance = totalBalance =
totalBalance + (manager.wallet as FiroWallet).balancePrivate.total; totalBalance + (manager.wallet as FiroWallet).balancePrivate.total;
} }
unit = manager.coin.ticker; contract = null;
decimals = manager.coin.decimals;
} else { } else {
final ethWallet = manager.wallet as EthereumWallet; final ethWallet = manager.wallet as EthereumWallet;
final contract = MainDB.instance.getEthContractSync(contractAddress!)!; contract = MainDB.instance.getEthContractSync(contractAddress!)!;
totalBalance = ethWallet.getCachedTokenBalance(contract).total; totalBalance = ethWallet.getCachedTokenBalance(contract).total;
unit = contract.symbol;
decimals = contract.decimals;
} }
return Text( return Text(
"${totalBalance.localizedStringAsFixed( ref
locale: locale, .watch(pAmountFormatter(manager.coin))
decimalPlaces: decimals, .format(totalBalance, ethContract: contract),
)} $unit",
style: Util.isDesktop style: Util.isDesktop
? STextStyles.desktopTextExtraSmall(context).copyWith( ? STextStyles.desktopTextExtraSmall(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textSubtitle1, color: Theme.of(context).extension<StackColors>()!.textSubtitle1,

View file

@ -11,7 +11,7 @@ description: Stack Wallet
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.7.10+174 version: 1.7.11+176
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"

View file

@ -126,12 +126,8 @@ void main() {
).thenThrow(Exception()); ).thenThrow(Exception());
final cachedClient = CachedElectrumX( final cachedClient = CachedElectrumX(
electrumXClient: client, electrumXClient: client,
port: 0, );
failovers: [],
server: '',
useSSL: true,
prefs: Prefs.instance);
expect( expect(
() async => await cachedClient.getTransaction( () async => await cachedClient.getTransaction(
@ -143,12 +139,8 @@ void main() {
test("clearSharedTransactionCache", () async { test("clearSharedTransactionCache", () async {
final cachedClient = CachedElectrumX( final cachedClient = CachedElectrumX(
server: '', electrumXClient: MockElectrumX(),
electrumXClient: MockElectrumX(), );
port: 0,
useSSL: true,
prefs: MockPrefs(),
failovers: []);
bool didThrow = false; bool didThrow = false;
try { try {
@ -174,11 +166,7 @@ void main() {
useSSL: true, useSSL: true,
); );
final client = CachedElectrumX.from( final client = CachedElectrumX.from(electrumXClient: MockElectrumX());
node: node,
prefs: MockPrefs(),
failovers: [],
electrumXClient: MockElectrumX());
expect(client, isA<CachedElectrumX>()); expect(client, isA<CachedElectrumX>());
}); });

View file

@ -57,16 +57,18 @@ void main() {
const jsonArgs = '["",true]'; const jsonArgs = '["",true]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"error": { "error": {
"code": 1, "code": 1,
"message": "None should be a transaction hash", "message": "None should be a transaction hash",
}, },
"id": "some requestId", "id": "some requestId",
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -93,13 +95,15 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": {"height": 520481, "hex": "some block hex string"}, "result": {"height": 520481, "hex": "some block hex string"},
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -126,7 +130,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -153,9 +159,15 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => {"jsonrpc": "2.0", "result": null, "id": "some requestId"}, (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0",
"result": null,
"id": "some requestId",
}),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -181,7 +193,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -208,9 +222,11 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": { "result": {
"genesis_hash": "genesis_hash":
@ -225,7 +241,7 @@ void main() {
"hash_function": "sha256" "hash_function": "sha256"
}, },
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -263,7 +279,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -290,13 +308,15 @@ void main() {
const jsonArgs = '["some raw transaction string"]'; const jsonArgs = '["some raw transaction string"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": "the txid of the rawtx", "result": "the txid of the rawtx",
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -323,7 +343,9 @@ void main() {
const jsonArgs = '["some raw transaction string"]'; const jsonArgs = '["some raw transaction string"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -353,16 +375,18 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": { "result": {
"confirmed": 103873966, "confirmed": 103873966,
"unconfirmed": 23684400, "unconfirmed": 23684400,
}, },
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -389,7 +413,9 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -418,9 +444,11 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": [ "result": [
{ {
@ -435,7 +463,7 @@ void main() {
} }
], ],
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -473,7 +501,9 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -502,9 +532,11 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": [ "result": [
{ {
@ -523,7 +555,7 @@ void main() {
} }
], ],
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -565,7 +597,9 @@ void main() {
const jsonArgs = '["dummy hash"]'; const jsonArgs = '["dummy hash"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -594,13 +628,15 @@ void main() {
const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": SampleGetTransactionData.txData0, "result": SampleGetTransactionData.txData0,
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -629,7 +665,9 @@ void main() {
const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]'; const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -659,13 +697,15 @@ void main() {
const jsonArgs = '["1",""]'; const jsonArgs = '["1",""]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": GetAnonymitySetSampleData.data, "result": GetAnonymitySetSampleData.data,
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -692,7 +732,9 @@ void main() {
const jsonArgs = '["1",""]'; const jsonArgs = '["1",""]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -721,13 +763,15 @@ void main() {
const jsonArgs = '["some mints"]'; const jsonArgs = '["some mints"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": "mint meta data", "result": "mint meta data",
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -754,7 +798,9 @@ void main() {
const jsonArgs = '["some mints"]'; const jsonArgs = '["some mints"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -783,13 +829,15 @@ void main() {
const jsonArgs = '["0"]'; const jsonArgs = '["0"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": GetUsedSerialsSampleData.serials, "result": GetUsedSerialsSampleData.serials,
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -816,7 +864,9 @@ void main() {
const jsonArgs = '["0"]'; const jsonArgs = '["0"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -845,9 +895,15 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => {"jsonrpc": "2.0", "result": 1, "id": "some requestId"}, (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0",
"result": 1,
"id": "some requestId",
}),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -873,7 +929,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -886,7 +944,10 @@ void main() {
prefs: mockPrefs, prefs: mockPrefs,
failovers: []); failovers: []);
expect(() => client.getLatestCoinId(requestID: "some requestId"), expect(
() => client.getLatestCoinId(
requestID: "some requestId",
),
throwsA(isA<Exception>())); throwsA(isA<Exception>()));
verify(mockPrefs.wifiOnly).called(1); verify(mockPrefs.wifiOnly).called(1);
verifyNoMoreInteractions(mockPrefs); verifyNoMoreInteractions(mockPrefs);
@ -900,13 +961,15 @@ void main() {
const jsonArgs = '["1",""]'; const jsonArgs = '["1",""]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": GetAnonymitySetSampleData.data, "result": GetAnonymitySetSampleData.data,
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -933,7 +996,9 @@ void main() {
const jsonArgs = '["1",""]'; const jsonArgs = '["1",""]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -947,8 +1012,10 @@ void main() {
failovers: []); failovers: []);
expect( expect(
() => () => client.getAnonymitySet(
client.getAnonymitySet(groupId: "1", requestID: "some requestId"), groupId: "1",
requestID: "some requestId",
),
throwsA(isA<Exception>())); throwsA(isA<Exception>()));
verify(mockPrefs.wifiOnly).called(1); verify(mockPrefs.wifiOnly).called(1);
verifyNoMoreInteractions(mockPrefs); verifyNoMoreInteractions(mockPrefs);
@ -962,13 +1029,15 @@ void main() {
const jsonArgs = '["some mints"]'; const jsonArgs = '["some mints"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": "mint meta data", "result": "mint meta data",
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -995,7 +1064,9 @@ void main() {
const jsonArgs = '["some mints"]'; const jsonArgs = '["some mints"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1010,7 +1081,9 @@ void main() {
expect( expect(
() => client.getMintData( () => client.getMintData(
mints: "some mints", requestID: "some requestId"), mints: "some mints",
requestID: "some requestId",
),
throwsA(isA<Exception>())); throwsA(isA<Exception>()));
verify(mockPrefs.wifiOnly).called(1); verify(mockPrefs.wifiOnly).called(1);
verifyNoMoreInteractions(mockPrefs); verifyNoMoreInteractions(mockPrefs);
@ -1024,13 +1097,15 @@ void main() {
const jsonArgs = '["0"]'; const jsonArgs = '["0"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": GetUsedSerialsSampleData.serials, "result": GetUsedSerialsSampleData.serials,
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1057,7 +1132,9 @@ void main() {
const jsonArgs = '["0"]'; const jsonArgs = '["0"]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1086,9 +1163,15 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => {"jsonrpc": "2.0", "result": 1, "id": "some requestId"}, (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0",
"result": 1,
"id": "some requestId",
}),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1114,7 +1197,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1141,15 +1226,17 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenAnswer( ).thenAnswer(
(_) async => { (_) async => JsonRPCResponse(data: {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"result": { "result": {
"rate": 1000, "rate": 1000,
}, },
"id": "some requestId" "id": "some requestId"
}, }),
); );
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();
@ -1175,7 +1262,9 @@ void main() {
const jsonArgs = '[]'; const jsonArgs = '[]';
when( when(
mockClient.request( mockClient.request(
'{"jsonrpc": "2.0", "id": "some requestId","method": "$command","params": $jsonArgs}'), '{"jsonrpc": "2.0", "id": "some requestId",'
'"method": "$command","params": $jsonArgs}',
),
).thenThrow(Exception()); ).thenThrow(Exception());
final mockPrefs = MockPrefs(); final mockPrefs = MockPrefs();

View file

@ -33,6 +33,17 @@ class _FakeDuration_0 extends _i1.SmartFake implements Duration {
); );
} }
class _FakeJsonRPCResponse_1 extends _i1.SmartFake
implements _i2.JsonRPCResponse {
_FakeJsonRPCResponse_1(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
/// A class which mocks [JsonRPC]. /// A class which mocks [JsonRPC].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
@ -47,40 +58,16 @@ class MockJsonRPC extends _i1.Mock implements _i2.JsonRPC {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
set useSSL(bool? _useSSL) => super.noSuchMethod(
Invocation.setter(
#useSSL,
_useSSL,
),
returnValueForMissingStub: null,
);
@override
String get host => (super.noSuchMethod( String get host => (super.noSuchMethod(
Invocation.getter(#host), Invocation.getter(#host),
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
set host(String? _host) => super.noSuchMethod(
Invocation.setter(
#host,
_host,
),
returnValueForMissingStub: null,
);
@override
int get port => (super.noSuchMethod( int get port => (super.noSuchMethod(
Invocation.getter(#port), Invocation.getter(#port),
returnValue: 0, returnValue: 0,
) as int); ) as int);
@override @override
set port(int? _port) => super.noSuchMethod(
Invocation.setter(
#port,
_port,
),
returnValueForMissingStub: null,
);
@override
Duration get connectionTimeout => (super.noSuchMethod( Duration get connectionTimeout => (super.noSuchMethod(
Invocation.getter(#connectionTimeout), Invocation.getter(#connectionTimeout),
returnValue: _FakeDuration_0( returnValue: _FakeDuration_0(
@ -89,21 +76,40 @@ class MockJsonRPC extends _i1.Mock implements _i2.JsonRPC {
), ),
) as Duration); ) as Duration);
@override @override
set connectionTimeout(Duration? _connectionTimeout) => super.noSuchMethod( _i3.Future<_i2.JsonRPCResponse> request(String? jsonRpcRequest) =>
Invocation.setter( (super.noSuchMethod(
#connectionTimeout,
_connectionTimeout,
),
returnValueForMissingStub: null,
);
@override
_i3.Future<dynamic> request(String? jsonRpcRequest) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#request, #request,
[jsonRpcRequest], [jsonRpcRequest],
), ),
returnValue: _i3.Future<dynamic>.value(), returnValue:
) as _i3.Future<dynamic>); _i3.Future<_i2.JsonRPCResponse>.value(_FakeJsonRPCResponse_1(
this,
Invocation.method(
#request,
[jsonRpcRequest],
),
)),
) as _i3.Future<_i2.JsonRPCResponse>);
@override
_i3.Future<void> disconnect({required String? reason}) => (super.noSuchMethod(
Invocation.method(
#disconnect,
[],
{#reason: reason},
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Future<void> connect() => (super.noSuchMethod(
Invocation.method(
#connect,
[],
),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
} }
/// A class which mocks [Prefs]. /// A class which mocks [Prefs].

View file

@ -17,7 +17,7 @@ void main() {
'{"jsonrpc": "2.0", "id": "some id","method": "server.ping","params": []}'; '{"jsonrpc": "2.0", "id": "some id","method": "server.ping","params": []}';
final result = await jsonRPC.request(jsonRequestString); final result = await jsonRPC.request(jsonRequestString);
expect(result, {"jsonrpc": "2.0", "result": null, "id": "some id"}); expect(result.data, {"jsonrpc": "2.0", "result": null, "id": "some id"});
}); });
test("JsonRPC.request fails due to SocketException", () async { test("JsonRPC.request fails due to SocketException", () async {

View file

@ -143,7 +143,7 @@ void main() {
] ]
}); });
expect(txChunk.toString(), expect(txChunk.toString(),
"timestamp: 993260735 transactions: [\n {txid: txid, type: txType, subType: mint, value: 10, fee: 1, height: 1, confirm: true, confirmations: 1, address: address, timestamp: 1876352482, worthNow: 1, inputs: [], slateid: slateId } \n]"); "timestamp: 993260735 transactions: [\n {txid: txid, type: txType, subType: mint, value: 10, fee: 1, height: 1, confirm: true, confirmations: 1, address: address, timestamp: 1876352482, worthNow: 1, inputs: [], slateid: slateId, numberOfMessages: null } \n]");
}); });
}); });

View file

@ -3,24 +3,23 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i9; import 'dart:async' as _i8;
import 'dart:ui' as _i15; import 'dart:ui' as _i14;
import 'package:local_auth/auth_strings.dart' as _i12; import 'package:local_auth/auth_strings.dart' as _i11;
import 'package:local_auth/local_auth.dart' as _i11; import 'package:local_auth/local_auth.dart' as _i10;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i7;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i8; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i2;
import 'package:stackwallet/models/balance.dart' as _i5; import 'package:stackwallet/models/balance.dart' as _i5;
import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16;
import 'package:stackwallet/models/models.dart' as _i4; import 'package:stackwallet/models/models.dart' as _i4;
import 'package:stackwallet/services/coins/coin_service.dart' as _i3; import 'package:stackwallet/services/coins/coin_service.dart' as _i3;
import 'package:stackwallet/services/coins/manager.dart' as _i16; import 'package:stackwallet/services/coins/manager.dart' as _i15;
import 'package:stackwallet/services/wallets_service.dart' as _i14; import 'package:stackwallet/services/wallets_service.dart' as _i13;
import 'package:stackwallet/utilities/amount/amount.dart' as _i6; import 'package:stackwallet/utilities/amount/amount.dart' as _i6;
import 'package:stackwallet/utilities/biometrics.dart' as _i13; import 'package:stackwallet/utilities/biometrics.dart' as _i12;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9;
import 'package:stackwallet/utilities/prefs.dart' as _i2;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -33,8 +32,8 @@ import 'package:stackwallet/utilities/prefs.dart' as _i2;
// ignore_for_file: camel_case_types // ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class // ignore_for_file: subtype_of_sealed_class
class _FakePrefs_0 extends _i1.SmartFake implements _i2.Prefs { class _FakeElectrumX_0 extends _i1.SmartFake implements _i2.ElectrumX {
_FakePrefs_0( _FakeElectrumX_0(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -93,38 +92,18 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
} }
@override @override
String get server => (super.noSuchMethod( _i2.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_0(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i2.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_0(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i2.Prefs); ) as _i2.ElectrumX);
@override @override
List<_i8.ElectrumXNode> get failovers => (super.noSuchMethod( _i8.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i8.ElectrumXNode>[],
) as List<_i8.ElectrumXNode>);
@override
_i9.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i10.Coin? coin, required _i9.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -137,8 +116,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i9.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i8.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i9.Future<Map<String, dynamic>>); ) as _i8.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -156,9 +135,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i9.Future<Map<String, dynamic>> getTransaction({ _i8.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i10.Coin? coin, required _i9.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -172,11 +151,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i9.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i8.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i9.Future<Map<String, dynamic>>); ) as _i8.Future<Map<String, dynamic>>);
@override @override
_i9.Future<List<String>> getUsedCoinSerials({ _i8.Future<List<String>> getUsedCoinSerials({
required _i10.Coin? coin, required _i9.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -188,43 +167,43 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i9.Future<List<String>>.value(<String>[]), returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i9.Future<List<String>>); ) as _i8.Future<List<String>>);
@override @override
_i9.Future<void> clearSharedTransactionCache({required _i10.Coin? coin}) => _i8.Future<void> clearSharedTransactionCache({required _i9.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
} }
/// A class which mocks [LocalAuthentication]. /// A class which mocks [LocalAuthentication].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockLocalAuthentication extends _i1.Mock class MockLocalAuthentication extends _i1.Mock
implements _i11.LocalAuthentication { implements _i10.LocalAuthentication {
MockLocalAuthentication() { MockLocalAuthentication() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
_i9.Future<bool> get canCheckBiometrics => (super.noSuchMethod( _i8.Future<bool> get canCheckBiometrics => (super.noSuchMethod(
Invocation.getter(#canCheckBiometrics), Invocation.getter(#canCheckBiometrics),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<bool> authenticateWithBiometrics({ _i8.Future<bool> authenticateWithBiometrics({
required String? localizedReason, required String? localizedReason,
bool? useErrorDialogs = true, bool? useErrorDialogs = true,
bool? stickyAuth = false, bool? stickyAuth = false,
_i12.AndroidAuthMessages? androidAuthStrings = _i11.AndroidAuthMessages? androidAuthStrings =
const _i12.AndroidAuthMessages(), const _i11.AndroidAuthMessages(),
_i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(),
bool? sensitiveTransaction = true, bool? sensitiveTransaction = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -240,16 +219,16 @@ class MockLocalAuthentication extends _i1.Mock
#sensitiveTransaction: sensitiveTransaction, #sensitiveTransaction: sensitiveTransaction,
}, },
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<bool> authenticate({ _i8.Future<bool> authenticate({
required String? localizedReason, required String? localizedReason,
bool? useErrorDialogs = true, bool? useErrorDialogs = true,
bool? stickyAuth = false, bool? stickyAuth = false,
_i12.AndroidAuthMessages? androidAuthStrings = _i11.AndroidAuthMessages? androidAuthStrings =
const _i12.AndroidAuthMessages(), const _i11.AndroidAuthMessages(),
_i12.IOSAuthMessages? iOSAuthStrings = const _i12.IOSAuthMessages(), _i11.IOSAuthMessages? iOSAuthStrings = const _i11.IOSAuthMessages(),
bool? sensitiveTransaction = true, bool? sensitiveTransaction = true,
bool? biometricOnly = false, bool? biometricOnly = false,
}) => }) =>
@ -267,46 +246,46 @@ class MockLocalAuthentication extends _i1.Mock
#biometricOnly: biometricOnly, #biometricOnly: biometricOnly,
}, },
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<bool> stopAuthentication() => (super.noSuchMethod( _i8.Future<bool> stopAuthentication() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#stopAuthentication, #stopAuthentication,
[], [],
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<bool> isDeviceSupported() => (super.noSuchMethod( _i8.Future<bool> isDeviceSupported() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#isDeviceSupported, #isDeviceSupported,
[], [],
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<List<_i11.BiometricType>> getAvailableBiometrics() => _i8.Future<List<_i10.BiometricType>> getAvailableBiometrics() =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getAvailableBiometrics, #getAvailableBiometrics,
[], [],
), ),
returnValue: returnValue:
_i9.Future<List<_i11.BiometricType>>.value(<_i11.BiometricType>[]), _i8.Future<List<_i10.BiometricType>>.value(<_i10.BiometricType>[]),
) as _i9.Future<List<_i11.BiometricType>>); ) as _i8.Future<List<_i10.BiometricType>>);
} }
/// A class which mocks [Biometrics]. /// A class which mocks [Biometrics].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockBiometrics extends _i1.Mock implements _i13.Biometrics { class MockBiometrics extends _i1.Mock implements _i12.Biometrics {
MockBiometrics() { MockBiometrics() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
_i9.Future<bool> authenticate({ _i8.Future<bool> authenticate({
required String? cancelButtonText, required String? cancelButtonText,
required String? localizedReason, required String? localizedReason,
required String? title, required String? title,
@ -321,28 +300,28 @@ class MockBiometrics extends _i1.Mock implements _i13.Biometrics {
#title: title, #title: title,
}, },
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
} }
/// A class which mocks [WalletsService]. /// A class which mocks [WalletsService].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockWalletsService extends _i1.Mock implements _i14.WalletsService { class MockWalletsService extends _i1.Mock implements _i13.WalletsService {
@override @override
_i9.Future<Map<String, _i14.WalletInfo>> get walletNames => _i8.Future<Map<String, _i13.WalletInfo>> get walletNames =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.getter(#walletNames), Invocation.getter(#walletNames),
returnValue: _i9.Future<Map<String, _i14.WalletInfo>>.value( returnValue: _i8.Future<Map<String, _i13.WalletInfo>>.value(
<String, _i14.WalletInfo>{}), <String, _i13.WalletInfo>{}),
) as _i9.Future<Map<String, _i14.WalletInfo>>); ) as _i8.Future<Map<String, _i13.WalletInfo>>);
@override @override
bool get hasListeners => (super.noSuchMethod( bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners), Invocation.getter(#hasListeners),
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i9.Future<bool> renameWallet({ _i8.Future<bool> renameWallet({
required String? from, required String? from,
required String? to, required String? to,
required bool? shouldNotifyListeners, required bool? shouldNotifyListeners,
@ -357,21 +336,21 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
#shouldNotifyListeners: shouldNotifyListeners, #shouldNotifyListeners: shouldNotifyListeners,
}, },
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
Map<String, _i14.WalletInfo> fetchWalletsData() => (super.noSuchMethod( Map<String, _i13.WalletInfo> fetchWalletsData() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#fetchWalletsData, #fetchWalletsData,
[], [],
), ),
returnValue: <String, _i14.WalletInfo>{}, returnValue: <String, _i13.WalletInfo>{},
) as Map<String, _i14.WalletInfo>); ) as Map<String, _i13.WalletInfo>);
@override @override
_i9.Future<void> addExistingStackWallet({ _i8.Future<void> addExistingStackWallet({
required String? name, required String? name,
required String? walletId, required String? walletId,
required _i10.Coin? coin, required _i9.Coin? coin,
required bool? shouldNotifyListeners, required bool? shouldNotifyListeners,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -385,13 +364,13 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
#shouldNotifyListeners: shouldNotifyListeners, #shouldNotifyListeners: shouldNotifyListeners,
}, },
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<String?> addNewWallet({ _i8.Future<String?> addNewWallet({
required String? name, required String? name,
required _i10.Coin? coin, required _i9.Coin? coin,
required bool? shouldNotifyListeners, required bool? shouldNotifyListeners,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -404,46 +383,46 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
#shouldNotifyListeners: shouldNotifyListeners, #shouldNotifyListeners: shouldNotifyListeners,
}, },
), ),
returnValue: _i9.Future<String?>.value(), returnValue: _i8.Future<String?>.value(),
) as _i9.Future<String?>); ) as _i8.Future<String?>);
@override @override
_i9.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod( _i8.Future<List<String>> getFavoriteWalletIds() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFavoriteWalletIds, #getFavoriteWalletIds,
[], [],
), ),
returnValue: _i9.Future<List<String>>.value(<String>[]), returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i9.Future<List<String>>); ) as _i8.Future<List<String>>);
@override @override
_i9.Future<void> saveFavoriteWalletIds(List<String>? walletIds) => _i8.Future<void> saveFavoriteWalletIds(List<String>? walletIds) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#saveFavoriteWalletIds, #saveFavoriteWalletIds,
[walletIds], [walletIds],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> addFavorite(String? walletId) => (super.noSuchMethod( _i8.Future<void> addFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addFavorite, #addFavorite,
[walletId], [walletId],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod( _i8.Future<void> removeFavorite(String? walletId) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#removeFavorite, #removeFavorite,
[walletId], [walletId],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> moveFavorite({ _i8.Future<void> moveFavorite({
required int? fromIndex, required int? fromIndex,
required int? toIndex, required int? toIndex,
}) => }) =>
@ -456,48 +435,48 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
#toIndex: toIndex, #toIndex: toIndex,
}, },
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod( _i8.Future<bool> checkForDuplicate(String? name) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#checkForDuplicate, #checkForDuplicate,
[name], [name],
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod( _i8.Future<String?> getWalletId(String? walletName) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getWalletId, #getWalletId,
[walletName], [walletName],
), ),
returnValue: _i9.Future<String?>.value(), returnValue: _i8.Future<String?>.value(),
) as _i9.Future<String?>); ) as _i8.Future<String?>);
@override @override
_i9.Future<bool> isMnemonicVerified({required String? walletId}) => _i8.Future<bool> isMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#isMnemonicVerified, #isMnemonicVerified,
[], [],
{#walletId: walletId}, {#walletId: walletId},
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<void> setMnemonicVerified({required String? walletId}) => _i8.Future<void> setMnemonicVerified({required String? walletId}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#setMnemonicVerified, #setMnemonicVerified,
[], [],
{#walletId: walletId}, {#walletId: walletId},
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<int> deleteWallet( _i8.Future<int> deleteWallet(
String? name, String? name,
bool? shouldNotifyListeners, bool? shouldNotifyListeners,
) => ) =>
@ -509,20 +488,20 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
shouldNotifyListeners, shouldNotifyListeners,
], ],
), ),
returnValue: _i9.Future<int>.value(0), returnValue: _i8.Future<int>.value(0),
) as _i9.Future<int>); ) as _i8.Future<int>);
@override @override
_i9.Future<void> refreshWallets(bool? shouldNotifyListeners) => _i8.Future<void> refreshWallets(bool? shouldNotifyListeners) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#refreshWallets, #refreshWallets,
[shouldNotifyListeners], [shouldNotifyListeners],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#addListener, #addListener,
[listener], [listener],
@ -530,7 +509,7 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
returnValueForMissingStub: null, returnValueForMissingStub: null,
); );
@override @override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#removeListener, #removeListener,
[listener], [listener],
@ -558,7 +537,7 @@ class MockWalletsService extends _i1.Mock implements _i14.WalletsService {
/// A class which mocks [Manager]. /// A class which mocks [Manager].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockManager extends _i1.Mock implements _i16.Manager { class MockManager extends _i1.Mock implements _i15.Manager {
@override @override
bool get isActiveWallet => (super.noSuchMethod( bool get isActiveWallet => (super.noSuchMethod(
Invocation.getter(#isActiveWallet), Invocation.getter(#isActiveWallet),
@ -586,10 +565,10 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i10.Coin get coin => (super.noSuchMethod( _i9.Coin get coin => (super.noSuchMethod(
Invocation.getter(#coin), Invocation.getter(#coin),
returnValue: _i10.Coin.bitcoin, returnValue: _i9.Coin.bitcoin,
) as _i10.Coin); ) as _i9.Coin);
@override @override
bool get isRefreshing => (super.noSuchMethod( bool get isRefreshing => (super.noSuchMethod(
Invocation.getter(#isRefreshing), Invocation.getter(#isRefreshing),
@ -622,23 +601,23 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValueForMissingStub: null, returnValueForMissingStub: null,
); );
@override @override
_i9.Future<_i4.FeeObject> get fees => (super.noSuchMethod( _i8.Future<_i4.FeeObject> get fees => (super.noSuchMethod(
Invocation.getter(#fees), Invocation.getter(#fees),
returnValue: _i9.Future<_i4.FeeObject>.value(_FakeFeeObject_2( returnValue: _i8.Future<_i4.FeeObject>.value(_FakeFeeObject_2(
this, this,
Invocation.getter(#fees), Invocation.getter(#fees),
)), )),
) as _i9.Future<_i4.FeeObject>); ) as _i8.Future<_i4.FeeObject>);
@override @override
_i9.Future<int> get maxFee => (super.noSuchMethod( _i8.Future<int> get maxFee => (super.noSuchMethod(
Invocation.getter(#maxFee), Invocation.getter(#maxFee),
returnValue: _i9.Future<int>.value(0), returnValue: _i8.Future<int>.value(0),
) as _i9.Future<int>); ) as _i8.Future<int>);
@override @override
_i9.Future<String> get currentReceivingAddress => (super.noSuchMethod( _i8.Future<String> get currentReceivingAddress => (super.noSuchMethod(
Invocation.getter(#currentReceivingAddress), Invocation.getter(#currentReceivingAddress),
returnValue: _i9.Future<String>.value(''), returnValue: _i8.Future<String>.value(''),
) as _i9.Future<String>); ) as _i8.Future<String>);
@override @override
_i5.Balance get balance => (super.noSuchMethod( _i5.Balance get balance => (super.noSuchMethod(
Invocation.getter(#balance), Invocation.getter(#balance),
@ -648,16 +627,16 @@ class MockManager extends _i1.Mock implements _i16.Manager {
), ),
) as _i5.Balance); ) as _i5.Balance);
@override @override
_i9.Future<List<_i17.Transaction>> get transactions => (super.noSuchMethod( _i8.Future<List<_i16.Transaction>> get transactions => (super.noSuchMethod(
Invocation.getter(#transactions), Invocation.getter(#transactions),
returnValue: returnValue:
_i9.Future<List<_i17.Transaction>>.value(<_i17.Transaction>[]), _i8.Future<List<_i16.Transaction>>.value(<_i16.Transaction>[]),
) as _i9.Future<List<_i17.Transaction>>); ) as _i8.Future<List<_i16.Transaction>>);
@override @override
_i9.Future<List<_i17.UTXO>> get utxos => (super.noSuchMethod( _i8.Future<List<_i16.UTXO>> get utxos => (super.noSuchMethod(
Invocation.getter(#utxos), Invocation.getter(#utxos),
returnValue: _i9.Future<List<_i17.UTXO>>.value(<_i17.UTXO>[]), returnValue: _i8.Future<List<_i16.UTXO>>.value(<_i16.UTXO>[]),
) as _i9.Future<List<_i17.UTXO>>); ) as _i8.Future<List<_i16.UTXO>>);
@override @override
set walletName(String? newName) => super.noSuchMethod( set walletName(String? newName) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
@ -677,15 +656,15 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i9.Future<List<String>> get mnemonic => (super.noSuchMethod( _i8.Future<List<String>> get mnemonic => (super.noSuchMethod(
Invocation.getter(#mnemonic), Invocation.getter(#mnemonic),
returnValue: _i9.Future<List<String>>.value(<String>[]), returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i9.Future<List<String>>); ) as _i8.Future<List<String>>);
@override @override
_i9.Future<String?> get mnemonicPassphrase => (super.noSuchMethod( _i8.Future<String?> get mnemonicPassphrase => (super.noSuchMethod(
Invocation.getter(#mnemonicPassphrase), Invocation.getter(#mnemonicPassphrase),
returnValue: _i9.Future<String?>.value(), returnValue: _i8.Future<String?>.value(),
) as _i9.Future<String?>); ) as _i8.Future<String?>);
@override @override
bool get isConnected => (super.noSuchMethod( bool get isConnected => (super.noSuchMethod(
Invocation.getter(#isConnected), Invocation.getter(#isConnected),
@ -727,24 +706,24 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i9.Future<String> get xpub => (super.noSuchMethod( _i8.Future<String> get xpub => (super.noSuchMethod(
Invocation.getter(#xpub), Invocation.getter(#xpub),
returnValue: _i9.Future<String>.value(''), returnValue: _i8.Future<String>.value(''),
) as _i9.Future<String>); ) as _i8.Future<String>);
@override @override
bool get hasListeners => (super.noSuchMethod( bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners), Invocation.getter(#hasListeners),
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i9.Future<void> updateNode(bool? shouldRefresh) => (super.noSuchMethod( _i8.Future<void> updateNode(bool? shouldRefresh) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#updateNode, #updateNode,
[shouldRefresh], [shouldRefresh],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
void dispose() => super.noSuchMethod( void dispose() => super.noSuchMethod(
Invocation.method( Invocation.method(
@ -754,7 +733,7 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValueForMissingStub: null, returnValueForMissingStub: null,
); );
@override @override
_i9.Future<Map<String, dynamic>> prepareSend({ _i8.Future<Map<String, dynamic>> prepareSend({
required String? address, required String? address,
required _i6.Amount? amount, required _i6.Amount? amount,
Map<String, dynamic>? args, Map<String, dynamic>? args,
@ -770,27 +749,27 @@ class MockManager extends _i1.Mock implements _i16.Manager {
}, },
), ),
returnValue: returnValue:
_i9.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i8.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i9.Future<Map<String, dynamic>>); ) as _i8.Future<Map<String, dynamic>>);
@override @override
_i9.Future<String> confirmSend({required Map<String, dynamic>? txData}) => _i8.Future<String> confirmSend({required Map<String, dynamic>? txData}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#confirmSend, #confirmSend,
[], [],
{#txData: txData}, {#txData: txData},
), ),
returnValue: _i9.Future<String>.value(''), returnValue: _i8.Future<String>.value(''),
) as _i9.Future<String>); ) as _i8.Future<String>);
@override @override
_i9.Future<void> refresh() => (super.noSuchMethod( _i8.Future<void> refresh() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#refresh, #refresh,
[], [],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
bool validateAddress(String? address) => (super.noSuchMethod( bool validateAddress(String? address) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -800,33 +779,33 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i9.Future<bool> testNetworkConnection() => (super.noSuchMethod( _i8.Future<bool> testNetworkConnection() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#testNetworkConnection, #testNetworkConnection,
[], [],
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<void> initializeNew() => (super.noSuchMethod( _i8.Future<void> initializeNew() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#initializeNew, #initializeNew,
[], [],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> initializeExisting() => (super.noSuchMethod( _i8.Future<void> initializeExisting() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#initializeExisting, #initializeExisting,
[], [],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> recoverFromMnemonic({ _i8.Future<void> recoverFromMnemonic({
required String? mnemonic, required String? mnemonic,
String? mnemonicPassphrase, String? mnemonicPassphrase,
required int? maxUnusedAddressGap, required int? maxUnusedAddressGap,
@ -845,20 +824,20 @@ class MockManager extends _i1.Mock implements _i16.Manager {
#height: height, #height: height,
}, },
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> exitCurrentWallet() => (super.noSuchMethod( _i8.Future<void> exitCurrentWallet() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#exitCurrentWallet, #exitCurrentWallet,
[], [],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<void> fullRescan( _i8.Future<void> fullRescan(
int? maxUnusedAddressGap, int? maxUnusedAddressGap,
int? maxNumberOfIndexesToCheck, int? maxNumberOfIndexesToCheck,
) => ) =>
@ -870,11 +849,11 @@ class MockManager extends _i1.Mock implements _i16.Manager {
maxNumberOfIndexesToCheck, maxNumberOfIndexesToCheck,
], ],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
_i9.Future<_i6.Amount> estimateFeeFor( _i8.Future<_i6.Amount> estimateFeeFor(
_i6.Amount? amount, _i6.Amount? amount,
int? feeRate, int? feeRate,
) => ) =>
@ -886,7 +865,7 @@ class MockManager extends _i1.Mock implements _i16.Manager {
feeRate, feeRate,
], ],
), ),
returnValue: _i9.Future<_i6.Amount>.value(_FakeAmount_4( returnValue: _i8.Future<_i6.Amount>.value(_FakeAmount_4(
this, this,
Invocation.method( Invocation.method(
#estimateFeeFor, #estimateFeeFor,
@ -896,26 +875,26 @@ class MockManager extends _i1.Mock implements _i16.Manager {
], ],
), ),
)), )),
) as _i9.Future<_i6.Amount>); ) as _i8.Future<_i6.Amount>);
@override @override
_i9.Future<bool> generateNewAddress() => (super.noSuchMethod( _i8.Future<bool> generateNewAddress() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#generateNewAddress, #generateNewAddress,
[], [],
), ),
returnValue: _i9.Future<bool>.value(false), returnValue: _i8.Future<bool>.value(false),
) as _i9.Future<bool>); ) as _i8.Future<bool>);
@override @override
_i9.Future<void> resetRescanOnOpen() => (super.noSuchMethod( _i8.Future<void> resetRescanOnOpen() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#resetRescanOnOpen, #resetRescanOnOpen,
[], [],
), ),
returnValue: _i9.Future<void>.value(), returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(), returnValueForMissingStub: _i8.Future<void>.value(),
) as _i9.Future<void>); ) as _i8.Future<void>);
@override @override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#addListener, #addListener,
[listener], [listener],
@ -923,7 +902,7 @@ class MockManager extends _i1.Mock implements _i16.Manager {
returnValueForMissingStub: null, returnValueForMissingStub: null,
); );
@override @override
void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#removeListener, #removeListener,
[listener], [listener],

View file

@ -3,16 +3,15 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5; import 'dart:async' as _i4;
import 'package:decimal/decimal.dart' as _i2; import 'package:decimal/decimal.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i3;
import 'package:stackwallet/services/transaction_notification_tracker.dart' import 'package:stackwallet/services/transaction_notification_tracker.dart'
as _i8; as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i3;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -35,8 +34,8 @@ class _FakeDecimal_0 extends _i1.SmartFake implements _i2.Decimal {
); );
} }
class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { class _FakeElectrumX_1 extends _i1.SmartFake implements _i3.ElectrumX {
_FakePrefs_1( _FakeElectrumX_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -48,13 +47,13 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs {
/// A class which mocks [ElectrumX]. /// A class which mocks [ElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { class MockElectrumX extends _i1.Mock implements _i3.ElectrumX {
MockElectrumX() { MockElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( set failovers(List<_i3.ElectrumXNode>? _failovers) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
#failovers, #failovers,
_failovers, _failovers,
@ -90,7 +89,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<dynamic> request({ _i4.Future<dynamic> request({
required String? command, required String? command,
List<dynamic>? args = const [], List<dynamic>? args = const [],
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -109,10 +108,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<List<Map<String, dynamic>>> batchRequest({ _i4.Future<List<Map<String, dynamic>>> batchRequest({
required String? command, required String? command,
required Map<String, List<dynamic>>? args, required Map<String, List<dynamic>>? args,
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -129,11 +128,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<bool> ping({ _i4.Future<bool> ping({
String? requestID, String? requestID,
int? retryCount = 1, int? retryCount = 1,
}) => }) =>
@ -146,10 +145,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retryCount: retryCount, #retryCount: retryCount,
}, },
), ),
returnValue: _i5.Future<bool>.value(false), returnValue: _i4.Future<bool>.value(false),
) as _i5.Future<bool>); ) as _i4.Future<bool>);
@override @override
_i5.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) => _i4.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getBlockHeadTip, #getBlockHeadTip,
@ -157,10 +156,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) => _i4.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getServerFeatures, #getServerFeatures,
@ -168,10 +167,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<String> broadcastTransaction({ _i4.Future<String> broadcastTransaction({
required String? rawTx, required String? rawTx,
String? requestID, String? requestID,
}) => }) =>
@ -184,10 +183,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<String>.value(''), returnValue: _i4.Future<String>.value(''),
) as _i5.Future<String>); ) as _i4.Future<String>);
@override @override
_i5.Future<Map<String, dynamic>> getBalance({ _i4.Future<Map<String, dynamic>> getBalance({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -201,10 +200,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getHistory({ _i4.Future<List<Map<String, dynamic>>> getHistory({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -217,11 +216,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -229,11 +228,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getUTXOs({ _i4.Future<List<Map<String, dynamic>>> getUTXOs({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -246,11 +245,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -258,11 +257,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
bool? verbose = true, bool? verbose = true,
String? requestID, String? requestID,
@ -278,10 +277,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getAnonymitySet({ _i4.Future<Map<String, dynamic>> getAnonymitySet({
String? groupId = r'1', String? groupId = r'1',
String? blockhash = r'', String? blockhash = r'',
String? requestID, String? requestID,
@ -297,10 +296,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<dynamic> getMintData({ _i4.Future<dynamic> getMintData({
dynamic mints, dynamic mints,
String? requestID, String? requestID,
}) => }) =>
@ -313,10 +312,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<Map<String, dynamic>> getUsedCoinSerials({ _i4.Future<Map<String, dynamic>> getUsedCoinSerials({
String? requestID, String? requestID,
required int? startNumber, required int? startNumber,
}) => }) =>
@ -330,19 +329,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod( _i4.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getLatestCoinId, #getLatestCoinId,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<int>.value(0), returnValue: _i4.Future<int>.value(0),
) as _i5.Future<int>); ) as _i4.Future<int>);
@override @override
_i5.Future<Map<String, dynamic>> getFeeRate({String? requestID}) => _i4.Future<Map<String, dynamic>> getFeeRate({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFeeRate, #getFeeRate,
@ -350,10 +349,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<_i2.Decimal> estimateFee({ _i4.Future<_i2.Decimal> estimateFee({
String? requestID, String? requestID,
required int? blocks, required int? blocks,
}) => }) =>
@ -366,7 +365,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#blocks: blocks, #blocks: blocks,
}, },
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#estimateFee, #estimateFee,
@ -377,15 +376,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
@override @override
_i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( _i4.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#relayFee, #relayFee,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#relayFee, #relayFee,
@ -393,50 +392,30 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
} }
/// A class which mocks [CachedElectrumX]. /// A class which mocks [CachedElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
MockCachedElectrumX() { MockCachedElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
String get server => (super.noSuchMethod( _i3.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_1(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i3.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_1(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i3.Prefs); ) as _i3.ElectrumX);
@override @override
List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( _i4.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i4.ElectrumXNode>[],
) as List<_i4.ElectrumXNode>);
@override
_i5.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i7.Coin? coin, required _i6.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -449,8 +428,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -468,9 +447,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i7.Coin? coin, required _i6.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -484,11 +463,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<String>> getUsedCoinSerials({ _i4.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin, required _i6.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -500,26 +479,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i5.Future<List<String>>.value(<String>[]), returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>); ) as _i4.Future<List<String>>);
@override @override
_i5.Future<void> clearSharedTransactionCache({required _i7.Coin? coin}) => _i4.Future<void> clearSharedTransactionCache({required _i6.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }
/// A class which mocks [TransactionNotificationTracker]. /// A class which mocks [TransactionNotificationTracker].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockTransactionNotificationTracker extends _i1.Mock class MockTransactionNotificationTracker extends _i1.Mock
implements _i8.TransactionNotificationTracker { implements _i7.TransactionNotificationTracker {
MockTransactionNotificationTracker() { MockTransactionNotificationTracker() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@ -548,14 +527,14 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedPending, #addNotifiedPending,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -565,21 +544,21 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedConfirmed, #addNotifiedConfirmed,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod( _i4.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#deleteTransaction, #deleteTransaction,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }

View file

@ -3,16 +3,15 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5; import 'dart:async' as _i4;
import 'package:decimal/decimal.dart' as _i2; import 'package:decimal/decimal.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i3;
import 'package:stackwallet/services/transaction_notification_tracker.dart' import 'package:stackwallet/services/transaction_notification_tracker.dart'
as _i8; as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i3;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -35,8 +34,8 @@ class _FakeDecimal_0 extends _i1.SmartFake implements _i2.Decimal {
); );
} }
class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { class _FakeElectrumX_1 extends _i1.SmartFake implements _i3.ElectrumX {
_FakePrefs_1( _FakeElectrumX_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -48,13 +47,13 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs {
/// A class which mocks [ElectrumX]. /// A class which mocks [ElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { class MockElectrumX extends _i1.Mock implements _i3.ElectrumX {
MockElectrumX() { MockElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( set failovers(List<_i3.ElectrumXNode>? _failovers) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
#failovers, #failovers,
_failovers, _failovers,
@ -90,7 +89,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<dynamic> request({ _i4.Future<dynamic> request({
required String? command, required String? command,
List<dynamic>? args = const [], List<dynamic>? args = const [],
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -109,10 +108,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<List<Map<String, dynamic>>> batchRequest({ _i4.Future<List<Map<String, dynamic>>> batchRequest({
required String? command, required String? command,
required Map<String, List<dynamic>>? args, required Map<String, List<dynamic>>? args,
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -129,11 +128,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<bool> ping({ _i4.Future<bool> ping({
String? requestID, String? requestID,
int? retryCount = 1, int? retryCount = 1,
}) => }) =>
@ -146,10 +145,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retryCount: retryCount, #retryCount: retryCount,
}, },
), ),
returnValue: _i5.Future<bool>.value(false), returnValue: _i4.Future<bool>.value(false),
) as _i5.Future<bool>); ) as _i4.Future<bool>);
@override @override
_i5.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) => _i4.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getBlockHeadTip, #getBlockHeadTip,
@ -157,10 +156,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) => _i4.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getServerFeatures, #getServerFeatures,
@ -168,10 +167,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<String> broadcastTransaction({ _i4.Future<String> broadcastTransaction({
required String? rawTx, required String? rawTx,
String? requestID, String? requestID,
}) => }) =>
@ -184,10 +183,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<String>.value(''), returnValue: _i4.Future<String>.value(''),
) as _i5.Future<String>); ) as _i4.Future<String>);
@override @override
_i5.Future<Map<String, dynamic>> getBalance({ _i4.Future<Map<String, dynamic>> getBalance({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -201,10 +200,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getHistory({ _i4.Future<List<Map<String, dynamic>>> getHistory({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -217,11 +216,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -229,11 +228,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getUTXOs({ _i4.Future<List<Map<String, dynamic>>> getUTXOs({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -246,11 +245,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -258,11 +257,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
bool? verbose = true, bool? verbose = true,
String? requestID, String? requestID,
@ -278,10 +277,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getAnonymitySet({ _i4.Future<Map<String, dynamic>> getAnonymitySet({
String? groupId = r'1', String? groupId = r'1',
String? blockhash = r'', String? blockhash = r'',
String? requestID, String? requestID,
@ -297,10 +296,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<dynamic> getMintData({ _i4.Future<dynamic> getMintData({
dynamic mints, dynamic mints,
String? requestID, String? requestID,
}) => }) =>
@ -313,10 +312,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<Map<String, dynamic>> getUsedCoinSerials({ _i4.Future<Map<String, dynamic>> getUsedCoinSerials({
String? requestID, String? requestID,
required int? startNumber, required int? startNumber,
}) => }) =>
@ -330,19 +329,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod( _i4.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getLatestCoinId, #getLatestCoinId,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<int>.value(0), returnValue: _i4.Future<int>.value(0),
) as _i5.Future<int>); ) as _i4.Future<int>);
@override @override
_i5.Future<Map<String, dynamic>> getFeeRate({String? requestID}) => _i4.Future<Map<String, dynamic>> getFeeRate({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFeeRate, #getFeeRate,
@ -350,10 +349,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<_i2.Decimal> estimateFee({ _i4.Future<_i2.Decimal> estimateFee({
String? requestID, String? requestID,
required int? blocks, required int? blocks,
}) => }) =>
@ -366,7 +365,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#blocks: blocks, #blocks: blocks,
}, },
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#estimateFee, #estimateFee,
@ -377,15 +376,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
@override @override
_i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( _i4.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#relayFee, #relayFee,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#relayFee, #relayFee,
@ -393,50 +392,30 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
} }
/// A class which mocks [CachedElectrumX]. /// A class which mocks [CachedElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
MockCachedElectrumX() { MockCachedElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
String get server => (super.noSuchMethod( _i3.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_1(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i3.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_1(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i3.Prefs); ) as _i3.ElectrumX);
@override @override
List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( _i4.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i4.ElectrumXNode>[],
) as List<_i4.ElectrumXNode>);
@override
_i5.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i7.Coin? coin, required _i6.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -449,8 +428,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -468,9 +447,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i7.Coin? coin, required _i6.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -484,11 +463,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<String>> getUsedCoinSerials({ _i4.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin, required _i6.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -500,26 +479,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i5.Future<List<String>>.value(<String>[]), returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>); ) as _i4.Future<List<String>>);
@override @override
_i5.Future<void> clearSharedTransactionCache({required _i7.Coin? coin}) => _i4.Future<void> clearSharedTransactionCache({required _i6.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }
/// A class which mocks [TransactionNotificationTracker]. /// A class which mocks [TransactionNotificationTracker].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockTransactionNotificationTracker extends _i1.Mock class MockTransactionNotificationTracker extends _i1.Mock
implements _i8.TransactionNotificationTracker { implements _i7.TransactionNotificationTracker {
MockTransactionNotificationTracker() { MockTransactionNotificationTracker() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@ -548,14 +527,14 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedPending, #addNotifiedPending,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -565,21 +544,21 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedConfirmed, #addNotifiedConfirmed,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod( _i4.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#deleteTransaction, #deleteTransaction,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }

View file

@ -3,16 +3,15 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5; import 'dart:async' as _i4;
import 'package:decimal/decimal.dart' as _i2; import 'package:decimal/decimal.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i3;
import 'package:stackwallet/services/transaction_notification_tracker.dart' import 'package:stackwallet/services/transaction_notification_tracker.dart'
as _i8; as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i3;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -35,8 +34,8 @@ class _FakeDecimal_0 extends _i1.SmartFake implements _i2.Decimal {
); );
} }
class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { class _FakeElectrumX_1 extends _i1.SmartFake implements _i3.ElectrumX {
_FakePrefs_1( _FakeElectrumX_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -48,13 +47,13 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs {
/// A class which mocks [ElectrumX]. /// A class which mocks [ElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { class MockElectrumX extends _i1.Mock implements _i3.ElectrumX {
MockElectrumX() { MockElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( set failovers(List<_i3.ElectrumXNode>? _failovers) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
#failovers, #failovers,
_failovers, _failovers,
@ -90,7 +89,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<dynamic> request({ _i4.Future<dynamic> request({
required String? command, required String? command,
List<dynamic>? args = const [], List<dynamic>? args = const [],
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -109,10 +108,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<List<Map<String, dynamic>>> batchRequest({ _i4.Future<List<Map<String, dynamic>>> batchRequest({
required String? command, required String? command,
required Map<String, List<dynamic>>? args, required Map<String, List<dynamic>>? args,
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -129,11 +128,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<bool> ping({ _i4.Future<bool> ping({
String? requestID, String? requestID,
int? retryCount = 1, int? retryCount = 1,
}) => }) =>
@ -146,10 +145,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retryCount: retryCount, #retryCount: retryCount,
}, },
), ),
returnValue: _i5.Future<bool>.value(false), returnValue: _i4.Future<bool>.value(false),
) as _i5.Future<bool>); ) as _i4.Future<bool>);
@override @override
_i5.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) => _i4.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getBlockHeadTip, #getBlockHeadTip,
@ -157,10 +156,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) => _i4.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getServerFeatures, #getServerFeatures,
@ -168,10 +167,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<String> broadcastTransaction({ _i4.Future<String> broadcastTransaction({
required String? rawTx, required String? rawTx,
String? requestID, String? requestID,
}) => }) =>
@ -184,10 +183,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<String>.value(''), returnValue: _i4.Future<String>.value(''),
) as _i5.Future<String>); ) as _i4.Future<String>);
@override @override
_i5.Future<Map<String, dynamic>> getBalance({ _i4.Future<Map<String, dynamic>> getBalance({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -201,10 +200,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getHistory({ _i4.Future<List<Map<String, dynamic>>> getHistory({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -217,11 +216,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -229,11 +228,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getUTXOs({ _i4.Future<List<Map<String, dynamic>>> getUTXOs({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -246,11 +245,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -258,11 +257,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
bool? verbose = true, bool? verbose = true,
String? requestID, String? requestID,
@ -278,10 +277,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getAnonymitySet({ _i4.Future<Map<String, dynamic>> getAnonymitySet({
String? groupId = r'1', String? groupId = r'1',
String? blockhash = r'', String? blockhash = r'',
String? requestID, String? requestID,
@ -297,10 +296,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<dynamic> getMintData({ _i4.Future<dynamic> getMintData({
dynamic mints, dynamic mints,
String? requestID, String? requestID,
}) => }) =>
@ -313,10 +312,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<Map<String, dynamic>> getUsedCoinSerials({ _i4.Future<Map<String, dynamic>> getUsedCoinSerials({
String? requestID, String? requestID,
required int? startNumber, required int? startNumber,
}) => }) =>
@ -330,19 +329,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod( _i4.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getLatestCoinId, #getLatestCoinId,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<int>.value(0), returnValue: _i4.Future<int>.value(0),
) as _i5.Future<int>); ) as _i4.Future<int>);
@override @override
_i5.Future<Map<String, dynamic>> getFeeRate({String? requestID}) => _i4.Future<Map<String, dynamic>> getFeeRate({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFeeRate, #getFeeRate,
@ -350,10 +349,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<_i2.Decimal> estimateFee({ _i4.Future<_i2.Decimal> estimateFee({
String? requestID, String? requestID,
required int? blocks, required int? blocks,
}) => }) =>
@ -366,7 +365,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#blocks: blocks, #blocks: blocks,
}, },
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#estimateFee, #estimateFee,
@ -377,15 +376,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
@override @override
_i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( _i4.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#relayFee, #relayFee,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#relayFee, #relayFee,
@ -393,50 +392,30 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
} }
/// A class which mocks [CachedElectrumX]. /// A class which mocks [CachedElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
MockCachedElectrumX() { MockCachedElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
String get server => (super.noSuchMethod( _i3.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_1(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i3.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_1(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i3.Prefs); ) as _i3.ElectrumX);
@override @override
List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( _i4.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i4.ElectrumXNode>[],
) as List<_i4.ElectrumXNode>);
@override
_i5.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i7.Coin? coin, required _i6.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -449,8 +428,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -468,9 +447,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i7.Coin? coin, required _i6.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -484,11 +463,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<String>> getUsedCoinSerials({ _i4.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin, required _i6.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -500,26 +479,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i5.Future<List<String>>.value(<String>[]), returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>); ) as _i4.Future<List<String>>);
@override @override
_i5.Future<void> clearSharedTransactionCache({required _i7.Coin? coin}) => _i4.Future<void> clearSharedTransactionCache({required _i6.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }
/// A class which mocks [TransactionNotificationTracker]. /// A class which mocks [TransactionNotificationTracker].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockTransactionNotificationTracker extends _i1.Mock class MockTransactionNotificationTracker extends _i1.Mock
implements _i8.TransactionNotificationTracker { implements _i7.TransactionNotificationTracker {
MockTransactionNotificationTracker() { MockTransactionNotificationTracker() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@ -548,14 +527,14 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedPending, #addNotifiedPending,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -565,21 +544,21 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedConfirmed, #addNotifiedConfirmed,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod( _i4.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#deleteTransaction, #deleteTransaction,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }

View file

@ -105,6 +105,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
), ),
) )
.toList(); .toList();

File diff suppressed because it is too large Load diff

View file

@ -126,6 +126,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
); );
when(wallet.transactions).thenAnswer((_) async => [ when(wallet.transactions).thenAnswer((_) async => [
tx, tx,

View file

@ -3,16 +3,15 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5; import 'dart:async' as _i4;
import 'package:decimal/decimal.dart' as _i2; import 'package:decimal/decimal.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i3;
import 'package:stackwallet/services/transaction_notification_tracker.dart' import 'package:stackwallet/services/transaction_notification_tracker.dart'
as _i8; as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i3;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -35,8 +34,8 @@ class _FakeDecimal_0 extends _i1.SmartFake implements _i2.Decimal {
); );
} }
class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { class _FakeElectrumX_1 extends _i1.SmartFake implements _i3.ElectrumX {
_FakePrefs_1( _FakeElectrumX_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -48,13 +47,13 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs {
/// A class which mocks [ElectrumX]. /// A class which mocks [ElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { class MockElectrumX extends _i1.Mock implements _i3.ElectrumX {
MockElectrumX() { MockElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( set failovers(List<_i3.ElectrumXNode>? _failovers) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
#failovers, #failovers,
_failovers, _failovers,
@ -90,7 +89,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<dynamic> request({ _i4.Future<dynamic> request({
required String? command, required String? command,
List<dynamic>? args = const [], List<dynamic>? args = const [],
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -109,10 +108,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<List<Map<String, dynamic>>> batchRequest({ _i4.Future<List<Map<String, dynamic>>> batchRequest({
required String? command, required String? command,
required Map<String, List<dynamic>>? args, required Map<String, List<dynamic>>? args,
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -129,11 +128,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<bool> ping({ _i4.Future<bool> ping({
String? requestID, String? requestID,
int? retryCount = 1, int? retryCount = 1,
}) => }) =>
@ -146,10 +145,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retryCount: retryCount, #retryCount: retryCount,
}, },
), ),
returnValue: _i5.Future<bool>.value(false), returnValue: _i4.Future<bool>.value(false),
) as _i5.Future<bool>); ) as _i4.Future<bool>);
@override @override
_i5.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) => _i4.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getBlockHeadTip, #getBlockHeadTip,
@ -157,10 +156,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) => _i4.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getServerFeatures, #getServerFeatures,
@ -168,10 +167,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<String> broadcastTransaction({ _i4.Future<String> broadcastTransaction({
required String? rawTx, required String? rawTx,
String? requestID, String? requestID,
}) => }) =>
@ -184,10 +183,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<String>.value(''), returnValue: _i4.Future<String>.value(''),
) as _i5.Future<String>); ) as _i4.Future<String>);
@override @override
_i5.Future<Map<String, dynamic>> getBalance({ _i4.Future<Map<String, dynamic>> getBalance({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -201,10 +200,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getHistory({ _i4.Future<List<Map<String, dynamic>>> getHistory({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -217,11 +216,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -229,11 +228,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getUTXOs({ _i4.Future<List<Map<String, dynamic>>> getUTXOs({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -246,11 +245,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -258,11 +257,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
bool? verbose = true, bool? verbose = true,
String? requestID, String? requestID,
@ -278,10 +277,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getAnonymitySet({ _i4.Future<Map<String, dynamic>> getAnonymitySet({
String? groupId = r'1', String? groupId = r'1',
String? blockhash = r'', String? blockhash = r'',
String? requestID, String? requestID,
@ -297,10 +296,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<dynamic> getMintData({ _i4.Future<dynamic> getMintData({
dynamic mints, dynamic mints,
String? requestID, String? requestID,
}) => }) =>
@ -313,10 +312,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<Map<String, dynamic>> getUsedCoinSerials({ _i4.Future<Map<String, dynamic>> getUsedCoinSerials({
String? requestID, String? requestID,
required int? startNumber, required int? startNumber,
}) => }) =>
@ -330,19 +329,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod( _i4.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getLatestCoinId, #getLatestCoinId,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<int>.value(0), returnValue: _i4.Future<int>.value(0),
) as _i5.Future<int>); ) as _i4.Future<int>);
@override @override
_i5.Future<Map<String, dynamic>> getFeeRate({String? requestID}) => _i4.Future<Map<String, dynamic>> getFeeRate({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFeeRate, #getFeeRate,
@ -350,10 +349,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<_i2.Decimal> estimateFee({ _i4.Future<_i2.Decimal> estimateFee({
String? requestID, String? requestID,
required int? blocks, required int? blocks,
}) => }) =>
@ -366,7 +365,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#blocks: blocks, #blocks: blocks,
}, },
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#estimateFee, #estimateFee,
@ -377,15 +376,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
@override @override
_i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( _i4.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#relayFee, #relayFee,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#relayFee, #relayFee,
@ -393,50 +392,30 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
} }
/// A class which mocks [CachedElectrumX]. /// A class which mocks [CachedElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
MockCachedElectrumX() { MockCachedElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
String get server => (super.noSuchMethod( _i3.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_1(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i3.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_1(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i3.Prefs); ) as _i3.ElectrumX);
@override @override
List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( _i4.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i4.ElectrumXNode>[],
) as List<_i4.ElectrumXNode>);
@override
_i5.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i7.Coin? coin, required _i6.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -449,8 +428,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -468,9 +447,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i7.Coin? coin, required _i6.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -484,11 +463,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<String>> getUsedCoinSerials({ _i4.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin, required _i6.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -500,26 +479,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i5.Future<List<String>>.value(<String>[]), returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>); ) as _i4.Future<List<String>>);
@override @override
_i5.Future<void> clearSharedTransactionCache({required _i7.Coin? coin}) => _i4.Future<void> clearSharedTransactionCache({required _i6.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }
/// A class which mocks [TransactionNotificationTracker]. /// A class which mocks [TransactionNotificationTracker].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockTransactionNotificationTracker extends _i1.Mock class MockTransactionNotificationTracker extends _i1.Mock
implements _i8.TransactionNotificationTracker { implements _i7.TransactionNotificationTracker {
MockTransactionNotificationTracker() { MockTransactionNotificationTracker() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@ -548,14 +527,14 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedPending, #addNotifiedPending,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -565,21 +544,21 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedConfirmed, #addNotifiedConfirmed,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod( _i4.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#deleteTransaction, #deleteTransaction,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }

View file

@ -3,16 +3,15 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5; import 'dart:async' as _i4;
import 'package:decimal/decimal.dart' as _i2; import 'package:decimal/decimal.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i6; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i5;
import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i4; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i3;
import 'package:stackwallet/services/transaction_notification_tracker.dart' import 'package:stackwallet/services/transaction_notification_tracker.dart'
as _i8; as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i3;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@ -35,8 +34,8 @@ class _FakeDecimal_0 extends _i1.SmartFake implements _i2.Decimal {
); );
} }
class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs { class _FakeElectrumX_1 extends _i1.SmartFake implements _i3.ElectrumX {
_FakePrefs_1( _FakeElectrumX_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@ -48,13 +47,13 @@ class _FakePrefs_1 extends _i1.SmartFake implements _i3.Prefs {
/// A class which mocks [ElectrumX]. /// A class which mocks [ElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockElectrumX extends _i1.Mock implements _i4.ElectrumX { class MockElectrumX extends _i1.Mock implements _i3.ElectrumX {
MockElectrumX() { MockElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( set failovers(List<_i3.ElectrumXNode>? _failovers) => super.noSuchMethod(
Invocation.setter( Invocation.setter(
#failovers, #failovers,
_failovers, _failovers,
@ -90,7 +89,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<dynamic> request({ _i4.Future<dynamic> request({
required String? command, required String? command,
List<dynamic>? args = const [], List<dynamic>? args = const [],
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -109,10 +108,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<List<Map<String, dynamic>>> batchRequest({ _i4.Future<List<Map<String, dynamic>>> batchRequest({
required String? command, required String? command,
required Map<String, List<dynamic>>? args, required Map<String, List<dynamic>>? args,
Duration? connectionTimeout = const Duration(seconds: 60), Duration? connectionTimeout = const Duration(seconds: 60),
@ -129,11 +128,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retries: retries, #retries: retries,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<bool> ping({ _i4.Future<bool> ping({
String? requestID, String? requestID,
int? retryCount = 1, int? retryCount = 1,
}) => }) =>
@ -146,10 +145,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#retryCount: retryCount, #retryCount: retryCount,
}, },
), ),
returnValue: _i5.Future<bool>.value(false), returnValue: _i4.Future<bool>.value(false),
) as _i5.Future<bool>); ) as _i4.Future<bool>);
@override @override
_i5.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) => _i4.Future<Map<String, dynamic>> getBlockHeadTip({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getBlockHeadTip, #getBlockHeadTip,
@ -157,10 +156,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) => _i4.Future<Map<String, dynamic>> getServerFeatures({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getServerFeatures, #getServerFeatures,
@ -168,10 +167,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<String> broadcastTransaction({ _i4.Future<String> broadcastTransaction({
required String? rawTx, required String? rawTx,
String? requestID, String? requestID,
}) => }) =>
@ -184,10 +183,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<String>.value(''), returnValue: _i4.Future<String>.value(''),
) as _i5.Future<String>); ) as _i4.Future<String>);
@override @override
_i5.Future<Map<String, dynamic>> getBalance({ _i4.Future<Map<String, dynamic>> getBalance({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -201,10 +200,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getHistory({ _i4.Future<List<Map<String, dynamic>>> getHistory({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -217,11 +216,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchHistory(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -229,11 +228,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<List<Map<String, dynamic>>> getUTXOs({ _i4.Future<List<Map<String, dynamic>>> getUTXOs({
required String? scripthash, required String? scripthash,
String? requestID, String? requestID,
}) => }) =>
@ -246,11 +245,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<List<Map<String, dynamic>>>.value( returnValue: _i4.Future<List<Map<String, dynamic>>>.value(
<Map<String, dynamic>>[]), <Map<String, dynamic>>[]),
) as _i5.Future<List<Map<String, dynamic>>>); ) as _i4.Future<List<Map<String, dynamic>>>);
@override @override
_i5.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs( _i4.Future<Map<String, List<Map<String, dynamic>>>> getBatchUTXOs(
{required Map<String, List<dynamic>>? args}) => {required Map<String, List<dynamic>>? args}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -258,11 +257,11 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
[], [],
{#args: args}, {#args: args},
), ),
returnValue: _i5.Future<Map<String, List<Map<String, dynamic>>>>.value( returnValue: _i4.Future<Map<String, List<Map<String, dynamic>>>>.value(
<String, List<Map<String, dynamic>>>{}), <String, List<Map<String, dynamic>>>{}),
) as _i5.Future<Map<String, List<Map<String, dynamic>>>>); ) as _i4.Future<Map<String, List<Map<String, dynamic>>>>);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
bool? verbose = true, bool? verbose = true,
String? requestID, String? requestID,
@ -278,10 +277,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<Map<String, dynamic>> getAnonymitySet({ _i4.Future<Map<String, dynamic>> getAnonymitySet({
String? groupId = r'1', String? groupId = r'1',
String? blockhash = r'', String? blockhash = r'',
String? requestID, String? requestID,
@ -297,10 +296,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<dynamic> getMintData({ _i4.Future<dynamic> getMintData({
dynamic mints, dynamic mints,
String? requestID, String? requestID,
}) => }) =>
@ -313,10 +312,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#requestID: requestID, #requestID: requestID,
}, },
), ),
returnValue: _i5.Future<dynamic>.value(), returnValue: _i4.Future<dynamic>.value(),
) as _i5.Future<dynamic>); ) as _i4.Future<dynamic>);
@override @override
_i5.Future<Map<String, dynamic>> getUsedCoinSerials({ _i4.Future<Map<String, dynamic>> getUsedCoinSerials({
String? requestID, String? requestID,
required int? startNumber, required int? startNumber,
}) => }) =>
@ -330,19 +329,19 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod( _i4.Future<int> getLatestCoinId({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getLatestCoinId, #getLatestCoinId,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<int>.value(0), returnValue: _i4.Future<int>.value(0),
) as _i5.Future<int>); ) as _i4.Future<int>);
@override @override
_i5.Future<Map<String, dynamic>> getFeeRate({String? requestID}) => _i4.Future<Map<String, dynamic>> getFeeRate({String? requestID}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#getFeeRate, #getFeeRate,
@ -350,10 +349,10 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<_i2.Decimal> estimateFee({ _i4.Future<_i2.Decimal> estimateFee({
String? requestID, String? requestID,
required int? blocks, required int? blocks,
}) => }) =>
@ -366,7 +365,7 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
#blocks: blocks, #blocks: blocks,
}, },
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#estimateFee, #estimateFee,
@ -377,15 +376,15 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
}, },
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
@override @override
_i5.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( _i4.Future<_i2.Decimal> relayFee({String? requestID}) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#relayFee, #relayFee,
[], [],
{#requestID: requestID}, {#requestID: requestID},
), ),
returnValue: _i5.Future<_i2.Decimal>.value(_FakeDecimal_0( returnValue: _i4.Future<_i2.Decimal>.value(_FakeDecimal_0(
this, this,
Invocation.method( Invocation.method(
#relayFee, #relayFee,
@ -393,50 +392,30 @@ class MockElectrumX extends _i1.Mock implements _i4.ElectrumX {
{#requestID: requestID}, {#requestID: requestID},
), ),
)), )),
) as _i5.Future<_i2.Decimal>); ) as _i4.Future<_i2.Decimal>);
} }
/// A class which mocks [CachedElectrumX]. /// A class which mocks [CachedElectrumX].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX { class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
MockCachedElectrumX() { MockCachedElectrumX() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
String get server => (super.noSuchMethod( _i3.ElectrumX get electrumXClient => (super.noSuchMethod(
Invocation.getter(#server), Invocation.getter(#electrumXClient),
returnValue: '', returnValue: _FakeElectrumX_1(
) as String);
@override
int get port => (super.noSuchMethod(
Invocation.getter(#port),
returnValue: 0,
) as int);
@override
bool get useSSL => (super.noSuchMethod(
Invocation.getter(#useSSL),
returnValue: false,
) as bool);
@override
_i3.Prefs get prefs => (super.noSuchMethod(
Invocation.getter(#prefs),
returnValue: _FakePrefs_1(
this, this,
Invocation.getter(#prefs), Invocation.getter(#electrumXClient),
), ),
) as _i3.Prefs); ) as _i3.ElectrumX);
@override @override
List<_i4.ElectrumXNode> get failovers => (super.noSuchMethod( _i4.Future<Map<String, dynamic>> getAnonymitySet({
Invocation.getter(#failovers),
returnValue: <_i4.ElectrumXNode>[],
) as List<_i4.ElectrumXNode>);
@override
_i5.Future<Map<String, dynamic>> getAnonymitySet({
required String? groupId, required String? groupId,
String? blockhash = r'', String? blockhash = r'',
required _i7.Coin? coin, required _i6.Coin? coin,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -449,8 +428,8 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
String base64ToHex(String? source) => (super.noSuchMethod( String base64ToHex(String? source) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -468,9 +447,9 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
returnValue: '', returnValue: '',
) as String); ) as String);
@override @override
_i5.Future<Map<String, dynamic>> getTransaction({ _i4.Future<Map<String, dynamic>> getTransaction({
required String? txHash, required String? txHash,
required _i7.Coin? coin, required _i6.Coin? coin,
bool? verbose = true, bool? verbose = true,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -484,11 +463,11 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
}, },
), ),
returnValue: returnValue:
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}), _i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>); ) as _i4.Future<Map<String, dynamic>>);
@override @override
_i5.Future<List<String>> getUsedCoinSerials({ _i4.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin, required _i6.Coin? coin,
int? startNumber = 0, int? startNumber = 0,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
@ -500,26 +479,26 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
#startNumber: startNumber, #startNumber: startNumber,
}, },
), ),
returnValue: _i5.Future<List<String>>.value(<String>[]), returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>); ) as _i4.Future<List<String>>);
@override @override
_i5.Future<void> clearSharedTransactionCache({required _i7.Coin? coin}) => _i4.Future<void> clearSharedTransactionCache({required _i6.Coin? coin}) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearSharedTransactionCache, #clearSharedTransactionCache,
[], [],
{#coin: coin}, {#coin: coin},
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }
/// A class which mocks [TransactionNotificationTracker]. /// A class which mocks [TransactionNotificationTracker].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockTransactionNotificationTracker extends _i1.Mock class MockTransactionNotificationTracker extends _i1.Mock
implements _i8.TransactionNotificationTracker { implements _i7.TransactionNotificationTracker {
MockTransactionNotificationTracker() { MockTransactionNotificationTracker() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@ -548,14 +527,14 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedPending(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedPending, #addNotifiedPending,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
@ -565,21 +544,21 @@ class MockTransactionNotificationTracker extends _i1.Mock
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override @override
_i5.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod( _i4.Future<void> addNotifiedConfirmed(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#addNotifiedConfirmed, #addNotifiedConfirmed,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
@override @override
_i5.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod( _i4.Future<void> deleteTransaction(String? txid) => (super.noSuchMethod(
Invocation.method( Invocation.method(
#deleteTransaction, #deleteTransaction,
[txid], [txid],
), ),
returnValue: _i5.Future<void>.value(), returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(), returnValueForMissingStub: _i4.Future<void>.value(),
) as _i5.Future<void>); ) as _i4.Future<void>);
} }

View file

@ -78,33 +78,33 @@ void main() {
); );
}); });
test("localizedStringAsFixed", () { // test("localizedStringAsFixed", () {
expect( // expect(
Amount(rawValue: BigInt.two, fractionDigits: 8) // Amount(rawValue: BigInt.two, fractionDigits: 8)
.localizedStringAsFixed(locale: "en_US"), // .localizedStringAsFixed(locale: "en_US"),
"0.00000002", // "0.00000002",
); // );
expect( // expect(
Amount(rawValue: BigInt.two, fractionDigits: 8) // Amount(rawValue: BigInt.two, fractionDigits: 8)
.localizedStringAsFixed(locale: "en_US", decimalPlaces: 2), // .localizedStringAsFixed(locale: "en_US", decimalPlaces: 2),
"0.00", // "0.00",
); // );
expect( // expect(
Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8) // Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8)
.localizedStringAsFixed(locale: "en_US"), // .localizedStringAsFixed(locale: "en_US"),
"2.00000000", // "2.00000000",
); // );
expect( // expect(
Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8) // Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8)
.localizedStringAsFixed(locale: "en_US", decimalPlaces: 4), // .localizedStringAsFixed(locale: "en_US", decimalPlaces: 4),
"2.0000", // "2.0000",
); // );
expect( // expect(
Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8) // Amount.fromDecimal(Decimal.fromInt(2), fractionDigits: 8)
.localizedStringAsFixed(locale: "en_US", decimalPlaces: 0), // .localizedStringAsFixed(locale: "en_US", decimalPlaces: 0),
"2", // "2",
); // );
}); // });
}); });
group("deserialization", () { group("deserialization", () {

View file

@ -68,7 +68,17 @@ void main() {
coin: Coin.ethereum, coin: Coin.ethereum,
maxDecimalPlaces: 8, maxDecimalPlaces: 8,
), ),
"10.12345678 ETH", "~10.12345678 ETH",
);
expect(
AmountUnit.normal.displayAmount(
amount: amount,
locale: "en_US",
coin: Coin.ethereum,
maxDecimalPlaces: 4,
),
"~10.1234 ETH",
); );
expect( expect(
@ -88,7 +98,7 @@ void main() {
coin: Coin.ethereum, coin: Coin.ethereum,
maxDecimalPlaces: 9, maxDecimalPlaces: 9,
), ),
"10123.456789123 mETH", "~10123.456789123 mETH",
); );
expect( expect(
@ -98,7 +108,7 @@ void main() {
coin: Coin.ethereum, coin: Coin.ethereum,
maxDecimalPlaces: 8, maxDecimalPlaces: 8,
), ),
"10123456.78912345 µETH", "~10123456.78912345 µETH",
); );
expect( expect(
@ -108,7 +118,7 @@ void main() {
coin: Coin.ethereum, coin: Coin.ethereum,
maxDecimalPlaces: 1, maxDecimalPlaces: 1,
), ),
"10123456789.1 gwei", "~10123456789.1 gwei",
); );
expect( expect(

View file

@ -3,20 +3,63 @@ import 'package:flutter_svg/svg.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart';
import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart'; import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart';
import '../sample_data/theme_json.dart'; import '../sample_data/theme_json.dart';
class PinWidget extends StatefulWidget {
const PinWidget({
super.key,
this.onSubmit,
this.controller,
required this.pinAnimation,
required this.isRandom,
});
final void Function(String)? onSubmit;
final TextEditingController? controller;
final bool isRandom;
final PinAnimationType pinAnimation;
@override
PinWidgetState createState() => PinWidgetState();
}
class PinWidgetState extends State<PinWidget> {
int pinCount = 1;
@override
Widget build(BuildContext context) {
bool submittedPinMatches = false;
return CustomPinPut(
fieldsCount: pinCount,
isRandom: widget.isRandom,
useNativeKeyboard: false,
eachFieldHeight: 12,
eachFieldWidth: 12,
textStyle: STextStyles.label(context).copyWith(
fontSize: 1,
),
obscureText: "",
onPinLengthChanged: (newLength) {
setState(() {
pinCount = newLength;
});
},
onSubmit: widget.onSubmit,
controller: widget.controller,
pinAnimationType: widget.pinAnimation,
);
}
}
void main() { void main() {
group("CustomPinPut tests, non-random PIN", () { group("CustomPinPut tests, non-random PIN", () {
testWidgets("CustomPinPut with 4 fields builds correctly, non-random PIN", testWidgets("CustomPinPut with 4 fields builds correctly, non-random PIN",
(tester) async { (tester) async {
const pinPut = CustomPinPut(
fieldsCount: 4,
isRandom: false,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -30,13 +73,16 @@ void main() {
], ],
), ),
home: const Material( home: const Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.none,
isRandom: false,
),
), ),
), ),
); );
// expects 5 here. Four + the actual text field text // expects 5 here. Four + the actual text field text
expect(find.text(""), findsNWidgets(5)); expect(find.text(""), findsNWidgets(1));
expect(find.byType(PinKeyboard), findsOneWidget); expect(find.byType(PinKeyboard), findsOneWidget);
expect(find.byType(BackspaceKey), findsOneWidget); expect(find.byType(BackspaceKey), findsOneWidget);
expect(find.byType(NumberKey), findsNWidgets(10)); expect(find.byType(NumberKey), findsNWidgets(10));
@ -45,15 +91,6 @@ void main() {
testWidgets("CustomPinPut entering a pin successfully, non-random PIN", testWidgets("CustomPinPut entering a pin successfully, non-random PIN",
(tester) async { (tester) async {
bool submittedPinMatches = false; bool submittedPinMatches = false;
final pinPut = CustomPinPut(
fieldsCount: 4,
onSubmit: (pin) {
submittedPinMatches = pin == "1234";
print("pin entered: $pin");
},
useNativeKeyboard: false,
isRandom: false,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -68,7 +105,14 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.none,
isRandom: false,
onSubmit: (pin) {
submittedPinMatches = pin == "1234";
print("pin entered: $pin");
},
),
), ),
), ),
); );
@ -99,12 +143,6 @@ void main() {
testWidgets("CustomPinPut pin enter fade animation, non-random PIN", testWidgets("CustomPinPut pin enter fade animation, non-random PIN",
(tester) async { (tester) async {
final controller = TextEditingController(); final controller = TextEditingController();
final pinPut = CustomPinPut(
fieldsCount: 4,
pinAnimationType: PinAnimationType.fade,
controller: controller,
isRandom: false,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -119,7 +157,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.none,
isRandom: false,
controller: controller,
),
), ),
), ),
); );
@ -137,12 +179,6 @@ void main() {
testWidgets("CustomPinPut pin enter scale animation, non-random PIN", testWidgets("CustomPinPut pin enter scale animation, non-random PIN",
(tester) async { (tester) async {
final controller = TextEditingController(); final controller = TextEditingController();
final pinPut = CustomPinPut(
fieldsCount: 4,
pinAnimationType: PinAnimationType.scale,
controller: controller,
isRandom: false,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -157,7 +193,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.scale,
isRandom: false,
controller: controller,
),
), ),
), ),
); );
@ -175,12 +215,6 @@ void main() {
testWidgets("CustomPinPut pin enter rotate animation, non-random PIN", testWidgets("CustomPinPut pin enter rotate animation, non-random PIN",
(tester) async { (tester) async {
final controller = TextEditingController(); final controller = TextEditingController();
final pinPut = CustomPinPut(
fieldsCount: 4,
pinAnimationType: PinAnimationType.rotation,
controller: controller,
isRandom: false,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -195,7 +229,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.rotation,
isRandom: false,
controller: controller,
),
), ),
), ),
); );
@ -256,11 +294,6 @@ void main() {
group("CustomPinPut tests, with random PIN", () { group("CustomPinPut tests, with random PIN", () {
testWidgets("CustomPinPut with 4 fields builds correctly, with random PIN", testWidgets("CustomPinPut with 4 fields builds correctly, with random PIN",
(tester) async { (tester) async {
const pinPut = CustomPinPut(
fieldsCount: 4,
isRandom: true,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -274,81 +307,76 @@ void main() {
], ],
), ),
home: const Material( home: const Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.none,
isRandom: true,
),
), ),
), ),
); );
// expects 5 here. Four + the actual text field text // expects 5 here. Four + the actual text field text
expect(find.text(""), findsNWidgets(5)); expect(find.text(""), findsNWidgets(1));
expect(find.byType(PinKeyboard), findsOneWidget); expect(find.byType(PinKeyboard), findsOneWidget);
expect(find.byType(BackspaceKey), findsOneWidget); expect(find.byType(BackspaceKey), findsOneWidget);
expect(find.byType(NumberKey), findsNWidgets(10)); expect(find.byType(NumberKey), findsNWidgets(10));
}); });
testWidgets("CustomPinPut entering a pin successfully, with random PIN", // testWidgets("CustomPinPut entering a pin successfully, with random PIN",
(tester) async { // (tester) async {
bool submittedPinMatches = false; // bool submittedPinMatches = false;
final pinPut = CustomPinPut( //
fieldsCount: 4, // await tester.pumpWidget(
onSubmit: (pin) { // MaterialApp(
submittedPinMatches = pin == "1234"; // theme: ThemeData(
print("pin entered: $pin"); // extensions: [
}, // StackColors.fromStackColorTheme(
useNativeKeyboard: false, // StackTheme.fromJson(
isRandom: true, // json: lightThemeJsonMap,
); // applicationThemesDirectoryPath: "test",
// ),
await tester.pumpWidget( // ),
MaterialApp( // ],
theme: ThemeData( // ),
extensions: [ // home: Material(
StackColors.fromStackColorTheme( // child: PinWidget(
StackTheme.fromJson( // pinAnimation: PinAnimationType.none,
json: lightThemeJsonMap, // isRandom: true,
applicationThemesDirectoryPath: "test", // onSubmit: (pin) {
), // submittedPinMatches = pin == "1234";
), // print("pin entered: $pin");
], // },
), // ),
home: Material( // ),
child: pinPut, // ),
), // );
), //
); // await tester.tap(find.byWidgetPredicate(
// (widget) => widget is NumberKey && widget.number == "1"));
await tester.tap(find.byWidgetPredicate( // await tester.pumpAndSettle();
(widget) => widget is NumberKey && widget.number == "1")); // await tester.tap(find.byWidgetPredicate(
await tester.pumpAndSettle(); // (widget) => widget is NumberKey && widget.number == "2"));
await tester.tap(find.byWidgetPredicate( // await tester.pumpAndSettle();
(widget) => widget is NumberKey && widget.number == "2")); // await tester.tap(find.byWidgetPredicate(
await tester.pumpAndSettle(); // (widget) => widget is NumberKey && widget.number == "6"));
await tester.tap(find.byWidgetPredicate( // await tester.pumpAndSettle();
(widget) => widget is NumberKey && widget.number == "6")); // await tester.tap(find.byType(BackspaceKey));
await tester.pumpAndSettle(); // await tester.pumpAndSettle();
await tester.tap(find.byType(BackspaceKey)); // await tester.tap(find.byWidgetPredicate(
await tester.pumpAndSettle(); // (widget) => widget is NumberKey && widget.number == "3"));
await tester.tap(find.byWidgetPredicate( // await tester.pumpAndSettle();
(widget) => widget is NumberKey && widget.number == "3")); // await tester.tap(find.byWidgetPredicate(
await tester.pumpAndSettle(); // (widget) => widget is NumberKey && widget.number == "4"));
await tester.tap(find.byWidgetPredicate( // await tester.pumpAndSettle();
(widget) => widget is NumberKey && widget.number == "4")); // await tester.tap(find.byType(SubmitKey));
await tester.pumpAndSettle(); // await tester.pumpAndSettle();
await tester.tap(find.byType(SubmitKey)); //
await tester.pumpAndSettle(); // expect(submittedPinMatches, true);
// });
expect(submittedPinMatches, true);
});
testWidgets("CustomPinPut pin enter fade animation, with random PIN", testWidgets("CustomPinPut pin enter fade animation, with random PIN",
(tester) async { (tester) async {
final controller = TextEditingController(); final controller = TextEditingController();
final pinPut = CustomPinPut(
fieldsCount: 4,
pinAnimationType: PinAnimationType.fade,
controller: controller,
isRandom: true,
);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -363,7 +391,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
pinAnimation: PinAnimationType.fade,
isRandom: true,
controller: controller,
),
), ),
), ),
); );
@ -401,7 +433,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
isRandom: true,
controller: controller,
pinAnimation: PinAnimationType.scale,
),
), ),
), ),
); );
@ -439,7 +475,11 @@ void main() {
], ],
), ),
home: Material( home: Material(
child: pinPut, child: PinWidget(
isRandom: true,
controller: controller,
pinAnimation: PinAnimationType.rotation,
),
), ),
), ),
); );

View file

@ -71,6 +71,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
)..address.value = Address( )..address.value = Address(
walletId: "walletId", walletId: "walletId",
value: "", value: "",
@ -188,6 +189,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
)..address.value = Address( )..address.value = Address(
walletId: "walletId", walletId: "walletId",
value: "", value: "",
@ -302,6 +304,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
)..address.value = Address( )..address.value = Address(
walletId: "walletId", walletId: "walletId",
value: "", value: "",
@ -410,6 +413,7 @@ void main() {
nonce: null, nonce: null,
inputs: [], inputs: [],
outputs: [], outputs: [],
numberOfMessages: null,
)..address.value = Address( )..address.value = Address(
walletId: "walletId", walletId: "walletId",
value: "", value: "",