@satrush/api 0.1.0 → 0.1.1

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/dist/index.d.ts CHANGED
@@ -313,6 +313,9 @@ declare const createClient: (config?: Config) => Client;
313
313
  type ClientOptions = {
314
314
  baseUrl: `${string}://${string}/api` | (string & {});
315
315
  };
316
+ type BadRequestErrorCodeErrorBody = {
317
+ code: 'invalid_path' | 'invalid_query' | 'invalid_body';
318
+ };
316
319
  /**
317
320
  * Board state: the active round pointer, its mining window, the strike
318
321
  * jackpot, the live blockchain slot and the current round's details.
@@ -340,6 +343,16 @@ type BoardDto = {
340
343
  startSlot: U64Dto;
341
344
  strike: StrikeJackpotDto;
342
345
  };
346
+ type FieldError = {
347
+ /**
348
+ * Field name in request.
349
+ */
350
+ field: string;
351
+ /**
352
+ * Validation error message.
353
+ */
354
+ message: string;
355
+ };
343
356
  /**
344
357
  * Signed 128-bit integer encoded as a decimal string.
345
358
  */
@@ -351,6 +364,42 @@ type I64Dto = bigint;
351
364
  type InternalErrorCodeErrorBody = {
352
365
  code: 'internal_error';
353
366
  };
367
+ /**
368
+ * A miner's accumulated protocol state, keyed by its authority wallet.
369
+ */
370
+ type MinerDto = {
371
+ authority: PubkeyDto;
372
+ /**
373
+ * Number of consecutive rounds played.
374
+ */
375
+ currentStreakCount: number;
376
+ /**
377
+ * Accumulated hashrate points.
378
+ */
379
+ hashrateAmount: U64Dto;
380
+ /**
381
+ * Id of the last round the miner played.
382
+ */
383
+ lastMinedRoundId: number;
384
+ /**
385
+ * BTC shares in the Sats Vault not yet claimed.
386
+ */
387
+ unclaimedBtcShares: U64Dto;
388
+ /**
389
+ * USD rewards not yet claimed.
390
+ */
391
+ unclaimedUsdAmount: U64Dto;
392
+ };
393
+ /**
394
+ * A user's profile: their miner account and currently-open deployments.
395
+ */
396
+ type ProfileDto = {
397
+ /**
398
+ * The authority's open public deployments.
399
+ */
400
+ deployments: Array<PublicDeploymentDto>;
401
+ miner: MinerDto;
402
+ };
354
403
  /**
355
404
  * Pubkey represented as base58 string in JSON and OpenAPI.
356
405
  *
@@ -358,6 +407,24 @@ type InternalErrorCodeErrorBody = {
358
407
  * - OpenAPI: `type: string`, pattern for base58, optional format
359
408
  */
360
409
  type PubkeyDto = string;
410
+ /**
411
+ * A miner's deployment of USD onto a round's tiles.
412
+ */
413
+ type PublicDeploymentDto = {
414
+ address: PubkeyDto;
415
+ /**
416
+ * USD deployed after protocol fees.
417
+ */
418
+ deployedUsdAmount: U64Dto;
419
+ /**
420
+ * Round this deployment belongs to.
421
+ */
422
+ roundId: number;
423
+ /**
424
+ * 21-bit mask of the selected tiles.
425
+ */
426
+ selectionMask: number;
427
+ };
361
428
  /**
362
429
  * Core state of a mining round.
363
430
  */
