Conversation
* feat: New MND rewards distribution * fix: Obtain firstMiningEpoch for GND
There was a problem hiding this comment.
Pull request overview
This pull request refactors the license rewards calculation system to use smart contract-based computation for MND and GND licenses, updates dependencies, and fixes several UI issues.
Changes:
- Refactored MND/GND reward calculations to use smart contract's
calculateRewardsfunction instead of local computation - Updated React (19.2.4), React DOM (19.2.4), Next.js (15.5.10), and added lodash (4.17.23)
- Enhanced GND license support to handle first mining epoch like MND licenses
- Fixed assignTimestamp display bug to properly show "Not assigned" for unassigned licenses
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated React, React DOM, Next.js versions and added lodash dependency |
| package-lock.json | Updated lockfile to reflect dependency changes |
| blockchain/MNDContract.ts | Added new ABI entries for enhanced reward calculation including carryover and withheld amounts |
| lib/api/blockchain.ts | Refactored reward calculation to use smart contract instead of local computation; unified MND/GND handling |
| app/server-components/main-cards/LicenseCard.tsx | Pass licenseId to LicenseRewardsPoA component for reward calculation |
| app/server-components/Licenses/LicenseRewardsPoA.tsx | Accept licenseId parameter and pass it to getLicenseRewards; return null on missing data |
| app/server-components/Licenses/License.tsx | Fixed bug by checking assignTimestamp for both falsy and '0' string values |
| app/server-components/LicensePage/LicensePageNodeCardWrapper.tsx | Return null instead of ErrorAlert when node data is unavailable |
| app/license/[licenseType]/[licenseId]/page.tsx | Code formatting changes only, no functional changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lib/api/blockchain.ts
Outdated
| const publicClient = await getPublicClient(); | ||
| const result = await publicClient.readContract({ | ||
| address: config.mndContractAddress, | ||
| abi: MNDContractAbi, | ||
| functionName: 'calculateRewards', | ||
| args: [ | ||
| [ | ||
| { | ||
| licenseId, | ||
| nodeAddress: license.nodeAddress, | ||
| epochs: epochs.map((epoch) => BigInt(epoch)), | ||
| availabilies: epochs_vals, | ||
| }, | ||
| ], | ||
| ], | ||
| }); |
There was a problem hiding this comment.
The error handling when rewards calculation fails could be improved. When the smart contract's calculateRewards function throws an error, it will propagate as an unhandled exception. Consider wrapping this in a try-catch block and returning undefined on error, consistent with how epoch length mismatches are handled on line 412. This would provide more graceful degradation when the contract call fails.
No description provided.