From 1e14eb92929f2e0efdfc502b06d6be30d084b17b Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 25 Sep 2023 16:12:40 -0700 Subject: [PATCH] style: linted --- src/endpoints.ts | 18 +++---- src/endpoints/v1.ts | 31 ++++++----- src/endpoints/v2.ts | 23 ++++++--- src/types.ts | 123 ++++++++++++++++++++++---------------------- 4 files changed, 100 insertions(+), 95 deletions(-) diff --git a/src/endpoints.ts b/src/endpoints.ts index 35590fe..31fe57a 100644 --- a/src/endpoints.ts +++ b/src/endpoints.ts @@ -1,15 +1,13 @@ -import { - APIClient, -} from '@wharfkit/antelope' -import { HyperionV1APIClient } from './endpoints/v1'; -import { HyperionV2APIClient } from './endpoints/v2'; +import {APIClient} from '@wharfkit/antelope' +import {HyperionV1APIClient} from './endpoints/v1' +import {HyperionV2APIClient} from './endpoints/v2' -export class HyperionAPIClient { - public v1: HyperionV1APIClient; - public v2: HyperionV2APIClient; +export class HyperionAPIClient { + public v1: HyperionV1APIClient + public v2: HyperionV2APIClient constructor(private client: APIClient) { - this.v1 = new HyperionV1APIClient(client); - this.v2 = new HyperionV2APIClient(client); + this.v1 = new HyperionV1APIClient(client) + this.v2 = new HyperionV2APIClient(client) } } diff --git a/src/endpoints/v1.ts b/src/endpoints/v1.ts index 76d4dad..36e3d30 100644 --- a/src/endpoints/v1.ts +++ b/src/endpoints/v1.ts @@ -1,15 +1,14 @@ -import { APIClient, NameType, TimePointType, UInt64Type } from "@wharfkit/antelope"; -import { SortType } from "../types"; +import {APIClient} from '@wharfkit/antelope' export class HyperionV1APIClient { - public history: HyperionV1HistoryAPIClient; - public chain: HyperionV1ChainAPIClient; - public trace_api: HyperionV1TraceApiClient; + 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); + this.history = new HyperionV1HistoryAPIClient(client) + this.chain = new HyperionV1ChainAPIClient(client) + this.trace_api = new HyperionV1TraceApiClient(client) } } @@ -17,19 +16,19 @@ class HyperionV1HistoryAPIClient { constructor(private client: APIClient) {} async get_actions(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } async get_controlled_accounts(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } - + async get_key_accounts(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } async get_transaction(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } } @@ -37,7 +36,7 @@ class HyperionV1ChainAPIClient { constructor(private client: APIClient) {} async get_block(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } } @@ -45,6 +44,6 @@ class HyperionV1TraceApiClient { constructor(private client: APIClient) {} async get_block(): Promise { - throw new Error("Method not implemented."); + 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 d591a58..3d8827a 100644 --- a/src/endpoints/v2.ts +++ b/src/endpoints/v2.ts @@ -1,13 +1,20 @@ -import { APIClient, Asset, Checksum256Type, Int64Type, NameType, PublicKeyType, TimePointType, UInt64Type } from "@wharfkit/antelope" -import { V2 } from "../types" +import { + APIClient, + Asset, + Checksum256Type, + Int64Type, + NameType, + PublicKeyType, +} from '@wharfkit/antelope' +import {V2} from '../types' export class HyperionV2APIClient { - public state: HyperionV2StateAPIClient; - public history: HyperionV2HistoryAPIClient; + public state: HyperionV2StateAPIClient + public history: HyperionV2HistoryAPIClient constructor(private client: APIClient) { - this.state = new HyperionV2StateAPIClient(client); - this.history = new HyperionV2HistoryAPIClient(client); + this.state = new HyperionV2StateAPIClient(client) + this.history = new HyperionV2HistoryAPIClient(client) } get_health(): Promise { @@ -210,10 +217,10 @@ export class HyperionV2HistoryAPIClient { } async get_transfers(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } async get_transacted_accounts(): Promise { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.') } } diff --git a/src/types.ts b/src/types.ts index a42c12c..e39a086 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,8 +13,6 @@ import { UInt8, } from '@wharfkit/antelope' -export type SortType = 'desc' | 'asc' | '1' | '-1'; - export namespace V1 {} export namespace V2 { @@ -24,19 +22,20 @@ export namespace V2 { @Struct.field(ABI) declare abi: ABI @Struct.field(Float64) declare query_time_ms: Float64 } - + @Struct.type('get_voters_response_voter') export class GetVotersResponseVoter extends Struct { @Struct.field(Name) declare account: Name @Struct.field(Float64) declare weight: Float64 @Struct.field(UInt32) declare last_vote: UInt32 } - + @Struct.type('get_voters_response') export class GetVotersResponse extends Struct { - @Struct.field(GetVotersResponseVoter, {array: true}) declare voters: GetVotersResponseVoter[] + @Struct.field(GetVotersResponseVoter, {array: true}) + declare voters: GetVotersResponseVoter[] } - + @Struct.type('get_links_response_link') export class GetLinksResponseLink extends Struct { @Struct.field(UInt32) declare block_num: UInt32 @@ -47,13 +46,13 @@ export namespace V2 { @Struct.field('string') declare action: string @Struct.field('bool', {optional: true}) declare irreversible?: boolean } - + @Struct.type('total_count') export class TotalCount extends Struct { @Struct.field(UInt32) declare value: UInt32 @Struct.field('string') declare relation: string } - + @Struct.type('get_links_response') export class GetLinksResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @@ -63,14 +62,14 @@ export namespace V2 { @Struct.field(TotalCount) declare total: TotalCount @Struct.field(GetLinksResponseLink, {array: true}) declare links: GetLinksResponseLink[] } - + @Struct.type('approval') export class Approval extends Struct { @Struct.field(Name) declare actor: Name @Struct.field(Name) declare permission: Name @Struct.field(TimePoint) declare time: TimePoint } - + @Struct.type('proposal') export class Proposal extends Struct { @Struct.field(Approval, {array: true}) declare provided_approvals: Approval[] @@ -81,7 +80,7 @@ export namespace V2 { @Struct.field(UInt64) declare primary_key: UInt64 @Struct.field('bool') declare executed: boolean } - + @Struct.type('get_proposals_response') export class GetProposalsResponse extends Struct { @Struct.field(Float64, {optional: true}) declare query_time?: Float64 @@ -90,7 +89,7 @@ export namespace V2 { @Struct.field(Proposal, {array: true}) declare proposals: Proposal[] @Struct.field(Float64) declare query_time_ms: Float64 } - + @Struct.type('act') export class ActionAct extends Struct { @Struct.field(Name) declare account: Name @@ -98,7 +97,7 @@ export namespace V2 { @Struct.field(PermissionLevel, {array: true}) declare authorization: PermissionLevel[] @Struct.field('any') declare data: any } - + @Struct.type('action') export class Action extends Struct { @Struct.field(UInt32) declare block_num: UInt32 @@ -106,7 +105,7 @@ export namespace V2 { @Struct.field(Checksum256) declare trx_id: Checksum256 @Struct.field(ActionAct) declare act: ActionAct } - + @Struct.type('get_actions_response') export class GetActionsResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @@ -115,20 +114,20 @@ export namespace V2 { @Struct.field(TotalCount) declare total: TotalCount @Struct.field(Action, {array: true}) declare actions: Action[] } - + @Struct.type('account_info') export class AccountInfo extends Struct { @Struct.field(Name) declare name: Name @Struct.field(Checksum256) declare trx_id: Checksum256 @Struct.field(TimePoint) declare timestamp: TimePoint } - + @Struct.type('get_created_accounts_response') export class GetCreatedAccountsResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @Struct.field(AccountInfo, {array: true}) declare accounts: AccountInfo[] } - + @Struct.type('get_creator_response') export class GetCreatorResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @@ -138,7 +137,7 @@ export namespace V2 { @Struct.field(UInt32) declare block_num: UInt32 @Struct.field(Checksum256) declare trx_id: Checksum256 } - + @Struct.type('delta') export class Delta extends Struct { @Struct.field(BlockTimestamp) declare timestamp: BlockTimestamp @@ -152,14 +151,14 @@ export namespace V2 { @Struct.field(Checksum256) declare block_id: Checksum256 @Struct.field('any') declare data: any } - + @Struct.type('get_deltas_response') export class GetDeltasResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @Struct.field(TotalCount) declare total: TotalCount @Struct.field(Delta, {array: true}) declare deltas: Delta[] } - + @Struct.type('get_table_state_response') export class GetTableStateResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @@ -170,12 +169,12 @@ export namespace V2 { @Struct.field('string') declare next_key: string @Struct.field('any', {array: true}) declare results: any[] } - + @Struct.type('get_key_accounts_response') export class GetKeyAccountsResponse extends Struct { @Struct.field(Name, {array: true}) declare account_names: Name[] } - + @Struct.type('token_info') export class TokenInfo extends Struct { @Struct.field('string') declare symbol: string @@ -190,7 +189,7 @@ export namespace V2 { @Struct.field(Float64) declare query_time_ms: Float64 @Struct.field(TokenInfo, {array: true}) declare tokens: TokenInfo[] } - + @Struct.type('get_transaction_response') export class GetTransactionResponse extends Struct { @Struct.field(Float64) declare query_time_ms: Float64 @@ -215,75 +214,77 @@ export namespace V2 { @Struct.field(GetAccountResponseLink, {array: true}) declare links: GetAccountResponseLink[] @Struct.field(TokenInfo, {array: true}) declare tokens: TokenInfo[] @Struct.field(UInt64) declare total_actions: UInt64 - @Struct.field(Action, { array: true }) declare actions: Action[] + @Struct.field(Action, {array: true}) declare actions: Action[] } // For the `health` field @Struct.type('health_entry') export class HealthEntry extends Struct { - @Struct.field('string') declare service: string; - @Struct.field('string') declare status: string; - @Struct.field('any', { optional: true }) declare service_data?: NodeosRPCServiceData | ElasticsearchServiceData; - @Struct.field(UInt64) declare time: UInt64; + @Struct.field('string') declare service: string + @Struct.field('string') declare status: string + @Struct.field('any', {optional: true}) declare service_data?: + | NodeosRPCServiceData + | ElasticsearchServiceData + @Struct.field(UInt64) declare time: UInt64 } @Struct.type('nodeos_rpc_service_data') export class NodeosRPCServiceData extends Struct { - @Struct.field(UInt64) declare head_block_num: UInt64; - @Struct.field('string') declare head_block_time: string; - @Struct.field(UInt64) declare time_offset: UInt64; - @Struct.field(UInt64) declare last_irreversible_block: UInt64; - @Struct.field('string') declare chain_id: string; + @Struct.field(UInt64) declare head_block_num: UInt64 + @Struct.field('string') declare head_block_time: string + @Struct.field(UInt64) declare time_offset: UInt64 + @Struct.field(UInt64) declare last_irreversible_block: UInt64 + @Struct.field('string') declare chain_id: string } @Struct.type('elasticsearch_service_data') export class ElasticsearchServiceData extends Struct { - @Struct.field('string') declare active_shards: string; - @Struct.field(UInt64) declare head_offset: UInt64; - @Struct.field(UInt64) declare first_indexed_block: UInt64; - @Struct.field(UInt64) declare last_indexed_block: UInt64; - @Struct.field(UInt64) declare total_indexed_blocks: UInt64; - @Struct.field(UInt64) declare missing_blocks: UInt64; - @Struct.field('string') declare missing_pct: string; + @Struct.field('string') declare active_shards: string + @Struct.field(UInt64) declare head_offset: UInt64 + @Struct.field(UInt64) declare first_indexed_block: UInt64 + @Struct.field(UInt64) declare last_indexed_block: UInt64 + @Struct.field(UInt64) declare total_indexed_blocks: UInt64 + @Struct.field(UInt64) declare missing_blocks: UInt64 + @Struct.field('string') declare missing_pct: string } // For the `features` field @Struct.type('streaming_features') export class StreamingFeatures extends Struct { - @Struct.field('bool') declare enable: boolean; - @Struct.field('bool') declare traces: boolean; - @Struct.field('bool') declare deltas: boolean; + @Struct.field('bool') declare enable: boolean + @Struct.field('bool') declare traces: boolean + @Struct.field('bool') declare deltas: boolean } @Struct.type('tables_features') export class TablesFeatures extends Struct { - @Struct.field('bool') declare proposals: boolean; - @Struct.field('bool') declare accounts: boolean; - @Struct.field('bool') declare voters: boolean; + @Struct.field('bool') declare proposals: boolean + @Struct.field('bool') declare accounts: boolean + @Struct.field('bool') declare voters: boolean } // For the `features` in the main type @Struct.type('features') export class Features extends Struct { - @Struct.field(StreamingFeatures) declare streaming: StreamingFeatures; - @Struct.field(TablesFeatures) declare tables: TablesFeatures; - @Struct.field('bool') declare index_deltas: boolean; - @Struct.field('bool') declare index_transfer_memo: boolean; - @Struct.field('bool') declare index_all_deltas: boolean; - @Struct.field('bool') declare deferred_trx: boolean; - @Struct.field('bool') declare failed_trx: boolean; - @Struct.field('bool') declare resource_limits: boolean; - @Struct.field('bool') declare resource_usage: boolean; + @Struct.field(StreamingFeatures) declare streaming: StreamingFeatures + @Struct.field(TablesFeatures) declare tables: TablesFeatures + @Struct.field('bool') declare index_deltas: boolean + @Struct.field('bool') declare index_transfer_memo: boolean + @Struct.field('bool') declare index_all_deltas: boolean + @Struct.field('bool') declare deferred_trx: boolean + @Struct.field('bool') declare failed_trx: boolean + @Struct.field('bool') declare resource_limits: boolean + @Struct.field('bool') declare resource_usage: boolean } // The main type @Struct.type('get_health_response') export class GetHealthResponse extends Struct { - @Struct.field('string') declare version: string; - @Struct.field('string') declare version_hash: string; - @Struct.field('string') declare host: string; - @Struct.field(HealthEntry, { array: true }) declare health: HealthEntry[]; - @Struct.field(Features) declare features: Features; - @Struct.field(Float64) declare query_time_ms: Float64; + @Struct.field('string') declare version: string + @Struct.field('string') declare version_hash: string + @Struct.field('string') declare host: string + @Struct.field(HealthEntry, {array: true}) declare health: HealthEntry[] + @Struct.field(Features) declare features: Features + @Struct.field(Float64) declare query_time_ms: Float64 } }