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

Commit

Permalink
Merge pull request #91 from ar-io/PE-5012-contracts
Browse files Browse the repository at this point in the history
fix(PE-5012): fix gql query for fetching contracts
  • Loading branch information
dtfiedler authored Jan 12, 2024
2 parents f7560ec + 0e06e05 commit 9d51c6f
Showing 1 changed file with 14 additions and 20 deletions.
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

0 comments on commit 9d51c6f

Please sign in to comment.