@@ -391,6 +458,44 @@ declare const RoundStateDto: {
391
458
  * Lifecycle state of a round.
392
459
  */
393
460
  type RoundStateDto = typeof RoundStateDto[keyof typeof RoundStateDto];
461
+ /**
462
+ * Protocol configuration: token mints and fee rates.
463
+ */
464
+ type SatrushConfigDto = {
465
+ address: PubkeyDto;
466
+ /**
467
+ * BTC mint (initially cbBTC).
468
+ */
469
+ btcMint: PubkeyDto;
470
+ /**
471
+ * Epoch Vault fee in basis points.
472
+ */
473
+ epochFeeBps: number;
474
+ /**
475
+ * 1 BTC Vault fee in basis points.
476
+ */
477
+ oneBtcFeeBps: number;
478
+ /**
479
+ * Protocol fee in basis points.
480
+ */
481
+ protocolFeeBps: number;
482
+ /**
483
+ * Sats Vault claim fee in basis points.
484
+ */
485
+ satsVaultClaimFeeBps: number;
486
+ /**
487
+ * Sats Vault round fee in basis points.
488
+ */
489
+ satsVaultRoundFeeBps: number;
490
+ /**
491
+ * Strike jackpot fee in basis points.
492
+ */
493
+ strikeFeeBps: number;
494
+ /**
495
+ * USD mint (initially USDC).
496
+ */
497
+ usdMint: PubkeyDto;
498
+ };
394
499
  /**
395
500
  * Strike jackpot balances tracked on the board.
396
501
  */
@@ -427,6 +532,26 @@ type U128Dto = bigint;
427
532
  * Unsigned 64-bit integer encoded as a decimal string.
428
533
  */
429
534
  type U64Dto = bigint;
535
+ type UserProfileApiError400Error = ({
536
+ code: 'invalid_address';
537
+ } & UserProfileApiError400InvalidAddress) | ({
538
+ code: 'invalid_body' | 'invalid_path' | 'invalid_query';
539
+ } & BadRequestErrorCodeErrorBody);
540
+ type UserProfileApiError400InvalidAddress = {
541
+ code: 'invalid_address';
542
+ };
543
+ type ValidationErrorCodeErrorBody = {
544
+ code: 'validation_failed';
545
+ data?: {
546
+ errors: Array<FieldError>;
547
+ };
548
+ };
549
+ type ValidationErrorCodeValidationDetailsErrorBody = {
550
+ code: 'validation_failed';
551
+ data?: {
552
+ errors: Array<FieldError>;
553
+ };
554
+ };
430
555
  type GetBoardData = {
431
556
  body?: never;
432
557
  path?: never;
@@ -443,6 +568,45 @@ type GetBoardResponses = {
443
568
  };
444
569
  };
445
570
  type GetBoardResponse = GetBoardResponses[keyof GetBoardResponses];
571
+ type GetConfigData = {
572
+ body?: never;
573
+ path?: never;
574
+ query?: never;
575
+ url: '/v1/config';
576
+ };
577
+ type GetConfigErrors = {
578
+ 500: InternalErrorCodeErrorBody;
579
+ };
580
+ type GetConfigError = GetConfigErrors[keyof GetConfigErrors];
581
+ type GetConfigResponses = {
582
+ 200: {
583
+ data: SatrushConfigDto;
584
+ };
585
+ };
586
+ type GetConfigResponse = GetConfigResponses[keyof GetConfigResponses];
587
+ type GetUserProfileData = {
588
+ body?: never;
589
+ path: {
590
+ /**
591
+ * User wallet address (base58)
592
+ */
593
+ address: string;
594
+ };
595
+ query?: never;
596
+ url: '/v1/user/{address}/profile';
597
+ };
598
+ type GetUserProfileErrors = {
599
+ 400: UserProfileApiError400Error;
600
+ 422: ValidationErrorCodeErrorBody;
601
+ 500: InternalErrorCodeErrorBody;
602
+ };
603
+ type GetUserProfileError = GetUserProfileErrors[keyof GetUserProfileErrors];
604
+ type GetUserProfileResponses = {
605
+ 200: {
606
+ data: ProfileDto;
607
+ };
608
+ };
609
+ type GetUserProfileResponse = GetUserProfileResponses[keyof GetUserProfileResponses];
446
610
 
447
611
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options$1<TData, ThrowOnError> & {
448
612
  /**
@@ -479,8 +643,29 @@ declare class SatrushBackendSdk extends HeyApiClient {
479
643
  * Request board
480
644
  */
481
645
  getBoard<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>): RequestResult<GetBoardResponses, GetBoardErrors, ThrowOnError, "fields">;
646
+ /**
647
+ * Request config
648
+ */
649
+ getConfig<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>): RequestResult<GetConfigResponses, GetConfigErrors, ThrowOnError, "fields">;
650
+ /**
651
+ * Request user profile
652
+ */
653
+ getUserProfile<ThrowOnError extends boolean = false>(parameters: {
654
+ address: string;
655
+ }, options?: Options<never, ThrowOnError>): RequestResult<GetUserProfileResponses, GetUserProfileErrors, ThrowOnError, "fields">;
482
656
  }
