Skip to content

Commit

Permalink
updated sdk version and fixed fetching of descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtmeeseeks committed Oct 28, 2024
1 parent 9761160 commit 10fa664
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
19 changes: 18 additions & 1 deletion src/api/contributions.api.ts
Original file line number Diff line number Diff line change
@@ -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<string, Hub> = {};

Expand Down Expand Up @@ -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,
Expand All @@ -49,7 +66,7 @@ const createContribution = async (
endDate: contribution.properties.endDate,
points: contribution.properties.points,
quantity: contribution.properties.quantity,
uri: uri
descriptionId: descriptionId
},
overrides
);
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useQueryContributions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseNFTModel<any>>(
contribution.uri,
uri,
environment.ipfsGatewayUrl
);
return {
Expand Down

0 comments on commit 10fa664

Please sign in to comment.