add output endpoint

This commit is contained in:
sneurlax 2023-07-19 10:45:18 -05:00
parent 828782f00c
commit 48e4f8c577
2 changed files with 21 additions and 7 deletions

View file

@ -1,3 +1,5 @@
import 'package:stackwallet/dto/ordinals/transaction_response.dart';
class OutputResponse { class OutputResponse {
final OutputLinks links; final OutputLinks links;
final String address; final String address;
@ -15,11 +17,11 @@ class OutputResponse {
factory OutputResponse.fromJson(Map<String, dynamic> json) { factory OutputResponse.fromJson(Map<String, dynamic> json) {
return OutputResponse( return OutputResponse(
links: OutputLinks.fromJson(json['_links']), links: OutputLinks.fromJson(json['_links'] as Map<String, dynamic>),
address: json['address'], address: json['address'] as String,
scriptPubkey: json['script_pubkey'], scriptPubkey: json['script_pubkey'] as String,
transaction: json['transaction'], transaction: json['transaction'] as String,
value: json['value'], value: json['value'] as int,
); );
} }
} }
@ -35,8 +37,8 @@ class OutputLinks {
factory OutputLinks.fromJson(Map<String, dynamic> json) { factory OutputLinks.fromJson(Map<String, dynamic> json) {
return OutputLinks( return OutputLinks(
self: OutputLink.fromJson(json['self']), self: OutputLink.fromJson(json['self'] as Map<String, dynamic>),
transaction: TransactionLink.fromJson(json['transaction']), transaction: TransactionLink.fromJson(json['transaction'] as Map<String, dynamic>),
); );
} }
} }

View file

@ -4,6 +4,8 @@ import 'package:http/http.dart' as http;
import 'package:stackwallet/dto/ordinals/feed_response.dart'; import 'package:stackwallet/dto/ordinals/feed_response.dart';
import 'package:stackwallet/dto/ordinals/inscription_response.dart'; import 'package:stackwallet/dto/ordinals/inscription_response.dart';
import 'package:stackwallet/dto/ordinals/sat_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';
class OrdinalsAPI { class OrdinalsAPI {
final String baseUrl; final String baseUrl;
@ -42,4 +44,14 @@ class OrdinalsAPI {
final response = await _getResponse('/sat/$satNumber'); final response = await _getResponse('/sat/$satNumber');
return SatResponse.fromJson(response); return SatResponse.fromJson(response);
} }
Future<TransactionResponse> getTransaction(String transactionId) async {
final response = await _getResponse('/tx/$transactionId');
return TransactionResponse.fromJson(response);
}
Future<OutputResponse> getTransactionOutputs(String transactionId) async {
final response = await _getResponse('/output/$transactionId');
return OutputResponse.fromJson(response);
}
} }