2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:hive/hive.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../utilities/default_nodes.dart';
|
|
|
|
import '../utilities/flutter_secure_storage_interface.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
part 'type_adaptors/node_model.g.dart';
|
|
|
|
|
|
|
|
// @HiveType(typeId: 12)
|
|
|
|
class NodeModel {
|
|
|
|
// @HiveField(0)
|
|
|
|
final String id;
|
|
|
|
// @HiveField(1)
|
|
|
|
final String host;
|
|
|
|
// @HiveField(2)
|
|
|
|
final int port;
|
|
|
|
// @HiveField(3)
|
|
|
|
final String name;
|
|
|
|
// @HiveField(4)
|
|
|
|
final bool useSSL;
|
|
|
|
// @HiveField(5)
|
|
|
|
final String? loginName;
|
|
|
|
// @HiveField(6)
|
|
|
|
final bool enabled;
|
|
|
|
// @HiveField(7)
|
|
|
|
final String coinName;
|
|
|
|
// @HiveField(8)
|
|
|
|
final bool isFailover;
|
|
|
|
// @HiveField(9)
|
|
|
|
final bool isDown;
|
2023-01-05 20:32:36 +00:00
|
|
|
// @HiveField(10)
|
|
|
|
final bool? trusted;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
NodeModel({
|
|
|
|
required this.host,
|
|
|
|
required this.port,
|
|
|
|
required this.name,
|
|
|
|
required this.id,
|
|
|
|
required this.useSSL,
|
|
|
|
required this.enabled,
|
|
|
|
required this.coinName,
|
|
|
|
required this.isFailover,
|
|
|
|
required this.isDown,
|
|
|
|
this.loginName,
|
2023-01-05 20:32:36 +00:00
|
|
|
this.trusted,
|
2022-08-26 08:11:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
NodeModel copyWith({
|
|
|
|
String? host,
|
|
|
|
int? port,
|
|
|
|
String? name,
|
|
|
|
bool? useSSL,
|
|
|
|
String? loginName,
|
|
|
|
bool? enabled,
|
|
|
|
String? coinName,
|
|
|
|
bool? isFailover,
|
|
|
|
bool? isDown,
|
2023-01-05 20:32:36 +00:00
|
|
|
bool? trusted,
|
2022-08-26 08:11:35 +00:00
|
|
|
}) {
|
|
|
|
return NodeModel(
|
|
|
|
host: host ?? this.host,
|
|
|
|
port: port ?? this.port,
|
|
|
|
name: name ?? this.name,
|
|
|
|
id: id,
|
|
|
|
useSSL: useSSL ?? this.useSSL,
|
|
|
|
loginName: loginName ?? this.loginName,
|
|
|
|
enabled: enabled ?? this.enabled,
|
|
|
|
coinName: coinName ?? this.coinName,
|
|
|
|
isFailover: isFailover ?? this.isFailover,
|
|
|
|
isDown: isDown ?? this.isDown,
|
2023-01-05 20:32:36 +00:00
|
|
|
trusted: trusted ?? this.trusted,
|
2022-08-26 08:11:35 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// convenience getter to retrieve login password
|
2022-11-09 23:48:43 +00:00
|
|
|
Future<String?> getPassword(SecureStorageInterface secureStorage) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
return await secureStorage.read(key: "${id}_nodePW");
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap() {
|
2024-05-27 23:56:22 +00:00
|
|
|
final Map<String, dynamic> map = {};
|
2022-08-26 08:11:35 +00:00
|
|
|
map['host'] = host;
|
|
|
|
map['port'] = port;
|
|
|
|
map['name'] = name;
|
|
|
|
map['id'] = id;
|
|
|
|
map['useSSL'] = useSSL;
|
|
|
|
map['loginName'] = loginName;
|
|
|
|
map['enabled'] = enabled;
|
|
|
|
map['coinName'] = coinName;
|
|
|
|
map['isFailover'] = isFailover;
|
|
|
|
map['isDown'] = isDown;
|
2023-01-05 20:32:36 +00:00
|
|
|
map['trusted'] = trusted;
|
2022-08-26 08:11:35 +00:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2022-11-25 20:28:53 +00:00
|
|
|
bool get isDefault => id.startsWith(DefaultNodes.defaultNodeIdPrefix);
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return toMap().toString();
|
|
|
|
}
|
|
|
|
}
|