@chaindex/priorityfee 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,505 @@
1
+ interface HttpTransportOptions {
2
+ baseUrl: string;
3
+ apiKey?: string;
4
+ token?: string;
5
+ fetch?: typeof globalThis.fetch;
6
+ }
7
+ declare class HttpTransport {
8
+ private readonly baseUrl;
9
+ private apiKey?;
10
+ private token?;
11
+ private readonly fetch;
12
+ constructor(options: HttpTransportOptions);
13
+ setToken(token: string): void;
14
+ clearToken(): void;
15
+ get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
16
+ post<T>(path: string, body?: unknown): Promise<T>;
17
+ delete<T>(path: string): Promise<T>;
18
+ private buildUrl;
19
+ private request;
20
+ }
21
+
22
+ type Duration = '1s' | '10s' | '30s' | '1min' | '3min' | '5min' | '10min' | '15min' | '30min' | '1hr' | '2hr' | '4hr' | '24hr';
23
+ type DetailLevel = 'minimal' | 'standard' | 'full';
24
+ type Percentile = 'mean' | 'median' | 'min' | 'max' | 'p5' | 'p10' | 'p15' | 'p20' | 'p25' | 'p30' | 'p35' | 'p40' | 'p45' | 'p50' | 'p55' | 'p60' | 'p65' | 'p70' | 'p75' | 'p80' | 'p85' | 'p90' | 'p95' | 'p96' | 'p97' | 'p98' | 'p99' | 'p99.9' | 'p99.99' | 'p99.999';
25
+ type Metric = 'fee' | 'price' | 'limit';
26
+ type TimeResolution = 'minute' | 'hour' | 'day' | 'week' | 'month';
27
+
28
+ interface Percentiles {
29
+ mean?: string;
30
+ median?: string;
31
+ min?: string;
32
+ max?: string;
33
+ p5?: string;
34
+ p10?: string;
35
+ p15?: string;
36
+ p20?: string;
37
+ p25?: string;
38
+ p30?: string;
39
+ p35?: string;
40
+ p40?: string;
41
+ p45?: string;
42
+ p50?: string;
43
+ p55?: string;
44
+ p60?: string;
45
+ p65?: string;
46
+ p70?: string;
47
+ p75?: string;
48
+ p80?: string;
49
+ p85?: string;
50
+ p90?: string;
51
+ p95?: string;
52
+ p96?: string;
53
+ p97?: string;
54
+ p98?: string;
55
+ p99?: string;
56
+ p99_9?: string;
57
+ p99_99?: string;
58
+ p99_999?: string;
59
+ }
60
+
61
+ interface BlockModel {
62
+ slot: string;
63
+ timestamp: string;
64
+ number_of_transactions: string;
65
+ total_priority_fees: string;
66
+ total_compute_units: string;
67
+ price?: Percentiles;
68
+ fee?: Percentiles;
69
+ limit?: Percentiles;
70
+ }
71
+ interface BlockListResponse {
72
+ network: string;
73
+ limit: number;
74
+ data: BlockModel[];
75
+ }
76
+ interface BlockQueryParams {
77
+ limit?: number;
78
+ detail?: DetailLevel;
79
+ percentiles?: Percentile[];
80
+ }
81
+
82
+ declare class BlockResource {
83
+ private readonly transport;
84
+ constructor(transport: HttpTransport);
85
+ get(params?: BlockQueryParams): Promise<BlockListResponse>;
86
+ getFee(params?: BlockQueryParams): Promise<BlockListResponse>;
87
+ getPrice(params?: BlockQueryParams): Promise<BlockListResponse>;
88
+ getLimit(params?: BlockQueryParams): Promise<BlockListResponse>;
89
+ }
90
+
91
+ interface RollingModel {
92
+ timestamp: string;
93
+ total_priority_fees: string;
94
+ number_of_transactions: string;
95
+ number_of_blocks: string;
96
+ price?: Percentiles;
97
+ fee?: Percentiles;
98
+ limit?: Percentiles;
99
+ }
100
+ interface RollingResponse {
101
+ network: string;
102
+ duration: Duration;
103
+ data: RollingModel;
104
+ }
105
+ interface RollingQueryParams {
106
+ duration?: Duration;
107
+ detail?: DetailLevel;
108
+ percentiles?: Percentile[];
109
+ }
110
+
111
+ declare class RollingResource {
112
+ private readonly transport;
113
+ constructor(transport: HttpTransport);
114
+ get(params?: RollingQueryParams): Promise<RollingResponse>;
115
+ getFee(params?: RollingQueryParams): Promise<RollingResponse>;
116
+ getPrice(params?: RollingQueryParams): Promise<RollingResponse>;
117
+ getLimit(params?: RollingQueryParams): Promise<RollingResponse>;
118
+ }
119
+
120
+ interface TumblingModel {
121
+ timestamp: string;
122
+ total_priority_fees: string;
123
+ number_of_transactions: string;
124
+ number_of_blocks: string;
125
+ price?: Percentiles;
126
+ fee?: Percentiles;
127
+ limit?: Percentiles;
128
+ }
129
+ interface TumblingResponse {
130
+ duration: Duration;
131
+ limit: number;
132
+ data: TumblingModel[];
133
+ }
134
+ interface TumblingQueryParams {
135
+ duration?: Duration;
136
+ limit?: number;
137
+ detail?: DetailLevel;
138
+ percentiles?: Percentile[];
139
+ }
140
+
141
+ declare class TumblingResource {
142
+ private readonly transport;
143
+ constructor(transport: HttpTransport);
144
+ get(params?: TumblingQueryParams): Promise<TumblingResponse>;
145
+ getFee(params?: TumblingQueryParams): Promise<TumblingResponse>;
146
+ getPrice(params?: TumblingQueryParams): Promise<TumblingResponse>;
147
+ getLimit(params?: TumblingQueryParams): Promise<TumblingResponse>;
148
+ }
149
+
150
+ interface DemoModel {
151
+ timestamp: number;
152
+ window_seconds: number;
153
+ window_start: number;
154
+ window_end: number;
155
+ tx_count: number;
156
+ data_points: number;
157
+ is_valid: boolean;
158
+ total_fees: number;
159
+ avg_fee_per_tx: number;
160
+ fee_per_cu: number;
161
+ fee_p50: number;
162
+ fee_p50_count: number;
163
+ fee_p75: number;
164
+ fee_p75_count: number;
165
+ fee_p90: number;
166
+ fee_p90_count: number;
167
+ fee_p99: number;
168
+ fee_p99_count: number;
169
+ fee_min: number;
170
+ fee_max: number;
171
+ price_p50: number;
172
+ price_p50_count: number;
173
+ price_p75: number;
174
+ price_p75_count: number;
175
+ price_p90: number;
176
+ price_p90_count: number;
177
+ price_p99: number;
178
+ price_p99_count: number;
179
+ price_min: number;
180
+ price_max: number;
181
+ limit_p50: number;
182
+ limit_p50_count: number;
183
+ limit_p75: number;
184
+ limit_p75_count: number;
185
+ limit_p90: number;
186
+ limit_p90_count: number;
187
+ limit_p99: number;
188
+ limit_p99_count: number;
189
+ limit_min: number;
190
+ limit_max: number;
191
+ total_cu_consumed: number;
192
+ total_cu_budgeted: number;
193
+ avg_utilization_pct: number;
194
+ wasted_cu: number;
195
+ wasted_cu_pct: number;
196
+ avg_cu_per_tx: number;
197
+ fee_efficiency_score: number;
198
+ }
199
+ interface DemoResponse {
200
+ network: string;
201
+ data: DemoModel;
202
+ }
203
+
204
+ declare class DemoResource {
205
+ private readonly transport;
206
+ constructor(transport: HttpTransport);
207
+ get(): Promise<DemoResponse>;
208
+ }
209
+
210
+ interface SiwsVerifyRequest {
211
+ input: {
212
+ domain?: string;
213
+ statement?: string;
214
+ chainId?: string;
215
+ issuedAt?: string;
216
+ };
217
+ output: {
218
+ account: {
219
+ address: string;
220
+ publicKey: number[];
221
+ };
222
+ signature: number[];
223
+ signedMessage: number[];
224
+ };
225
+ }
226
+ interface VerifyResponse {
227
+ token: string;
228
+ expires_at: number;
229
+ wallet_address: string;
230
+ }
231
+ interface MeResponse {
232
+ wallet_address: string;
233
+ created_at: number;
234
+ last_login_at: number | null;
235
+ }
236
+
237
+ declare class AuthResource {
238
+ private readonly transport;
239
+ constructor(transport: HttpTransport);
240
+ verify(request: SiwsVerifyRequest): Promise<VerifyResponse>;
241
+ me(): Promise<MeResponse>;
242
+ }
243
+
244
+ interface ApiKey {
245
+ id: string;
246
+ name: string;
247
+ key_prefix: string;
248
+ created_at: number;
249
+ last_used_at: number | null;
250
+ request_count: number;
251
+ disabled_at: number | null;
252
+ }
253
+ interface ApiKeyWithSecret extends Omit<ApiKey, 'last_used_at' | 'request_count' | 'disabled_at'> {
254
+ key: string;
255
+ }
256
+ interface ListKeysResponse {
257
+ data: ApiKey[];
258
+ }
259
+
260
+ declare class KeysResource {
261
+ private readonly transport;
262
+ constructor(transport: HttpTransport);
263
+ create(name: string): Promise<ApiKeyWithSecret>;
264
+ list(): Promise<ListKeysResponse>;
265
+ delete(id: string): Promise<{
266
+ disabled: boolean;
267
+ }>;
268
+ }
269
+
270
+ interface Endpoint {
271
+ id: number;
272
+ path: string;
273
+ name: string;
274
+ category: string;
275
+ }
276
+ interface UsageEntry {
277
+ month: string;
278
+ endpoint: Endpoint;
279
+ request_count: number;
280
+ }
281
+ interface UsageResponse {
282
+ data: UsageEntry[];
283
+ }
284
+ interface DetailedUsageEntry {
285
+ api_key_id: string;
286
+ api_key_name: string;
287
+ time_bucket: number;
288
+ endpoint: Endpoint;
289
+ request_count: number;
290
+ }
291
+ interface DetailedUsageResponse {
292
+ data: DetailedUsageEntry[];
293
+ resolution: TimeResolution;
294
+ start: number;
295
+ end: number;
296
+ }
297
+ interface DetailedUsageParams {
298
+ resolution: TimeResolution;
299
+ start?: number;
300
+ end?: number;
301
+ api_key_id?: string;
302
+ }
303
+
304
+ declare class UsageResource {
305
+ private readonly transport;
306
+ constructor(transport: HttpTransport);
307
+ get(): Promise<UsageResponse>;
308
+ getDetailed(params: DetailedUsageParams): Promise<DetailedUsageResponse>;
309
+ }
310
+
311
+ interface HealthResponse {
312
+ status: string;
313
+ service: string;
314
+ version: string;
315
+ }
316
+
317
+ declare class HealthResource {
318
+ private readonly transport;
319
+ constructor(transport: HttpTransport);
320
+ check(): Promise<HealthResponse>;
321
+ }
322
+
323
+ interface HttpClientOptions {
324
+ baseUrl: string;
325
+ apiKey?: string;
326
+ token?: string;
327
+ fetch?: typeof globalThis.fetch;
328
+ }
329
+ declare class HttpClient {
330
+ readonly block: BlockResource;
331
+ readonly rolling: RollingResource;
332
+ readonly tumbling: TumblingResource;
333
+ readonly demo: DemoResource;
334
+ readonly auth: AuthResource;
335
+ readonly keys: KeysResource;
336
+ readonly usage: UsageResource;
337
+ readonly health: HealthResource;
338
+ private readonly transport;
339
+ constructor(options: HttpClientOptions);
340
+ setToken(token: string): void;
341
+ clearToken(): void;
342
+ }
343
+
344
+ type WsChannel = 'block' | 'rolling' | 'demo';
345
+ interface BlockSubscribeParams {
346
+ metric?: Metric;
347
+ detail?: DetailLevel;
348
+ percentiles?: Percentile[];
349
+ limit?: number;
350
+ }
351
+ interface RollingSubscribeParams {
352
+ duration?: Duration;
353
+ metric?: Metric;
354
+ detail?: DetailLevel;
355
+ percentiles?: Percentile[];
356
+ }
357
+ interface DemoSubscribeParams {
358
+ }
359
+ type BlockSubscribeChannel = {
360
+ type: 'block';
361
+ } & BlockSubscribeParams;
362
+ type RollingSubscribeChannel = {
363
+ type: 'rolling';
364
+ } & RollingSubscribeParams;
365
+ type DemoSubscribeChannel = {
366
+ type: 'demo';
367
+ } & DemoSubscribeParams;
368
+ type SubscribeChannel = BlockSubscribeChannel | RollingSubscribeChannel | DemoSubscribeChannel;
369
+ type SubscribeParams = {
370
+ channel: SubscribeChannel;
371
+ };
372
+ type ClientMessage = {
373
+ type: 'subscribe';
374
+ channel: SubscribeChannel;
375
+ } | {
376
+ type: 'unsubscribe';
377
+ id: string;
378
+ } | {
379
+ type: 'ping';
380
+ };
381
+ interface SubscribedMessage {
382
+ type: 'subscribed';
383
+ id: string;
384
+ channel: WsChannel;
385
+ }
386
+ interface DataMessage {
387
+ type: 'data';
388
+ id: string;
389
+ channel: WsChannel;
390
+ payload: unknown;
391
+ }
392
+ interface UnsubscribedMessage {
393
+ type: 'unsubscribed';
394
+ id: string;
395
+ }
396
+ interface WsErrorMessage {
397
+ type: 'error';
398
+ id: string | null;
399
+ code: string;
400
+ message: string;
401
+ }
402
+ interface PongMessage {
403
+ type: 'pong';
404
+ }
405
+ type ServerMessage = SubscribedMessage | DataMessage | UnsubscribedMessage | WsErrorMessage | PongMessage;
406
+ interface Subscription {
407
+ readonly id: string;
408
+ readonly channel: WsChannel;
409
+ unsubscribe(): void;
410
+ }
411
+ interface ChannelPayloadMap {
412
+ block: BlockListResponse;
413
+ rolling: RollingResponse;
414
+ demo: DemoResponse;
415
+ }
416
+ interface SubscriptionHandlers<C extends WsChannel> {
417
+ onData: (data: ChannelPayloadMap[C]) => void;
418
+ onError?: (error: WsErrorMessage) => void;
419
+ }
420
+ interface WsClientOptions {
421
+ baseUrl: string;
422
+ apiKey: string;
423
+ autoConnect?: boolean;
424
+ reconnect?: boolean;
425
+ maxReconnectAttempts?: number;
426
+ reconnectDelay?: number;
427
+ pingInterval?: number;
428
+ WebSocket?: unknown;
429
+ }
430
+ type WsTransportState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
431
+ interface WsTransportEvents {
432
+ open: () => void;
433
+ close: (code: number, reason: string) => void;
434
+ error: (error: Event) => void;
435
+ message: (msg: ServerMessage) => void;
436
+ stateChange: (state: WsTransportState) => void;
437
+ }
438
+
439
+ type ClientEventName = 'open' | 'close' | 'error' | 'stateChange';
440
+ type ClientListener<E extends ClientEventName> = WsTransportEvents[E];
441
+ declare class WsClient {
442
+ private readonly transport;
443
+ private readonly active;
444
+ private readonly pending;
445
+ constructor(options: WsClientOptions);
446
+ get state(): WsTransportState;
447
+ connect(): void;
448
+ disconnect(): void;
449
+ on<E extends ClientEventName>(event: E, fn: ClientListener<E>): void;
450
+ off<E extends ClientEventName>(event: E, fn: ClientListener<E>): void;
451
+ subscribeBlock(params: BlockSubscribeParams, handlers: SubscriptionHandlers<'block'>): Promise<Subscription>;
452
+ subscribeRolling(params: RollingSubscribeParams, handlers: SubscriptionHandlers<'rolling'>): Promise<Subscription>;
453
+ subscribeDemo(handlers: SubscriptionHandlers<'demo'>): Promise<Subscription>;
454
+ private subscribe;
455
+ private handleMessage;
456
+ private handleSubscribed;
457
+ private handleData;
458
+ private handleError;
459
+ private handleReconnect;
460
+ }
461
+
462
+ type EventName = keyof WsTransportEvents;
463
+ type Listener<E extends EventName> = WsTransportEvents[E];
464
+ declare class WsTransport {
465
+ private ws;
466
+ private _state;
467
+ private disposed;
468
+ private reconnectAttempt;
469
+ private reconnectTimer;
470
+ private pingTimer;
471
+ private pongTimer;
472
+ private listeners;
473
+ private readonly url;
474
+ private readonly reconnect;
475
+ private readonly maxReconnectAttempts;
476
+ private readonly reconnectDelay;
477
+ private readonly pingInterval;
478
+ private readonly WsCtor;
479
+ constructor(options: WsClientOptions);
480
+ get state(): WsTransportState;
481
+ connect(): void;
482
+ disconnect(): void;
483
+ send(msg: ClientMessage): void;
484
+ on<E extends EventName>(event: E, fn: Listener<E>): void;
485
+ off<E extends EventName>(event: E, fn: Listener<E>): void;
486
+ private emit;
487
+ private setState;
488
+ private handleMessage;
489
+ private startPing;
490
+ private stopPing;
491
+ private clearPongTimer;
492
+ private scheduleReconnect;
493
+ private clearReconnectTimer;
494
+ }
495
+
496
+ declare class SdkError extends Error {
497
+ constructor(message: string);
498
+ }
499
+ declare class ApiError extends SdkError {
500
+ readonly status: number;
501
+ readonly body?: unknown;
502
+ constructor(status: number, message: string, body?: unknown);
503
+ }
504
+
505
+ export { ApiError, type ApiKey, type ApiKeyWithSecret, type BlockListResponse, type BlockModel, type BlockQueryParams, type BlockSubscribeParams, type ChannelPayloadMap, type DemoModel, type DemoResponse, type DemoSubscribeParams, type DetailLevel, type DetailedUsageEntry, type DetailedUsageParams, type DetailedUsageResponse, type Duration, type Endpoint, type HealthResponse, HttpClient, type HttpClientOptions, HttpTransport, type HttpTransportOptions, type ListKeysResponse, type MeResponse, type Metric, type Percentile, type Percentiles, type RollingModel, type RollingQueryParams, type RollingResponse, type RollingSubscribeParams, SdkError, type SiwsVerifyRequest, type SubscribeParams, type Subscription, type SubscriptionHandlers, type TimeResolution, type TumblingModel, type TumblingQueryParams, type TumblingResponse, type UsageEntry, type UsageResponse, type VerifyResponse, type WsChannel, WsClient, type WsClientOptions, type WsErrorMessage, WsTransport, type WsTransportEvents, type WsTransportState };