mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +00:00
autoformatting
This commit is contained in:
parent
c584cb862d
commit
c847656ca5
1 changed files with 14 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:stackwallet/dto/ordinals/inscription_data.dart';
|
||||
import 'package:stackwallet/dto/ordinals/litescribe_response.dart';
|
||||
|
||||
|
@ -21,7 +21,8 @@ class LitescribeAPI {
|
|||
if (response.statusCode == 200) {
|
||||
return LitescribeResponse(data: _validateJson(response.body));
|
||||
} else {
|
||||
throw Exception('LitescribeAPI _getResponse exception: Failed to load data');
|
||||
throw Exception(
|
||||
'LitescribeAPI _getResponse exception: Failed to load data');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,16 +31,19 @@ class LitescribeAPI {
|
|||
if (parsed is Map<String, dynamic>) {
|
||||
return parsed;
|
||||
} else {
|
||||
throw const FormatException('LitescribeAPI _validateJson exception: Invalid JSON format');
|
||||
throw const FormatException(
|
||||
'LitescribeAPI _validateJson exception: Invalid JSON format');
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<InscriptionData>> getInscriptionsByAddress(String address, {int cursor = 0, int size = 1000}) async {
|
||||
Future<List<InscriptionData>> getInscriptionsByAddress(String address,
|
||||
{int cursor = 0, int size = 1000}) async {
|
||||
// size param determines how many inscriptions are returned per response
|
||||
// default of 1000 is used to cover most addresses (I assume)
|
||||
// if the total number of inscriptions at the address exceeds the length of the list of inscriptions returned, another call with a higher size is made
|
||||
final int defaultLimit = 1000;
|
||||
final response = await _getResponse('/address/inscriptions?address=$address&cursor=$cursor&size=$size');
|
||||
final response = await _getResponse(
|
||||
'/address/inscriptions?address=$address&cursor=$cursor&size=$size');
|
||||
|
||||
// Check if the number of returned inscriptions equals the limit
|
||||
final list = response.data['result']['list'];
|
||||
|
@ -54,18 +58,19 @@ class LitescribeAPI {
|
|||
// increment the cursor and make the next API call to fetch the remaining inscriptions.
|
||||
final int newCursor = cursor + size;
|
||||
return getInscriptionsByAddress(address, cursor: newCursor, size: size);
|
||||
|
||||
} else {
|
||||
try {
|
||||
// Iterate through the list and create InscriptionData objects from each element
|
||||
final List<InscriptionData> inscriptions = (list as List<dynamic>)
|
||||
.map((json) => InscriptionData.fromJson(json as Map<String, dynamic>))
|
||||
.map((json) =>
|
||||
InscriptionData.fromJson(json as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
return inscriptions;
|
||||
} catch (e) {
|
||||
throw const FormatException('LitescribeAPI getInscriptionsByAddress exception: AddressInscriptionResponse.fromJson failure');
|
||||
throw const FormatException(
|
||||
'LitescribeAPI getInscriptionsByAddress exception: AddressInscriptionResponse.fromJson failure');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue