Skip to content

Commit

Permalink
Merge pull request #37 from martillansky/Desing-alignment
Browse files Browse the repository at this point in the history
Chiado + IPFS Gateway
  • Loading branch information
martillansky authored Mar 29, 2024
2 parents c6b4d60 + dc2b959 commit a3b27ba
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 18 deletions.
1 change: 1 addition & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare global {
namespace NodeJS {
interface ProcessEnv {
GNOSIS_RPC: string;
CHIADO_RPC: string;
SEPOLIA_RPC: string;
FILEBASE_TOKEN: string;
DATALAKE_URL: string;
Expand Down
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ const nextConfig = {

return config;
},
env: {
REACT_APP_IPFS_GATEWAY: process.env.REACT_APP_IPFS_GATEWAY,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: process.env.REACT_APP_IPFS_GATEWAY,
//hostname: "ipfs.kleros.io",
port: "",
pathname: "/ipfs/**",
},
Expand Down
15 changes: 8 additions & 7 deletions src/app/[pohid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ async function Profile({ params: { pohid } }: PageProps) {
(chain) => !!humanity[chain.id]?.crossChainRegistration
);

const humanityHomeChainRegistration = homeChain && humanity[homeChain.id]!.humanity!.registration;
//const humanityHomeChainRegistration = homeChain && humanity[homeChain.id]!.humanity!.registration;
const humanityCrossChainRegistration = homeCrossChain && humanity[homeCrossChain.id].crossChainRegistration;

console.log(">>>>>>>>> >>>>>>> >>>>> >>> > ", homeChain, homeCrossChain, humanityCrossChainRegistration);

const arbitrationCost = homeChain
? await getArbitrationCost(
Expand All @@ -67,7 +68,7 @@ async function Profile({ params: { pohid } }: PageProps) {
})[0]
: null;

const humanityLEChainRegistration = lastEvidenceChain && humanity[lastEvidenceChain.id]!.humanity!.registration;
//const humanityLEChainRegistration = lastEvidenceChain && humanity[lastEvidenceChain.id]!.humanity!.registration;

const pendingRequests = supportedChains.reduce(
(acc, chain) => [
Expand All @@ -86,16 +87,16 @@ async function Profile({ params: { pohid } }: PageProps) {
);


let expired = (lastEvidenceChain && humanity[lastEvidenceChain.id]!.humanity!.registration!.expirationTime < Date.now() / 1000)
let expired = (lastEvidenceChain && humanity[lastEvidenceChain.id]!.humanity!.registration!.expirationTime < Date.now() / 1000);

let winnerClaimRequest =
(lastEvidenceChain &&
!(expired) && // It did not expired
humanity[lastEvidenceChain.id].humanity!.winnerClaim[0]);

if (!winnerClaimRequest) {
winnerClaimRequest = (!!homeCrossChain && humanity[homeCrossChain.id].humanity!.winnerClaim[0]);
if (!(!!lastEvidenceChain) && !winnerClaimRequest) {
expired = (!!humanityCrossChainRegistration && humanityCrossChainRegistration.expirationTime < Date.now() / 1000);
winnerClaimRequest = (!expired && !!homeCrossChain && humanity[homeCrossChain.id].humanity!.winnerClaim[0]);
}

// pastRequests must not contain pendingRequests nor winningClaimRequest if it did not expired
Expand Down Expand Up @@ -229,7 +230,7 @@ async function Profile({ params: { pohid } }: PageProps) {
lastTransferChain={lastTransferChain}
/>
</>
) : homeCrossChain && humanityCrossChainRegistration ? (
) : homeCrossChain && humanityCrossChainRegistration && !expired ? (
<CrossChain
claimer={
humanityCrossChainRegistration!.claimer.id
Expand Down Expand Up @@ -356,7 +357,7 @@ async function Profile({ params: { pohid } }: PageProps) {
<div className="grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4">
{pastRequests.map((req) => (
<Card
key={req.id}
key={req.chainId+'/'+req.id}
chainId={req.chainId}
claimer={req.claimer.id}
evidence={req.evidenceGroup.evidence}
Expand Down
6 changes: 4 additions & 2 deletions src/components/ChainLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import { SVGProps } from "react";
import { mainnet, sepolia, gnosis } from "viem/chains";
import { mainnet, sepolia, gnosis, gnosisChiado } from "viem/chains";
import MainnetIcon from "icons/mainnet.svg";
import GnosisIcon from "icons/gnosis.svg";
// import TestnetIcon from "icons/testnet.svg";
import TestnetIcon from "icons/testnet.svg";

interface ChainLogoProps extends SVGProps<any> {
chainId: number;
Expand All @@ -18,6 +18,8 @@ const ChainLogo: React.FC<ChainLogoProps> = ({ chainId, ...props }) => {
return <MainnetIcon {...props} />;
case gnosis.id:
return <GnosisIcon {...props} />;
case gnosisChiado.id:
return <TestnetIcon {...props} />;
default:
throw new Error("chain not supported");
}
Expand Down
10 changes: 8 additions & 2 deletions src/config/chains.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gnosis, sepolia } from "viem/chains";
import { gnosis, sepolia, /* gnosisChiado */ } from "viem/chains";

export const supportedChains = [gnosis, sepolia];
export const supportedChains = [gnosis, sepolia, /* gnosisChiado */];
export const defaultChain = supportedChains[0];

export const legacyChain = sepolia;
Expand All @@ -16,6 +16,8 @@ export function nameToChain(name: string): SupportedChain | null {
return sepolia;
case gnosis.name.toLowerCase():
return gnosis;
/* case gnosisChiado.name.toLowerCase():
return gnosisChiado; */
default:
return null;
// throw new Error("chain not supported");
Expand All @@ -28,6 +30,8 @@ export function idToChain(id: number): SupportedChain | null {
return sepolia;
case gnosis.id:
return gnosis;
/* case gnosisChiado.id:
return gnosisChiado; */
default:
return null;
// throw new Error("chain not supported");
Expand All @@ -49,6 +53,8 @@ export function getChainRpc(id: number): string {
return process.env.SEPOLIA_RPC;
case gnosis.id:
return process.env.GNOSIS_RPC;
/* case gnosisChiado.id:
return process.env.CHIADO_RPC; */
default:
throw new Error("chain not supported");
}
Expand Down
1 change: 0 additions & 1 deletion src/config/index.ts

This file was deleted.

8 changes: 7 additions & 1 deletion src/config/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSdk } from "generated/graphql";
import { GraphQLClient } from "graphql-request";
import { gnosis, sepolia } from "viem/chains";
import { gnosis, sepolia, /* gnosisChiado */ } from "viem/chains";
import { SupportedChainId } from "./chains";

export type sdkReturnType = ReturnType<typeof getSdk>;
Expand All @@ -21,4 +21,10 @@ export const sdk = {
"https://api.studio.thegraph.com/query/64099/proof-of-humanity-gnosis/version/latest"
)
),
/* [gnosisChiado.id]: getSdk(
new GraphQLClient(
"https://api.studio.thegraph.com/query/64099/proof-of-humanity-gnosis/version/latest"
//"https://api.studio.thegraph.com/query/64099/proof-of-humanity-chiado/version/latest"
)
), */
};
5 changes: 4 additions & 1 deletion src/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { gnosis, sepolia } from "viem/chains";
import { gnosis, sepolia, /* gnosisChiado */ } from "viem/chains";

export const Contract = {
ProofOfHumanity: {
[sepolia.id]: "0x29defF3DbEf6f79ef20d3fe4f9CFa0547acCeC0D",
//[gnosis.id]: "0xB6412c84eC958cafcC80B688d6F473e399be488f",
[gnosis.id]: "0x4a594f0e73223c9a1CE0EfC16da92fFaA193a612",
//[gnosisChiado.id]: "0x2505C87AA36d9ed18514Ea7473Ac58aeDeb50849",
},
CrossChainProofOfHumanity: {
[sepolia.id]: "0xd134748B972A320a73EfDe3AfF7a68718F6bA92c",
[gnosis.id]: "0x2C692919Da3B5471F9Ac6ae1C9D1EE54F8111f76",
//[gnosisChiado.id]: "0xBEd896A3DEa0E065F05Ba83Fa63322c7b9d67838",
},
Multicall3: {
[sepolia.id]: sepolia.contracts.multicall3.address,
[gnosis.id]: gnosis.contracts.multicall3.address,
//[gnosisChiado.id]: gnosisChiado.contracts.multicall3.address,
},
// GroupCurrencyToken: {
// [sepolia.id]: "0x0000000000000000000000000000000000000000",
Expand Down
4 changes: 1 addition & 3 deletions src/utils/ipfs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import axios from "axios";
import { IPFS_GATEWAY } from "../config";

export const uploadToIPFS = async (data: FormData) => {
const result = await axios.post("/api/ipfs-upload", data);
return result.data.uri;
};

export const ipfs = (uri: string) => `https://${IPFS_GATEWAY}${uri}`;
//export const ipfs = (uri: string) => `https://ipfs.kleros.io${uri}`;
export const ipfs = (uri: string) => `https://${process.env.REACT_APP_IPFS_GATEWAY}${uri}`;

export const ipfsFetch = async <F>(ipfsURI: string) =>
(await axios.get(ipfs(ipfsURI))).data as F;

0 comments on commit a3b27ba

Please sign in to comment.