@helium/blockchain-api 0.1.2 → 0.1.3

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 (52) hide show
  1. package/README.md +24 -2
  2. package/package.json +31 -31
  3. package/types/README.md +24 -2
  4. package/types/generated/index.d.mts +2481 -0
  5. package/types/generated/index.d.ts +2481 -0
  6. package/types/generated/index.js +723 -0
  7. package/types/generated/index.mjs +614 -0
  8. package/types/index.ts +11 -8
  9. package/src/server/api/errors.ts +0 -152
  10. package/src/server/api/index.ts +0 -40
  11. package/src/server/api/procedures.ts +0 -144
  12. package/src/server/api/routers/fiat/router.ts +0 -709
  13. package/src/server/api/routers/fiat/schemas.ts +0 -169
  14. package/src/server/api/routers/health/router.ts +0 -41
  15. package/src/server/api/routers/hotspots/procedures/claimRewards.ts +0 -258
  16. package/src/server/api/routers/hotspots/procedures/createSplit.ts +0 -253
  17. package/src/server/api/routers/hotspots/procedures/deleteSplit.ts +0 -156
  18. package/src/server/api/routers/hotspots/procedures/getHotspots.ts +0 -31
  19. package/src/server/api/routers/hotspots/procedures/getPendingRewards.ts +0 -44
  20. package/src/server/api/routers/hotspots/procedures/getSplit.ts +0 -88
  21. package/src/server/api/routers/hotspots/procedures/transferHotspot.ts +0 -204
  22. package/src/server/api/routers/hotspots/procedures/updateRewardsDestination.ts +0 -201
  23. package/src/server/api/routers/hotspots/router.ts +0 -30
  24. package/src/server/api/routers/hotspots/schemas.ts +0 -182
  25. package/src/server/api/routers/swap/procedures/getInstructions.ts +0 -152
  26. package/src/server/api/routers/swap/procedures/getQuote.ts +0 -53
  27. package/src/server/api/routers/swap/procedures/getTokens.ts +0 -88
  28. package/src/server/api/routers/swap/router.ts +0 -15
  29. package/src/server/api/routers/swap/schemas.ts +0 -96
  30. package/src/server/api/routers/tokens/procedures/createHntAccount.ts +0 -87
  31. package/src/server/api/routers/tokens/procedures/getBalances.ts +0 -27
  32. package/src/server/api/routers/tokens/procedures/transfer.ts +0 -159
  33. package/src/server/api/routers/tokens/router.ts +0 -15
  34. package/src/server/api/routers/tokens/schemas.ts +0 -80
  35. package/src/server/api/routers/transactions/procedures/get.ts +0 -46
  36. package/src/server/api/routers/transactions/procedures/getByPayer.ts +0 -111
  37. package/src/server/api/routers/transactions/procedures/getByPayerAndTag.ts +0 -119
  38. package/src/server/api/routers/transactions/procedures/resubmit.ts +0 -68
  39. package/src/server/api/routers/transactions/procedures/submit.ts +0 -216
  40. package/src/server/api/routers/transactions/router.ts +0 -21
  41. package/src/server/api/routers/transactions/schemas.ts +0 -119
  42. package/src/server/api/routers/webhooks/router.ts +0 -75
  43. package/src/server/api/routers/welcomePacks/procedures/claim.ts +0 -157
  44. package/src/server/api/routers/welcomePacks/procedures/create.ts +0 -247
  45. package/src/server/api/routers/welcomePacks/procedures/deletePack.ts +0 -118
  46. package/src/server/api/routers/welcomePacks/procedures/get.ts +0 -36
  47. package/src/server/api/routers/welcomePacks/procedures/getByAddress.ts +0 -26
  48. package/src/server/api/routers/welcomePacks/procedures/invite.ts +0 -44
  49. package/src/server/api/routers/welcomePacks/procedures/list.ts +0 -27
  50. package/src/server/api/routers/welcomePacks/router.ts +0 -27
  51. package/src/server/api/routers/welcomePacks/schemas.ts +0 -135
  52. package/src/server/api/schemas.ts +0 -281
@@ -1,36 +0,0 @@
1
- import { publicProcedure } from "../../../procedures";
2
- import { GetInputSchema, WelcomePackSchema } from "../schemas";
3
- import { getWelcomePackByAddress } from "@/lib/queries/welcome-packs";
4
- import { welcomePackKey } from "@helium/welcome-pack-sdk";
5
- import { PublicKey } from "@solana/web3.js";
6
-
7
- /**
8
- * Get a welcome pack by wallet address and pack ID.
9
- */
10
- export const get = publicProcedure
11
- .route({
12
- method: "GET",
13
- path: "/welcome-packs/wallet/{walletAddress}/{packId}",
14
- })
15
- .input(GetInputSchema)
16
- .output(WelcomePackSchema)
17
- .errors({
18
- NOT_FOUND: { message: "Welcome pack not found" },
19
- })
20
- .handler(async ({ input, errors }) => {
21
- const { walletAddress, packId } = input;
22
-
23
- // Derive the welcome pack address from wallet and packId
24
- const welcomePackAddress = welcomePackKey(
25
- new PublicKey(walletAddress),
26
- Number(packId),
27
- )[0].toBase58();
28
-
29
- const pack = await getWelcomePackByAddress(welcomePackAddress);
30
-
31
- if (!pack) {
32
- throw errors.NOT_FOUND({ message: "Welcome pack not found" });
33
- }
34
-
35
- return pack;
36
- });
@@ -1,26 +0,0 @@
1
- import { publicProcedure } from "../../../procedures";
2
- import { GetByAddressInputSchema, WelcomePackSchema } from "../schemas";
3
- import { ORPCError } from "@orpc/server";
4
- import { getWelcomePackByAddress } from "@/lib/queries/welcome-packs";
5
-
6
- /**
7
- * Get a welcome pack by its address.
8
- */
9
- export const getByAddress = publicProcedure
10
- .route({ method: "GET", path: "/welcome-packs/{packAddress}" })
11
- .input(GetByAddressInputSchema)
12
- .output(WelcomePackSchema)
13
- .errors({
14
- NOT_FOUND: { message: "Welcome pack not found" },
15
- })
16
- .handler(async ({ input, errors }) => {
17
- const { packAddress } = input;
18
-
19
- const pack = await getWelcomePackByAddress(packAddress);
20
-
21
- if (!pack) {
22
- throw errors.NOT_FOUND({ message: "Welcome pack not found" });
23
- }
24
-
25
- return pack;
26
- });
@@ -1,44 +0,0 @@
1
- import { publicProcedure } from "../../../procedures";
2
- import { InviteInputSchema, InviteOutputSchema } from "../schemas";
3
- import { ORPCError } from "@orpc/server";
4
- import { createSolanaConnection } from "@/lib/solana";
5
- import { init as initWelcomePack } from "@helium/welcome-pack-sdk";
6
- import { PublicKey } from "@solana/web3.js";
7
-
8
- /**
9
- * Generate an invite message to be signed for a welcome pack.
10
- */
11
- export const invite = publicProcedure
12
- .route({
13
- method: "POST",
14
- path: "/welcome-packs/{packAddress}/invite/{walletAddress}",
15
- })
16
- .input(InviteInputSchema)
17
- .output(InviteOutputSchema)
18
- .errors({
19
- BAD_REQUEST: { message: "Invalid request" },
20
- })
21
- .handler(async ({ input, errors }) => {
22
- const { packAddress, walletAddress, expirationDays } = input;
23
-
24
- if (!packAddress || !walletAddress) {
25
- throw errors.BAD_REQUEST({
26
- message: "Pack address and wallet address are required",
27
- });
28
- }
29
-
30
- // Load uniqueId from on-chain welcome pack account
31
- const { provider } = createSolanaConnection(walletAddress);
32
- const program = await initWelcomePack(provider);
33
- const welcomePack = await program.account.welcomePackV0.fetch(
34
- new PublicKey(packAddress),
35
- );
36
- const uniqueId = welcomePack.uniqueId.toString();
37
- const expirationTs =
38
- Math.floor(Date.now() / 1000) + expirationDays * 24 * 60 * 60;
39
-
40
- // Keep the canonical message format aligned with client expectations
41
- const message = `Approve invite ${uniqueId} expiring ${expirationTs}`;
42
-
43
- return { message, expirationTs };
44
- });
@@ -1,27 +0,0 @@
1
- import { publicProcedure } from "../../../procedures";
2
- import { ListInputSchema, ListOutputSchema } from "../schemas";
3
- import { ORPCError } from "@orpc/server";
4
- import { getWelcomePacksByOwner } from "@/lib/queries/welcome-packs";
5
-
6
- /**
7
- * List all welcome packs for a wallet.
8
- */
9
- export const list = publicProcedure
10
- .route({ method: "GET", path: "/welcome-packs/wallet/{walletAddress}" })
11
- .input(ListInputSchema)
12
- .output(ListOutputSchema)
13
- .errors({
14
- BAD_REQUEST: { message: "Wallet address is required" },
15
- })
16
- .handler(async ({ input }) => {
17
- const { walletAddress } = input;
18
-
19
- if (!walletAddress) {
20
- throw new ORPCError("BAD_REQUEST", {
21
- message: "Wallet address is required",
22
- });
23
- }
24
-
25
- const packs = await getWelcomePacksByOwner(walletAddress);
26
- return packs;
27
- });
@@ -1,27 +0,0 @@
1
- import { list } from "./procedures/list";
2
- import { create } from "./procedures/create";
3
- import { get } from "./procedures/get";
4
- import { deletePack } from "./procedures/deletePack";
5
- import { getByAddress } from "./procedures/getByAddress";
6
- import { claim } from "./procedures/claim";
7
- import { invite } from "./procedures/invite";
8
-
9
- /**
10
- * Welcome Packs router - handles welcome pack operations.
11
- */
12
- export const welcomePacksRouter = {
13
- /** List all welcome packs for a wallet */
14
- list,
15
- /** Create a new welcome pack */
16
- create,
17
- /** Get a welcome pack by wallet and pack ID */
18
- get,
19
- /** Delete a welcome pack */
20
- delete: deletePack,
21
- /** Get a welcome pack by its address */
22
- getByAddress,
23
- /** Claim a welcome pack */
24
- claim,
25
- /** Generate an invite message for a welcome pack */
26
- invite,
27
- };
@@ -1,135 +0,0 @@
1
- import { z } from "zod";
2
- import { HotspotSchema } from "@/server/api/schemas";
3
-
4
- // ============================================================================
5
- // Input Schemas
6
- // ============================================================================
7
-
8
- export const ListInputSchema = z.object({
9
- walletAddress: z.string().min(32),
10
- });
11
-
12
- export const RewardSplitInputSchema = z.object({
13
- address: z.string(),
14
- type: z.enum(["percentage", "fixed"]),
15
- amount: z.number(),
16
- });
17
-
18
- export const ScheduleInputSchema = z.object({
19
- frequency: z.enum(["daily", "weekly", "monthly"]),
20
- time: z.string(),
21
- timezone: z.string(),
22
- dayOfWeek: z.string().optional(),
23
- dayOfMonth: z.string().optional(),
24
- });
25
-
26
- export const CreateInputSchema = z.object({
27
- walletAddress: z.string().min(32),
28
- assetId: z.string(),
29
- solAmount: z.number(),
30
- rentRefund: z.string(),
31
- assetReturnAddress: z.string(),
32
- rewardsSplit: z.array(RewardSplitInputSchema),
33
- schedule: ScheduleInputSchema,
34
- lazyDistributor: z.string(),
35
- });
36
-
37
- export const GetInputSchema = z.object({
38
- walletAddress: z.string().min(32),
39
- packId: z.number(),
40
- });
41
-
42
- export const DeleteInputSchema = z.object({
43
- walletAddress: z.string().min(32),
44
- packId: z.number(),
45
- });
46
-
47
- export const GetByAddressInputSchema = z.object({
48
- packAddress: z.string().min(32),
49
- });
50
-
51
- export const ClaimInputSchema = z.object({
52
- packAddress: z.string().min(32),
53
- walletAddress: z.string().min(32),
54
- signature: z.string(),
55
- expirationTs: z.string(),
56
- });
57
-
58
- export const InviteInputSchema = z.object({
59
- packAddress: z.string().min(32),
60
- walletAddress: z.string().min(32),
61
- expirationDays: z.number().int().positive().max(365).default(7),
62
- });
63
-
64
- // ============================================================================
65
- // Output Schemas
66
- // ============================================================================
67
-
68
- export const WelcomePackSchema = z.object({
69
- address: z.string(),
70
- id: z.number(),
71
- owner: z.string(),
72
- asset: z.string(),
73
- lazyDistributor: z.string(),
74
- rewardsMint: z.string(),
75
- rentRefund: z.string(),
76
- solAmount: z.string(),
77
- rewardsSplit: z.array(RewardSplitInputSchema),
78
- rewardsSchedule: z.string(),
79
- assetReturnAddress: z.string(),
80
- bumpSeed: z.number(),
81
- uniqueId: z.string(),
82
- loading: z.boolean().optional(),
83
- hotspot: HotspotSchema.nullable(),
84
- });
85
-
86
- export const ListOutputSchema = z.array(WelcomePackSchema);
87
-
88
- export const TransactionMetadataSchema = z
89
- .object({
90
- type: z.string(),
91
- description: z.string(),
92
- })
93
- .catchall(z.unknown());
94
-
95
- export const TransactionItemSchema = z.object({
96
- serializedTransaction: z.string(),
97
- metadata: TransactionMetadataSchema.optional(),
98
- });
99
-
100
- export const TransactionDataSchema = z.object({
101
- transactions: z.array(TransactionItemSchema),
102
- parallel: z.boolean(),
103
- tag: z.string().optional(),
104
- });
105
-
106
- export const CreateOutputSchema = z.object({
107
- welcomePack: WelcomePackSchema,
108
- transactionData: TransactionDataSchema,
109
- });
110
-
111
- export const DeleteOutputSchema = z.object({
112
- transactionData: TransactionDataSchema,
113
- });
114
-
115
- export const ClaimOutputSchema = z.object({
116
- transactionData: TransactionDataSchema,
117
- });
118
-
119
- export const InviteOutputSchema = z.object({
120
- message: z.string(),
121
- expirationTs: z.number(),
122
- });
123
-
124
- // ============================================================================
125
- // Type Exports
126
- // ============================================================================
127
-
128
- export type ListInput = z.infer<typeof ListInputSchema>;
129
- export type CreateInput = z.infer<typeof CreateInputSchema>;
130
- export type GetInput = z.infer<typeof GetInputSchema>;
131
- export type DeleteInput = z.infer<typeof DeleteInputSchema>;
132
- export type GetByAddressInput = z.infer<typeof GetByAddressInputSchema>;
133
- export type ClaimInput = z.infer<typeof ClaimInputSchema>;
134
- export type InviteInput = z.infer<typeof InviteInputSchema>;
135
- export type WelcomePack = z.infer<typeof WelcomePackSchema>;
@@ -1,281 +0,0 @@
1
- import { z } from "zod";
2
-
3
- // ============================================================================
4
- // Common Transaction Schemas
5
- // ============================================================================
6
-
7
- /**
8
- * Metadata associated with a transaction for tracking and display purposes.
9
- */
10
- export const TransactionMetadataSchema = z
11
- .object({
12
- type: z.string(),
13
- description: z.string(),
14
- })
15
- .catchall(z.unknown());
16
-
17
- /**
18
- * A single transaction item with serialized data and optional metadata.
19
- */
20
- export const TransactionItemSchema = z.object({
21
- serializedTransaction: z.string(),
22
- metadata: TransactionMetadataSchema.optional(),
23
- });
24
-
25
- /**
26
- * Transaction data returned by procedures that create transactions.
27
- * Contains serialized transactions ready for signing and submission.
28
- */
29
- export const TransactionDataSchema = z.object({
30
- transactions: z.array(TransactionItemSchema),
31
- parallel: z.boolean(),
32
- tag: z.string().optional(),
33
- });
34
-
35
- /**
36
- * Request schema for submitting a batch of transactions.
37
- */
38
- export const TransactionBatchRequestSchema = z.object({
39
- transactions: z.array(TransactionItemSchema),
40
- parallel: z.boolean(),
41
- tag: z.string().optional(),
42
- });
43
-
44
- /**
45
- * Response schema for transaction batch submission.
46
- */
47
- export const TransactionBatchResponseSchema = z.object({
48
- batchId: z.string(),
49
- message: z.string().optional(),
50
- });
51
-
52
- // ============================================================================
53
- // Common Response Schemas
54
- // ============================================================================
55
-
56
- /**
57
- * Standard error response schema.
58
- */
59
- export const ErrorResponseSchema = z.object({
60
- error: z.string(),
61
- details: z.array(z.string()).optional(),
62
- });
63
-
64
- // ============================================================================
65
- // Wallet Address Schema
66
- // ============================================================================
67
-
68
- /**
69
- * Solana wallet address validation.
70
- */
71
- export const WalletAddressSchema = z.string().min(32).max(44);
72
-
73
- /**
74
- * Solana public key validation (base58 encoded).
75
- */
76
- export const PublicKeySchema = z.string().min(32).max(44);
77
-
78
- // ============================================================================
79
- // Pagination Schemas
80
- // ============================================================================
81
-
82
- /**
83
- * Standard pagination input schema.
84
- */
85
- export const PaginationInputSchema = z.object({
86
- page: z.coerce.number().int().min(1).default(1),
87
- limit: z.coerce.number().int().min(1).max(100).default(10),
88
- });
89
-
90
- /**
91
- * Standard pagination output schema.
92
- */
93
- export const PaginationOutputSchema = z.object({
94
- total: z.number(),
95
- page: z.number(),
96
- totalPages: z.number(),
97
- });
98
-
99
- // ============================================================================
100
- // Hotspot Schemas
101
- // ============================================================================
102
-
103
- /**
104
- * Hotspot type enumeration.
105
- */
106
- export const HotspotTypeSchema = z.enum(["iot", "mobile", "all"]);
107
-
108
- /**
109
- * Hotspot device type enumeration.
110
- */
111
- export const DeviceTypeSchema = z.enum([
112
- "iot-gateway",
113
- "wifiIndoor",
114
- "wifiOutdoor",
115
- "wifiDataOnly",
116
- "cbrs",
117
- ]);
118
-
119
- /**
120
- * Hotspot ownership type enumeration.
121
- */
122
- export const OwnershipTypeSchema = z.enum(["owner", "direct", "fanout", "all"]);
123
-
124
- /**
125
- * Hotspot share configuration.
126
- */
127
- export const HotspotSharesSchema = z.object({
128
- fixed: z.string().optional(),
129
- percentage: z.number().optional(),
130
- });
131
-
132
- /**
133
- * Complete hotspot data schema.
134
- */
135
- export const HotspotSchema = z.object({
136
- address: z.string(),
137
- entityKey: z.string(),
138
- name: z.string(),
139
- type: HotspotTypeSchema,
140
- deviceType: DeviceTypeSchema,
141
- city: z.string().optional(),
142
- state: z.string().optional(),
143
- country: z.string().optional(),
144
- asset: z.string(),
145
- isOnline: z.boolean().optional(),
146
- owner: z.string().optional(),
147
- shares: HotspotSharesSchema.optional(),
148
- ownershipType: z.string(),
149
- });
150
-
151
- /**
152
- * Paginated hotspots response schema.
153
- */
154
- export const HotspotsDataSchema = z.object({
155
- hotspots: z.array(HotspotSchema),
156
- total: z.number(),
157
- page: z.number(),
158
- totalPages: z.number(),
159
- });
160
-
161
- // ============================================================================
162
- // Token Schemas
163
- // ============================================================================
164
-
165
- /**
166
- * Token account data schema.
167
- */
168
- export const TokenAccountSchema = z.object({
169
- mint: z.string(),
170
- address: z.string(),
171
- balance: z.string(),
172
- decimals: z.number(),
173
- uiAmount: z.number(),
174
- symbol: z.string().optional(),
175
- name: z.string().optional(),
176
- logoURI: z.string().optional(),
177
- priceUsd: z.number().optional(),
178
- balanceUsd: z.number().optional(),
179
- });
180
-
181
- /**
182
- * Token balance data response schema.
183
- */
184
- export const TokenBalanceDataSchema = z.object({
185
- totalBalanceUsd: z.number(),
186
- solBalance: z.number(),
187
- solBalanceUsd: z.number(),
188
- tokens: z.array(TokenAccountSchema),
189
- });
190
-
191
- // ============================================================================
192
- // Welcome Pack Schemas
193
- // ============================================================================
194
-
195
- /**
196
- * Reward split recipient schema.
197
- */
198
- export const RewardSplitSchema = z.object({
199
- address: z.string(),
200
- type: z.enum(["percentage", "fixed"]),
201
- amount: z.number(),
202
- });
203
-
204
- /**
205
- * Schedule configuration schema.
206
- */
207
- export const ScheduleSchema = z.object({
208
- frequency: z.enum(["daily", "weekly", "monthly"]),
209
- time: z.string(),
210
- timezone: z.string(),
211
- dayOfWeek: z.string().optional(),
212
- dayOfMonth: z.string().optional(),
213
- });
214
-
215
- /**
216
- * Welcome pack with status schema.
217
- */
218
- export const WelcomePackWithStatusSchema = z.object({
219
- address: z.string(),
220
- id: z.number(),
221
- owner: z.string(),
222
- asset: z.string(),
223
- lazyDistributor: z.string(),
224
- rewardsMint: z.string(),
225
- rentRefund: z.string(),
226
- solAmount: z.string(),
227
- rewardsSplit: z.array(RewardSplitSchema),
228
- rewardsSchedule: z.string(),
229
- assetReturnAddress: z.string(),
230
- bumpSeed: z.number(),
231
- uniqueId: z.string(),
232
- loading: z.boolean().optional(),
233
- });
234
-
235
- // ============================================================================
236
- // Split Schemas
237
- // ============================================================================
238
-
239
- /**
240
- * Split share schema.
241
- */
242
- export const SplitShareSchema = z.object({
243
- wallet: z.string(),
244
- delegate: z.string(),
245
- fixed: z.number(),
246
- shares: z.number(),
247
- });
248
-
249
- /**
250
- * Split response schema.
251
- */
252
- export const SplitResponseSchema = z.object({
253
- walletAddress: z.string(),
254
- hotspotPubkey: z.string(),
255
- splitAddress: z.string(),
256
- shares: z.array(SplitShareSchema),
257
- });
258
-
259
- // ============================================================================
260
- // Type Exports
261
- // ============================================================================
262
-
263
- export type TransactionMetadata = z.infer<typeof TransactionMetadataSchema>;
264
- export type TransactionItem = z.infer<typeof TransactionItemSchema>;
265
- export type TransactionData = z.infer<typeof TransactionDataSchema>;
266
- export type TransactionBatchRequest = z.infer<
267
- typeof TransactionBatchRequestSchema
268
- >;
269
- export type TransactionBatchResponse = z.infer<
270
- typeof TransactionBatchResponseSchema
271
- >;
272
- export type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
273
- export type Hotspot = z.infer<typeof HotspotSchema>;
274
- export type HotspotsData = z.infer<typeof HotspotsDataSchema>;
275
- export type TokenAccount = z.infer<typeof TokenAccountSchema>;
276
- export type TokenBalanceData = z.infer<typeof TokenBalanceDataSchema>;
277
- export type RewardSplit = z.infer<typeof RewardSplitSchema>;
278
- export type Schedule = z.infer<typeof ScheduleSchema>;
279
- export type WelcomePackWithStatus = z.infer<typeof WelcomePackWithStatusSchema>;
280
- export type SplitShare = z.infer<typeof SplitShareSchema>;
281
- export type SplitResponse = z.infer<typeof SplitResponseSchema>;