diff --git a/src/index.ts b/src/index.ts index 3d6f363..9ff243d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import Emittery from "emittery" import semverSatisfies from 'semver/functions/satisfies' -import { AppInfoResponse, AppAgentClient, AppAgentCallZomeRequest, AppCreateCloneCellRequest, CreateCloneCellResponse, AgentPubKey, AppEnableCloneCellRequest, AppDisableCloneCellRequest, EnableCloneCellResponse, DisableCloneCellResponse, AppSignal, decodeHashFromBase64, NetworkInfoRequest, NetworkInfoResponse } from '@holochain/client' +import { AppInfoResponse, AppAgentClient, AppAgentCallZomeRequest, AppCreateCloneCellRequest, CreateCloneCellResponse, AgentPubKey, AppEnableCloneCellRequest, AppDisableCloneCellRequest, EnableCloneCellResponse, DisableCloneCellResponse, AppSignal, decodeHashFromBase64, NetworkInfoResponse, AppAgentNetworkInfoRequest } from '@holochain/client' const COMPATIBLE_CHAPERONE_VERSION = '>=0.1.1 <0.2.0' @@ -192,6 +192,8 @@ class WebSdkApi implements AppAgentClient { appInfo = (): Promise => this.#child.call('appInfo') + networkInfo = (args: AppAgentNetworkInfoRequest): Promise => this.#child.call('networkInfo', args) + callZome = async (args: AppAgentCallZomeRequest): Promise => this.#child.call('callZome', args).then(unwrap) createCloneCell = (args: AppCreateCloneCellRequest): Promise => this.#child.call('createCloneCell', args).then(unwrap) @@ -200,8 +202,6 @@ class WebSdkApi implements AppAgentClient { enableCloneCell = (args: AppEnableCloneCellRequest): Promise => this.#child.call('enableCloneCell', args).then(unwrap) - networkInfo = (args: NetworkInfoRequest): Promise => this.#child.call('networkInfo', args).then(unwrap) - signPayload = (args: any): Promise => this.#child.call('signPayload', args).then(unwrap) stateDump = () => this.#child.call('stateDump') diff --git a/tests/api.test.ts b/tests/api.test.ts index 6fd4d70..93c07ea 100644 --- a/tests/api.test.ts +++ b/tests/api.test.ts @@ -74,6 +74,32 @@ describe('test API endpoints', () => { expect(response).toMatchObject(expectedResponse) }) + it("should call network_info", async () => { + const expectedResponse = [ + { + fetch_pool_info: { + op_bytes_to_fetch: 1, + num_ops_to_fetch: 1, + }, + current_number_of_peers: 1, + arc_size: 1, + total_network_peers: 1, + bytes_since_last_time_queried: 1, + completed_rounds_since_last_time_queried: 1, + } + ] + + mock_comb.nextResponse(expectedResponse) + + const response = await holo.networkInfo({ + dnas: ['dna_hash'], + }); + + log.debug("Response: %s", response) + + expect(response).toBeDefined() + }) + it("should sign payloads", async () => { const payload = { mockPayload: 'value' } const expectedResponse = {