getTransactions method
Implementation
Future<Set<TronTransaction>> getTransactions({
required String address,
required CoinEntity token,
int limit = 10,
int? startTimestamp,
int? endTimestamp,
String? type,
String? method,
List<String>? tokens,
}) async {
assert(limit <= 50, "Limit must be less than or equal to 50");
final data = [];
int? totalLength;
for (int i = 0; true; i += limit) {
final endpoint = getTransactionsEndpont(
start: i,
address: address,
limit: limit,
startTimestamp: startTimestamp,
endTimestamp: endTimestamp,
type: type,
method: method,
tokens: tokens,
);
final result = await getCall<JSON>(endpoint);
totalLength ??= result['total'] as int;
final newData = result['data'];
data.addAll(newData);
if (data.length >= totalLength) {
break;
}
}
return {
for (final item in data) TronTransaction.fromJson(item, token, address),
}.whereType<TronTransaction>().toSet();
}