diff --git a/lib/dto/ordinals/sat_response.dart b/lib/dto/ordinals/sat_response.dart index 0f88918f3..b57ccb3cf 100644 --- a/lib/dto/ordinals/sat_response.dart +++ b/lib/dto/ordinals/sat_response.dart @@ -29,18 +29,18 @@ class SatResponse { factory SatResponse.fromJson(Map json) { return SatResponse( - links: SatLinks.fromJson(json['_links']), - block: json['block'], - cycle: json['cycle'], - decimal: json['decimal'], - degree: json['degree'], - epoch: json['epoch'], - name: json['name'], - offset: json['offset'], - percentile: json['percentile'], - period: json['period'], - rarity: json['rarity'], - timestamp: json['timestamp'], + links: SatLinks.fromJson(json['_links'] as Map), + block: json['block'] as int, + cycle: json['cycle'] as int, + decimal: json['decimal'] as String, + degree: json['degree'] as String, + epoch: json['epoch'] as int, + name: json['name'] as String, + offset: json['offset'] as int, + percentile: json['percentile'] as String, + period: json['period'] as int, + rarity: json['rarity'] as String, + timestamp: json['timestamp'] as String, ); } } @@ -62,11 +62,11 @@ class SatLinks { factory SatLinks.fromJson(Map json) { return SatLinks( - block: SatLink.fromJson(json['block']), - inscription: SatLink.fromJson(json['inscription']), - next: SatLink.fromJson(json['next']), - prev: SatLink.fromJson(json['prev']), - self: SatLink.fromJson(json['self']), + block: SatLink.fromJson(json['block'] as Map), + inscription: SatLink.fromJson(json['inscription'] as Map), + next: SatLink.fromJson(json['next'] as Map), + prev: SatLink.fromJson(json['prev'] as Map), + self: SatLink.fromJson(json['self'] as Map), ); } } @@ -77,6 +77,6 @@ class SatLink { SatLink({required this.href}); factory SatLink.fromJson(Map json) { - return SatLink(href: json['href']); + return SatLink(href: json['href'] as String); } } diff --git a/lib/services/ordinals_api.dart b/lib/services/ordinals_api.dart index a966988d7..264223f8a 100644 --- a/lib/services/ordinals_api.dart +++ b/lib/services/ordinals_api.dart @@ -3,6 +3,7 @@ import 'package:http/http.dart' as http; import 'package:stackwallet/dto/ordinals/feed_response.dart'; import 'package:stackwallet/dto/ordinals/inscription_response.dart'; +import 'package:stackwallet/dto/ordinals/sat_response.dart'; class OrdinalsAPI { final String baseUrl; @@ -36,4 +37,9 @@ class OrdinalsAPI { final response = await _getResponse('/inscription/$inscriptionId'); return InscriptionResponse.fromJson(response); } + + Future getSatDetails(int satNumber) async { + final response = await _getResponse('/sat/$satNumber'); + return SatResponse.fromJson(response); + } }