Skip to content

fix: align batchService.js stage mapping with constants/stages.js#198

Merged
Nitya-003 merged 1 commit intoNitya-003:mainfrom
navin-oss:fixxbug
Mar 15, 2026
Merged

fix: align batchService.js stage mapping with constants/stages.js#198
Nitya-003 merged 1 commit intoNitya-003:mainfrom
navin-oss:fixxbug

Conversation

@navin-oss
Copy link
Contributor

Fixed the stage inconsistency between constants/stages.js and batchService.js.

Issue: The stage mappings were completely different:

  • constants/stages.js: ['farmer', 'mandi', 'transport', 'retailer'] with mapping { farmer: 0, mandi: 1, transport: 2, retailer: 3 }
  • batchService.js: { 'farmer': 0, 'processor': 1, 'distributor': 2, 'retailer': 3, 'consumer': 4 } (hardcoded inline)

Fix applied:

  1. Imported STAGE_TO_NUMBER from constants/stages.js
  2. Replaced the hardcoded inline stageMap with the imported STAGE_TO_NUMBER

This now correctly matches the Solidity contract's Stage enum (Farmer=0, Mandi=1, Transport=2, Retailer=3), preventing blockchain sync failures.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Easy Easy to solve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants