@helium/blockchain-api 0.2.0 → 0.2.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.
Files changed (4) hide show
  1. package/README.md +4 -15
  2. package/dist/index.d.ts +2239 -1166
  3. package/dist/index.js +324 -371
  4. package/package.json +5 -13
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createORPCClient } from '@orpc/client';
2
2
  import { RPCLink } from '@orpc/client/fetch';
3
3
  import { z } from 'zod';
4
+ import { oc } from '@orpc/contract';
4
5
 
5
6
  // src/client.ts
6
7
  function createClient(options) {
@@ -63,18 +64,6 @@ function createMockClient(mocks = {}) {
63
64
  };
64
65
  return createProxy();
65
66
  }
66
- var HealthResponseSchema = z.object({
67
- ok: z.boolean(),
68
- error: z.string().optional()
69
- });
70
-
71
- // src/contracts/health.ts
72
- var healthContract = {
73
- check: {
74
- route: { method: "GET", path: "/health" },
75
- output: HealthResponseSchema
76
- }
77
- };
78
67
  var TransactionMetadataSchema = z.object({
79
68
  type: z.string(),
80
69
  description: z.string()
@@ -112,8 +101,10 @@ var PaginationOutputSchema = z.object({
112
101
  page: z.number(),
113
102
  totalPages: z.number()
114
103
  });
115
-
116
- // src/schemas/tokens.ts
104
+ var HealthResponseSchema = z.object({
105
+ ok: z.boolean(),
106
+ error: z.string().optional()
107
+ });
117
108
  var GetBalancesInputSchema = z.object({
118
109
  walletAddress: z.string().min(32)
119
110
  });
@@ -151,35 +142,6 @@ var TransferOutputSchema = z.object({
151
142
  var CreateHntAccountOutputSchema = z.object({
152
143
  transactionData: TransactionDataSchema
153
144
  });
154
-
155
- // src/contracts/tokens.ts
156
- var tokensContract = {
157
- getBalances: {
158
- route: { method: "GET", path: "/tokens/{walletAddress}" },
159
- input: GetBalancesInputSchema,
160
- output: TokenBalanceDataSchema,
161
- errors: {
162
- BAD_REQUEST: { message: "Wallet address is required" }
163
- }
164
- },
165
- transfer: {
166
- route: { method: "POST", path: "/tokens/transfer" },
167
- input: TransferInputSchema,
168
- output: TransferOutputSchema,
169
- errors: {
170
- BAD_REQUEST: { message: "Invalid transfer parameters" },
171
- INSUFFICIENT_FUNDS: { message: "Insufficient balance for transfer" }
172
- }
173
- },
174
- createHntAccount: {
175
- route: { method: "POST", path: "/tokens/hnt-account" },
176
- input: CreateHntAccountInputSchema,
177
- output: CreateHntAccountOutputSchema,
178
- errors: {
179
- BAD_REQUEST: { message: "Invalid wallet address" }
180
- }
181
- }
182
- };
183
145
  var HotspotTypeSchema = z.enum(["iot", "mobile", "all"]);
184
146
  var DeviceTypeSchema = z.enum([
185
147
  "iot-gateway",
@@ -294,133 +256,6 @@ var DeleteSplitOutputSchema = z.object({
294
256
  var PendingRewardsOutputSchema = z.object({
295
257
  pending: z.string()
296
258
  });
297
- var UNAUTHORIZED = {
298
- status: 401,
299
- message: "Authentication required. Please sign in to continue."
300
- };
301
- var FORBIDDEN = {
302
- status: 403,
303
- message: "You do not have permission to access this resource."
304
- };
305
- var NOT_FOUND = {
306
- status: 404,
307
- message: "The requested resource was not found."
308
- };
309
- var VALIDATION_ERROR = {
310
- status: 400,
311
- message: "Invalid input data provided.",
312
- data: z.object({
313
- fields: z.array(z.string()).optional()
314
- })
315
- };
316
- var RATE_LIMITED = {
317
- status: 429,
318
- message: "Too many requests. Please try again later."
319
- };
320
- var CONFLICT = {
321
- status: 409,
322
- message: "A resource with this identifier already exists.",
323
- data: z.object({
324
- existingId: z.string().optional()
325
- })
326
- };
327
- var commonErrors = {
328
- UNAUTHORIZED,
329
- FORBIDDEN,
330
- NOT_FOUND,
331
- VALIDATION_ERROR
332
- };
333
-
334
- // src/errors/hotspot.ts
335
- var NOT_OWNER = {
336
- status: 403,
337
- message: "You do not own this asset.",
338
- data: z.object({
339
- owner: z.string(),
340
- wallet: z.string()
341
- })
342
- };
343
- var INVALID_HOTSPOT = {
344
- status: 400,
345
- message: "The specified asset is not a valid Helium hotspot."
346
- };
347
- var hotspotErrors = {
348
- NOT_OWNER,
349
- INVALID_HOTSPOT,
350
- NOT_FOUND
351
- };
352
-
353
- // src/contracts/hotspots.ts
354
- var hotspotsContract = {
355
- getHotspots: {
356
- route: { method: "GET", path: "/hotspots/wallet/{walletAddress}" },
357
- input: GetHotspotsInputSchema,
358
- output: HotspotsDataSchema,
359
- errors: {
360
- BAD_REQUEST: { message: "Invalid wallet address" }
361
- }
362
- },
363
- claimRewards: {
364
- route: { method: "POST", path: "/hotspots/claim-rewards" },
365
- input: ClaimRewardsInputSchema,
366
- output: ClaimRewardsOutputSchema,
367
- errors: {
368
- BAD_REQUEST: { message: "Invalid wallet address" },
369
- NO_REWARDS: { message: "No rewards to claim" }
370
- }
371
- },
372
- getPendingRewards: {
373
- route: { method: "GET", path: "/hotspots/pending-rewards/{walletAddress}" },
374
- input: GetPendingRewardsInputSchema,
375
- output: PendingRewardsOutputSchema,
376
- errors: {
377
- BAD_REQUEST: { message: "Invalid wallet address" }
378
- }
379
- },
380
- transferHotspot: {
381
- route: { method: "POST", path: "/hotspots/transfer" },
382
- input: TransferHotspotInputSchema,
383
- output: TransferHotspotOutputSchema,
384
- errors: {
385
- ...hotspotErrors,
386
- BAD_REQUEST: { message: "Invalid transfer parameters" }
387
- }
388
- },
389
- updateRewardsDestination: {
390
- route: { method: "POST", path: "/hotspots/update-rewards-destination" },
391
- input: UpdateRewardsDestinationInputSchema,
392
- output: UpdateRewardsDestinationOutputSchema,
393
- errors: {
394
- ...hotspotErrors,
395
- BAD_REQUEST: { message: "Invalid parameters" }
396
- }
397
- },
398
- getSplit: {
399
- route: { method: "GET", path: "/hotspots/split/{walletAddress}/{hotspotPubkey}" },
400
- input: GetSplitInputSchema,
401
- output: SplitResponseSchema,
402
- errors: {
403
- NOT_FOUND: { message: "Split not found" }
404
- }
405
- },
406
- createSplit: {
407
- route: { method: "POST", path: "/hotspots/split" },
408
- input: CreateSplitInputSchema,
409
- output: CreateSplitOutputSchema,
410
- errors: {
411
- ...hotspotErrors,
412
- BAD_REQUEST: { message: "Invalid split configuration" }
413
- }
414
- },
415
- deleteSplit: {
416
- route: { method: "DELETE", path: "/hotspots/split" },
417
- input: DeleteSplitInputSchema,
418
- output: DeleteSplitOutputSchema,
419
- errors: {
420
- ...hotspotErrors
421
- }
422
- }
423
- };
424
259
  var GetTokensInputSchema = z.object({
425
260
  limit: z.coerce.number().int().min(1).max(100).default(50)
426
261
  });
@@ -498,19 +333,31 @@ var SubmitOutputSchema = z.object({
498
333
  batchId: z.string(),
499
334
  message: z.string().optional()
500
335
  });
336
+ var TransactionStateSchema = z.union([
337
+ z.literal("pending"),
338
+ z.literal("confirmed"),
339
+ z.literal("failed"),
340
+ z.literal("expired"),
341
+ z.literal("partial")
342
+ ]);
501
343
  var TransactionStatusSchema = z.object({
502
344
  signature: z.string(),
503
- status: z.string(),
345
+ status: TransactionStateSchema,
504
346
  transaction: z.unknown().optional()
505
347
  });
506
348
  var BatchStatusOutputSchema = z.object({
507
349
  batchId: z.string(),
508
- status: z.string(),
509
- submissionType: z.string(),
350
+ status: TransactionStateSchema,
351
+ submissionType: z.union([
352
+ z.literal("single"),
353
+ z.literal("parallel"),
354
+ z.literal("sequential"),
355
+ z.literal("jito_bundle")
356
+ ]),
510
357
  parallel: z.boolean(),
511
358
  transactions: z.array(TransactionStatusSchema),
512
- jitoBundleId: z.string().optional(),
513
- jitoBundleStatus: z.unknown().optional()
359
+ jitoBundleId: z.string().optional().nullable(),
360
+ jitoBundleStatus: z.unknown().optional().nullable()
514
361
  });
515
362
  var ResubmitOutputSchema = z.object({
516
363
  success: z.boolean(),
@@ -609,33 +456,32 @@ var WelcomePackInviteOutputSchema = z.object({
609
456
  message: z.string(),
610
457
  expirationTs: z.number()
611
458
  });
612
-
613
- // src/contracts/swap.ts
614
- var swapContract = {
615
- getTokens: {
616
- route: { method: "GET", path: "/swap/tokens" },
617
- input: GetTokensInputSchema,
618
- output: TokenListOutputSchema,
619
- errors: {}
620
- },
621
- getQuote: {
622
- route: { method: "GET", path: "/swap/quote" },
623
- input: GetQuoteInputSchema,
624
- output: QuoteResponseSchema,
625
- errors: {
626
- BAD_REQUEST: { message: "Invalid quote parameters" },
627
- EXTERNAL_API_ERROR: { message: "Jupiter API request failed" }
628
- }
629
- },
630
- getInstructions: {
631
- route: { method: "POST", path: "/swap/instructions" },
632
- input: GetInstructionsInputSchema,
633
- output: TransactionDataSchema,
634
- errors: {
635
- BAD_REQUEST: { message: "Invalid instruction parameters" },
636
- EXTERNAL_API_ERROR: { message: "Jupiter API request failed" }
637
- }
638
- }
459
+ var UNAUTHENTICATED = {
460
+ status: 401,
461
+ message: "Authentication required. Please sign in to continue."
462
+ };
463
+ var UNAUTHORIZED = {
464
+ status: 403,
465
+ message: "You do not have permission to access this resource."
466
+ };
467
+ var NOT_FOUND = {
468
+ status: 404,
469
+ message: "The requested resource was not found."
470
+ };
471
+ var BAD_REQUEST = {
472
+ status: 400,
473
+ message: "Invalid input data provided.",
474
+ data: z.object({
475
+ fields: z.array(z.string()).optional()
476
+ }).optional()
477
+ };
478
+ var RATE_LIMITED = {
479
+ status: 429,
480
+ message: "Too many requests. Please try again later."
481
+ };
482
+ var CONFLICT = {
483
+ status: 409,
484
+ message: "A resource with this identifier already exists."
639
485
  };
640
486
  var INSUFFICIENT_FUNDS = {
641
487
  status: 400,
@@ -661,121 +507,284 @@ var SIMULATION_FAILED = {
661
507
  link: z.string().optional()
662
508
  })
663
509
  };
664
- var solanaErrors = {
665
- INSUFFICIENT_FUNDS,
666
- TRANSACTION_FAILED,
667
- SIMULATION_FAILED
510
+ var protectedOc = oc.errors({
511
+ UNAUTHENTICATED,
512
+ UNAUTHORIZED
513
+ });
514
+ var publicOc = oc.errors({
515
+ INVALID_WALLET_ADDRESS: { message: "Invalid wallet address", status: 400 }
516
+ });
517
+
518
+ // src/contracts/health.ts
519
+ var healthContract = {
520
+ check: publicOc.route({ method: "GET", path: "/health", tags: ["Health"], summary: "Health check" }).output(HealthResponseSchema)
521
+ };
522
+
523
+ // src/contracts/tokens.ts
524
+ var tokensContract = {
525
+ /** Public: Get token balances for a wallet */
526
+ getBalances: publicOc.route({ method: "GET", path: "/tokens/{walletAddress}", tags: ["Tokens"], summary: "Get token balances for a wallet" }).input(GetBalancesInputSchema).output(TokenBalanceDataSchema).errors({}),
527
+ /** Protected: Transfer tokens */
528
+ transfer: publicOc.route({ method: "POST", path: "/tokens/transfer", tags: ["Tokens"], summary: "Transfer tokens" }).input(TransferInputSchema).output(TransferOutputSchema).errors({
529
+ BAD_REQUEST,
530
+ INSUFFICIENT_FUNDS
531
+ }),
532
+ /** Protected: Create HNT account */
533
+ createHntAccount: publicOc.route({ method: "POST", path: "/tokens/hnt-account", tags: ["Tokens"], summary: "Create HNT account" }).input(CreateHntAccountInputSchema).output(CreateHntAccountOutputSchema).errors({})
534
+ };
535
+
536
+ // src/contracts/hotspots.ts
537
+ var hotspotsContract = {
538
+ /** Public: Get hotspots for a wallet */
539
+ getHotspots: publicOc.route({ method: "GET", path: "/hotspots/wallet/{walletAddress}", tags: ["Hotspots"], summary: "Get hotspots for a wallet" }).input(GetHotspotsInputSchema).output(HotspotsDataSchema).errors({}),
540
+ /** Protected: Claim rewards for hotspots */
541
+ claimRewards: publicOc.route({ method: "POST", path: "/hotspots/claim-rewards", tags: ["Hotspots"], summary: "Claim all hotspot rewards" }).input(ClaimRewardsInputSchema).output(ClaimRewardsOutputSchema).errors({
542
+ INSUFFICIENT_FUNDS
543
+ }),
544
+ /** Public: Get pending rewards for a wallet */
545
+ getPendingRewards: publicOc.route({ method: "GET", path: "/hotspots/pending-rewards/{walletAddress}", tags: ["Hotspots"], summary: "Get pending rewards" }).input(GetPendingRewardsInputSchema).output(PendingRewardsOutputSchema).errors({
546
+ BAD_REQUEST: { message: "Invalid wallet address", status: 400 }
547
+ }),
548
+ /** Protected: Transfer hotspot ownership */
549
+ transferHotspot: publicOc.route({ method: "POST", path: "/hotspots/transfer", tags: ["Hotspots"], summary: "Transfer ownership" }).input(TransferHotspotInputSchema).output(TransferHotspotOutputSchema).errors({
550
+ UNAUTHORIZED,
551
+ NOT_FOUND,
552
+ BAD_REQUEST: { message: "Invalid transfer parameters", status: 400 }
553
+ }),
554
+ /** Protected: Update rewards destination */
555
+ updateRewardsDestination: publicOc.route({ method: "POST", path: "/hotspots/update-rewards-destination", tags: ["Hotspots"], summary: "Update rewards destination" }).input(UpdateRewardsDestinationInputSchema).output(UpdateRewardsDestinationOutputSchema).errors({
556
+ BAD_REQUEST: { message: "Invalid parameters", status: 400 },
557
+ NOT_FOUND
558
+ }),
559
+ /** Public: Get split configuration for a hotspot */
560
+ getSplit: publicOc.route({ method: "GET", path: "/hotspots/split/{walletAddress}/{hotspotPubkey}", tags: ["Hotspots"], summary: "Get reward split" }).input(GetSplitInputSchema).output(SplitResponseSchema).errors({
561
+ NOT_FOUND: { message: "Split not found", status: 404 }
562
+ }),
563
+ /** Protected: Create a split configuration */
564
+ createSplit: publicOc.route({ method: "POST", path: "/hotspots/split", tags: ["Hotspots"], summary: "Create a reward split" }).input(CreateSplitInputSchema).output(CreateSplitOutputSchema).errors({
565
+ NOT_FOUND,
566
+ BAD_REQUEST: { message: "Invalid split configuration", status: 400 },
567
+ INSUFFICIENT_FUNDS
568
+ }),
569
+ /** Protected: Delete a split configuration */
570
+ deleteSplit: publicOc.route({ method: "DELETE", path: "/hotspots/split", tags: ["Hotspots"], summary: "Delete a reward split" }).input(DeleteSplitInputSchema).output(DeleteSplitOutputSchema).errors({
571
+ NOT_FOUND
572
+ })
573
+ };
574
+
575
+ // src/contracts/swap.ts
576
+ var swapContract = {
577
+ getTokens: publicOc.route({ method: "GET", path: "/swap/tokens", tags: ["Swap"] }).input(GetTokensInputSchema).output(TokenListOutputSchema).errors({
578
+ JUPITER_ERROR: { message: "Failed to fetch tokens from Jupiter" }
579
+ }),
580
+ getQuote: publicOc.route({ method: "GET", path: "/swap/quote", tags: ["Swap"] }).input(GetQuoteInputSchema).output(QuoteResponseSchema).errors({
581
+ BAD_REQUEST: { message: "Invalid quote parameters", status: 400 },
582
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter" }
583
+ }),
584
+ getInstructions: publicOc.route({ method: "POST", path: "/swap/instructions", tags: ["Swap"] }).input(GetInstructionsInputSchema).output(TransactionDataSchema).errors({
585
+ BAD_REQUEST: { message: "Invalid instruction parameters", status: 400 },
586
+ JUPITER_ERROR: { message: "Failed to get swap instructions from Jupiter" }
587
+ })
668
588
  };
669
589
 
670
590
  // src/contracts/transactions.ts
671
591
  var transactionsContract = {
672
- submit: {
673
- route: { method: "POST", path: "/transactions" },
674
- input: SubmitInputSchema,
675
- output: SubmitOutputSchema,
676
- errors: {
677
- BAD_REQUEST: { message: "Invalid transaction data" },
678
- ...solanaErrors
679
- }
680
- },
681
- get: {
682
- route: { method: "GET", path: "/transactions/{id}" },
683
- input: GetInputSchema,
684
- output: BatchStatusOutputSchema,
685
- errors: {
686
- NOT_FOUND: { message: "Transaction batch not found" }
687
- }
688
- },
689
- resubmit: {
690
- route: { method: "POST", path: "/transactions/{id}/resubmit" },
691
- input: ResubmitInputSchema,
692
- output: ResubmitOutputSchema,
693
- errors: {
694
- NOT_FOUND: { message: "Transaction batch not found" },
695
- BAD_REQUEST: { message: "Cannot resubmit this transaction" }
696
- }
697
- },
698
- getByPayer: {
699
- route: { method: "GET", path: "/transactions/payer/{payer}" },
700
- input: GetByPayerInputSchema,
701
- output: PayerBatchesOutputSchema,
702
- errors: {
703
- BAD_REQUEST: { message: "Invalid payer address" }
704
- }
705
- },
706
- getByPayerAndTag: {
707
- route: { method: "GET", path: "/transactions/payer/{payer}/tag/{tag}" },
708
- input: GetByPayerAndTagInputSchema,
709
- output: PayerBatchesOutputSchema,
710
- errors: {
711
- BAD_REQUEST: { message: "Invalid parameters" }
712
- }
713
- }
592
+ submit: publicOc.route({ method: "POST", path: "/transactions", tags: ["Transactions"], summary: "Submit a transaction" }).input(SubmitInputSchema).output(SubmitOutputSchema).errors({
593
+ BAD_REQUEST,
594
+ CONFLICT,
595
+ SIMULATION_FAILED
596
+ }),
597
+ get: publicOc.route({ method: "GET", path: "/transactions/{id}", tags: ["Transactions"], summary: "Get transaction status" }).input(GetInputSchema).output(BatchStatusOutputSchema).errors({
598
+ NOT_FOUND
599
+ }),
600
+ resubmit: publicOc.route({ method: "POST", path: "/transactions/{id}/resubmit", tags: ["Transactions"], summary: "Resubmit a transaction" }).input(ResubmitInputSchema).output(ResubmitOutputSchema).errors({
601
+ NOT_FOUND,
602
+ BAD_REQUEST
603
+ }),
604
+ getByPayer: publicOc.route({ method: "GET", path: "/transactions/payer/{payer}", tags: ["Transactions"], summary: "Get transactions by payer" }).input(GetByPayerInputSchema).output(PayerBatchesOutputSchema).errors({
605
+ BAD_REQUEST
606
+ }),
607
+ getByPayerAndTag: publicOc.route({ method: "GET", path: "/transactions/payer/{payer}/tag/{tag}", tags: ["Transactions"], summary: "Get transactions by payer and tag" }).input(GetByPayerAndTagInputSchema).output(PayerBatchesOutputSchema).errors({
608
+ BAD_REQUEST
609
+ })
714
610
  };
715
611
 
716
612
  // src/contracts/welcome-packs.ts
717
613
  var welcomePacksContract = {
718
- list: {
719
- route: { method: "GET", path: "/welcome-packs/{walletAddress}" },
720
- input: WelcomePackListInputSchema,
721
- output: WelcomePackListOutputSchema,
722
- errors: {
723
- BAD_REQUEST: { message: "Invalid wallet address" }
724
- }
725
- },
726
- create: {
727
- route: { method: "POST", path: "/welcome-packs" },
728
- input: WelcomePackCreateInputSchema,
729
- output: WelcomePackCreateOutputSchema,
730
- errors: {
731
- ...commonErrors,
732
- BAD_REQUEST: { message: "Invalid welcome pack configuration" }
733
- }
734
- },
735
- get: {
736
- route: { method: "GET", path: "/welcome-packs/{walletAddress}/{packId}" },
737
- input: WelcomePackGetInputSchema,
738
- output: WelcomePackSchema,
739
- errors: {
740
- NOT_FOUND: { message: "Welcome pack not found" }
741
- }
742
- },
743
- delete: {
744
- route: { method: "DELETE", path: "/welcome-packs/{walletAddress}/{packId}" },
745
- input: WelcomePackDeleteInputSchema,
746
- output: WelcomePackDeleteOutputSchema,
747
- errors: {
748
- ...commonErrors,
749
- NOT_FOUND: { message: "Welcome pack not found" }
750
- }
751
- },
752
- getByAddress: {
753
- route: { method: "GET", path: "/welcome-packs/address/{packAddress}" },
754
- input: WelcomePackGetByAddressInputSchema,
755
- output: WelcomePackSchema,
756
- errors: {
757
- NOT_FOUND: { message: "Welcome pack not found" }
758
- }
759
- },
760
- claim: {
761
- route: { method: "POST", path: "/welcome-packs/claim" },
762
- input: WelcomePackClaimInputSchema,
763
- output: WelcomePackClaimOutputSchema,
764
- errors: {
765
- ...commonErrors,
766
- BAD_REQUEST: { message: "Invalid claim parameters" },
767
- EXPIRED: { message: "Claim link has expired" }
768
- }
769
- },
770
- invite: {
771
- route: { method: "POST", path: "/welcome-packs/invite" },
772
- input: WelcomePackInviteInputSchema,
773
- output: WelcomePackInviteOutputSchema,
774
- errors: {
775
- ...commonErrors,
776
- NOT_FOUND: { message: "Welcome pack not found" }
777
- }
778
- }
614
+ /** Public: List welcome packs for a wallet */
615
+ list: publicOc.route({ method: "GET", path: "/welcome-packs/{walletAddress}", tags: ["Welcome Packs"], summary: "List welcome packs for a wallet" }).input(WelcomePackListInputSchema).output(WelcomePackListOutputSchema).errors({}),
616
+ /** Protected: Create a new welcome pack */
617
+ create: publicOc.route({ method: "POST", path: "/welcome-packs", tags: ["Welcome Packs"], summary: "Create a new welcome pack" }).input(WelcomePackCreateInputSchema).output(WelcomePackCreateOutputSchema).errors({
618
+ BAD_REQUEST
619
+ }),
620
+ /** Public: Get a specific welcome pack */
621
+ get: publicOc.route({ method: "GET", path: "/welcome-packs/{walletAddress}/{packId}", tags: ["Welcome Packs"], summary: "Get a specific welcome pack" }).input(WelcomePackGetInputSchema).output(WelcomePackSchema).errors({
622
+ NOT_FOUND
623
+ }),
624
+ /** Protected: Delete a welcome pack */
625
+ delete: publicOc.route({ method: "DELETE", path: "/welcome-packs/{walletAddress}/{packId}", tags: ["Welcome Packs"], summary: "Delete a welcome pack" }).input(WelcomePackDeleteInputSchema).output(WelcomePackDeleteOutputSchema).errors({
626
+ BAD_REQUEST
627
+ }),
628
+ /** Public: Get welcome pack by pack address */
629
+ getByAddress: publicOc.route({ method: "GET", path: "/welcome-packs/address/{packAddress}", tags: ["Welcome Packs"], summary: "Get welcome pack by pack address" }).input(WelcomePackGetByAddressInputSchema).output(WelcomePackSchema).errors({
630
+ NOT_FOUND
631
+ }),
632
+ /** Public: Claim a welcome pack (no auth needed, uses claim token) */
633
+ claim: publicOc.route({ method: "POST", path: "/welcome-packs/claim", tags: ["Welcome Packs"], summary: "Claim a welcome pack" }).input(WelcomePackClaimInputSchema).output(WelcomePackClaimOutputSchema).errors({
634
+ BAD_REQUEST,
635
+ EXPIRED: { message: "Claim link has expired", status: 410 }
636
+ }),
637
+ /** Protected: Send an invite for a welcome pack */
638
+ invite: publicOc.route({ method: "POST", path: "/welcome-packs/invite", tags: ["Welcome Packs"], summary: "Send an invite for a welcome pack" }).input(WelcomePackInviteInputSchema).output(WelcomePackInviteOutputSchema).errors({
639
+ BAD_REQUEST,
640
+ NOT_FOUND
641
+ })
642
+ };
643
+ var InitKycInputSchema = z.object({
644
+ type: z.enum(["individual", "business"]).optional()
645
+ });
646
+ var CreateBankAccountInputSchema = z.object({
647
+ currency: z.string(),
648
+ account_type: z.string(),
649
+ bank_name: z.string(),
650
+ account_name: z.string(),
651
+ first_name: z.string().optional(),
652
+ last_name: z.string().optional(),
653
+ account_owner_name: z.string().optional(),
654
+ business_name: z.string().optional(),
655
+ account: z.object({
656
+ account_number: z.string(),
657
+ routing_number: z.string(),
658
+ checking_or_savings: z.string()
659
+ }),
660
+ address: z.object({
661
+ street_line_1: z.string(),
662
+ line2: z.string().optional(),
663
+ city: z.string(),
664
+ state: z.string(),
665
+ postal_code: z.string(),
666
+ country: z.string()
667
+ })
668
+ });
669
+ z.object({
670
+ id: z.string()
671
+ });
672
+ var DeleteBankAccountInputSchema = z.object({
673
+ id: z.number()
674
+ });
675
+ var GetSendQuoteInputSchema = z.object({
676
+ id: z.string(),
677
+ usdAmount: z.string()
678
+ });
679
+ var SendFundsInputSchema = z.object({
680
+ id: z.string(),
681
+ userAddress: z.string(),
682
+ quoteResponse: QuoteResponseSchema
683
+ });
684
+ z.object({
685
+ id: z.string()
686
+ });
687
+ var UpdateTransferInputSchema = z.object({
688
+ id: z.string(),
689
+ solanaSignature: z.string()
690
+ });
691
+ var KycStatusOutputSchema = z.object({
692
+ kycStatus: z.string(),
693
+ tosStatus: z.string(),
694
+ tosLink: z.string().nullable(),
695
+ kycLink: z.string().nullable(),
696
+ kycLinkId: z.string().nullable(),
697
+ accountType: z.string().optional(),
698
+ rejectionReasons: z.array(z.string()).optional()
699
+ });
700
+ var FeesOutputSchema = z.object({
701
+ developer_fee: z.string(),
702
+ developer_fee_percent: z.number()
703
+ });
704
+ var BankAccountSchema = z.object({
705
+ id: z.number().optional(),
706
+ bridgeUserId: z.number().optional(),
707
+ bridgeExternalAccountId: z.string().optional(),
708
+ accountName: z.string().optional(),
709
+ bankName: z.string().optional(),
710
+ lastFourDigits: z.string().optional(),
711
+ routingNumber: z.string().optional(),
712
+ accountType: z.string().optional(),
713
+ createdAt: z.union([z.string(), z.date()]).optional(),
714
+ updatedAt: z.union([z.string(), z.date()]).optional()
715
+ }).passthrough();
716
+ var BankAccountListOutputSchema = z.array(BankAccountSchema);
717
+ var DeleteBankAccountOutputSchema = z.object({
718
+ success: z.boolean()
719
+ });
720
+ var BridgeTransferSchema = z.object({
721
+ id: z.string(),
722
+ state: z.string(),
723
+ source_deposit_instructions: z.object({
724
+ to_address: z.string()
725
+ })
726
+ }).passthrough();
727
+ var SendFundsOutputSchema = z.object({
728
+ bridgeTransfer: BridgeTransferSchema,
729
+ transactionData: TransactionDataSchema
730
+ });
731
+ var UpdateTransferOutputSchema = z.object({
732
+ success: z.boolean()
733
+ });
734
+ var QuoteOutputSchema = QuoteResponseSchema;
735
+
736
+ // src/contracts/fiat.ts
737
+ var fiatContract = {
738
+ getKycStatus: protectedOc.route({ method: "GET", path: "/fiat/kyc/status" }).output(KycStatusOutputSchema).errors({
739
+ EMAIL_NOT_LINKED: { status: 401, message: "Email not linked." }
740
+ }),
741
+ initKyc: protectedOc.route({ method: "POST", path: "/fiat/kyc/init" }).input(InitKycInputSchema).output(KycStatusOutputSchema).errors({
742
+ EMAIL_NOT_LINKED: { status: 401, message: "Email not linked." },
743
+ BRIDGE_ERROR: { message: "Failed to create Bridge KYC link", status: 500 }
744
+ }),
745
+ getFees: protectedOc.route({ method: "GET", path: "/fiat/fees" }).output(FeesOutputSchema).errors({}),
746
+ listBankAccounts: protectedOc.route({ method: "GET", path: "/fiat/bank-accounts" }).output(BankAccountListOutputSchema).errors({
747
+ NOT_FOUND: { message: "Bridge customer ID not found", status: 404 }
748
+ }),
749
+ createBankAccount: protectedOc.route({ method: "POST", path: "/fiat/bank-accounts" }).input(CreateBankAccountInputSchema).output(BankAccountSchema).errors({
750
+ NO_CUSTOMER: { message: "Bridge customer ID not found", status: 404 },
751
+ BRIDGE_ERROR: { message: "Failed to create Bridge KYC link", status: 500 }
752
+ }),
753
+ deleteBankAccount: protectedOc.route({ method: "DELETE", path: "/fiat/bank-accounts/{id}" }).input(DeleteBankAccountInputSchema).output(DeleteBankAccountOutputSchema).errors({
754
+ NO_CUSTOMER: { message: "Bridge customer ID not found", status: 404 },
755
+ BRIDGE_ERROR: { message: "Failed to delete bank account", status: 500 }
756
+ }),
757
+ getSendQuote: protectedOc.route({ method: "GET", path: "/fiat/quote/{id}" }).input(GetSendQuoteInputSchema).output(QuoteOutputSchema).errors({
758
+ BAD_REQUEST,
759
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter", status: 500 }
760
+ }),
761
+ sendFunds: protectedOc.route({ method: "POST", path: "/fiat/send" }).input(SendFundsInputSchema).output(SendFundsOutputSchema).errors({
762
+ NOT_FOUND,
763
+ BRIDGE_ERROR: { message: "Failed to create Bridge transfer", status: 500 },
764
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter", status: 500 }
765
+ }),
766
+ updateTransfer: protectedOc.route({ method: "PUT", path: "/fiat/transfer/{id}" }).input(UpdateTransferInputSchema).output(UpdateTransferOutputSchema).errors({
767
+ NOT_FOUND: { message: "Transfer not found", status: 404 }
768
+ })
769
+ };
770
+ var BridgeWebhookInputSchema = z.object({
771
+ type: z.string(),
772
+ kyc_link_id: z.string().optional(),
773
+ kyc_status: z.string().optional(),
774
+ tos_status: z.string().optional(),
775
+ customer_id: z.string().optional()
776
+ });
777
+ var BridgeWebhookOutputSchema = z.object({
778
+ success: z.boolean(),
779
+ error: z.string().optional()
780
+ });
781
+
782
+ // src/contracts/webhooks.ts
783
+ var webhooksContract = {
784
+ bridge: publicOc.route({ method: "POST", path: "/webhooks/bridge" }).input(BridgeWebhookInputSchema).output(BridgeWebhookOutputSchema).errors({
785
+ NOT_FOUND,
786
+ INVALID_PAYLOAD: { message: "Invalid webhook payload", status: 400 }
787
+ })
779
788
  };
780
789
 
781
790
  // src/contracts/index.ts
@@ -787,66 +796,10 @@ var apiContract = {
787
796
  transactions: transactionsContract,
788
797
  welcomePacks: welcomePacksContract
789
798
  };
799
+ var fullApiContract = {
800
+ ...apiContract,
801
+ fiat: fiatContract,
802
+ webhooks: webhooksContract
803
+ };
790
804
 
791
- // src/openapi.ts
792
- function generateOpenAPISpec(options) {
793
- const { info = {}, servers = [] } = options;
794
- const paths = {};
795
- const schemas = {};
796
- for (const [routerName, router] of Object.entries(apiContract)) {
797
- for (const [procedureName, procedure] of Object.entries(
798
- router
799
- )) {
800
- if (!procedure.route) continue;
801
- const { method, path } = procedure.route;
802
- const operationId = `${routerName}_${procedureName}`;
803
- const openApiPath = path.replace(/\{(\w+)\}/g, "{$1}");
804
- if (!paths[openApiPath]) {
805
- paths[openApiPath] = {};
806
- }
807
- paths[openApiPath][method.toLowerCase()] = {
808
- operationId,
809
- tags: [routerName],
810
- summary: `${routerName}.${procedureName}`,
811
- responses: {
812
- "200": {
813
- description: "Successful response"
814
- },
815
- "400": {
816
- description: "Bad request"
817
- },
818
- "401": {
819
- description: "Unauthorized"
820
- },
821
- "403": {
822
- description: "Forbidden"
823
- },
824
- "404": {
825
- description: "Not found"
826
- },
827
- "500": {
828
- description: "Internal server error"
829
- }
830
- }
831
- };
832
- }
833
- }
834
- return {
835
- openapi: "3.0.3",
836
- info: {
837
- title: info.title ?? "Helium Blockchain API",
838
- version: info.version ?? "1.0.0",
839
- description: info.description ?? "API for interacting with the Helium blockchain, including hotspots, tokens, and transactions."
840
- },
841
- servers,
842
- paths,
843
- components: {
844
- schemas
845
- }
846
- };
847
- }
848
- function getAPIContract() {
849
- return apiContract;
850
- }
851
-
852
- export { BatchStatusOutputSchema, CONFLICT, ClaimRewardsInputSchema, ClaimRewardsOutputSchema, CreateHntAccountInputSchema, CreateHntAccountOutputSchema, CreateSplitInputSchema, CreateSplitOutputSchema, DeleteSplitInputSchema, DeleteSplitOutputSchema, DeviceTypeSchema, ErrorResponseSchema, FORBIDDEN, GetBalancesInputSchema, GetByPayerAndTagInputSchema, GetByPayerInputSchema, GetHotspotsInputSchema, GetInputSchema, GetInstructionsInputSchema, GetPendingRewardsInputSchema, GetQuoteInputSchema, GetSplitInputSchema, GetTokensInputSchema, HealthResponseSchema, HotspotSchema, HotspotSharesSchema, HotspotTypeSchema, HotspotsDataSchema, INSUFFICIENT_FUNDS, INVALID_HOTSPOT, NOT_FOUND, NOT_OWNER, OwnershipTypeSchema, PaginationInputSchema, PaginationOutputSchema, PayerBatchSummarySchema, PayerBatchesOutputSchema, PendingRewardsOutputSchema, PublicKeySchema, QuoteResponseSchema, RATE_LIMITED, ResubmitInputSchema, ResubmitOutputSchema, RewardSplitInputSchema, SIMULATION_FAILED, ScheduleInputSchema, SplitResponseSchema, SplitShareSchema, SubmitInputSchema, SubmitOutputSchema, SwapTransactionDataSchema, TRANSACTION_FAILED, TokenAccountSchema, TokenBalanceDataSchema, TokenListOutputSchema, TokenSchema, TransactionBatchRequestSchema, TransactionBatchResponseSchema, TransactionDataSchema, TransactionItemSchema, TransactionMetadataSchema, TransactionStatusSchema, TransferHotspotInputSchema, TransferHotspotOutputSchema, TransferInputSchema, TransferOutputSchema, UNAUTHORIZED, UpdateRewardsDestinationInputSchema, UpdateRewardsDestinationOutputSchema, VALIDATION_ERROR, WalletAddressSchema, WelcomePackClaimInputSchema, WelcomePackClaimOutputSchema, WelcomePackCreateInputSchema, WelcomePackCreateOutputSchema, WelcomePackDeleteInputSchema, WelcomePackDeleteOutputSchema, WelcomePackGetByAddressInputSchema, WelcomePackGetInputSchema, WelcomePackInviteInputSchema, WelcomePackInviteOutputSchema, WelcomePackListInputSchema, WelcomePackListOutputSchema, WelcomePackSchema, apiContract, commonErrors, createClient, createMockClient, generateOpenAPISpec, getAPIContract, hotspotErrors, solanaErrors };
805
+ export { BAD_REQUEST, BatchStatusOutputSchema, CONFLICT, ClaimRewardsInputSchema, ClaimRewardsOutputSchema, CreateHntAccountInputSchema, CreateHntAccountOutputSchema, CreateSplitInputSchema, CreateSplitOutputSchema, DeleteSplitInputSchema, DeleteSplitOutputSchema, DeviceTypeSchema, ErrorResponseSchema, GetBalancesInputSchema, GetByPayerAndTagInputSchema, GetByPayerInputSchema, GetHotspotsInputSchema, GetInputSchema, GetInstructionsInputSchema, GetPendingRewardsInputSchema, GetQuoteInputSchema, GetSplitInputSchema, GetTokensInputSchema, HealthResponseSchema, HotspotSchema, HotspotSharesSchema, HotspotTypeSchema, HotspotsDataSchema, INSUFFICIENT_FUNDS, NOT_FOUND, OwnershipTypeSchema, PaginationInputSchema, PaginationOutputSchema, PayerBatchSummarySchema, PayerBatchesOutputSchema, PendingRewardsOutputSchema, PublicKeySchema, QuoteResponseSchema, RATE_LIMITED, ResubmitInputSchema, ResubmitOutputSchema, RewardSplitInputSchema, SIMULATION_FAILED, ScheduleInputSchema, SplitResponseSchema, SplitShareSchema, SubmitInputSchema, SubmitOutputSchema, SwapTransactionDataSchema, TRANSACTION_FAILED, TokenAccountSchema, TokenBalanceDataSchema, TokenListOutputSchema, TokenSchema, TransactionBatchRequestSchema, TransactionBatchResponseSchema, TransactionDataSchema, TransactionItemSchema, TransactionMetadataSchema, TransactionStatusSchema, TransferHotspotInputSchema, TransferHotspotOutputSchema, TransferInputSchema, TransferOutputSchema, UNAUTHENTICATED, UNAUTHORIZED, UpdateRewardsDestinationInputSchema, UpdateRewardsDestinationOutputSchema, WalletAddressSchema, WelcomePackClaimInputSchema, WelcomePackClaimOutputSchema, WelcomePackCreateInputSchema, WelcomePackCreateOutputSchema, WelcomePackDeleteInputSchema, WelcomePackDeleteOutputSchema, WelcomePackGetByAddressInputSchema, WelcomePackGetInputSchema, WelcomePackInviteInputSchema, WelcomePackInviteOutputSchema, WelcomePackListInputSchema, WelcomePackListOutputSchema, WelcomePackSchema, apiContract, createClient, createMockClient, fullApiContract };