Skip to content

Commit

Permalink
feat: Replaced type with enum for types with multiple values (#157)
Browse files Browse the repository at this point in the history
* Fixed memo.trim()

* Added enum types
  • Loading branch information
tomijaga authored Apr 29, 2021
1 parent 1a18fad commit cab172b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/models/responses/bank/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export interface BankConfigResponse {
protocol: Protocol;
version: Version;
default_transaction_fee: number;
node_type: NodeType;
node_type: NodeType.bank;
}
2 changes: 1 addition & 1 deletion src/models/responses/confirmation-validator/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export interface ConfirmationValidatorConfigResponse {
root_account_file_hash: Hex;
seed_block_identifier: Hex;
daily_confirmation_rate: number;
node_type: NodeType;
node_type: NodeType.confirmationValidator;
}
6 changes: 5 additions & 1 deletion src/models/responses/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export type NodeType = "BANK" | "CONFIRMATION_VALIDATOR" | "PRIMARY_VALIDATOR";
export enum NodeType {
bank = "BANK",
confirmationValidator = "CONFIRMATION_VALIDATOR",
primaryValidator = "PRIMARY_VALIDATOR",
}
export type Version = "v1.0";
export type Protocol = "http" | "https";
export type Port = number;
Expand Down
6 changes: 6 additions & 0 deletions src/models/responses/generic/clean.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { Origin, Port, Protocol } from "../constants";

export enum CleanStatus {
cleaning = "cleaning",
notCleaning = "not_cleaning",
stopRequested = "stop_requested",
}

/** The response model for a crawl request. */
export interface CleanResponse {
clean_last_completed: string;
Expand Down
8 changes: 7 additions & 1 deletion src/models/responses/generic/crawl.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import type { Origin, Port, Protocol } from "../constants";

export enum CrawlStatus {
crawling = "crawling",
notCrawling = "not_crawling",
stopRequested = "stop_requested",
}

/** The response model for a crawl request. */
export interface CrawlResponse {
crawl_last_completed: string;
crawl_status: string;
crawl_status: CrawlStatus;
ip_address: Origin;
port: Port;
protocol: Protocol;
Expand Down
4 changes: 2 additions & 2 deletions src/models/responses/primary-validator/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Hex, Origin, Port, Protocol, Url, Trust, Version, NodeType } from "../constants";
import type { Hex, Origin, Port, Protocol, Url, Version, NodeType } from "../constants";

export interface PrimaryValidatorConfigResponse {
primary_validator: null;
Expand All @@ -13,5 +13,5 @@ export interface PrimaryValidatorConfigResponse {
root_account_file_hash: Hex;
seed_block_identifier: Hex;
daily_confirmation_rate: number;
node_type: NodeType;
node_type: NodeType.primaryValidator;
}

0 comments on commit cab172b

Please sign in to comment.