From 2a26bc3c96ba26ce0c25e620da23622c33f2e53e Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 25 Sep 2023 16:11:31 -0700 Subject: [PATCH] enhancement: throwing error when non-implemented method is called --- src/endpoints/v1.ts | 50 ++++++++++++++++++++++++++++++--------------- src/endpoints/v2.ts | 24 +++++++--------------- src/types.ts | 6 ++---- test/api.ts | 8 -------- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/endpoints/v1.ts b/src/endpoints/v1.ts index 2a1c991..76d4dad 100644 --- a/src/endpoints/v1.ts +++ b/src/endpoints/v1.ts @@ -3,30 +3,48 @@ import { SortType } from "../types"; export class HyperionV1APIClient { public history: HyperionV1HistoryAPIClient; + public chain: HyperionV1ChainAPIClient; + public trace_api: HyperionV1TraceApiClient; constructor(private client: APIClient) { this.history = new HyperionV1HistoryAPIClient(client); + this.chain = new HyperionV1ChainAPIClient(client); + this.trace_api = new HyperionV1TraceApiClient(client); } } class HyperionV1HistoryAPIClient { constructor(private client: APIClient) {} - async get_actions(options: { - account_name: NameType - pos?: UInt64Type; - offset?: UInt64Type; - filter?: UInt64Type; - sort?: SortType; - after?: TimePointType; - before?: TimePointType; - parent?: number; - }): Promise { - return this.client.call({ - path: `/v1/history/get_actions`, - method: 'POST', - // responseType: GetActionsResponse, - params: options - }) + async get_actions(): Promise { + throw new Error("Method not implemented."); + } + + async get_controlled_accounts(): Promise { + throw new Error("Method not implemented."); + } + + async get_key_accounts(): Promise { + throw new Error("Method not implemented."); + } + + async get_transaction(): Promise { + throw new Error("Method not implemented."); + } +} + +class HyperionV1ChainAPIClient { + constructor(private client: APIClient) {} + + async get_block(): Promise { + throw new Error("Method not implemented."); + } +} + +class HyperionV1TraceApiClient { + constructor(private client: APIClient) {} + + async get_block(): Promise { + throw new Error("Method not implemented."); } } \ No newline at end of file diff --git a/src/endpoints/v2.ts b/src/endpoints/v2.ts index 6221902..d591a58 100644 --- a/src/endpoints/v2.ts +++ b/src/endpoints/v2.ts @@ -14,7 +14,7 @@ export class HyperionV2APIClient { return this.client.call({ path: `/v2/health`, method: 'GET', - // responseType: V2.GetHealthResponse, + responseType: V2.GetHealthResponse, }) } } @@ -209,21 +209,11 @@ export class HyperionV2HistoryAPIClient { }) } - async get_transfers(params: { - from?: NameType; - to?: NameType; - symbol?: NameType; - contract?: NameType; - skip?: UInt64Type; - limit?: UInt64Type; - after?: TimePointType; - before?: TimePointType; - }): Promise { - const queryParams = new URLSearchParams(params as any).toString(); - return this.client.call({ - path: `/v2/history/get_transfers?${queryParams}`, - method: 'GET', - // responseType: V2.GetTransfersResponse, - }); + async get_transfers(): Promise { + throw new Error("Method not implemented."); + } + + async get_transacted_accounts(): Promise { + throw new Error("Method not implemented."); } } diff --git a/src/types.ts b/src/types.ts index 182eb31..a42c12c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,9 +15,7 @@ import { export type SortType = 'desc' | 'asc' | '1' | '-1'; -export namespace V1 { - -} +export namespace V1 {} export namespace V2 { @Struct.type('get_abi_snapshot_response') @@ -225,7 +223,7 @@ export namespace V2 { export class HealthEntry extends Struct { @Struct.field('string') declare service: string; @Struct.field('string') declare status: string; - @Struct.field('map') declare service_data?: NodeosRPCServiceData | ElasticsearchServiceData; + @Struct.field('any', { optional: true }) declare service_data?: NodeosRPCServiceData | ElasticsearchServiceData; @Struct.field(UInt64) declare time: UInt64; } diff --git a/test/api.ts b/test/api.ts index 726c725..544f424 100644 --- a/test/api.ts +++ b/test/api.ts @@ -152,14 +152,6 @@ suite('Hyperion API', function () { assert.instanceOf(response.creator, Name); assert.equal(String(response.creator), "gqyqi.waa"); }) - - test('get_transfers', async function () { - const response = await hyperion.v2.history.get_transfers({ from: 'teamgreymass' }); - - assert.isArray(response.transfers); - assert.equal(response.transfers.length, 10); - assert.instanceOf(response.transfers[0].from, Name); - }) }) }) })