Skip to content

Commit

Permalink
Merge pull request #1045 from oraidex/fix/update-sdk
Browse files Browse the repository at this point in the history
fix crash co-havest
  • Loading branch information
haunv3 authored Nov 21, 2024
2 parents 94735ed + 9d4e38e commit 1eb8243
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/pages/CoHarvest/components/ListHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const ListHistory = ({
}) => {
const [theme] = useConfigReducer('theme');
const { listBiddingRoundInfo, isLoading } = useGetListBiddingRoundInfo(activeRound);

const [limit, setLimit] = useState(LIMIT_PAGE);

// const { handleUpdateRoundURL } = useRoundRoute(activeRound, setFilterRound);
Expand Down
24 changes: 19 additions & 5 deletions src/pages/CoHarvest/hooks/useGetBidRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,29 @@ export const useGetListBiddingRoundInfo = (round: number) => {
const getListHistoryRound = async () => {
const multicall = new MulticallQueryClient(window.client, network.multicall);

const res = await multicall.aggregate({
queries: roundArr.map((round) => ({
const calls = roundArr.map((round) => {
return {
address: network.bid_pool,
data: toBinary({
bidding_info: {
round
}
})
}))
};
});

const chunks = [];
const MAX_CHUNK_SIZE = 30;

for (let i = 0; i < roundArr.length; i += MAX_CHUNK_SIZE) {
chunks.push(calls.slice(i, i + MAX_CHUNK_SIZE));
}

const result = (await Promise.all(chunks.map((chunk) => multicall.tryAggregate({ queries: chunk })))) as any;
const res = result.flatMap((item) => item.return_data.map((data) => data));

return roundArr.map((round, ind) => {
if (!res.return_data[ind].success) {
if (!res[ind]?.success) {
return {
bid_info: {
round,
Expand All @@ -170,7 +180,7 @@ export const useGetListBiddingRoundInfo = (round: number) => {
}
};
}
const response: BiddingInfoResponse = fromBinary(res.return_data[ind].data);
const response: BiddingInfoResponse = fromBinary(res[ind].data);
return response;
});
};
Expand Down Expand Up @@ -202,6 +212,10 @@ export const useGetListBiddingRoundInfo = (round: number) => {
enabled: !!round
});

console.log({
listBiddingRoundInfo
});

return { listBiddingRoundInfo, isLoading, refetchListBiddingRoundInfo };
};

Expand Down

0 comments on commit 1eb8243

Please sign in to comment.