Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Jipperism committed Oct 27, 2023
1 parent 84e1a8c commit e81b090
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions components/admin/create-registry-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "@/components/forms/create-or-update-registry-form";
import { useChainId } from "wagmi";
import { useCreateClaims } from "@/hooks/useCreateClaims";
import { useHypercertClient } from "@/components/providers";

export const CreateRegistryModal = ({
initialValues,
Expand All @@ -22,6 +23,7 @@ export const CreateRegistryModal = ({
const address = useAddress();
const toast = useToast();
const chainId = useChainId();
const client = useHypercertClient();

const { refetch } = useMyRegistries();
const { mutateAsync: createClaims } = useCreateClaims();
Expand All @@ -30,6 +32,17 @@ export const CreateRegistryModal = ({
claims,
...registry
}: CreateUpdateRegistryFormValues) => {
if (!client) {
toast({
title: "Error",
description: "Client not initialized",
status: "error",
duration: 9000,
isClosable: true,
});
return;
}

if (!address) {
toast({
title: "Error",
Expand Down Expand Up @@ -86,12 +99,21 @@ export const CreateRegistryModal = ({
});

try {
const claimInserts: ClaimInsert[] = claims.map(({ hypercert_id }) => ({
registry_id: insertedRegistry.id,
hypercert_id,
chain_id: chainId,
admin_id: address,
}));
const claimInserts: ClaimInsert[] = await Promise.all(
claims.map(async ({ hypercert_id }) => {
const claim = await client.indexer.claimById(hypercert_id);
if (!claim.claim) {
throw new Error("Claim not found");
}
return {
registry_id: insertedRegistry.id,
hypercert_id,
chain_id: chainId,
admin_id: address,
owner_id: claim.claim.owner,
};
}),
);
await createClaims({
claims: claimInserts,
});
Expand Down

0 comments on commit e81b090

Please sign in to comment.