File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,14 +43,46 @@ export interface ServiceEndpoint {
4343 urlPath : string
4444}
4545
46+ export interface NodeStatusProvider {
47+ chainId : string
48+ network : string
49+ }
50+
51+ export interface NodeStatusIndexer {
52+ chainId : string
53+ network : string
54+ block : string
55+ }
56+
4657export interface NodeStatus {
47- nodeId : string
48- chainIds : string [ ]
49- providerAddress : string
50- nodePublicKey : Record < string , number >
51- serviceEndpoints : Record < string , [ string , string ] >
52- software : string
58+ id : string
59+ publicKey : string
60+ friendlyName : string
61+ address : string
5362 version : string
63+ http : boolean
64+ p2p : boolean
65+ provider : NodeStatusProvider [ ]
66+ indexer : NodeStatusIndexer [ ]
67+ escrowAddress : Record < string , string >
68+ supportedStorage : Record < string , boolean >
69+ platform : {
70+ cpus : number
71+ freemem : number
72+ totalmem : number
73+ loadavg : number [ ]
74+ arch : string
75+ machine : string
76+ platform : string
77+ osType : string
78+ node : string
79+ }
80+ codeHash : string
81+ allowedAdmins : {
82+ addresses : string [ ]
83+ accessLists : string [ ] | null
84+ }
85+ uptime : number
5486}
5587export interface UserCustomParameters {
5688 [ key : string ] : any
Original file line number Diff line number Diff line change @@ -57,7 +57,23 @@ export class HttpProvider {
5757 }
5858
5959 public async getNodeStatus ( nodeUri : string , signal ?: AbortSignal ) : Promise < NodeStatus > {
60- return this . getEndpoints ( nodeUri )
60+ const providerEndpoints = await this . getEndpoints ( nodeUri )
61+ const serviceEndpoints = await this . getServiceEndpoints ( nodeUri , providerEndpoints )
62+ const endpoint = this . getEndpointURL ( serviceEndpoints , 'directCommand' )
63+ if ( ! endpoint ?. urlPath ) return null
64+ try {
65+ const response = await fetch ( endpoint . urlPath , {
66+ method : 'POST' ,
67+ headers : { 'Content-Type' : 'application/json' } ,
68+ body : JSON . stringify ( { command : PROTOCOL_COMMANDS . STATUS } ) ,
69+ signal
70+ } )
71+ if ( response ?. ok ) return response . json ( )
72+ return null
73+ } catch ( e ) {
74+ LoggerInstance . error ( 'getNodeStatus failed:' , e )
75+ return null
76+ }
6177 }
6278
6379 public async getNodeJobs (
Original file line number Diff line number Diff line change @@ -58,9 +58,10 @@ describe('Provider tests', async () => {
5858 it ( 'Alice tests getNodeStatus' , async ( ) => {
5959 const status = await ProviderInstance . getNodeStatus ( config . oceanNodeUri )
6060 assert ( status , 'No status returned' )
61- assert ( status . providerAddress , 'Status missing provider address' )
62- assert ( status . nodeId , 'Status missing nodeId' )
63- assert ( Array . isArray ( status . chainIds ) , 'Status missing chainIds' )
61+ assert ( status . id , 'Status missing id' )
62+ assert ( status . address , 'Status missing address' )
63+ assert ( status . version , 'Status missing version' )
64+ assert ( Array . isArray ( status . provider ) , 'Status missing provider array' )
6465 } )
6566
6667 it ( 'Alice tests getNodeJobs' , async ( ) => {
You can’t perform that action at this time.
0 commit comments