From 10371dc361183a4aa2d14422fb898ea38de242fd Mon Sep 17 00:00:00 2001 From: mehditorabiv Date: Sun, 1 Sep 2024 21:25:21 +0300 Subject: [PATCH] remove garbage codes --- .../Identifiers/Attestation/Attestation.tsx | 284 ------------------ 1 file changed, 284 deletions(-) diff --git a/src/pages/Identifiers/Attestation/Attestation.tsx b/src/pages/Identifiers/Attestation/Attestation.tsx index c2f26b0..887c96c 100644 --- a/src/pages/Identifiers/Attestation/Attestation.tsx +++ b/src/pages/Identifiers/Attestation/Attestation.tsx @@ -26,7 +26,6 @@ export default function Attestation() { }; const handlePrepareAttestation = (attested: AttestPayload) => { - console.log({ attested }); setAttestedSignature(attested); handleNextStep(); }; @@ -61,289 +60,6 @@ export default function Attestation() { /> )} {activeStep === 2 && } - {/* Add step navigation buttons or any additional content below */} ); } - -// /* eslint-disable @typescript-eslint/no-explicit-any */ -// import { useEffect, useState } from 'react'; -// import { -// DelegatedAttestationRequest, -// EAS, -// } from '@ethereum-attestation-service/eas-sdk'; -// import Button from '@mui/material/Button'; -// import CircularProgress from '@mui/material/CircularProgress'; -// import Paper from '@mui/material/Paper'; -// import Typography from '@mui/material/Typography'; -// import { jwtDecode } from 'jwt-decode'; -// import { useLocation, useNavigate, useParams } from 'react-router-dom'; -// import { Address } from 'viem'; -// import { useAccount } from 'wagmi'; - -// import StepperComponent from '../../../components/shared/CustomStepper'; -// import { AttestPayload } from '../../../interfaces'; -// import { platformAuthentication } from '../../../services/api/auth'; -// import { useLinkIdentifierMutation } from '../../../services/api/eas/query'; -// import useSnackbarStore from '../../../store/useSnackbarStore'; -// import sepoliaChain from '../../../utils/contracts/eas/sepoliaChain.json'; -// import { useSigner } from '../../../utils/eas-wagmi-utils'; -// import { -// convertStringsToBigInts, -// getTokenForProvider, -// } from '../../../utils/helper'; - -// const steps = [{ label: 'Auth' }, { label: 'Attest' }, { label: 'Transact' }]; - -// type Provider = 'DISCORD' | 'GOOGLE'; -// type Token = { token: string; exp: number; provider: Provider }; -// type DecodedToken = { provider: Provider; iat: number; exp: number }; - -// export function Attestation() { -// const { isConnected, address } = useAccount(); -// const signer = useSigner(); -// const { showSnackbar } = useSnackbarStore(); -// const { providers } = useParams<{ providers: 'DISCORD' | 'GOOGLE' }>(); -// const location = useLocation(); -// const navigate = useNavigate(); -// const { -// mutate: mutateIdentifier, -// data: linkingIdentifier, -// isPending, -// } = useLinkIdentifierMutation(); - -// const [activeStep, setActiveStep] = useState(0); -// const [linkingIdentifierRequest, setLinkingIdentifierRequest] = -// useState(null); - -// const [isAuthorizing, setIsAuthorizing] = useState(false); -// const [isAttesting, setIsAttesting] = useState(false); - -// useEffect(() => { -// if (!isConnected) { -// console.error('Not connected'); -// } -// }, [isConnected, address]); - -// const handleNext = () => { -// setActiveStep((prevActiveStep) => -// Math.min(prevActiveStep + 1, steps.length - 1) -// ); -// }; - -// useEffect(() => { -// if (linkingIdentifier) { -// const payload: AttestPayload = convertStringsToBigInts( -// linkingIdentifier.data -// ) as AttestPayload; - -// setLinkingIdentifierRequest(payload); -// handleNext(); -// } -// }, [linkingIdentifier]); - -// useEffect(() => { -// const searchParams = new URLSearchParams(location.search); -// const jwtToken = searchParams.get('jwt'); - -// if (jwtToken) { -// try { -// const decoded: DecodedToken = jwtDecode(jwtToken); -// const { provider: jwtProvider } = decoded; - -// const existingTokens: Token[] = JSON.parse( -// localStorage.getItem('OCI_PROVIDER_TOKENS') || '[]' -// ); -// const updatedTokens = existingTokens.filter( -// (token) => token.provider !== jwtProvider -// ); - -// updatedTokens.push({ -// token: jwtToken, -// exp: decoded.exp, -// provider: jwtProvider, -// }); -// localStorage.setItem( -// 'OCI_PROVIDER_TOKENS', -// JSON.stringify(updatedTokens) -// ); - -// navigate(location.pathname, { replace: true }); - -// setActiveStep(1); -// } catch (error) { -// console.error('Invalid JWT token:', error); -// } -// } -// }, [location.search, location.pathname, navigate]); - -// const handleAuthorize = async () => { -// if (!providers) return; - -// setIsAuthorizing(true); -// try { -// await platformAuthentication({ platformType: providers }); -// } finally { -// setIsAuthorizing(false); -// } -// }; - -// const handleAttest = async () => { -// setIsAttesting(true); -// try { -// const eas = new EAS(sepoliaChain.easContractAddress as Address); - -// if (!signer) throw new Error('Signer not found'); - -// if (!linkingIdentifierRequest) throw new Error('No linking identifier'); - -// eas.connect(signer); - -// const transformedPayload: DelegatedAttestationRequest = { -// schema: linkingIdentifierRequest?.message?.schema, -// data: { -// recipient: linkingIdentifierRequest.message.recipient, -// expirationTime: linkingIdentifierRequest.message.expirationTime, -// revocable: linkingIdentifierRequest.message.revocable, -// refUID: linkingIdentifierRequest.message.refUID, -// data: linkingIdentifierRequest.message.data, -// }, -// signature: linkingIdentifierRequest.signature, -// attester: linkingIdentifierRequest.message.attester as string, -// deadline: 0n, -// }; -// console.log({ transformedPayload }); - -// const tx = await eas.attestByDelegation(transformedPayload); - -// console.log({ tx }); - -// const newAttestationUID = await tx.wait(); - -// showSnackbar('Attestation created successfully', { -// severity: 'success', -// }); - -// navigate('/identifiers'); - -// console.log('New attestation UID:', newAttestationUID); - -// console.log('Transaction receipt:', tx.receipt); -// } catch (error: any) { -// const errorCode = error?.info?.error?.code || ''; - -// if (errorCode === 4001) { -// showSnackbar( -// `${errorCode}, you reject the transaction. please try again...`, -// { -// severity: 'error', -// } -// ); -// } -// } finally { -// setIsAttesting(false); -// } -// }; - -// const handleLinkIdentifier = async () => { -// const siweJwt = localStorage.getItem('OCI_TOKEN'); -// if (!siweJwt || !providers) return; - -// const anyJwt = getTokenForProvider(providers); - -// mutateIdentifier({ -// siweJwt, -// anyJwt, -// }); -// }; - -// return ( -// -// -//
-// {activeStep === 0 && ( -//
-// -// Let’s get started! -// -// -// Please sign in with {providers}. -// -// -//
-// )} -// {activeStep === 1 && ( -//
-// -// Generate an attestation. -// -// -// An attestation is a proof that links your {providers} account to -// your wallet address. -// -// -//
-// )} -// {activeStep === 2 && ( -//
-// -// Sign Transaction. -// -// -// Signing the transaction will put your attestation on-chain. -// -// -// -// This will cost a small amount of gas. -// -//
-// )} -//
-//
-// ); -// } - -// export default Attestation;