@@ -2,6 +2,7 @@ import LicenseCard from '@/app/server-components/main-cards/LicenseCard';
22import NodeCard from '@/app/server-components/main-cards/NodeCard' ;
33import NodePerformanceCard from '@/app/server-components/main-cards/NodePerformanceCard' ;
44import { DetailedAlert } from '@/app/server-components/shared/DetailedAlert' ;
5+ import { getServerConfig } from '@/config/serverConfig' ;
56import { getNodeAvailability } from '@/lib/actions' ;
67import { getNodeLicenseDetails } from '@/lib/api/blockchain' ;
78import { isEmptyETHAddr } from '@/lib/utils' ;
@@ -13,6 +14,7 @@ import { isAddress } from 'viem';
1314
1415export async function generateMetadata ( { params } ) {
1516 const { nodeEthAddr } = await params ;
17+ const { config } = await getServerConfig ( ) ;
1618
1719 if ( ! nodeEthAddr || ! isAddress ( nodeEthAddr ) || isEmptyETHAddr ( nodeEthAddr ) ) {
1820 console . log ( `[Node Page] Invalid node address: ${ nodeEthAddr } ` ) ;
@@ -22,7 +24,7 @@ export async function generateMetadata({ params }) {
2224 let nodeResponse : types . OraclesAvailabilityResult & types . OraclesDefaultResult ;
2325
2426 try {
25- ( { nodeResponse } = await getCachedLicenseDetailsAndNodeAvailability ( nodeEthAddr ) ) ;
27+ ( { nodeResponse } = await getCachedLicenseDetailsAndNodeAvailability ( nodeEthAddr , config . environment ) ) ;
2628
2729 if ( ! nodeResponse ) {
2830 console . log ( `[Node Page] No node response found for address: ${ nodeEthAddr } ` ) ;
@@ -49,25 +51,42 @@ export async function generateMetadata({ params }) {
4951const getCachedLicenseDetailsAndNodeAvailability = cache (
5052 async (
5153 nodeEthAddr : types . EthAddress ,
54+ _environment : 'mainnet' | 'testnet' | 'devnet' ,
5255 ) : Promise < {
5356 license : types . License ;
5457 licenseId : bigint ;
5558 licenseType : 'ND' | 'MND' | 'GND' ;
5659 owner : types . EthAddress ;
5760 nodeResponse : types . OraclesAvailabilityResult & types . OraclesDefaultResult ;
5861 } > => {
59- const {
60- nodeAddress,
61- totalAssignedAmount,
62- totalClaimedAmount,
63- lastClaimEpoch,
64- assignTimestamp,
65- lastClaimOracle,
66- isBanned,
67- licenseId,
68- licenseType,
69- owner,
70- } = await getNodeLicenseDetails ( nodeEthAddr ) ;
62+ let nodeAddress : types . EthAddress ,
63+ totalAssignedAmount : bigint ,
64+ totalClaimedAmount : bigint ,
65+ lastClaimEpoch : bigint ,
66+ assignTimestamp : bigint ,
67+ lastClaimOracle : types . EthAddress ,
68+ isBanned : boolean ,
69+ licenseId : bigint ,
70+ licenseType : 'ND' | 'MND' | 'GND' | undefined ,
71+ owner : types . EthAddress ;
72+
73+ try {
74+ ( {
75+ nodeAddress,
76+ totalAssignedAmount,
77+ totalClaimedAmount,
78+ lastClaimEpoch,
79+ assignTimestamp,
80+ lastClaimOracle,
81+ isBanned,
82+ licenseId,
83+ licenseType,
84+ owner,
85+ } = await getNodeLicenseDetails ( nodeEthAddr ) ) ;
86+ } catch ( error ) {
87+ console . error ( error ) ;
88+ throw new Error ( 'Failed to get node license details.' ) ;
89+ }
7190
7291 if ( ! licenseId || ! licenseType ) {
7392 throw new Error ( 'License not found.' ) ;
@@ -98,6 +117,7 @@ const getCachedLicenseDetailsAndNodeAvailability = cache(
98117
99118export default async function NodePage ( { params } ) {
100119 const { nodeEthAddr } = await params ;
120+ const { config } = await getServerConfig ( ) ;
101121
102122 if ( ! nodeEthAddr || ! isAddress ( nodeEthAddr ) || isEmptyETHAddr ( nodeEthAddr ) ) {
103123 console . log ( `[Node Page] Invalid node address in page component: ${ nodeEthAddr } ` ) ;
@@ -111,8 +131,10 @@ export default async function NodePage({ params }) {
111131 let nodeResponse : types . OraclesAvailabilityResult & types . OraclesDefaultResult ;
112132
113133 try {
114- ( { license, licenseId, licenseType, owner, nodeResponse } =
115- await getCachedLicenseDetailsAndNodeAvailability ( nodeEthAddr ) ) ;
134+ ( { license, licenseId, licenseType, owner, nodeResponse } = await getCachedLicenseDetailsAndNodeAvailability (
135+ nodeEthAddr ,
136+ config . environment ,
137+ ) ) ;
116138 } catch ( error : any ) {
117139 console . error ( error ) ;
118140
0 commit comments