diff --git a/lib/dto/ordinals/address_response.dart b/lib/dto/ordinals/address_response.dart index 7932d8ec7..5c1f66323 100644 --- a/lib/dto/ordinals/address_response.dart +++ b/lib/dto/ordinals/address_response.dart @@ -1,4 +1,4 @@ -import 'package:stackwallet/dto/ordinals/inscription_response.dart'; +import 'package:stackwallet/dto/ordinals/inscription_link.dart'; class AddressResponse { final AddressLinks links; @@ -48,14 +48,3 @@ class AddressLink { return AddressLink(href: json['href'] as String); } } - -class InscriptionLink { - final String href; - final String title; - - InscriptionLink(this.href, this.title); - - factory InscriptionLink.fromJson(Map json) { - return InscriptionLink(json['href'] as String, json['title'] as String); - } -} diff --git a/lib/dto/ordinals/feed_response.dart b/lib/dto/ordinals/feed_response.dart index d958fbe4c..e29d2d334 100644 --- a/lib/dto/ordinals/feed_response.dart +++ b/lib/dto/ordinals/feed_response.dart @@ -1,3 +1,5 @@ +import 'package:stackwallet/dto/ordinals/inscription_link.dart'; + class FeedResponse { final List inscriptions; @@ -12,17 +14,3 @@ class FeedResponse { return FeedResponse(inscriptions: inscriptions); } } - -class InscriptionLink { - final String href; - final String title; - - InscriptionLink({required this.href, required this.title}); - - factory InscriptionLink.fromJson(Map json) { - return InscriptionLink( - href: json['href'] as String ?? '', - title: json['title'] as String ?? '', - ); - } -} diff --git a/lib/dto/ordinals/inscription_link.dart b/lib/dto/ordinals/inscription_link.dart new file mode 100644 index 000000000..f23b63248 --- /dev/null +++ b/lib/dto/ordinals/inscription_link.dart @@ -0,0 +1,13 @@ +class InscriptionLink { + final String href; + final String title; + + InscriptionLink({required this.href, required this.title}); + + factory InscriptionLink.fromJson(Map json) { + return InscriptionLink( + href: json['href'] as String ?? '', + title: json['title'] as String ?? '', + ); + } +} diff --git a/lib/dto/ordinals/transaction_response.dart b/lib/dto/ordinals/transaction_response.dart index b030a1daa..11912a3ad 100644 --- a/lib/dto/ordinals/transaction_response.dart +++ b/lib/dto/ordinals/transaction_response.dart @@ -1,3 +1,5 @@ +import 'package:stackwallet/dto/ordinals/inscription_link.dart'; + class TransactionResponse { final TransactionLinks links; final List inputs; @@ -18,21 +20,21 @@ class TransactionResponse { factory TransactionResponse.fromJson(Map json) { final inputsJson = json['_links']['inputs'] as List; final inputs = inputsJson - .map((inputJson) => OutputLink.fromJson(inputJson)) + .map((inputJson) => OutputLink.fromJson(inputJson as Map)) .toList(); final outputsJson = json['_links']['outputs'] as List; final outputs = outputsJson - .map((outputJson) => OutputLink.fromJson(outputJson)) + .map((outputJson) => OutputLink.fromJson(outputJson as Map)) .toList(); return TransactionResponse( - links: TransactionLinks.fromJson(json['_links']), + links: TransactionLinks.fromJson(json['_links'] as Map), inputs: inputs, - inscription: InscriptionLink.fromJson(json['_links']['inscription']), + inscription: InscriptionLink.fromJson(json['_links']['inscription'] as Map), outputs: outputs, - self: TransactionLink.fromJson(json['_links']['self']), - transaction: json['transaction'], + self: TransactionLink.fromJson(json['_links']['self'] as Map), + transaction: json['transaction'] as String, ); } } @@ -50,9 +52,9 @@ class TransactionLinks { factory TransactionLinks.fromJson(Map json) { return TransactionLinks( - block: TransactionLink.fromJson(json['block']), - inscription: InscriptionLink.fromJson(json['inscription']), - self: TransactionLink.fromJson(json['self']), + block: TransactionLink.fromJson(json['block'] as Map), + inscription: InscriptionLink.fromJson(json['inscription'] as Map), + self: TransactionLink.fromJson(json['self'] as Map), ); } } @@ -63,7 +65,7 @@ class TransactionLink { TransactionLink({required this.href}); factory TransactionLink.fromJson(Map json) { - return TransactionLink(href: json['href']); + return TransactionLink(href: json['href'] as String); } } @@ -73,6 +75,6 @@ class OutputLink { OutputLink({required this.href}); factory OutputLink.fromJson(Map json) { - return OutputLink(href: json['href']); + return OutputLink(href: json['href'] as String); } }