Skip to content

Commit

Permalink
fix: vouch icon does not show due to legacy subgraph issue on registr…
Browse files Browse the repository at this point in the history
…ation

Profiles keep both registrations from issue on legacy subgraph

Pending fix on subgraph

This is a temporary workaround for fixing the issue at front-end
  • Loading branch information
martillansky committed Oct 28, 2024
1 parent 42edc65 commit 9b89ebe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/app/[pohid]/[chain]/[request]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
import { EvidenceFile, MetaEvidenceFile, RegistrationFile } from "types/docs";
import { ipfs, ipfsFetch } from "utils/ipfs";
import { SupportedChainId, paramToChain, supportedChains } from "config/chains";
import ActionBar from "./ActionBar";
import Evidence from "./Evidence";
import { getOffChainVouches, getRequestData } from "data/request";
import { getContractData } from "data/contract";
import { getArbitrationCost } from "data/costs";
import { machinifyId, prettifyId } from "utils/identifier";
import { Hash } from "@wagmi/core";
import Attachment from "components/Attachment";
import ChainLogo from "components/ChainLogo";
import ExternalLink from "components/ExternalLink";
import Identicon from "components/Identicon";
import { explorerLink } from "config/chains";
import Image from "next/image";
import Previewed from "components/Previewed";
import Label from "components/Label";
import Previewed from "components/Previewed";
import TimeAgo from "components/TimeAgo";
import Link from "next/link";
import Attachment from "components/Attachment";
import ChainLogo from "components/ChainLogo";
import Info from "./Info";
import { Address } from "viem";
import { Hash } from "@wagmi/core";
import { getClaimerData } from "data/claimer";
import { ClaimerQuery, Request, Vouch as VouchQuery } from "generated/graphql";
import Vouch from "components/Vouch";
import {
SupportedChainId,
explorerLink,
paramToChain,
supportedChains,
} from "config/chains";
import { getClaimerData } from "data/claimer";
import { getContractData } from "data/contract";
import { getArbitrationCost } from "data/costs";
import { getOffChainVouches, getRequestData } from "data/request";
import { ValidVouch, isValidOnChainVouch, isValidVouch } from "data/vouch";
import { ClaimerQuery, Request, Vouch as VouchQuery } from "generated/graphql";
import Image from "next/image";
import Link from "next/link";
import { EvidenceFile, MetaEvidenceFile, RegistrationFile } from "types/docs";
import { machinifyId, prettifyId } from "utils/identifier";
import { ipfs, ipfsFetch } from "utils/ipfs";
import { Address } from "viem";
import ActionBar from "./ActionBar";
import Evidence from "./Evidence";
import Info from "./Info";

interface PageProps {
params: { pohid: string; chain: string; request: string };
Expand Down
23 changes: 23 additions & 0 deletions src/data/claimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ import { cache } from "react";
import { Address } from "viem";
import { sanitizeClaimerData } from "./sanitizer";

// This fixes an error in the legacy subgraph were registration has not
// been removed as expected. Once solved the issue at subgraph level this
// function should be removed
const sanitizeRegistration = (res: Record<SupportedChainId, ClaimerQuery>) => {
var regChain: SupportedChainId | undefined = undefined;
supportedChains.map((chain) => {
if (!regChain && res[chain.id].claimer?.registration) regChain = chain.id;
else if (regChain && res[chain.id].claimer?.registration) {
if (
res[regChain].claimer?.registration?.humanity.winnerClaim.at(0)
?.resolutionTime >
res[chain.id].claimer?.registration?.humanity.winnerClaim.at(0)
?.resolutionTime
) {
res[chain.id].claimer!.registration = null;
} else {
res[regChain].claimer!.registration = null;
}
}
});
};

export const getClaimerData = cache(async (id: Address) => {
const res = await Promise.all(
supportedChains.map((chain) => sdk[chain.id].Claimer({ id })),
Expand All @@ -15,5 +37,6 @@ export const getClaimerData = cache(async (id: Address) => {
{} as Record<SupportedChainId, ClaimerQuery>,
);

sanitizeRegistration(out);
return await sanitizeClaimerData(out, id);
});

0 comments on commit 9b89ebe

Please sign in to comment.