From 10fa664d96803b2d459aae4c3db1fce85383cc6c Mon Sep 17 00:00:00 2001 From: mrtmeeseeks Date: Mon, 28 Oct 2024 21:00:35 +0200 Subject: [PATCH] updated sdk version and fixed fetching of descriptions --- package-lock.json | 28 ++++++++++++++-------------- package.json | 8 ++++---- src/api/contributions.api.ts | 19 ++++++++++++++++++- src/hooks/useQueryContributions.tsx | 5 ++++- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 341b07f..fe2aff8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,10 @@ "version": "0.1.0", "dependencies": { "@apollo/client": "^3.9.1", - "@aut-labs/abi-types": "^0.0.83-dev", + "@aut-labs/abi-types": "^0.0.86-dev", "@aut-labs/connector": "^0.0.203", - "@aut-labs/d-aut": "^1.0.202-dev", - "@aut-labs/sdk": "^0.0.212-dev", + "@aut-labs/d-aut": "^1.0.204-dev", + "@aut-labs/sdk": "^0.0.220-dev", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@leenguyen/react-flip-clock-countdown": "^1.4.0", @@ -34,6 +34,7 @@ "emoji-mart": "^5.5.2", "ethers": "^6.10.0", "flipdown": "^0.3.2", + "graphql": "^16.8.1", "react": "^18.2.0", "react-copy-to-clipboard": "^5.1.0", "react-cropper": "^2.3.3", @@ -148,9 +149,9 @@ } }, "node_modules/@aut-labs/abi-types": { - "version": "0.0.83-dev", - "resolved": "https://registry.npmjs.org/@aut-labs/abi-types/-/abi-types-0.0.83-dev.tgz", - "integrity": "sha512-TYdWEyJ5rAM5uJSF4HwsKbSpygfDhg7PTyahXwEO2cyT4cDz65VAu9B5kA2FOum0teraKrbxHA+5gILVHYzeig==", + "version": "0.0.86-dev", + "resolved": "https://registry.npmjs.org/@aut-labs/abi-types/-/abi-types-0.0.86-dev.tgz", + "integrity": "sha512-I9VNsYN8smW516wPQeDWhJaw4OWiIc7WxRBIn2GkqKw4oYKaLbDRzTV2XXVrMlvVCo7V82V51SlV+fC0Hajq/w==", "license": "ISC" }, "node_modules/@aut-labs/connector": { @@ -178,17 +179,17 @@ } }, "node_modules/@aut-labs/d-aut": { - "version": "1.0.202-dev", - "resolved": "https://registry.npmjs.org/@aut-labs/d-aut/-/d-aut-1.0.202-dev.tgz", - "integrity": "sha512-ocqU6ousVfW/ffOz8IIpx8Kr8OjS2xKTyPR/y4PgLetEb0rC7BJKDztTd6ztHMvTddsH24OvdHp4oiN0EgdmJQ==" + "version": "1.0.204-dev", + "resolved": "https://registry.npmjs.org/@aut-labs/d-aut/-/d-aut-1.0.204-dev.tgz", + "integrity": "sha512-sDEu6yyvqu/KjqobI6nBoovrHWwhA4DoXPWObQLcGRs1Isuxg/d2HhP2/9k6Xz5zjFDo/w3MDI3XDvpVos20dg==" }, "node_modules/@aut-labs/sdk": { - "version": "0.0.212-dev", - "resolved": "https://registry.npmjs.org/@aut-labs/sdk/-/sdk-0.0.212-dev.tgz", - "integrity": "sha512-+dbUE8TdthXebu1nRAMGaT/MmGs9ZCLR/ysWUWtLJvi0ESAmEPrgvgJO2qNGVmdTrzvfNCfOs5+ppu9IxoUIiw==", + "version": "0.0.220-dev", + "resolved": "https://registry.npmjs.org/@aut-labs/sdk/-/sdk-0.0.220-dev.tgz", + "integrity": "sha512-Y5ud38chCfVVfKwr8mEP9IP5kZUImC6V1ZkmoUGUX9fyGHdDg56OVlAr7OaJnU/IfrJDDCuQllyLVk4QZJB6Xw==", "license": "MIT", "dependencies": { - "@aut-labs/abi-types": "^0.0.83-dev", + "@aut-labs/abi-types": "^0.0.86-dev", "date-fns": "^2.29.3", "ethers": "^6.10.0" } @@ -13028,7 +13029,6 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", "license": "MIT", - "peer": true, "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } diff --git a/package.json b/package.json index f39368c..96d7a53 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ }, "dependencies": { "@apollo/client": "^3.9.1", - "@aut-labs/abi-types": "^0.0.83-dev", + "@aut-labs/abi-types": "^0.0.86-dev", "@aut-labs/connector": "^0.0.203", - "@aut-labs/d-aut": "^1.0.202-dev", - "@aut-labs/sdk": "^0.0.212-dev", + "@aut-labs/d-aut": "^1.0.204-dev", + "@aut-labs/sdk": "^0.0.220-dev", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@leenguyen/react-flip-clock-countdown": "^1.4.0", @@ -50,11 +50,11 @@ "clsx": "^2.1.0", "date-fns": "3.2.0", "dateformat": "^5.0.3", - "graphql": "^16.8.1", "dayjs": "^1.11.8", "emoji-mart": "^5.5.2", "ethers": "^6.10.0", "flipdown": "^0.3.2", + "graphql": "^16.8.1", "react": "^18.2.0", "react-copy-to-clipboard": "^5.1.0", "react-cropper": "^2.3.3", diff --git a/src/api/contributions.api.ts b/src/api/contributions.api.ts index 20963b5..ae938ab 100644 --- a/src/api/contributions.api.ts +++ b/src/api/contributions.api.ts @@ -1,11 +1,13 @@ import AutSDK, { BaseNFTModel, + findLogEvent, getOverrides, Hub, TaskContributionNFT } from "@aut-labs/sdk"; import { BaseQueryApi, createApi } from "@reduxjs/toolkit/query/react"; import { OpenTaskContribution } from "./contribution.model"; +import { TaskFactoryContractEventType } from "@aut-labs/abi-types"; const hubServiceCache: Record = {}; @@ -41,6 +43,21 @@ const createContribution = async ( quantity: contribution.properties.quantity, uri: uri }); + + const tx = await (await taskFactory.functions.registerDescription( + { uri }, + overrides + )).wait(); + debugger; + + const event = findLogEvent(tx, TaskFactoryContractEventType.RegisterDescription); + if (!event) { + return { + error: "Failed to register description" + }; + } + + const descriptionId = event.args[0]?.toString(); const response = await taskFactory.createContribution( { taskId: contribution.properties.taskId, @@ -49,7 +66,7 @@ const createContribution = async ( endDate: contribution.properties.endDate, points: contribution.properties.points, quantity: contribution.properties.quantity, - uri: uri + descriptionId: descriptionId }, overrides ); diff --git a/src/hooks/useQueryContributions.tsx b/src/hooks/useQueryContributions.tsx index d37ef8c..e00b6b5 100644 --- a/src/hooks/useQueryContributions.tsx +++ b/src/hooks/useQueryContributions.tsx @@ -24,8 +24,11 @@ const fetchOnChainContributions = async ( ids.map(async (id) => { const _contribution = await taskFactory.functions.getContributionById(id); const contribution = TaskContribution.mapFromTuple(_contribution as any); + const { uri } = await taskFactory.functions.getDescriptionById( + contribution.descriptionId + ); const metadata = await fetchMetadata>( - contribution.uri, + uri, environment.ipfsGatewayUrl ); return {