@render-foundation/utils 0.0.253 → 0.0.255
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/client/pg/base.js.map +1 -1
- package/lib/cjs/client/pg/v2Client.js +109 -45
- package/lib/cjs/client/pg/v2Client.js.map +1 -1
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/esm/src/client/pg/base.js.map +1 -1
- package/lib/esm/src/client/pg/v2Client.js +105 -41
- package/lib/esm/src/client/pg/v2Client.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/src/client/pg/base.d.ts +5 -1
- package/lib/types/src/client/pg/base.d.ts.map +1 -1
- package/lib/types/src/client/pg/v2Client.d.ts +1 -1
- package/lib/types/src/client/pg/v2Client.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/client/pg/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6C;AAE7C,yCACC;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/client/pg/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6C;AAE7C,yCACC;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAmED,MAAa,QAAQ;IAMnB;QALS,oCAAoB;QAE7B,oCAA8C;QAC9C,mCAAgC;QAahC,YAAO,GAAG,CAAC,KAAyB,EAAQ,EAAE;YAC5C,IAAI,uBAAA,IAAI,yBAAS,EAAE;gBACjB,uBAAA,IAAI,yBAAS,MAAb,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,WAAgB,EAChB,MAAY,EACZ,QAAc;;QAEd,iEAAiE;QACjE,IAAI,IAAY,CAAA;QAChB,IAAI,MAAM,GAA2B,EAAE,CAAA;QACvC,IAAI,EAAO,CAAA;QAEX,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACnC,IAAI,GAAG,WAAW,CAAA;YAClB,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;gBAChC,EAAE,GAAG,MAAM,CAAA;aACZ;iBAAM;gBACL,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAA;gBACrB,EAAE,GAAG,QAAQ,CAAA;aACd;SACF;aAAM;YACL,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;YACvB,MAAM,GAAG,MAAA,WAAW,CAAC,MAAM,mCAAI,EAAE,CAAA;YACjC,EAAE,GAAG,MAAM,CAAA,CAAC,2BAA2B;SACxC;QAED,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;QAEhE,IAAI,EAAE,EAAE;YACN,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACxC,oDAAoD;YACpD,OAAM;SACP;QACD,OAAO,CAAC,CAAA;IACV,CAAC,CAGA;IAAC,IAAY,CAAC,UAAU,GAAG,SAAS,CAAA;AACvC,CAAC;AA1CD,wDA0CC"}
|
|
@@ -1558,7 +1558,7 @@ const pgClient = (config) => {
|
|
|
1558
1558
|
});
|
|
1559
1559
|
},
|
|
1560
1560
|
fetchBurns(db, f, log = logger_1.consoleLogger) {
|
|
1561
|
-
var _a, _b;
|
|
1561
|
+
var _a, _b, _c;
|
|
1562
1562
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1563
1563
|
let q = db.trx
|
|
1564
1564
|
.selectFrom('burn')
|
|
@@ -1606,6 +1606,7 @@ const pgClient = (config) => {
|
|
|
1606
1606
|
eurToUsdc: r.eur_to_usdc,
|
|
1607
1607
|
markedBurnedAt: r.marked_burned_at,
|
|
1608
1608
|
tags: r.tags ? r.tags.split(',') : [],
|
|
1609
|
+
fromEscrowUsdc: BigInt((_c = r.from_escrow_usdc) !== null && _c !== void 0 ? _c : 0),
|
|
1609
1610
|
});
|
|
1610
1611
|
burnIdToIdx[r.id] = burns.length - 1;
|
|
1611
1612
|
}
|
|
@@ -1631,75 +1632,138 @@ const pgClient = (config) => {
|
|
|
1631
1632
|
fetchBurnsPage(db, f, log = logger_1.consoleLogger) {
|
|
1632
1633
|
var _a;
|
|
1633
1634
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1636
|
-
.
|
|
1637
|
-
.
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
if (f.
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1635
|
+
const params = [];
|
|
1636
|
+
const p = (v) => {
|
|
1637
|
+
params.push(v);
|
|
1638
|
+
return `$${params.length}`;
|
|
1639
|
+
};
|
|
1640
|
+
// Decode cursor — supports new {t,id,ea} format and legacy bare-id format.
|
|
1641
|
+
let cursorEa;
|
|
1642
|
+
let cursorType;
|
|
1643
|
+
let cursorId;
|
|
1644
|
+
if (f.cursor) {
|
|
1645
|
+
const raw = atob(f.cursor);
|
|
1646
|
+
try {
|
|
1647
|
+
const c = JSON.parse(raw);
|
|
1648
|
+
cursorEa = new Date(c.ea);
|
|
1649
|
+
cursorType = c.t;
|
|
1650
|
+
cursorId = c.id;
|
|
1651
|
+
}
|
|
1652
|
+
catch (_b) {
|
|
1653
|
+
// Legacy cursor: bare burn.id — treat as buy-burn cursor.
|
|
1654
|
+
cursorId = Number(raw);
|
|
1655
|
+
cursorType = 'buy';
|
|
1656
|
+
}
|
|
1652
1657
|
}
|
|
1658
|
+
// Shared WHERE fragments pushed into each union leg for index use.
|
|
1659
|
+
const dateFilters = [];
|
|
1660
|
+
if (f.executedAfter)
|
|
1661
|
+
dateFilters.push(`st.executed_at >= ${p(f.executedAfter)}`);
|
|
1662
|
+
if (f.executedBefore)
|
|
1663
|
+
dateFilters.push(`st.executed_at <= ${p(f.executedBefore)}`);
|
|
1664
|
+
const sigFilter = f.sig ? `st.sig = ${p(f.sig)}` : '';
|
|
1665
|
+
// Buy-burn leg
|
|
1666
|
+
const buyWhere = [...dateFilters];
|
|
1667
|
+
if (!f.inclManual)
|
|
1668
|
+
buyWhere.push('b.usdc_spent > 0');
|
|
1669
|
+
if (sigFilter)
|
|
1670
|
+
buyWhere.push(sigFilter);
|
|
1653
1671
|
if (f.jobId !== undefined) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1672
|
+
buyWhere.push(`b.id IN (SELECT burn_id FROM job WHERE id = ${p(f.jobId)})`);
|
|
1673
|
+
}
|
|
1674
|
+
const buyWhereClause = buyWhere.length ? `WHERE ${buyWhere.join(' AND ')}` : '';
|
|
1675
|
+
const buySql = `
|
|
1676
|
+
SELECT 'buy'::text AS type, b.id::bigint AS sortid, b.id AS id,
|
|
1677
|
+
st.executed_at, b.priced_at, b.burned::text AS burned,
|
|
1678
|
+
b.usdc_spent::text AS usdc_spent, b.quote_amt::text AS quote_amt,
|
|
1679
|
+
b.tags, st.sig, b.render_to_usdc, b.eur_to_usdc,
|
|
1680
|
+
coalesce(b.from_escrow_usdc, 0)::text AS from_escrow_usdc,
|
|
1681
|
+
b.down_correction_id, b.escrow_correction_id,
|
|
1682
|
+
b.marked_burned_at
|
|
1683
|
+
FROM burn b
|
|
1684
|
+
INNER JOIN sol_tx st ON st.id = b.sol_tx_id
|
|
1685
|
+
${buyWhereClause}`;
|
|
1686
|
+
// Grant-burn leg
|
|
1687
|
+
const grantWhere = [...dateFilters];
|
|
1688
|
+
if (sigFilter)
|
|
1689
|
+
grantWhere.push(sigFilter);
|
|
1690
|
+
if (f.jobId !== undefined) {
|
|
1691
|
+
grantWhere.push(`gb.id IN (SELECT grant_burn_id FROM job WHERE id = ${p(f.jobId)})`);
|
|
1692
|
+
}
|
|
1693
|
+
const grantWhereClause = grantWhere.length ? `WHERE ${grantWhere.join(' AND ')}` : '';
|
|
1694
|
+
const grantSql = `
|
|
1695
|
+
SELECT 'grant'::text AS type, gb.id::bigint AS sortid, gb.id AS id,
|
|
1696
|
+
st.executed_at, null::timestamp AS priced_at, gb.burned::text AS burned,
|
|
1697
|
+
'0' AS usdc_spent, '0' AS quote_amt,
|
|
1698
|
+
gb.tags, st.sig, null::float8 AS render_to_usdc, null::float8 AS eur_to_usdc,
|
|
1699
|
+
'0' AS from_escrow_usdc,
|
|
1700
|
+
null::bigint AS down_correction_id, null::bigint AS escrow_correction_id,
|
|
1701
|
+
gb.marked_burned_at
|
|
1702
|
+
FROM grant_burn gb
|
|
1703
|
+
INNER JOIN sol_tx st ON st.id = gb.sol_tx_id
|
|
1704
|
+
${grantWhereClause}`;
|
|
1705
|
+
// Cursor filter on the outer query — row comparison for deterministic paging.
|
|
1706
|
+
let cursorFilter = '';
|
|
1707
|
+
if (cursorEa && cursorType && cursorId !== undefined) {
|
|
1708
|
+
cursorFilter = `WHERE (u.executed_at, u.type, u.sortid) > (${p(cursorEa)}, ${p(cursorType)}, ${p(cursorId)})`;
|
|
1709
|
+
}
|
|
1710
|
+
else if (cursorId !== undefined) {
|
|
1711
|
+
// Legacy cursor fallback: only buy burns, ordered by id.
|
|
1712
|
+
cursorFilter = `WHERE u.type = 'buy' AND u.sortid > ${p(cursorId)}`;
|
|
1664
1713
|
}
|
|
1665
1714
|
const limit = (_a = f.limit) !== null && _a !== void 0 ? _a : 1000;
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1715
|
+
const sql = `
|
|
1716
|
+
SELECT u.* FROM (
|
|
1717
|
+
${buySql}
|
|
1718
|
+
UNION ALL
|
|
1719
|
+
${grantSql}
|
|
1720
|
+
) u
|
|
1721
|
+
${cursorFilter}
|
|
1722
|
+
ORDER BY u.executed_at ASC, u.type, u.sortid
|
|
1723
|
+
LIMIT ${p(limit)}`;
|
|
1724
|
+
const { rows } = yield (0, base_1.timedQuery)(pgPool, sql, params, 'fetchBurnsPage', log);
|
|
1669
1725
|
const burns = rows.map((r) => {
|
|
1670
|
-
var _a, _b;
|
|
1726
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1671
1727
|
return ({
|
|
1672
1728
|
jobs: [],
|
|
1673
1729
|
id: Number(r.id),
|
|
1674
|
-
|
|
1730
|
+
type: r.type,
|
|
1731
|
+
renderToUsdc: (_a = r.render_to_usdc) !== null && _a !== void 0 ? _a : undefined,
|
|
1675
1732
|
solTx: r.sig,
|
|
1676
1733
|
executedAt: r.executed_at,
|
|
1677
|
-
pricedAt: r.priced_at,
|
|
1678
|
-
usdcSpent: BigInt((
|
|
1679
|
-
quoteAmt: BigInt((
|
|
1734
|
+
pricedAt: (_b = r.priced_at) !== null && _b !== void 0 ? _b : undefined,
|
|
1735
|
+
usdcSpent: BigInt((_c = r.usdc_spent) !== null && _c !== void 0 ? _c : 0),
|
|
1736
|
+
quoteAmt: BigInt((_d = r.quote_amt) !== null && _d !== void 0 ? _d : 0),
|
|
1680
1737
|
burned: BigInt(r.burned),
|
|
1681
|
-
eurToUsdc: r.eur_to_usdc,
|
|
1738
|
+
eurToUsdc: (_e = r.eur_to_usdc) !== null && _e !== void 0 ? _e : undefined,
|
|
1682
1739
|
markedBurnedAt: r.marked_burned_at,
|
|
1683
1740
|
tags: r.tags ? r.tags.split(',') : [],
|
|
1741
|
+
fromEscrowUsdc: BigInt((_f = r.from_escrow_usdc) !== null && _f !== void 0 ? _f : 0),
|
|
1742
|
+
downCorrectionId: r.down_correction_id ? Number(r.down_correction_id) : undefined,
|
|
1743
|
+
escrowCorrectionId: r.escrow_correction_id ? Number(r.escrow_correction_id) : undefined,
|
|
1684
1744
|
});
|
|
1685
1745
|
});
|
|
1686
1746
|
return {
|
|
1687
1747
|
burns,
|
|
1688
|
-
// Only hand back a cursor on a full page; a short page means we're done.
|
|
1689
1748
|
cursor: burns.length === limit
|
|
1690
|
-
? btoa(
|
|
1749
|
+
? btoa(JSON.stringify({
|
|
1750
|
+
ea: rows[burns.length - 1].executed_at,
|
|
1751
|
+
t: rows[burns.length - 1].type,
|
|
1752
|
+
id: rows[burns.length - 1].sortid,
|
|
1753
|
+
}))
|
|
1691
1754
|
: undefined,
|
|
1692
1755
|
};
|
|
1693
1756
|
});
|
|
1694
1757
|
},
|
|
1695
|
-
fetchBurnJobs(db, burnId, log = logger_1.consoleLogger) {
|
|
1758
|
+
fetchBurnJobs(db, burnId, burnType = 'buy', log = logger_1.consoleLogger) {
|
|
1696
1759
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1760
|
+
const fk = burnType === 'grant' ? 'grant_burn_id' : 'burn_id';
|
|
1697
1761
|
const rows = yield db.trx
|
|
1698
1762
|
.selectFrom('job')
|
|
1699
1763
|
.selectAll('job')
|
|
1700
|
-
.where(
|
|
1764
|
+
.where(fk, '=', String(burnId))
|
|
1701
1765
|
.execute();
|
|
1702
|
-
log.debug(`fetchBurnJobs
|
|
1766
|
+
log.debug(`fetchBurnJobs ${burnType} ${burnId} -> ${rows.length} jobs`);
|
|
1703
1767
|
return rows.map((r) => ({
|
|
1704
1768
|
id: Number(r.id),
|
|
1705
1769
|
completedAt: r.completed_at,
|
|
@@ -1722,8 +1786,8 @@ const pgClient = (config) => {
|
|
|
1722
1786
|
.innerJoin('sol_tx', 'sol_tx.id', 'burn.sol_tx_id')
|
|
1723
1787
|
.select(({ fn }) => [
|
|
1724
1788
|
dayExpr.as('day'),
|
|
1725
|
-
|
|
1726
|
-
|
|
1789
|
+
(0, kysely_1.sql) `SUM(CASE WHEN burn.burned > 0 THEN burn.burned WHEN COALESCE(burn.from_escrow_usdc, 0) > 0 AND burn.render_to_usdc > 0 THEN (burn.from_escrow_usdc::numeric / burn.render_to_usdc * 100)::bigint ELSE 0 END)`.as('render_burned'),
|
|
1790
|
+
(0, kysely_1.sql) `SUM(CASE WHEN burn.usdc_spent > 0 THEN burn.usdc_spent ELSE COALESCE(burn.from_escrow_usdc, 0) END)`.as('usdc_spent'),
|
|
1727
1791
|
fn.count('burn.id').as('burn_count'),
|
|
1728
1792
|
])
|
|
1729
1793
|
.groupBy((0, kysely_1.sql) `date_trunc('day', sol_tx.executed_at)`)
|