Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelkrimdev committed Dec 9, 2022
1 parent 4980bba commit 552510f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/module/src/providers/tango.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,20 @@ export class TangoProvider implements IFetcher, ISubmitter {
}

async fetchAssetAddresses(asset: string): Promise<{ address: string; quantity: string }[]> {
const toAddress = (item) => ({
address: item.address,
quantity: item.quantity.toString(),
});

const paginateAddresses = async <T>(cursor = '', addresses: T[] = []): Promise<T[]> => {
const { data, status } = await this._axiosInstance.get(
`assets/${asset}/addresses?size=100&cursor=${cursor}`,
);

if (status === 200)
return data.cursor !== null && data.cursor?.length > 0
? paginateAddresses(data.cursor, [...addresses, ...data.data])
: data.data;
? paginateAddresses(data.cursor, [...addresses, ...data.data.map(toAddress)])
: data.data.map(toAddress);

throw parseHttpError(data);
};
Expand Down

0 comments on commit 552510f

Please sign in to comment.