Skip to content

Commit

Permalink
Converting while loop to do-while in the "getOrders" method.
Browse files Browse the repository at this point in the history
  • Loading branch information
darley-silva-funttastic committed Sep 22, 2023
1 parent 3e17392 commit 9128d48
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/connectors/kujira/kujira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,29 +1304,28 @@ export class Kujira {
const response: JsonObject = { orders: [] };
let partialResponse: JsonObject;

while (
partialResponse &&
partialResponse.orders.length >=
KujiraConfig.config.orders.open.paginationLimit &&
response.orders.length <= KujiraConfig.config.orders.open.limit
) {
do {
partialResponse = await this.kujiraQueryClientWasmQueryContractSmart(
market.connectorMarket.address,
{
orders_by_user: {
address: ownerAddress,
limit: KujiraConfig.config.orders.open.limit,
start_after: partialResponse
? partialResponse.orders[
market.connectorMarket.address,
{
orders_by_user: {
address: ownerAddress,
limit: KujiraConfig.config.orders.open.limit,
start_after: partialResponse
? partialResponse.orders[
partialResponse.orders.length - 1
].idx.toString()
: null,
},
}
].idx.toString()
: null,
},
}
);

response.orders = [...response.orders, ...partialResponse.orders];
}
} while ((
partialResponse.orders.length >= KujiraConfig.config.orders.open.paginationLimit
) && (
response.orders.length <= KujiraConfig.config.orders.open.limit
));

const bundles = IMap<string, any>().asMutable();

Expand Down

0 comments on commit 9128d48

Please sign in to comment.