483
657
 
658
+ declare const zBadRequestErrorCodeErrorBody: z.ZodObject<{
659
+ code: z.ZodEnum<{
660
+ invalid_path: "invalid_path";
661
+ invalid_query: "invalid_query";
662
+ invalid_body: "invalid_body";
663
+ }>;
664
+ }, z.core.$strip>;
665
+ declare const zFieldError: z.ZodObject<{
666
+ field: z.ZodString;
667
+ message: z.ZodString;
668
+ }, z.core.$strip>;
484
669
  /**
485
670
  * Signed 128-bit integer encoded as a decimal string.
486
671
  */
@@ -510,6 +695,20 @@ declare const zRoundStateDto: z.ZodEnum<{
510
695
  settled: "settled";
511
696
  finished: "finished";
512
697
  }>;
698
+ /**
699
+ * Protocol configuration: token mints and fee rates.
700
+ */
701
+ declare const zSatrushConfigDto: z.ZodObject<{
702
+ address: z.ZodString;
703
+ btcMint: z.ZodString;
704
+ epochFeeBps: z.ZodInt;
705
+ oneBtcFeeBps: z.ZodInt;
706
+ protocolFeeBps: z.ZodInt;
707
+ satsVaultClaimFeeBps: z.ZodInt;
708
+ satsVaultRoundFeeBps: z.ZodInt;
709
+ strikeFeeBps: z.ZodInt;
710
+ usdMint: z.ZodString;
711
+ }, z.core.$strip>;
513
712
  /**
514
713
  * Unsigned 128-bit integer encoded as a decimal string.
515
714
  */
@@ -518,6 +717,45 @@ declare const zU128Dto: z.ZodString;
518
717
  * Unsigned 64-bit integer encoded as a decimal string.
519
718
  */
520
719
  declare const zU64Dto: z.ZodCoercedBigInt<unknown>;
720
+ /**
721
+ * A miner's accumulated protocol state, keyed by its authority wallet.
722
+ */
723
+ declare const zMinerDto: z.ZodObject<{
724
+ authority: z.ZodString;
725
+ currentStreakCount: z.ZodInt;
726
+ hashrateAmount: z.ZodCoercedBigInt<unknown>;
727
+ lastMinedRoundId: z.ZodInt;
728
+ unclaimedBtcShares: z.ZodCoercedBigInt<unknown>;
729
+ unclaimedUsdAmount: z.ZodCoercedBigInt<unknown>;
730
+ }, z.core.$strip>;
731
+ /**
732
+ * A miner's deployment of USD onto a round's tiles.
733
+ */
734
+ declare const zPublicDeploymentDto: z.ZodObject<{
735
+ address: z.ZodString;
736
+ deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
737
+ roundId: z.ZodInt;
738
+ selectionMask: z.ZodInt;
739
+ }, z.core.$strip>;
740
+ /**
741
+ * A user's profile: their miner account and currently-open deployments.
742
+ */
743
+ declare const zProfileDto: z.ZodObject<{
744
+ deployments: z.ZodArray<z.ZodObject<{
745
+ address: z.ZodString;
746
+ deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
747
+ roundId: z.ZodInt;
748
+ selectionMask: z.ZodInt;
749
+ }, z.core.$strip>>;
750
+ miner: z.ZodObject<{
751
+ authority: z.ZodString;
752
+ currentStreakCount: z.ZodInt;
753
+ hashrateAmount: z.ZodCoercedBigInt<unknown>;
754
+ lastMinedRoundId: z.ZodInt;
755
+ unclaimedBtcShares: z.ZodCoercedBigInt<unknown>;
756
+ unclaimedUsdAmount: z.ZodCoercedBigInt<unknown>;
757
+ }, z.core.$strip>;
758
+ }, z.core.$strip>;
521
759
  /**
522
760
  * Strike jackpot balances tracked on the board.
523
761
  */
@@ -630,6 +868,48 @@ declare const zBoardDto: z.ZodObject<{
630
868
  usdAmount: z.ZodCoercedBigInt<unknown>;
631
869
  }, z.core.$strip>;
