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

Move application page fetcher to data layer #2902

Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ff14627
Application page redesign
carlbarrdahl Nov 23, 2023
4bf5749
Merge branch 'main' into feat/application-page-redesign
carlbarrdahl Nov 23, 2023
f04706c
Merge branch 'main' into feat/application-page-redesign
carlbarrdahl Nov 23, 2023
f8e0687
Update RoundEndedBanner
carlbarrdahl Nov 23, 2023
5b6af03
Clean up
carlbarrdahl Nov 23, 2023
1806db5
Remove unused file
carlbarrdahl Nov 23, 2023
56fa34a
Remove console.log
carlbarrdahl Nov 23, 2023
1e8a553
Remove unused code
carlbarrdahl Nov 23, 2023
f5ad9e4
Fix tests
carlbarrdahl Nov 23, 2023
9e93700
Fix tests
carlbarrdahl Nov 24, 2023
1cea499
Merge branch 'main' into feat/application-page-redesign
carlbarrdahl Nov 24, 2023
d0810c0
Add loading skeleton for about text
carlbarrdahl Nov 24, 2023
abe4255
Add wrapping div to reduce diff in component
carlbarrdahl Nov 24, 2023
ce73c96
Refactor hooks and ProjectStats into seperate files
carlbarrdahl Nov 24, 2023
15d18c0
Revert "Refactor hooks and ProjectStats into seperate files"
carlbarrdahl Nov 24, 2023
a514e61
Merge branch 'main' into feat/application-page-redesign
carlbarrdahl Nov 24, 2023
00cca93
Fix icon color
carlbarrdahl Nov 24, 2023
eb085de
Merge branch 'main' into feat/application-page-redesign
carlbarrdahl Nov 27, 2023
c9d6f00
Create useApplication hook to fetch data from the indexer
carlbarrdahl Nov 30, 2023
081be64
Merge branch 'feat/application-page-redesign' into 2670-application-p…
carlbarrdahl Dec 1, 2023
ad78b43
Merge remote-tracking branch 'origin/main' into 2670-application-page…
vacekj Feb 2, 2024
05c6553
fix: use real indexer v2 endpointˆ
vacekj Feb 2, 2024
e2755be
Merge branch 'main' into 2670-application-page-indexer-data
vacekj Feb 2, 2024
45d41bb
fix: finish application page indexer v2 data
vacekj Feb 2, 2024
e056208
feat: don't show v2 projects on v1, disallow adding v2 projects to ca…
vacekj Feb 2, 2024
eaee6ca
feat: don't show v2 projects on v1, disallow adding v2 projects to ca…
vacekj Feb 2, 2024
d82e45c
feat: type-safe non-optional useParams
vacekj Feb 2, 2024
04fa035
Merge branch 'main' into 2670-application-page-indexer-data
vacekj Feb 2, 2024
51df87e
wip: tests
vacekj Feb 2, 2024
37ca4e7
Merge branch 'main' into 2670-application-page-indexer-data
vacekj Feb 6, 2024
663eaba
Merge branch '2670-application-page-indexer-data' of github.com:gitco…
vacekj Feb 6, 2024
b5afc16
fix: tests for application pageˆ
vacekj Feb 6, 2024
314dd3a
feat: simplify tests for application page
vacekj Feb 6, 2024
51ee234
fix: fix cart tests
vacekj Feb 6, 2024
bb48482
fix: types
vacekj Feb 6, 2024
bb7cc96
Merge branch 'main' into 2670-application-page-indexer-data
vacekj Feb 7, 2024
cdbeb6d
feat: move getApplication to data layer
vacekj Feb 7, 2024
054213e
feat: move getApplication to data layer
vacekj Feb 7, 2024
1b4a26a
fix: tsc, lints
vacekj Feb 7, 2024
063f1b3
Merge branch 'main' into 2851-explorer-v2-view-round-explorer-applica…
vacekj Feb 7, 2024
d896e14
Explorer: fix indexer v2 base url in data-layer initialization
gravityblast Feb 13, 2024
d7e1703
check fetch error
gravityblast Feb 13, 2024
f37115c
fix merge conflicts
gravityblast Feb 13, 2024
d69ec60
fix more conflicts
gravityblast Feb 13, 2024
38ba8a5
fix test
gravityblast Feb 13, 2024
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
10 changes: 8 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import { Network, Web3Provider } from "@ethersproject/providers";
import { Signer } from "@ethersproject/abstract-signer";
import { graphql_fetch } from "./graphql_fetch";
import { ChainId } from "./chain-ids";
import { useParams as useRouterParams } from "react-router";

export * from "./icons";
export * from "./markdown";

export { ChainId };

export function useParams<T extends Record<string, string> = never>() {
return useRouterParams<T>() as T;
}

export enum PassportState {
NOT_CONNECTED,
INVALID_PASSPORT,
Expand Down Expand Up @@ -312,7 +318,7 @@ export { AlloV2 } from "./allo/backends/allo-v2";
export {
createWaitForIndexerSyncTo,
getCurrentSubgraphBlockNumber,
waitForSubgraphSyncTo
waitForSubgraphSyncTo,
} from "./allo/indexer";
export type { WaitUntilIndexerSynced } from "./allo/indexer";
export { createPinataIpfsUploader } from "./allo/ipfs";
Expand All @@ -323,7 +329,7 @@ export {
createViemTransactionSender,
decodeEventFromReceipt,
sendRawTransaction,
sendTransaction
sendTransaction,
} from "./allo/transaction-sender";

export type AnyJson =
Expand Down
47 changes: 40 additions & 7 deletions packages/data-layer/src/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as collections from "./backends/collections";
import * as legacy from "./backends/legacy";
import { AlloVersion, PaginationInfo } from "./data-layer.types";
import {
Application,
Collection,
Program,
ProjectApplication,
Expand All @@ -16,16 +17,17 @@ import {
RoundOverview,
SearchBasedProjectCategory,
TimestampVariables,
V2Round,
v2Project,
V2Round,
} from "./data.types";
import {
ApplicationSummary,
DefaultApi as SearchApi,
Configuration as SearchApiConfiguration,
DefaultApi as SearchApi,
SearchResult,
} from "./openapi-search-client/index";
import {
getApplication,
getApplicationsByProjectId,
getProgramName,
getProgramsByUser,
Expand All @@ -34,6 +36,7 @@ import {
getProjectsAndRolesByAddress,
getRoundByIdAndChainId,
} from "./queries";
import { Address } from "viem";

/**
* DataLayer is a class that provides a unified interface to the various data sources.
Expand Down Expand Up @@ -299,10 +302,10 @@ export class DataLayer {
return projectEventsMap;
}

// getApplicationsByProjectId
/**
* getApplicationsByProjectId() returns a list of projects by address.
* @param projectId
* @param chainIds
*/
async getApplicationsByProjectId({
projectId,
Expand All @@ -325,6 +328,34 @@ export class DataLayer {
return response.applications ?? [];
}

/**
* Returns a single application as identified by its id, round name and chain name
* @param projectId
*/
async getApplication({
roundId,
chainId,
applicationId,
}: {
roundId: Lowercase<Address>;
chainId: number;
applicationId: string;
}): Promise<Application | undefined> {
const requestVariables = {
roundId,
chainId,
applicationId,
};

const response: { application: Application } = await request(
this.gsIndexerEndpoint,
getApplication,
requestVariables,
);

return response.application ?? [];
}

async getProgramName({
projectId,
}: {
Expand All @@ -351,14 +382,16 @@ export class DataLayer {
roundId: string;
chainId: number;
}): Promise<V2Round> {

const requestVariables = {
roundId,
chainId
chainId,
};

const response : {rounds: V2Round[]} =
await request(this.gsIndexerEndpoint, getRoundByIdAndChainId, requestVariables);
const response: { rounds: V2Round[] } = await request(
this.gsIndexerEndpoint,
getRoundByIdAndChainId,
requestVariables,
);

return response.rounds[0] ?? [];
}
Expand Down
36 changes: 32 additions & 4 deletions packages/data-layer/src/data.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { VerifiableCredential } from "@gitcoinco/passport-sdk-types";
import {
RoundApplicationMetadata,
} from './roundApplication.types';
import { RoundApplicationMetadata } from "./roundApplication.types";
// TODO `RoundPayoutType` and `RoundVisibilityType` are duplicated from `common` to
// avoid further spaghetti dependencies. They should probably be relocated here.
export type RoundPayoutType = "MERKLE" | "DIRECT";
Expand Down Expand Up @@ -233,7 +231,7 @@ export type V2Round = {
roundMetadataCid: string;
applicationMetadata: RoundApplicationMetadata;
applicationMetadataCid: string;
}
};

export type ProjectEvents = {
createdAtBlock: number | undefined;
Expand Down Expand Up @@ -416,3 +414,33 @@ export type Collection = {
description: string;
applicationRefs: string[];
};

export type Application = {
vacekj marked this conversation as resolved.
Show resolved Hide resolved
id: string;
chainId: string;
roundId: string;
projectId: string;
status: ApplicationStatus;
totalAmountDonatedInUsd: number;
totalDonationsCount: string;
uniqueDonorsCount: number;
round: {
donationsStartTime: string;
donationsEndTime: string;
applicationsStartTime: string;
applicationsEndTime: string;
roundMetadata: RoundMetadata;
matchTokenAddress: string;
tags: string[];
};
project: {
id: string;
metadata: ProjectMetadata;
};
metadata: {
application: {
recipient: string;
answers: GrantApplicationFormAnswer[];
};
};
};
38 changes: 36 additions & 2 deletions packages/data-layer/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,38 @@ export const getApplicationsByProjectId = gql`
}
`;

export const getApplication = gql`
query Application(
$chainId: Int!
$applicationId: String!
$roundId: String!
) {
application(chainId: $chainId, id: $applicationId, roundId: $roundId) {
id
chainId
roundId
projectId
status
totalAmountDonatedInUsd
uniqueDonorsCount
round {
donationsStartTime
donationsEndTime
applicationsStartTime
applicationsEndTime
matchTokenAddress
roundMetadata
}
metadata
project {
tags
id
metadata
}
}
}
`;

export const getProgramName = gql`
query getProgramNameQuery($projectId: String!) {
projects(filter: { id: { equalTo: $projectId } }) {
Expand Down Expand Up @@ -249,7 +281,9 @@ export const getBlockNumberQuery = gql`

export const getRoundByIdAndChainId = gql`
query getRoundByIdAndChainId($roundId: String!, $chainId: Int!) {
rounds(filter: { id: { equalTo: $roundId }, chainId: { equalTo: $chainId } }) {
rounds(
filter: { id: { equalTo: $roundId }, chainId: { equalTo: $chainId } }
) {
id
chainId
applicationsStartTime
Expand All @@ -263,4 +297,4 @@ export const getRoundByIdAndChainId = gql`
applicationMetadataCid
}
}
`;
`;
Loading
Loading