diff --git a/packages/komodo_defi_local_auth/lib/src/auth/auth_state.dart b/packages/komodo_defi_local_auth/lib/src/auth/auth_state.dart index d27d645d..aba382a1 100644 --- a/packages/komodo_defi_local_auth/lib/src/auth/auth_state.dart +++ b/packages/komodo_defi_local_auth/lib/src/auth/auth_state.dart @@ -1,46 +1,24 @@ -import 'package:equatable/equatable.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:komodo_defi_types/komodo_defi_types.dart'; +part 'auth_state.freezed.dart'; + /// Represents the current state of an authentication process -class AuthenticationState extends Equatable { - const AuthenticationState({ - required this.status, - this.message, - this.taskId, - this.error, - this.user, - }); +@freezed +abstract class AuthenticationState with _$AuthenticationState { + const factory AuthenticationState({ + required AuthenticationStatus status, + String? message, + int? taskId, + String? error, + KdfUser? user, + }) = _AuthenticationState; factory AuthenticationState.completed(KdfUser user) => AuthenticationState(status: AuthenticationStatus.completed, user: user); factory AuthenticationState.error(String error) => AuthenticationState(status: AuthenticationStatus.error, error: error); - - final AuthenticationStatus status; - final String? message; - final int? taskId; - final String? error; - final KdfUser? user; - - AuthenticationState copyWith({ - AuthenticationStatus? status, - String? message, - int? taskId, - String? error, - KdfUser? user, - }) { - return AuthenticationState( - status: status ?? this.status, - message: message ?? this.message, - taskId: taskId ?? this.taskId, - error: error ?? this.error, - user: user ?? this.user, - ); - } - - @override - List get props => [status, message, taskId, error, user]; } /// General authentication status that can be used for any wallet type diff --git a/packages/komodo_defi_local_auth/lib/src/auth/auth_state.freezed.dart b/packages/komodo_defi_local_auth/lib/src/auth/auth_state.freezed.dart new file mode 100644 index 00000000..d1c2f92d --- /dev/null +++ b/packages/komodo_defi_local_auth/lib/src/auth/auth_state.freezed.dart @@ -0,0 +1,154 @@ +// dart format width=80 +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'auth_state.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$AuthenticationState { + + AuthenticationStatus get status; String? get message; int? get taskId; String? get error; KdfUser? get user; +/// Create a copy of AuthenticationState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AuthenticationStateCopyWith get copyWith => _$AuthenticationStateCopyWithImpl(this as AuthenticationState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthenticationState&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.error, error) || other.error == error)&&(identical(other.user, user) || other.user == user)); +} + + +@override +int get hashCode => Object.hash(runtimeType,status,message,taskId,error,user); + +@override +String toString() { + return 'AuthenticationState(status: $status, message: $message, taskId: $taskId, error: $error, user: $user)'; +} + + +} + +/// @nodoc +abstract mixin class $AuthenticationStateCopyWith<$Res> { + factory $AuthenticationStateCopyWith(AuthenticationState value, $Res Function(AuthenticationState) _then) = _$AuthenticationStateCopyWithImpl; +@useResult +$Res call({ + AuthenticationStatus status, String? message, int? taskId, String? error, KdfUser? user +}); + + + + +} +/// @nodoc +class _$AuthenticationStateCopyWithImpl<$Res> + implements $AuthenticationStateCopyWith<$Res> { + _$AuthenticationStateCopyWithImpl(this._self, this._then); + + final AuthenticationState _self; + final $Res Function(AuthenticationState) _then; + +/// Create a copy of AuthenticationState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = freezed,Object? taskId = freezed,Object? error = freezed,Object? user = freezed,}) { + return _then(_self.copyWith( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthenticationStatus,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,taskId: freezed == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable +as int?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as String?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as KdfUser?, + )); +} + +} + + +/// @nodoc + + +class _AuthenticationState implements AuthenticationState { + const _AuthenticationState({required this.status, this.message, this.taskId, this.error, this.user}); + + +@override final AuthenticationStatus status; +@override final String? message; +@override final int? taskId; +@override final String? error; +@override final KdfUser? user; + +/// Create a copy of AuthenticationState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AuthenticationStateCopyWith<_AuthenticationState> get copyWith => __$AuthenticationStateCopyWithImpl<_AuthenticationState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AuthenticationState&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.error, error) || other.error == error)&&(identical(other.user, user) || other.user == user)); +} + + +@override +int get hashCode => Object.hash(runtimeType,status,message,taskId,error,user); + +@override +String toString() { + return 'AuthenticationState(status: $status, message: $message, taskId: $taskId, error: $error, user: $user)'; +} + + +} + +/// @nodoc +abstract mixin class _$AuthenticationStateCopyWith<$Res> implements $AuthenticationStateCopyWith<$Res> { + factory _$AuthenticationStateCopyWith(_AuthenticationState value, $Res Function(_AuthenticationState) _then) = __$AuthenticationStateCopyWithImpl; +@override @useResult +$Res call({ + AuthenticationStatus status, String? message, int? taskId, String? error, KdfUser? user +}); + + + + +} +/// @nodoc +class __$AuthenticationStateCopyWithImpl<$Res> + implements _$AuthenticationStateCopyWith<$Res> { + __$AuthenticationStateCopyWithImpl(this._self, this._then); + + final _AuthenticationState _self; + final $Res Function(_AuthenticationState) _then; + +/// Create a copy of AuthenticationState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = freezed,Object? taskId = freezed,Object? error = freezed,Object? user = freezed,}) { + return _then(_AuthenticationState( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthenticationStatus,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,taskId: freezed == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable +as int?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as String?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as KdfUser?, + )); +} + + +} + +// dart format on diff --git a/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.dart b/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.dart index 83e871b7..728eed89 100644 --- a/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.dart +++ b/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.dart @@ -1,18 +1,23 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:komodo_defi_local_auth/komodo_defi_local_auth.dart'; import 'package:komodo_defi_rpc_methods/komodo_defi_rpc_methods.dart'; +part 'trezor_initialization_state.freezed.dart'; + /// Represents the current state of Trezor initialization -class TrezorInitializationState { - /// Creates a new initialization state - const TrezorInitializationState({ - required this.status, - this.message, - this.deviceInfo, - this.error, - this.taskId, - }); +@freezed +abstract class TrezorInitializationState with _$TrezorInitializationState { + const factory TrezorInitializationState({ + required AuthenticationStatus status, + String? message, + TrezorDeviceInfo? deviceInfo, + String? error, + int? taskId, + }) = _TrezorInitializationState; + + const TrezorInitializationState._(); - /// Factory constructor that maps API status response to domain state + /// Maps API status response to domain state factory TrezorInitializationState.fromStatusResponse( TrezorStatusResponse response, int taskId, @@ -34,7 +39,6 @@ class TrezorInitializationState { taskId: taskId, ); } - case 'Error': final errorInfo = response.errorInfo; return TrezorInitializationState( @@ -42,21 +46,18 @@ class TrezorInitializationState { error: errorInfo?.error ?? 'Unknown error occurred', taskId: taskId, ); - case 'InProgress': final description = response.progressDescription; return TrezorInitializationState.fromInProgressDescription( description, taskId, ); - case 'UserActionRequired': final description = response.progressDescription; return TrezorInitializationState.fromUserActionRequired( description, taskId, ); - default: return TrezorInitializationState( status: AuthenticationStatus.error, @@ -66,8 +67,7 @@ class TrezorInitializationState { } } - /// Factory constructor that maps in-progress descriptions - /// to appropriate states + /// Maps in-progress descriptions to appropriate states factory TrezorInitializationState.fromInProgressDescription( String? description, int taskId, @@ -107,8 +107,7 @@ class TrezorInitializationState { ); } - /// Factory constructor that maps user action requirements - /// to appropriate states + /// Maps user action requirements to appropriate states factory TrezorInitializationState.fromUserActionRequired( String? description, int taskId, @@ -144,38 +143,6 @@ class TrezorInitializationState { ); } - /// Current status of the initialization process - final AuthenticationStatus status; - - /// Human-readable message describing current state - final String? message; - - /// Device information (available when initialization is complete) - final TrezorDeviceInfo? deviceInfo; - - /// Error information (available when status is error) - final String? error; - - /// Task ID for the current initialization process - final int? taskId; - - /// Creates a copy of this state with optional parameter updates - TrezorInitializationState copyWith({ - AuthenticationStatus? status, - String? message, - TrezorDeviceInfo? deviceInfo, - String? error, - int? taskId, - }) { - return TrezorInitializationState( - status: status ?? this.status, - message: message ?? this.message, - deviceInfo: deviceInfo ?? this.deviceInfo, - error: error ?? this.error, - taskId: taskId ?? this.taskId, - ); - } - AuthenticationState toAuthenticationState() { return AuthenticationState( status: status, @@ -184,14 +151,4 @@ class TrezorInitializationState { error: error, ); } - - @override - String toString() { - return 'TrezorInitializationState(' - 'status: $status, ' - 'message: $message, ' - 'deviceInfo: ${deviceInfo?.deviceName}, ' - 'error: $error, ' - 'taskId: $taskId)'; - } } diff --git a/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.freezed.dart b/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.freezed.dart new file mode 100644 index 00000000..885dd250 --- /dev/null +++ b/packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.freezed.dart @@ -0,0 +1,154 @@ +// dart format width=80 +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'trezor_initialization_state.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$TrezorInitializationState { + + AuthenticationStatus get status; String? get message; TrezorDeviceInfo? get deviceInfo; String? get error; int? get taskId; +/// Create a copy of TrezorInitializationState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TrezorInitializationStateCopyWith get copyWith => _$TrezorInitializationStateCopyWithImpl(this as TrezorInitializationState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is TrezorInitializationState&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.deviceInfo, deviceInfo) || other.deviceInfo == deviceInfo)&&(identical(other.error, error) || other.error == error)&&(identical(other.taskId, taskId) || other.taskId == taskId)); +} + + +@override +int get hashCode => Object.hash(runtimeType,status,message,deviceInfo,error,taskId); + +@override +String toString() { + return 'TrezorInitializationState(status: $status, message: $message, deviceInfo: $deviceInfo, error: $error, taskId: $taskId)'; +} + + +} + +/// @nodoc +abstract mixin class $TrezorInitializationStateCopyWith<$Res> { + factory $TrezorInitializationStateCopyWith(TrezorInitializationState value, $Res Function(TrezorInitializationState) _then) = _$TrezorInitializationStateCopyWithImpl; +@useResult +$Res call({ + AuthenticationStatus status, String? message, TrezorDeviceInfo? deviceInfo, String? error, int? taskId +}); + + + + +} +/// @nodoc +class _$TrezorInitializationStateCopyWithImpl<$Res> + implements $TrezorInitializationStateCopyWith<$Res> { + _$TrezorInitializationStateCopyWithImpl(this._self, this._then); + + final TrezorInitializationState _self; + final $Res Function(TrezorInitializationState) _then; + +/// Create a copy of TrezorInitializationState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = freezed,Object? deviceInfo = freezed,Object? error = freezed,Object? taskId = freezed,}) { + return _then(_self.copyWith( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthenticationStatus,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,deviceInfo: freezed == deviceInfo ? _self.deviceInfo : deviceInfo // ignore: cast_nullable_to_non_nullable +as TrezorDeviceInfo?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as String?,taskId: freezed == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// @nodoc + + +class _TrezorInitializationState extends TrezorInitializationState { + const _TrezorInitializationState({required this.status, this.message, this.deviceInfo, this.error, this.taskId}): super._(); + + +@override final AuthenticationStatus status; +@override final String? message; +@override final TrezorDeviceInfo? deviceInfo; +@override final String? error; +@override final int? taskId; + +/// Create a copy of TrezorInitializationState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TrezorInitializationStateCopyWith<_TrezorInitializationState> get copyWith => __$TrezorInitializationStateCopyWithImpl<_TrezorInitializationState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TrezorInitializationState&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.deviceInfo, deviceInfo) || other.deviceInfo == deviceInfo)&&(identical(other.error, error) || other.error == error)&&(identical(other.taskId, taskId) || other.taskId == taskId)); +} + + +@override +int get hashCode => Object.hash(runtimeType,status,message,deviceInfo,error,taskId); + +@override +String toString() { + return 'TrezorInitializationState(status: $status, message: $message, deviceInfo: $deviceInfo, error: $error, taskId: $taskId)'; +} + + +} + +/// @nodoc +abstract mixin class _$TrezorInitializationStateCopyWith<$Res> implements $TrezorInitializationStateCopyWith<$Res> { + factory _$TrezorInitializationStateCopyWith(_TrezorInitializationState value, $Res Function(_TrezorInitializationState) _then) = __$TrezorInitializationStateCopyWithImpl; +@override @useResult +$Res call({ + AuthenticationStatus status, String? message, TrezorDeviceInfo? deviceInfo, String? error, int? taskId +}); + + + + +} +/// @nodoc +class __$TrezorInitializationStateCopyWithImpl<$Res> + implements _$TrezorInitializationStateCopyWith<$Res> { + __$TrezorInitializationStateCopyWithImpl(this._self, this._then); + + final _TrezorInitializationState _self; + final $Res Function(_TrezorInitializationState) _then; + +/// Create a copy of TrezorInitializationState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = freezed,Object? deviceInfo = freezed,Object? error = freezed,Object? taskId = freezed,}) { + return _then(_TrezorInitializationState( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthenticationStatus,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,deviceInfo: freezed == deviceInfo ? _self.deviceInfo : deviceInfo // ignore: cast_nullable_to_non_nullable +as TrezorDeviceInfo?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as String?,taskId: freezed == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/packages/komodo_defi_local_auth/pubspec.yaml b/packages/komodo_defi_local_auth/pubspec.yaml index c66117a7..65fd5a59 100644 --- a/packages/komodo_defi_local_auth/pubspec.yaml +++ b/packages/komodo_defi_local_auth/pubspec.yaml @@ -26,10 +26,13 @@ dependencies: local_auth: ^2.3.0 mutex: ^3.1.0 uuid: ^4.4.2 + freezed_annotation: ^3.0.0 dev_dependencies: flutter_test: sdk: flutter index_generator: ^4.0.1 mocktail: ^1.0.4 + build_runner: ^2.4.14 + freezed: ^3.0.4 very_good_analysis: ^8.0.0 diff --git a/packages/komodo_defi_rpc_methods/index_generator.yaml b/packages/komodo_defi_rpc_methods/index_generator.yaml index 38ee2a04..0674eada 100644 --- a/packages/komodo_defi_rpc_methods/index_generator.yaml +++ b/packages/komodo_defi_rpc_methods/index_generator.yaml @@ -5,6 +5,7 @@ index_generator: page_width: 100 exclude: - '**.g.dart' + - '**.freezed.dart' - '{_,**/_}*.dart' libraries: - directory_path: lib/src/common_structures diff --git a/packages/komodo_defi_sdk/index_generator.yaml b/packages/komodo_defi_sdk/index_generator.yaml index 77e0da0c..d1057c62 100644 --- a/packages/komodo_defi_sdk/index_generator.yaml +++ b/packages/komodo_defi_sdk/index_generator.yaml @@ -5,6 +5,7 @@ index_generator: page_width: 80 exclude: - "**.g.dart" + - "**.freezed.dart" libraries: # Default index and library name diff --git a/packages/komodo_defi_types/analysis_options.yaml b/packages/komodo_defi_types/analysis_options.yaml index 70b1ce68..c6c60ed6 100644 --- a/packages/komodo_defi_types/analysis_options.yaml +++ b/packages/komodo_defi_types/analysis_options.yaml @@ -1,6 +1,7 @@ analyzer: errors: public_member_api_docs: ignore + invalid_annotation_target: ignore include: package:very_good_analysis/analysis_options.6.0.0.yaml \ No newline at end of file diff --git a/packages/komodo_defi_types/lib/src/types.dart b/packages/komodo_defi_types/lib/src/types.dart index e8a605f1..ed0ae9f7 100644 --- a/packages/komodo_defi_types/lib/src/types.dart +++ b/packages/komodo_defi_types/lib/src/types.dart @@ -45,6 +45,7 @@ export 'public_key/pubkey.dart'; export 'public_key/pubkey_strategy.dart'; export 'public_key/token_balance_map.dart'; export 'public_key/wallet_balance.dart'; +export 'seed_node/seed_node.dart'; export 'transactions/asset_transaction_history_id.dart'; export 'transactions/balance_changes.dart'; export 'transactions/fee_info.dart';