-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 Refine comments for clarity and readability
- Loading branch information
Alex
committed
Nov 15, 2024
1 parent
c89e011
commit 3ea4a7e
Showing
3 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import 'package:camelus/data_layer/repositories/app_update_repository_impl.dart'; | ||
import 'package:camelus/data_layer/repositories/app_update_repository_impl.dart'; | ||
import 'package:camelus/domain_layer/repositories/app_update_repository.dart'; | ||
import 'package:camelus/domain_layer/usecases/check_app_update.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
import '../../data_layer/data_sources/http_request_data_source.dart'; | ||
|
||
// Provider for checking app updates. | ||
// interacts with the AppUpdateRepository to check for app updates. | ||
final appUpdateProvider = Provider<CheckAppUpdate>((ref) { | ||
// Creating an HTTP client for making requests to the data source. | ||
final http.Client client = http.Client(); | ||
|
||
// Creating an instance of HttpRequestDataSource, which handles HTTP requests. | ||
final HttpRequestDataSource dataSource = HttpRequestDataSource(client); | ||
|
||
final AppUpdateRepository appUpdateRepository = | ||
AppUpdateRepositoryImpl(httpJsonDataSource: dataSource); | ||
|
||
final CheckAppUpdate appUpdate = CheckAppUpdate(appUpdateRepository); | ||
|
||
// Returning the CheckAppUpdate instance, which will be used by consumers. | ||
return appUpdate; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
import 'package:ndk/ndk.dart'; | ||
import 'package:ndk/ndk.dart'; | ||
import 'package:ndk/entities.dart' as ndk_entities; | ||
import 'package:riverpod/riverpod.dart'; | ||
|
||
// Provider for the EventVerifier, which provides an instance of a specific event verifier. | ||
// Currently set to use the RustEventVerifier. | ||
final eventVerifierProvider = Provider<EventVerifier>((ref) { | ||
// Creating instances of different EventVerifiers (Bip340, Mock, Rust). | ||
final EventVerifier eventVerifier = Bip340EventVerifier(); | ||
final EventVerifier mockEventVerifier = MockEventVerifier(); | ||
final RustEventVerifier rustEventVerifier = RustEventVerifier(); | ||
|
||
|
||
return rustEventVerifier; | ||
}); | ||
|
||
/// This mock verifier returns a fixed result, controlled by the constructor. | ||
class MockEventVerifier implements EventVerifier { | ||
bool _result = true; | ||
|
||
/// If [result] is false, [verify] will always return false. Default is true. | ||
|
||
/// The result parameter controls whether verify always returns true or false. | ||
MockEventVerifier({bool result = true}) { | ||
_result = result; | ||
_result = result; | ||
} | ||
|
||
/// Verifies the event, returning a fixed result. | ||
@override | ||
Future<bool> verify(ndk_entities.Nip01Event event) async { | ||
return _result; | ||
return _result; // Return the mock result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters