@glowlabs-org/utils 0.2.121 → 0.2.122

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.
@@ -1,9 +1,10 @@
1
- import type { Kickstarter, CreateKickstarterPayload, KickstarterCreateResponse, CommitKickstarterPayload, CommitKickstarterResponse, KickstarterDetails } from "../types";
1
+ import type { Kickstarter, CreateKickstarterPayload, KickstarterCreateResponse, CommitKickstarterPayload, CommitKickstarterResponse, KickstarterDetails, KickstarterCommitmentsQuery, KickstarterCommitmentsResponse } from "../types";
2
2
  export declare function KickstarterRouter(baseUrl: string): {
3
3
  readonly fetchKickstarters: () => Promise<Kickstarter[]>;
4
4
  readonly fetchKickstarter: (idOrSlug: string) => Promise<KickstarterDetails>;
5
5
  readonly fetchKickstartersByWallet: (wallet: string) => Promise<Kickstarter[]>;
6
6
  readonly commitKickstarter: (kickstarterId: string, payload: CommitKickstarterPayload) => Promise<CommitKickstarterResponse>;
7
7
  readonly createKickstarter: (payload: CreateKickstarterPayload) => Promise<KickstarterCreateResponse>;
8
+ readonly fetchRegionCommitments: (regionId: number, query?: KickstarterCommitmentsQuery) => Promise<KickstarterCommitmentsResponse>;
8
9
  readonly isCreatingKickstarter: boolean;
9
10
  };
@@ -237,6 +237,25 @@ export interface CommitKickstarterResponse {
237
237
  success: true;
238
238
  regionId: number;
239
239
  }
240
+ export interface KickstarterCommitmentEvent {
241
+ id: string;
242
+ epoch: number;
243
+ wallet: string;
244
+ regionId: number;
245
+ amount: string;
246
+ ts: string;
247
+ isFinalized: boolean;
248
+ }
249
+ export interface KickstarterCommitmentsQuery {
250
+ page?: number;
251
+ limit?: number;
252
+ finalized?: boolean;
253
+ }
254
+ export interface KickstarterCommitmentsResponse {
255
+ page: number;
256
+ limit: number;
257
+ events: KickstarterCommitmentEvent[];
258
+ }
240
259
  export interface ActivationEvent {
241
260
  id: string;
242
261
  regionId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/utils",
3
- "version": "0.2.121",
3
+ "version": "0.2.122",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -8,6 +8,8 @@ import type {
8
8
  CommitKickstarterPayload,
9
9
  CommitKickstarterResponse,
10
10
  KickstarterDetails,
11
+ KickstarterCommitmentsQuery,
12
+ KickstarterCommitmentsResponse,
11
13
  } from "../types";
12
14
 
13
15
  function parseApiError(error: unknown): string {
@@ -109,12 +111,40 @@ export function KickstarterRouter(baseUrl: string) {
109
111
  }
110
112
  };
111
113
 
114
+ // Build pagination query helper
115
+ const buildPaginationQuery = (page?: number, limit?: number) => {
116
+ const p = page ?? 1;
117
+ const l = limit ?? 50;
118
+ return `?page=${p}&limit=${l}`;
119
+ };
120
+
121
+ const fetchRegionCommitments = async (
122
+ regionId: number,
123
+ query?: KickstarterCommitmentsQuery
124
+ ): Promise<KickstarterCommitmentsResponse> => {
125
+ try {
126
+ const base = `/kickstarters/region/${regionId}/commitments${buildPaginationQuery(
127
+ query?.page,
128
+ query?.limit
129
+ )}`;
130
+ const finalQuery =
131
+ query?.finalized !== undefined
132
+ ? `${base}&finalized=${query.finalized}`
133
+ : base;
134
+ const data = await request<KickstarterCommitmentsResponse>(finalQuery);
135
+ return data;
136
+ } catch (error) {
137
+ throw new Error(parseApiError(error));
138
+ }
139
+ };
140
+
112
141
  return {
113
142
  fetchKickstarters,
114
143
  fetchKickstarter,
115
144
  fetchKickstartersByWallet,
116
145
  commitKickstarter,
117
146
  createKickstarter,
147
+ fetchRegionCommitments,
118
148
  get isCreatingKickstarter() {
119
149
  return isCreatingKickstarter;
120
150
  },
@@ -293,6 +293,28 @@ export interface CommitKickstarterResponse {
293
293
  regionId: number;
294
294
  }
295
295
 
296
+ export interface KickstarterCommitmentEvent {
297
+ id: string;
298
+ epoch: number;
299
+ wallet: string;
300
+ regionId: number;
301
+ amount: string; // atomic GCTL (6 decimals)
302
+ ts: string; // ISO 8601
303
+ isFinalized: boolean;
304
+ }
305
+
306
+ export interface KickstarterCommitmentsQuery {
307
+ page?: number; // default 1
308
+ limit?: number; // default 50, max 100
309
+ finalized?: boolean; // optional filter on isFinalized
310
+ }
311
+
312
+ export interface KickstarterCommitmentsResponse {
313
+ page: number;
314
+ limit: number;
315
+ events: KickstarterCommitmentEvent[];
316
+ }
317
+
296
318
  export interface ActivationEvent {
297
319
  id: string;
298
320
  regionId: number;