Skip to content

Commit

Permalink
enhancement: use pagination request for getAssetsForAddress (#2026)
Browse files Browse the repository at this point in the history
Co-authored-by: Tuditi <[email protected]>
  • Loading branch information
nicole-obrien and Tuditi authored Mar 4, 2024
1 parent 799cf53 commit 43e532c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/shared/src/lib/auxiliary/blockscout/api/blockscout.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,14 @@ export class BlockscoutApi extends BaseApi implements IBlockscoutApi {
): Promise<IBlockscoutAsset[]> {
const tokenType = standard.replace('ERC', 'ERC-')
const path = `addresses/${address}/tokens`
const response = await this.get<IPaginationResponse<IBlockscoutAsset>>(path, { type: tokenType })
if (response) {
return (response?.items ?? []).map((asset) => ({
...asset,
token: {
...asset.token,
type: asset.token.type.replace('-', ''),
},
}))
} else {
return []
}
const items = await this.makePaginatedGetRequest<IBlockscoutAsset>(path, { type: tokenType })
return items.map((asset) => ({
...asset,
token: {
...asset.token,
type: asset.token.type.replace('-', ''),
},
}))
}

async getTransactionsForAddress(
Expand Down

0 comments on commit 43e532c

Please sign in to comment.