Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: indexer integration #36

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions packages/ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const preview: Preview = {
locales: "en-US",
},
},
msw: {
handlers,
},
// msw: {
// handlers,
// },
},

loaders: [mswLoader],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const application: CheckerApplication = {
updatedAt: "2023-01-01T00:00:00Z",
},
],
canonicalProject: {
roles: [{ address: "0xroleaddress1234567890abcdef12345678" }],
project: {
projectRoles: [{ address: "0xroleaddress1234567890abcdef12345678" }],
},
alloApplicationId: "",
evaluations: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/features/checker/apps/Checker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const meta = {
component: Checker,
args: {
address: "0x0D1781F0b693b35939A49831A6C799B938Bd2F80",
poolId: "597",
chainId: 11155111,
poolId: "7",
chainId: 10,
},
} satisfies Meta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const useApplicationEvaluations = (
roundId,
applicationId,
);
if (!application || !applicationEvaluations) return undefined;
const data = {
application,
applicationEvaluations: applicationEvaluations,
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/features/checker/hooks/usePoolData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export const usePoolData = (): { poolData: CheckerPoolData | null; refetch: () =

useEffect(() => {
if (data && poolId && chainId && address) {
const managers = data.roundData.roles.map((role) => role.address.toLowerCase());
const managers = data.roundData.project.projectRoles.map((role) =>
role.address.toLowerCase(),
);
dispatch(
setPoolDataAction({
poolId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export default meta;
type Story = StoryObj<typeof ApplicationEvaluationOverviewPage>;

export const Default: Story = {
parameters: {
msw: {
handlers,
},
},
// parameters: {
// msw: {
// handlers,
// },
// },
args: {
chainId: 11155111,
poolId: "605",
chainId: 10,
poolId: "7",
applicationId: "1",
address: "0x0D1781F0b693b35939A49831A6C799B938Bd2F80",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const Default: Story = {
},
},
args: {
chainId: 11155111,
poolId: "605",
chainId: 10,
poolId: "7",
applicationId: "1",
address: "0x0D1781F0b693b35939A49831A6C799B938Bd2F80",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const Default: Story = {
},
},
args: {
chainId: 42161,
poolId: "609",
applicationId: "0",
chainId: 10,
poolId: "7",
applicationId: "1",
},
};
4 changes: 3 additions & 1 deletion packages/ui/src/features/checker/services/allo/alloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
import { GraphQLClient } from "graphql-request";

// Base URL for the GraphQL API
const GS_INDEXER_ENDPOINT = "https://grants-stack-indexer-v2.gitcoin.co/graphql";
const GS_INDEXER_ENDPOINT = "http://gitcoin-data-layer-staging-lb-242619440.us-east-2.elb.amazonaws.com/v1/graphql";
const GS_INDEXER_ADMIN_SECRET = "ADD_SECRET_HERE";

// Create a new instance of GraphQLClient
export const graphqlClient = new GraphQLClient(GS_INDEXER_ENDPOINT, {
headers: {
"Content-Type": "application/json",
"x-hasura-admin-secret": GS_INDEXER_ADMIN_SECRET,
},
});

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/features/checker/services/allo/dataLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getApplicationsFromIndexer(
});
return {
applications: response.applications as ProjectApplicationForManager[],
roundData: response.round as PoolInfo,
roundData: response.rounds[0] as PoolInfo,
};
} catch (e) {
throw new Error(`Failed to fetch applications data. with error: ${e}`);
Expand All @@ -37,7 +37,7 @@ export async function getApplicationByIdFromIndexer(
roundId,
applicationId,
});
return response.application as ProjectApplication;
return response.applications[0] as ProjectApplication;
} catch (e) {
throw new Error(`Failed to fetch application data. with error: ${e}`);
}
Expand All @@ -55,7 +55,7 @@ export async function getPastApplicationsByApplicationIdFromIndexer(
applicationId,
});

return response.applications[0].project.applications as PastApplication[];
return response.applications[0].project[0].applications as PastApplication[];
} catch (e) {
throw new Error(`Failed to fetch past applications data. with error: ${e}`);
}
Expand Down
31 changes: 13 additions & 18 deletions packages/ui/src/features/checker/services/allo/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { gql } from "graphql-request";

export const applicationsForManagerQuery = gql`
query getApplicationsForManager($chainId: Int!, $roundId: String!) {
applications(
first: 1000
filter: { roundId: { equalTo: $roundId }, chainId: { equalTo: $chainId } }
) {
applications(limit: 1000, where: { roundId: { _eq: $roundId }, chainId: { _eq: $chainId } }) {
id
projectId
chainId
Expand All @@ -16,33 +13,35 @@ export const applicationsForManagerQuery = gql`
distributionTransaction
statusSnapshots
anchorAddress
canonicalProject {
roles {
project {
projectRoles {
address
}
}
}
round(chainId: $chainId, id: $roundId) {
rounds(where: { chainId: { _eq: $chainId }, id: { _eq: $roundId } }) {
roundMetadata
strategyName
strategyAddress
applicationsStartTime
applicationsEndTime
donationsEndTime
donationsStartTime
roles {
address
}
project {
id
projectRoles {
address
}
}
}
}
`;

export const getApplicationByIdQuery = gql`
query getApplicationById($chainId: Int!, $roundId: String!, $applicationId: String!) {
application(chainId: $chainId, roundId: $roundId, id: $applicationId) {
applications(
where: { chainId: { _eq: $chainId }, roundId: { _eq: $roundId }, id: { _eq: $applicationId } }
) {
id
projectId
chainId
Expand All @@ -53,8 +52,8 @@ export const getApplicationByIdQuery = gql`
distributionTransaction
statusSnapshots
anchorAddress
canonicalProject {
roles {
project {
projectRoles {
address
}
}
Expand All @@ -69,11 +68,7 @@ export const getPastApplicationsQueryByApplicationId = gql`
$applicationId: String!
) {
applications(
filter: {
chainId: { equalTo: $chainId }
roundId: { equalTo: $roundId }
id: { equalTo: $applicationId }
}
where: { chainId: { _eq: $chainId }, roundId: { _eq: $roundId }, id: { _eq: $applicationId } }
) {
project {
applications {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/features/checker/services/allo/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ interface StatusSnapshot {
export interface ProjectApplicationForManager extends ProjectApplication {
anchorAddress: Address;
statusSnapshots: StatusSnapshot[];
canonicalProject: {
roles: { address: Address }[];
project: {
projectRoles: { address: Address }[];
};
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/features/checker/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export interface PoolInfo {
};
project: {
id: string;
projectRoles: {
address: string;
}[];
};
roles: {
address: string;
}[];
strategyAddress: string;
strategyName: string;
applicationsStartTime: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const checkerPoolDataHandler = graphql.query("getCheckerPoolData", () =>
});

export const indexerGetApplicationByIdHandler = graphql.query("getApplicationByIdQuery", () => {
return HttpResponse.json({ data: { application: getApplicationById } });
return HttpResponse.json({ data: { applications: [getApplicationById] } });
});

export const checkerApplicationEvaluationsHandler = graphql.query(
Expand Down
Loading