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

[API] ICR API Integration #2051

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Conversation

psparacino
Copy link
Collaborator

@psparacino psparacino commented Dec 20, 2023

Description

API Integration for ICR credits

  • POSTMAN TESTS CHECK FAILURE: The postman tests are currently failing as this PR is currently using a test subgraph that is updated for ICR but doesn't index the main Carbonmark contract and thus doesn't have activity for the project included in the test. After the ICR updates have been merged to the main subgraph, deployed etc the tests should pass

Notes for reviewers:

  1. ICR tracks quantities only in regular integers (i.e. 40) vs wei. This is why amount is handled per registry throughout. Ideally in the next iteration we can move this quantity handling to the subgraph (which currently only handles amounts in wei).
  2. Individual projects (/projects/[id]) from ICR are stitched into the cms carbonProject type here
  3. for /projects list, the ICR projects are combined with cms projects here.
    These projects will likely be included in the cms in the near future and not handled here.
  4. The ICR API limit is 50 for all projects
  5. ICRs countries and vintages are fetched here to be combined with the options for the search filters.
  6. The ICR API supports querying projects by and/or serialization (a unique ICR key, which contains the necessary info for the CM format of registry-registryNum-vintage), contractAddress and projectID (a unique ICR identifier). Serialization is always used when possible, but there is some debt taken on by supporting lookup by contractAddress when the serialization is not available, or projectID (especially in [KLIMADAO/Klimadao] Polygon-digital-carbon for retirement data #2048 ) when neither of those are available. Moving projects to the cms will get around the majority of these workarounds.
  7. These subgraph are deployed to a personal account. The updated subgraphs should deployed under the organizational account before merge.

Related Ticket

Closes ICR epic
This PR is dependent on #2047 and #2048 and should be merged after those.

Notes For QA

Specific pages, components or journeys that might be affected:

Relevant preview URLs:

Other notes:

  • As is this obviously a very large PR, if any reviewer would prefer to pair review or has any questions please reach out!

Copy link

vercel bot commented Dec 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
carbonmark ✅ Ready (Inspect) Visit Preview Jan 22, 2024 3:51am
carbonmark-api ✅ Ready (Inspect) Visit Preview Jan 22, 2024 3:51am
demo-integration ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 3:51am
klimadao-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 3:51am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
carbon ⬜️ Ignored (Inspect) Visit Preview Jan 22, 2024 3:51am

Copy link
Collaborator

@biwano biwano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work.
Be careful, this is going to massively conflict with #2049

carbonmark-api/src/models/Project.model.ts Show resolved Hide resolved
carbonmark-api/src/utils/ICR/ICR_API_endpoints.ts Outdated Show resolved Hide resolved
carbonmark-api/src/utils/ICR/icr.types.ts Outdated Show resolved Hide resolved
carbonmark-api/src/utils/getCategoryFromMethodoloy.ts Outdated Show resolved Hide resolved
carbonmark-api/src/routes/purchases/[id]/get.ts Outdated Show resolved Hide resolved
carbonmark-api/src/utils/ICR/icr.utils.ts Outdated Show resolved Hide resolved
carbonmark-api/src/utils/helpers/cms.utils.ts Outdated Show resolved Hide resolved
@psparacino psparacino closed this Jan 19, 2024
@psparacino psparacino force-pushed the API_feature/icr-api-integration branch from 381ee83 to 31e8527 Compare January 19, 2024 14:26
@psparacino psparacino reopened this Jan 19, 2024
@psparacino psparacino deployed to Preview – carbonmark-api January 19, 2024 14:43 — with GitHub Actions Active
@psparacino psparacino deployed to Preview – carbonmark-api January 19, 2024 14:43 — with GitHub Actions Active
@psparacino psparacino force-pushed the API_feature/icr-api-integration branch from 3aa1705 to 614d464 Compare January 19, 2024 16:36
@psparacino psparacino deployed to Preview – carbonmark-api January 19, 2024 16:36 — with GitHub Actions Active
Copy link
Collaborator

@biwano biwano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved. If you can address my last 2 comments before merging.

@@ -1,6 +1,6 @@
{
"name": "@klimadao/carbonmark-api",
"version": "5.2.1",
"version": "5.3.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 5.3.0

username: "someusername",
profileImgUrl: null,
};

export const EXPECTED_USER_RESPONSE = {
...omit(MOCK_USER_PROFILE, ["address", "updatedAt", "createdAt"]),
updatedAt: 1699715108,
updatedAt: 1702675,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is wrong here. I think MOCK_USER_PROFILE updated at should be something like 1702675170000

@psparacino psparacino merged commit ec9cadc into staging Jan 22, 2024
10 checks passed
@psparacino psparacino deleted the API_feature/icr-api-integration branch January 22, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants