Skip to content

Commit

Permalink
feat: upgrade graph version, remove web3storage functionality,
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrohba1 committed Jan 13, 2024
1 parent 6def74d commit ef5793e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
40 changes: 20 additions & 20 deletions front-end/app/api/store/route.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { NextResponse } from "next/server";
import { Web3Storage, File } from "web3.storage";
// import { Web3Storage, File } from "web3.storage";

export async function POST(req: Request) {
const formData = await req.formData();
const formDataEntries = Array.from(formData.entries());
// const formData = await req.formData();
// const formDataEntries = Array.from(formData.entries());

const files = [];
for (const [fieldName, formDataEntryValue] of formDataEntries) {
if (
typeof formDataEntryValue === "object" &&
"arrayBuffer" in formDataEntryValue
) {
const blob = formDataEntryValue as Blob;
// Create a File object from the Blob and set its name.
const file = new File([blob], fieldName);
files.push(file);
}
}
// const files = [];
// for (const [fieldName, formDataEntryValue] of formDataEntries) {
// if (
// typeof formDataEntryValue === "object" &&
// "arrayBuffer" in formDataEntryValue
// ) {
// const blob = formDataEntryValue as Blob;
// // Create a File object from the Blob and set its name.
// const file = new File([blob], fieldName);
// files.push(file);
// }
// }

const client = new Web3Storage({
token: String(process.env.WEB3_STORAGE_TOKEN),
});
// const client = new Web3Storage({
// token: String(process.env.WEB3_STORAGE_TOKEN),
// });

const cid = await client.put(files);
// const cid = await client.put(files);

return NextResponse.json({ cid });
return NextResponse.json({ cid: "0x00" });
}
2 changes: 2 additions & 0 deletions front-end/components/FileUploader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export const FileUploader = ({
className="bg-pg-primary py-2 px-4 font-bold w-1/2 mt-3"
type="submit"
>
{/* TODO: mostrar uma caixa com todos os carregamentos. Primeiro o que envia para o IPFS e depois o que envia para a rede */}
{/* TODO: corrigir redirect de página, para redirecionar corretamente após criação do contrato */}
Create contract
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion front-end/config/contractConstants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const contractConstants = {
PeerGradingAddress: "0x1C7E64bF2A366DCE4EFDEb671e9cc988ec625d7a",
PeerGradingAddress: "0x90164B2beaD98d87a7D9435761FDeBBF00c14513",
};
2 changes: 1 addition & 1 deletion front-end/lib/services/apollo/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloClient, InMemoryCache } from "@apollo/client";

export const client = new ApolloClient({
uri: "https://api.studio.thegraph.com/query/53131/peer-grading-subgraph/v0.0.11",
uri: "https://api.studio.thegraph.com/query/53131/peer-grading-subgraph/v0.0.12",
cache: new InMemoryCache(),
});
1 change: 1 addition & 0 deletions front-end/lib/wagmi/useCreatePReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface Args {
ipfsHash: string;
}

// TODO: tratar erros de criação de contrato.
export function useCreatePReview({ participants, workload, ipfsHash }: Args) {
const { config } = usePrepareContractWrite({
address: contractConstants.PeerGradingAddress as `0x${string}`,
Expand Down

0 comments on commit ef5793e

Please sign in to comment.