From bc8f5ce8f93ba2d7163a7d47878c92522314ca69 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 19 Jul 2023 15:58:26 -0500 Subject: [PATCH] update OrdinalsInterface to not need baseUrl declared by withee classes --- lib/services/mixins/ordinals_interface.dart | 10 ++++++---- lib/services/ordinals_api.dart | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/services/mixins/ordinals_interface.dart b/lib/services/mixins/ordinals_interface.dart index 57a76fbd6..1ab157b2c 100644 --- a/lib/services/mixins/ordinals_interface.dart +++ b/lib/services/mixins/ordinals_interface.dart @@ -1,8 +1,10 @@ -import 'package:stackwallet/services/ordinals_api.dart'; -import 'package:stackwallet/dto/ordinals/feed_response.dart'; +import 'package:stackwallet/dto/ordinals/feed_response.dart'; // Assuming this import is necessary +import 'package:stackwallet/services/ordinals_api.dart'; // Assuming this import is necessary mixin OrdinalsInterface { - Future fetchLatestInscriptions(OrdinalsAPI ordinalsAPI) async { + final OrdinalsAPI ordinalsAPI = OrdinalsAPI(baseUrl: 'http://ord-litecoin.stackwallet.com'); + + Future fetchLatestInscriptions() async { try { final feedResponse = await ordinalsAPI.getLatestInscriptions(); // Process the feedResponse data as needed @@ -16,4 +18,4 @@ mixin OrdinalsInterface { throw Exception('Error in OrdinalsInterface: $e'); } } -} +} \ No newline at end of file diff --git a/lib/services/ordinals_api.dart b/lib/services/ordinals_api.dart index e9d734203..c1d3aad94 100644 --- a/lib/services/ordinals_api.dart +++ b/lib/services/ordinals_api.dart @@ -12,10 +12,19 @@ import 'package:stackwallet/dto/ordinals/block_response.dart'; import 'package:stackwallet/dto/ordinals/content_response.dart'; import 'package:stackwallet/dto/ordinals/preview_response.dart'; -class OrdinalsAPI { - final String baseUrl; +import 'package:stackwallet/dto/ordinals/feed_response.dart'; // Assuming this import is necessary - OrdinalsAPI({required this.baseUrl}); +class OrdinalsAPI { + static final OrdinalsAPI _instance = OrdinalsAPI._internal(); + + factory OrdinalsAPI({required String baseUrl}) { + _instance.baseUrl = baseUrl; + return _instance; + } + + OrdinalsAPI._internal(); + + late String baseUrl; Future _getResponse(String endpoint) async { final response = await http.get(Uri.parse('$baseUrl$endpoint'));