Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

fix(PE-5012): fix gql query for fetching contracts #91

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,17 @@ export async function getDeployedContractsByWallet(
continue;
}
response.data.data.transactions.edges
.map(
(e: {
cursor: string;
node: { id: string };
pageInfo?: { hasNextPage: boolean };
}) => ({
id: e.node.id,
cursor: e.cursor,
hasNextPage: e.pageInfo?.hasNextPage,
}),
)
.forEach((c: { id: string; cursor: string; hasNextPage: boolean }) => {
.map((e: { node: { id: string } }) => ({
id: e.node.id,
}))
.forEach((c: { id: string; cursor: string }) => {
ids.add(c.id);
cursor = c.cursor;
hasNextPage = c.hasNextPage ?? false;
});
cursor =
response.data.data.transactions.edges[MAX_REQUEST_SIZE - 1]?.cursor ??
undefined;
hasNextPage =
response.data.data.transactions.pageInfo?.hasNextPage ?? false;
} while (hasNextPage);

return {
Expand Down Expand Up @@ -452,9 +447,7 @@ export async function getContractsTransferredToOrControlledByWallet(
response.data.data.transactions.edges
.map(
(e: {
cursor: string;
node: { id: string; tags: { name: string; value: string }[] };
pageInfo?: { hasNextPage: boolean };
}) => {
// get the contract id of the interaction
const contractTag = e.node.tags.find(
Expand All @@ -463,16 +456,17 @@ export async function getContractsTransferredToOrControlledByWallet(
// we want to preserve the cursor here, so add even if a duplicate and the set will handle removing the contract if its a duplicate
return {
id: contractTag?.value,
cursor: e.cursor,
hasNextPage: e.pageInfo?.hasNextPage,
};
},
)
.forEach((c: { id: string; cursor: string; hasNextPage: boolean }) => {
ids.add(c.id);
cursor = c.cursor;
hasNextPage = c.hasNextPage ?? false;
});
cursor =
response.data.data.transactions.edges[MAX_REQUEST_SIZE - 1]?.cursor ??
undefined;
hasNextPage =
response.data.data.transactions.pageInfo?.hasNextPage ?? false;
} while (hasNextPage);

return {
Expand Down
Loading