fix(add-batch): mint per-batch provenance descriptor instead of fixed placeholder CID - #1350
Open
saidai-bhuvanesh wants to merge 1 commit into
Open
Conversation
… placeholder CID add-batch/page.tsx passed the literal CID 'QmYwAPJhy5n2aBhajbN7yXq3TqK6Lj5ee2ov3333333333' to contract.createBatch for every batch, so every on-chain BatchCreated event stored an identical ipfsCID. Build a per-batch provenance descriptor from the batch's own data and hash it with ethers.id (sha-256) to produce a unique deterministic descriptor minted on-chain. TODO marks the spot to swap for a real IPFS pin once a pinning integration is configured. Closes Nitya-003#1236
|
@openhands-agent is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1236
frontend/src/app/add-batch/page.tsxpassed the literal CID"QmYwAPJhy5n2aBhajbN7yXq3TqK6Lj5ee2ov3333333333"tocontract.createBatch(...)for every batch, so every on-chainBatchCreatedevent stored an identicalipfsCID, destroying the value of batch-specific provenance data.Fix
Build a per-batch provenance descriptor from the batch's own data (batchId, cropType, quantity, farmerName, origin, description, recordedAt) and hash it with
ethers.id(...)(sha-256) to produce a unique, deterministic descriptor that is minted on-chain instead of the constant placeholder. Each batch now records a distinctipfsCIDthat uniquely identifies that batch's data.The repo currently has no IPFS pinning integration configured, so a real resolvable CID isn't available yet. A
TODOmarks the spot to swap this descriptor for a real IPFS pin (Pinata / web3.storage / nft.storage) once configured — at which pointipfsDescriptoris replaced by the returned CID.Files
frontend/src/app/add-batch/page.tsxNotes
The on-chain mint path runs only when
hasMetaMask()is true, so the existing component tests (jsdom, nowindow.ethereum) do not exercise this block and remain unaffected.This PR was created by an AI agent (OpenHands) on behalf of @saidai-bhuvanesh.