@satrush/api 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.
- package/README.md +97 -0
- package/dist/index.cjs +1138 -0
- package/dist/index.d.cts +728 -0
- package/dist/index.d.ts +728 -0
- package/dist/index.js +1082 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
type AuthToken = string | undefined;
|
|
4
|
+
interface Auth {
|
|
5
|
+
/**
|
|
6
|
+
* Which part of the request do we use to send the auth?
|
|
7
|
+
*
|
|
8
|
+
* @default 'header'
|
|
9
|
+
*/
|
|
10
|
+
in?: 'header' | 'query' | 'cookie';
|
|
11
|
+
/**
|
|
12
|
+
* Header or query parameter name.
|
|
13
|
+
*
|
|
14
|
+
* @default 'Authorization'
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
17
|
+
scheme?: 'basic' | 'bearer';
|
|
18
|
+
type: 'apiKey' | 'http';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SerializerOptions<T> {
|
|
22
|
+
/**
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
explode: boolean;
|
|
26
|
+
style: T;
|
|
27
|
+
}
|
|
28
|
+
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
29
|
+
type ObjectStyle = 'form' | 'deepObject';
|
|
30
|
+
|
|
31
|
+
type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
32
|
+
type BodySerializer = (body: any) => any;
|
|
33
|
+
type QuerySerializerOptionsObject = {
|
|
34
|
+
allowReserved?: boolean;
|
|
35
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
36
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
37
|
+
};
|
|
38
|
+
type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
39
|
+
/**
|
|
40
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
41
|
+
* override the global array/object settings for specific parameter names.
|
|
42
|
+
*/
|
|
43
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
47
|
+
type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
48
|
+
/**
|
|
49
|
+
* Returns the final request URL.
|
|
50
|
+
*/
|
|
51
|
+
buildUrl: BuildUrlFn;
|
|
52
|
+
getConfig: () => Config;
|
|
53
|
+
request: RequestFn;
|
|
54
|
+
setConfig: (config: Config) => Config;
|
|
55
|
+
} & {
|
|
56
|
+
[K in HttpMethod]: MethodFn;
|
|
57
|
+
} & ([SseFn] extends [never] ? {
|
|
58
|
+
sse?: never;
|
|
59
|
+
} : {
|
|
60
|
+
sse: {
|
|
61
|
+
[K in HttpMethod]: SseFn;
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
interface Config$1 {
|
|
65
|
+
/**
|
|
66
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
67
|
+
* added to the request payload as defined by its `security` array.
|
|
68
|
+
*/
|
|
69
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
70
|
+
/**
|
|
71
|
+
* A function for serializing request body parameter. By default,
|
|
72
|
+
* {@link JSON.stringify()} will be used.
|
|
73
|
+
*/
|
|
74
|
+
bodySerializer?: BodySerializer | null;
|
|
75
|
+
/**
|
|
76
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
77
|
+
* `Headers` object with.
|
|
78
|
+
*
|
|
79
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
80
|
+
*/
|
|
81
|
+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* The request method.
|
|
84
|
+
*
|
|
85
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
86
|
+
*/
|
|
87
|
+
method?: Uppercase<HttpMethod>;
|
|
88
|
+
/**
|
|
89
|
+
* A function for serializing request query parameters. By default, arrays
|
|
90
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
91
|
+
* style, and reserved characters are percent-encoded.
|
|
92
|
+
*
|
|
93
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
94
|
+
* API function is used.
|
|
95
|
+
*
|
|
96
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
97
|
+
*/
|
|
98
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
99
|
+
/**
|
|
100
|
+
* A function validating request data. This is useful if you want to ensure
|
|
101
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
102
|
+
* the server.
|
|
103
|
+
*/
|
|
104
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* A function transforming response data before it's returned. This is useful
|
|
107
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
108
|
+
*/
|
|
109
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* A function validating response data. This is useful if you want to ensure
|
|
112
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
113
|
+
* the transformers and returned to the user.
|
|
114
|
+
*/
|
|
115
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
119
|
+
/**
|
|
120
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
121
|
+
* fetch instance.
|
|
122
|
+
*
|
|
123
|
+
* @default globalThis.fetch
|
|
124
|
+
*/
|
|
125
|
+
fetch?: typeof fetch;
|
|
126
|
+
/**
|
|
127
|
+
* Implementing clients can call request interceptors inside this hook.
|
|
128
|
+
*/
|
|
129
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
130
|
+
/**
|
|
131
|
+
* Callback invoked when a network or parsing error occurs during streaming.
|
|
132
|
+
*
|
|
133
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
134
|
+
*
|
|
135
|
+
* @param error The error that occurred.
|
|
136
|
+
*/
|
|
137
|
+
onSseError?: (error: unknown) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Callback invoked when an event is streamed from the server.
|
|
140
|
+
*
|
|
141
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
142
|
+
*
|
|
143
|
+
* @param event Event streamed from the server.
|
|
144
|
+
* @returns Nothing (void).
|
|
145
|
+
*/
|
|
146
|
+
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
147
|
+
serializedBody?: RequestInit['body'];
|
|
148
|
+
/**
|
|
149
|
+
* Default retry delay in milliseconds.
|
|
150
|
+
*
|
|
151
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
152
|
+
*
|
|
153
|
+
* @default 3000
|
|
154
|
+
*/
|
|
155
|
+
sseDefaultRetryDelay?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Maximum number of retry attempts before giving up.
|
|
158
|
+
*/
|
|
159
|
+
sseMaxRetryAttempts?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Maximum retry delay in milliseconds.
|
|
162
|
+
*
|
|
163
|
+
* Applies only when exponential backoff is used.
|
|
164
|
+
*
|
|
165
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
166
|
+
*
|
|
167
|
+
* @default 30000
|
|
168
|
+
*/
|
|
169
|
+
sseMaxRetryDelay?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Optional sleep function for retry backoff.
|
|
172
|
+
*
|
|
173
|
+
* Defaults to using `setTimeout`.
|
|
174
|
+
*/
|
|
175
|
+
sseSleepFn?: (ms: number) => Promise<void>;
|
|
176
|
+
url: string;
|
|
177
|
+
};
|
|
178
|
+
interface StreamEvent<TData = unknown> {
|
|
179
|
+
data: TData;
|
|
180
|
+
event?: string;
|
|
181
|
+
id?: string;
|
|
182
|
+
retry?: number;
|
|
183
|
+
}
|
|
184
|
+
type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
185
|
+
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
186
|
+
};
|
|
187
|
+
declare const createSseClient: <TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions) => ServerSentEventsResult<TData>;
|
|
188
|
+
|
|
189
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
190
|
+
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
191
|
+
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
192
|
+
declare class Interceptors<Interceptor> {
|
|
193
|
+
fns: Array<Interceptor | null>;
|
|
194
|
+
clear(): void;
|
|
195
|
+
eject(id: number | Interceptor): void;
|
|
196
|
+
exists(id: number | Interceptor): boolean;
|
|
197
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
198
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
199
|
+
use(fn: Interceptor): number;
|
|
200
|
+
}
|
|
201
|
+
interface Middleware<Req, Res, Err, Options> {
|
|
202
|
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
203
|
+
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
204
|
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type ResponseStyle = 'data' | 'fields';
|
|
208
|
+
interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
|
|
209
|
+
/**
|
|
210
|
+
* Base URL for all requests made by this client.
|
|
211
|
+
*/
|
|
212
|
+
baseUrl?: T['baseUrl'];
|
|
213
|
+
/**
|
|
214
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
215
|
+
* fetch instance.
|
|
216
|
+
*
|
|
217
|
+
* @default globalThis.fetch
|
|
218
|
+
*/
|
|
219
|
+
fetch?: typeof fetch;
|
|
220
|
+
/**
|
|
221
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
222
|
+
* options won't have any effect.
|
|
223
|
+
*
|
|
224
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
225
|
+
*/
|
|
226
|
+
next?: never;
|
|
227
|
+
/**
|
|
228
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
229
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
230
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
231
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
232
|
+
*
|
|
233
|
+
* @default 'auto'
|
|
234
|
+
*/
|
|
235
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
236
|
+
/**
|
|
237
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
238
|
+
*
|
|
239
|
+
* @default 'fields'
|
|
240
|
+
*/
|
|
241
|
+
responseStyle?: ResponseStyle;
|
|
242
|
+
/**
|
|
243
|
+
* Throw an error instead of returning it in the response?
|
|
244
|
+
*
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
throwOnError?: T['throwOnError'];
|
|
248
|
+
}
|
|
249
|
+
interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
250
|
+
responseStyle: TResponseStyle;
|
|
251
|
+
throwOnError: ThrowOnError;
|
|
252
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
253
|
+
/**
|
|
254
|
+
* Any body that you want to add to your request.
|
|
255
|
+
*
|
|
256
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
257
|
+
*/
|
|
258
|
+
body?: unknown;
|
|
259
|
+
path?: Record<string, unknown>;
|
|
260
|
+
query?: Record<string, unknown>;
|
|
261
|
+
/**
|
|
262
|
+
* Security mechanism(s) to use for the request.
|
|
263
|
+
*/
|
|
264
|
+
security?: ReadonlyArray<Auth>;
|
|
265
|
+
url: Url;
|
|
266
|
+
}
|
|
267
|
+
interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
268
|
+
serializedBody?: string;
|
|
269
|
+
}
|
|
270
|
+
type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
271
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
272
|
+
request: Request;
|
|
273
|
+
response: Response;
|
|
274
|
+
}> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
275
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
276
|
+
error: undefined;
|
|
277
|
+
} | {
|
|
278
|
+
data: undefined;
|
|
279
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
280
|
+
}) & {
|
|
281
|
+
request: Request;
|
|
282
|
+
response: Response;
|
|
283
|
+
}>;
|
|
284
|
+
interface ClientOptions$1 {
|
|
285
|
+
baseUrl?: string;
|
|
286
|
+
responseStyle?: ResponseStyle;
|
|
287
|
+
throwOnError?: boolean;
|
|
288
|
+
}
|
|
289
|
+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
290
|
+
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
291
|
+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
292
|
+
type BuildUrlFn = <TData extends {
|
|
293
|
+
body?: unknown;
|
|
294
|
+
path?: Record<string, unknown>;
|
|
295
|
+
query?: Record<string, unknown>;
|
|
296
|
+
url: string;
|
|
297
|
+
}>(options: TData & Options$1<TData>) => string;
|
|
298
|
+
type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
299
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
300
|
+
};
|
|
301
|
+
interface TDataShape {
|
|
302
|
+
body?: unknown;
|
|
303
|
+
headers?: unknown;
|
|
304
|
+
path?: unknown;
|
|
305
|
+
query?: unknown;
|
|
306
|
+
url: string;
|
|
307
|
+
}
|
|
308
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
309
|
+
type Options$1<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
310
|
+
|
|
311
|
+
declare const createClient: (config?: Config) => Client;
|
|
312
|
+
|
|
313
|
+
type ClientOptions = {
|
|
314
|
+
baseUrl: `${string}://${string}/api` | (string & {});
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* Board state: the active round pointer, its mining window, the strike
|
|
318
|
+
* jackpot, the live blockchain slot and the current round's details.
|
|
319
|
+
*/
|
|
320
|
+
type BoardDto = {
|
|
321
|
+
activeRound?: null | RoundDto;
|
|
322
|
+
address: PubkeyDto;
|
|
323
|
+
/**
|
|
324
|
+
* Latest finalized blockchain slot observed by the service.
|
|
325
|
+
*/
|
|
326
|
+
currentSlot: U64Dto;
|
|
327
|
+
/**
|
|
328
|
+
* Slot at which the current round ends mining.
|
|
329
|
+
*/
|
|
330
|
+
endSlot: U64Dto;
|
|
331
|
+
previousRound?: null | RoundDto;
|
|
332
|
+
/**
|
|
333
|
+
* Round duration in slots.
|
|
334
|
+
*/
|
|
335
|
+
roundDuration: number;
|
|
336
|
+
roundId: number;
|
|
337
|
+
/**
|
|
338
|
+
* Slot at which the current round starts mining.
|
|
339
|
+
*/
|
|
340
|
+
startSlot: U64Dto;
|
|
341
|
+
strike: StrikeJackpotDto;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Signed 128-bit integer encoded as a decimal string.
|
|
345
|
+
*/
|
|
346
|
+
type I128Dto = bigint;
|
|
347
|
+
/**
|
|
348
|
+
* Signed 64-bit integer encoded as a decimal string.
|
|
349
|
+
*/
|
|
350
|
+
type I64Dto = bigint;
|
|
351
|
+
type InternalErrorCodeErrorBody = {
|
|
352
|
+
code: 'internal_error';
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Pubkey represented as base58 string in JSON and OpenAPI.
|
|
356
|
+
*
|
|
357
|
+
* - JSON: `"11111111111111111111111111111111"`
|
|
358
|
+
* - OpenAPI: `type: string`, pattern for base58, optional format
|
|
359
|
+
*/
|
|
360
|
+
type PubkeyDto = string;
|
|
361
|
+
/**
|
|
362
|
+
* Core state of a mining round.
|
|
363
|
+
*/
|
|
364
|
+
type RoundDto = {
|
|
365
|
+
address: PubkeyDto;
|
|
366
|
+
deployedBtcAmount: U64Dto;
|
|
367
|
+
deployedPendingUsdAmount: U64Dto;
|
|
368
|
+
deployedUsdAmount: U64Dto;
|
|
369
|
+
deployedUsdOnWinningTileAmount: U64Dto;
|
|
370
|
+
id: number;
|
|
371
|
+
minersCount: number;
|
|
372
|
+
revealedMinersCount: number;
|
|
373
|
+
settledMinersCount: number;
|
|
374
|
+
state: RoundStateDto;
|
|
375
|
+
strikeBonusBtc: U64Dto;
|
|
376
|
+
strikeBonusUsd: U64Dto;
|
|
377
|
+
tileStakes: Array<TileStakeDto>;
|
|
378
|
+
winnersCount: number;
|
|
379
|
+
winningTile?: number | null;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Lifecycle state of a round.
|
|
383
|
+
*/
|
|
384
|
+
declare const RoundStateDto: {
|
|
385
|
+
readonly ACTIVE: "active";
|
|
386
|
+
readonly REVEALED: "revealed";
|
|
387
|
+
readonly SETTLED: "settled";
|
|
388
|
+
readonly FINISHED: "finished";
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Lifecycle state of a round.
|
|
392
|
+
*/
|
|
393
|
+
type RoundStateDto = typeof RoundStateDto[keyof typeof RoundStateDto];
|
|
394
|
+
/**
|
|
395
|
+
* Strike jackpot balances tracked on the board.
|
|
396
|
+
*/
|
|
397
|
+
type StrikeJackpotDto = {
|
|
398
|
+
/**
|
|
399
|
+
* BTC held after the swap.
|
|
400
|
+
*/
|
|
401
|
+
btcAmount: U64Dto;
|
|
402
|
+
/**
|
|
403
|
+
* Last round id at which the strike jackpot was triggered.
|
|
404
|
+
*/
|
|
405
|
+
lastTriggerRoundId: number;
|
|
406
|
+
/**
|
|
407
|
+
* USD waiting to be swapped into BTC.
|
|
408
|
+
*/
|
|
409
|
+
pendingUsdAmount: U64Dto;
|
|
410
|
+
/**
|
|
411
|
+
* USD held after the swap.
|
|
412
|
+
*/
|
|
413
|
+
usdAmount: U64Dto;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Per-tile deploy count and even-split stake sum.
|
|
417
|
+
*/
|
|
418
|
+
type TileStakeDto = {
|
|
419
|
+
deployCount: number;
|
|
420
|
+
stake: U64Dto;
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Unsigned 128-bit integer encoded as a decimal string.
|
|
424
|
+
*/
|
|
425
|
+
type U128Dto = bigint;
|
|
426
|
+
/**
|
|
427
|
+
* Unsigned 64-bit integer encoded as a decimal string.
|
|
428
|
+
*/
|
|
429
|
+
type U64Dto = bigint;
|
|
430
|
+
type GetBoardData = {
|
|
431
|
+
body?: never;
|
|
432
|
+
path?: never;
|
|
433
|
+
query?: never;
|
|
434
|
+
url: '/v1/board';
|
|
435
|
+
};
|
|
436
|
+
type GetBoardErrors = {
|
|
437
|
+
500: InternalErrorCodeErrorBody;
|
|
438
|
+
};
|
|
439
|
+
type GetBoardError = GetBoardErrors[keyof GetBoardErrors];
|
|
440
|
+
type GetBoardResponses = {
|
|
441
|
+
200: {
|
|
442
|
+
data: BoardDto;
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
type GetBoardResponse = GetBoardResponses[keyof GetBoardResponses];
|
|
446
|
+
|
|
447
|
+
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options$1<TData, ThrowOnError> & {
|
|
448
|
+
/**
|
|
449
|
+
* You can provide a client instance returned by `createClient()` instead of
|
|
450
|
+
* individual options. This might be also useful if you want to implement a
|
|
451
|
+
* custom client.
|
|
452
|
+
*/
|
|
453
|
+
client?: Client;
|
|
454
|
+
/**
|
|
455
|
+
* You can pass arbitrary values through the `meta` object. This can be
|
|
456
|
+
* used to access values that aren't defined as part of the SDK function.
|
|
457
|
+
*/
|
|
458
|
+
meta?: Record<string, unknown>;
|
|
459
|
+
};
|
|
460
|
+
declare class HeyApiClient {
|
|
461
|
+
protected client: Client;
|
|
462
|
+
constructor(args?: {
|
|
463
|
+
client?: Client;
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
declare class HeyApiRegistry<T> {
|
|
467
|
+
private readonly defaultKey;
|
|
468
|
+
private readonly instances;
|
|
469
|
+
get(key?: string): T;
|
|
470
|
+
set(value: T, key?: string): void;
|
|
471
|
+
}
|
|
472
|
+
declare class SatrushBackendSdk extends HeyApiClient {
|
|
473
|
+
static readonly __registry: HeyApiRegistry<SatrushBackendSdk>;
|
|
474
|
+
constructor(args?: {
|
|
475
|
+
client?: Client;
|
|
476
|
+
key?: string;
|
|
477
|
+
});
|
|
478
|
+
/**
|
|
479
|
+
* Request board
|
|
480
|
+
*/
|
|
481
|
+
getBoard<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>): RequestResult<GetBoardResponses, GetBoardErrors, ThrowOnError, "fields">;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Signed 128-bit integer encoded as a decimal string.
|
|
486
|
+
*/
|
|
487
|
+
declare const zI128Dto: z.ZodString;
|
|
488
|
+
/**
|
|
489
|
+
* Signed 64-bit integer encoded as a decimal string.
|
|
490
|
+
*/
|
|
491
|
+
declare const zI64Dto: z.ZodCoercedBigInt<unknown>;
|
|
492
|
+
declare const zInternalErrorCodeErrorBody: z.ZodObject<{
|
|
493
|
+
code: z.ZodEnum<{
|
|
494
|
+
internal_error: "internal_error";
|
|
495
|
+
}>;
|
|
496
|
+
}, z.core.$strip>;
|
|
497
|
+
/**
|
|
498
|
+
* Pubkey represented as base58 string in JSON and OpenAPI.
|
|
499
|
+
*
|
|
500
|
+
* - JSON: `"11111111111111111111111111111111"`
|
|
501
|
+
* - OpenAPI: `type: string`, pattern for base58, optional format
|
|
502
|
+
*/
|
|
503
|
+
declare const zPubkeyDto: z.ZodString;
|
|
504
|
+
/**
|
|
505
|
+
* Lifecycle state of a round.
|
|
506
|
+
*/
|
|
507
|
+
declare const zRoundStateDto: z.ZodEnum<{
|
|
508
|
+
active: "active";
|
|
509
|
+
revealed: "revealed";
|
|
510
|
+
settled: "settled";
|
|
511
|
+
finished: "finished";
|
|
512
|
+
}>;
|
|
513
|
+
/**
|
|
514
|
+
* Unsigned 128-bit integer encoded as a decimal string.
|
|
515
|
+
*/
|
|
516
|
+
declare const zU128Dto: z.ZodString;
|
|
517
|
+
/**
|
|
518
|
+
* Unsigned 64-bit integer encoded as a decimal string.
|
|
519
|
+
*/
|
|
520
|
+
declare const zU64Dto: z.ZodCoercedBigInt<unknown>;
|
|
521
|
+
/**
|
|
522
|
+
* Strike jackpot balances tracked on the board.
|
|
523
|
+
*/
|
|
524
|
+
declare const zStrikeJackpotDto: z.ZodObject<{
|
|
525
|
+
btcAmount: z.ZodCoercedBigInt<unknown>;
|
|
526
|
+
lastTriggerRoundId: z.ZodInt;
|
|
527
|
+
pendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
528
|
+
usdAmount: z.ZodCoercedBigInt<unknown>;
|
|
529
|
+
}, z.core.$strip>;
|
|
530
|
+
/**
|
|
531
|
+
* Per-tile deploy count and even-split stake sum.
|
|
532
|
+
*/
|
|
533
|
+
declare const zTileStakeDto: z.ZodObject<{
|
|
534
|
+
deployCount: z.ZodInt;
|
|
535
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
536
|
+
}, z.core.$strip>;
|
|
537
|
+
/**
|
|
538
|
+
* Core state of a mining round.
|
|
539
|
+
*/
|
|
540
|
+
declare const zRoundDto: z.ZodObject<{
|
|
541
|
+
address: z.ZodString;
|
|
542
|
+
deployedBtcAmount: z.ZodCoercedBigInt<unknown>;
|
|
543
|
+
deployedPendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
544
|
+
deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
545
|
+
deployedUsdOnWinningTileAmount: z.ZodCoercedBigInt<unknown>;
|
|
546
|
+
id: z.ZodInt;
|
|
547
|
+
minersCount: z.ZodInt;
|
|
548
|
+
revealedMinersCount: z.ZodInt;
|
|
549
|
+
settledMinersCount: z.ZodInt;
|
|
550
|
+
state: z.ZodEnum<{
|
|
551
|
+
active: "active";
|
|
552
|
+
revealed: "revealed";
|
|
553
|
+
settled: "settled";
|
|
554
|
+
finished: "finished";
|
|
555
|
+
}>;
|
|
556
|
+
strikeBonusBtc: z.ZodCoercedBigInt<unknown>;
|
|
557
|
+
strikeBonusUsd: z.ZodCoercedBigInt<unknown>;
|
|
558
|
+
tileStakes: z.ZodArray<z.ZodObject<{
|
|
559
|
+
deployCount: z.ZodInt;
|
|
560
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
561
|
+
}, z.core.$strip>>;
|
|
562
|
+
winnersCount: z.ZodInt;
|
|
563
|
+
winningTile: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodNull]>>;
|
|
564
|
+
}, z.core.$strip>;
|
|
565
|
+
/**
|
|
566
|
+
* Board state: the active round pointer, its mining window, the strike
|
|
567
|
+
* jackpot, the live blockchain slot and the current round's details.
|
|
568
|
+
*/
|
|
569
|
+
declare const zBoardDto: z.ZodObject<{
|
|
570
|
+
activeRound: z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
571
|
+
address: z.ZodString;
|
|
572
|
+
deployedBtcAmount: z.ZodCoercedBigInt<unknown>;
|
|
573
|
+
deployedPendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
574
|
+
deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
575
|
+
deployedUsdOnWinningTileAmount: z.ZodCoercedBigInt<unknown>;
|
|
576
|
+
id: z.ZodInt;
|
|
577
|
+
minersCount: z.ZodInt;
|
|
578
|
+
revealedMinersCount: z.ZodInt;
|
|
579
|
+
settledMinersCount: z.ZodInt;
|
|
580
|
+
state: z.ZodEnum<{
|
|
581
|
+
active: "active";
|
|
582
|
+
revealed: "revealed";
|
|
583
|
+
settled: "settled";
|
|
584
|
+
finished: "finished";
|
|
585
|
+
}>;
|
|
586
|
+
strikeBonusBtc: z.ZodCoercedBigInt<unknown>;
|
|
587
|
+
strikeBonusUsd: z.ZodCoercedBigInt<unknown>;
|
|
588
|
+
tileStakes: z.ZodArray<z.ZodObject<{
|
|
589
|
+
deployCount: z.ZodInt;
|
|
590
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
591
|
+
}, z.core.$strip>>;
|
|
592
|
+
winnersCount: z.ZodInt;
|
|
593
|
+
winningTile: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodNull]>>;
|
|
594
|
+
}, z.core.$strip>]>>;
|
|
595
|
+
address: z.ZodString;
|
|
596
|
+
currentSlot: z.ZodCoercedBigInt<unknown>;
|
|
597
|
+
endSlot: z.ZodCoercedBigInt<unknown>;
|
|
598
|
+
previousRound: z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
599
|
+
address: z.ZodString;
|
|
600
|
+
deployedBtcAmount: z.ZodCoercedBigInt<unknown>;
|
|
601
|
+
deployedPendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
602
|
+
deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
603
|
+
deployedUsdOnWinningTileAmount: z.ZodCoercedBigInt<unknown>;
|
|
604
|
+
id: z.ZodInt;
|
|
605
|
+
minersCount: z.ZodInt;
|
|
606
|
+
revealedMinersCount: z.ZodInt;
|
|
607
|
+
settledMinersCount: z.ZodInt;
|
|
608
|
+
state: z.ZodEnum<{
|
|
609
|
+
active: "active";
|
|
610
|
+
revealed: "revealed";
|
|
611
|
+
settled: "settled";
|
|
612
|
+
finished: "finished";
|
|
613
|
+
}>;
|
|
614
|
+
strikeBonusBtc: z.ZodCoercedBigInt<unknown>;
|
|
615
|
+
strikeBonusUsd: z.ZodCoercedBigInt<unknown>;
|
|
616
|
+
tileStakes: z.ZodArray<z.ZodObject<{
|
|
617
|
+
deployCount: z.ZodInt;
|
|
618
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
619
|
+
}, z.core.$strip>>;
|
|
620
|
+
winnersCount: z.ZodInt;
|
|
621
|
+
winningTile: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodNull]>>;
|
|
622
|
+
}, z.core.$strip>]>>;
|
|
623
|
+
roundDuration: z.ZodInt;
|
|
624
|
+
roundId: z.ZodInt;
|
|
625
|
+
startSlot: z.ZodCoercedBigInt<unknown>;
|
|
626
|
+
strike: z.ZodObject<{
|
|
627
|
+
btcAmount: z.ZodCoercedBigInt<unknown>;
|
|
628
|
+
lastTriggerRoundId: z.ZodInt;
|
|
629
|
+
pendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
630
|
+
usdAmount: z.ZodCoercedBigInt<unknown>;
|
|
631
|
+
}, z.core.$strip>;
|
|
632
|
+
}, z.core.$strip>;
|
|
633
|
+
declare const zGetBoardData: z.ZodObject<{
|
|
634
|
+
body: z.ZodOptional<z.ZodNever>;
|
|
635
|
+
path: z.ZodOptional<z.ZodNever>;
|
|
636
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
637
|
+
}, z.core.$strip>;
|
|
638
|
+
declare const zGetBoardResponse: z.ZodObject<{
|
|
639
|
+
data: z.ZodObject<{
|
|
640
|
+
activeRound: z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
641
|
+
address: z.ZodString;
|
|
642
|
+
deployedBtcAmount: z.ZodCoercedBigInt<unknown>;
|
|
643
|
+
deployedPendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
644
|
+
deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
645
|
+
deployedUsdOnWinningTileAmount: z.ZodCoercedBigInt<unknown>;
|
|
646
|
+
id: z.ZodInt;
|
|
647
|
+
minersCount: z.ZodInt;
|
|
648
|
+
revealedMinersCount: z.ZodInt;
|
|
649
|
+
settledMinersCount: z.ZodInt;
|
|
650
|
+
state: z.ZodEnum<{
|
|
651
|
+
active: "active";
|
|
652
|
+
revealed: "revealed";
|
|
653
|
+
settled: "settled";
|
|
654
|
+
finished: "finished";
|
|
655
|
+
}>;
|
|
656
|
+
strikeBonusBtc: z.ZodCoercedBigInt<unknown>;
|
|
657
|
+
strikeBonusUsd: z.ZodCoercedBigInt<unknown>;
|
|
658
|
+
tileStakes: z.ZodArray<z.ZodObject<{
|
|
659
|
+
deployCount: z.ZodInt;
|
|
660
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
661
|
+
}, z.core.$strip>>;
|
|
662
|
+
winnersCount: z.ZodInt;
|
|
663
|
+
winningTile: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodNull]>>;
|
|
664
|
+
}, z.core.$strip>]>>;
|
|
665
|
+
address: z.ZodString;
|
|
666
|
+
currentSlot: z.ZodCoercedBigInt<unknown>;
|
|
667
|
+
endSlot: z.ZodCoercedBigInt<unknown>;
|
|
668
|
+
previousRound: z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
|
|
669
|
+
address: z.ZodString;
|
|
670
|
+
deployedBtcAmount: z.ZodCoercedBigInt<unknown>;
|
|
671
|
+
deployedPendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
672
|
+
deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
673
|
+
deployedUsdOnWinningTileAmount: z.ZodCoercedBigInt<unknown>;
|
|
674
|
+
id: z.ZodInt;
|
|
675
|
+
minersCount: z.ZodInt;
|
|
676
|
+
revealedMinersCount: z.ZodInt;
|
|
677
|
+
settledMinersCount: z.ZodInt;
|
|
678
|
+
state: z.ZodEnum<{
|
|
679
|
+
active: "active";
|
|
680
|
+
revealed: "revealed";
|
|
681
|
+
settled: "settled";
|
|
682
|
+
finished: "finished";
|
|
683
|
+
}>;
|
|
684
|
+
strikeBonusBtc: z.ZodCoercedBigInt<unknown>;
|
|
685
|
+
strikeBonusUsd: z.ZodCoercedBigInt<unknown>;
|
|
686
|
+
tileStakes: z.ZodArray<z.ZodObject<{
|
|
687
|
+
deployCount: z.ZodInt;
|
|
688
|
+
stake: z.ZodCoercedBigInt<unknown>;
|
|
689
|
+
}, z.core.$strip>>;
|
|
690
|
+
winnersCount: z.ZodInt;
|
|
691
|
+
winningTile: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodNull]>>;
|
|
692
|
+
}, z.core.$strip>]>>;
|
|
693
|
+
roundDuration: z.ZodInt;
|
|
694
|
+
roundId: z.ZodInt;
|
|
695
|
+
startSlot: z.ZodCoercedBigInt<unknown>;
|
|
696
|
+
strike: z.ZodObject<{
|
|
697
|
+
btcAmount: z.ZodCoercedBigInt<unknown>;
|
|
698
|
+
lastTriggerRoundId: z.ZodInt;
|
|
699
|
+
pendingUsdAmount: z.ZodCoercedBigInt<unknown>;
|
|
700
|
+
usdAmount: z.ZodCoercedBigInt<unknown>;
|
|
701
|
+
}, z.core.$strip>;
|
|
702
|
+
}, z.core.$strip>;
|
|
703
|
+
}, z.core.$strip>;
|
|
704
|
+
type GetBoardResponseZodType = z.infer<typeof zGetBoardResponse>;
|
|
705
|
+
|
|
706
|
+
type HasOnlyDataKey<T> = T extends object ? (Exclude<keyof T, "data"> extends never ? true : false) : false;
|
|
707
|
+
type UnwrapData<T> = T extends {
|
|
708
|
+
data: infer U;
|
|
709
|
+
} ? (HasOnlyDataKey<T> extends true ? U : T) : T;
|
|
710
|
+
type ExtractData<T> = T extends {
|
|
711
|
+
data: infer D;
|
|
712
|
+
error?: undefined;
|
|
713
|
+
} ? D : T extends {
|
|
714
|
+
data?: undefined;
|
|
715
|
+
error: unknown;
|
|
716
|
+
} ? never : T;
|
|
717
|
+
type UnwrapReturn<T> = UnwrapData<NonNullable<ExtractData<T>>>;
|
|
718
|
+
declare function unwrap<T>(promise: Promise<T>): Promise<UnwrapReturn<T>>;
|
|
719
|
+
|
|
720
|
+
declare class SatrushBackendSdkError<TCause = unknown> extends Error {
|
|
721
|
+
cause?: TCause;
|
|
722
|
+
status: number;
|
|
723
|
+
constructor(message: string, status: number, cause?: TCause);
|
|
724
|
+
}
|
|
725
|
+
declare const satrushSdkErrorInterceptor: (error: unknown, response?: Response) => SatrushBackendSdkError<unknown>;
|
|
726
|
+
declare const isSatrushSdkError: <TCause = unknown>(error: unknown) => error is SatrushBackendSdkError<TCause>;
|
|
727
|
+
|
|
728
|
+
export { type BoardDto, type ClientOptions, type GetBoardData, type GetBoardError, type GetBoardErrors, type GetBoardResponse, type GetBoardResponseZodType, type GetBoardResponses, type I128Dto, type I64Dto, type InternalErrorCodeErrorBody, type Options, type PubkeyDto, type RoundDto, RoundStateDto, SatrushBackendSdk, SatrushBackendSdkError, type ServerSentEventsOptions, type ServerSentEventsResult, type StreamEvent, type StrikeJackpotDto, type TileStakeDto, type U128Dto, type U64Dto, createClient, createSseClient, isSatrushSdkError, satrushSdkErrorInterceptor, unwrap, zBoardDto, zGetBoardData, zGetBoardResponse, zI128Dto, zI64Dto, zInternalErrorCodeErrorBody, zPubkeyDto, zRoundDto, zRoundStateDto, zStrikeJackpotDto, zTileStakeDto, zU128Dto, zU64Dto };
|