Skip to content

Commit

Permalink
feat(blockscan): add defaults for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI committed Oct 30, 2023
1 parent abad1a0 commit 5a1bc28
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/blockscan/blockscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,22 @@ export class Blockscan {
}

public async query (params: { module: string, action: string, [key: string]: any }) {
params = Object.assign(
{
endblock: '99999999',
sort: 'asc',
offset: '10000',
startblock: '0',
page: '0'
},
params,
{ apikey: this.apiKey }
)

return await retry(async () => {
try {
params = Object.assign(params, { apikey: this.apiKey })

const { data } = await axios.get(this.apiUrl, { params })

if (data.status !== '1') {
throw new Error(typeof data.result === 'string' ? data.result : data.message)
}
Expand Down

0 comments on commit 5a1bc28

Please sign in to comment.