Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the node page to support internal node addresses (prefixed with 0xai_) in addition to standard Ethereum addresses. A new resolution layer converts internal addresses to Ethereum addresses before fetching node data.
- Added
resolveNodeEthAddressfunction to handle both internal and Ethereum address formats - Refactored parameter names from
nodeEthAddrtonodeAddrthroughout to reflect dual address support - Added loading skeleton component for improved user experience during page loads
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/node/[nodeAddr]/page.tsx | Implements internal address resolution and updates parameter naming to support both address types |
| app/node/[nodeAddr]/loading.tsx | Adds skeleton loading states for node page sections |
Comments suppressed due to low confidence (1)
app/node/[nodeAddr]/page.tsx:26
- The internal address validation is missing a length check. In other parts of the codebase (lib/actions.ts line 62 and lib/utils.tsx line 231), internal addresses are validated to be exactly 49 characters long with the pattern
query.startsWith('0xai_') && query.length === 49. This function should include the same length validation to ensure consistency and reject malformed internal addresses.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
app/node/[nodeAddr]/page.tsx:32
- The error handling in the try-catch block silently catches and ignores errors from internalNodeAddressToEthAddress. Consider logging the error for debugging purposes to help identify issues with malformed internal addresses.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const firstMiningEpoch = ( | ||
| await publicClient.readContract({ | ||
| address: config.mndContractAddress, | ||
| abi: MNDContractAbi, | ||
| functionName: 'licenses', | ||
| args: [BigInt(licenseId)], | ||
| }) | ||
| )[3]; |
There was a problem hiding this comment.
The array indexing used to extract firstMiningEpoch is fragile and unclear. Using a magic index [3] makes the code difficult to understand and maintain. Consider either destructuring the return value with named properties or adding a comment explaining what index 3 represents in the licenses tuple.
| const firstMiningEpoch = ( | |
| await publicClient.readContract({ | |
| address: config.mndContractAddress, | |
| abi: MNDContractAbi, | |
| functionName: 'licenses', | |
| args: [BigInt(licenseId)], | |
| }) | |
| )[3]; | |
| // The 'licenses' function returns a tuple where the 4th element is firstMiningEpoch. | |
| const [, , , firstMiningEpoch] = await publicClient.readContract({ | |
| address: config.mndContractAddress, | |
| abi: MNDContractAbi, | |
| functionName: 'licenses', | |
| args: [BigInt(licenseId)], | |
| }); |
| } | ||
|
|
||
| const maxRemainingClaimAmount = license.totalAssignedAmount - license.totalClaimedAmount; | ||
| return rewards_amount > maxRemainingClaimAmount ? maxRemainingClaimAmount : rewards_amount; |
There was a problem hiding this comment.
The comparison logic should use strict equality. The condition should be written as rewards_amount < maxRemainingClaimAmount ? rewards_amount : maxRemainingClaimAmount to match the pattern used in the original calculateLicenseRewards function at line 414. Currently, it uses the reversed order which could be confusing for maintainability.
| return rewards_amount > maxRemainingClaimAmount ? maxRemainingClaimAmount : rewards_amount; | |
| return rewards_amount < maxRemainingClaimAmount ? rewards_amount : maxRemainingClaimAmount; |
| firstMiningEpoch = ( | ||
| await publicClient.readContract({ | ||
| address: config.mndContractAddress, | ||
| abi: MNDContractAbi, | ||
| functionName: 'licenses', | ||
| args: [result.licenseId], | ||
| }) | ||
| )[3]; |
There was a problem hiding this comment.
The array indexing used to extract firstMiningEpoch is fragile and unclear. Using a magic index [3] makes the code difficult to understand and maintain. Consider either destructuring the return value with named properties or adding a comment explaining what index 3 represents in the licenses tuple.
| firstMiningEpoch = ( | |
| await publicClient.readContract({ | |
| address: config.mndContractAddress, | |
| abi: MNDContractAbi, | |
| functionName: 'licenses', | |
| args: [result.licenseId], | |
| }) | |
| )[3]; | |
| const [, , , firstMiningEpochFromLicense] = await publicClient.readContract({ | |
| address: config.mndContractAddress, | |
| abi: MNDContractAbi, | |
| functionName: 'licenses', | |
| args: [result.licenseId], | |
| }); | |
| firstMiningEpoch = firstMiningEpochFromLicense; |
No description provided.