From 0284bb2951e362cc7c76309c0bd7683731e345bd Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 19 Jul 2023 17:13:54 -0500 Subject: [PATCH] use https api, implement other methods --- lib/pages/ordinals/ordinals_view.dart | 2 +- lib/services/mixins/ordinals_interface.dart | 87 +++++++++++++++++++-- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/lib/pages/ordinals/ordinals_view.dart b/lib/pages/ordinals/ordinals_view.dart index 2d051b07a..3dd8b7ae7 100644 --- a/lib/pages/ordinals/ordinals_view.dart +++ b/lib/pages/ordinals/ordinals_view.dart @@ -182,7 +182,7 @@ class _OrdinalsViewState extends ConsumerState with OrdinalsInterf height: 16, ), TextButton(onPressed: () async { - await fetchLatestInscriptions(); + await getTransaction('ed5a5c4e555e204768ec54c049ae0b01c86fdcc8b126a9d100c4dff745e7d3ca'); }, child: Text( "Test", style: STextStyles.navBarTitle(context), diff --git a/lib/services/mixins/ordinals_interface.dart b/lib/services/mixins/ordinals_interface.dart index 1ab157b2c..92974c67d 100644 --- a/lib/services/mixins/ordinals_interface.dart +++ b/lib/services/mixins/ordinals_interface.dart @@ -1,21 +1,94 @@ -import 'package:stackwallet/dto/ordinals/feed_response.dart'; // Assuming this import is necessary +import 'package:stackwallet/dto/ordinals/feed_response.dart'; +import 'package:stackwallet/dto/ordinals/inscription_response.dart'; +import 'package:stackwallet/dto/ordinals/sat_response.dart'; +import 'package:stackwallet/dto/ordinals/transaction_response.dart'; +import 'package:stackwallet/dto/ordinals/output_response.dart'; +import 'package:stackwallet/dto/ordinals/address_response.dart'; +import 'package:stackwallet/dto/ordinals/block_response.dart'; +import 'package:stackwallet/dto/ordinals/content_response.dart'; +import 'package:stackwallet/dto/ordinals/preview_response.dart'; import 'package:stackwallet/services/ordinals_api.dart'; // Assuming this import is necessary mixin OrdinalsInterface { - final OrdinalsAPI ordinalsAPI = OrdinalsAPI(baseUrl: 'http://ord-litecoin.stackwallet.com'); + final OrdinalsAPI ordinalsAPI = OrdinalsAPI(baseUrl: 'https://ord-litecoin.stackwallet.com'); Future fetchLatestInscriptions() async { try { final feedResponse = await ordinalsAPI.getLatestInscriptions(); // Process the feedResponse data as needed - print('Latest Inscriptions:'); - for (var inscription in feedResponse.inscriptions) { - print('Title: ${inscription.title}, Href: ${inscription.href}'); - } + // print('Latest Inscriptions:'); + // for (var inscription in feedResponse.inscriptions) { + // print('Title: ${inscription.title}, Href: ${inscription.href}'); + // } return feedResponse; } catch (e) { // Handle errors - throw Exception('Error in OrdinalsInterface: $e'); + throw Exception('Error in OrdinalsInterface fetchLatestInscriptions: $e'); + } + } + + Future getInscriptionDetails(String inscriptionId) async { + try { + return await ordinalsAPI.getInscriptionDetails(inscriptionId); + } catch (e) { + throw Exception('Error in OrdinalsInterface getInscriptionDetails: $e'); + } + } + + Future getSatDetails(int satNumber) async { + try { + return await ordinalsAPI.getSatDetails(satNumber); + } catch (e) { + throw Exception('Error in OrdinalsInterface getSatDetails: $e'); + } + } + + Future getTransaction(String transactionId) async { + try { + print(1); + return await ordinalsAPI.getTransaction(transactionId); + } catch (e) { + throw Exception('Error in OrdinalsInterface getTransaction: $e'); + } + } + + Future getTransactionOutputs(String transactionId) async { + try { + return await ordinalsAPI.getTransactionOutputs(transactionId); + } catch (e) { + throw Exception('Error in OrdinalsInterface getTransactionOutputs: $e'); + } + } + + Future getInscriptionsByAddress(String address) async { + try { + return await ordinalsAPI.getInscriptionsByAddress(address); + } catch (e) { + throw Exception('Error in OrdinalsInterface getInscriptionsByAddress: $e'); + } + } + + Future getBlock(int blockNumber) async { + try { + return await ordinalsAPI.getBlock(blockNumber); + } catch (e) { + throw Exception('Error in OrdinalsInterface getBlock: $e'); + } + } + + Future getInscriptionContent(String inscriptionId) async { + try { + return await ordinalsAPI.getInscriptionContent(inscriptionId); + } catch (e) { + throw Exception('Error in OrdinalsInterface getInscriptionContent: $e'); + } + } + + Future getInscriptionPreview(String inscriptionId) async { + try { + return await ordinalsAPI.getInscriptionPreview(inscriptionId); + } catch (e) { + throw Exception('Error in OrdinalsInterface getInscriptionPreview: $e'); } } } \ No newline at end of file