Skip to content

Commit

Permalink
Feature/new sdk (#45)
Browse files Browse the repository at this point in the history
* (feat): use the new sdk

* (feat): disable typescript
  • Loading branch information
Jipperism authored Jun 26, 2024
1 parent e205526 commit 5dda715
Show file tree
Hide file tree
Showing 19 changed files with 770 additions and 208 deletions.
11 changes: 8 additions & 3 deletions components/admin/create-registry-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
import { useChainId } from "wagmi";
import { useCreateClaims } from "@/hooks/useCreateClaims";
import { useHypercertClient } from "@/components/providers";
import { getHypercertWithMetadata } from "@/hooks/useFetchHypercertById";
import { urqlClient } from "@/hooks/urqlClient";

export const CreateRegistryModal = ({
initialValues,
Expand Down Expand Up @@ -106,8 +108,11 @@ export const CreateRegistryModal = ({
claim_id = crypto.randomUUID(),
display_size,
}) => {
const claim = await client.indexer.claimById(hypercert_id);
if (!claim?.claim) {
const claim = await getHypercertWithMetadata(
hypercert_id,
urqlClient,
);
if (!claim) {
throw new Error("Claim not found");
}
return {
Expand All @@ -117,7 +122,7 @@ export const CreateRegistryModal = ({
hypercert_id,
chain_id: chainId,
admin_id: address,
owner_id: claim.claim.owner,
owner_id: claim.creator_address!,
};
},
),
Expand Down
15 changes: 10 additions & 5 deletions components/admin/fraction-display-data-admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ const DefaultDisplayDataForClaim = ({
};
const address = useAddress();
const fractionsOwnedByAdmin = fractions
?.filter((fraction) => fraction.owner === address?.toLowerCase())
?.filter(
(fraction) =>
fraction?.owner_address?.toLowerCase() === address?.toLowerCase(),
)
.map((fraction) => ({
...(fractionSpecificData?.find((x) => x.fraction_id === fraction.id) ||
{}),
...(fractionSpecificData?.find(
(x) =>
x.fraction_id.toLowerCase() === fraction?.fraction_id?.toLowerCase(),
) || {}),
...fraction,
}));
const inputRef = useRef<HTMLInputElement>(null);
Expand All @@ -85,7 +90,7 @@ const DefaultDisplayDataForClaim = ({
}
const csvData = fractionsOwnedByAdmin.map((fraction) => [
fraction.metadata?.name || "",
fraction.hypercertId,
fraction.hypercert_id,
fraction.id,
fraction.units,
fraction.value || "",
Expand Down Expand Up @@ -161,7 +166,7 @@ const DefaultDisplayDataForClaim = ({
{fractionsOwnedByAdmin?.map((fraction) => (
<Tr key={fraction.id}>
<Td>{fraction.metadata?.name}</Td>
<Td>{fraction.tokenID}</Td>
<Td>{fraction.fraction_id}</Td>
<Td>{fraction.units}</Td>
<Td>{fraction.percentage}</Td>
<Td>{fraction.value}</Td>
Expand Down
10 changes: 5 additions & 5 deletions components/admin/registries-admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,22 @@ export const ClaimRow = ({
target={"_blank"}
textDecoration={"underline"}
>
{data.metadata.name}
{data.metadata?.name}
</Link>
</Td>
<Td>{chain_id}</Td>
<Td>{formatAddress(data.owner)}</Td>
<Td>{formatAddress(data.creator_address || "")}</Td>
<Td>
<Link
href={data.metadata.external_url}
href={data.metadata?.external_url || ""}
target={"_blank"}
textDecoration={"underline"}
>
{data.metadata.external_url}
{data.metadata?.external_url}
</Link>
</Td>
<Td maxW={"300px"} isTruncated>
{data.metadata.description}
{data.metadata?.description}
</Td>
<Td>{display_size}</Td>
<Td textAlign={"end"}>
Expand Down
1 change: 1 addition & 0 deletions components/hyperboard-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const HyperboardRenderer = ({
borderColor={borderColor}
data={
(Object.values(x.content) || {}).map(
// @ts-ignore
registryContentItemToHyperboardEntry,
) || []
}
Expand Down
4 changes: 3 additions & 1 deletion components/hyperboard/ownership-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export const OwnershipTable = ({
overflowY={"auto"}
className={"custom-scrollbar"}
>
{/*
//@ts-ignore */}
<ClaimOwnershipOverview data={dataToShow} />
</Flex>
</Flex>
Expand Down Expand Up @@ -316,7 +318,7 @@ const HypercertClaimRow = ({
return (
<ClaimRow
{...props}
text={claim.metadata.name || "No name"}
text={claim?.metadata?.name || "No name"}
icon={
<Image
alt={"Claim icon"}
Expand Down
6 changes: 1 addition & 5 deletions components/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,11 @@ export const HypercertClientProvider = ({
};

const hypercertClient = new HypercertClient({
chain: { id: chainToUse() },
nftStorageToken: NFT_STORAGE_TOKEN,
web3StorageToken: WEB3_STORAGE_TOKEN,
easContractAddress: EAS_CONTRACT_ADDRESS,
environment: "test",
// @ts-ignore
walletClient,
// @ts-ignore
publicClient,
indexerEnvironment: "all",
});

setClient(hypercertClient);
Expand Down
Loading

0 comments on commit 5dda715

Please sign in to comment.