632
870
  }, z.core.$strip>;
871
+ declare const zUserProfileApiError400InvalidAddress: z.ZodObject<{
872
+ code: z.ZodEnum<{
873
+ invalid_address: "invalid_address";
874
+ }>;
875
+ }, z.core.$strip>;
876
+ declare const zUserProfileApiError400Error: z.ZodUnion<readonly [z.ZodIntersection<z.ZodObject<{
877
+ code: z.ZodLiteral<"invalid_address">;
878
+ }, z.core.$strip>, z.ZodObject<{
879
+ code: z.ZodEnum<{
880
+ invalid_address: "invalid_address";
881
+ }>;
882
+ }, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
883
+ code: z.ZodUnion<readonly [z.ZodLiteral<"invalid_body">, z.ZodLiteral<"invalid_path">, z.ZodLiteral<"invalid_query">]>;
884
+ }, z.core.$strip>, z.ZodObject<{
885
+ code: z.ZodEnum<{
886
+ invalid_path: "invalid_path";
887
+ invalid_query: "invalid_query";
888
+ invalid_body: "invalid_body";
889
+ }>;
890
+ }, z.core.$strip>>]>;
891
+ declare const zValidationErrorCodeErrorBody: z.ZodObject<{
892
+ code: z.ZodEnum<{
893
+ validation_failed: "validation_failed";
894
+ }>;
895
+ data: z.ZodOptional<z.ZodObject<{
896
+ errors: z.ZodArray<z.ZodObject<{
897
+ field: z.ZodString;
898
+ message: z.ZodString;
899
+ }, z.core.$strip>>;
900
+ }, z.core.$strip>>;
901
+ }, z.core.$strip>;
902
+ declare const zValidationErrorCodeValidationDetailsErrorBody: z.ZodObject<{
903
+ code: z.ZodEnum<{
904
+ validation_failed: "validation_failed";
905
+ }>;
906
+ data: z.ZodOptional<z.ZodObject<{
907
+ errors: z.ZodArray<z.ZodObject<{
908
+ field: z.ZodString;
909
+ message: z.ZodString;
910
+ }, z.core.$strip>>;
911
+ }, z.core.$strip>>;
912
+ }, z.core.$strip>;
633
913
  declare const zGetBoardData: z.ZodObject<{
634
914
  body: z.ZodOptional<z.ZodNever>;
635
915
  path: z.ZodOptional<z.ZodNever>;
@@ -702,11 +982,56 @@ declare const zGetBoardResponse: z.ZodObject<{
702
982
  }, z.core.$strip>;
703
983
  }, z.core.$strip>;
704
984
  type GetBoardResponseZodType = z.infer<typeof zGetBoardResponse>;
985
+ declare const zGetConfigData: z.ZodObject<{
986
+ body: z.ZodOptional<z.ZodNever>;
987
+ path: z.ZodOptional<z.ZodNever>;
988
+ query: z.ZodOptional<z.ZodNever>;
989
+ }, z.core.$strip>;
990
+ declare const zGetConfigResponse: z.ZodObject<{
991
+ data: z.ZodObject<{
992
+ address: z.ZodString;
993
+ btcMint: z.ZodString;
994
+ epochFeeBps: z.ZodInt;
995
+ oneBtcFeeBps: z.ZodInt;
996
+ protocolFeeBps: z.ZodInt;
997
+ satsVaultClaimFeeBps: z.ZodInt;
998
+ satsVaultRoundFeeBps: z.ZodInt;
999
+ strikeFeeBps: z.ZodInt;
1000
+ usdMint: z.ZodString;
1001
+ }, z.core.$strip>;
1002
+ }, z.core.$strip>;
1003
+ type GetConfigResponseZodType = z.infer<typeof zGetConfigResponse>;
1004
+ declare const zGetUserProfileData: z.ZodObject<{
1005
+ body: z.ZodOptional<z.ZodNever>;
1006
+ path: z.ZodObject<{
1007
+ address: z.ZodString;
1008
+ }, z.core.$strip>;
1009
+ query: z.ZodOptional<z.ZodNever>;
1010
+ }, z.core.$strip>;
1011
+ declare const zGetUserProfileResponse: z.ZodObject<{
1012
+ data: z.ZodObject<{
1013
+ deployments: z.ZodArray<z.ZodObject<{
1014
+ address: z.ZodString;
1015
+ deployedUsdAmount: z.ZodCoercedBigInt<unknown>;
1016
+ roundId: z.ZodInt;
1017
+ selectionMask: z.ZodInt;
1018
+ }, z.core.$strip>>;
1019
+ miner: z.ZodObject<{
1020
+ authority: z.ZodString;
1021
+ currentStreakCount: z.ZodInt;
1022
+ hashrateAmount: z.ZodCoercedBigInt<unknown>;
1023
+ lastMinedRoundId: z.ZodInt;
1024
+ unclaimedBtcShares: z.ZodCoercedBigInt<unknown>;
1025
+ unclaimedUsdAmount: z.ZodCoercedBigInt<unknown>;
1026
+ }, z.core.$strip>;
1027
+ }, z.core.$strip>;
1028
+ }, z.core.$strip>;
1029
+ type GetUserProfileResponseZodType = z.infer<typeof zGetUserProfileResponse>;
705
1030
 
