Skip to content

Commit

Permalink
fixed zero balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Axelrod committed Jun 25, 2024
1 parent 6b9614b commit 4dd2891
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/services/operator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IPagination } from '~app/model/pagination.model';
import { GetOperatorValidatorsResponse } from '~app/model/validator.model';
import { getStoredNetwork } from '~root/providers/networkInfo.provider';
import { IHttpResponse, getRequest, postRequest, putRequest } from '~root/services/httpApi.service';
import { getOperatorBalance } from '~root/services/operatorContract.service.ts';

type OperatorsListQuery = {
page?: number;
Expand Down Expand Up @@ -34,7 +35,14 @@ const getOperatorsByOwnerAddress = async ({
}): Promise<{ operators: IOperator[]; pagination: IPagination }> => {
const url = `${getStoredNetwork().api}/operators/owned_by/${accountAddress}?page=${page}&perPage=${perPage}&withFee=true&ts=${new Date().getTime()}&ordering=id:asc`;
const res = await getRequest(url, false);
return res ?? { operators: [], pagination: DEFAULT_PAGINATION };
const operators = await Promise.all(
res.operators.map(async (operator: any) => {
const { id } = operator;
const balance = await getOperatorBalance({ id });
return { ...operator, balance };
})
);
return { operators: operators || [], pagination: DEFAULT_PAGINATION };
};

type OperatorSearchResponse = {
Expand Down

0 comments on commit 4dd2891

Please sign in to comment.