@render-foundation/utils 0.0.234-beta.1 → 0.0.236
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/lib/cjs/assertSecrets.js +1 -2
- package/lib/cjs/assertSecrets.js.map +1 -1
- package/lib/cjs/backfiller.js +16 -16
- package/lib/cjs/backfiller.js.map +1 -1
- package/lib/cjs/client/dispersed.js +4 -4
- package/lib/cjs/client/dispersed.js.map +1 -1
- package/lib/cjs/client/onchain.js +3 -3
- package/lib/cjs/client/onchain.js.map +1 -1
- package/lib/cjs/client/pg/base.js +7 -7
- package/lib/cjs/client/pg/base.js.map +1 -1
- package/lib/cjs/client/pg/v1.js +31 -31
- package/lib/cjs/client/pg/v1.js.map +1 -1
- package/lib/cjs/client/pg/v2Client.js +170 -172
- package/lib/cjs/client/pg/v2Client.js.map +1 -1
- package/lib/cjs/client/pg/viewClient.js +6 -6
- package/lib/cjs/client/pg/viewClient.js.map +1 -1
- package/lib/cjs/client/price.js +2 -2
- package/lib/cjs/client/price.js.map +1 -1
- package/lib/cjs/client/render.js +10 -10
- package/lib/cjs/client/render.js.map +1 -1
- package/lib/cjs/client/squads.js +20 -10
- package/lib/cjs/client/squads.js.map +1 -1
- package/lib/cjs/client/trade.js +15 -12
- package/lib/cjs/client/trade.js.map +1 -1
- package/lib/cjs/client/wormhole.js +19 -9
- package/lib/cjs/client/wormhole.js.map +1 -1
- package/lib/cjs/errorReporter.js +1 -1
- package/lib/cjs/errorReporter.js.map +1 -1
- package/lib/cjs/index.js +17 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/esm/src/assertSecrets.js.map +1 -1
- package/lib/esm/src/backfiller.js.map +1 -1
- package/lib/esm/src/client/dispersed.js.map +1 -1
- package/lib/esm/src/client/onchain.js.map +1 -1
- package/lib/esm/src/client/pg/base.js.map +1 -1
- package/lib/esm/src/client/pg/v1.js.map +1 -1
- package/lib/esm/src/client/pg/v2Client.js +74 -56
- package/lib/esm/src/client/pg/v2Client.js.map +1 -1
- package/lib/esm/src/client/pg/viewClient.js.map +1 -1
- package/lib/esm/src/client/price.js.map +1 -1
- package/lib/esm/src/client/render.js.map +1 -1
- package/lib/esm/src/client/squads.js.map +1 -1
- package/lib/esm/src/client/trade.js +2 -2
- package/lib/esm/src/client/trade.js.map +1 -1
- package/lib/esm/src/client/wormhole.js.map +1 -1
- package/lib/esm/src/errorReporter.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/backfiller.d.ts.map +1 -1
- package/lib/types/src/client/dispersed.d.ts.map +1 -1
- package/lib/types/src/client/onchain.d.ts +2 -1
- package/lib/types/src/client/onchain.d.ts.map +1 -1
- package/lib/types/src/client/pg/base.d.ts.map +1 -1
- package/lib/types/src/client/pg/v1.d.ts.map +1 -1
- package/lib/types/src/client/pg/v2Client.d.ts +30 -24
- package/lib/types/src/client/pg/v2Client.d.ts.map +1 -1
- package/lib/types/src/client/pg/viewClient.d.ts.map +1 -1
- package/lib/types/src/client/render.d.ts.map +1 -1
- package/lib/types/src/client/squads.d.ts.map +1 -1
- package/lib/types/src/client/trade.d.ts.map +1 -1
- package/lib/types/src/client/wormhole.d.ts +1 -1
- package/lib/types/src/client/wormhole.d.ts.map +1 -1
- package/lib/types/src/dbTypesV2.d.ts +19 -16
- package/lib/types/src/dbTypesV2.d.ts.map +1 -1
- package/lib/types/src/errorReporter.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.pgClient = exports.batchFinishedAtMedian = exports.DISPERSED_SETTLEMENT_TABLE = exports.GRANT_BURN_TABLE = exports.GRANT_BURN_ID_TABLE = exports.USER_GRANT_SPEND_TABLE = exports.CURRENT_USER_GRANT_SPEND_TABLE = exports.POLYGON_UPGRADE_TABLE = exports.ENTITY_EPOCH_INFO_TABLE = exports.
|
|
48
|
+
exports.pgClient = exports.batchFinishedAtMedian = exports.DISPERSED_SETTLEMENT_TABLE = exports.GRANT_BURN_TABLE = exports.GRANT_BURN_ID_TABLE = exports.USER_GRANT_SPEND_TABLE = exports.CURRENT_USER_GRANT_SPEND_TABLE = exports.POLYGON_UPGRADE_TABLE = exports.ENTITY_EPOCH_INFO_TABLE = exports.BURN_CORRECTION_TABLE = exports.NETWORK_REVENUE_TABLE = exports.BRIDGE_TRANSFER_TABLE = exports.BURN_TABLE = exports.JOB_TABLE = exports.JOB_ID_TABLE = exports.LIABILITY_ADJUSTMENT_BATCH_TABLE = exports.LIABILITY_ADJUSTMENT_TABLE = exports.LIABILITY_TABLE = exports.SOL_TRANSFER_TABLE = exports.ENTITY_TABLE = exports.MANUAL_BURN_TABLE = exports.EPOCH_TABLE = exports.SOL_TX_TABLE = void 0;
|
|
39
49
|
const kysely_1 = require("kysely");
|
|
40
50
|
const logger_1 = require("../../logger");
|
|
41
51
|
const pg_1 = require("pg");
|
|
@@ -54,8 +64,7 @@ exports.JOB_TABLE = 'job';
|
|
|
54
64
|
exports.BURN_TABLE = 'burn';
|
|
55
65
|
exports.BRIDGE_TRANSFER_TABLE = 'bridge_transfer';
|
|
56
66
|
exports.NETWORK_REVENUE_TABLE = 'network_revenue';
|
|
57
|
-
exports.
|
|
58
|
-
exports.TX_BURN_ADJUSTMENT_TABLE = 'tx_burn_adjustment';
|
|
67
|
+
exports.BURN_CORRECTION_TABLE = 'burn_correction';
|
|
59
68
|
exports.ENTITY_EPOCH_INFO_TABLE = 'entity_epoch_info';
|
|
60
69
|
exports.POLYGON_UPGRADE_TABLE = 'polygon_upgrade';
|
|
61
70
|
exports.CURRENT_USER_GRANT_SPEND_TABLE = 'current_user_grant_spend';
|
|
@@ -96,7 +105,7 @@ const pgClient = (config) => {
|
|
|
96
105
|
const db = new kysely_1.Kysely({
|
|
97
106
|
dialect,
|
|
98
107
|
});
|
|
99
|
-
const getOrInsertEntity = (
|
|
108
|
+
const getOrInsertEntity = (db_1, p_1, ...args_1) => __awaiter(void 0, [db_1, p_1, ...args_1], void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
100
109
|
const res = (yield db
|
|
101
110
|
.selectFrom(exports.ENTITY_TABLE)
|
|
102
111
|
.select('id')
|
|
@@ -117,7 +126,7 @@ const pgClient = (config) => {
|
|
|
117
126
|
log.debug(`inserted entity ${id}`);
|
|
118
127
|
return id;
|
|
119
128
|
});
|
|
120
|
-
const getOrInsertTx = (
|
|
129
|
+
const getOrInsertTx = (db_1, p_1, ...args_1) => __awaiter(void 0, [db_1, p_1, ...args_1], void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
121
130
|
const res = yield db
|
|
122
131
|
.selectFrom(exports.SOL_TX_TABLE)
|
|
123
132
|
.select('id')
|
|
@@ -139,7 +148,7 @@ const pgClient = (config) => {
|
|
|
139
148
|
log.debug(`inserted tx ${id}`);
|
|
140
149
|
return id;
|
|
141
150
|
});
|
|
142
|
-
const getOrInsertEpoch = (
|
|
151
|
+
const getOrInsertEpoch = (db_1, p_1, ...args_1) => __awaiter(void 0, [db_1, p_1, ...args_1], void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
143
152
|
const res = yield db
|
|
144
153
|
.selectFrom(exports.EPOCH_TABLE)
|
|
145
154
|
.select('id')
|
|
@@ -167,7 +176,7 @@ const pgClient = (config) => {
|
|
|
167
176
|
log.debug(`inserted epoch ${id}`);
|
|
168
177
|
return id;
|
|
169
178
|
});
|
|
170
|
-
const getCurrentUserGrantSpend = (
|
|
179
|
+
const getCurrentUserGrantSpend = (db_1, p_1, ...args_1) => __awaiter(void 0, [db_1, p_1, ...args_1], void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
171
180
|
var _a;
|
|
172
181
|
const res = yield db
|
|
173
182
|
.selectFrom(exports.CURRENT_USER_GRANT_SPEND_TABLE)
|
|
@@ -197,7 +206,7 @@ const pgClient = (config) => {
|
|
|
197
206
|
.executeTakeFirst());
|
|
198
207
|
log.info(`set ${res.numUpdatedRows} rows. channel: ${p.channel}, ui: ${p.uiEpochId} -> totalRndr ${totalRndr} `);
|
|
199
208
|
});
|
|
200
|
-
const fetchJobs1 = (
|
|
209
|
+
const fetchJobs1 = (db_1, f_1, ...args_1) => __awaiter(void 0, [db_1, f_1, ...args_1], void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
201
210
|
let q = db.selectFrom('job').selectAll();
|
|
202
211
|
//.where('job.burn_id', 'is not', null)
|
|
203
212
|
if (f.completedAtAfter) {
|
|
@@ -227,7 +236,7 @@ const pgClient = (config) => {
|
|
|
227
236
|
insertedAt: r.inserted_at,
|
|
228
237
|
}));
|
|
229
238
|
});
|
|
230
|
-
const fetchJobs2 = (
|
|
239
|
+
const fetchJobs2 = (db_1, f_1, ...args_1) => __awaiter(void 0, [db_1, f_1, ...args_1], void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
231
240
|
let q = db.selectFrom('job').selectAll();
|
|
232
241
|
//.where('job.burn_id', 'is not', null)
|
|
233
242
|
if (f.completedAtAfter) {
|
|
@@ -261,7 +270,7 @@ const pgClient = (config) => {
|
|
|
261
270
|
});
|
|
262
271
|
});
|
|
263
272
|
});
|
|
264
|
-
const createBridgeTransfers = (
|
|
273
|
+
const createBridgeTransfers = (db_1, bts_1, ...args_1) => __awaiter(void 0, [db_1, bts_1, ...args_1], void 0, function* (db, bts, log = logger_1.consoleLogger) {
|
|
265
274
|
const sequenceNumbers = [];
|
|
266
275
|
const dbEpochIds = [];
|
|
267
276
|
for (const bt of bts) {
|
|
@@ -305,7 +314,7 @@ const pgClient = (config) => {
|
|
|
305
314
|
}
|
|
306
315
|
return { sequenceNumbers: sequenceNumbers };
|
|
307
316
|
});
|
|
308
|
-
const createPayments = (
|
|
317
|
+
const createPayments = (db_1, ps_1, ...args_1) => __awaiter(void 0, [db_1, ps_1, ...args_1], void 0, function* (db, ps, log = logger_1.consoleLogger) {
|
|
309
318
|
const ids = [];
|
|
310
319
|
const epochDbIds = [];
|
|
311
320
|
for (const p of ps) {
|
|
@@ -402,18 +411,18 @@ const pgClient = (config) => {
|
|
|
402
411
|
rollback: () => { },
|
|
403
412
|
trx: db,
|
|
404
413
|
},
|
|
405
|
-
startTransaction(
|
|
406
|
-
return __awaiter(this,
|
|
414
|
+
startTransaction() {
|
|
415
|
+
return __awaiter(this, arguments, void 0, function* (log = logger_1.consoleLogger) {
|
|
407
416
|
return (0, base_2.begin)(db, log);
|
|
408
417
|
});
|
|
409
418
|
},
|
|
410
|
-
createPayments(
|
|
411
|
-
return __awaiter(this,
|
|
419
|
+
createPayments(db_1, ps_1) {
|
|
420
|
+
return __awaiter(this, arguments, void 0, function* (db, ps, log = logger_1.consoleLogger) {
|
|
412
421
|
return createPayments(db.trx, ps, log);
|
|
413
422
|
});
|
|
414
423
|
},
|
|
415
|
-
fetchTransfers(
|
|
416
|
-
return __awaiter(this,
|
|
424
|
+
fetchTransfers(db_1, f_1) {
|
|
425
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
417
426
|
let lastId = undefined;
|
|
418
427
|
if (f.cursor) {
|
|
419
428
|
lastId = atob(f.cursor);
|
|
@@ -469,8 +478,8 @@ const pgClient = (config) => {
|
|
|
469
478
|
};
|
|
470
479
|
});
|
|
471
480
|
},
|
|
472
|
-
fetchEpochs(
|
|
473
|
-
return __awaiter(this,
|
|
481
|
+
fetchEpochs(db_1, f_1) {
|
|
482
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
474
483
|
let q = db.trx.selectFrom(exports.EPOCH_TABLE).selectAll();
|
|
475
484
|
if (f.channels) {
|
|
476
485
|
q = q.where('channel', 'in', f.channels);
|
|
@@ -493,9 +502,9 @@ const pgClient = (config) => {
|
|
|
493
502
|
}));
|
|
494
503
|
});
|
|
495
504
|
},
|
|
496
|
-
fetchLiabilities(
|
|
497
|
-
|
|
498
|
-
|
|
505
|
+
fetchLiabilities(db_1, f_1) {
|
|
506
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
507
|
+
var _a;
|
|
499
508
|
let offset = 0;
|
|
500
509
|
let orderBy = (_a = f.orderBy) !== null && _a !== void 0 ? _a : 'epoch.ui,liability.id';
|
|
501
510
|
if (f.cursor) {
|
|
@@ -562,8 +571,8 @@ const pgClient = (config) => {
|
|
|
562
571
|
};
|
|
563
572
|
});
|
|
564
573
|
},
|
|
565
|
-
getLiabilitiesAndTransfers(
|
|
566
|
-
return __awaiter(this,
|
|
574
|
+
getLiabilitiesAndTransfers(f_1) {
|
|
575
|
+
return __awaiter(this, arguments, void 0, function* (f, log = logger_1.consoleLogger) {
|
|
567
576
|
let lq = db
|
|
568
577
|
.selectFrom(exports.LIABILITY_TABLE)
|
|
569
578
|
.selectAll()
|
|
@@ -624,9 +633,9 @@ const pgClient = (config) => {
|
|
|
624
633
|
return { transfers, liabilities, epochs: Object.values(epochs) };
|
|
625
634
|
});
|
|
626
635
|
},
|
|
627
|
-
getOutstanding(
|
|
628
|
-
|
|
629
|
-
|
|
636
|
+
getOutstanding(f_1) {
|
|
637
|
+
return __awaiter(this, arguments, void 0, function* (f, log = logger_1.consoleLogger) {
|
|
638
|
+
var _a, _b, _c, _d, _e;
|
|
630
639
|
log.info(`getting outstanding balances for ${(_a = f.channels) !== null && _a !== void 0 ? _a : '(no channels specified)'} epoch: ${(_b = f.startEpochId.id) !== null && _b !== void 0 ? _b : '(no epoch specified)'}`);
|
|
631
640
|
let epochUi;
|
|
632
641
|
let epochEndTime;
|
|
@@ -762,8 +771,8 @@ const pgClient = (config) => {
|
|
|
762
771
|
return out;
|
|
763
772
|
});
|
|
764
773
|
},
|
|
765
|
-
addLiabilityAdjustments(
|
|
766
|
-
return __awaiter(this,
|
|
774
|
+
addLiabilityAdjustments(batch_1, rows_1) {
|
|
775
|
+
return __awaiter(this, arguments, void 0, function* (batch, rows, log = logger_1.consoleLogger) {
|
|
767
776
|
return yield db.transaction().execute((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
768
777
|
var _a;
|
|
769
778
|
// Upsert the batch by its label (idempotent re-runs; label is the run identity).
|
|
@@ -815,9 +824,9 @@ const pgClient = (config) => {
|
|
|
815
824
|
}));
|
|
816
825
|
});
|
|
817
826
|
},
|
|
818
|
-
fetchNodeOperatorEpoch(
|
|
819
|
-
|
|
820
|
-
|
|
827
|
+
fetchNodeOperatorEpoch(epochId_1) {
|
|
828
|
+
return __awaiter(this, arguments, void 0, function* (epochId, log = logger_1.consoleLogger) {
|
|
829
|
+
var _a;
|
|
821
830
|
const q = db
|
|
822
831
|
.selectFrom(exports.JOB_ID_TABLE)
|
|
823
832
|
.innerJoin(exports.EPOCH_TABLE, 'epoch.id', 'job_id.epoch_id')
|
|
@@ -867,14 +876,14 @@ const pgClient = (config) => {
|
|
|
867
876
|
};
|
|
868
877
|
});
|
|
869
878
|
},
|
|
870
|
-
insertEpoch(
|
|
871
|
-
return __awaiter(this,
|
|
879
|
+
insertEpoch(db_1, epoch_1) {
|
|
880
|
+
return __awaiter(this, arguments, void 0, function* (db, epoch, log = logger_1.consoleLogger) {
|
|
872
881
|
yield getOrInsertEpoch(db.trx, Object.assign(Object.assign({}, epoch), { uiEpochId: epoch.ui }), log);
|
|
873
882
|
});
|
|
874
883
|
},
|
|
875
|
-
getEpoch(
|
|
876
|
-
|
|
877
|
-
|
|
884
|
+
getEpoch(f_1) {
|
|
885
|
+
return __awaiter(this, arguments, void 0, function* (f, log = logger_1.consoleLogger) {
|
|
886
|
+
var _a;
|
|
878
887
|
const now = new Date(Date.now());
|
|
879
888
|
try {
|
|
880
889
|
let q = db
|
|
@@ -912,9 +921,9 @@ const pgClient = (config) => {
|
|
|
912
921
|
}
|
|
913
922
|
});
|
|
914
923
|
},
|
|
915
|
-
getLatestNodeOperatorEpoch(
|
|
916
|
-
|
|
917
|
-
|
|
924
|
+
getLatestNodeOperatorEpoch(f_1) {
|
|
925
|
+
return __awaiter(this, arguments, void 0, function* (f, log = logger_1.consoleLogger) {
|
|
926
|
+
var _a;
|
|
918
927
|
const now = new Date(Date.now());
|
|
919
928
|
try {
|
|
920
929
|
let q = db
|
|
@@ -954,8 +963,8 @@ const pgClient = (config) => {
|
|
|
954
963
|
}
|
|
955
964
|
});
|
|
956
965
|
},
|
|
957
|
-
saveNodeOperatorEpoch(
|
|
958
|
-
return __awaiter(this,
|
|
966
|
+
saveNodeOperatorEpoch(epochId_1, liabilities_1, jobIds_1, totalRndr_1) {
|
|
967
|
+
return __awaiter(this, arguments, void 0, function* (epochId, liabilities, jobIds, totalRndr, log = logger_1.consoleLogger) {
|
|
959
968
|
yield db
|
|
960
969
|
.transaction()
|
|
961
970
|
.setIsolationLevel('repeatable read')
|
|
@@ -991,8 +1000,8 @@ const pgClient = (config) => {
|
|
|
991
1000
|
return;
|
|
992
1001
|
});
|
|
993
1002
|
},
|
|
994
|
-
produceBurnedJobs(
|
|
995
|
-
return __awaiter(this,
|
|
1003
|
+
produceBurnedJobs(jobs_1) {
|
|
1004
|
+
return __awaiter(this, arguments, void 0, function* (jobs, log = logger_1.consoleLogger) {
|
|
996
1005
|
yield db.transaction().execute((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
997
1006
|
var _a;
|
|
998
1007
|
let num = BigInt(0);
|
|
@@ -1015,9 +1024,9 @@ const pgClient = (config) => {
|
|
|
1015
1024
|
}));
|
|
1016
1025
|
});
|
|
1017
1026
|
},
|
|
1018
|
-
markJobsBurntWithGrant(
|
|
1019
|
-
|
|
1020
|
-
|
|
1027
|
+
markJobsBurntWithGrant(db_1, p_1) {
|
|
1028
|
+
return __awaiter(this, arguments, void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
1029
|
+
var _a;
|
|
1021
1030
|
const solTxId = yield getOrInsertTx(db.trx, { sig: p.tx.sig, executedAt: p.tx.executedAt }, log);
|
|
1022
1031
|
const { id } = yield db.trx
|
|
1023
1032
|
.insertInto(exports.GRANT_BURN_TABLE)
|
|
@@ -1048,9 +1057,9 @@ const pgClient = (config) => {
|
|
|
1048
1057
|
return;
|
|
1049
1058
|
});
|
|
1050
1059
|
},
|
|
1051
|
-
insertGrantSpend(
|
|
1052
|
-
|
|
1053
|
-
|
|
1060
|
+
insertGrantSpend(db_1, p_1) {
|
|
1061
|
+
return __awaiter(this, arguments, void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
1062
|
+
var _a, _b, _c;
|
|
1054
1063
|
const existing = yield getCurrentUserGrantSpend(db.trx, { userId: p.userId }, log);
|
|
1055
1064
|
const diff = {
|
|
1056
1065
|
render_spent: ((_a = existing === null || existing === void 0 ? void 0 : existing.renderSpent) !== null && _a !== void 0 ? _a : BigInt(0)) + p.renderSpentDelta,
|
|
@@ -1115,9 +1124,9 @@ const pgClient = (config) => {
|
|
|
1115
1124
|
}
|
|
1116
1125
|
});
|
|
1117
1126
|
},
|
|
1118
|
-
markJobsBurnt(
|
|
1119
|
-
|
|
1120
|
-
|
|
1127
|
+
markJobsBurnt(trx_1, p_1) {
|
|
1128
|
+
return __awaiter(this, arguments, void 0, function* (trx, p, log = logger_1.consoleLogger) {
|
|
1129
|
+
var _a, _b;
|
|
1121
1130
|
if (!p.buyBurn && !p.grantBurn) {
|
|
1122
1131
|
throw new Error('no buyBurn or grantBurn');
|
|
1123
1132
|
}
|
|
@@ -1125,7 +1134,7 @@ const pgClient = (config) => {
|
|
|
1125
1134
|
let buyBurnId;
|
|
1126
1135
|
let grantBurnId;
|
|
1127
1136
|
if (p.buyBurn) {
|
|
1128
|
-
const { burned, usdcSpent, eurToUsdc, renderToUsdc, quoteAmt, tags,
|
|
1137
|
+
const { burned, usdcSpent, eurToUsdc, renderToUsdc, quoteAmt, tags, downCorrectionId, escrowCorrectionId, toBurn, fromEscrowUsdc, } = p.buyBurn;
|
|
1129
1138
|
let pricedAt = p.buyBurn.pricedAt;
|
|
1130
1139
|
if (!pricedAt) {
|
|
1131
1140
|
const jobs = yield fetchJobs1(trx.trx, { ids: p.jobs.map((j) => String(j.id)) }, log);
|
|
@@ -1144,8 +1153,8 @@ const pgClient = (config) => {
|
|
|
1144
1153
|
quote_amt: quoteAmt,
|
|
1145
1154
|
burned: burned,
|
|
1146
1155
|
tags: tags.join(','),
|
|
1147
|
-
|
|
1148
|
-
|
|
1156
|
+
down_correction_id: downCorrectionId,
|
|
1157
|
+
escrow_correction_id: escrowCorrectionId,
|
|
1149
1158
|
to_burn: toBurn,
|
|
1150
1159
|
from_escrow_usdc: fromEscrowUsdc !== null && fromEscrowUsdc !== void 0 ? fromEscrowUsdc : 0,
|
|
1151
1160
|
};
|
|
@@ -1218,8 +1227,8 @@ const pgClient = (config) => {
|
|
|
1218
1227
|
return { grantBurnId, buyBurnId };
|
|
1219
1228
|
});
|
|
1220
1229
|
},
|
|
1221
|
-
markJobsBurned(
|
|
1222
|
-
return __awaiter(this,
|
|
1230
|
+
markJobsBurned(trx_1, p_1) {
|
|
1231
|
+
return __awaiter(this, arguments, void 0, function* (trx, p, log = logger_1.consoleLogger) {
|
|
1223
1232
|
let { markedAt, solTx } = p;
|
|
1224
1233
|
let res = yield trx.trx
|
|
1225
1234
|
.updateTable(exports.BURN_TABLE)
|
|
@@ -1243,8 +1252,8 @@ const pgClient = (config) => {
|
|
|
1243
1252
|
}
|
|
1244
1253
|
});
|
|
1245
1254
|
},
|
|
1246
|
-
consumeAndLockBurnJobs(
|
|
1247
|
-
return __awaiter(this,
|
|
1255
|
+
consumeAndLockBurnJobs(limit_1, lowerRndrThreshold_1, upperRndrThreshold_1) {
|
|
1256
|
+
return __awaiter(this, arguments, void 0, function* (limit, lowerRndrThreshold, upperRndrThreshold, log = logger_1.consoleLogger) {
|
|
1248
1257
|
const trx = yield (0, base_2.begin)(db, log);
|
|
1249
1258
|
const q = trx.trx
|
|
1250
1259
|
.selectFrom(trx.trx
|
|
@@ -1351,9 +1360,9 @@ const pgClient = (config) => {
|
|
|
1351
1360
|
};
|
|
1352
1361
|
});
|
|
1353
1362
|
},
|
|
1354
|
-
incrBuyBurnMetrics(
|
|
1355
|
-
|
|
1356
|
-
|
|
1363
|
+
incrBuyBurnMetrics() {
|
|
1364
|
+
return __awaiter(this, arguments, void 0, function* (log = logger_1.consoleLogger) {
|
|
1365
|
+
var _a;
|
|
1357
1366
|
const res = yield db
|
|
1358
1367
|
.selectFrom(exports.JOB_TABLE)
|
|
1359
1368
|
.select('inserted_at')
|
|
@@ -1370,9 +1379,9 @@ const pgClient = (config) => {
|
|
|
1370
1379
|
};
|
|
1371
1380
|
});
|
|
1372
1381
|
},
|
|
1373
|
-
fetchBurns(
|
|
1374
|
-
|
|
1375
|
-
|
|
1382
|
+
fetchBurns(db_1, f_1) {
|
|
1383
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
1384
|
+
var _a, _b;
|
|
1376
1385
|
let q = db.trx
|
|
1377
1386
|
.selectFrom('burn')
|
|
1378
1387
|
.selectAll('burn')
|
|
@@ -1441,9 +1450,9 @@ const pgClient = (config) => {
|
|
|
1441
1450
|
return burns;
|
|
1442
1451
|
});
|
|
1443
1452
|
},
|
|
1444
|
-
fetchBurnsAndGrants(
|
|
1445
|
-
|
|
1446
|
-
|
|
1453
|
+
fetchBurnsAndGrants(db_1, f_1) {
|
|
1454
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
1455
|
+
var _a, _b;
|
|
1447
1456
|
// Build a unified query to get all transactions with both buy burns and grant burns
|
|
1448
1457
|
let baseQuery = db.trx
|
|
1449
1458
|
.selectFrom('sol_tx')
|
|
@@ -1581,13 +1590,13 @@ const pgClient = (config) => {
|
|
|
1581
1590
|
return groupedBurns;
|
|
1582
1591
|
});
|
|
1583
1592
|
},
|
|
1584
|
-
createBridgeTransfers(
|
|
1585
|
-
return __awaiter(this,
|
|
1593
|
+
createBridgeTransfers(db_1, bts_1) {
|
|
1594
|
+
return __awaiter(this, arguments, void 0, function* (db, bts, log = logger_1.consoleLogger) {
|
|
1586
1595
|
return createBridgeTransfers(db.trx, bts, log);
|
|
1587
1596
|
});
|
|
1588
1597
|
},
|
|
1589
|
-
getBridgeTransfers(
|
|
1590
|
-
return __awaiter(this,
|
|
1598
|
+
getBridgeTransfers(_a) {
|
|
1599
|
+
return __awaiter(this, arguments, void 0, function* ({ solKey, page, }, log = logger_1.consoleLogger) {
|
|
1591
1600
|
let q = db
|
|
1592
1601
|
.selectFrom(exports.BRIDGE_TRANSFER_TABLE)
|
|
1593
1602
|
.innerJoin(exports.EPOCH_TABLE, 'epoch.id', 'bridge_transfer.epoch_id')
|
|
@@ -1664,8 +1673,8 @@ const pgClient = (config) => {
|
|
|
1664
1673
|
});
|
|
1665
1674
|
},
|
|
1666
1675
|
getTotalBurned(db) {
|
|
1667
|
-
var _a, _b;
|
|
1668
1676
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1677
|
+
var _a, _b;
|
|
1669
1678
|
const total = yield db.trx
|
|
1670
1679
|
.selectFrom('burn')
|
|
1671
1680
|
.select(({ fn }) => fn.sum('burned').as('total_burned'))
|
|
@@ -1673,8 +1682,8 @@ const pgClient = (config) => {
|
|
|
1673
1682
|
return BigInt((_b = (_a = total[0]) === null || _a === void 0 ? void 0 : _a.total_burned) !== null && _b !== void 0 ? _b : 0);
|
|
1674
1683
|
});
|
|
1675
1684
|
},
|
|
1676
|
-
insertBurn(
|
|
1677
|
-
return __awaiter(this,
|
|
1685
|
+
insertBurn(p_1) {
|
|
1686
|
+
return __awaiter(this, arguments, void 0, function* (p, log = logger_1.consoleLogger) {
|
|
1678
1687
|
yield db.transaction().execute((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
1679
1688
|
var _a;
|
|
1680
1689
|
const solTxId = yield getOrInsertTx(trx, { sig: p.solTx, executedAt: p.executedAt }, log);
|
|
@@ -1711,9 +1720,9 @@ const pgClient = (config) => {
|
|
|
1711
1720
|
}));
|
|
1712
1721
|
});
|
|
1713
1722
|
},
|
|
1714
|
-
insertDispersedOutbox(
|
|
1715
|
-
|
|
1716
|
-
|
|
1723
|
+
insertDispersedOutbox(p_1) {
|
|
1724
|
+
return __awaiter(this, arguments, void 0, function* (p, log = logger_1.consoleLogger) {
|
|
1725
|
+
var _a, _b, _c;
|
|
1717
1726
|
const res = yield db
|
|
1718
1727
|
.insertInto(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1719
1728
|
.values({
|
|
@@ -1732,8 +1741,8 @@ const pgClient = (config) => {
|
|
|
1732
1741
|
log.debug(`dispersed outbox tx ${p.txSignature}: ${res.numInsertedOrUpdatedRows} row(s)`);
|
|
1733
1742
|
});
|
|
1734
1743
|
},
|
|
1735
|
-
markDispersedSettled(
|
|
1736
|
-
return __awaiter(this,
|
|
1744
|
+
markDispersedSettled(txSignature_1, p_1) {
|
|
1745
|
+
return __awaiter(this, arguments, void 0, function* (txSignature, p, log = logger_1.consoleLogger) {
|
|
1737
1746
|
yield db
|
|
1738
1747
|
.updateTable(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1739
1748
|
.set({ settled_at: new Date(), idempotent_replay: p.idempotentReplay })
|
|
@@ -1742,8 +1751,8 @@ const pgClient = (config) => {
|
|
|
1742
1751
|
log.debug(`dispersed settled tx ${txSignature}`);
|
|
1743
1752
|
});
|
|
1744
1753
|
},
|
|
1745
|
-
getUnsettledDispersed(
|
|
1746
|
-
return __awaiter(this,
|
|
1754
|
+
getUnsettledDispersed() {
|
|
1755
|
+
return __awaiter(this, arguments, void 0, function* (log = logger_1.consoleLogger) {
|
|
1747
1756
|
const rows = yield db
|
|
1748
1757
|
.selectFrom(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1749
1758
|
.selectAll()
|
|
@@ -1769,8 +1778,8 @@ const pgClient = (config) => {
|
|
|
1769
1778
|
});
|
|
1770
1779
|
});
|
|
1771
1780
|
},
|
|
1772
|
-
voidDispersedOutbox(
|
|
1773
|
-
return __awaiter(this,
|
|
1781
|
+
voidDispersedOutbox(txSignature_1) {
|
|
1782
|
+
return __awaiter(this, arguments, void 0, function* (txSignature, log = logger_1.consoleLogger) {
|
|
1774
1783
|
const res = yield db
|
|
1775
1784
|
.deleteFrom(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1776
1785
|
.where('tx_signature', '=', txSignature)
|
|
@@ -1780,9 +1789,9 @@ const pgClient = (config) => {
|
|
|
1780
1789
|
log.debug(`dispersed outbox void tx ${txSignature}: ${res.numDeletedRows} row(s)`);
|
|
1781
1790
|
});
|
|
1782
1791
|
},
|
|
1783
|
-
fetchDispersedSettlements(
|
|
1784
|
-
|
|
1785
|
-
|
|
1792
|
+
fetchDispersedSettlements(f_1) {
|
|
1793
|
+
return __awaiter(this, arguments, void 0, function* (f, _log = logger_1.consoleLogger) {
|
|
1794
|
+
var _a;
|
|
1786
1795
|
let q = db
|
|
1787
1796
|
.selectFrom(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1788
1797
|
// Settled burns only — pending (un-landed) outbox rows aren't real, completed burns.
|
|
@@ -1822,8 +1831,8 @@ const pgClient = (config) => {
|
|
|
1822
1831
|
});
|
|
1823
1832
|
});
|
|
1824
1833
|
},
|
|
1825
|
-
fetchDispersedMonthlyStats(
|
|
1826
|
-
return __awaiter(this,
|
|
1834
|
+
fetchDispersedMonthlyStats(f_1) {
|
|
1835
|
+
return __awaiter(this, arguments, void 0, function* (f, _log = logger_1.consoleLogger) {
|
|
1827
1836
|
let q = db
|
|
1828
1837
|
.selectFrom(exports.DISPERSED_SETTLEMENT_TABLE)
|
|
1829
1838
|
.where('settled_at', 'is not', null);
|
|
@@ -1853,18 +1862,18 @@ const pgClient = (config) => {
|
|
|
1853
1862
|
}));
|
|
1854
1863
|
});
|
|
1855
1864
|
},
|
|
1856
|
-
fetchJobs(
|
|
1857
|
-
return __awaiter(this,
|
|
1865
|
+
fetchJobs(db_1, f_1) {
|
|
1866
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
1858
1867
|
return yield fetchJobs1(db.trx, f, log);
|
|
1859
1868
|
});
|
|
1860
1869
|
},
|
|
1861
|
-
fetchJobsWithGrantValues(
|
|
1862
|
-
return __awaiter(this,
|
|
1870
|
+
fetchJobsWithGrantValues(db_1, f_1) {
|
|
1871
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
1863
1872
|
return yield fetchJobs2(db.trx, f, log);
|
|
1864
1873
|
});
|
|
1865
1874
|
},
|
|
1866
|
-
fetchLiabilityEpochs(
|
|
1867
|
-
return __awaiter(this,
|
|
1875
|
+
fetchLiabilityEpochs(db_1) {
|
|
1876
|
+
return __awaiter(this, arguments, void 0, function* (db, log = logger_1.consoleLogger) {
|
|
1868
1877
|
const q = db.trx
|
|
1869
1878
|
.selectFrom(exports.LIABILITY_TABLE)
|
|
1870
1879
|
.select(({ fn }) => [
|
|
@@ -1922,94 +1931,83 @@ const pgClient = (config) => {
|
|
|
1922
1931
|
}));
|
|
1923
1932
|
});
|
|
1924
1933
|
},
|
|
1925
|
-
|
|
1926
|
-
return __awaiter(this,
|
|
1927
|
-
//
|
|
1934
|
+
createBurnCorrection(trx_1, p_1) {
|
|
1935
|
+
return __awaiter(this, arguments, void 0, function* (trx, p, log = logger_1.consoleLogger) {
|
|
1936
|
+
// Anchor + unit invariants are also DB CHECKs; validate here for a clearer error.
|
|
1937
|
+
if ((p.jobId == null) === (p.solTxId == null))
|
|
1938
|
+
throw new Error('burn_correction needs exactly one anchor (jobId XOR solTxId)');
|
|
1939
|
+
if (p.kind === 'down_adjust' && p.amountRender == null)
|
|
1940
|
+
throw new Error('down_adjust needs amountRender');
|
|
1941
|
+
if (p.kind === 'escrow_credit' && p.amountUsdc == null)
|
|
1942
|
+
throw new Error('escrow_credit needs amountUsdc');
|
|
1943
|
+
// Idempotent per (anchor, kind) — a re-run for the same bad job/tx is a no-op.
|
|
1928
1944
|
const row = yield trx.trx
|
|
1929
|
-
.insertInto(exports.
|
|
1945
|
+
.insertInto(exports.BURN_CORRECTION_TABLE)
|
|
1930
1946
|
.values({
|
|
1947
|
+
kind: p.kind,
|
|
1948
|
+
job_id: p.jobId,
|
|
1931
1949
|
sol_tx_id: p.solTxId,
|
|
1932
|
-
|
|
1950
|
+
amount_render: p.amountRender,
|
|
1951
|
+
amount_usdc: p.amountUsdc,
|
|
1933
1952
|
description: p.description,
|
|
1934
1953
|
})
|
|
1935
|
-
.onConflict((oc) => oc.
|
|
1954
|
+
.onConflict((oc) => oc.doNothing())
|
|
1936
1955
|
.returning('id')
|
|
1937
1956
|
.executeTakeFirst();
|
|
1938
1957
|
if (!row) {
|
|
1939
|
-
log.info(`
|
|
1958
|
+
log.info(`burn_correction ${p.kind} for ${p.jobId != null ? `job ${p.jobId}` : `sol_tx ${p.solTxId}`} already exists — skipped`);
|
|
1940
1959
|
return undefined;
|
|
1941
1960
|
}
|
|
1942
|
-
log.info(`created
|
|
1961
|
+
log.info(`created burn_correction ${row.id} (${p.kind}, ${p.jobId != null ? `job ${p.jobId}` : `sol_tx ${p.solTxId}`}): ${p.kind === 'down_adjust' ? `${p.amountRender} RENDER` : `${p.amountUsdc} USDC`}`);
|
|
1943
1962
|
return Number(row.id);
|
|
1944
1963
|
});
|
|
1945
1964
|
},
|
|
1946
|
-
|
|
1947
|
-
return __awaiter(this,
|
|
1965
|
+
getBurnCorrections(trx_1, ps_1) {
|
|
1966
|
+
return __awaiter(this, arguments, void 0, function* (trx, ps, log = logger_1.consoleLogger) {
|
|
1948
1967
|
if (!ps.toFill)
|
|
1949
1968
|
return [];
|
|
1969
|
+
// fill column depends on kind: down_adjust consumes (to_burn - burned); escrow_credit consumes
|
|
1970
|
+
// from_escrow_usdc. Each links via its own burn FK so one burn can carry one of each.
|
|
1971
|
+
const linkCol = ps.kind === 'down_adjust' ? 'down_correction_id' : 'escrow_correction_id';
|
|
1950
1972
|
const q = trx.trx
|
|
1951
|
-
.selectFrom(exports.
|
|
1952
|
-
.selectAll(exports.
|
|
1953
|
-
.
|
|
1954
|
-
.select([`${exports.JOB_TABLE}.completed_at`, `${exports.JOB_TABLE}.render_amt`])
|
|
1955
|
-
.leftJoin(exports.BURN_TABLE, `${exports.BURN_TABLE}.job_burn_adjustment_id`, `${exports.JOB_BURN_ADJUSTMENT_TABLE}.id`)
|
|
1973
|
+
.selectFrom(exports.BURN_CORRECTION_TABLE)
|
|
1974
|
+
.selectAll(exports.BURN_CORRECTION_TABLE)
|
|
1975
|
+
.leftJoin(exports.BURN_TABLE, `${exports.BURN_TABLE}.${linkCol}`, `${exports.BURN_CORRECTION_TABLE}.id`)
|
|
1956
1976
|
.select(({ fn, lit }) => [
|
|
1957
1977
|
fn.sum(fn.coalesce(`${exports.BURN_TABLE}.to_burn`, lit(0))).as('tot_to_burn'),
|
|
1958
1978
|
fn.sum(fn.coalesce(`${exports.BURN_TABLE}.burned`, lit(0))).as('tot_burned'),
|
|
1959
|
-
])
|
|
1960
|
-
.groupBy([
|
|
1961
|
-
`${exports.JOB_BURN_ADJUSTMENT_TABLE}.id`,
|
|
1962
|
-
`${exports.JOB_TABLE}.completed_at`,
|
|
1963
|
-
`${exports.JOB_TABLE}.render_amt`,
|
|
1964
|
-
]);
|
|
1965
|
-
log.info(`getJobBurnAdjustments ${q.compile().sql}`);
|
|
1966
|
-
const res = yield q.execute();
|
|
1967
|
-
return res
|
|
1968
|
-
.map((r) => ({
|
|
1969
|
-
id: Number(r.id),
|
|
1970
|
-
createdAt: r.created_at,
|
|
1971
|
-
jobId: Number(r.job_id),
|
|
1972
|
-
downAdjRndrUsed: Number(r.down_adj_rndr_used),
|
|
1973
|
-
downAdjToBurn: Number(r.down_adj_to_burn),
|
|
1974
|
-
adjusted: Number(r.tot_to_burn) - Number(r.tot_burned),
|
|
1975
|
-
job: {
|
|
1976
|
-
id: Number(r.job_id),
|
|
1977
|
-
completedAt: r.completed_at,
|
|
1978
|
-
rndrUsed: BigInt(r.render_amt),
|
|
1979
|
-
},
|
|
1980
|
-
}))
|
|
1981
|
-
.filter((a) => a.adjusted < a.downAdjToBurn);
|
|
1982
|
-
});
|
|
1983
|
-
},
|
|
1984
|
-
getTxBurnAdjustments(trx, ps, log = logger_1.consoleLogger) {
|
|
1985
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1986
|
-
if (!ps.toFill)
|
|
1987
|
-
return [];
|
|
1988
|
-
const q = trx.trx
|
|
1989
|
-
.selectFrom(exports.TX_BURN_ADJUSTMENT_TABLE)
|
|
1990
|
-
.selectAll(exports.TX_BURN_ADJUSTMENT_TABLE)
|
|
1991
|
-
.leftJoin(exports.BURN_TABLE, `${exports.BURN_TABLE}.tx_burn_adjustment_id`, `${exports.TX_BURN_ADJUSTMENT_TABLE}.id`)
|
|
1992
|
-
.select(({ fn, lit }) => [
|
|
1993
1979
|
fn
|
|
1994
1980
|
.sum(fn.coalesce(`${exports.BURN_TABLE}.from_escrow_usdc`, lit(0)))
|
|
1995
1981
|
.as('tot_from_escrow'),
|
|
1996
1982
|
])
|
|
1997
|
-
.
|
|
1998
|
-
|
|
1983
|
+
.where(`${exports.BURN_CORRECTION_TABLE}.kind`, '=', ps.kind)
|
|
1984
|
+
.groupBy(`${exports.BURN_CORRECTION_TABLE}.id`)
|
|
1985
|
+
.orderBy(`${exports.BURN_CORRECTION_TABLE}.created_at`, 'asc');
|
|
1986
|
+
log.info(`getBurnCorrections(${ps.kind}) ${q.compile().sql}`);
|
|
1999
1987
|
const res = yield q.execute();
|
|
2000
1988
|
return res
|
|
2001
1989
|
.map((r) => ({
|
|
2002
1990
|
id: Number(r.id),
|
|
2003
1991
|
createdAt: r.created_at,
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
1992
|
+
jobId: r.job_id != null ? Number(r.job_id) : undefined,
|
|
1993
|
+
solTxId: r.sol_tx_id != null ? Number(r.sol_tx_id) : undefined,
|
|
1994
|
+
kind: r.kind,
|
|
1995
|
+
amountRender: r.amount_render != null ? Number(r.amount_render) : undefined,
|
|
1996
|
+
amountUsdc: r.amount_usdc != null ? Number(r.amount_usdc) : undefined,
|
|
1997
|
+
consumed: ps.kind === 'down_adjust'
|
|
1998
|
+
? Number(r.tot_to_burn) - Number(r.tot_burned)
|
|
1999
|
+
: Number(r.tot_from_escrow),
|
|
2007
2000
|
}))
|
|
2008
|
-
.filter((
|
|
2001
|
+
.filter((c) => {
|
|
2002
|
+
var _a, _b;
|
|
2003
|
+
return c.kind === 'down_adjust'
|
|
2004
|
+
? c.consumed < ((_a = c.amountRender) !== null && _a !== void 0 ? _a : 0)
|
|
2005
|
+
: c.consumed < ((_b = c.amountUsdc) !== null && _b !== void 0 ? _b : 0);
|
|
2006
|
+
});
|
|
2009
2007
|
});
|
|
2010
2008
|
},
|
|
2011
|
-
insertPolygonUpgrade(
|
|
2012
|
-
return __awaiter(this,
|
|
2009
|
+
insertPolygonUpgrade(db_1, p_1) {
|
|
2010
|
+
return __awaiter(this, arguments, void 0, function* (db, p, log = logger_1.consoleLogger) {
|
|
2013
2011
|
const solTxId = yield getOrInsertTx(db.trx, {
|
|
2014
2012
|
sig: p.solTx.sig,
|
|
2015
2013
|
executedAt: p.solTx.executedAt,
|
|
@@ -2027,8 +2025,8 @@ const pgClient = (config) => {
|
|
|
2027
2025
|
return;
|
|
2028
2026
|
});
|
|
2029
2027
|
},
|
|
2030
|
-
fetchPolygonUpgrades(
|
|
2031
|
-
return __awaiter(this,
|
|
2028
|
+
fetchPolygonUpgrades(db_1, f_1) {
|
|
2029
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
2032
2030
|
let query = db.trx
|
|
2033
2031
|
.selectFrom('polygon_upgrade')
|
|
2034
2032
|
.selectAll('polygon_upgrade')
|
|
@@ -2054,13 +2052,13 @@ const pgClient = (config) => {
|
|
|
2054
2052
|
}));
|
|
2055
2053
|
});
|
|
2056
2054
|
},
|
|
2057
|
-
getCurrentUserGrantSpend(
|
|
2058
|
-
return __awaiter(this,
|
|
2055
|
+
getCurrentUserGrantSpend(db_1, f_1) {
|
|
2056
|
+
return __awaiter(this, arguments, void 0, function* (db, f, log = logger_1.consoleLogger) {
|
|
2059
2057
|
return yield getCurrentUserGrantSpend(db.trx, f, log);
|
|
2060
2058
|
});
|
|
2061
2059
|
},
|
|
2062
|
-
deleteAll(
|
|
2063
|
-
return __awaiter(this,
|
|
2060
|
+
deleteAll() {
|
|
2061
|
+
return __awaiter(this, arguments, void 0, function* (log = logger_1.consoleLogger) {
|
|
2064
2062
|
if (config.database.includes('render')) {
|
|
2065
2063
|
throw new Error('cannot nuke from deployed database. call from tests only');
|
|
2066
2064
|
}
|
|
@@ -2106,8 +2104,8 @@ const pgClient = (config) => {
|
|
|
2106
2104
|
}
|
|
2107
2105
|
});
|
|
2108
2106
|
},
|
|
2109
|
-
checkPaymentsForDate(
|
|
2110
|
-
return __awaiter(this,
|
|
2107
|
+
checkPaymentsForDate(targetDate_1) {
|
|
2108
|
+
return __awaiter(this, arguments, void 0, function* (targetDate, channel = 'both', log = logger_1.consoleLogger) {
|
|
2111
2109
|
const startOfDay = new Date(targetDate);
|
|
2112
2110
|
startOfDay.setHours(0, 0, 0, 0);
|
|
2113
2111
|
const endOfDay = new Date(targetDate);
|
|
@@ -2158,8 +2156,8 @@ const pgClient = (config) => {
|
|
|
2158
2156
|
}
|
|
2159
2157
|
});
|
|
2160
2158
|
},
|
|
2161
|
-
checkEpochProcessed(
|
|
2162
|
-
return __awaiter(this,
|
|
2159
|
+
checkEpochProcessed(epochId_1, channel_1) {
|
|
2160
|
+
return __awaiter(this, arguments, void 0, function* (epochId, channel, log = logger_1.consoleLogger) {
|
|
2163
2161
|
try {
|
|
2164
2162
|
const result = yield db
|
|
2165
2163
|
.selectFrom('epoch')
|
|
@@ -2179,8 +2177,8 @@ const pgClient = (config) => {
|
|
|
2179
2177
|
}
|
|
2180
2178
|
});
|
|
2181
2179
|
},
|
|
2182
|
-
checkRecentPaymentActivity(
|
|
2183
|
-
return __awaiter(this,
|
|
2180
|
+
checkRecentPaymentActivity() {
|
|
2181
|
+
return __awaiter(this, arguments, void 0, function* (lookbackHours = 2, channel = 'both', log = logger_1.consoleLogger) {
|
|
2184
2182
|
const lookbackTime = new Date(Date.now() - lookbackHours * 60 * 60 * 1000);
|
|
2185
2183
|
const now = new Date();
|
|
2186
2184
|
try {
|