AOSSIE-Org / AOSSIE-Org/Agora-Blockchain

BUG:Candidate Description IPFS Inconsistency

オープン
#240 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
97
フォーク
199
PR マージ指標
30日以内にマージされた PR はありません

説明

### 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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。