mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
add dtos for ord-litecoin documented endpoint responses
This commit is contained in:
parent
5b4a803215
commit
b60e3fbf1b
9 changed files with 455 additions and 0 deletions
48
lib/dto/ordinals/address_response.dart
Normal file
48
lib/dto/ordinals/address_response.dart
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return AddressResponse(
|
||||||
|
links: AddressLinks.fromJson(json['_links']),
|
||||||
|
address: json['address'],
|
||||||
|
inscriptions: inscriptions,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddressLinks {
|
||||||
|
final AddressLink? self;
|
||||||
|
|
||||||
|
AddressLinks({
|
||||||
|
this.self,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory AddressLinks.fromJson(Map<String, dynamic> json) {
|
||||||
|
return AddressLinks(
|
||||||
|
self: AddressLink.fromJson(json['self']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddressLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
AddressLink({required this.href});
|
||||||
|
|
||||||
|
factory AddressLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return AddressLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
58
lib/dto/ordinals/block_response.dart
Normal file
58
lib/dto/ordinals/block_response.dart
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
class BlockResponse {
|
||||||
|
final BlockLinks links;
|
||||||
|
final String hash;
|
||||||
|
final String previousBlockhash;
|
||||||
|
final int size;
|
||||||
|
final String target;
|
||||||
|
final String timestamp;
|
||||||
|
final int weight;
|
||||||
|
|
||||||
|
BlockResponse({
|
||||||
|
required this.links,
|
||||||
|
required this.hash,
|
||||||
|
required this.previousBlockhash,
|
||||||
|
required this.size,
|
||||||
|
required this.target,
|
||||||
|
required this.timestamp,
|
||||||
|
required this.weight,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BlockResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BlockResponse(
|
||||||
|
links: BlockLinks.fromJson(json['_links']),
|
||||||
|
hash: json['hash'],
|
||||||
|
previousBlockhash: json['previous_blockhash'],
|
||||||
|
size: json['size'],
|
||||||
|
target: json['target'],
|
||||||
|
timestamp: json['timestamp'],
|
||||||
|
weight: json['weight'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BlockLinks {
|
||||||
|
final BlockLink? prev;
|
||||||
|
final BlockLink? self;
|
||||||
|
|
||||||
|
BlockLinks({
|
||||||
|
this.prev,
|
||||||
|
this.self,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory BlockLinks.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BlockLinks(
|
||||||
|
prev: BlockLink.fromJson(json['prev']),
|
||||||
|
self: BlockLink.fromJson(json['self']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class BlockLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
BlockLink({required this.href});
|
||||||
|
|
||||||
|
factory BlockLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return BlockLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
19
lib/dto/ordinals/content_response.dart
Normal file
19
lib/dto/ordinals/content_response.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class ContentResponse {
|
||||||
|
final FileLink fileLink;
|
||||||
|
|
||||||
|
ContentResponse({required this.fileLink});
|
||||||
|
|
||||||
|
factory ContentResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return ContentResponse(fileLink: FileLink.fromJson(json['_links']['file']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
FileLink({required this.href});
|
||||||
|
|
||||||
|
factory FileLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return FileLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
14
lib/dto/ordinals/feed_response.dart
Normal file
14
lib/dto/ordinals/feed_response.dart
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class FeedResponse {
|
||||||
|
final List<InscriptionLink> inscriptions;
|
||||||
|
|
||||||
|
FeedResponse(this.inscriptions);
|
||||||
|
|
||||||
|
factory FeedResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
final inscriptionsJson = json['_links']['inscriptions'] as List;
|
||||||
|
final inscriptions = inscriptionsJson
|
||||||
|
.map((inscriptionJson) => InscriptionLink.fromJson(inscriptionJson))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return FeedResponse(inscriptions);
|
||||||
|
}
|
||||||
|
}
|
95
lib/dto/ordinals/inscription_response.dart
Normal file
95
lib/dto/ordinals/inscription_response.dart
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
class InscriptionResponse {
|
||||||
|
final InscriptionLinks links;
|
||||||
|
final String address;
|
||||||
|
final int contentLength;
|
||||||
|
final String contentType;
|
||||||
|
final int genesisFee;
|
||||||
|
final int genesisHeight;
|
||||||
|
final String genesisTransaction;
|
||||||
|
final String location;
|
||||||
|
final int number;
|
||||||
|
final int offset;
|
||||||
|
final String output;
|
||||||
|
final dynamic sat; // Change to appropriate type if available
|
||||||
|
final String timestamp;
|
||||||
|
|
||||||
|
InscriptionResponse({
|
||||||
|
required this.links,
|
||||||
|
required this.address,
|
||||||
|
required this.contentLength,
|
||||||
|
required this.contentType,
|
||||||
|
required this.genesisFee,
|
||||||
|
required this.genesisHeight,
|
||||||
|
required this.genesisTransaction,
|
||||||
|
required this.location,
|
||||||
|
required this.number,
|
||||||
|
required this.offset,
|
||||||
|
required this.output,
|
||||||
|
required this.sat,
|
||||||
|
required this.timestamp,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory InscriptionResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InscriptionResponse(
|
||||||
|
links: InscriptionLinks.fromJson(json['_links']),
|
||||||
|
address: json['address'],
|
||||||
|
contentLength: json['content_length'],
|
||||||
|
contentType: json['content_type'],
|
||||||
|
genesisFee: json['genesis_fee'],
|
||||||
|
genesisHeight: json['genesis_height'],
|
||||||
|
genesisTransaction: json['genesis_transaction'],
|
||||||
|
location: json['location'],
|
||||||
|
number: json['number'],
|
||||||
|
offset: json['offset'],
|
||||||
|
output: json['output'],
|
||||||
|
sat: json['sat'],
|
||||||
|
timestamp: json['timestamp'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InscriptionLinks {
|
||||||
|
final InscriptionLink? content;
|
||||||
|
final InscriptionLink? genesisTransaction;
|
||||||
|
final InscriptionLink? next;
|
||||||
|
final InscriptionLink? output;
|
||||||
|
final InscriptionLink? prev;
|
||||||
|
final InscriptionLink? preview;
|
||||||
|
final InscriptionLink? sat;
|
||||||
|
final InscriptionLink? self;
|
||||||
|
|
||||||
|
InscriptionLinks({
|
||||||
|
this.content,
|
||||||
|
this.genesisTransaction,
|
||||||
|
this.next,
|
||||||
|
this.output,
|
||||||
|
this.prev,
|
||||||
|
this.preview,
|
||||||
|
this.sat,
|
||||||
|
this.self,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory InscriptionLinks.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InscriptionLinks(
|
||||||
|
content: InscriptionLink.fromJson(json['content']),
|
||||||
|
genesisTransaction: InscriptionLink.fromJson(json['genesis_transaction']),
|
||||||
|
next: InscriptionLink.fromJson(json['next']),
|
||||||
|
output: InscriptionLink.fromJson(json['output']),
|
||||||
|
prev: InscriptionLink.fromJson(json['prev']),
|
||||||
|
preview: InscriptionLink.fromJson(json['preview']),
|
||||||
|
sat: InscriptionLink.fromJson(json['sat']),
|
||||||
|
self: InscriptionLink.fromJson(json['self']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InscriptionLink {
|
||||||
|
final String href;
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
InscriptionLink({required this.href, required this.title});
|
||||||
|
|
||||||
|
factory InscriptionLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return InscriptionLink(href: json['href'], title: json['title']);
|
||||||
|
}
|
||||||
|
}
|
42
lib/dto/ordinals/output_response
Normal file
42
lib/dto/ordinals/output_response
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
class OutputResponse {
|
||||||
|
final OutputLinks links;
|
||||||
|
final String address;
|
||||||
|
final String scriptPubkey;
|
||||||
|
final String transaction;
|
||||||
|
final int value;
|
||||||
|
|
||||||
|
OutputResponse({
|
||||||
|
required this.links,
|
||||||
|
required this.address,
|
||||||
|
required this.scriptPubkey,
|
||||||
|
required this.transaction,
|
||||||
|
required this.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OutputResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OutputResponse(
|
||||||
|
links: OutputLinks.fromJson(json['_links']),
|
||||||
|
address: json['address'],
|
||||||
|
scriptPubkey: json['script_pubkey'],
|
||||||
|
transaction: json['transaction'],
|
||||||
|
value: json['value'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OutputLinks {
|
||||||
|
final OutputLink? self;
|
||||||
|
final TransactionLink? transaction;
|
||||||
|
|
||||||
|
OutputLinks({
|
||||||
|
this.self,
|
||||||
|
this.transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OutputLinks.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OutputLinks(
|
||||||
|
self: OutputLink.fromJson(json['self']),
|
||||||
|
transaction: TransactionLink.fromJson(json['transaction']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
19
lib/dto/ordinals/preview_response.dart
Normal file
19
lib/dto/ordinals/preview_response.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class PreviewResponse {
|
||||||
|
final ImageLink imageLink;
|
||||||
|
|
||||||
|
PreviewResponse({required this.imageLink});
|
||||||
|
|
||||||
|
factory PreviewResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
return PreviewResponse(imageLink: ImageLink.fromJson(json['_links']['image']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ImageLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
ImageLink({required this.href});
|
||||||
|
|
||||||
|
factory ImageLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return ImageLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
82
lib/dto/ordinals/sat_response.dart
Normal file
82
lib/dto/ordinals/sat_response.dart
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
class SatResponse {
|
||||||
|
final SatLinks links;
|
||||||
|
final int block;
|
||||||
|
final int cycle;
|
||||||
|
final String decimal;
|
||||||
|
final String degree;
|
||||||
|
final int epoch;
|
||||||
|
final String name;
|
||||||
|
final int offset;
|
||||||
|
final String percentile;
|
||||||
|
final int period;
|
||||||
|
final String rarity;
|
||||||
|
final String timestamp;
|
||||||
|
|
||||||
|
SatResponse({
|
||||||
|
required this.links,
|
||||||
|
required this.block,
|
||||||
|
required this.cycle,
|
||||||
|
required this.decimal,
|
||||||
|
required this.degree,
|
||||||
|
required this.epoch,
|
||||||
|
required this.name,
|
||||||
|
required this.offset,
|
||||||
|
required this.percentile,
|
||||||
|
required this.period,
|
||||||
|
required this.rarity,
|
||||||
|
required this.timestamp,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory SatResponse.fromJson(Map<String, dynamic> 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'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SatLinks {
|
||||||
|
final SatLink? block;
|
||||||
|
final SatLink? inscription;
|
||||||
|
final SatLink? next;
|
||||||
|
final SatLink? prev;
|
||||||
|
final SatLink? self;
|
||||||
|
|
||||||
|
SatLinks({
|
||||||
|
this.block,
|
||||||
|
this.inscription,
|
||||||
|
this.next,
|
||||||
|
this.prev,
|
||||||
|
this.self,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory SatLinks.fromJson(Map<String, dynamic> 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']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SatLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
SatLink({required this.href});
|
||||||
|
|
||||||
|
factory SatLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return SatLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
78
lib/dto/ordinals/transaction_response.dart
Normal file
78
lib/dto/ordinals/transaction_response.dart
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
class TransactionResponse {
|
||||||
|
final TransactionLinks links;
|
||||||
|
final List<OutputLink> inputs;
|
||||||
|
final InscriptionLink inscription;
|
||||||
|
final List<OutputLink> outputs;
|
||||||
|
final TransactionLink self;
|
||||||
|
final String transaction;
|
||||||
|
|
||||||
|
TransactionResponse({
|
||||||
|
required this.links,
|
||||||
|
required this.inputs,
|
||||||
|
required this.inscription,
|
||||||
|
required this.outputs,
|
||||||
|
required this.self,
|
||||||
|
required this.transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory TransactionResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
final inputsJson = json['_links']['inputs'] as List;
|
||||||
|
final inputs = inputsJson
|
||||||
|
.map((inputJson) => OutputLink.fromJson(inputJson))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final outputsJson = json['_links']['outputs'] as List;
|
||||||
|
final outputs = outputsJson
|
||||||
|
.map((outputJson) => OutputLink.fromJson(outputJson))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return TransactionResponse(
|
||||||
|
links: TransactionLinks.fromJson(json['_links']),
|
||||||
|
inputs: inputs,
|
||||||
|
inscription: InscriptionLink.fromJson(json['_links']['inscription']),
|
||||||
|
outputs: outputs,
|
||||||
|
self: TransactionLink.fromJson(json['_links']['self']),
|
||||||
|
transaction: json['transaction'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TransactionLinks {
|
||||||
|
final TransactionLink? block;
|
||||||
|
final InscriptionLink? inscription;
|
||||||
|
final TransactionLink? self;
|
||||||
|
|
||||||
|
TransactionLinks({
|
||||||
|
this.block,
|
||||||
|
this.inscription,
|
||||||
|
this.self,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory TransactionLinks.fromJson(Map<String, dynamic> json) {
|
||||||
|
return TransactionLinks(
|
||||||
|
block: TransactionLink.fromJson(json['block']),
|
||||||
|
inscription: InscriptionLink.fromJson(json['inscription']),
|
||||||
|
self: TransactionLink.fromJson(json['self']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TransactionLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
TransactionLink({required this.href});
|
||||||
|
|
||||||
|
factory TransactionLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return TransactionLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OutputLink {
|
||||||
|
final String href;
|
||||||
|
|
||||||
|
OutputLink({required this.href});
|
||||||
|
|
||||||
|
factory OutputLink.fromJson(Map<String, dynamic> json) {
|
||||||
|
return OutputLink(href: json['href']);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue