-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testnets #118
Testnets #118
Conversation
fix: remove duplicate Request reference
WalkthroughThe changes in this pull request primarily involve modifications to the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for proof-of-humanity-v2 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
src/app/[pohid]/[chain]/[request]/page.tsx (4)
Line range hint
75-93
: Cleanup commented code and simplify expiration logicThe
hasExpired
function contains commented-out code and nested conditions that could be simplified for better readability.Consider refactoring to:
const hasExpired = () => { if (request.status.id === "resolved") { if (!request.revocation && request.humanity.winnerClaim.length > 0) { if (request.humanity.winnerClaim[0].index === request.index) { if (!!contractData.humanityLifespan) { - return ( - /* (Number(request.humanity.winnerClaim[0].resolutionTime) > 0 && - Number(request.humanity.winnerClaim[0].resolutionTime) + Number(contractData.humanityLifespan) < Date.now() / 1000) || - (Number(request.creationTime) + Number(contractData.humanityLifespan) < Date.now() / 1000) || */ - !request.humanity.registration || - Number(request.humanity.registration?.expirationTime) < - Date.now() / 1000 - ); + return !request.humanity.registration || + Number(request.humanity.registration?.expirationTime) < Date.now() / 1000; } } else return true; } } else if (request.status.id === "transferring") { return Number(request.creationTime) + Number(contractData.humanityLifespan) < Date.now() / 1000; } return true; };
Line range hint
146-196
: Improve error handling and promise management in vouch preparationThe
prepareVouchData
function has several areas that could be improved:
- Empty catch block silently swallows errors
- Complex promise chains could be simplified using async/await
- Potential undefined access in chain finding logic
Consider these improvements:
const prepareVouchData = ( rawVouches: Record<SupportedChainId, ClaimerQuery>[], isOnChain: boolean, skipStatusCheck: boolean, ): Promise<VouchData>[] => { return rawVouches.map(async (rawVoucher) => { const out: VouchData = { voucher: undefined, name: undefined, pohId: undefined, photo: undefined, vouchStatus: undefined, isOnChain: isOnChain, }; try { const voucherEvidenceChain = supportedChains.find( (chain) => - rawVoucher[chain.id].claimer && - rawVoucher[chain.id].claimer?.registration?.humanity.winnerClaim, + rawVoucher[chain.id]?.claimer?.registration?.humanity?.winnerClaim?.length > 0 ); const relevantChain = voucherEvidenceChain ?? chain; const claimer = rawVoucher[relevantChain.id]?.claimer; if (!claimer) return out; out.name = claimer.name; out.voucher = claimer.id; out.pohId = claimer.registration?.humanity.id ?? out.voucher; const uri = claimer.registration?.humanity.winnerClaim ?.at(0) ?.evidenceGroup.evidence.at(0)?.uri; if (!skipStatusCheck) { out.vouchStatus = isOnChain ? isValidOnChainVouch( request.claimer.vouchesReceived.find( (v) => v.from.id === out.voucher!, )! as VouchQuery, ) : await isValidVouch( chain.id, out.voucher!, offChainVouches.find( (vouch) => vouch.voucher === claimer.id, )?.expiration, ); } if (!uri) return out; const evFile = await ipfsFetch<EvidenceFile>(uri); if (!evFile?.fileURI) return out; const regFile = await ipfsFetch<RegistrationFile>(evFile.fileURI); out.photo = regFile.photo; return out; - } catch { + } catch (error) { + console.error('Error preparing vouch data:', error); return out; } }); };
Line range hint
315-316
: Add error handling for video playbackThe video element should handle potential loading errors gracefully.
Consider adding error handling:
{registrationFile && ( <video className="w-full" src={ipfs(registrationFile.video)} controls + onError={(e) => { + console.error('Error loading video:', e); + e.currentTarget.style.display = 'none'; + }} /> )}
Line range hint
343-362
: Clean up policy tooltip and improve readabilityThe tooltip contains commented-out code and could benefit from better formatting.
Consider this cleanup:
<div className="text-primaryText group relative flex py-[8px]"> Policy in force at submission <div className="invisible absolute left-1/2 z-10 m-4 mx-auto w-[260px] flex-shrink-0 -translate-x-1/2 transform place-content-center content-between rounded-[3px] border-[1px] border-[solid] bg-[var(--Light-Mode-White-background,_#FFF)] p-[8px] text-justify text-[14px] font-normal not-italic leading-[normal] outline-black transition-opacity ease-in-out [box-shadow:0px_2px_3px_0px_rgba(0,_0,_0,_0.06)] group-hover:visible md:w-[400px]"> <span> - {/* (Policy in force since {new Date(policyUpdate * 1000).toDateString()}) */} This is the policy that was in effect when this submission was made... </span> </div> </div>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/app/[pohid]/[chain]/[request]/page.tsx (1 hunks)
🔇 Additional comments (1)
src/app/[pohid]/[chain]/[request]/page.tsx (1)
21-21
: LGTM: Import cleanupThe removal of unused
Request
type from graphql imports aligns with the changes in vouch handling logic.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor