Skip to content

Commit

Permalink
Quests subgraph done
Browse files Browse the repository at this point in the history
  • Loading branch information
Corantin committed Oct 29, 2023
1 parent aae93f2 commit 9520dbc
Show file tree
Hide file tree
Showing 29 changed files with 4,653 additions and 2,079 deletions.
3 changes: 2 additions & 1 deletion packages/hardhat/deploy/deploy-quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default async ({
}: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

// Get another deployed contract address
const { address: tokenAddress } = await deployments.get("DeedNFT");
const deployResult = await deploy("Quest", {
from: deployer,
args: questConstructorArguments,
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deployments/xdai/Govern.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x9CA2A0fB572D63dc5ED203ae271898db52e69dA4",
"address": "0x549748A54ce150D75f73504Dd720C3adF04c9173",
"abi": [
{
"type": "constructor",
Expand Down
10 changes: 4 additions & 6 deletions packages/react-app/src/components/quest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,10 @@ export default function Quest({
<QuestFooterStyled>
{walletConnected ? (
<>
{questData.isWhitelist && (
<PlayerListModal
questData={questData}
isEdit={walletAddress === questData.creatorAddress && questData.isWhitelist}
/>
)}
<PlayerListModal
questData={questData}
isEdit={walletAddress === questData.creatorAddress && questData.isWhitelist}
/>
<FundModal quest={questData} />
{questData.features.playableQuest && !questData.isWhitelist && (
<>
Expand Down
3 changes: 1 addition & 2 deletions packages/react-app/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const networks = Object.freeze({
chainId: 5,
name: 'Goerli tesnet',
explorer: 'etherscan',
questsSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/quests-goerli',
questsSubgraph: 'https://api.studio.thegraph.com/query/33583/quests-goerli/version/latest',
governSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/govern-goerli',
tokenPairSubgraph: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2',
questFactoryAddress: HardhatDeployement[5].goerli.contracts.QuestFactory.address,
Expand All @@ -24,7 +24,6 @@ export const networks = Object.freeze({
},
goerliStaging: {
stagingOf: 'goerli',
questsSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/quests-goerli-staging',
governSubgraph: 'https://api.thegraph.com/subgraphs/name/corantin/govern-goerli-staging',
} as StagingNetworkModel,
gnosis: {
Expand Down
15 changes: 10 additions & 5 deletions packages/react-app/src/queries/quests.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ const QuestEntityQuery = gql`
version
questAddress
questTitle
questDescription
questCommunicationLink
questExpireTimeSec
questDetailsRef
questMetadata {
id
questDescription
questCommunicationLink
}
questRewardTokenAddress
creationTimestamp
questCreateDepositToken
Expand Down Expand Up @@ -90,9 +92,12 @@ const QuestEntitiesQuery = (payload: any) => gql`
version
questAddress
questTitle
questDescription
questExpireTimeSec
questDetailsRef
questMetadata {
id
questDescription
questCommunicationLink
}
questRewardTokenAddress
creationTimestamp
questCreateDepositToken
Expand Down
16 changes: 4 additions & 12 deletions packages/react-app/src/services/quest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { request } from 'graphql-request';
import { FilterModel } from 'src/models/filter.model';
import { TokenAmountModel } from 'src/models/token-amount.model';
import { getNetwork } from 'src/networks';
import { hexToBytes, toAscii, toChecksumAddress } from 'web3-utils';
import { hexToBytes, toChecksumAddress } from 'web3-utils';
import {
GovernQueueChallengeReasonQuery,
GovernQueueChallengesQuery,
Expand Down Expand Up @@ -64,7 +64,6 @@ import {
cacheGovernQueueAddressForQuest,
} from './cache.service';
import { loadFeatureSupport } from './feature-support.service';
import { isDevelopement } from 'src/components/utils/debug-util';

let questList: QuestModel[] = [];

Expand All @@ -78,9 +77,9 @@ async function mapQuest(questEntity: any, claimCountMap: Map<string, number>) {
const quest: QuestModel = {
address: questAddress,
title: questEntity.questTitle,
description: questEntity.questDescription || undefined, // if '' -> undefined
communicationLink: questEntity.questCommunicationLink,
detailsRefIpfs: toAscii(questEntity.questDetailsRef),
description: questEntity.questMetadata.questDescription,
communicationLink: questEntity.questMetadata.questCommunicationLink,
detailsRefIpfs: questEntity.questMetadata.id,
rewardToken: (await getTokenInfo(questEntity.questRewardTokenAddress)) ?? undefined,
expireTime: new Date(questEntity.questExpireTimeSec * 1000), // sec to Ms
creationTime: new Date(questEntity.creationTimestamp * 1000), // sec to Ms
Expand Down Expand Up @@ -111,13 +110,6 @@ async function mapQuest(questEntity: any, claimCountMap: Map<string, number>) {

loadFeatureSupport(quest);

if (!quest.detailsRefIpfs) {
quest.description = '[No description]';
} else if (!quest.description) {
// If failed to fetch ipfs description
quest.description = formatIpfsMarkdownLink(quest.detailsRefIpfs, 'See description');
}

if (quest?.maxPlayers !== undefined) {
quest.players = await getQuestContract(quest).getPlayers();
}
Expand Down
Loading

0 comments on commit 9520dbc

Please sign in to comment.