Skip to content

Fix: user balance decimal128 - #867

Merged
Nitya-003 merged 2 commits into
Nitya-003:mainfrom
Kirtan-pc:fix/user-balance-decimal128
Jul 29, 2026
Merged

Fix: user balance decimal128#867
Nitya-003 merged 2 commits into
Nitya-003:mainfrom
Kirtan-pc:fix/user-balance-decimal128

Conversation

@Kirtan-pc

Copy link
Copy Markdown
Contributor

📌 Overview

This PR fixes the duplicate balance field definition in backend/models/User.js where the field was declared twice with conflicting types — first as mongoose.Schema.Types.Decimal128 with a fromString('100000') default, immediately followed by type: Number with default: 100000. Mongoose silently used only the last definition, causing all balance operations to use raw JavaScript Number with floating-point precision instead of Decimal128, resulting in silent financial rounding errors.

🛠️ Type of Change

  • ⛓️ Smart Contract (Solidity changes, Gas optimization)
  • 💻 Frontend (UI/UX, React components, Tailwind)
  • ⚙️ Backend (API routes, MongoDB schemas, Middleware)
  • 📄 Documentation (README, Roadmap updates)
  • 🧪 Testing (Hardhat tests, Jest/Vitest)

🔗 Related Issue

Closes #828


🧪 Testing & Verification

  • Smart Contracts: npx hardhat test passed? (Yes/No/NA)
  • Frontend: Verified on Mobile/Desktop responsiveness? (Yes/No/NA)
  • Integration: Verified User.js loads without errors and balance uses Decimal128 type

📸 Screenshots / Demos

N/A


✅ PR Checklist

  • My code follows the project's style guidelines.
  • I have commented my code, particularly in complex areas (e.g., Smart Contract logic).
  • I have updated the documentation accordingly.
  • My changes generate no new warnings.

💬 Additional Notes

The duplicate field was introduced during a previous merge conflict resolution that left both old (Number) and new (Decimal128) balance definitions in the schema. Removing the duplicate Number definition ensures all balance operations use consistent Decimal128 precision for accurate financial calculations across bids, fund transfers, and balance queries.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Kirtan-pc 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.

@Nitya-003 Nitya-003 added bug Something isn't working gssoc:approved gssoc'26 approved quality:clean *1.2 for contributor +5 pts for mentor level:intermediate 35 pts for contributor 20 pts for mentor type:bug labels Jul 29, 2026
@Nitya-003
Nitya-003 merged commit 4244837 into Nitya-003:main Jul 29, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gssoc:approved gssoc'26 approved level:intermediate 35 pts for contributor 20 pts for mentor quality:clean *1.2 for contributor +5 pts for mentor type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate User balance field causes financial precision loss

2 participants