update OrdinalsInterface to not need baseUrl declared by withee classes

This commit is contained in:
sneurlax 2023-07-19 15:58:26 -05:00
parent 8e17556e41
commit bc8f5ce8f9
2 changed files with 18 additions and 7 deletions

View file

@ -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<FeedResponse> fetchLatestInscriptions(OrdinalsAPI ordinalsAPI) async {
final OrdinalsAPI ordinalsAPI = OrdinalsAPI(baseUrl: 'http://ord-litecoin.stackwallet.com');
Future<FeedResponse> fetchLatestInscriptions() async {
try {
final feedResponse = await ordinalsAPI.getLatestInscriptions();
// Process the feedResponse data as needed

View file

@ -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<OrdinalsResponse> _getResponse(String endpoint) async {
final response = await http.get(Uri.parse('$baseUrl$endpoint'));