@fairmint/canton-fairmint-sdk 0.0.23 → 0.0.25

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 (41) hide show
  1. package/dist/clients/postgres-db-api/fairmint-db/app-markers.d.ts +26 -0
  2. package/dist/clients/postgres-db-api/fairmint-db/app-markers.d.ts.map +1 -0
  3. package/dist/clients/postgres-db-api/fairmint-db/app-markers.js +219 -0
  4. package/dist/clients/postgres-db-api/fairmint-db/app-markers.js.map +1 -0
  5. package/dist/clients/postgres-db-api/fairmint-db/base.d.ts +30 -0
  6. package/dist/clients/postgres-db-api/fairmint-db/base.d.ts.map +1 -0
  7. package/dist/clients/postgres-db-api/fairmint-db/base.js +208 -0
  8. package/dist/clients/postgres-db-api/fairmint-db/base.js.map +1 -0
  9. package/dist/clients/postgres-db-api/fairmint-db/index.d.ts +9 -0
  10. package/dist/clients/postgres-db-api/fairmint-db/index.d.ts.map +1 -0
  11. package/dist/clients/postgres-db-api/fairmint-db/index.js +21 -0
  12. package/dist/clients/postgres-db-api/fairmint-db/index.js.map +1 -0
  13. package/dist/clients/postgres-db-api/fairmint-db/ocf-deployments.d.ts +95 -0
  14. package/dist/clients/postgres-db-api/fairmint-db/ocf-deployments.d.ts.map +1 -0
  15. package/dist/clients/postgres-db-api/fairmint-db/ocf-deployments.js +592 -0
  16. package/dist/clients/postgres-db-api/fairmint-db/ocf-deployments.js.map +1 -0
  17. package/dist/clients/postgres-db-api/fairmint-db/parties.d.ts +22 -0
  18. package/dist/clients/postgres-db-api/fairmint-db/parties.d.ts.map +1 -0
  19. package/dist/clients/postgres-db-api/fairmint-db/parties.js +178 -0
  20. package/dist/clients/postgres-db-api/fairmint-db/parties.js.map +1 -0
  21. package/dist/clients/postgres-db-api/fairmint-db/reward-coupons.d.ts +41 -0
  22. package/dist/clients/postgres-db-api/fairmint-db/reward-coupons.d.ts.map +1 -0
  23. package/dist/clients/postgres-db-api/fairmint-db/reward-coupons.js +467 -0
  24. package/dist/clients/postgres-db-api/fairmint-db/reward-coupons.js.map +1 -0
  25. package/dist/clients/postgres-db-api/fairmint-db/time-series.d.ts +48 -0
  26. package/dist/clients/postgres-db-api/fairmint-db/time-series.d.ts.map +1 -0
  27. package/dist/clients/postgres-db-api/fairmint-db/time-series.js +419 -0
  28. package/dist/clients/postgres-db-api/fairmint-db/time-series.js.map +1 -0
  29. package/dist/clients/postgres-db-api/fairmint-db/transfers.d.ts +25 -0
  30. package/dist/clients/postgres-db-api/fairmint-db/transfers.d.ts.map +1 -0
  31. package/dist/clients/postgres-db-api/fairmint-db/transfers.js +206 -0
  32. package/dist/clients/postgres-db-api/fairmint-db/transfers.js.map +1 -0
  33. package/dist/clients/postgres-db-api/fairmint-db/valuation-reports.d.ts +11 -0
  34. package/dist/clients/postgres-db-api/fairmint-db/valuation-reports.d.ts.map +1 -0
  35. package/dist/clients/postgres-db-api/fairmint-db/valuation-reports.js +54 -0
  36. package/dist/clients/postgres-db-api/fairmint-db/valuation-reports.js.map +1 -0
  37. package/dist/clients/postgres-db-api/fairmintDbClient.d.ts +83 -132
  38. package/dist/clients/postgres-db-api/fairmintDbClient.d.ts.map +1 -1
  39. package/dist/clients/postgres-db-api/fairmintDbClient.js +183 -2973
  40. package/dist/clients/postgres-db-api/fairmintDbClient.js.map +1 -1
  41. package/package.json +1 -1
@@ -0,0 +1,467 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RewardCouponsRepository = void 0;
4
+ const base_1 = require("./base");
5
+ /**
6
+ * Repository for Canton App Reward Coupon operations.
7
+ */
8
+ class RewardCouponsRepository extends base_1.BaseRepository {
9
+ async insertCantonAppRewardCoupon(coupon) {
10
+ const query = `
11
+ INSERT INTO canton_app_reward_coupons (
12
+ status, tx_update_id, tx_record_time, contract_id, template_id, package_name,
13
+ dso_party_id, provider_party_id, featured, round_number, beneficiary_party_id, coupon_amount
14
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
15
+ RETURNING *
16
+ `;
17
+ const values = [
18
+ coupon.status,
19
+ coupon.tx_update_id,
20
+ coupon.tx_record_time,
21
+ coupon.contract_id,
22
+ coupon.template_id,
23
+ coupon.package_name,
24
+ coupon.dso_party_id,
25
+ coupon.provider_party_id,
26
+ coupon.featured,
27
+ coupon.round_number,
28
+ coupon.beneficiary_party_id,
29
+ coupon.coupon_amount,
30
+ ];
31
+ const result = await this.pool.query(query, values);
32
+ return this.mapRewardCouponFromDb(result.rows[0]);
33
+ }
34
+ async batchInsertCantonAppRewardCoupons(coupons) {
35
+ if (coupons.length === 0) {
36
+ return { insertedCount: 0, skippedCount: 0 };
37
+ }
38
+ // Build the VALUES clause with placeholders
39
+ const valuesPlaceholders = coupons
40
+ .map((_, idx) => `($${idx * 12 + 1}, $${idx * 12 + 2}, $${idx * 12 + 3}, $${idx * 12 + 4}, $${idx * 12 + 5}, $${idx * 12 + 6}, $${idx * 12 + 7}, $${idx * 12 + 8}, $${idx * 12 + 9}, $${idx * 12 + 10}, $${idx * 12 + 11}, $${idx * 12 + 12})`)
41
+ .join(', ');
42
+ const query = `
43
+ INSERT INTO canton_app_reward_coupons (
44
+ status, tx_update_id, tx_record_time, contract_id, template_id, package_name,
45
+ dso_party_id, provider_party_id, featured, round_number, beneficiary_party_id, coupon_amount
46
+ ) VALUES ${valuesPlaceholders}
47
+ ON CONFLICT (contract_id) DO NOTHING
48
+ RETURNING *
49
+ `;
50
+ // Flatten all coupon values into a single array
51
+ const values = coupons.flatMap(coupon => [
52
+ coupon.status,
53
+ coupon.tx_update_id,
54
+ coupon.tx_record_time,
55
+ coupon.contract_id,
56
+ coupon.template_id,
57
+ coupon.package_name,
58
+ coupon.dso_party_id,
59
+ coupon.provider_party_id,
60
+ coupon.featured,
61
+ coupon.round_number,
62
+ coupon.beneficiary_party_id,
63
+ coupon.coupon_amount,
64
+ ]);
65
+ const result = await this.pool.query(query, values);
66
+ const insertedCount = result.rowCount ?? 0;
67
+ const skippedCount = coupons.length - insertedCount;
68
+ return { insertedCount, skippedCount };
69
+ }
70
+ async upsertCantonAppRewardCouponWithStatus(coupon) {
71
+ const query = `
72
+ INSERT INTO canton_app_reward_coupons (
73
+ status, tx_update_id, tx_record_time, contract_id, template_id, package_name,
74
+ dso_party_id, provider_party_id, featured, round_number, beneficiary_party_id, coupon_amount
75
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
76
+ ON CONFLICT (contract_id) DO UPDATE
77
+ SET status = EXCLUDED.status, updated_at = NOW()
78
+ RETURNING *
79
+ `;
80
+ const values = [
81
+ coupon.status,
82
+ coupon.tx_update_id,
83
+ coupon.tx_record_time,
84
+ coupon.contract_id,
85
+ coupon.template_id,
86
+ coupon.package_name,
87
+ coupon.dso_party_id,
88
+ coupon.provider_party_id,
89
+ coupon.featured,
90
+ coupon.round_number,
91
+ coupon.beneficiary_party_id,
92
+ coupon.coupon_amount,
93
+ ];
94
+ const result = await this.pool.query(query, values);
95
+ return this.mapRewardCouponFromDb(result.rows[0]);
96
+ }
97
+ async getCantonAppRewardCoupon(id) {
98
+ const query = 'SELECT * FROM canton_app_reward_coupons WHERE id = $1';
99
+ const result = await this.pool.query(query, [id]);
100
+ return result.rows.length > 0
101
+ ? this.mapRewardCouponFromDb(result.rows[0])
102
+ : null;
103
+ }
104
+ async getCantonAppRewardCouponByContractId(contractId) {
105
+ const query = 'SELECT * FROM canton_app_reward_coupons WHERE contract_id = $1';
106
+ const result = await this.pool.query(query, [contractId]);
107
+ return result.rows.length > 0
108
+ ? this.mapRewardCouponFromDb(result.rows[0])
109
+ : null;
110
+ }
111
+ async getCantonAppRewardCouponsByContractIds(contractIds) {
112
+ if (contractIds.length === 0) {
113
+ return [];
114
+ }
115
+ const placeholders = contractIds
116
+ .map((_, index) => `$${index + 1}`)
117
+ .join(', ');
118
+ const query = `
119
+ SELECT * FROM canton_app_reward_coupons
120
+ WHERE contract_id IN (${placeholders})
121
+ `;
122
+ const result = await this.pool.query(query, contractIds);
123
+ return result.rows.map(row => this.mapRewardCouponFromDb(row));
124
+ }
125
+ async getCantonAppRewardCouponsByStatus(status, limit = 100, sortOrder = 'ASC', beneficiaryPartyId) {
126
+ let query = `
127
+ SELECT * FROM canton_app_reward_coupons
128
+ WHERE status = $1
129
+ `;
130
+ const params = [status];
131
+ if (beneficiaryPartyId) {
132
+ query += ` AND beneficiary_party_id = $${params.length + 1}`;
133
+ params.push(beneficiaryPartyId);
134
+ }
135
+ query += ` ORDER BY tx_record_time ${sortOrder} LIMIT $${params.length + 1}`;
136
+ params.push(limit);
137
+ const result = await this.pool.query(query, params);
138
+ return result.rows.map(row => this.mapRewardCouponFromDb(row));
139
+ }
140
+ async countCantonAppRewardCouponsByStatus(status) {
141
+ const query = `
142
+ SELECT COUNT(*) FROM canton_app_reward_coupons
143
+ WHERE status = $1
144
+ `;
145
+ const result = await this.pool.query(query, [status]);
146
+ return Number(result.rows[0]?.count ?? 0);
147
+ }
148
+ async getOldestCreatedCantonAppRewardCoupons(limit = 100) {
149
+ const query = `
150
+ SELECT * FROM canton_app_reward_coupons
151
+ WHERE status = 'created'
152
+ ORDER BY tx_record_time ASC
153
+ LIMIT $1
154
+ `;
155
+ const result = await this.pool.query(query, [limit]);
156
+ return result.rows.map(row => this.mapRewardCouponFromDb(row));
157
+ }
158
+ async getCantonAppRewardCouponsByDateRange(startDate, endDate, status, limit = 1000, sortOrder = 'ASC') {
159
+ let query = `
160
+ SELECT * FROM canton_app_reward_coupons
161
+ WHERE tx_archive_record_time >= $1 AND tx_archive_record_time <= $2
162
+ `;
163
+ const values = [startDate, endDate];
164
+ let paramIndex = 3;
165
+ if (status) {
166
+ query += ` AND status = $${paramIndex}`;
167
+ values.push(status);
168
+ paramIndex++;
169
+ }
170
+ query += ` ORDER BY tx_archive_record_time ${sortOrder} LIMIT $${paramIndex}`;
171
+ values.push(limit);
172
+ const result = await this.pool.query(query, values);
173
+ return result.rows.map(row => this.mapRewardCouponFromDb(row));
174
+ }
175
+ async updateCantonAppRewardCoupon(id, updates) {
176
+ const setClauses = [];
177
+ const values = [];
178
+ let paramIndex = 1;
179
+ // Build dynamic update query
180
+ Object.entries(updates).forEach(([key, value]) => {
181
+ if (key !== 'id' && key !== 'created_at') {
182
+ setClauses.push(`${this.toSnakeCase(key)} = $${paramIndex}`);
183
+ values.push(value);
184
+ paramIndex++;
185
+ }
186
+ });
187
+ if (setClauses.length === 0) {
188
+ throw new Error('No valid fields to update');
189
+ }
190
+ values.push(id);
191
+ const query = `
192
+ UPDATE canton_app_reward_coupons
193
+ SET ${setClauses.join(', ')}, updated_at = NOW()
194
+ WHERE id = $${paramIndex}
195
+ RETURNING *
196
+ `;
197
+ const result = await this.pool.query(query, values);
198
+ return result.rows.length > 0
199
+ ? this.mapRewardCouponFromDb(result.rows[0])
200
+ : null;
201
+ }
202
+ async batchUpdateCantonAppRewardCouponsByContractIds(contractIds, updates) {
203
+ if (contractIds.length === 0) {
204
+ return [];
205
+ }
206
+ const setClauses = [];
207
+ const values = [];
208
+ let paramIndex = 1;
209
+ // Build dynamic update query
210
+ Object.entries(updates).forEach(([key, value]) => {
211
+ if (key !== 'id' && key !== 'created_at') {
212
+ setClauses.push(`${this.toSnakeCase(key)} = $${paramIndex}`);
213
+ values.push(value);
214
+ paramIndex++;
215
+ }
216
+ });
217
+ if (setClauses.length === 0) {
218
+ throw new Error('No valid fields to update');
219
+ }
220
+ // Build the WHERE clause for contract IDs
221
+ const contractIdPlaceholders = contractIds
222
+ .map((_, index) => `$${paramIndex + index}`)
223
+ .join(', ');
224
+ values.push(...contractIds);
225
+ const query = `
226
+ UPDATE canton_app_reward_coupons
227
+ SET ${setClauses.join(', ')}, updated_at = NOW()
228
+ WHERE contract_id IN (${contractIdPlaceholders})
229
+ RETURNING *
230
+ `;
231
+ const result = await this.pool.query(query, values);
232
+ return result.rows.map(row => this.mapRewardCouponFromDb(row));
233
+ }
234
+ async getRewardCoupons(options = {}) {
235
+ const { limit = 100, order = 'oldest', redeemed = 'Both' } = options;
236
+ let query = `
237
+ SELECT
238
+ c.id as coupon_id,
239
+ c.status as coupon_status,
240
+ c.tx_update_id as coupon_tx_update_id,
241
+ c.tx_record_time as coupon_tx_record_time,
242
+ c.contract_id as coupon_contract_id,
243
+ c.template_id as coupon_template_id,
244
+ c.package_name as coupon_package_name,
245
+ c.dso_party_id as coupon_dso_party_id,
246
+ c.provider_party_id as coupon_provider_party_id,
247
+ c.featured as coupon_featured,
248
+ c.round_number as coupon_round_number,
249
+ c.beneficiary_party_id as coupon_beneficiary_party_id,
250
+ c.coupon_amount as coupon_coupon_amount,
251
+ c.tx_archive_update_id as coupon_tx_archive_update_id,
252
+ c.tx_archive_record_time as coupon_tx_archive_record_time,
253
+ c.app_reward_amount as coupon_app_reward_amount,
254
+ c.created_at as coupon_created_at,
255
+ c.updated_at as coupon_updated_at,
256
+ t.id as transfer_id,
257
+ t.status as transfer_status,
258
+ t.api_tracking_id as transfer_api_tracking_id,
259
+ t.api_expires_at as transfer_api_expires_at,
260
+ t.transfer_sender_party_id as transfer_transfer_sender_party_id,
261
+ t.transfer_receiver_party_id as transfer_transfer_receiver_party_id,
262
+ t.transfer_amount as transfer_transfer_amount,
263
+ t.transfer_description as transfer_transfer_description,
264
+ t.transfer_burned_amount as transfer_transfer_burned_amount,
265
+ t.receiver_holding_cids as transfer_receiver_holding_cids,
266
+ t.sender_change_cids as transfer_sender_change_cids,
267
+ t.tx_update_id as transfer_tx_update_id,
268
+ t.tx_record_time as transfer_tx_record_time,
269
+ t.app_reward_coupon_id as transfer_app_reward_coupon_id,
270
+ t.created_at as transfer_created_at,
271
+ t.updated_at as transfer_updated_at,
272
+ r.id as redemption_id,
273
+ r.tx_update_id as redemption_tx_update_id,
274
+ r.tx_record_time as redemption_tx_record_time,
275
+ r.tx_synchronizer_id as redemption_tx_synchronizer_id,
276
+ r.tx_effective_at as redemption_tx_effective_at,
277
+ r.total_app_rewards,
278
+ r.created_at as redemption_created_at,
279
+ r.updated_at as redemption_updated_at
280
+ FROM canton_app_reward_coupons c
281
+ LEFT JOIN canton_transfers t ON t.app_reward_coupon_id = c.id
282
+ LEFT JOIN canton_app_reward_coupon_redemptions r ON c.id = ANY(r.app_reward_coupon_ids)
283
+ `;
284
+ const conditions = [];
285
+ const values = [];
286
+ const paramIndex = 1;
287
+ // Filter by redemption status
288
+ if (redeemed === 'Unredeemed') {
289
+ conditions.push('r.id IS NULL');
290
+ }
291
+ else if (redeemed === 'Redeemed') {
292
+ conditions.push('r.id IS NOT NULL');
293
+ }
294
+ if (conditions.length > 0) {
295
+ query += ` WHERE ${conditions.join(' AND ')}`;
296
+ }
297
+ // Order by
298
+ query += ` ORDER BY c.tx_record_time ${order === 'oldest' ? 'ASC' : 'DESC'}`;
299
+ // Limit
300
+ query += ` LIMIT $${paramIndex}`;
301
+ values.push(limit);
302
+ const result = await this.pool.query(query, values);
303
+ return result.rows.map(row => this.mapRewardCouponWithTransferFromDb(row));
304
+ }
305
+ async getRewardCoupon(options) {
306
+ const { contract_id } = options;
307
+ const query = `
308
+ SELECT
309
+ c.id as coupon_id,
310
+ c.status as coupon_status,
311
+ c.tx_update_id as coupon_tx_update_id,
312
+ c.tx_record_time as coupon_tx_record_time,
313
+ c.contract_id as coupon_contract_id,
314
+ c.template_id as coupon_template_id,
315
+ c.package_name as coupon_package_name,
316
+ c.dso_party_id as coupon_dso_party_id,
317
+ c.provider_party_id as coupon_provider_party_id,
318
+ c.featured as coupon_featured,
319
+ c.round_number as coupon_round_number,
320
+ c.beneficiary_party_id as coupon_beneficiary_party_id,
321
+ c.coupon_amount as coupon_coupon_amount,
322
+ c.tx_archive_update_id as coupon_tx_archive_update_id,
323
+ c.tx_archive_record_time as coupon_tx_archive_record_time,
324
+ c.app_reward_amount as coupon_app_reward_amount,
325
+ c.created_at as coupon_created_at,
326
+ c.updated_at as coupon_updated_at,
327
+ t.id as transfer_id,
328
+ t.status as transfer_status,
329
+ t.api_tracking_id as transfer_api_tracking_id,
330
+ t.api_expires_at as transfer_api_expires_at,
331
+ t.transfer_sender_party_id as transfer_transfer_sender_party_id,
332
+ t.transfer_receiver_party_id as transfer_transfer_receiver_party_id,
333
+ t.transfer_amount as transfer_transfer_amount,
334
+ t.transfer_description as transfer_transfer_description,
335
+ t.transfer_burned_amount as transfer_transfer_burned_amount,
336
+ t.receiver_holding_cids as transfer_receiver_holding_cids,
337
+ t.sender_change_cids as transfer_sender_change_cids,
338
+ t.tx_update_id as transfer_tx_update_id,
339
+ t.tx_record_time as transfer_tx_record_time,
340
+ t.app_reward_coupon_id as transfer_app_reward_coupon_id,
341
+ t.created_at as transfer_created_at,
342
+ t.updated_at as transfer_updated_at,
343
+ r.id as redemption_id,
344
+ r.tx_update_id as redemption_tx_update_id,
345
+ r.tx_record_time as redemption_tx_record_time,
346
+ r.tx_synchronizer_id as redemption_tx_synchronizer_id,
347
+ r.tx_effective_at as redemption_tx_effective_at,
348
+ r.total_app_rewards,
349
+ r.created_at as redemption_created_at,
350
+ r.updated_at as redemption_updated_at
351
+ FROM canton_app_reward_coupons c
352
+ LEFT JOIN canton_transfers t ON t.app_reward_coupon_id = c.id
353
+ LEFT JOIN canton_app_reward_coupon_redemptions r ON c.id = ANY(r.app_reward_coupon_ids)
354
+ WHERE c.contract_id = $1
355
+ `;
356
+ const result = await this.pool.query(query, [contract_id]);
357
+ return result.rows.length > 0
358
+ ? this.mapRewardCouponWithTransferFromDb(result.rows[0])
359
+ : null;
360
+ }
361
+ async getMonthlyAppRewardAmountTotal(monthStart, monthEnd) {
362
+ const query = `
363
+ SELECT COALESCE(SUM(app_reward_amount), 0) as total_amount
364
+ FROM canton_app_reward_coupons
365
+ WHERE created_at >= $1
366
+ AND created_at <= $2
367
+ AND app_reward_amount IS NOT NULL
368
+ `;
369
+ const result = await this.pool.query(query, [monthStart, monthEnd]);
370
+ const totalAmount = parseFloat(result.rows[0].total_amount);
371
+ return totalAmount;
372
+ }
373
+ async getLatestCouponAmounts() {
374
+ // Get the most recent coupon amounts (featured and unfeatured) from the latest rounds
375
+ const query = `
376
+ SELECT
377
+ MAX(coupon_amount) FILTER (WHERE featured) AS featured_amount,
378
+ MAX(coupon_amount) FILTER (WHERE NOT featured) AS unfeatured_amount
379
+ FROM canton_app_reward_coupons
380
+ WHERE round_number >= (
381
+ SELECT COALESCE(MAX(round_number), 0) - 100
382
+ FROM canton_app_reward_coupons
383
+ )
384
+ `;
385
+ const result = await this.pool.query(query);
386
+ return {
387
+ featuredAmount: parseFloat(result.rows[0].featured_amount || '0'),
388
+ unfeaturedAmount: parseFloat(result.rows[0].unfeatured_amount || '0'),
389
+ };
390
+ }
391
+ async getLastAppRewardCouponTimestamp(partyFilter) {
392
+ let query = `
393
+ SELECT MAX(tx_record_time) as latest
394
+ FROM canton_app_reward_coupons
395
+ `;
396
+ const params = [];
397
+ if (partyFilter) {
398
+ query += ` WHERE beneficiary_party_id = $1`;
399
+ params.push(partyFilter);
400
+ }
401
+ const result = await this.pool.query(query, params);
402
+ return result.rows[0]?.latest || null;
403
+ }
404
+ async getLifetimeAppRewards() {
405
+ const query = `
406
+ SELECT COALESCE(SUM(app_reward_amount), 0) as total
407
+ FROM canton_app_reward_coupons
408
+ WHERE app_reward_amount IS NOT NULL
409
+ `;
410
+ const result = await this.pool.query(query);
411
+ return parseFloat(result.rows[0].total);
412
+ }
413
+ async getUniqueCouponBeneficiaryParties() {
414
+ const query = `
415
+ SELECT
416
+ beneficiary_party_id as party_id,
417
+ COUNT(*) as coupon_count
418
+ FROM canton_app_reward_coupons
419
+ GROUP BY beneficiary_party_id
420
+ ORDER BY coupon_count DESC
421
+ `;
422
+ const result = await this.pool.query(query);
423
+ return result.rows.map(row => ({
424
+ party_id: row.party_id,
425
+ coupon_count: parseInt(row.coupon_count, 10),
426
+ }));
427
+ }
428
+ async getHistoricalIssuanceRates(roundNumbers) {
429
+ if (roundNumbers.length === 0) {
430
+ return [];
431
+ }
432
+ // Query the scan_acs_store table for ClosedMiningRound contracts
433
+ // The template_id_qualified_name should match the ClosedMiningRound template
434
+ const query = `
435
+ SELECT
436
+ round,
437
+ create_arguments
438
+ FROM scan_acs_store
439
+ WHERE template_id_qualified_name LIKE '%:Splice.Round:ClosedMiningRound'
440
+ AND round = ANY($1)
441
+ AND create_arguments IS NOT NULL
442
+ ORDER BY round ASC
443
+ `;
444
+ try {
445
+ const result = await this.pool.query(query, [roundNumbers]);
446
+ return result.rows.map(row => {
447
+ const payload = row.create_arguments;
448
+ const roundNumber = parseInt(row.round, 10);
449
+ // Extract issuance rates from the contract payload
450
+ // The payload is stored as JSON and contains the issuance rate fields
451
+ const issuancePerFeaturedAppRewardCoupon = parseFloat(payload.issuancePerFeaturedAppRewardCoupon ?? '0');
452
+ const issuancePerUnfeaturedAppRewardCoupon = parseFloat(payload.issuancePerUnfeaturedAppRewardCoupon ?? '0');
453
+ return {
454
+ roundNumber,
455
+ issuancePerFeaturedAppRewardCoupon,
456
+ issuancePerUnfeaturedAppRewardCoupon,
457
+ };
458
+ });
459
+ }
460
+ catch (error) {
461
+ console.error('Error querying historical issuance rates:', error);
462
+ throw new Error(`Failed to get historical issuance rates: ${error instanceof Error ? error.message : 'Unknown error'}`);
463
+ }
464
+ }
465
+ }
466
+ exports.RewardCouponsRepository = RewardCouponsRepository;
467
+ //# sourceMappingURL=reward-coupons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reward-coupons.js","sourceRoot":"","sources":["../../../../src/clients/postgres-db-api/fairmint-db/reward-coupons.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AASxC;;GAEG;AACH,MAAa,uBAAwB,SAAQ,qBAAc;IACzD,KAAK,CAAC,2BAA2B,CAC/B,MAA6B;QAE7B,MAAM,KAAK,GAAG;;;;;;KAMb,CAAC;QAEF,MAAM,MAAM,GAAG;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,YAAY;YACnB,MAAM,CAAC,cAAc;YACrB,MAAM,CAAC,WAAW;YAClB,MAAM,CAAC,WAAW;YAClB,MAA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BACtE,MAAM,kCAAkC,GAAG,UAAU,CACnD,OAAO,CAAC,kCAAkC,IAAI,GAAG,CAClD,CAAC;gBACF,MAAM,oCAAoC,GAAG,UAAU,CACrD,OAAO,CAAC,oCAAoC,IAAI,GAAG,CACpD,CAAC;gBAEF,OAAO;oBACL,WAAW;oBACX,kCAAkC;oBAClC,oCAAoC;iBACrC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,4CAA4C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACvG,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzkBD,0DAykBC"}
@@ -0,0 +1,48 @@
1
+ import { BaseRepository } from './base';
2
+ type TimeRange = '15m' | '1h' | '6h' | '1d' | '7d' | '30d' | 'last-month' | 'all';
3
+ /**
4
+ * Repository for time series data analytics.
5
+ */
6
+ export declare class TimeSeriesRepository extends BaseRepository {
7
+ private getTimeSeriesConfig;
8
+ getTransferTimeSeriesData(timeRange: TimeRange, _metric?: 'count' | 'amount', timePeriod?: 'most-recent' | 'custom-start', customStartDate?: string): Promise<Array<{
9
+ timestamp: string;
10
+ count: number;
11
+ amount: number;
12
+ }>>;
13
+ getRewardCouponTimeSeriesData(timeRange: TimeRange, _metric?: 'count' | 'amount' | 'couponAmount', timePeriod?: 'most-recent' | 'custom-start', customStartDate?: string, partyFilter?: string, couponStatus?: 'created' | 'archived' | 'all'): Promise<Array<{
14
+ timestamp: string;
15
+ count: number;
16
+ amount: number;
17
+ couponAmount: number;
18
+ }>>;
19
+ getRewardCouponRoundSeriesData(timeRange: TimeRange, _metric?: 'count' | 'amount' | 'couponAmount', timePeriod?: 'most-recent' | 'custom-start', customStartDate?: string, partyFilter?: string, couponStatus?: 'created' | 'archived' | 'all'): Promise<Array<{
20
+ timestamp: string;
21
+ count: number;
22
+ amount: number;
23
+ couponAmount: number;
24
+ round: number;
25
+ }>>;
26
+ getAppMarkerTimeSeriesData(timeRange: TimeRange, _metric?: 'count', timePeriod?: 'most-recent' | 'custom-start', customStartDate?: string, partyFilter?: string, _statusFilter?: 'created' | 'archived'): Promise<Array<{
27
+ timestamp: string;
28
+ count: number;
29
+ amount: number;
30
+ couponAmount: number;
31
+ archivedCount?: number;
32
+ createdCount?: number;
33
+ archivedWeight?: number;
34
+ createdWeight?: number;
35
+ }>>;
36
+ getAppMarkerRoundSeriesData(timeRange: TimeRange, _metric?: 'count', timePeriod?: 'most-recent' | 'custom-start', customStartDate?: string, partyFilter?: string, _statusFilter?: 'created' | 'archived' | 'all'): Promise<Array<{
37
+ timestamp: string;
38
+ count: number;
39
+ round: number;
40
+ archivedCount: number;
41
+ createdCount: number;
42
+ archivedWeight: number;
43
+ createdWeight: number;
44
+ }>>;
45
+ getMonthlyTransferTotal(monthStart: Date, monthEnd: Date): Promise<number>;
46
+ }
47
+ export {};
48
+ //# sourceMappingURL=time-series.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-series.d.ts","sourceRoot":"","sources":["../../../../src/clients/postgres-db-api/fairmint-db/time-series.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxC,KAAK,SAAS,GACV,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,YAAY,GACZ,KAAK,CAAC;AAYV;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,OAAO,CAAC,mBAAmB;IAiGrB,yBAAyB,CAC7B,SAAS,EAAE,SAAS,EACpB,OAAO,GAAE,OAAO,GAAG,QAAkB,EACrC,UAAU,CAAC,EAAE,aAAa,GAAG,cAAc,EAC3C,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,KAAK,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