From 19cc069ba330be8a2789b06c41c852007377f102 Mon Sep 17 00:00:00 2001 From: selim <138768831+sprrwhwk@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:08:25 +0300 Subject: [PATCH] add tokenId to listings (#2188) * add tokenId to listings * bump api version * extract tokenId from fixture * rename test * make vintage required * migrate to new graph version * remove tokenId frmo fixtures * remove tokenId mock * revert renaming token to symbol * revert test changes * remove icr fixture --------- Co-authored-by: emc <0xemc@protonmail.com> --- carbonmark-api/package.json | 2 +- .../src/.generated/mocks/marketplace.mocks.ts | 9 ++++++++ .../src/.generated/types/marketplace.types.ts | 23 +++++++++++++++---- carbonmark-api/src/app.constants.ts | 2 +- .../src/graphql/marketplace.fragments.gql | 1 + carbonmark-api/src/models/Listing.model.ts | 1 + 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/carbonmark-api/package.json b/carbonmark-api/package.json index 2736e09a4e..a4dd439606 100644 --- a/carbonmark-api/package.json +++ b/carbonmark-api/package.json @@ -1,6 +1,6 @@ { "name": "@klimadao/carbonmark-api", - "version": "6.0.1", + "version": "6.1.0", "description": "An API for exploring Carbonmark project data, prices and activity.", "main": "app.ts", "scripts": { diff --git a/carbonmark-api/src/.generated/mocks/marketplace.mocks.ts b/carbonmark-api/src/.generated/mocks/marketplace.mocks.ts index 3dcc0340ac..cfed5cf00f 100644 --- a/carbonmark-api/src/.generated/mocks/marketplace.mocks.ts +++ b/carbonmark-api/src/.generated/mocks/marketplace.mocks.ts @@ -311,6 +311,7 @@ export const aListing = (overrides?: Partial, _relationshipsToOmit: Set seller: overrides && overrides.hasOwnProperty('seller') ? overrides.seller! : relationshipsToOmit.has('User') ? {} as User : aUser({}, relationshipsToOmit), singleUnitPrice: overrides && overrides.hasOwnProperty('singleUnitPrice') ? overrides.singleUnitPrice! : '100000000000000000000', tokenAddress: overrides && overrides.hasOwnProperty('tokenAddress') ? overrides.tokenAddress! : 'at', + tokenId: overrides && overrides.hasOwnProperty('tokenId') ? overrides.tokenId! : '100000000000000000000', tokenSymbol: overrides && overrides.hasOwnProperty('tokenSymbol') ? overrides.tokenSymbol! : 'assumenda', totalAmountToSell: overrides && overrides.hasOwnProperty('totalAmountToSell') ? overrides.totalAmountToSell! : '100000000000000000000', updatedAt: overrides && overrides.hasOwnProperty('updatedAt') ? overrides.updatedAt! : '100000000000000000000', @@ -445,6 +446,14 @@ export const aListing_Filter = (overrides?: Partial, _relationsh tokenAddress_not: overrides && overrides.hasOwnProperty('tokenAddress_not') ? overrides.tokenAddress_not! : 'sint', tokenAddress_not_contains: overrides && overrides.hasOwnProperty('tokenAddress_not_contains') ? overrides.tokenAddress_not_contains! : 'dolorem', tokenAddress_not_in: overrides && overrides.hasOwnProperty('tokenAddress_not_in') ? overrides.tokenAddress_not_in! : ['ut'], + tokenId: overrides && overrides.hasOwnProperty('tokenId') ? overrides.tokenId! : '100000000000000000000', + tokenId_gt: overrides && overrides.hasOwnProperty('tokenId_gt') ? overrides.tokenId_gt! : '100000000000000000000', + tokenId_gte: overrides && overrides.hasOwnProperty('tokenId_gte') ? overrides.tokenId_gte! : '100000000000000000000', + tokenId_in: overrides && overrides.hasOwnProperty('tokenId_in') ? overrides.tokenId_in! : ['100000000000000000000'], + tokenId_lt: overrides && overrides.hasOwnProperty('tokenId_lt') ? overrides.tokenId_lt! : '100000000000000000000', + tokenId_lte: overrides && overrides.hasOwnProperty('tokenId_lte') ? overrides.tokenId_lte! : '100000000000000000000', + tokenId_not: overrides && overrides.hasOwnProperty('tokenId_not') ? overrides.tokenId_not! : '100000000000000000000', + tokenId_not_in: overrides && overrides.hasOwnProperty('tokenId_not_in') ? overrides.tokenId_not_in! : ['100000000000000000000'], tokenSymbol: overrides && overrides.hasOwnProperty('tokenSymbol') ? overrides.tokenSymbol! : 'sed', tokenSymbol_contains: overrides && overrides.hasOwnProperty('tokenSymbol_contains') ? overrides.tokenSymbol_contains! : 'quo', tokenSymbol_contains_nocase: overrides && overrides.hasOwnProperty('tokenSymbol_contains_nocase') ? overrides.tokenSymbol_contains_nocase! : 'quo', diff --git a/carbonmark-api/src/.generated/types/marketplace.types.ts b/carbonmark-api/src/.generated/types/marketplace.types.ts index 44142e7828..461bacac7f 100644 --- a/carbonmark-api/src/.generated/types/marketplace.types.ts +++ b/carbonmark-api/src/.generated/types/marketplace.types.ts @@ -236,6 +236,7 @@ export enum Activity_OrderBy { listing__minFillAmount = 'listing__minFillAmount', listing__singleUnitPrice = 'listing__singleUnitPrice', listing__tokenAddress = 'listing__tokenAddress', + listing__tokenId = 'listing__tokenId', listing__tokenSymbol = 'listing__tokenSymbol', listing__totalAmountToSell = 'listing__totalAmountToSell', listing__updatedAt = 'listing__updatedAt', @@ -356,6 +357,7 @@ export type Listing = { seller: User; singleUnitPrice: Scalars['BigInt']; tokenAddress: Scalars['Bytes']; + tokenId: Scalars['BigInt']; tokenSymbol: Scalars['String']; totalAmountToSell: Scalars['BigInt']; updatedAt: Maybe; @@ -496,6 +498,14 @@ export type Listing_Filter = { tokenAddress_not: InputMaybe; tokenAddress_not_contains: InputMaybe; tokenAddress_not_in: InputMaybe>; + tokenId: InputMaybe; + tokenId_gt: InputMaybe; + tokenId_gte: InputMaybe; + tokenId_in: InputMaybe>; + tokenId_lt: InputMaybe; + tokenId_lte: InputMaybe; + tokenId_not: InputMaybe; + tokenId_not_in: InputMaybe>; tokenSymbol: InputMaybe; tokenSymbol_contains: InputMaybe; tokenSymbol_contains_nocase: InputMaybe; @@ -558,6 +568,7 @@ export enum Listing_OrderBy { seller__id = 'seller__id', singleUnitPrice = 'singleUnitPrice', tokenAddress = 'tokenAddress', + tokenId = 'tokenId', tokenSymbol = 'tokenSymbol', totalAmountToSell = 'totalAmountToSell', updatedAt = 'updatedAt' @@ -891,6 +902,7 @@ export enum Purchase_OrderBy { listing__minFillAmount = 'listing__minFillAmount', listing__singleUnitPrice = 'listing__singleUnitPrice', listing__tokenAddress = 'listing__tokenAddress', + listing__tokenId = 'listing__tokenId', listing__tokenSymbol = 'listing__tokenSymbol', listing__totalAmountToSell = 'listing__totalAmountToSell', listing__updatedAt = 'listing__updatedAt', @@ -1298,7 +1310,7 @@ export enum _SubgraphErrorPolicy_ { deny = 'deny' } -export type ListingFragmentFragment = { __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }; +export type ListingFragmentFragment = { __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, tokenId: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }; export type ProjectFragmentFragment = { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } }; @@ -1338,7 +1350,7 @@ export type GetListingByIdQueryVariables = Exact<{ }>; -export type GetListingByIdQuery = { __typename?: 'Query', listing: { __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } } | null }; +export type GetListingByIdQuery = { __typename?: 'Query', listing: { __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, tokenId: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } } | null }; export type GetUserByWalletQueryVariables = Exact<{ wallet: InputMaybe; @@ -1346,7 +1358,7 @@ export type GetUserByWalletQueryVariables = Exact<{ }>; -export type GetUserByWalletQuery = { __typename?: 'Query', listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }>, activities: Array<{ __typename?: 'Activity', id: string, amount: string | null, previousAmount: string | null, price: string | null, previousPrice: string | null, timeStamp: string | null, activityType: ActivityType, project: { __typename?: 'Project', key: string, vintage: string }, buyer: { __typename?: 'User', id: any } | null, seller: { __typename?: 'User', id: any } }> }; +export type GetUserByWalletQuery = { __typename?: 'Query', listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, tokenId: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }>, activities: Array<{ __typename?: 'Activity', id: string, amount: string | null, previousAmount: string | null, price: string | null, previousPrice: string | null, timeStamp: string | null, activityType: ActivityType, project: { __typename?: 'Project', key: string, vintage: string }, buyer: { __typename?: 'User', id: any } | null, seller: { __typename?: 'User', id: any } }> }; export type GetProjectsQueryVariables = Exact<{ search: InputMaybe; @@ -1357,7 +1369,7 @@ export type GetProjectsQueryVariables = Exact<{ }>; -export type GetProjectsQuery = { __typename?: 'Query', projects: Array<{ __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }> | null, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } }> }; +export type GetProjectsQuery = { __typename?: 'Query', projects: Array<{ __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, tokenId: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }> | null, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } }> }; export type GetProjectByIdQueryVariables = Exact<{ projectId: Scalars['ID']; @@ -1365,7 +1377,7 @@ export type GetProjectByIdQueryVariables = Exact<{ }>; -export type GetProjectByIdQuery = { __typename?: 'Query', project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }> | null, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } | null }; +export type GetProjectByIdQuery = { __typename?: 'Query', project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, listings: Array<{ __typename?: 'Listing', id: string, totalAmountToSell: string, leftToSell: string, tokenAddress: any, active: boolean | null, deleted: boolean | null, singleUnitPrice: string, createdAt: string | null, updatedAt: string | null, expiration: string, minFillAmount: string, tokenId: string, seller: { __typename?: 'User', id: any }, project: { __typename?: 'Project', id: string, key: string, vintage: string, name: string, methodology: string, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } }> | null, category: { __typename?: 'Category', id: string }, country: { __typename?: 'Country', id: string } } | null }; export type GetActivitiesByProjectIdQueryVariables = Exact<{ projectId: InputMaybe | Scalars['ID']>; @@ -1416,6 +1428,7 @@ export const ListingFragmentFragmentDoc = gql` } expiration minFillAmount + tokenId } ${ProjectFragmentFragmentDoc}`; export const ActivityFragmentFragmentDoc = gql` diff --git a/carbonmark-api/src/app.constants.ts b/carbonmark-api/src/app.constants.ts index 0a19c5ca4d..820d6ff423 100644 --- a/carbonmark-api/src/app.constants.ts +++ b/carbonmark-api/src/app.constants.ts @@ -12,7 +12,7 @@ const GRAPH_API_ROOT_ID = "https://api.thegraph.com/subgraphs/id"; * This is also the case for SANITY_URLS */ const POLYGON_URLS = { - marketplace: `${GRAPH_API_ROOT_ID}/QmXrzcwG5b31hE1nDzT5NCAiHfM9stwMLqs8uk9enJiyPf`, + marketplace: `${GRAPH_API_ROOT_ID}/QmaHkN47zUB3b1xnfeqCwatG5DRtMuitEDf9FdFkq5V3Fr`, assets: `${GRAPH_API_ROOT}/cujowolf/klima-refi-current-holdings`, tokens: `${GRAPH_API_ROOT}/klimadao/klimadao-pairs`, digitalCarbon: `${GRAPH_API_ROOT}/klimadao/polygon-digital-carbon`, diff --git a/carbonmark-api/src/graphql/marketplace.fragments.gql b/carbonmark-api/src/graphql/marketplace.fragments.gql index d854609325..a93b37e0d2 100644 --- a/carbonmark-api/src/graphql/marketplace.fragments.gql +++ b/carbonmark-api/src/graphql/marketplace.fragments.gql @@ -16,6 +16,7 @@ fragment ListingFragment on Listing { } expiration minFillAmount + tokenId } fragment ProjectFragment on Project { diff --git a/carbonmark-api/src/models/Listing.model.ts b/carbonmark-api/src/models/Listing.model.ts index 04240bc3a1..8b0a464d53 100644 --- a/carbonmark-api/src/models/Listing.model.ts +++ b/carbonmark-api/src/models/Listing.model.ts @@ -49,6 +49,7 @@ export const ListingModel = Type.Object( methodology: Type.String(), }), symbol: Type.Optional(Type.String({ description: "Symbol of the token" })), + tokenId: Type.String({ description: "ID of the token" }), }, { description: "Marketplace listing with per-tonne price and project info.",