Skip to content

chore: issue on apply #3811

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

Merged
merged 1 commit into from
Apr 2, 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
13 changes: 11 additions & 2 deletions packages/builder/src/components/application/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export default function Form({
const allProjectMetadata = state.grantsMetadata;
const { chainID } = state.web3;

console.log("allProjectMetadata", allProjectMetadata);
const projectIds = Object.keys(allProjectMetadata);
console.log("projectIds", projectIds);

return {
anchors: state.projects.anchor,
Expand Down Expand Up @@ -139,6 +141,7 @@ export default function Form({
let selectedProjectMetadata: Metadata | undefined;
let createLinkedProject = false;

// VERIFY LOGIC AFTER POPULATING linkedChains
if (selectedProjectID !== undefined && selectedProjectID !== "") {
selectedProjectMetadata =
props.allProjectMetadata[selectedProjectID]?.metadata;
Expand Down Expand Up @@ -302,11 +305,15 @@ export default function Form({

useEffect(() => {
const currentOptions = props.projectIDs.map((id): ProjectOption => {
console.log("currentOptions: id", id);
const chainId = props.allProjectMetadata[id]!.metadata!.chainId!;

console.log("currentOptions: chainId", chainId);
const chain = getChainById(chainId);
console.log("currentOptions: chain", chain);
const chainName = chain.prettyName;
console.log("currentOptions: chainName", chainName);
const { icon } = chain;
console.log("currentOptions: icon", icon);

return {
id,
Expand All @@ -319,7 +326,7 @@ export default function Form({
};
});
currentOptions.unshift({ id: undefined, title: "", chainInfo: undefined });

console.log("currentOptions: currentOptions", currentOptions);
setProjectOptions(currentOptions);
}, [props.allProjectMetadata]);

Expand Down Expand Up @@ -402,6 +409,8 @@ export default function Form({
return null;
}

console.log("answers", answers);

if (input.type === "project") {
return readOnly ? (
<TextInput
Expand Down
2 changes: 1 addition & 1 deletion packages/data-layer/src/data-layer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const mockProjects: v2Project[] = [
createdAtBlock: "5146499",
},
],
projectType: "CANONICAL",
projectType: "canonical",
linkedChains: [],
},
];
Expand Down
10 changes: 6 additions & 4 deletions packages/data-layer/src/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
getRoundsForManagerByAddress,
getDirectDonationsByProjectId,
} from "./queries";
import { orderByMapping } from "./utils";
import { mergeCanonicalAndLinkedProjects, orderByMapping } from "./utils";
import {
AttestationService,
type MintingAttestationIdsData,
Expand Down Expand Up @@ -250,10 +250,11 @@ export class DataLayer {
);

if (response.projects.length === 0) return null;
console.log("response.projects", response.projects);

// const project = mergeCanonicalAndLinkedProjects(response.projects)[0];
const project = mergeCanonicalAndLinkedProjects(response.projects)[0];

return { project: response.projects[0] };
return { project: project };
}

async getProjectAnchorByIdAndChainId({
Expand Down Expand Up @@ -316,7 +317,8 @@ export class DataLayer {
requestVariables,
);

return response.projects;
const mergedProjects = mergeCanonicalAndLinkedProjects(response.projects);
return mergedProjects;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/data-layer/src/data.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type ApplicationStatus =
| "CANCELLED"
| "IN_REVIEW";

export type ProjectType = "CANONICAL" | "LINKED";
export type ProjectType = "canonical" | "linked";

export type GrantApplicationFormAnswer = {
questionId: number;
Expand Down Expand Up @@ -208,7 +208,7 @@ export type v2Project = {
nonce?: bigint;
anchorAddress?: string;
/**
* The type of the project - `CANONICAL` or `LINKED`
* The type of the project - `canonical` or `linked`
*/
projectType: ProjectType;
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/data-layer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export const mergeCanonicalAndLinkedProjects = (
projects: v2Project[],
): v2Project[] => {
const canonicalProjects = projects.filter(
(project) => project.projectType === "CANONICAL",
(project) => project.projectType === "canonical",
);

const linkedProjects = projects.filter(
(project) => project.projectType === "LINKED",
(project) => project.projectType === "linked",
);
const allProjects: Record<string, v2Project> = {};
for (const project of canonicalProjects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const expectedProject: Project = {
createdAtBlock: "",
updatedAtBlock: "",
projectRoles: [],
projectType: "CANONICAL",
projectType: "canonical",
},
};

Expand Down