From 576634406de1f8d6b70db428938de3a3932c7eb9 Mon Sep 17 00:00:00 2001 From: melonges Date: Wed, 24 Sep 2025 15:28:06 +0300 Subject: [PATCH] types: `TimeInterval` --- src/data-api.ts | 9 +++++---- src/interfaces.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/data-api.ts b/src/data-api.ts index cc00bba..b703fd3 100644 --- a/src/data-api.ts +++ b/src/data-api.ts @@ -1,4 +1,4 @@ -import { +import type { TokenDetailResponse, MultiTokensResponse, TokenHoldersResponse, @@ -28,7 +28,8 @@ import { WalletTradesResponse, ProcessedEvent, SubscriptionResponse, - ChartDataParams + ChartDataParams, + TimeInterval } from './interfaces'; import { decodeBinaryEvents } from './event-processor'; @@ -834,7 +835,7 @@ export class Client { */ async getHoldersChart( tokenAddress: string, - type?: string, + type?: TimeInterval, timeFrom?: number, timeTo?: number ): Promise { @@ -1053,4 +1054,4 @@ export class Client { return events; } -} \ No newline at end of file +} diff --git a/src/interfaces.ts b/src/interfaces.ts index b20b80e..576f7a8 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -132,6 +132,14 @@ export interface PriceChangeData { priceChangePercentage: number; } +type Seconds = 1 | 5 | 15; +type Minutes = 1 | 3 | 5 | 15 | 30; +type Hours = 1 | 2 | 4 | 6 | 8 | 12; +type Days = 1 | 3 +type Weeks = 1 +type Months = 1 +export type TimeInterval = `${Seconds}s` | `${Minutes}m` | `${Hours}h` | `${Days}d` | `${Weeks}w` | `${Months}mn` + export interface TokenEvents { "1m"?: PriceChangeData; "5m"?: PriceChangeData; @@ -743,7 +751,7 @@ export interface ChartDataParams { /** Pool address (only for pool-specific charts) */ poolAddress?: string; /** Time interval (e.g., "1s", "1m", "1h", "1d") */ - type?: string; + type?: TimeInterval; /** Start time (Unix timestamp in seconds) */ timeFrom?: number; /** End time (Unix timestamp in seconds) */ @@ -759,4 +767,3 @@ export interface ChartDataParams { /** Enable live cache for faster response times (default: false) */ fastCache?: boolean; } -