mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
working proof of concept
This commit is contained in:
parent
4db0328c73
commit
b773811eac
3 changed files with 17 additions and 11 deletions
|
@ -15,8 +15,6 @@ import 'package:stackwallet/models/ordinal.dart';
|
|||
import 'package:stackwallet/pages/ordinals/ordinals_filter_view.dart';
|
||||
import 'package:stackwallet/pages/ordinals/widgets/ordinals_list.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
// import 'package:stackwallet/services/litescribe_api.dart';
|
||||
// import 'package:stackwallet/services/ordinals_api.dart';
|
||||
import 'package:stackwallet/services/mixins/ordinals_interface.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -29,7 +27,6 @@ import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
|||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||
|
||||
|
||||
class OrdinalsView extends ConsumerStatefulWidget {
|
||||
const OrdinalsView({
|
||||
super.key,
|
||||
|
@ -44,7 +41,7 @@ class OrdinalsView extends ConsumerStatefulWidget {
|
|||
ConsumerState<OrdinalsView> createState() => _OrdinalsViewState();
|
||||
}
|
||||
|
||||
class _OrdinalsViewState extends ConsumerState<OrdinalsView> with OrdinalsInterface {
|
||||
class _OrdinalsViewState extends ConsumerState<OrdinalsView> {
|
||||
late final TextEditingController searchController;
|
||||
late final FocusNode searchFocus;
|
||||
|
||||
|
@ -94,7 +91,10 @@ class _OrdinalsViewState extends ConsumerState<OrdinalsView> with OrdinalsInterf
|
|||
.topNavIconPrimary,
|
||||
),
|
||||
onPressed: () async {
|
||||
refreshInscriptions();
|
||||
final manager = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManager(widget.walletId)));
|
||||
|
||||
(manager.wallet as OrdinalsInterface).refreshInscriptions();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
@ -42,7 +42,7 @@ class LitescribeAPI {
|
|||
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'] as List<InscriptionData>;
|
||||
final list = response.data['result']['list'];
|
||||
final int total = response.data['result']['total'] as int;
|
||||
final int currentSize = list.length;
|
||||
|
||||
|
@ -51,10 +51,15 @@ 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);
|
||||
// TODO test logic with smaller size "pagination"
|
||||
|
||||
} else {
|
||||
try {
|
||||
return list;
|
||||
// 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>))
|
||||
.toList();
|
||||
|
||||
return inscriptions;
|
||||
} catch (e) {
|
||||
throw const FormatException('LitescribeAPI getInscriptionsByAddress exception: AddressInscriptionResponse.fromJson failure');
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/isar/main_db.dart';
|
||||
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
|
||||
|
@ -18,7 +20,6 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|||
import 'package:stackwallet/services/litescribe_api.dart';
|
||||
import 'package:stackwallet/dto/ordinals/inscription_data.dart';
|
||||
|
||||
|
||||
mixin OrdinalsInterface {
|
||||
late final String _walletId;
|
||||
late final Coin _coin;
|
||||
|
@ -50,7 +51,7 @@ mixin OrdinalsInterface {
|
|||
List<dynamic> _inscriptions;
|
||||
final utxos = await _db.getUTXOs(_walletId).findAll();
|
||||
final uniqueAddresses = getUniqueAddressesFromUTXOs(utxos);
|
||||
_inscriptions = await getAllInscriptionsFromAddresses(uniqueAddresses);
|
||||
_inscriptions = await getInscriptionsFromAddresses(uniqueAddresses);
|
||||
// TODO save inscriptions to isar which gets watched by a StreamBuilder
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ mixin OrdinalsInterface {
|
|||
return uniqueAddresses.toList();
|
||||
}
|
||||
|
||||
Future<List<InscriptionData>> getAllInscriptionsFromAddresses(List<String> addresses) async {
|
||||
Future<List<InscriptionData>> getInscriptionsFromAddresses(List<String> addresses) async {
|
||||
List<InscriptionData> allInscriptions = [];
|
||||
for (String address in addresses) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue