mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
add address endpoint
This commit is contained in:
parent
48e4f8c577
commit
f972c34dc4
3 changed files with 25 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'package:stackwallet/dto/ordinals/inscription_response.dart';
|
||||||
|
|
||||||
class AddressResponse {
|
class AddressResponse {
|
||||||
final AddressLinks links;
|
final AddressLinks links;
|
||||||
final String address;
|
final String address;
|
||||||
|
@ -12,12 +14,12 @@ class AddressResponse {
|
||||||
factory AddressResponse.fromJson(Map<String, dynamic> json) {
|
factory AddressResponse.fromJson(Map<String, dynamic> json) {
|
||||||
final inscriptionsJson = json['inscriptions'] as List;
|
final inscriptionsJson = json['inscriptions'] as List;
|
||||||
final inscriptions = inscriptionsJson
|
final inscriptions = inscriptionsJson
|
||||||
.map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson))
|
.map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return AddressResponse(
|
return AddressResponse(
|
||||||
links: AddressLinks.fromJson(json['_links']),
|
links: AddressLinks.fromJson(json['_links'] as Map<String, dynamic>),
|
||||||
address: json['address'],
|
address: json['address'] as String,
|
||||||
inscriptions: inscriptions,
|
inscriptions: inscriptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +34,7 @@ class AddressLinks {
|
||||||
|
|
||||||
factory AddressLinks.fromJson(Map<String, dynamic> json) {
|
factory AddressLinks.fromJson(Map<String, dynamic> json) {
|
||||||
return AddressLinks(
|
return AddressLinks(
|
||||||
self: AddressLink.fromJson(json['self']),
|
self: AddressLink.fromJson(json['self'] as Map<String, dynamic>),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +45,17 @@ class AddressLink {
|
||||||
AddressLink({required this.href});
|
AddressLink({required this.href});
|
||||||
|
|
||||||
factory AddressLink.fromJson(Map<String, dynamic> json) {
|
factory AddressLink.fromJson(Map<String, dynamic> json) {
|
||||||
return AddressLink(href: json['href']);
|
return AddressLink(href: json['href'] as String);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InscriptionLink {
|
||||||
|
final String href;
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
InscriptionLink(this.href, this.title);
|
||||||
|
|
||||||
|
factory InscriptionLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InscriptionLink(json['href'] as String, json['title'] as String);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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/transaction_response.dart';
|
||||||
import 'package:stackwallet/dto/ordinals/output_response.dart';
|
import 'package:stackwallet/dto/ordinals/output_response.dart';
|
||||||
|
import 'package:stackwallet/dto/ordinals/address_response.dart';
|
||||||
|
|
||||||
class OrdinalsAPI {
|
class OrdinalsAPI {
|
||||||
final String baseUrl;
|
final String baseUrl;
|
||||||
|
@ -54,4 +55,9 @@ class OrdinalsAPI {
|
||||||
final response = await _getResponse('/output/$transactionId');
|
final response = await _getResponse('/output/$transactionId');
|
||||||
return OutputResponse.fromJson(response);
|
return OutputResponse.fromJson(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<AddressResponse> getInscriptionsByAddress(String address) async {
|
||||||
|
final response = await _getResponse('/address/$address');
|
||||||
|
return AddressResponse.fromJson(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue