Skip to content

Commit 5a8dd5b

Browse files
authored
Merge branch 'main' into main
2 parents 01af87b + 95ba3b2 commit 5a8dd5b

File tree

21 files changed

+861
-41
lines changed

21 files changed

+861
-41
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ REACT_APP_COINGECKO_API_KEY=
7979
# ---------------------------
8080

8181
REACT_APP_STAKING_APP=https://boost.explorer.gitcoin.co/
82+
REACT_APP_STAKING_HUB_ENDPOINT=https://api.staking-hub.gitcoin.co
83+
84+
# ---------------------------
85+
# Karma
86+
REACT_APP_KARMA_GAP_INDEXER_URL=https://gapapi.karmahq.xyz
87+
REACT_APP_KARMA_GAP_APP_URL=https://gap.karmahq.xyz

packages/builder/src/components/application/Form.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export default function Form({
111111
const allProjectMetadata = state.grantsMetadata;
112112
const { chainID } = state.web3;
113113

114+
console.log("allProjectMetadata", allProjectMetadata);
114115
const projectIds = Object.keys(allProjectMetadata);
116+
console.log("projectIds", projectIds);
115117

116118
return {
117119
anchors: state.projects.anchor,
@@ -139,6 +141,7 @@ export default function Form({
139141
let selectedProjectMetadata: Metadata | undefined;
140142
let createLinkedProject = false;
141143

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

303306
useEffect(() => {
304307
const currentOptions = props.projectIDs.map((id): ProjectOption => {
308+
console.log("currentOptions: id", id);
305309
const chainId = props.allProjectMetadata[id]!.metadata!.chainId!;
306-
310+
console.log("currentOptions: chainId", chainId);
307311
const chain = getChainById(chainId);
312+
console.log("currentOptions: chain", chain);
308313
const chainName = chain.prettyName;
314+
console.log("currentOptions: chainName", chainName);
309315
const { icon } = chain;
316+
console.log("currentOptions: icon", icon);
310317

311318
return {
312319
id,
@@ -319,7 +326,7 @@ export default function Form({
319326
};
320327
});
321328
currentOptions.unshift({ id: undefined, title: "", chainInfo: undefined });
322-
329+
console.log("currentOptions: currentOptions", currentOptions);
323330
setProjectOptions(currentOptions);
324331
}, [props.allProjectMetadata]);
325332

@@ -402,6 +409,8 @@ export default function Form({
402409
return null;
403410
}
404411

412+
console.log("answers", answers);
413+
405414
if (input.type === "project") {
406415
return readOnly ? (
407416
<TextInput

packages/common/src/allo/backends/allo-v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class AlloV2 implements Allo {
170170
abi: MRC_ABI,
171171
functionName: "allocate",
172172
args: [poolIds, amounts, data],
173-
value: nativeTokenAmount,
173+
value: nativeTokenAmount + (directAllocation?.amount ?? BigInt(0)),
174174
},
175175
this.chainId
176176
);

packages/data-layer/src/data-layer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const mockProjects: v2Project[] = [
4646
createdAtBlock: "5146499",
4747
},
4848
],
49-
projectType: "CANONICAL",
49+
projectType: "canonical",
5050
linkedChains: [],
5151
},
5252
];

packages/data-layer/src/data-layer.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import {
5959
getRoundsForManagerByAddress,
6060
getDirectDonationsByProjectId,
6161
} from "./queries";
62-
import { orderByMapping } from "./utils";
62+
import { mergeCanonicalAndLinkedProjects, orderByMapping } from "./utils";
6363
import {
6464
AttestationService,
6565
type MintingAttestationIdsData,
@@ -251,9 +251,9 @@ export class DataLayer {
251251

252252
if (response.projects.length === 0) return null;
253253

254-
// const project = mergeCanonicalAndLinkedProjects(response.projects)[0];
254+
const project = mergeCanonicalAndLinkedProjects(response.projects)[0];
255255

256-
return { project: response.projects[0] };
256+
return { project: project };
257257
}
258258

259259
async getProjectAnchorByIdAndChainId({
@@ -316,7 +316,8 @@ export class DataLayer {
316316
requestVariables,
317317
);
318318

319-
return response.projects;
319+
const mergedProjects = mergeCanonicalAndLinkedProjects(response.projects);
320+
return mergedProjects;
320321
}
321322

322323
/**
@@ -815,17 +816,30 @@ export class DataLayer {
815816
chainIds: number[];
816817
}): Promise<Contribution[]> {
817818
const { address, chainIds } = args;
818-
const response: { donations: Contribution[] } = await request(
819-
this.gsIndexerEndpoint,
820-
getDonationsByDonorAddress,
821-
{
822-
address: getAddress(address),
823-
chainIds,
824-
},
825-
);
819+
let offset = 0;
820+
let hasMore = true;
821+
const limit = 200;
822+
let donations: Contribution[] = [];
823+
824+
while (hasMore) {
825+
const response: { donations: Contribution[] } = await request(
826+
this.gsIndexerEndpoint,
827+
getDonationsByDonorAddress,
828+
{ address: getAddress(address), chainIds, limit, offset },
829+
);
830+
831+
donations = [...donations, ...response.donations];
832+
833+
// Check if we need to fetch more
834+
if (response.donations.length < limit) {
835+
hasMore = false;
836+
} else {
837+
offset += limit;
838+
}
839+
}
826840

827841
// Filter out invalid donations and map the project metadata from application metadata (solution for canonical projects in indexer v2)
828-
const validDonations = response.donations.reduce<Contribution[]>(
842+
const validDonations = donations.reduce<Contribution[]>(
829843
(validDonations, donation) => {
830844
if (donation.round.strategyName !== "allov2.DirectAllocationStrategy") {
831845
if (donation.application?.project) {

packages/data-layer/src/data.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type ApplicationStatus =
3232
| "CANCELLED"
3333
| "IN_REVIEW";
3434

35-
export type ProjectType = "CANONICAL" | "LINKED";
35+
export type ProjectType = "canonical" | "linked";
3636

3737
export type GrantApplicationFormAnswer = {
3838
questionId: number;
@@ -208,7 +208,7 @@ export type v2Project = {
208208
nonce?: bigint;
209209
anchorAddress?: string;
210210
/**
211-
* The type of the project - `CANONICAL` or `LINKED`
211+
* The type of the project - `canonical` or `linked`
212212
*/
213213
projectType: ProjectType;
214214
/**

packages/data-layer/src/queries.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,15 @@ export const getRoundForExplorer = gql`
773773
`;
774774

775775
export const getDonationsByDonorAddress = gql`
776-
query getDonationsByDonorAddress($address: String!, $chainIds: [Int!]!) {
776+
query getDonationsByDonorAddress(
777+
$address: String!
778+
$chainIds: [Int!]!
779+
$limit: Int = 200
780+
$offset: Int = 0
781+
) {
777782
donations(
783+
limit: $limit
784+
offset: $offset
778785
where: { chainId: { _in: $chainIds }, donorAddress: { _eq: $address } }
779786
) {
780787
id

packages/data-layer/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export const mergeCanonicalAndLinkedProjects = (
1212
projects: v2Project[],
1313
): v2Project[] => {
1414
const canonicalProjects = projects.filter(
15-
(project) => project.projectType === "CANONICAL",
15+
(project) => project.projectType === "canonical",
1616
);
1717

1818
const linkedProjects = projects.filter(
19-
(project) => project.projectType === "LINKED",
19+
(project) => project.projectType === "linked",
2020
);
2121
const allProjects: Record<string, v2Project> = {};
2222
for (const project of canonicalProjects) {

packages/grant-explorer/public/index.html

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)