Just playing around with the library at the moment, though I’m not yet using Typescript (shall switch over when I start a new project), but I’ve noticed some quirks while using incomingTransactionsPaginated. Is it my code, or the fact I’m not yet using TS, or both.
-
When trying to fetch transactions from accounts with zero incoming transactions, I can’t seem to get anything returned. Chances are highly likely I’m doing something wrong, but I thought I’d check. If there are transactions, then the subscribe method spits them out as you’d expect.
-
I’m trying to use the pagination to fill an array before sending them to the front end. But each time I do so using the code below, I seem to introduce duplicates. At this point I’ll be blind to my own errors, so please let me know if something looks/smells funny.
transactionsMax
is the maximum I need to display, so I don’t need to fetch more than than from the NIS.
const accountHttp = new AccountHttp();
const preparedAddress = new Address(address);
const pageSize = 100;
const recent = accountHttp.incomingTransactionsPaginated(preparedAddress, {
pageSize
});
let total = [];
recent.subscribe(incoming => {
total = [...total, ...incoming];
console.log(incoming);
if (total.length < transactionsMax && incoming.length === pageSize) {
recent.nextPage();
} else {
socket.send(payload('transactionsRecent', total));
}
});