Skip to content

Commit e935ef0

Browse files
committed
tweak
1 parent 3dc0196 commit e935ef0

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ SYNCHRONIZE=false
33
LOGGING=true
44
PORT=4000
55
INDEXER_URL=https://grants-stack-indexer-v2.gitcoin.co/
6-
INDEXER_ADMIN_SECRET=your_indexer_admin_secret
76
OPENAI_API_KEY=your_openai_api_key
87
NODE_ENV=development
98
# Performance tuning

src/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ interface EnvVars {
1010
SYNCHRONIZE: string;
1111
LOGGING: string;
1212
INDEXER_URL: string;
13-
INDEXER_ADMIN_SECRET: string;
1413
OPENAI_API_KEY: string;
1514
[key: string]: string | number | undefined;
1615
}
@@ -26,7 +25,6 @@ export const env: EnvVars = {
2625
SYNCHRONIZE: process.env.SYNCHRONIZE ?? 'false',
2726
LOGGING: process.env.LOGGING ?? 'false',
2827
INDEXER_URL: process.env.INDEXER_URL ?? '',
29-
INDEXER_ADMIN_SECRET: process.env.INDEXER_ADMIN_SECRET ?? '',
3028
OPENAI_API_KEY: process.env.OPENAI_API_KEY ?? '',
3129
...process.env,
3230
};

src/ext/indexer/indexer.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ class IndexerClient {
8585
const response: ManagerRolesResponse = await request(
8686
this.indexerEndpoint,
8787
getRoundManager,
88-
requestVariables,
89-
{
90-
'x-hasura-admin-secret': env.INDEXER_ADMIN_SECRET,
91-
}
88+
requestVariables
9289
);
9390
if (response.rounds.length === 0) {
9491
this.logger.warn(
@@ -149,10 +146,7 @@ class IndexerClient {
149146
const response: RoundApplicationsQueryResponse = await request(
150147
this.indexerEndpoint,
151148
getRoundWithApplications,
152-
requestVariables,
153-
{
154-
'x-hasura-admin-secret': env.INDEXER_ADMIN_SECRET,
155-
}
149+
requestVariables
156150
);
157151

158152
if (response.rounds.length === 0) {
@@ -162,7 +156,16 @@ class IndexerClient {
162156
return null;
163157
}
164158

165-
const round = response.rounds[0];
159+
const round = {
160+
chainId: response.rounds[0].chainId,
161+
id: response.rounds[0].id,
162+
roundMetadata: response.rounds[0].roundMetadata,
163+
roundMetadataCid: response.rounds[0].roundMetadataCid,
164+
applications: response.rounds[0].applications.map(application => ({
165+
...application,
166+
project: application.projects[0],
167+
})),
168+
};
166169

167170
// Cache the result
168171
this.cache.set(cacheKey, round);
@@ -199,10 +202,7 @@ class IndexerClient {
199202
const response: ApplicationRoundQueryResponse = await request(
200203
this.indexerEndpoint,
201204
getApplicationWithRound,
202-
requestVariables,
203-
{
204-
'x-hasura-admin-secret': env.INDEXER_ADMIN_SECRET,
205-
}
205+
requestVariables
206206
);
207207

208208
const application = response.applications[0];

src/ext/indexer/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const getRoundWithApplications = gql`
2323
metadataCid
2424
status
2525
projectId
26-
project {
26+
projects(where: { projectType: { _eq: "canonical" } }) {
2727
metadata
2828
metadataCid
2929
}

src/ext/indexer/types.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// 1. Basic Types & Enums
12
export type Address = `0x${string}`;
23

34
export enum Status {
@@ -6,6 +7,7 @@ export enum Status {
67
REJECTED = 'REJECTED',
78
}
89

10+
// 2. Metadata & Supporting Interfaces
911
export interface ApplicationMetadata {
1012
signature: string;
1113
application: {
@@ -52,34 +54,48 @@ export interface ProjectMetadata {
5254
projectTwitter?: string;
5355
userGithub?: string;
5456
projectGithub?: string;
55-
// credentials: ProjectCredentials;
5657
owners: Array<{ address: string }>;
5758
createdAt: number;
5859
lastUpdated: number;
5960
}
6061

61-
export interface Application {
62+
// 3. Base Interfaces (Used in Multiple Places)
63+
export interface BaseProject {
64+
metadata: ProjectMetadata;
65+
metadataCid: string;
66+
}
67+
68+
export interface BaseApplication {
6269
id: string;
6370
metadata: ApplicationMetadata;
6471
metadataCid: string;
6572
status: Status;
6673
projectId: string;
67-
project: {
68-
metadata: ProjectMetadata;
69-
metadataCid: string;
70-
};
7174
}
7275

73-
export interface RoundWithApplications {
76+
// 4. Extended Implementations
77+
export interface Application extends BaseApplication {
78+
project: BaseProject;
79+
}
80+
81+
export interface ApplicationQuery extends BaseApplication {
82+
projects: BaseProject[];
83+
}
84+
85+
export interface BaseRound<T extends BaseApplication> {
7486
chainId: number;
7587
id: string;
7688
roundMetadata: RoundMetadata;
7789
roundMetadataCid: string;
78-
applications: Application[];
90+
applications: T[];
7991
}
8092

93+
export type RoundWithApplications = BaseRound<Application>;
94+
export type RoundWithApplicationsQuery = BaseRound<ApplicationQuery>;
95+
96+
// 5. API Response Structures
8197
export interface RoundApplicationsQueryResponse {
82-
rounds: RoundWithApplications[];
98+
rounds: RoundWithApplicationsQuery[];
8399
}
84100

85101
export interface ApplicationWithRound {

0 commit comments

Comments
 (0)