export async function fetchAddressTransactions(
address: string,
parameters?: string,
chainId?: number,
): Promise<AddressTransactionsBlockscout> {
const chainProvider: string = getChainProviderBlockscout(chainId);
let query: string = '';
if (parameters) {
query =
https://${chainProvider}/api/v2/addresses/${address}/transactions?${parameters}
;
}
if (!parameters) {
query =
https://${chainProvider}/api/v2/addresses/${address}/transactions
;
}
const response: Response = await fetch(query);
const body = (await response.json()) as AddressTransactionsBlockscout;
if (body) return body;
throw new Error('no transactions');
}
const transactions = await fetchAddressTransactions(
'0x398eC7346DcD622eDc5ae82352F02bE94C62d119',
);
const array1: string[] = [];
const map1 = transactions?.items?.map((x) => {
array1.push(x.hash);
});
console.log([...new Set(array1)].length);
const transactionsSecondPage = await fetchAddressTransactions(
'0x398eC7346DcD622eDc5ae82352F02bE94C62d119',
?block_number=${transactions?.next_page_params?.block_number}&index=${transactions?.next_page_params?.index}&items_count=${transactions?.next_page_params?.items_count}
,
);
const array2: string[] = [];
const map2 = transactionsSecondPage?.items?.map((x) => {
array2.push(x.hash);
});
console.log([...new Set(array2)].length);
console.log([...new Set(array1.concat(array2))].length);
The result is that there are 20 duplicate entries