@helium/blockchain-api 0.1.2 → 0.2.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.
Files changed (51) hide show
  1. package/README.md +106 -49
  2. package/dist/index.d.ts +2382 -0
  3. package/dist/index.js +852 -0
  4. package/package.json +36 -126
  5. package/src/server/api/errors.ts +0 -152
  6. package/src/server/api/index.ts +0 -40
  7. package/src/server/api/procedures.ts +0 -144
  8. package/src/server/api/routers/fiat/router.ts +0 -709
  9. package/src/server/api/routers/fiat/schemas.ts +0 -169
  10. package/src/server/api/routers/health/router.ts +0 -41
  11. package/src/server/api/routers/hotspots/procedures/claimRewards.ts +0 -258
  12. package/src/server/api/routers/hotspots/procedures/createSplit.ts +0 -253
  13. package/src/server/api/routers/hotspots/procedures/deleteSplit.ts +0 -156
  14. package/src/server/api/routers/hotspots/procedures/getHotspots.ts +0 -31
  15. package/src/server/api/routers/hotspots/procedures/getPendingRewards.ts +0 -44
  16. package/src/server/api/routers/hotspots/procedures/getSplit.ts +0 -88
  17. package/src/server/api/routers/hotspots/procedures/transferHotspot.ts +0 -204
  18. package/src/server/api/routers/hotspots/procedures/updateRewardsDestination.ts +0 -201
  19. package/src/server/api/routers/hotspots/router.ts +0 -30
  20. package/src/server/api/routers/hotspots/schemas.ts +0 -182
  21. package/src/server/api/routers/swap/procedures/getInstructions.ts +0 -152
  22. package/src/server/api/routers/swap/procedures/getQuote.ts +0 -53
  23. package/src/server/api/routers/swap/procedures/getTokens.ts +0 -88
  24. package/src/server/api/routers/swap/router.ts +0 -15
  25. package/src/server/api/routers/swap/schemas.ts +0 -96
  26. package/src/server/api/routers/tokens/procedures/createHntAccount.ts +0 -87
  27. package/src/server/api/routers/tokens/procedures/getBalances.ts +0 -27
  28. package/src/server/api/routers/tokens/procedures/transfer.ts +0 -159
  29. package/src/server/api/routers/tokens/router.ts +0 -15
  30. package/src/server/api/routers/tokens/schemas.ts +0 -80
  31. package/src/server/api/routers/transactions/procedures/get.ts +0 -46
  32. package/src/server/api/routers/transactions/procedures/getByPayer.ts +0 -111
  33. package/src/server/api/routers/transactions/procedures/getByPayerAndTag.ts +0 -119
  34. package/src/server/api/routers/transactions/procedures/resubmit.ts +0 -68
  35. package/src/server/api/routers/transactions/procedures/submit.ts +0 -216
  36. package/src/server/api/routers/transactions/router.ts +0 -21
  37. package/src/server/api/routers/transactions/schemas.ts +0 -119
  38. package/src/server/api/routers/webhooks/router.ts +0 -75
  39. package/src/server/api/routers/welcomePacks/procedures/claim.ts +0 -157
  40. package/src/server/api/routers/welcomePacks/procedures/create.ts +0 -247
  41. package/src/server/api/routers/welcomePacks/procedures/deletePack.ts +0 -118
  42. package/src/server/api/routers/welcomePacks/procedures/get.ts +0 -36
  43. package/src/server/api/routers/welcomePacks/procedures/getByAddress.ts +0 -26
  44. package/src/server/api/routers/welcomePacks/procedures/invite.ts +0 -44
  45. package/src/server/api/routers/welcomePacks/procedures/list.ts +0 -27
  46. package/src/server/api/routers/welcomePacks/router.ts +0 -27
  47. package/src/server/api/routers/welcomePacks/schemas.ts +0 -135
  48. package/src/server/api/schemas.ts +0 -281
  49. package/tsconfig.json +0 -45
  50. package/types/README.md +0 -86
  51. package/types/index.ts +0 -27
