diff --git a/package.json b/package.json index 3451252..f9bf962 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@quest-chains/sdk", "description": "An SDK for building applications on top of Quest Chains", - "version": "0.1.14", + "version": "0.1.17", "license": "GPL-3.0", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/codegen.yml b/src/codegen.yml index 506bccc..29342cc 100644 --- a/src/codegen.yml +++ b/src/codegen.yml @@ -1,5 +1,5 @@ overwrite: true -schema: 'https://api.thegraph.com/subgraphs/name/dan13ram/quest-chains-rinkeby' +schema: 'https://api.thegraph.com/subgraphs/name/quest-chains/quest-chains-mumbai' generates: src/graphql/types.ts: config: diff --git a/src/graphql/badgesForUser.ts b/src/graphql/badgesForUser.ts index 4537113..29ca5f0 100644 --- a/src/graphql/badgesForUser.ts +++ b/src/graphql/badgesForUser.ts @@ -8,7 +8,7 @@ export type UserBadges = { imageUrl?: string | null | undefined; questChain?: { address: string | null | undefined; - } + }; }[]; chainId: string; }; diff --git a/src/graphql/client.ts b/src/graphql/client.ts index 220ec07..6f778dd 100644 --- a/src/graphql/client.ts +++ b/src/graphql/client.ts @@ -11,23 +11,23 @@ export type NetworkInfo = { export const SUPPORTED_NETWORK_INFO: NetworkInfo = { '0x89': { chainId: '0x89', - subgraphName: 'dan13ram/quest-chains-polygon', - subgraphUrl: 'https://api.thegraph.com/subgraphs/name/dan13ram/quest-chains-polygon', + subgraphName: 'quest-chains/quest-chains-polygon', + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/quest-chains/quest-chains-polygon', }, '0x64': { chainId: '0x64', - subgraphName: 'dan13ram/quest-chains-xdai', - subgraphUrl: 'https://api.thegraph.com/subgraphs/name/dan13ram/quest-chains-xdai', + subgraphName: 'quest-chains/quest-chains-xdai', + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/quest-chains/quest-chains-xdai', }, '0x5': { chainId: '0x5', - subgraphName: 'dan13ram/quest-chains-goerli', - subgraphUrl: 'https://api.thegraph.com/subgraphs/name/dan13ram/quest-chains-goerli', + subgraphName: 'quest-chains/quest-chains-goerli', + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/quest-chains/quest-chains-goerli', }, '0x13881': { chainId: '0x13881', - subgraphName: 'dan13ram/quest-chains-mumbai', - subgraphUrl: 'https://api.thegraph.com/subgraphs/name/dan13ram/quest-chains-mumbai', + subgraphName: 'quest-chains/quest-chains-mumbai', + subgraphUrl: 'https://api.thegraph.com/subgraphs/name/quest-chains/quest-chains-mumbai', }, }; diff --git a/src/graphql/fragments.graphql b/src/graphql/fragments.graphql index 3d53c9d..24fe197 100644 --- a/src/graphql/fragments.graphql +++ b/src/graphql/fragments.graphql @@ -31,6 +31,7 @@ fragment QuestChainInfo on QuestChain { numCompletedQuesters description imageUrl + slug quests { questId paused diff --git a/src/graphql/queries.graphql b/src/graphql/queries.graphql index fe8b5b8..31d3efd 100644 --- a/src/graphql/queries.graphql +++ b/src/graphql/queries.graphql @@ -11,12 +11,7 @@ query QuestChainsInfo($limit: Int) { } query CreatedQuestChainsInfo($limit: Int, $user: String) { - questChains( - first: $limit - where: { createdBy: $user } - orderBy: createdAt - orderDirection: desc - ) { + questChains(first: $limit, where: { createdBy: $user }, orderBy: createdAt, orderDirection: desc) { ...QuestChainInfo } } @@ -44,13 +39,8 @@ query QuestChainSearch($search: String, $limit: Int) { } } -query QuestChainSearch($search: String, $limit: Int) { - questChains( - first: $limit - where: { search_contains: $search, paused: false } - orderBy: createdAt - orderDirection: desc - ) { +query QuestChainSearchBySlug($slug: String) { + questChains(where: { slug: $slug }) { ...QuestChainInfo } } diff --git a/src/graphql/questChains.ts b/src/graphql/questChains.ts index c9d5490..cbd80cd 100644 --- a/src/graphql/questChains.ts +++ b/src/graphql/questChains.ts @@ -10,6 +10,9 @@ import { QuestChainInfoFragment, QuestChainInfoQuery, QuestChainInfoQueryVariables, + QuestChainSearchBySlugDocument, + QuestChainSearchBySlugQuery, + QuestChainSearchBySlugQueryVariables, QuestChainSearchDocument, QuestChainSearchQuery, QuestChainSearchQueryVariables, @@ -61,6 +64,21 @@ export const getQuestChainsFromSearch = async (chainId: string, search: string): return data.questChains; }; +export const getQuestChainsFromSlug = async (chainId: string, slug: string): Promise => { + const { data, error } = await getClient(chainId) + .query(QuestChainSearchBySlugDocument, { + slug: slug.toLowerCase(), + }) + .toPromise(); + if (!data) { + if (error) { + throw error; + } + return []; + } + return data.questChains; +}; + export const getCreatedQuestChains = async (chainId: string, address: string): Promise => { const { data, error } = await getClient(chainId) .query(CreatedQuestChainsInfoDocument, { diff --git a/src/metadata/schema.json b/src/metadata/schema.json index e7e949c..65883b5 100644 --- a/src/metadata/schema.json +++ b/src/metadata/schema.json @@ -38,6 +38,14 @@ "default": "", "examples": ["ipfs://QmZTzK8YAsPcLoKENzWmXv519pDmX1XgNQ6h9RtnSjwksn"] }, + "slug": { + "$id": "#/properties/slug", + "type": "string", + "title": "The slug schema", + "description": "This property defines an optional slug for the item", + "default": "", + "examples": ["path-of-the-engaged"] + }, "animation_url": { "$id": "#/properties/animation_url", "type": "string", diff --git a/src/metadata/validate.ts b/src/metadata/validate.ts index 4390ce2..1db09c8 100644 --- a/src/metadata/validate.ts +++ b/src/metadata/validate.ts @@ -11,6 +11,7 @@ export type Metadata = { image_url?: string; animation_url?: string; external_url?: string; + slug?: string; attributes?: { trait_type?: string; value: string | number;