fetchUtxosOfScript method
Implementation
Future<Map<String, dynamic>> fetchUtxosOfScript({
required String script,
int pageSize = 100,
String? cursor,
int? amount,
}) async {
final QueryOptions options = QueryOptions(
document: gql(getUtxosOfScriptQuery),
variables: <String, dynamic>{
'script': script,
'pageSize': pageSize,
'cursor': cursor,
if (amount != null) 'amount': amount,
},
);
final QueryResult result = await _client.query(options);
if (result.hasException) {
printIfDebug(result.exception.toString());
throw Exception('Unexpected error happened in graphql request');
}
final pageInfo = result.data!['utxosOfScript']['pageInfo'];
final edges = result.data!['utxosOfScript']['edges'];
final endCursor = pageInfo['endCursor'];
final hasNextPage = pageInfo['hasNextPage'];
return {
'utxos': edges.map((e) => e['node']).toList(),
'endCursor': endCursor,
'hasNextPage': hasNextPage,
};
}