@helium/blockchain-api 0.2.0 → 0.2.2

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 +2071 -1171
  3. package/dist/index.js +367 -405
  4. package/package.json +6 -14
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()
@@ -103,6 +92,7 @@ var ErrorResponseSchema = z.object({
103
92
  });
104
93
  var WalletAddressSchema = z.string().min(32).max(44);
105
94
  var PublicKeySchema = z.string().min(32).max(44);
95
+ var HeliumPublicKeySchema = z.string().min(32).max(400);
106
96
  var PaginationInputSchema = z.object({
107
97
  page: z.coerce.number().int().min(1).default(1),
108
98
  limit: z.coerce.number().int().min(1).max(100).default(10)
@@ -112,20 +102,22 @@ var PaginationOutputSchema = z.object({
112
102
  page: z.number(),
113
103
  totalPages: z.number()
114
104
  });
115
-
116
- // src/schemas/tokens.ts
105
+ var HealthResponseSchema = z.object({
106
+ ok: z.boolean(),
107
+ error: z.string().optional()
108
+ });
117
109
  var GetBalancesInputSchema = z.object({
118
- walletAddress: z.string().min(32)
110
+ walletAddress: WalletAddressSchema
119
111
  });
120
112
  var TransferInputSchema = z.object({
121
- walletAddress: z.string().min(32),
113
+ walletAddress: WalletAddressSchema,
122
114
  mint: z.string().nullable().optional(),
123
115
  destination: z.string().min(32),
124
116
  amount: z.string(),
125
117
  decimals: z.number().optional()
126
118
  });
127
119
  var CreateHntAccountInputSchema = z.object({
128
- walletAddress: z.string().min(32)
120
+ walletAddress: WalletAddressSchema
129
121
  });
130
122
  var TokenAccountSchema = z.object({
131
123
  mint: z.string(),
@@ -151,35 +143,6 @@ var TransferOutputSchema = z.object({
151
143
  var CreateHntAccountOutputSchema = z.object({
152
144
  transactionData: TransactionDataSchema
153
145
  });
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
146
  var HotspotTypeSchema = z.enum(["iot", "mobile", "all"]);
184
147
  var DeviceTypeSchema = z.enum([
185
148
  "iot-gateway",
@@ -209,31 +172,31 @@ var HotspotSchema = z.object({
209
172
  ownershipType: z.string()
210
173
  });
211
174
  var GetHotspotsInputSchema = z.object({
212
- walletAddress: z.string().min(32),
175
+ walletAddress: WalletAddressSchema,
213
176
  type: HotspotTypeSchema.optional(),
214
177
  page: z.coerce.number().int().min(1).default(1),
215
178
  limit: z.coerce.number().int().min(1).max(100).default(10)
216
179
  });
217
180
  var ClaimRewardsInputSchema = z.object({
218
- walletAddress: z.string().min(32)
181
+ walletAddress: WalletAddressSchema
219
182
  });
220
183
  var GetPendingRewardsInputSchema = z.object({
221
- walletAddress: z.string().min(32)
184
+ walletAddress: WalletAddressSchema
222
185
  });
223
186
  var TransferHotspotInputSchema = z.object({
224
- walletAddress: z.string().min(32),
225
- hotspotPubkey: z.string().min(1),
187
+ walletAddress: WalletAddressSchema,
188
+ hotspotPubkey: HeliumPublicKeySchema,
226
189
  recipient: z.string().min(32)
227
190
  });
228
191
  var UpdateRewardsDestinationInputSchema = z.object({
229
- walletAddress: z.string().min(32),
230
- hotspotPubkey: z.string().min(1),
192
+ walletAddress: WalletAddressSchema,
193
+ hotspotPubkey: HeliumPublicKeySchema,
231
194
  destination: z.string().min(32),
232
195
  lazyDistributors: z.array(z.string().min(32)).min(1)
233
196
  });
234
197
  var GetSplitInputSchema = z.object({
235
- walletAddress: z.string().min(32),
236
- hotspotPubkey: z.string().min(1)
198
+ walletAddress: WalletAddressSchema,
199
+ hotspotPubkey: HeliumPublicKeySchema
237
200
  });
238
201
  var RewardSplitInputSchema = z.object({
239
202
  address: z.string().min(32),
@@ -248,15 +211,15 @@ var ScheduleInputSchema = z.object({
248
211
  dayOfMonth: z.string().optional()
249
212
  });
250
213
  var CreateSplitInputSchema = z.object({
251
- walletAddress: z.string().min(32),
252
- hotspotPubkey: z.string().min(1),
214
+ walletAddress: WalletAddressSchema,
215
+ hotspotPubkey: HeliumPublicKeySchema,
253
216
  rewardsSplit: z.array(RewardSplitInputSchema),
254
217
  schedule: ScheduleInputSchema,
255
218
  lazyDistributor: z.string().min(32)
256
219
  });
257
220
  var DeleteSplitInputSchema = z.object({
258
- walletAddress: z.string().min(32),
259
- hotspotPubkey: z.string().min(1)
221
+ walletAddress: WalletAddressSchema,
222
+ hotspotPubkey: HeliumPublicKeySchema
260
223
  });
261
224
  var HotspotsDataSchema = z.object({
262
225
  hotspots: z.array(HotspotSchema),
@@ -294,133 +257,18 @@ var DeleteSplitOutputSchema = z.object({
294
257
  var PendingRewardsOutputSchema = z.object({
295
258
  pending: z.string()
296
259
  });
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
- };
260
+ var ReassertLocationRequestSchema = z.object({
261
+ entityPubKey: HeliumPublicKeySchema,
262
+ walletAddress: WalletAddressSchema,
263
+ location: z.object({
264
+ lat: z.number().min(-90).max(90),
265
+ lng: z.number().min(-180).max(180)
266
+ }),
267
+ azimuth: z.number().min(0).max(360).optional()
268
+ });
269
+ var ReassertLocationResponseSchema = z.object({
270
+ transactionData: TransactionDataSchema
271
+ });
424
272
  var GetTokensInputSchema = z.object({
425
273
  limit: z.coerce.number().int().min(1).max(100).default(50)
426
274
  });
@@ -498,19 +346,31 @@ var SubmitOutputSchema = z.object({
498
346
  batchId: z.string(),
499
347
  message: z.string().optional()
500
348
  });
349
+ var TransactionStateSchema = z.union([
350
+ z.literal("pending"),
351
+ z.literal("confirmed"),
352
+ z.literal("failed"),
353
+ z.literal("expired"),
354
+ z.literal("partial")
355
+ ]);
501
356
  var TransactionStatusSchema = z.object({
502
357
  signature: z.string(),
503
- status: z.string(),
358
+ status: TransactionStateSchema,
504
359
  transaction: z.unknown().optional()
505
360
  });
506
361
  var BatchStatusOutputSchema = z.object({
507
362
  batchId: z.string(),
508
- status: z.string(),
509
- submissionType: z.string(),
363
+ status: TransactionStateSchema,
364
+ submissionType: z.union([
365
+ z.literal("single"),
366
+ z.literal("parallel"),
367
+ z.literal("sequential"),
368
+ z.literal("jito_bundle")
369
+ ]),
510
370
  parallel: z.boolean(),
511
371
  transactions: z.array(TransactionStatusSchema),
512
- jitoBundleId: z.string().optional(),
513
- jitoBundleStatus: z.unknown().optional()
372
+ jitoBundleId: z.string().optional().nullable(),
373
+ jitoBundleStatus: z.unknown().optional().nullable()
514
374
  });
515
375
  var ResubmitOutputSchema = z.object({
516
376
  success: z.boolean(),
@@ -543,10 +403,10 @@ var PayerBatchesOutputSchema = z.object({
543
403
  })
544
404
  });
545
405
  var WelcomePackListInputSchema = z.object({
546
- walletAddress: z.string().min(32)
406
+ walletAddress: WalletAddressSchema
547
407
  });
548
408
  var WelcomePackCreateInputSchema = z.object({
549
- walletAddress: z.string().min(32),
409
+ walletAddress: WalletAddressSchema,
550
410
  assetId: z.string(),
551
411
  solAmount: z.number(),
552
412
  rentRefund: z.string(),
@@ -556,11 +416,11 @@ var WelcomePackCreateInputSchema = z.object({
556
416
  lazyDistributor: z.string()
557
417
  });
558
418
  var WelcomePackGetInputSchema = z.object({
559
- walletAddress: z.string().min(32),
419
+ walletAddress: WalletAddressSchema,
560
420
  packId: z.number()
561
421
  });
562
422
  var WelcomePackDeleteInputSchema = z.object({
563
- walletAddress: z.string().min(32),
423
+ walletAddress: WalletAddressSchema,
564
424
  packId: z.number()
565
425
  });
566
426
  var WelcomePackGetByAddressInputSchema = z.object({
@@ -568,13 +428,13 @@ var WelcomePackGetByAddressInputSchema = z.object({
568
428
  });
569
429
  var WelcomePackClaimInputSchema = z.object({
570
430
  packAddress: z.string().min(32),
571
- walletAddress: z.string().min(32),
431
+ walletAddress: WalletAddressSchema,
572
432
  signature: z.string(),
573
433
  expirationTs: z.string()
574
434
  });
575
435
  var WelcomePackInviteInputSchema = z.object({
576
436
  packAddress: z.string().min(32),
577
- walletAddress: z.string().min(32),
437
+ walletAddress: WalletAddressSchema,
578
438
  expirationDays: z.number().int().positive().max(365).default(7)
579
439
  });
580
440
  var WelcomePackSchema = z.object({
@@ -609,33 +469,36 @@ var WelcomePackInviteOutputSchema = z.object({
609
469
  message: z.string(),
610
470
  expirationTs: z.number()
611
471
  });
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
- }
472
+ var UNAUTHENTICATED = {
473
+ status: 401,
474
+ message: "Authentication required. Please sign in to continue."
475
+ };
476
+ var UNAUTHORIZED = {
477
+ status: 403,
478
+ message: "You do not have permission to access this resource."
479
+ };
480
+ var NOT_FOUND = {
481
+ status: 404,
482
+ message: "The requested resource was not found."
483
+ };
484
+ var BAD_REQUEST = {
485
+ status: 400,
486
+ message: "Invalid input data provided.",
487
+ data: z.object({
488
+ fields: z.array(z.string()).optional()
489
+ }).optional()
490
+ };
491
+ var INVALID_WALLET_ADDRESS = {
492
+ status: 400,
493
+ message: "The provided wallet address is invalid."
494
+ };
495
+ var RATE_LIMITED = {
496
+ status: 429,
497
+ message: "Too many requests. Please try again later."
498
+ };
499
+ var CONFLICT = {
500
+ status: 409,
501
+ message: "A resource with this identifier already exists."
639
502
  };
640
503
  var INSUFFICIENT_FUNDS = {
641
504
  status: 400,
@@ -661,192 +524,291 @@ var SIMULATION_FAILED = {
661
524
  link: z.string().optional()
662
525
  })
663
526
  };
664
- var solanaErrors = {
665
- INSUFFICIENT_FUNDS,
666
- TRANSACTION_FAILED,
667
- SIMULATION_FAILED
668
- };
669
-
670
- // src/contracts/transactions.ts
671
- 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
- }
714
- };
715
-
716
- // src/contracts/welcome-packs.ts
717
- 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
- }
779
- };
527
+ var healthContract = oc.tag("Health").router({
528
+ check: oc.route({ method: "GET", path: "/health", summary: "Health check" }).output(HealthResponseSchema)
529
+ });
530
+ var tokensContract = oc.tag("Tokens").router({
531
+ /** Public: Get token balances for a wallet */
532
+ getBalances: oc.route({ method: "GET", path: "/tokens/{walletAddress}", summary: "Get token balances for a wallet" }).input(GetBalancesInputSchema).output(TokenBalanceDataSchema).errors({
533
+ INVALID_WALLET_ADDRESS
534
+ }),
535
+ /** Protected: Transfer tokens */
536
+ transfer: oc.route({ method: "POST", path: "/tokens/transfer", summary: "Transfer tokens" }).input(TransferInputSchema).output(TransferOutputSchema).errors({
537
+ BAD_REQUEST,
538
+ INSUFFICIENT_FUNDS
539
+ }),
540
+ /** Protected: Create HNT account */
541
+ createHntAccount: oc.route({ method: "POST", path: "/tokens/hnt-account", summary: "Create HNT account" }).input(CreateHntAccountInputSchema).output(CreateHntAccountOutputSchema).errors({
542
+ INVALID_WALLET_ADDRESS
543
+ })
544
+ });
545
+ var hotspotsContract = oc.tag("Hotspot").prefix("/hotspots").router({
546
+ /** Public: Get hotspots for a wallet */
547
+ getHotspots: oc.route({ method: "GET", path: "/wallet/{walletAddress}", summary: "Get hotspots for a wallet" }).input(GetHotspotsInputSchema).output(HotspotsDataSchema).errors({
548
+ INVALID_WALLET_ADDRESS
549
+ }),
550
+ /** Protected: Claim rewards for hotspots */
551
+ claimRewards: oc.route({ method: "POST", path: "/claim-rewards", summary: "Claim all hotspot rewards" }).input(ClaimRewardsInputSchema).output(ClaimRewardsOutputSchema).errors({
552
+ INSUFFICIENT_FUNDS
553
+ }),
554
+ /** Public: Get pending rewards for a wallet */
555
+ getPendingRewards: oc.route({ method: "GET", path: "/pending-rewards/{walletAddress}", summary: "Get pending rewards" }).input(GetPendingRewardsInputSchema).output(PendingRewardsOutputSchema).errors({
556
+ BAD_REQUEST: { message: "Invalid wallet address", status: 400 },
557
+ INVALID_WALLET_ADDRESS
558
+ }),
559
+ /** Protected: Transfer hotspot ownership */
560
+ transferHotspot: oc.route({ method: "POST", path: "/transfer", summary: "Transfer ownership" }).input(TransferHotspotInputSchema).output(TransferHotspotOutputSchema).errors({
561
+ UNAUTHORIZED,
562
+ NOT_FOUND,
563
+ BAD_REQUEST: { message: "Invalid transfer parameters", status: 400 }
564
+ }),
565
+ /** Protected: Update rewards destination */
566
+ updateRewardsDestination: oc.route({ method: "POST", path: "/update-rewards-destination", summary: "Update rewards destination" }).input(UpdateRewardsDestinationInputSchema).output(UpdateRewardsDestinationOutputSchema).errors({
567
+ BAD_REQUEST: { message: "Invalid parameters", status: 400 },
568
+ NOT_FOUND
569
+ }),
570
+ /** Public: Get split configuration for a hotspot */
571
+ getSplit: oc.route({ method: "GET", path: "/split/{walletAddress}/{hotspotPubkey}", summary: "Get reward split" }).input(GetSplitInputSchema).output(SplitResponseSchema).errors({
572
+ NOT_FOUND: { message: "Split not found", status: 404 },
573
+ INVALID_WALLET_ADDRESS
574
+ }),
575
+ /** Protected: Create a split configuration */
576
+ createSplit: oc.route({ method: "POST", path: "/split", summary: "Create a reward split" }).input(CreateSplitInputSchema).output(CreateSplitOutputSchema).errors({
577
+ NOT_FOUND,
578
+ BAD_REQUEST: { message: "Invalid split configuration", status: 400 },
579
+ INSUFFICIENT_FUNDS
580
+ }),
581
+ /** Protected: Delete a split configuration */
582
+ deleteSplit: oc.route({ method: "DELETE", path: "/split", summary: "Delete a reward split" }).input(DeleteSplitInputSchema).output(DeleteSplitOutputSchema).errors({
583
+ NOT_FOUND
584
+ })
585
+ });
586
+ var swapContract = oc.tag("Swap").router({
587
+ getTokens: oc.route({ method: "GET", path: "/swap/tokens" }).input(GetTokensInputSchema).output(TokenListOutputSchema).errors({
588
+ JUPITER_ERROR: { message: "Failed to fetch tokens from Jupiter" }
589
+ }),
590
+ getQuote: oc.route({ method: "GET", path: "/swap/quote" }).input(GetQuoteInputSchema).output(QuoteResponseSchema).errors({
591
+ BAD_REQUEST: { message: "Invalid quote parameters", status: 400 },
592
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter" }
593
+ }),
594
+ getInstructions: oc.route({ method: "POST", path: "/swap/instructions" }).input(GetInstructionsInputSchema).output(TransactionDataSchema).errors({
595
+ BAD_REQUEST: { message: "Invalid instruction parameters", status: 400 },
596
+ JUPITER_ERROR: { message: "Failed to get swap instructions from Jupiter" }
597
+ })
598
+ });
599
+ var transactionsContract = oc.tag("Transactions").router({
600
+ submit: oc.route({ method: "POST", path: "/transactions", summary: "Submit a transaction" }).input(SubmitInputSchema).output(SubmitOutputSchema).errors({
601
+ BAD_REQUEST,
602
+ CONFLICT,
603
+ SIMULATION_FAILED
604
+ }),
605
+ get: oc.route({ method: "GET", path: "/transactions/{id}", summary: "Get transaction status" }).input(GetInputSchema).output(BatchStatusOutputSchema).errors({
606
+ NOT_FOUND
607
+ }),
608
+ resubmit: oc.route({ method: "POST", path: "/transactions/{id}/resubmit", summary: "Resubmit a transaction" }).input(ResubmitInputSchema).output(ResubmitOutputSchema).errors({
609
+ NOT_FOUND,
610
+ BAD_REQUEST
611
+ }),
612
+ getByPayer: oc.route({ method: "GET", path: "/transactions/payer/{payer}", summary: "Get transactions by payer" }).input(GetByPayerInputSchema).output(PayerBatchesOutputSchema).errors({
613
+ BAD_REQUEST
614
+ }),
615
+ getByPayerAndTag: oc.route({ method: "GET", path: "/transactions/payer/{payer}/tag/{tag}", summary: "Get transactions by payer and tag" }).input(GetByPayerAndTagInputSchema).output(PayerBatchesOutputSchema).errors({
616
+ BAD_REQUEST
617
+ })
618
+ });
619
+ var welcomePacksContract = oc.tag("Welcome Packs").router({
620
+ /** Public: List welcome packs for a wallet */
621
+ list: oc.route({ method: "GET", path: "/welcome-packs/{walletAddress}", summary: "List welcome packs for a wallet" }).input(WelcomePackListInputSchema).output(WelcomePackListOutputSchema).errors({
622
+ INVALID_WALLET_ADDRESS
623
+ }),
624
+ /** Protected: Create a new welcome pack */
625
+ create: oc.route({ method: "POST", path: "/welcome-packs", summary: "Create a new welcome pack" }).input(WelcomePackCreateInputSchema).output(WelcomePackCreateOutputSchema).errors({
626
+ BAD_REQUEST
627
+ }),
628
+ /** Public: Get a specific welcome pack */
629
+ get: oc.route({ method: "GET", path: "/welcome-packs/{walletAddress}/{packId}", summary: "Get a specific welcome pack" }).input(WelcomePackGetInputSchema).output(WelcomePackSchema).errors({
630
+ NOT_FOUND,
631
+ INVALID_WALLET_ADDRESS
632
+ }),
633
+ /** Protected: Delete a welcome pack */
634
+ delete: oc.route({ method: "DELETE", path: "/welcome-packs/{walletAddress}/{packId}", summary: "Delete a welcome pack" }).input(WelcomePackDeleteInputSchema).output(WelcomePackDeleteOutputSchema).errors({
635
+ BAD_REQUEST,
636
+ INVALID_WALLET_ADDRESS
637
+ }),
638
+ /** Public: Get welcome pack by pack address */
639
+ getByAddress: oc.route({ method: "GET", path: "/welcome-packs/address/{packAddress}", summary: "Get welcome pack by pack address" }).input(WelcomePackGetByAddressInputSchema).output(WelcomePackSchema).errors({
640
+ NOT_FOUND
641
+ }),
642
+ /** Public: Claim a welcome pack (no auth needed, uses claim token) */
643
+ claim: oc.route({ method: "POST", path: "/welcome-packs/claim", summary: "Claim a welcome pack" }).input(WelcomePackClaimInputSchema).output(WelcomePackClaimOutputSchema).errors({
644
+ BAD_REQUEST,
645
+ EXPIRED: { message: "Claim link has expired", status: 410 }
646
+ }),
647
+ /** Protected: Send an invite for a welcome pack */
648
+ invite: oc.route({ method: "POST", path: "/welcome-packs/invite", summary: "Send an invite for a welcome pack" }).input(WelcomePackInviteInputSchema).output(WelcomePackInviteOutputSchema).errors({
649
+ BAD_REQUEST,
650
+ NOT_FOUND
651
+ })
652
+ });
653
+ var InitKycInputSchema = z.object({
654
+ type: z.enum(["individual", "business"]).optional()
655
+ });
656
+ var CreateBankAccountInputSchema = z.object({
657
+ currency: z.string(),
658
+ account_type: z.string(),
659
+ bank_name: z.string(),
660
+ account_name: z.string(),
661
+ first_name: z.string().optional(),
662
+ last_name: z.string().optional(),
663
+ account_owner_name: z.string().optional(),
664
+ business_name: z.string().optional(),
665
+ account: z.object({
666
+ account_number: z.string(),
667
+ routing_number: z.string(),
668
+ checking_or_savings: z.string()
669
+ }),
670
+ address: z.object({
671
+ street_line_1: z.string(),
672
+ line2: z.string().optional(),
673
+ city: z.string(),
674
+ state: z.string(),
675
+ postal_code: z.string(),
676
+ country: z.string()
677
+ })
678
+ });
679
+ z.object({
680
+ id: z.string()
681
+ });
682
+ var DeleteBankAccountInputSchema = z.object({
683
+ id: z.number()
684
+ });
685
+ var GetSendQuoteInputSchema = z.object({
686
+ id: z.string(),
687
+ usdAmount: z.string()
688
+ });
689
+ var SendFundsInputSchema = z.object({
690
+ id: z.string(),
691
+ userAddress: z.string(),
692
+ quoteResponse: QuoteResponseSchema
693
+ });
694
+ z.object({
695
+ id: z.string()
696
+ });
697
+ var UpdateTransferInputSchema = z.object({
698
+ id: z.string(),
699
+ solanaSignature: z.string()
700
+ });
701
+ var KycStatusOutputSchema = z.object({
702
+ kycStatus: z.string(),
703
+ tosStatus: z.string(),
704
+ tosLink: z.string().nullable(),
705
+ kycLink: z.string().nullable(),
706
+ kycLinkId: z.string().nullable(),
707
+ accountType: z.string().optional(),
708
+ rejectionReasons: z.array(z.string()).optional()
709
+ });
710
+ var FeesOutputSchema = z.object({
711
+ developer_fee: z.string(),
712
+ developer_fee_percent: z.number()
713
+ });
714
+ var BankAccountSchema = z.object({
715
+ id: z.number().optional(),
716
+ bridgeUserId: z.number().optional(),
717
+ bridgeExternalAccountId: z.string().optional(),
718
+ accountName: z.string().optional(),
719
+ bankName: z.string().optional(),
720
+ lastFourDigits: z.string().optional(),
721
+ routingNumber: z.string().optional(),
722
+ accountType: z.string().optional(),
723
+ createdAt: z.union([z.string(), z.date()]).optional(),
724
+ updatedAt: z.union([z.string(), z.date()]).optional()
725
+ }).passthrough();
726
+ var BankAccountListOutputSchema = z.array(BankAccountSchema);
727
+ var DeleteBankAccountOutputSchema = z.object({
728
+ success: z.boolean()
729
+ });
730
+ var BridgeTransferSchema = z.object({
731
+ id: z.string(),
732
+ state: z.string(),
733
+ source_deposit_instructions: z.object({
734
+ to_address: z.string()
735
+ })
736
+ }).passthrough();
737
+ var SendFundsOutputSchema = z.object({
738
+ bridgeTransfer: BridgeTransferSchema,
739
+ transactionData: TransactionDataSchema
740
+ });
741
+ var UpdateTransferOutputSchema = z.object({
742
+ success: z.boolean()
743
+ });
744
+ var QuoteOutputSchema = QuoteResponseSchema;
745
+ var fiatContract = oc.errors({
746
+ UNAUTHENTICATED,
747
+ UNAUTHORIZED
748
+ }).tag("Fiat").router({
749
+ getKycStatus: oc.route({ method: "GET", path: "/fiat/kyc/status" }).output(KycStatusOutputSchema).errors({
750
+ EMAIL_NOT_LINKED: { status: 401, message: "Email not linked." }
751
+ }),
752
+ initKyc: oc.route({ method: "POST", path: "/fiat/kyc/init" }).input(InitKycInputSchema).output(KycStatusOutputSchema).errors({
753
+ EMAIL_NOT_LINKED: { status: 401, message: "Email not linked." },
754
+ BRIDGE_ERROR: { message: "Failed to create Bridge KYC link", status: 500 }
755
+ }),
756
+ getFees: oc.route({ method: "GET", path: "/fiat/fees" }).output(FeesOutputSchema).errors({}),
757
+ listBankAccounts: oc.route({ method: "GET", path: "/fiat/bank-accounts" }).output(BankAccountListOutputSchema).errors({
758
+ NOT_FOUND: { message: "Bridge customer ID not found", status: 404 }
759
+ }),
760
+ createBankAccount: oc.route({ method: "POST", path: "/fiat/bank-accounts" }).input(CreateBankAccountInputSchema).output(BankAccountSchema).errors({
761
+ NO_CUSTOMER: { message: "Bridge customer ID not found", status: 404 },
762
+ BRIDGE_ERROR: { message: "Failed to create Bridge KYC link", status: 500 }
763
+ }),
764
+ deleteBankAccount: oc.route({ method: "DELETE", path: "/fiat/bank-accounts/{id}" }).input(DeleteBankAccountInputSchema).output(DeleteBankAccountOutputSchema).errors({
765
+ NO_CUSTOMER: { message: "Bridge customer ID not found", status: 404 },
766
+ BRIDGE_ERROR: { message: "Failed to delete bank account", status: 500 }
767
+ }),
768
+ getSendQuote: oc.route({ method: "GET", path: "/fiat/quote/{id}" }).input(GetSendQuoteInputSchema).output(QuoteOutputSchema).errors({
769
+ BAD_REQUEST,
770
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter", status: 500 }
771
+ }),
772
+ sendFunds: oc.route({ method: "POST", path: "/fiat/send" }).input(SendFundsInputSchema).output(SendFundsOutputSchema).errors({
773
+ NOT_FOUND,
774
+ BRIDGE_ERROR: { message: "Failed to create Bridge transfer", status: 500 },
775
+ JUPITER_ERROR: { message: "Failed to get quote from Jupiter", status: 500 }
776
+ }),
777
+ updateTransfer: oc.route({ method: "PUT", path: "/fiat/transfer/{id}" }).input(UpdateTransferInputSchema).output(UpdateTransferOutputSchema).errors({
778
+ NOT_FOUND: { message: "Transfer not found", status: 404 }
779
+ })
780
+ });
781
+ var BridgeWebhookInputSchema = z.object({
782
+ type: z.string(),
783
+ kyc_link_id: z.string().optional(),
784
+ kyc_status: z.string().optional(),
785
+ tos_status: z.string().optional(),
786
+ customer_id: z.string().optional()
787
+ });
788
+ var BridgeWebhookOutputSchema = z.object({
789
+ success: z.boolean(),
790
+ error: z.string().optional()
791
+ });
780
792
 
781
- // src/contracts/index.ts
782
- var apiContract = {
793
+ // src/contracts/webhooks.ts
794
+ var webhooksContract = oc.tag("Webhooks").router({
795
+ bridge: oc.route({ method: "POST", path: "/webhooks/bridge" }).input(BridgeWebhookInputSchema).output(BridgeWebhookOutputSchema).errors({
796
+ NOT_FOUND,
797
+ INVALID_PAYLOAD: { message: "Invalid webhook payload", status: 400 }
798
+ })
799
+ });
800
+ var apiContract = oc.router({
783
801
  health: healthContract,
784
802
  tokens: tokensContract,
785
803
  hotspots: hotspotsContract,
786
804
  swap: swapContract,
787
805
  transactions: transactionsContract,
788
806
  welcomePacks: welcomePacksContract
789
- };
790
-
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
- }
807
+ });
808
+ var fullApiContract = oc.router({
809
+ ...apiContract,
810
+ fiat: fiatContract,
811
+ webhooks: webhooksContract
812
+ });
851
813
 
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 };
814
+ 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, HeliumPublicKeySchema, HotspotSchema, HotspotSharesSchema, HotspotTypeSchema, HotspotsDataSchema, INSUFFICIENT_FUNDS, INVALID_WALLET_ADDRESS, NOT_FOUND, OwnershipTypeSchema, PaginationInputSchema, PaginationOutputSchema, PayerBatchSummarySchema, PayerBatchesOutputSchema, PendingRewardsOutputSchema, PublicKeySchema, QuoteResponseSchema, RATE_LIMITED, ReassertLocationRequestSchema, ReassertLocationResponseSchema, 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 };