package/dist/index.js ADDED
@@ -0,0 +1,852 @@
1
+ import { createORPCClient } from '@orpc/client';
2
+ import { RPCLink } from '@orpc/client/fetch';
3
+ import { z } from 'zod';
4
+
5
+ // src/client.ts
6
+ function createClient(options) {
7
+ const { url, transport = "rpc" } = options;
8
+ const endpoint = transport === "rpc" ? `${url}/rpc` : `${url}/api/v1`;
9
+ const link = new RPCLink({
10
+ url: endpoint,
11
+ fetch: (input, init) => {
12
+ return fetch(input, {
13
+ ...init,
14
+ credentials: "include"
15
+ });
16
+ }
17
+ });
18
+ return createORPCClient(link);
19
+ }
20
+
21
+ // src/mock-client.ts
22
+ function createMockClient(mocks = {}) {
23
+ const createProxy = (path = []) => {
24
+ return new Proxy(() => {
25
+ }, {
26
+ get(_, prop) {
27
+ const newPath = [...path, prop];
28
+ let mockValue = mocks;
29
+ for (const key of newPath) {
30
+ if (mockValue && typeof mockValue === "object" && key in mockValue) {
31
+ mockValue = mockValue[key];
32
+ } else {
33
+ mockValue = void 0;
34
+ break;
35
+ }
36
+ }
37
+ if (typeof mockValue === "function") {
38
+ return mockValue;
39
+ }
40
+ if (mockValue && typeof mockValue === "object") {
41
+ return createProxy(newPath);
42
+ }
43
+ return createProxy(newPath);
44
+ },
45
+ apply(_, __, args) {
46
+ let mockValue = mocks;
47
+ for (const key of path) {
48
+ if (mockValue && typeof mockValue === "object" && key in mockValue) {
49
+ mockValue = mockValue[key];
50
+ } else {
51
+ mockValue = void 0;
52
+ break;
53
+ }
54
+ }
55
+ if (typeof mockValue === "function") {
56
+ return mockValue(...args);
57
+ }
58
+ throw new Error(
59
+ `Mock not implemented for: ${path.join(".")}. Provide a mock implementation in createMockClient().`
60
+ );
61
+ }
62
+ });
63
+ };
64
+ return createProxy();
65
+ }
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
+ var TransactionMetadataSchema = z.object({
79
+ type: z.string(),
80
+ description: z.string()
81
+ }).catchall(z.unknown());
82
+ var TransactionItemSchema = z.object({
83
+ serializedTransaction: z.string(),
84
+ metadata: TransactionMetadataSchema.optional()
85
+ });
86
+ var TransactionDataSchema = z.object({
87
+ transactions: z.array(TransactionItemSchema),
88
+ parallel: z.boolean(),
89
+ tag: z.string().optional()
90
+ });
91
+ var TransactionBatchRequestSchema = z.object({
92
+ transactions: z.array(TransactionItemSchema),
93
+ parallel: z.boolean(),
94
+ tag: z.string().optional()
95
+ });
96
+ var TransactionBatchResponseSchema = z.object({
97
+ batchId: z.string(),
98
+ message: z.string().optional()
99
+ });
100
+ var ErrorResponseSchema = z.object({
101
+ error: z.string(),
102
+ details: z.array(z.string()).optional()
103
+ });
104
+ var WalletAddressSchema = z.string().min(32).max(44);
105
+ var PublicKeySchema = z.string().min(32).max(44);
106
+ var PaginationInputSchema = z.object({
107
+ page: z.coerce.number().int().min(1).default(1),
108
+ limit: z.coerce.number().int().min(1).max(100).default(10)
109
+ });
110
+ var PaginationOutputSchema = z.object({
111
+ total: z.number(),
112
+ page: z.number(),
113
+ totalPages: z.number()
114
+ });
115
+
116
+ // src/schemas/tokens.ts
117
+ var GetBalancesInputSchema = z.object({
118
+ walletAddress: z.string().min(32)
119
+ });
120
+ var TransferInputSchema = z.object({
121
+ walletAddress: z.string().min(32),
122
+ mint: z.string().nullable().optional(),
123
+ destination: z.string().min(32),
124
+ amount: z.string(),
125
+ decimals: z.number().optional()
126
+ });
127
+ var CreateHntAccountInputSchema = z.object({
128
+ walletAddress: z.string().min(32)
129
+ });
130
+ var TokenAccountSchema = z.object({
131
+ mint: z.string(),
132
+ address: z.string(),
133
+ balance: z.string(),
134
+ decimals: z.number(),
135
+ uiAmount: z.number(),
136
+ symbol: z.string().optional(),
137
+ name: z.string().optional(),
138
+ logoURI: z.string().optional(),
139
+ priceUsd: z.number().optional(),
140
+ balanceUsd: z.number().optional()
141
+ });
142
+ var TokenBalanceDataSchema = z.object({
143
+ totalBalanceUsd: z.number(),
144
+ solBalance: z.number(),
145
+ solBalanceUsd: z.number(),
146
+ tokens: z.array(TokenAccountSchema)
147
+ });
148
+ var TransferOutputSchema = z.object({
149
+ transactionData: TransactionDataSchema
150
+ });
151
+ var CreateHntAccountOutputSchema = z.object({
152
+ transactionData: TransactionDataSchema
153
+ });
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
+ var HotspotTypeSchema = z.enum(["iot", "mobile", "all"]);
184
+ var DeviceTypeSchema = z.enum([
185
+ "iot-gateway",
186
+ "wifiIndoor",
187
+ "wifiOutdoor",
188
+ "wifiDataOnly",
189
+ "cbrs"
190
+ ]);
191
+ var OwnershipTypeSchema = z.enum(["owner", "direct", "fanout", "all"]);
192
+ var HotspotSharesSchema = z.object({
193
+ fixed: z.string().optional(),
194
+ percentage: z.number().optional()
195
+ });
196
+ var HotspotSchema = z.object({
197
+ address: z.string(),
198
+ entityKey: z.string(),
199
+ name: z.string(),
200
+ type: HotspotTypeSchema,
201
+ deviceType: DeviceTypeSchema,
202
+ city: z.string().optional(),
203
+ state: z.string().optional(),
204
+ country: z.string().optional(),
205
+ asset: z.string(),
206
+ isOnline: z.boolean().optional(),
207
+ owner: z.string().optional(),
208
+ shares: HotspotSharesSchema.optional(),
209
+ ownershipType: z.string()
210
+ });
211
+ var GetHotspotsInputSchema = z.object({
212
+ walletAddress: z.string().min(32),
213
+ type: HotspotTypeSchema.optional(),
214
+ page: z.coerce.number().int().min(1).default(1),
215
+ limit: z.coerce.number().int().min(1).max(100).default(10)
216
+ });
217
+ var ClaimRewardsInputSchema = z.object({
218
+ walletAddress: z.string().min(32)
219
+ });
220
+ var GetPendingRewardsInputSchema = z.object({
221
+ walletAddress: z.string().min(32)
222
+ });
223
+ var TransferHotspotInputSchema = z.object({
224
+ walletAddress: z.string().min(32),
225
+ hotspotPubkey: z.string().min(1),
226
+ recipient: z.string().min(32)
227
+ });
228
+ var UpdateRewardsDestinationInputSchema = z.object({
229
+ walletAddress: z.string().min(32),
230
+ hotspotPubkey: z.string().min(1),
231
+ destination: z.string().min(32),
232
+ lazyDistributors: z.array(z.string().min(32)).min(1)
233
+ });
234
+ var GetSplitInputSchema = z.object({
235
+ walletAddress: z.string().min(32),
236
+ hotspotPubkey: z.string().min(1)
237
+ });
238
+ var RewardSplitInputSchema = z.object({
239
+ address: z.string().min(32),
240
+ type: z.enum(["percentage", "fixed"]),
241
+ amount: z.number()
242
+ });
243
+ var ScheduleInputSchema = z.object({
244
+ frequency: z.enum(["daily", "weekly", "monthly"]),
245
+ time: z.string(),
246
+ timezone: z.string(),
247
+ dayOfWeek: z.string().optional(),
248
+ dayOfMonth: z.string().optional()
249
+ });
250
+ var CreateSplitInputSchema = z.object({
251
+ walletAddress: z.string().min(32),
252
+ hotspotPubkey: z.string().min(1),
253
+ rewardsSplit: z.array(RewardSplitInputSchema),
254
+ schedule: ScheduleInputSchema,
255
+ lazyDistributor: z.string().min(32)
256
+ });
257
+ var DeleteSplitInputSchema = z.object({
258
+ walletAddress: z.string().min(32),
259
+ hotspotPubkey: z.string().min(1)
260
+ });
261
+ var HotspotsDataSchema = z.object({
262
+ hotspots: z.array(HotspotSchema),
263
+ total: z.number(),
264
+ page: z.number(),
265
+ totalPages: z.number()
266
+ });
267
+ var ClaimRewardsOutputSchema = z.object({
268
+ transactionData: TransactionDataSchema
269
+ });
270
+ var TransferHotspotOutputSchema = z.object({
271
+ transactionData: TransactionDataSchema
272
+ });
273
+ var UpdateRewardsDestinationOutputSchema = z.object({
274
+ transactionData: TransactionDataSchema
275
+ });
276
+ var SplitShareSchema = z.object({
277
+ wallet: z.string(),
278
+ delegate: z.string(),
279
+ fixed: z.number(),
280
+ shares: z.number()
281
+ });
282
+ var SplitResponseSchema = z.object({
283
+ walletAddress: z.string(),
284
+ hotspotPubkey: z.string(),
285
+ splitAddress: z.string(),
286
+ shares: z.array(SplitShareSchema)
287
+ });
288
+ var CreateSplitOutputSchema = z.object({
289
+ transactionData: TransactionDataSchema
290
+ });
291
+ var DeleteSplitOutputSchema = z.object({
292
+ transactionData: TransactionDataSchema
293
+ });
294
+ var PendingRewardsOutputSchema = z.object({
295
+ pending: z.string()
296
+ });
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
+ var GetTokensInputSchema = z.object({
425
+ limit: z.coerce.number().int().min(1).max(100).default(50)
426
+ });
427
+ var GetQuoteInputSchema = z.object({
428
+ inputMint: z.string().min(1),
429
+ outputMint: z.string().min(1),
430
+ amount: z.string().min(1),
431
+ swapMode: z.enum(["ExactIn", "ExactOut"]).default("ExactIn"),
432
+ slippageBps: z.coerce.number().min(0).max(1e4).default(50)
433
+ });
434
+ var QuoteResponseSchema = z.object({
435
+ inputMint: z.string(),
436
+ inAmount: z.string(),
437
+ outputMint: z.string(),
438
+ outAmount: z.string(),
439
+ otherAmountThreshold: z.string(),
440
+ swapMode: z.string(),
441
+ slippageBps: z.number(),
442
+ platformFee: z.unknown().optional(),
443
+ priceImpactPct: z.string(),
444
+ routePlan: z.array(z.unknown()),
445
+ contextSlot: z.number().optional(),
446
+ timeTaken: z.number().optional()
447
+ }).passthrough();
448
+ var GetInstructionsInputSchema = z.object({
449
+ quoteResponse: QuoteResponseSchema,
450
+ userPublicKey: z.string().min(1),
451
+ destinationTokenAccount: z.string().optional(),
452
+ dynamicComputeUnitLimit: z.boolean().default(true),
453
+ prioritizationFeeLamports: z.object({
454
+ priorityLevelWithMaxLamports: z.object({
455
+ maxLamports: z.number().default(1e6),
456
+ priorityLevel: z.enum(["low", "medium", "high"]).default("medium")
457
+ })
458
+ }).optional()
459
+ });
460
+ var TokenSchema = z.object({
461
+ address: z.string(),
462
+ symbol: z.string(),
463
+ name: z.string(),
464
+ decimals: z.number(),
465
+ logoURI: z.string().optional(),
466
+ tags: z.array(z.string()).optional()
467
+ });
468
+ var TokenListOutputSchema = z.object({
469
+ tokens: z.array(TokenSchema)
470
+ });
471
+ var SwapTransactionDataSchema = TransactionDataSchema;
472
+ var SubmitInputSchema = z.object({
473
+ transactions: z.array(TransactionItemSchema),
474
+ parallel: z.boolean(),
475
+ tag: z.string().optional()
476
+ });
477
+ var GetInputSchema = z.object({
478
+ id: z.string(),
479
+ commitment: z.enum(["confirmed", "finalized"])
480
+ });
481
+ var ResubmitInputSchema = z.object({
482
+ id: z.string()
483
+ });
484
+ var GetByPayerInputSchema = z.object({
485
+ payer: z.string().min(32),
486
+ page: z.coerce.number().int().min(1).default(1),
487
+ limit: z.coerce.number().int().min(1).max(100).default(20),
488
+ status: z.string().optional().default("pending")
489
+ });
490
+ var GetByPayerAndTagInputSchema = z.object({
491
+ payer: z.string().min(32),
492
+ tag: z.string(),
493
+ page: z.coerce.number().int().min(1).default(1),
494
+ limit: z.coerce.number().int().min(1).max(100).default(20),
495
+ status: z.string().optional().default("pending")
496
+ });
497
+ var SubmitOutputSchema = z.object({
498
+ batchId: z.string(),
499
+ message: z.string().optional()
500
+ });
501
+ var TransactionStatusSchema = z.object({
502
+ signature: z.string(),
503
+ status: z.string(),
504
+ transaction: z.unknown().optional()
505
+ });
506
+ var BatchStatusOutputSchema = z.object({
507
+ batchId: z.string(),
508
+ status: z.string(),
509
+ submissionType: z.string(),
510
+ parallel: z.boolean(),
511
+ transactions: z.array(TransactionStatusSchema),
512
+ jitoBundleId: z.string().optional(),
513
+ jitoBundleStatus: z.unknown().optional()
514
+ });
515
+ var ResubmitOutputSchema = z.object({
516
+ success: z.boolean(),
517
+ message: z.string(),
518
+ error: z.string().optional(),
519
+ newSignatures: z.array(z.string()).optional()
520
+ });
521
+ var PayerBatchSummarySchema = z.object({
522
+ batchId: z.string(),
523
+ tag: z.string().optional(),
524
+ status: z.string(),
525
+ submissionType: z.string(),
526
+ parallel: z.boolean(),
527
+ createdAt: z.string(),
528
+ updatedAt: z.string(),
529
+ transactions: z.array(
530
+ z.object({
531
+ metadata: TransactionMetadataSchema.optional()
532
+ })
533
+ )
534
+ });
535
+ var PayerBatchesOutputSchema = z.object({
536
+ payer: z.string(),
537
+ batches: z.array(PayerBatchSummarySchema),
538
+ pagination: z.object({
539
+ page: z.number(),
540
+ limit: z.number(),
541
+ total: z.number(),
542
+ totalPages: z.number()
543
+ })
544
+ });
545
+ var WelcomePackListInputSchema = z.object({
546
+ walletAddress: z.string().min(32)
547
+ });
548
+ var WelcomePackCreateInputSchema = z.object({
549
+ walletAddress: z.string().min(32),
550
+ assetId: z.string(),
551
+ solAmount: z.number(),
552
+ rentRefund: z.string(),
553
+ assetReturnAddress: z.string(),
554
+ rewardsSplit: z.array(RewardSplitInputSchema),
555
+ schedule: ScheduleInputSchema,
556
+ lazyDistributor: z.string()
557
+ });
558
+ var WelcomePackGetInputSchema = z.object({
559
+ walletAddress: z.string().min(32),
560
+ packId: z.number()
561
+ });
562
+ var WelcomePackDeleteInputSchema = z.object({
563
+ walletAddress: z.string().min(32),
564
+ packId: z.number()
565
+ });
566
+ var WelcomePackGetByAddressInputSchema = z.object({
567
+ packAddress: z.string().min(32)
568
+ });
569
+ var WelcomePackClaimInputSchema = z.object({
570
+ packAddress: z.string().min(32),
571
+ walletAddress: z.string().min(32),
572
+ signature: z.string(),
573
+ expirationTs: z.string()
574
+ });
575
+ var WelcomePackInviteInputSchema = z.object({
576
+ packAddress: z.string().min(32),
577
+ walletAddress: z.string().min(32),
578
+ expirationDays: z.number().int().positive().max(365).default(7)
579
+ });
580
+ var WelcomePackSchema = z.object({
581
+ address: z.string(),
582
+ id: z.number(),
583
+ owner: z.string(),
584
+ asset: z.string(),
585
+ lazyDistributor: z.string(),
586
+ rewardsMint: z.string(),
587
+ rentRefund: z.string(),
588
+ solAmount: z.string(),
589
+ rewardsSplit: z.array(RewardSplitInputSchema),
590
+ rewardsSchedule: z.string(),
591
+ assetReturnAddress: z.string(),
592
+ bumpSeed: z.number(),
593
+ uniqueId: z.string(),
594
+ loading: z.boolean().optional(),
595
+ hotspot: HotspotSchema.nullable()
596
+ });
597
+ var WelcomePackListOutputSchema = z.array(WelcomePackSchema);
598
+ var WelcomePackCreateOutputSchema = z.object({
599
+ welcomePack: WelcomePackSchema,
600
+ transactionData: TransactionDataSchema
601
+ });
602
+ var WelcomePackDeleteOutputSchema = z.object({
603
+ transactionData: TransactionDataSchema
604
+ });
605
+ var WelcomePackClaimOutputSchema = z.object({
606
+ transactionData: TransactionDataSchema
607
+ });
608
+ var WelcomePackInviteOutputSchema = z.object({
609
+ message: z.string(),
610
+ expirationTs: z.number()
611
+ });
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
+ }
639
+ };
640
+ var INSUFFICIENT_FUNDS = {
641
+ status: 400,
642
+ message: "Insufficient SOL balance to complete this transaction.",
643
+ data: z.object({
644
+ required: z.number(),
645
+ available: z.number()
646
+ })
647
+ };
648
+ var TRANSACTION_FAILED = {
649
+ status: 500,
650
+ message: "Transaction failed to execute.",
651
+ data: z.object({
652
+ logs: z.array(z.string()).optional(),
653
+ signature: z.string().optional()
654
+ })
655
+ };
656
+ var SIMULATION_FAILED = {
657
+ status: 400,
658
+ message: "Transaction simulation failed.",
659
+ data: z.object({
660
+ logs: z.array(z.string()).optional(),
661
+ link: z.string().optional()
662
+ })
663
+ };
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
+ };
780
+
781
+ // src/contracts/index.ts
782
+ var apiContract = {
783
+ health: healthContract,
784
+ tokens: tokensContract,
785
+ hotspots: hotspotsContract,
786
+ swap: swapContract,
787
+ transactions: transactionsContract,
788
+ 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
+ }
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 };