import { Rpc } from "." ; export class NodeRpc { private rpc : Rpc ; hidden constructor ( rpc ) { this . rpc = rpc ; } returns public ping ( id ? ) { return new Promise ( ( resolve , reject ) => { this . rpc . sendRpcRequest ( "ping" , [ ] , { id } ) . then ( result => { if ( typeof result === "string" ) { return resolve ( result ) ; } return reject ( Error ( `Expected ping() to return a string but it returned ${ result }` ) ) ; } ) . catch ( reject ) ; } ) ; } returns public getNodeVersion ( ) { return new Promise ( ( resolve , reject ) => { this . rpc . sendRpcRequest ( "version" , [ ] ) . then ( result => { if ( typeof result === "string" ) { return resolve ( result ) ; } return reject ( Error ( `Expected getNodeVersion() to return a string but it returned ${ result }` ) ) ; } ) . catch ( reject ) ; } ) ; } hidden public getCommitHash ( ) { return new Promise ( ( resolve , reject ) => { this . rpc . sendRpcRequest ( "commitHash" , [ ] ) . then ( result => { if ( typeof result === "string" ) { return resolve ( result ) ; } return reject ( Error ( `Expected getCommitHash() to return a string but it returned ${ result }` ) ) ; } ) . catch ( reject ) ; } ) ; } }