getTransactions method
Future<(List<SuiTransactionBlockResponse> , String?, String?)>
getTransactions(
- String address, {
- SuiTransactionBlockResponseOptions? options,
- TransactionDigest? filterFromCursor,
- TransactionDigest? filterToCursor,
- int? limit,
- bool descendingOrder = true,
Query Transactions
Implementation
Future<(List<SuiTransactionBlockResponse> data, String?, String?)> getTransactions(
String address, {
SuiTransactionBlockResponseOptions? options,
TransactionDigest? filterFromCursor,
TransactionDigest? filterToCursor,
int? limit,
bool descendingOrder = true,
}) async {
final filterFromAddressQuery = queryTransactionBlocks(
{'FromAddress': address},
options: options,
cursor: filterFromCursor,
limit: limit,
descendingOrder: descendingOrder);
final filterToAddressQuery = queryTransactionBlocks(
{'ToAddress': address},
options: options,
cursor: filterToCursor,
limit: limit,
descendingOrder: descendingOrder);
final result = await Future.wait([filterFromAddressQuery, filterToAddressQuery]);
final fromResult = result[0];
final toResult = result[1];
final txs = fromResult.data;
final nextFromCursor = fromResult.hasNextPage ? fromResult.nextCursor : null;
final nextToCursor = toResult.hasNextPage ? toResult.nextCursor : null;
final digests = txs.isNotEmpty ? txs.map((e) => e.digest).toList() : [];
if (digests.isEmpty) {
return (toResult.data, nextFromCursor, nextToCursor);
}
for (var item in toResult.data) {
if (digests.contains(item.digest)) {
continue;
}
txs.add(item);
}
return (txs, nextFromCursor, nextToCursor);
}