@helium/blockchain-api 0.1.3 → 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.
package/dist/index.js ADDED
@@ -0,0 +1,805 @@
1
+ import { createORPCClient } from '@orpc/client';
2
+ import { RPCLink } from '@orpc/client/fetch';
3
+ import { z } from 'zod';
4
+ import { oc } from '@orpc/contract';
5
+
6
+ // src/client.ts
7
+ function createClient(options) {
8
+ const { url, transport = "rpc" } = options;
9
+ const endpoint = transport === "rpc" ? `${url}/rpc` : `${url}/api/v1`;
10
+ const link = new RPCLink({
11
+ url: endpoint,
12
+ fetch: (input, init) => {
13
+ return fetch(input, {
14
+ ...init,
15
+ credentials: "include"
16
+ });
17
+ }
18
+ });
19
+ return createORPCClient(link);
20
+ }
21
+
22
+ // src/mock-client.ts
23
+ function createMockClient(mocks = {}) {
24
+ const createProxy = (path = []) => {
25
+ return new Proxy(() => {
26
+ }, {
27
+ get(_, prop) {
28
+ const newPath = [...path, prop];
29
+ let mockValue = mocks;
30
+ for (const key of newPath) {
31
+ if (mockValue && typeof mockValue === "object" && key in mockValue) {
32
+ mockValue = mockValue[key];
33
+ } else {
34
+ mockValue = void 0;
35
+ break;
36
+ }
37
+ }
38
+ if (typeof mockValue === "function") {
39
+ return mockValue;
40
+ }
41
+ if (mockValue && typeof mockValue === "object") {
42
+ return createProxy(newPath);
43
+ }
44
+ return createProxy(newPath);
45
+ },
46
+ apply(_, __, args) {
47
+ let mockValue = mocks;
48
+ for (const key of path) {
49
+ if (mockValue && typeof mockValue === "object" && key in mockValue) {
50
+ mockValue = mockValue[key];
51
+ } else {
52
+ mockValue = void 0;
53
+ break;
54
+ }
55
+ }
56
+ if (typeof mockValue === "function") {
57
+ return mockValue(...args);
58
+ }
59
+ throw new Error(
60
+ `Mock not implemented for: ${path.join(".")}. Provide a mock implementation in createMockClient().`
61
+ );
62
+ }
63
+ });
64
+ };
65
+ return createProxy();
66
+ }
67
+ var TransactionMetadataSchema = z.object({
68
+ type: z.string(),
69
+ description: z.string()
70
+ }).catchall(z.unknown());
71
+ var TransactionItemSchema = z.object({
72
+ serializedTransaction: z.string(),
73
+ metadata: TransactionMetadataSchema.optional()
74
+ });
75
+ var TransactionDataSchema = z.object({
76
+ transactions: z.array(TransactionItemSchema),
77
+ parallel: z.boolean(),
78
+ tag: z.string().optional()
79
+ });
80
+ var TransactionBatchRequestSchema = z.object({
81
+ transactions: z.array(TransactionItemSchema),
82
+ parallel: z.boolean(),
83
+ tag: z.string().optional()
84
+ });
85
+ var TransactionBatchResponseSchema = z.object({
86
+ batchId: z.string(),
87
+ message: z.string().optional()
88
+ });
89
+ var ErrorResponseSchema = z.object({
90
+ error: z.string(),
91
+ details: z.array(z.string()).optional()
92
+ });
93
+ var WalletAddressSchema = z.string().min(32).max(44);
94
+ var PublicKeySchema = z.string().min(32).max(44);
95
+ var PaginationInputSchema = z.object({
96
+ page: z.coerce.number().int().min(1).default(1),
97
+ limit: z.coerce.number().int().min(1).max(100).default(10)
98
+ });
99
+ var PaginationOutputSchema = z.object({
100
+ total: z.number(),
101
+ page: z.number(),
102
+ totalPages: z.number()
103
+ });
104
+ var HealthResponseSchema = z.object({
105
+ ok: z.boolean(),
106
+ error: z.string().optional()
107
+ });
108
+ var GetBalancesInputSchema = z.object({
109
+ walletAddress: z.string().min(32)
110
+ });
111
+ var TransferInputSchema = z.object({
112
+ walletAddress: z.string().min(32),
113
+ mint: z.string().nullable().optional(),
114
+ destination: z.string().min(32),
115
+ amount: z.string(),
116
+ decimals: z.number().optional()
117
+ });
118
+ var CreateHntAccountInputSchema = z.object({
119
+ walletAddress: z.string().min(32)
120
+ });
121
+ var TokenAccountSchema = z.object({
122
+ mint: z.string(),
123
+ address: z.string(),
124
+ balance: z.string(),
125
+ decimals: z.number(),
126
+ uiAmount: z.number(),
127
+ symbol: z.string().optional(),
128
+ name: z.string().optional(),
129
+ logoURI: z.string().optional(),
130
+ priceUsd: z.number().optional(),
131
+ balanceUsd: z.number().optional()
132
+ });
133
+ var TokenBalanceDataSchema = z.object({
134
+ totalBalanceUsd: z.number(),
135
+ solBalance: z.number(),
136
+ solBalanceUsd: z.number(),
137
+ tokens: z.array(TokenAccountSchema)
138
+ });
139
+ var TransferOutputSchema = z.object({
140
+ transactionData: TransactionDataSchema
141
+ });
142
+ var CreateHntAccountOutputSchema = z.object({
143
+ transactionData: TransactionDataSchema
144
+ });
145
+ var HotspotTypeSchema = z.enum(["iot", "mobile", "all"]);
146
+ var DeviceTypeSchema = z.enum([
147
+ "iot-gateway",
148
+ "wifiIndoor",
149
+ "wifiOutdoor",
150
+ "wifiDataOnly",
151
+ "cbrs"
152
+ ]);
153
+ var OwnershipTypeSchema = z.enum(["owner", "direct", "fanout", "all"]);
154
+ var HotspotSharesSchema = z.object({
155
+ fixed: z.string().optional(),
156
+ percentage: z.number().optional()
157
+ });
158
+ var HotspotSchema = z.object({
159
+ address: z.string(),
160
+ entityKey: z.string(),
161
+ name: z.string(),
162
+ type: HotspotTypeSchema,
163
+ deviceType: DeviceTypeSchema,
164
+ city: z.string().optional(),
165
+ state: z.string().optional(),
166
+ country: z.string().optional(),
167
+ asset: z.string(),
168
+ isOnline: z.boolean().optional(),
169
+ owner: z.string().optional(),
170
+ shares: HotspotSharesSchema.optional(),
171
+ ownershipType: z.string()
172
+ });
173
+ var GetHotspotsInputSchema = z.object({
174
+ walletAddress: z.string().min(32),
175
+ type: HotspotTypeSchema.optional(),
176
+ page: z.coerce.number().int().min(1).default(1),
177
+ limit: z.coerce.number().int().min(1).max(100).default(10)
178
+ });
179
+ var ClaimRewardsInputSchema = z.object({
180
+ walletAddress: z.string().min(32)
181
+ });
182
+ var GetPendingRewardsInputSchema = z.object({
183
+ walletAddress: z.string().min(32)
184
+ });
185
+ var TransferHotspotInputSchema = z.object({
186
+ walletAddress: z.string().min(32),
187
+ hotspotPubkey: z.string().min(1),
188
+ recipient: z.string().min(32)
189
+ });
190
+ var UpdateRewardsDestinationInputSchema = z.object({
191
+ walletAddress: z.string().min(32),
192
+ hotspotPubkey: z.string().min(1),
193
+ destination: z.string().min(32),
194
+ lazyDistributors: z.array(z.string().min(32)).min(1)
195
+ });
196
+ var GetSplitInputSchema = z.object({
197
+ walletAddress: z.string().min(32),
198
+ hotspotPubkey: z.string().min(1)
199
+ });
200
+ var RewardSplitInputSchema = z.object({
201
+ address: z.string().min(32),
202
+ type: z.enum(["percentage", "fixed"]),
203
+ amount: z.number()
204
+ });
205
+ var ScheduleInputSchema = z.object({
206
+ frequency: z.enum(["daily", "weekly", "monthly"]),
207
+ time: z.string(),
208
+ timezone: z.string(),
209
+ dayOfWeek: z.string().optional(),
210
+ dayOfMonth: z.string().optional()
211
+ });
212
+ var CreateSplitInputSchema = z.object({
213
+ walletAddress: z.string().min(32),
214
+ hotspotPubkey: z.string().min(1),
215
+ rewardsSplit: z.array(RewardSplitInputSchema),
216
+ schedule: ScheduleInputSchema,
217
+ lazyDistributor: z.string().min(32)
218
+ });
219
+ var DeleteSplitInputSchema = z.object({
220
+ walletAddress: z.string().min(32),
221
+ hotspotPubkey: z.string().min(1)
222
+ });
223
+ var HotspotsDataSchema = z.object({
224
+ hotspots: z.array(HotspotSchema),
225
+ total: z.number(),
226
+ page: z.number(),
227
+ totalPages: z.number()
228
+ });
229
+ var ClaimRewardsOutputSchema = z.object({
230
+ transactionData: TransactionDataSchema
231
+ });
232
+ var TransferHotspotOutputSchema = z.object({
233
+ transactionData: TransactionDataSchema
234
+ });
235
+ var UpdateRewardsDestinationOutputSchema = z.object({
236
+ transactionData: TransactionDataSchema
237
+ });
238
+ var SplitShareSchema = z.object({
239
+ wallet: z.string(),
240
+ delegate: z.string(),
241
+ fixed: z.number(),
242
+ shares: z.number()
243
+ });
244
+ var SplitResponseSchema = z.object({
245
+ walletAddress: z.string(),
246
+ hotspotPubkey: z.string(),
247
+ splitAddress: z.string(),
248
+ shares: z.array(SplitShareSchema)
249
+ });
250
+ var CreateSplitOutputSchema = z.object({
251
+ transactionData: TransactionDataSchema
252
+ });
253
+ var DeleteSplitOutputSchema = z.object({
254
+ transactionData: TransactionDataSchema
255
+ });
256
+ var PendingRewardsOutputSchema = z.object({
257
+ pending: z.string()
258
+ });
259
+ var GetTokensInputSchema = z.object({
260
+ limit: z.coerce.number().int().min(1).max(100).default(50)
261
+ });
262
+ var GetQuoteInputSchema = z.object({
263
+ inputMint: z.string().min(1),
264
+ outputMint: z.string().min(1),
265
+ amount: z.string().min(1),
266
+ swapMode: z.enum(["ExactIn", "ExactOut"]).default("ExactIn"),
267
+ slippageBps: z.coerce.number().min(0).max(1e4).default(50)
268
+ });
269
+ var QuoteResponseSchema = z.object({
270
+ inputMint: z.string(),
271
+ inAmount: z.string(),
272
+ outputMint: z.string(),
273
+ outAmount: z.string(),
274
+ otherAmountThreshold: z.string(),
275
+ swapMode: z.string(),
276
+ slippageBps: z.number(),
277
+ platformFee: z.unknown().optional(),
278
+ priceImpactPct: z.string(),
279
+ routePlan: z.array(z.unknown()),
280
+ contextSlot: z.number().optional(),
281
+ timeTaken: z.number().optional()
282
+ }).passthrough();
283
+ var GetInstructionsInputSchema = z.object({
284
+ quoteResponse: QuoteResponseSchema,
285
+ userPublicKey: z.string().min(1),
286
+ destinationTokenAccount: z.string().optional(),
287
+ dynamicComputeUnitLimit: z.boolean().default(true),
288
+ prioritizationFeeLamports: z.object({
289
+ priorityLevelWithMaxLamports: z.object({
290
+ maxLamports: z.number().default(1e6),
291
+ priorityLevel: z.enum(["low", "medium", "high"]).default("medium")
292
+ })
293
+ }).optional()
294
+ });
295
+ var TokenSchema = z.object({
296
+ address: z.string(),
297
+ symbol: z.string(),
298
+ name: z.string(),
299
+ decimals: z.number(),
300
+ logoURI: z.string().optional(),
301
+ tags: z.array(z.string()).optional()
302
+ });
303
+ var TokenListOutputSchema = z.object({
304
+ tokens: z.array(TokenSchema)
305
+ });
306
+ var SwapTransactionDataSchema = TransactionDataSchema;
307
+ var SubmitInputSchema = z.object({
308
+ transactions: z.array(TransactionItemSchema),
309
+ parallel: z.boolean(),
310
+ tag: z.string().optional()
311
+ });
312
+ var GetInputSchema = z.object({
313
+ id: z.string(),
314
+ commitment: z.enum(["confirmed", "finalized"])
315
+ });
316
+ var ResubmitInputSchema = z.object({
317
+ id: z.string()
318
+ });
319
+ var GetByPayerInputSchema = z.object({
320
+ payer: z.string().min(32),
321
+ page: z.coerce.number().int().min(1).default(1),
322
+ limit: z.coerce.number().int().min(1).max(100).default(20),
323
+ status: z.string().optional().default("pending")
324
+ });
325
+ var GetByPayerAndTagInputSchema = z.object({
326
+ payer: z.string().min(32),
327
+ tag: z.string(),
328
+ page: z.coerce.number().int().min(1).default(1),
329
+ limit: z.coerce.number().int().min(1).max(100).default(20),
330
+ status: z.string().optional().default("pending")
331
+ });
332
+ var SubmitOutputSchema = z.object({
333
+ batchId: z.string(),
334
+ message: z.string().optional()
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
+ ]);
343
+ var TransactionStatusSchema = z.object({
344
+ signature: z.string(),
345
+ status: TransactionStateSchema,
346
+ transaction: z.unknown().optional()
347
+ });
348
+ var BatchStatusOutputSchema = z.object({
349
+ batchId: 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
+ ]),
357
+ parallel: z.boolean(),
358
+ transactions: z.array(TransactionStatusSchema),
359
+ jitoBundleId: z.string().optional().nullable(),
360
+ jitoBundleStatus: z.unknown().optional().nullable()
361
+ });
362
+ var ResubmitOutputSchema = z.object({
363
+ success: z.boolean(),
364
+ message: z.string(),
365
+ error: z.string().optional(),
366
+ newSignatures: z.array(z.string()).optional()
367
+ });
368
+ var PayerBatchSummarySchema = z.object({
369
+ batchId: z.string(),
370
+ tag: z.string().optional(),
371
+ status: z.string(),
372
+ submissionType: z.string(),
373
+ parallel: z.boolean(),
374
+ createdAt: z.string(),
375
+ updatedAt: z.string(),
376
+ transactions: z.array(
377
+ z.object({
378
+ metadata: TransactionMetadataSchema.optional()
379
+ })
380
+ )
381
+ });
382
+ var PayerBatchesOutputSchema = z.object({
383
+ payer: z.string(),
384
+ batches: z.array(PayerBatchSummarySchema),
385
+ pagination: z.object({
386
+ page: z.number(),
387
+ limit: z.number(),
388
+ total: z.number(),
389
+ totalPages: z.number()
390
+ })
391
+ });
392
+ var WelcomePackListInputSchema = z.object({
393
+ walletAddress: z.string().min(32)
394
+ });
395
+ var WelcomePackCreateInputSchema = z.object({
396
+ walletAddress: z.string().min(32),
397
+ assetId: z.string(),
398
+ solAmount: z.number(),
399
+ rentRefund: z.string(),
400
+ assetReturnAddress: z.string(),
401
+ rewardsSplit: z.array(RewardSplitInputSchema),
402
+ schedule: ScheduleInputSchema,
403
+ lazyDistributor: z.string()
404
+ });
405
+ var WelcomePackGetInputSchema = z.object({
406
+ walletAddress: z.string().min(32),
407
+ packId: z.number()
408
+ });
409
+ var WelcomePackDeleteInputSchema = z.object({
410
+ walletAddress: z.string().min(32),
411
+ packId: z.number()
412
+ });
413
+ var WelcomePackGetByAddressInputSchema = z.object({
414
+ packAddress: z.string().min(32)
415
+ });
416
+ var WelcomePackClaimInputSchema = z.object({
417
+ packAddress: z.string().min(32),
418
+ walletAddress: z.string().min(32),
419
+ signature: z.string(),
420
+ expirationTs: z.string()
421
+ });
422
+ var WelcomePackInviteInputSchema = z.object({
423
+ packAddress: z.string().min(32),
424
+ walletAddress: z.string().min(32),
425
+ expirationDays: z.number().int().positive().max(365).default(7)
426
+ });
427
+ var WelcomePackSchema = z.object({
428
+ address: z.string(),
429
+ id: z.number(),
430
+ owner: z.string(),
431
+ asset: z.string(),
432
+ lazyDistributor: z.string(),
433
+ rewardsMint: z.string(),
434
+ rentRefund: z.string(),
435
+ solAmount: z.string(),
436
+ rewardsSplit: z.array(RewardSplitInputSchema),
437
+ rewardsSchedule: z.string(),
438
+ assetReturnAddress: z.string(),
439
+ bumpSeed: z.number(),
440
+ uniqueId: z.string(),
441
+ loading: z.boolean().optional(),
442
+ hotspot: HotspotSchema.nullable()
443
+ });
444
+ var WelcomePackListOutputSchema = z.array(WelcomePackSchema);
445
+ var WelcomePackCreateOutputSchema = z.object({
446
+ welcomePack: WelcomePackSchema,
447
+ transactionData: TransactionDataSchema
448
+ });
449
+ var WelcomePackDeleteOutputSchema = z.object({
450
+ transactionData: TransactionDataSchema
451
+ });
452
+ var WelcomePackClaimOutputSchema = z.object({
453
+ transactionData: TransactionDataSchema
454
+ });
455
+ var WelcomePackInviteOutputSchema = z.object({
456
+ message: z.string(),
457
+ expirationTs: z.number()
458
+ });
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."
485
+ };
486
+ var INSUFFICIENT_FUNDS = {
487
+ status: 400,
488
+ message: "Insufficient SOL balance to complete this transaction.",
489
+ data: z.object({
490
+ required: z.number(),
491
+ available: z.number()
492
+ })
493
+ };
494
+ var TRANSACTION_FAILED = {
495
+ status: 500,
496
+ message: "Transaction failed to execute.",
497
+ data: z.object({
498
+ logs: z.array(z.string()).optional(),
499
+ signature: z.string().optional()
500
+ })
501
+ };
502
+ var SIMULATION_FAILED = {
503
+ status: 400,
504
+ message: "Transaction simulation failed.",
505
+ data: z.object({
506
+ logs: z.array(z.string()).optional(),
507
+ link: z.string().optional()
508
+ })
509
+ };
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
+ })
588
+ };
589
+
590
+ // src/contracts/transactions.ts
591
+ var transactionsContract = {
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
+ })
610
+ };
611
+
612
+ // src/contracts/welcome-packs.ts
613
+ var welcomePacksContract = {
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
+ })
788
+ };
789
+
790
+ // src/contracts/index.ts
791
+ var apiContract = {
792
+ health: healthContract,
793
+ tokens: tokensContract,
794
+ hotspots: hotspotsContract,
795
+ swap: swapContract,
796
+ transactions: transactionsContract,
797
+ welcomePacks: welcomePacksContract
798
+ };
799
+ var fullApiContract = {
800
+ ...apiContract,
801
+ fiat: fiatContract,
802
+ webhooks: webhooksContract
803
+ };
804
+
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 };