@secondlayer/shared 7.5.1 → 7.7.0
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/dist/src/archive/copy-loader.d.ts +49 -0
- package/dist/src/archive/copy-loader.js +111 -0
- package/dist/src/archive/copy-loader.js.map +10 -0
- package/dist/src/archive/range-digest.d.ts +1062 -0
- package/dist/src/archive/range-digest.js +142 -0
- package/dist/src/archive/range-digest.js.map +10 -0
- package/dist/src/db/index.d.ts +107 -1
- package/dist/src/db/index.js +49 -1
- package/dist/src/db/index.js.map +4 -4
- package/dist/src/db/queries/chain-reorgs.d.ts +25 -0
- package/dist/src/db/queries/chain-reorgs.js +49 -1
- package/dist/src/db/queries/chain-reorgs.js.map +4 -4
- package/dist/src/db/queries/contracts.d.ts +25 -0
- package/dist/src/db/queries/integrity.d.ts +25 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +25 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +25 -0
- package/dist/src/db/queries/subgraphs.d.ts +25 -0
- package/dist/src/db/queries/subgraphs.js +49 -1
- package/dist/src/db/queries/subgraphs.js.map +4 -4
- package/dist/src/db/queries/subscriptions.d.ts +25 -0
- package/dist/src/db/schema.d.ts +26 -1
- package/dist/src/index.d.ts +107 -1
- package/dist/src/index.js +49 -1
- package/dist/src/index.js.map +4 -4
- package/dist/src/node/local-client.d.ts +25 -0
- package/migrations/0113_mempool_contract_function_idx.ts +28 -0
- package/migrations/0114_observer_journal.ts +54 -0
- package/package.json +9 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/archive/range-digest.ts
|
|
18
|
+
import { sql } from "kysely";
|
|
19
|
+
var RANGE_DIGEST_SPEC = "md5:sql-identity-v1";
|
|
20
|
+
function identityExpression(dataset) {
|
|
21
|
+
if (dataset === "blocks") {
|
|
22
|
+
return sql`md5(
|
|
23
|
+
height::text || '|' ||
|
|
24
|
+
hash || '|' ||
|
|
25
|
+
parent_hash || '|' ||
|
|
26
|
+
burn_block_height::text || '|' ||
|
|
27
|
+
coalesce(burn_block_hash, '~') || '|' ||
|
|
28
|
+
coalesce(index_block_hash, '~')
|
|
29
|
+
)`;
|
|
30
|
+
}
|
|
31
|
+
if (dataset === "transactions") {
|
|
32
|
+
return sql`md5(
|
|
33
|
+
tx_id || '|' ||
|
|
34
|
+
block_height::text || '|' ||
|
|
35
|
+
tx_index::text || '|' ||
|
|
36
|
+
type || '|' ||
|
|
37
|
+
sender || '|' ||
|
|
38
|
+
status || '|' ||
|
|
39
|
+
coalesce(contract_id, '~') || '|' ||
|
|
40
|
+
coalesce(function_name, '~')
|
|
41
|
+
)`;
|
|
42
|
+
}
|
|
43
|
+
return sql`md5(
|
|
44
|
+
tx_id || '|' ||
|
|
45
|
+
block_height::text || '|' ||
|
|
46
|
+
event_index::text || '|' ||
|
|
47
|
+
type
|
|
48
|
+
)`;
|
|
49
|
+
}
|
|
50
|
+
function orderExpression(dataset) {
|
|
51
|
+
if (dataset === "blocks")
|
|
52
|
+
return sql`height`;
|
|
53
|
+
if (dataset === "transactions")
|
|
54
|
+
return sql`block_height, tx_index, tx_id`;
|
|
55
|
+
return sql`block_height, event_index, tx_id`;
|
|
56
|
+
}
|
|
57
|
+
function fromExpression(dataset) {
|
|
58
|
+
if (dataset === "blocks") {
|
|
59
|
+
return sql`FROM blocks WHERE canonical = true`;
|
|
60
|
+
}
|
|
61
|
+
const table = dataset === "transactions" ? sql`transactions` : sql`events`;
|
|
62
|
+
return sql`FROM ${table} AS child
|
|
63
|
+
JOIN blocks AS b ON b.height = child.block_height AND b.canonical = true
|
|
64
|
+
WHERE true`;
|
|
65
|
+
}
|
|
66
|
+
function heightColumn(dataset) {
|
|
67
|
+
return dataset === "blocks" ? sql`height` : sql`child.block_height`;
|
|
68
|
+
}
|
|
69
|
+
async function computeRangeDigest(db, dataset, fromBlock, toBlock) {
|
|
70
|
+
const { rows } = await sql`
|
|
71
|
+
SELECT
|
|
72
|
+
md5(string_agg(row_digest, '' ORDER BY ord)) AS digest,
|
|
73
|
+
COUNT(*)::text AS row_count
|
|
74
|
+
FROM (
|
|
75
|
+
SELECT
|
|
76
|
+
${identityExpression(dataset)} AS row_digest,
|
|
77
|
+
row_number() OVER (ORDER BY ${orderExpression(dataset)}) AS ord
|
|
78
|
+
${fromExpression(dataset)}
|
|
79
|
+
AND ${heightColumn(dataset)} >= ${fromBlock}
|
|
80
|
+
AND ${heightColumn(dataset)} <= ${toBlock}
|
|
81
|
+
) AS identity_rows
|
|
82
|
+
`.execute(db);
|
|
83
|
+
const row = rows[0];
|
|
84
|
+
const rowCount = Number(row?.row_count ?? 0);
|
|
85
|
+
return {
|
|
86
|
+
dataset,
|
|
87
|
+
from_block: fromBlock,
|
|
88
|
+
to_block: toBlock,
|
|
89
|
+
row_count: rowCount,
|
|
90
|
+
digest: rowCount === 0 ? null : row?.digest ?? null,
|
|
91
|
+
digest_spec: RANGE_DIGEST_SPEC
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function computeRangeDigests(db, fromBlock, toBlock, datasets = [
|
|
95
|
+
"blocks",
|
|
96
|
+
"transactions",
|
|
97
|
+
"events"
|
|
98
|
+
]) {
|
|
99
|
+
const digests = [];
|
|
100
|
+
for (const dataset of datasets) {
|
|
101
|
+
digests.push(await computeRangeDigest(db, dataset, fromBlock, toBlock));
|
|
102
|
+
}
|
|
103
|
+
return digests;
|
|
104
|
+
}
|
|
105
|
+
function compareRangeDigests(local, reference) {
|
|
106
|
+
const localByKey = new Map(local.map((d) => [`${d.dataset}:${d.from_block}-${d.to_block}`, d]));
|
|
107
|
+
return reference.map((expected) => {
|
|
108
|
+
const key = `${expected.dataset}:${expected.from_block}-${expected.to_block}`;
|
|
109
|
+
const actual = localByKey.get(key);
|
|
110
|
+
const base = {
|
|
111
|
+
dataset: expected.dataset,
|
|
112
|
+
from_block: expected.from_block,
|
|
113
|
+
to_block: expected.to_block,
|
|
114
|
+
expected_digest: expected.digest,
|
|
115
|
+
expected_rows: expected.row_count
|
|
116
|
+
};
|
|
117
|
+
if (!actual) {
|
|
118
|
+
return {
|
|
119
|
+
...base,
|
|
120
|
+
status: "missing-locally",
|
|
121
|
+
actual_digest: null,
|
|
122
|
+
actual_rows: 0
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const status = actual.row_count !== expected.row_count ? "count-mismatch" : actual.digest === expected.digest ? "match" : "digest-mismatch";
|
|
126
|
+
return {
|
|
127
|
+
...base,
|
|
128
|
+
status,
|
|
129
|
+
actual_digest: actual.digest,
|
|
130
|
+
actual_rows: actual.row_count
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
computeRangeDigests,
|
|
136
|
+
computeRangeDigest,
|
|
137
|
+
compareRangeDigests,
|
|
138
|
+
RANGE_DIGEST_SPEC
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
//# debugId=D76FA402AE6DA40A64756E2164756E21
|
|
142
|
+
//# sourceMappingURL=range-digest.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/archive/range-digest.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { sql } from \"kysely\";\nimport type { Kysely } from \"kysely\";\nimport type { Database } from \"../db/schema.ts\";\n\n/**\n * Cheap, SQL-computed digests over a height range — the basis of a verify that\n * runs in seconds instead of hours.\n *\n * The archive's per-object `sha256:parquet-object` digests can only be checked\n * by regenerating the Parquet locally, which costs a full export. That is a\n * reasonable paranoid check and a terrible first-run experience: nobody will\n * spend two hours to discover whether they are broken. These digests are\n * computed by the database itself, over the columns that actually carry chain\n * identity, so an operator gets an answer before they lose interest.\n *\n * What this catches is not a subset chosen for convenience — it is precisely\n * the defect class seen in production: missing heights, a canonical child whose\n * `parent_hash` names a block we no longer hold, duplicate canonical rows at one\n * height, and any altered block/transaction identity. What it deliberately does\n * NOT catch is a difference in bulky payload columns (`raw_tx`, event `data`)\n * that leaves identity intact; `--deep` re-export exists for that.\n *\n * Determinism rules, so two independent databases agree:\n * - Aggregate over an explicit ORDER BY, never table order.\n * - Hash each row to a fixed-width digest FIRST, then aggregate those, so the\n * intermediate string is 32 bytes/row rather than the whole row.\n * - Normalize NULL to a sentinel that cannot collide with a real value.\n * - Never include a column whose representation is environment-dependent\n * (timestamps with timezone rendering, generated ids, `created_at`).\n */\n\nexport const RANGE_DIGEST_SPEC = \"md5:sql-identity-v1\" as const;\n\nexport type RangeDigestDataset = \"blocks\" | \"transactions\" | \"events\";\n\nexport type RangeDigest = {\n\tdataset: RangeDigestDataset;\n\tfrom_block: number;\n\tto_block: number;\n\trow_count: number;\n\t/** null when the range holds no rows — an empty range has no digest, and\n\t * that is materially different from \"a digest that happens to be of zero\n\t * rows\", which would compare equal across datasets. */\n\tdigest: string | null;\n\tdigest_spec: typeof RANGE_DIGEST_SPEC;\n};\n\n/**\n * Identity columns per dataset. `blocks` carries the whole corruption surface\n * we care about, which is why quick mode leans on it.\n */\nfunction identityExpression(dataset: RangeDigestDataset) {\n\tif (dataset === \"blocks\") {\n\t\treturn sql`md5(\n\t\t\theight::text || '|' ||\n\t\t\thash || '|' ||\n\t\t\tparent_hash || '|' ||\n\t\t\tburn_block_height::text || '|' ||\n\t\t\tcoalesce(burn_block_hash, '~') || '|' ||\n\t\t\tcoalesce(index_block_hash, '~')\n\t\t)`;\n\t}\n\tif (dataset === \"transactions\") {\n\t\treturn sql`md5(\n\t\t\ttx_id || '|' ||\n\t\t\tblock_height::text || '|' ||\n\t\t\ttx_index::text || '|' ||\n\t\t\ttype || '|' ||\n\t\t\tsender || '|' ||\n\t\t\tstatus || '|' ||\n\t\t\tcoalesce(contract_id, '~') || '|' ||\n\t\t\tcoalesce(function_name, '~')\n\t\t)`;\n\t}\n\treturn sql`md5(\n\t\ttx_id || '|' ||\n\t\tblock_height::text || '|' ||\n\t\tevent_index::text || '|' ||\n\t\ttype\n\t)`;\n}\n\nfunction orderExpression(dataset: RangeDigestDataset) {\n\tif (dataset === \"blocks\") return sql`height`;\n\tif (dataset === \"transactions\") return sql`block_height, tx_index, tx_id`;\n\treturn sql`block_height, event_index, tx_id`;\n}\n\n/**\n * Rows are restricted to CANONICAL blocks in every dataset — a non-canonical\n * row at a height must not change the digest, or a database that merely retains\n * more reorg history than another would report as diverging.\n */\nfunction fromExpression(dataset: RangeDigestDataset) {\n\tif (dataset === \"blocks\") {\n\t\treturn sql`FROM blocks WHERE canonical = true`;\n\t}\n\tconst table = dataset === \"transactions\" ? sql`transactions` : sql`events`;\n\treturn sql`FROM ${table} AS child\n\t\tJOIN blocks AS b ON b.height = child.block_height AND b.canonical = true\n\t\tWHERE true`;\n}\n\nfunction heightColumn(dataset: RangeDigestDataset) {\n\treturn dataset === \"blocks\" ? sql`height` : sql`child.block_height`;\n}\n\nexport async function computeRangeDigest(\n\tdb: Kysely<Database>,\n\tdataset: RangeDigestDataset,\n\tfromBlock: number,\n\ttoBlock: number,\n): Promise<RangeDigest> {\n\tconst { rows } = await sql<{ digest: string | null; row_count: string }>`\n\t\tSELECT\n\t\t\tmd5(string_agg(row_digest, '' ORDER BY ord)) AS digest,\n\t\t\tCOUNT(*)::text AS row_count\n\t\tFROM (\n\t\t\tSELECT\n\t\t\t\t${identityExpression(dataset)} AS row_digest,\n\t\t\t\trow_number() OVER (ORDER BY ${orderExpression(dataset)}) AS ord\n\t\t\t${fromExpression(dataset)}\n\t\t\t\tAND ${heightColumn(dataset)} >= ${fromBlock}\n\t\t\t\tAND ${heightColumn(dataset)} <= ${toBlock}\n\t\t) AS identity_rows\n\t`.execute(db);\n\n\tconst row = rows[0];\n\tconst rowCount = Number(row?.row_count ?? 0);\n\treturn {\n\t\tdataset,\n\t\tfrom_block: fromBlock,\n\t\tto_block: toBlock,\n\t\trow_count: rowCount,\n\t\tdigest: rowCount === 0 ? null : (row?.digest ?? null),\n\t\tdigest_spec: RANGE_DIGEST_SPEC,\n\t};\n}\n\nexport async function computeRangeDigests(\n\tdb: Kysely<Database>,\n\tfromBlock: number,\n\ttoBlock: number,\n\tdatasets: readonly RangeDigestDataset[] = [\n\t\t\"blocks\",\n\t\t\"transactions\",\n\t\t\"events\",\n\t],\n): Promise<RangeDigest[]> {\n\tconst digests: RangeDigest[] = [];\n\tfor (const dataset of datasets) {\n\t\tdigests.push(await computeRangeDigest(db, dataset, fromBlock, toBlock));\n\t}\n\treturn digests;\n}\n\nexport type RangeComparison = {\n\tdataset: RangeDigestDataset;\n\tfrom_block: number;\n\tto_block: number;\n\tstatus: \"match\" | \"digest-mismatch\" | \"count-mismatch\" | \"missing-locally\";\n\texpected_digest: string | null;\n\tactual_digest: string | null;\n\texpected_rows: number;\n\tactual_rows: number;\n};\n\n/**\n * Compare locally computed digests against a reference set.\n *\n * Row count is reported separately from digest because the two failures mean\n * different things to an operator: a count difference is missing or extra data\n * (usually a gap or an un-swept reorg), while an equal count with a different\n * digest means the same number of rows carry different identities — the\n * fork-point corruption signature.\n */\nexport function compareRangeDigests(\n\tlocal: readonly RangeDigest[],\n\treference: readonly RangeDigest[],\n): RangeComparison[] {\n\tconst localByKey = new Map(\n\t\tlocal.map((d) => [`${d.dataset}:${d.from_block}-${d.to_block}`, d]),\n\t);\n\n\treturn reference.map((expected) => {\n\t\tconst key = `${expected.dataset}:${expected.from_block}-${expected.to_block}`;\n\t\tconst actual = localByKey.get(key);\n\t\tconst base = {\n\t\t\tdataset: expected.dataset,\n\t\t\tfrom_block: expected.from_block,\n\t\t\tto_block: expected.to_block,\n\t\t\texpected_digest: expected.digest,\n\t\t\texpected_rows: expected.row_count,\n\t\t};\n\t\tif (!actual) {\n\t\t\treturn {\n\t\t\t\t...base,\n\t\t\t\tstatus: \"missing-locally\" as const,\n\t\t\t\tactual_digest: null,\n\t\t\t\tactual_rows: 0,\n\t\t\t};\n\t\t}\n\t\tconst status =\n\t\t\tactual.row_count !== expected.row_count\n\t\t\t\t? (\"count-mismatch\" as const)\n\t\t\t\t: actual.digest === expected.digest\n\t\t\t\t\t? (\"match\" as const)\n\t\t\t\t\t: (\"digest-mismatch\" as const);\n\t\treturn {\n\t\t\t...base,\n\t\t\tstatus,\n\t\t\tactual_digest: actual.digest,\n\t\t\tactual_rows: actual.row_count,\n\t\t};\n\t});\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "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",
|
|
8
|
+
"debugId": "D76FA402AE6DA40A64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/src/db/index.d.ts
CHANGED
|
@@ -715,6 +715,30 @@ interface PendingForkBlocksTable {
|
|
|
715
715
|
payload: ColumnType<unknown, unknown, unknown>;
|
|
716
716
|
received_at: Generated<Date>;
|
|
717
717
|
}
|
|
718
|
+
type ObserverJournalStatus = "received" | "processed" | "failed";
|
|
719
|
+
/**
|
|
720
|
+
* Exact observer callback receipt. `raw_body` is immutable evidence; the
|
|
721
|
+
* processing columns are updated only after the current derived-state write
|
|
722
|
+
* succeeds or fails.
|
|
723
|
+
*/
|
|
724
|
+
interface ObserverJournalTable {
|
|
725
|
+
sequence: Generated<string>;
|
|
726
|
+
network: string;
|
|
727
|
+
path: string;
|
|
728
|
+
source: string | null;
|
|
729
|
+
received_at: Generated<Date>;
|
|
730
|
+
raw_body: ColumnType<Buffer, Buffer, Buffer>;
|
|
731
|
+
raw_body_sha256: string;
|
|
732
|
+
status: ColumnType<ObserverJournalStatus, ObserverJournalStatus | undefined, ObserverJournalStatus>;
|
|
733
|
+
semantic_sha256: string | null;
|
|
734
|
+
block_height: number | null;
|
|
735
|
+
block_hash: string | null;
|
|
736
|
+
burn_block_height: number | null;
|
|
737
|
+
burn_block_hash: string | null;
|
|
738
|
+
result: unknown | null;
|
|
739
|
+
error: string | null;
|
|
740
|
+
processed_at: Date | null;
|
|
741
|
+
}
|
|
718
742
|
interface Database {
|
|
719
743
|
blocks: BlocksTable;
|
|
720
744
|
transactions: TransactionsTable;
|
|
@@ -778,6 +802,7 @@ interface Database {
|
|
|
778
802
|
x402_balances: X402BalancesTable;
|
|
779
803
|
chain_read_cache: ChainReadCacheTable;
|
|
780
804
|
pending_fork_blocks: PendingForkBlocksTable;
|
|
805
|
+
observer_journal: ObserverJournalTable;
|
|
781
806
|
}
|
|
782
807
|
/** Prepaid x402 credit — one running USD-micros balance per payer principal. */
|
|
783
808
|
interface X402BalancesTable {
|
|
@@ -1090,6 +1115,7 @@ declare const SOURCE_READ_COLUMNS: {
|
|
|
1090
1115
|
readonly transactions: readonly ["block_height", "contract_id", "function_args", "function_name", "raw_result", "raw_tx", "sender", "status", "tx_id", "tx_index", "type"]
|
|
1091
1116
|
readonly mempool_transactions: readonly ["contract_id", "function_args", "function_name", "raw_tx", "received_at", "sender", "seq", "tx_id", "type"]
|
|
1092
1117
|
readonly pox4_calls: readonly ["aggregated_amount_ustx", "aggregated_signer_index", "amount_ustx", "auth_allowed", "auth_id", "auth_period", "auth_topic", "block_height", "block_time", "burn_block_height", "caller", "canonical", "cursor", "delegate_to", "end_cycle", "function_name", "lock_period", "max_amount", "pox_addr_btc", "pox_addr_hashbytes", "pox_addr_version", "result_ok", "reward_cycle", "signer_key", "signer_signature", "source_cursor", "stacker", "start_cycle", "tx_id", "tx_index"]
|
|
1118
|
+
readonly pox5_events: readonly ["amount_sats", "amount_ustx", "block_height", "block_time", "bond_index", "canonical", "cursor", "data", "event_index", "first_reward_cycle", "is_l1_lock", "reward_cycle", "signer", "signer_key", "signer_manager", "staker", "topic", "tx_id", "tx_index", "unlock_burn_height", "unlock_cycle"]
|
|
1093
1119
|
readonly sbtc_events: readonly ["amount", "bitcoin_txid", "block_height", "block_time", "burn_hash", "burn_height", "canonical", "cursor", "event_index", "fee", "governance_contract_type", "governance_new_contract", "max_fee", "output_index", "recipient_btc_hashbytes", "recipient_btc_version", "request_id", "sender", "signer_address", "signer_aggregate_pubkey", "signer_bitmap", "signer_keys_count", "signer_threshold", "sweep_txid", "topic", "tx_id", "tx_index"]
|
|
1094
1120
|
readonly sbtc_token_events: readonly ["amount", "block_height", "block_time", "canonical", "cursor", "event_index", "event_type", "memo", "recipient", "sender", "tx_id", "tx_index"]
|
|
1095
1121
|
readonly bns_name_events: readonly ["block_height", "block_time", "bns_id", "canonical", "cursor", "event_index", "fqn", "hashed_salted_fqn_preorder", "imported_at", "name", "namespace", "owner", "preordered_by", "registered_at", "renewal_height", "stx_burn", "topic", "tx_id", "tx_index"]
|
|
@@ -1371,6 +1397,84 @@ declare const SOURCE_READ_TYPES: {
|
|
|
1371
1397
|
readonly type: "int"
|
|
1372
1398
|
}
|
|
1373
1399
|
}
|
|
1400
|
+
readonly pox5_events: {
|
|
1401
|
+
readonly amount_sats: {
|
|
1402
|
+
readonly type: "text"
|
|
1403
|
+
readonly nullable: true
|
|
1404
|
+
}
|
|
1405
|
+
readonly amount_ustx: {
|
|
1406
|
+
readonly type: "text"
|
|
1407
|
+
readonly nullable: true
|
|
1408
|
+
}
|
|
1409
|
+
readonly block_height: {
|
|
1410
|
+
readonly type: "int"
|
|
1411
|
+
}
|
|
1412
|
+
readonly block_time: {
|
|
1413
|
+
readonly type: "timestamp"
|
|
1414
|
+
}
|
|
1415
|
+
readonly bond_index: {
|
|
1416
|
+
readonly type: "int"
|
|
1417
|
+
readonly nullable: true
|
|
1418
|
+
}
|
|
1419
|
+
readonly canonical: {
|
|
1420
|
+
readonly type: "boolean"
|
|
1421
|
+
}
|
|
1422
|
+
readonly cursor: {
|
|
1423
|
+
readonly type: "text"
|
|
1424
|
+
}
|
|
1425
|
+
readonly data: {
|
|
1426
|
+
readonly type: "jsonb"
|
|
1427
|
+
readonly nullable: true
|
|
1428
|
+
}
|
|
1429
|
+
readonly event_index: {
|
|
1430
|
+
readonly type: "int"
|
|
1431
|
+
}
|
|
1432
|
+
readonly first_reward_cycle: {
|
|
1433
|
+
readonly type: "int"
|
|
1434
|
+
readonly nullable: true
|
|
1435
|
+
}
|
|
1436
|
+
readonly is_l1_lock: {
|
|
1437
|
+
readonly type: "boolean"
|
|
1438
|
+
readonly nullable: true
|
|
1439
|
+
}
|
|
1440
|
+
readonly reward_cycle: {
|
|
1441
|
+
readonly type: "int"
|
|
1442
|
+
readonly nullable: true
|
|
1443
|
+
}
|
|
1444
|
+
readonly signer: {
|
|
1445
|
+
readonly type: "text"
|
|
1446
|
+
readonly nullable: true
|
|
1447
|
+
}
|
|
1448
|
+
readonly signer_key: {
|
|
1449
|
+
readonly type: "text"
|
|
1450
|
+
readonly nullable: true
|
|
1451
|
+
}
|
|
1452
|
+
readonly signer_manager: {
|
|
1453
|
+
readonly type: "text"
|
|
1454
|
+
readonly nullable: true
|
|
1455
|
+
}
|
|
1456
|
+
readonly staker: {
|
|
1457
|
+
readonly type: "text"
|
|
1458
|
+
readonly nullable: true
|
|
1459
|
+
}
|
|
1460
|
+
readonly topic: {
|
|
1461
|
+
readonly type: "text"
|
|
1462
|
+
}
|
|
1463
|
+
readonly tx_id: {
|
|
1464
|
+
readonly type: "text"
|
|
1465
|
+
}
|
|
1466
|
+
readonly tx_index: {
|
|
1467
|
+
readonly type: "int"
|
|
1468
|
+
}
|
|
1469
|
+
readonly unlock_burn_height: {
|
|
1470
|
+
readonly type: "int"
|
|
1471
|
+
readonly nullable: true
|
|
1472
|
+
}
|
|
1473
|
+
readonly unlock_cycle: {
|
|
1474
|
+
readonly type: "int"
|
|
1475
|
+
readonly nullable: true
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1374
1478
|
readonly sbtc_events: {
|
|
1375
1479
|
readonly amount: {
|
|
1376
1480
|
readonly type: "text"
|
|
@@ -1811,6 +1915,7 @@ declare const SOURCE_READ_PKS: {
|
|
|
1811
1915
|
readonly transactions: readonly ["tx_id"]
|
|
1812
1916
|
readonly mempool_transactions: readonly ["seq"]
|
|
1813
1917
|
readonly pox4_calls: readonly ["cursor"]
|
|
1918
|
+
readonly pox5_events: readonly ["cursor"]
|
|
1814
1919
|
readonly sbtc_events: readonly ["cursor"]
|
|
1815
1920
|
readonly sbtc_token_events: readonly ["cursor"]
|
|
1816
1921
|
readonly bns_name_events: readonly ["cursor"]
|
|
@@ -1885,6 +1990,7 @@ declare const TABLE_TO_DB: {
|
|
|
1885
1990
|
chain_reorgs: string
|
|
1886
1991
|
chain_read_cache: string
|
|
1887
1992
|
pending_fork_blocks: string
|
|
1993
|
+
observer_journal: string
|
|
1888
1994
|
decoded_events: string
|
|
1889
1995
|
decoder_checkpoints: string
|
|
1890
1996
|
pox4_calls: string
|
|
@@ -2003,4 +2109,4 @@ declare function getRawClient(role?: "source" | "target"): ReturnType<typeof pos
|
|
|
2003
2109
|
declare function getRawClientFor(url: string): ReturnType<typeof postgres>;
|
|
2004
2110
|
/** Close all DB connection pools. Call in CLI commands to allow process exit. */
|
|
2005
2111
|
declare function closeDb(): Promise<void>;
|
|
2006
|
-
export { sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getDbSplitStatus, getDb, closeDb, assertDbSplit, X402PaymentsTable, X402BalancesTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, TABLE_TO_DB, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, OutboxStatus, NumericAsText, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, Database, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
|
2112
|
+
export { sql, setMigrationRole, parseJsonb, onControlPlane, onChainPlane, jsonb, getTargetDb, getSourceDb, getRawClientFor, getRawClient, getMigrationRole, getDbSplitStatus, getDb, closeDb, assertDbSplit, X402PaymentsTable, X402BalancesTable, UsageSnapshotsTable, UsageSnapshot, UsageDailyTable, UsageDaily, UpdateTransaction, UpdateTenantUsageMonthly, UpdateTenantComputeAddon, UpdateTenant, UpdateSubscriptionOutbox, UpdateSubscription, UpdateSubgraphOperation, UpdateSubgraph, UpdateProject, UpdateIndexProgress, UpdateEvent, UpdateContract, UpdateBlock, UpdateApiKey, UpdateAccountSpendCap, UpdateAccountCredits, TriggerEvaluatorStateTable, TriggerEvaluatorState, TransactionsTable, TransactionsArchiveTable, Transaction, TenantsTable, TenantUsageMonthlyTable, TenantUsageMonthly, TenantStatus, TenantComputeAddonsTable, TenantComputeAddon, Tenant, TeamMembersTable, TeamMember, TeamInvitationsTable, TeamInvitation, TABLE_TO_DB, SubscriptionsTable, SubscriptionStatus, SubscriptionRuntime, SubscriptionOutboxTable, SubscriptionOutbox, SubscriptionKind, SubscriptionFormat, SubscriptionDelivery, SubscriptionDeliveriesTable, Subscription, SubgraphsTable, SubgraphUsageDailyTable, SubgraphUsageDaily, SubgraphTableSnapshotsTable, SubgraphProcessingStatsTable, SubgraphOperationsTable, SubgraphOperationStatus, SubgraphOperationKind, SubgraphOperation, SubgraphHealthSnapshotsTable, SubgraphHealthSnapshot, SubgraphGapsTable, SubgraphGap, Subgraph, SessionsTable, Session, ServiceHeartbeatsTable, SbtcTokenEventsTable, SbtcTokenEventType, SbtcSupplySnapshotsTable, SbtcSettlementsTable, SbtcEventsTable, SbtcEventTopic, SOURCE_READ_TYPES, SOURCE_READ_PKS, SOURCE_READ_COLUMNS, ProvisioningAuditStatus, ProvisioningAuditLogTable, ProvisioningAuditLog, ProvisioningAuditEvent, ProjectsTable, Project, ProcessedStripeEventsTable, Pox5EventsTable, Pox5EventTopic, Pox4SignersDailyTable, Pox4FunctionName, Pox4CyclesDailyTable, Pox4CallsTable, PendingForkBlocksTable, OutboxStatus, ObserverJournalTable, ObserverJournalStatus, NumericAsText, MigrationRole, MempoolTransactionsTable, MempoolTransaction, MagicLinksTable, MagicLink, InsertTransaction, InsertTenantUsageMonthly, InsertTenantComputeAddon, InsertTenant, InsertTeamMember, InsertTeamInvitation, InsertSubscriptionOutbox, InsertSubscriptionDelivery, InsertSubscription, InsertSubgraphUsageDaily, InsertSubgraphOperation, InsertSubgraphHealthSnapshot, InsertSubgraphGap, InsertSubgraph, InsertSession, InsertProvisioningAuditLog, InsertProject, InsertMempoolTransaction, InsertMagicLink, InsertIndexProgress, InsertEvent, InsertContract, InsertClaimToken, InsertBlock, InsertApiKey, InsertAccountSpendCap, InsertAccountInsight, InsertAccountCredits, InsertAccountAgentRun, InsertAccount, IndexProgressTable, IndexProgress, IndexPrimaryKey, IndexColumnType, IndexColumn, EventsTable, EventsArchiveTable, Event, DecoderCheckpointsTable, DecodedEventsTable, DeadLetterEventsTable, DbSplitStatus, DbReadRow, DbPlane, Database, ContractsTable, Contract, ClaimTokensTable, ClaimToken, ChainReorgsTable, ChainReadCacheTable, BurnBlockRewardsTable, BurnBlockRewardSlotsTable, BnsNamespacesTable, BnsNamespaceEventsTable, BnsNamespaceEventStatus, BnsNamesTable, BnsNameEventsTable, BnsNameEventTopic, BnsMarketplaceEventsTable, BnsMarketplaceAction, BlocksTable, Block, ApiKeysTable, ApiKey, AccountsTable, AccountSpendCapsTable, AccountSpendCap, AccountInsightsTable, AccountInsight, AccountCreditsTable, AccountCredits, AccountAgentRunsTable, AccountAgentRun, Account };
|
package/dist/src/db/index.js
CHANGED
|
@@ -245,6 +245,29 @@ var SOURCE_READ_COLUMNS = {
|
|
|
245
245
|
"tx_id",
|
|
246
246
|
"tx_index"
|
|
247
247
|
],
|
|
248
|
+
pox5_events: [
|
|
249
|
+
"amount_sats",
|
|
250
|
+
"amount_ustx",
|
|
251
|
+
"block_height",
|
|
252
|
+
"block_time",
|
|
253
|
+
"bond_index",
|
|
254
|
+
"canonical",
|
|
255
|
+
"cursor",
|
|
256
|
+
"data",
|
|
257
|
+
"event_index",
|
|
258
|
+
"first_reward_cycle",
|
|
259
|
+
"is_l1_lock",
|
|
260
|
+
"reward_cycle",
|
|
261
|
+
"signer",
|
|
262
|
+
"signer_key",
|
|
263
|
+
"signer_manager",
|
|
264
|
+
"staker",
|
|
265
|
+
"topic",
|
|
266
|
+
"tx_id",
|
|
267
|
+
"tx_index",
|
|
268
|
+
"unlock_burn_height",
|
|
269
|
+
"unlock_cycle"
|
|
270
|
+
],
|
|
248
271
|
sbtc_events: [
|
|
249
272
|
"amount",
|
|
250
273
|
"bitcoin_txid",
|
|
@@ -465,6 +488,29 @@ var SOURCE_READ_TYPES = {
|
|
|
465
488
|
tx_id: { type: "text" },
|
|
466
489
|
tx_index: { type: "int" }
|
|
467
490
|
},
|
|
491
|
+
pox5_events: {
|
|
492
|
+
amount_sats: { type: "text", nullable: true },
|
|
493
|
+
amount_ustx: { type: "text", nullable: true },
|
|
494
|
+
block_height: { type: "int" },
|
|
495
|
+
block_time: { type: "timestamp" },
|
|
496
|
+
bond_index: { type: "int", nullable: true },
|
|
497
|
+
canonical: { type: "boolean" },
|
|
498
|
+
cursor: { type: "text" },
|
|
499
|
+
data: { type: "jsonb", nullable: true },
|
|
500
|
+
event_index: { type: "int" },
|
|
501
|
+
first_reward_cycle: { type: "int", nullable: true },
|
|
502
|
+
is_l1_lock: { type: "boolean", nullable: true },
|
|
503
|
+
reward_cycle: { type: "int", nullable: true },
|
|
504
|
+
signer: { type: "text", nullable: true },
|
|
505
|
+
signer_key: { type: "text", nullable: true },
|
|
506
|
+
signer_manager: { type: "text", nullable: true },
|
|
507
|
+
staker: { type: "text", nullable: true },
|
|
508
|
+
topic: { type: "text" },
|
|
509
|
+
tx_id: { type: "text" },
|
|
510
|
+
tx_index: { type: "int" },
|
|
511
|
+
unlock_burn_height: { type: "int", nullable: true },
|
|
512
|
+
unlock_cycle: { type: "int", nullable: true }
|
|
513
|
+
},
|
|
468
514
|
sbtc_events: {
|
|
469
515
|
amount: { type: "text", nullable: true },
|
|
470
516
|
bitcoin_txid: { type: "text", nullable: true },
|
|
@@ -616,6 +662,7 @@ var SOURCE_READ_PKS = {
|
|
|
616
662
|
transactions: ["tx_id"],
|
|
617
663
|
mempool_transactions: ["seq"],
|
|
618
664
|
pox4_calls: ["cursor"],
|
|
665
|
+
pox5_events: ["cursor"],
|
|
619
666
|
sbtc_events: ["cursor"],
|
|
620
667
|
sbtc_token_events: ["cursor"],
|
|
621
668
|
bns_name_events: ["cursor"],
|
|
@@ -658,6 +705,7 @@ var TABLE_TO_DB = {
|
|
|
658
705
|
chain_reorgs: "source",
|
|
659
706
|
chain_read_cache: "source",
|
|
660
707
|
pending_fork_blocks: "source",
|
|
708
|
+
observer_journal: "source",
|
|
661
709
|
decoded_events: "source",
|
|
662
710
|
decoder_checkpoints: "source",
|
|
663
711
|
pox4_calls: "source",
|
|
@@ -901,5 +949,5 @@ export {
|
|
|
901
949
|
SOURCE_READ_COLUMNS
|
|
902
950
|
};
|
|
903
951
|
|
|
904
|
-
//# debugId=
|
|
952
|
+
//# debugId=37AABDB3C4D0230C64756E2164756E21
|
|
905
953
|
//# sourceMappingURL=index.js.map
|