AOSSIE-Org / AOSSIE-Org/Agora-Blockchain

BUG:Candidate Description IPFS Inconsistency

Aperta
#240 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
97
Fork
199
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Issue Description ✍️

Is there an existing issue for this?

No

Issue Description ✍️
📌 Issue Summary

The current implementation of candidate creation in the `createElection` flow
has an inconsistency in how candidate descriptions are stored compared to the
`addCandidate` flow used post-creation.

When a candidate is added **after** election creation via `addCandidate`
(`client/app/components/Modal/AddCandidate.tsx`), the description is first
pinned to IPFS via Pinata, and only the resulting CID hash is stored on-chain.
This is the correct approach.

However, when candidates are added **during** election creation via the Create
page (`client/app/create/page.tsx`), the raw description string is passed
directly to the contract with no IPFS pinning step whatsoever:

This causes `CandidateDescription.tsx` to receive a raw string instead of a
valid IPFS CID, since it always treats the `description` field as a CID and
tries to fetch it from the IPFS gateway:

As a result, descriptions of all initially created candidates either fail to
load or display nothing in the UI, affecting every election created through
the platform.

Solution

The fix involves pinning each candidate's description to IPFS before
submitting the `createElection` transaction, bringing it in line with the
`addCandidate` flow.

In `client/app/create/page.tsx`, before calling `writeContractAsync`,
candidates should be mapped through the Pinata API:

Then `pinnedCandidates` is passed instead of raw `candidates` to the contract
call. No changes to any Solidity contracts are required.

This ensures that all candidate descriptions — whether added during or after
election creation — are consistently stored as IPFS CID hashes on-chain, and
`CandidateDescription.tsx` can reliably fetch and display them.

Regards

### Record

- [x] I have synced all my node versions as mentioned in the project
- [x] I am using the same version of npm as is the project
- [x] My current branch is in sync with the development branch
- [x] I want to work on this issue

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.