mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
afbf818ab5
TODO replace casting throughout ordinals DTOs with refactored validation
50 lines
1.2 KiB
Dart
50 lines
1.2 KiB
Dart
import 'package:stackwallet/dto/ordinals/inscription_link.dart';
|
|
|
|
class AddressResponse {
|
|
final AddressLinks links;
|
|
final String address;
|
|
final List<InscriptionLink> inscriptions;
|
|
|
|
AddressResponse({
|
|
required this.links,
|
|
required this.address,
|
|
required this.inscriptions,
|
|
});
|
|
|
|
factory AddressResponse.fromJson(Map<String, dynamic> json) {
|
|
final inscriptionsJson = json['inscriptions'] as List;
|
|
final inscriptions = inscriptionsJson
|
|
.map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson as Map<String, dynamic>))
|
|
.toList();
|
|
|
|
return AddressResponse(
|
|
links: AddressLinks.fromJson(json['_links'] as Map<String, dynamic>),
|
|
address: json['address'] as String,
|
|
inscriptions: inscriptions,
|
|
);
|
|
}
|
|
}
|
|
|
|
class AddressLinks {
|
|
final AddressLink? self;
|
|
|
|
AddressLinks({
|
|
this.self,
|
|
});
|
|
|
|
factory AddressLinks.fromJson(Map<String, dynamic> json) {
|
|
return AddressLinks(
|
|
self: AddressLink.fromJson(json['self'] as Map<String, dynamic>),
|
|
);
|
|
}
|
|
}
|
|
|
|
class AddressLink {
|
|
final String href;
|
|
|
|
AddressLink({required this.href});
|
|
|
|
factory AddressLink.fromJson(Map<String, dynamic> json) {
|
|
return AddressLink(href: json['href'] as String);
|
|
}
|
|
}
|