706
- type HasOnlyDataKey<T> = T extends object ? (Exclude<keyof T, "data"> extends never ? true : false) : false;
1031
+ type HasOnlyDataKey<T> = T extends object ? Exclude<keyof T, 'data'> extends never ? true : false : false;
707
1032
  type UnwrapData<T> = T extends {
708
1033
  data: infer U;
709
- } ? (HasOnlyDataKey<T> extends true ? U : T) : T;
1034
+ } ? HasOnlyDataKey<T> extends true ? U : T : T;
710
1035
  type ExtractData<T> = T extends {
711
1036
  data: infer D;
712
1037
  error?: undefined;
@@ -725,4 +1050,4 @@ declare class SatrushBackendSdkError<TCause = unknown> extends Error {
725
1050
  declare const satrushSdkErrorInterceptor: (error: unknown, response?: Response) => SatrushBackendSdkError<unknown>;
726
1051
  declare const isSatrushSdkError: <TCause = unknown>(error: unknown) => error is SatrushBackendSdkError<TCause>;
727
1052
 
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 };
1053
+ export { type BadRequestErrorCodeErrorBody, type BoardDto, type ClientOptions, type FieldError, type GetBoardData, type GetBoardError, type GetBoardErrors, type GetBoardResponse, type GetBoardResponseZodType, type GetBoardResponses, type GetConfigData, type GetConfigError, type GetConfigErrors, type GetConfigResponse, type GetConfigResponseZodType, type GetConfigResponses, type GetUserProfileData, type GetUserProfileError, type GetUserProfileErrors, type GetUserProfileResponse, type GetUserProfileResponseZodType, type GetUserProfileResponses, type I128Dto, type I64Dto, type InternalErrorCodeErrorBody, type MinerDto, type Options, type ProfileDto, type PubkeyDto, type PublicDeploymentDto, type RoundDto, RoundStateDto, SatrushBackendSdk, SatrushBackendSdkError, type SatrushConfigDto, type ServerSentEventsOptions, type ServerSentEventsResult, type StreamEvent, type StrikeJackpotDto, type TileStakeDto, type U128Dto, type U64Dto, type UserProfileApiError400Error, type UserProfileApiError400InvalidAddress, type ValidationErrorCodeErrorBody, type ValidationErrorCodeValidationDetailsErrorBody, createClient, createSseClient, isSatrushSdkError, satrushSdkErrorInterceptor, unwrap, zBadRequestErrorCodeErrorBody, zBoardDto, zFieldError, zGetBoardData, zGetBoardResponse, zGetConfigData, zGetConfigResponse, zGetUserProfileData, zGetUserProfileResponse, zI128Dto, zI64Dto, zInternalErrorCodeErrorBody, zMinerDto, zProfileDto, zPubkeyDto, zPublicDeploymentDto, zRoundDto, zRoundStateDto, zSatrushConfigDto, zStrikeJackpotDto, zTileStakeDto, zU128Dto, zU64Dto, zUserProfileApiError400Error, zUserProfileApiError400InvalidAddress, zValidationErrorCodeErrorBody, zValidationErrorCodeValidationDetailsErrorBody };