@secondlayer/shared 0.10.1 → 0.10.2
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/db/index.d.ts +2 -0
- package/dist/src/db/queries/accounts.d.ts +2 -0
- package/dist/src/db/queries/integrity.d.ts +2 -0
- package/dist/src/db/queries/metrics.d.ts +2 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +2 -0
- package/dist/src/db/queries/subgraphs.d.ts +2 -0
- package/dist/src/db/queries/usage.d.ts +2 -0
- package/dist/src/db/schema.d.ts +2 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/node/hiro-pg-client.js +5 -3
- package/dist/src/node/hiro-pg-client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +6 -0
- package/dist/src/node/local-client.js +19 -9
- package/dist/src/node/local-client.js.map +3 -3
- package/dist/src/types.d.ts +2 -0
- package/migrations/0021_tx_function_args_result.ts +27 -0
- package/package.json +1 -1
package/dist/src/db/index.d.ts
CHANGED
package/dist/src/db/schema.d.ts
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ class HiroPgClient {
|
|
|
123
123
|
return null;
|
|
124
124
|
const block = blocks[0];
|
|
125
125
|
const txs = await this.sql`
|
|
126
|
-
SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, event_count,
|
|
126
|
+
SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, raw_result, event_count,
|
|
127
127
|
contract_call_contract_id, contract_call_function_name, smart_contract_contract_id
|
|
128
128
|
FROM ${this.sql(SCHEMA)}.txs
|
|
129
129
|
WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true
|
|
@@ -134,6 +134,7 @@ class HiroPgClient {
|
|
|
134
134
|
const entry = {
|
|
135
135
|
txid: toHex(tx.tx_id),
|
|
136
136
|
raw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : "0x00",
|
|
137
|
+
raw_result: tx.raw_result ? toHex(tx.raw_result) : undefined,
|
|
137
138
|
status: mapTxStatus(tx.status),
|
|
138
139
|
tx_index: tx.tx_index,
|
|
139
140
|
tx_type: txType,
|
|
@@ -329,7 +330,7 @@ class HiroPgClient {
|
|
|
329
330
|
blockMap.set(b.block_height, { ...b, transactions: [], events: [] });
|
|
330
331
|
}
|
|
331
332
|
const txs = await this.sql`
|
|
332
|
-
SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, event_count, block_height,
|
|
333
|
+
SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, raw_result, event_count, block_height,
|
|
333
334
|
contract_call_contract_id, contract_call_function_name, smart_contract_contract_id
|
|
334
335
|
FROM ${this.sql(SCHEMA)}.txs
|
|
335
336
|
WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true
|
|
@@ -343,6 +344,7 @@ class HiroPgClient {
|
|
|
343
344
|
const entry = {
|
|
344
345
|
txid: toHex(tx.tx_id),
|
|
345
346
|
raw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : "0x00",
|
|
347
|
+
raw_result: tx.raw_result ? toHex(tx.raw_result) : undefined,
|
|
346
348
|
status: mapTxStatus(tx.status),
|
|
347
349
|
tx_index: tx.tx_index,
|
|
348
350
|
tx_type: txType,
|
|
@@ -539,5 +541,5 @@ export {
|
|
|
539
541
|
HiroPgClient
|
|
540
542
|
};
|
|
541
543
|
|
|
542
|
-
//# debugId=
|
|
544
|
+
//# debugId=BA4EBAB2A677181864756E2164756E21
|
|
543
545
|
//# sourceMappingURL=hiro-pg-client.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/node/hiro-pg-client.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Direct Postgres client for reading from a local Hiro API database.\n *\n * Bypasses the Hiro HTTP API entirely — queries the stacks_blockchain_api\n * schema directly. Orders of magnitude faster for bulk backfill since we\n * avoid per-tx HTTP round-trips and the API's slow UNION event queries.\n *\n * Expects HIRO_PG_URL env var pointing to the Hiro API database, e.g.:\n * postgres://secondlayer:pass@localhost:5432/stacks_blockchain_api\n */\n\nimport postgres from \"postgres\";\n\nconst SCHEMA = \"stacks_blockchain_api\";\n\n// Hiro DB stores bytea; we need 0x-prefixed hex strings\nfunction toHex(buf: Buffer | Uint8Array | null): string {\n\tif (!buf) return \"0x\";\n\treturn \"0x\" + Buffer.from(buf).toString(\"hex\");\n}\n\n// asset_event_type_id mapping: 1=transfer, 2=mint, 3=burn\nfunction stxEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"stx_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"stx_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"stx_burn_event\";\n\t\tdefault:\n\t\t\treturn \"stx_transfer_event\";\n\t}\n}\n\nfunction ftEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"ft_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"ft_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"ft_burn_event\";\n\t\tdefault:\n\t\t\treturn \"ft_transfer_event\";\n\t}\n}\n\nfunction nftEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"nft_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"nft_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"nft_burn_event\";\n\t\tdefault:\n\t\t\treturn \"nft_transfer_event\";\n\t}\n}\n\n// Hiro tx type_id mapping\nfunction mapTxTypeId(typeId: number): string {\n\tswitch (typeId) {\n\t\tcase 0:\n\t\t\treturn \"token_transfer\";\n\t\tcase 1:\n\t\t\treturn \"smart_contract\";\n\t\tcase 2:\n\t\t\treturn \"contract_call\";\n\t\tcase 3:\n\t\t\treturn \"poison_microblock\";\n\t\tcase 4:\n\t\t\treturn \"coinbase\";\n\t\tcase 5:\n\t\t\treturn \"coinbase\"; // coinbase-pay-to-alt\n\t\tcase 6:\n\t\t\treturn \"smart_contract\"; // versioned\n\t\tcase 7:\n\t\t\treturn \"tenure_change\";\n\t\tcase 8:\n\t\t\treturn \"coinbase\"; // nakamoto coinbase\n\t\tdefault:\n\t\t\treturn \"token_transfer\";\n\t}\n}\n\n// Hiro tx status mapping\nfunction mapTxStatus(status: number): string {\n\tswitch (status) {\n\t\tcase 1:\n\t\t\treturn \"success\";\n\t\tcase 0:\n\t\t\treturn \"abort_by_response\";\n\t\tdefault:\n\t\t\treturn \"abort_by_post_condition\";\n\t}\n}\n\ninterface BlockRow {\n\tblock_hash: Buffer;\n\tblock_height: number;\n\tindex_block_hash: Buffer;\n\tparent_block_hash: Buffer;\n\tparent_index_block_hash: Buffer;\n\tburn_block_hash: Buffer;\n\tburn_block_height: number;\n\tburn_block_time: number;\n\tblock_time: number;\n\tminer_txid: Buffer;\n}\n\ninterface TxRow {\n\ttx_id: Buffer;\n\ttx_index: number;\n\ttype_id: number;\n\tstatus: number;\n\tsender_address: string;\n\traw_tx: Buffer;\n\tevent_count: number;\n\tcontract_call_contract_id: string | null;\n\tcontract_call_function_name: string | null;\n\tsmart_contract_contract_id: string | null;\n}\n\nexport class HiroPgClient {\n\tprivate sql: ReturnType<typeof postgres>;\n\n\tconstructor(connectionUrl?: string) {\n\t\tconst url = connectionUrl || process.env.HIRO_PG_URL;\n\t\tif (!url) throw new Error(\"HIRO_PG_URL is required for HiroPgClient\");\n\t\tthis.sql = postgres(url, {\n\t\t\tmax: 10,\n\t\t\tidle_timeout: 30,\n\t\t});\n\t}\n\n\tasync getChainTip(): Promise<number> {\n\t\tconst rows = await this.sql`\n SELECT MAX(block_height) as tip FROM ${this.sql(SCHEMA)}.blocks WHERE canonical = true\n `;\n\t\treturn Number(rows[0]?.tip ?? 0);\n\t}\n\n\t/**\n\t * Fetch a complete block by height directly from PG.\n\t * Returns data in the same NewBlockPayload shape the backfill expects.\n\t */\n\tasync getBlockForIndexer(\n\t\theight: number,\n\t\toptions?: { includeRawTx?: boolean },\n\t): Promise<any | null> {\n\t\t// 1. Block metadata\n\t\tconst blocks = await this.sql<BlockRow[]>`\n SELECT block_hash, block_height, index_block_hash, parent_block_hash,\n parent_index_block_hash, burn_block_hash, burn_block_height,\n burn_block_time, block_time, miner_txid\n FROM ${this.sql(SCHEMA)}.blocks\n WHERE block_height = ${height} AND canonical = true\n LIMIT 1\n `;\n\t\tif (blocks.length === 0) return null;\n\t\tconst block = blocks[0];\n\n\t\t// 2. Transactions\n\t\tconst txs = await this.sql<TxRow[]>`\n SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, event_count,\n contract_call_contract_id, contract_call_function_name, smart_contract_contract_id\n FROM ${this.sql(SCHEMA)}.txs\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY tx_index\n `;\n\n\t\tconst transactions = txs.map((tx) => {\n\t\t\tconst txType = mapTxTypeId(tx.type_id);\n\t\t\tconst entry: any = {\n\t\t\t\ttxid: toHex(tx.tx_id),\n\t\t\t\traw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : \"0x00\",\n\t\t\t\tstatus: mapTxStatus(tx.status),\n\t\t\t\ttx_index: tx.tx_index,\n\t\t\t\ttx_type: txType,\n\t\t\t\tsender_address: tx.sender_address,\n\t\t\t};\n\t\t\tif (txType === \"contract_call\" && tx.contract_call_contract_id) {\n\t\t\t\tentry.contract_call = {\n\t\t\t\t\tcontract_id: tx.contract_call_contract_id,\n\t\t\t\t\tfunction_name: tx.contract_call_function_name || \"\",\n\t\t\t\t};\n\t\t\t} else if (txType === \"smart_contract\" && tx.smart_contract_contract_id) {\n\t\t\t\tentry.smart_contract = {\n\t\t\t\t\tcontract_id: tx.smart_contract_contract_id,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn entry;\n\t\t});\n\n\t\t// 3. Events — query all event tables by block_height (fast, indexed)\n\t\tconst events: any[] = [];\n\n\t\t// STX events\n\t\tconst stxEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, amount, sender, recipient, memo\n FROM ${this.sql(SCHEMA)}.stx_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of stxEvents) {\n\t\t\tconst type = stxEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"stx_transfer_event\") {\n\t\t\t\tevt.stx_transfer_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t\t...(e.memo ? { memo: toHex(e.memo) } : {}),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_mint_event\") {\n\t\t\t\tevt.stx_mint_event = {\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_burn_event\") {\n\t\t\t\tevt.stx_burn_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// STX lock events\n\t\tconst lockEvents = await this.sql`\n SELECT tx_id, event_index, locked_amount, unlock_height, locked_address\n FROM ${this.sql(SCHEMA)}.stx_lock_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of lockEvents) {\n\t\t\tevents.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\tstx_lock_event: {\n\t\t\t\t\tlocked_amount: String(e.locked_amount),\n\t\t\t\t\tunlock_height: String(e.unlock_height),\n\t\t\t\t\tlocked_address: e.locked_address,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// FT events\n\t\tconst ftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, amount, sender, recipient\n FROM ${this.sql(SCHEMA)}.ft_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of ftEvents) {\n\t\t\tconst type = ftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"ft_transfer_event\") {\n\t\t\t\tevt.ft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_mint_event\") {\n\t\t\t\tevt.ft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_burn_event\") {\n\t\t\t\tevt.ft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// NFT events\n\t\tconst nftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, value, sender, recipient\n FROM ${this.sql(SCHEMA)}.nft_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of nftEvents) {\n\t\t\tconst type = nftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tconst val = toHex(e.value);\n\t\t\tif (type === \"nft_transfer_event\") {\n\t\t\t\tevt.nft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_mint_event\") {\n\t\t\t\tevt.nft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_burn_event\") {\n\t\t\t\tevt.nft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// Contract log events\n\t\tconst logEvents = await this.sql`\n SELECT tx_id, event_index, contract_identifier, topic, value\n FROM ${this.sql(SCHEMA)}.contract_logs\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of logEvents) {\n\t\t\tevents.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"smart_contract_event\",\n\t\t\t\tsmart_contract_event: {\n\t\t\t\t\tcontract_identifier: e.contract_identifier,\n\t\t\t\t\ttopic: e.topic,\n\t\t\t\t\tvalue: toHex(e.value),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tblock_hash: toHex(block.block_hash),\n\t\t\tblock_height: block.block_height,\n\t\t\tindex_block_hash: toHex(block.index_block_hash),\n\t\t\tparent_block_hash: toHex(block.parent_block_hash),\n\t\t\tparent_index_block_hash: toHex(block.parent_index_block_hash),\n\t\t\tburn_block_hash: toHex(block.burn_block_hash),\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.burn_block_time,\n\t\t\tminer_txid: toHex(block.miner_txid),\n\t\t\ttimestamp: block.block_time,\n\t\t\ttransactions,\n\t\t\tevents,\n\t\t};\n\t}\n\n\t/**\n\t * Fetch multiple blocks in bulk — 6 queries total instead of 6 per block.\n\t * Returns array of NewBlockPayload in height order.\n\t */\n\tasync getBlockBatch(\n\t\theights: number[],\n\t\toptions?: { includeRawTx?: boolean },\n\t): Promise<any[]> {\n\t\tif (heights.length === 0) return [];\n\n\t\t// 1. All blocks in range\n\t\tconst blocks = await this.sql`\n SELECT block_hash, block_height, index_block_hash, parent_block_hash,\n parent_index_block_hash, burn_block_hash, burn_block_height,\n burn_block_time, block_time, miner_txid\n FROM ${this.sql(SCHEMA)}.blocks\n WHERE block_height = ANY(${heights}) AND canonical = true\n `;\n\n\t\tif (blocks.length === 0) return [];\n\t\tconst blockMap = new Map<number, any>();\n\t\tfor (const b of blocks) {\n\t\t\tblockMap.set(b.block_height, { ...b, transactions: [], events: [] });\n\t\t}\n\n\t\t// 2. All transactions\n\t\tconst txs = await this.sql`\n SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, event_count, block_height,\n contract_call_contract_id, contract_call_function_name, smart_contract_contract_id\n FROM ${this.sql(SCHEMA)}.txs\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n ORDER BY block_height, tx_index\n `;\n\t\tfor (const tx of txs) {\n\t\t\tconst block = blockMap.get(tx.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst txType = mapTxTypeId(tx.type_id);\n\t\t\tconst entry: any = {\n\t\t\t\ttxid: toHex(tx.tx_id),\n\t\t\t\traw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : \"0x00\",\n\t\t\t\tstatus: mapTxStatus(tx.status),\n\t\t\t\ttx_index: tx.tx_index,\n\t\t\t\ttx_type: txType,\n\t\t\t\tsender_address: tx.sender_address,\n\t\t\t};\n\t\t\tif (txType === \"contract_call\" && tx.contract_call_contract_id) {\n\t\t\t\tentry.contract_call = {\n\t\t\t\t\tcontract_id: tx.contract_call_contract_id,\n\t\t\t\t\tfunction_name: tx.contract_call_function_name || \"\",\n\t\t\t\t};\n\t\t\t} else if (txType === \"smart_contract\" && tx.smart_contract_contract_id) {\n\t\t\t\tentry.smart_contract = { contract_id: tx.smart_contract_contract_id };\n\t\t\t}\n\t\t\tblock.transactions.push(entry);\n\t\t}\n\n\t\t// 3. STX events\n\t\tconst stxEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, amount, sender, recipient, memo, block_height\n FROM ${this.sql(SCHEMA)}.stx_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of stxEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = stxEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"stx_transfer_event\") {\n\t\t\t\tevt.stx_transfer_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t\t...(e.memo ? { memo: toHex(e.memo) } : {}),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_mint_event\") {\n\t\t\t\tevt.stx_mint_event = {\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_burn_event\") {\n\t\t\t\tevt.stx_burn_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 4. STX lock events\n\t\tconst lockEvents = await this.sql`\n SELECT tx_id, event_index, locked_amount, unlock_height, locked_address, block_height\n FROM ${this.sql(SCHEMA)}.stx_lock_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of lockEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tblock.events.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\tstx_lock_event: {\n\t\t\t\t\tlocked_amount: String(e.locked_amount),\n\t\t\t\t\tunlock_height: String(e.unlock_height),\n\t\t\t\t\tlocked_address: e.locked_address,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// 5. FT events\n\t\tconst ftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, amount, sender, recipient, block_height\n FROM ${this.sql(SCHEMA)}.ft_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of ftEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = ftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"ft_transfer_event\") {\n\t\t\t\tevt.ft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_mint_event\") {\n\t\t\t\tevt.ft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_burn_event\") {\n\t\t\t\tevt.ft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 6. NFT events\n\t\tconst nftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, value, sender, recipient, block_height\n FROM ${this.sql(SCHEMA)}.nft_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of nftEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = nftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tconst val = toHex(e.value);\n\t\t\tif (type === \"nft_transfer_event\") {\n\t\t\t\tevt.nft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_mint_event\") {\n\t\t\t\tevt.nft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_burn_event\") {\n\t\t\t\tevt.nft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 7. Contract log events\n\t\tconst logEvents = await this.sql`\n SELECT tx_id, event_index, contract_identifier, topic, value, block_height\n FROM ${this.sql(SCHEMA)}.contract_logs\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of logEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tblock.events.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"smart_contract_event\",\n\t\t\t\tsmart_contract_event: {\n\t\t\t\t\tcontract_identifier: e.contract_identifier,\n\t\t\t\t\ttopic: e.topic,\n\t\t\t\t\tvalue: toHex(e.value),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Build results in height order\n\t\treturn heights\n\t\t\t.filter((h) => blockMap.has(h))\n\t\t\t.map((h) => {\n\t\t\t\tconst b = blockMap.get(h)!;\n\t\t\t\treturn {\n\t\t\t\t\tblock_hash: toHex(b.block_hash),\n\t\t\t\t\tblock_height: b.block_height,\n\t\t\t\t\tindex_block_hash: toHex(b.index_block_hash),\n\t\t\t\t\tparent_block_hash: toHex(b.parent_block_hash),\n\t\t\t\t\tparent_index_block_hash: toHex(b.parent_index_block_hash),\n\t\t\t\t\tburn_block_hash: toHex(b.burn_block_hash),\n\t\t\t\t\tburn_block_height: b.burn_block_height,\n\t\t\t\t\tburn_block_timestamp: b.burn_block_time,\n\t\t\t\t\tminer_txid: toHex(b.miner_txid),\n\t\t\t\t\ttimestamp: b.block_time,\n\t\t\t\t\ttransactions: b.transactions,\n\t\t\t\t\tevents: b.events,\n\t\t\t\t};\n\t\t\t});\n\t}\n\n\tasync close(): Promise<void> {\n\t\tawait this.sql.end();\n\t}\n}\n"
|
|
5
|
+
"/**\n * Direct Postgres client for reading from a local Hiro API database.\n *\n * Bypasses the Hiro HTTP API entirely — queries the stacks_blockchain_api\n * schema directly. Orders of magnitude faster for bulk backfill since we\n * avoid per-tx HTTP round-trips and the API's slow UNION event queries.\n *\n * Expects HIRO_PG_URL env var pointing to the Hiro API database, e.g.:\n * postgres://secondlayer:pass@localhost:5432/stacks_blockchain_api\n */\n\nimport postgres from \"postgres\";\n\nconst SCHEMA = \"stacks_blockchain_api\";\n\n// Hiro DB stores bytea; we need 0x-prefixed hex strings\nfunction toHex(buf: Buffer | Uint8Array | null): string {\n\tif (!buf) return \"0x\";\n\treturn \"0x\" + Buffer.from(buf).toString(\"hex\");\n}\n\n// asset_event_type_id mapping: 1=transfer, 2=mint, 3=burn\nfunction stxEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"stx_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"stx_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"stx_burn_event\";\n\t\tdefault:\n\t\t\treturn \"stx_transfer_event\";\n\t}\n}\n\nfunction ftEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"ft_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"ft_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"ft_burn_event\";\n\t\tdefault:\n\t\t\treturn \"ft_transfer_event\";\n\t}\n}\n\nfunction nftEventType(assetTypeId: number): string {\n\tswitch (assetTypeId) {\n\t\tcase 1:\n\t\t\treturn \"nft_transfer_event\";\n\t\tcase 2:\n\t\t\treturn \"nft_mint_event\";\n\t\tcase 3:\n\t\t\treturn \"nft_burn_event\";\n\t\tdefault:\n\t\t\treturn \"nft_transfer_event\";\n\t}\n}\n\n// Hiro tx type_id mapping\nfunction mapTxTypeId(typeId: number): string {\n\tswitch (typeId) {\n\t\tcase 0:\n\t\t\treturn \"token_transfer\";\n\t\tcase 1:\n\t\t\treturn \"smart_contract\";\n\t\tcase 2:\n\t\t\treturn \"contract_call\";\n\t\tcase 3:\n\t\t\treturn \"poison_microblock\";\n\t\tcase 4:\n\t\t\treturn \"coinbase\";\n\t\tcase 5:\n\t\t\treturn \"coinbase\"; // coinbase-pay-to-alt\n\t\tcase 6:\n\t\t\treturn \"smart_contract\"; // versioned\n\t\tcase 7:\n\t\t\treturn \"tenure_change\";\n\t\tcase 8:\n\t\t\treturn \"coinbase\"; // nakamoto coinbase\n\t\tdefault:\n\t\t\treturn \"token_transfer\";\n\t}\n}\n\n// Hiro tx status mapping\nfunction mapTxStatus(status: number): string {\n\tswitch (status) {\n\t\tcase 1:\n\t\t\treturn \"success\";\n\t\tcase 0:\n\t\t\treturn \"abort_by_response\";\n\t\tdefault:\n\t\t\treturn \"abort_by_post_condition\";\n\t}\n}\n\ninterface BlockRow {\n\tblock_hash: Buffer;\n\tblock_height: number;\n\tindex_block_hash: Buffer;\n\tparent_block_hash: Buffer;\n\tparent_index_block_hash: Buffer;\n\tburn_block_hash: Buffer;\n\tburn_block_height: number;\n\tburn_block_time: number;\n\tblock_time: number;\n\tminer_txid: Buffer;\n}\n\ninterface TxRow {\n\ttx_id: Buffer;\n\ttx_index: number;\n\ttype_id: number;\n\tstatus: number;\n\tsender_address: string;\n\traw_tx: Buffer;\n\traw_result: Buffer | null;\n\tevent_count: number;\n\tcontract_call_contract_id: string | null;\n\tcontract_call_function_name: string | null;\n\tsmart_contract_contract_id: string | null;\n}\n\nexport class HiroPgClient {\n\tprivate sql: ReturnType<typeof postgres>;\n\n\tconstructor(connectionUrl?: string) {\n\t\tconst url = connectionUrl || process.env.HIRO_PG_URL;\n\t\tif (!url) throw new Error(\"HIRO_PG_URL is required for HiroPgClient\");\n\t\tthis.sql = postgres(url, {\n\t\t\tmax: 10,\n\t\t\tidle_timeout: 30,\n\t\t});\n\t}\n\n\tasync getChainTip(): Promise<number> {\n\t\tconst rows = await this.sql`\n SELECT MAX(block_height) as tip FROM ${this.sql(SCHEMA)}.blocks WHERE canonical = true\n `;\n\t\treturn Number(rows[0]?.tip ?? 0);\n\t}\n\n\t/**\n\t * Fetch a complete block by height directly from PG.\n\t * Returns data in the same NewBlockPayload shape the backfill expects.\n\t */\n\tasync getBlockForIndexer(\n\t\theight: number,\n\t\toptions?: { includeRawTx?: boolean },\n\t): Promise<any | null> {\n\t\t// 1. Block metadata\n\t\tconst blocks = await this.sql<BlockRow[]>`\n SELECT block_hash, block_height, index_block_hash, parent_block_hash,\n parent_index_block_hash, burn_block_hash, burn_block_height,\n burn_block_time, block_time, miner_txid\n FROM ${this.sql(SCHEMA)}.blocks\n WHERE block_height = ${height} AND canonical = true\n LIMIT 1\n `;\n\t\tif (blocks.length === 0) return null;\n\t\tconst block = blocks[0];\n\n\t\t// 2. Transactions\n\t\tconst txs = await this.sql<TxRow[]>`\n SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, raw_result, event_count,\n contract_call_contract_id, contract_call_function_name, smart_contract_contract_id\n FROM ${this.sql(SCHEMA)}.txs\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY tx_index\n `;\n\n\t\tconst transactions = txs.map((tx) => {\n\t\t\tconst txType = mapTxTypeId(tx.type_id);\n\t\t\tconst entry: any = {\n\t\t\t\ttxid: toHex(tx.tx_id),\n\t\t\t\traw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : \"0x00\",\n\t\t\t\traw_result: tx.raw_result ? toHex(tx.raw_result) : undefined,\n\t\t\t\tstatus: mapTxStatus(tx.status),\n\t\t\t\ttx_index: tx.tx_index,\n\t\t\t\ttx_type: txType,\n\t\t\t\tsender_address: tx.sender_address,\n\t\t\t};\n\t\t\tif (txType === \"contract_call\" && tx.contract_call_contract_id) {\n\t\t\t\tentry.contract_call = {\n\t\t\t\t\tcontract_id: tx.contract_call_contract_id,\n\t\t\t\t\tfunction_name: tx.contract_call_function_name || \"\",\n\t\t\t\t};\n\t\t\t} else if (txType === \"smart_contract\" && tx.smart_contract_contract_id) {\n\t\t\t\tentry.smart_contract = {\n\t\t\t\t\tcontract_id: tx.smart_contract_contract_id,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn entry;\n\t\t});\n\n\t\t// 3. Events — query all event tables by block_height (fast, indexed)\n\t\tconst events: any[] = [];\n\n\t\t// STX events\n\t\tconst stxEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, amount, sender, recipient, memo\n FROM ${this.sql(SCHEMA)}.stx_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of stxEvents) {\n\t\t\tconst type = stxEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"stx_transfer_event\") {\n\t\t\t\tevt.stx_transfer_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t\t...(e.memo ? { memo: toHex(e.memo) } : {}),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_mint_event\") {\n\t\t\t\tevt.stx_mint_event = {\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_burn_event\") {\n\t\t\t\tevt.stx_burn_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// STX lock events\n\t\tconst lockEvents = await this.sql`\n SELECT tx_id, event_index, locked_amount, unlock_height, locked_address\n FROM ${this.sql(SCHEMA)}.stx_lock_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of lockEvents) {\n\t\t\tevents.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\tstx_lock_event: {\n\t\t\t\t\tlocked_amount: String(e.locked_amount),\n\t\t\t\t\tunlock_height: String(e.unlock_height),\n\t\t\t\t\tlocked_address: e.locked_address,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// FT events\n\t\tconst ftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, amount, sender, recipient\n FROM ${this.sql(SCHEMA)}.ft_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of ftEvents) {\n\t\t\tconst type = ftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"ft_transfer_event\") {\n\t\t\t\tevt.ft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_mint_event\") {\n\t\t\t\tevt.ft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_burn_event\") {\n\t\t\t\tevt.ft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// NFT events\n\t\tconst nftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, value, sender, recipient\n FROM ${this.sql(SCHEMA)}.nft_events\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of nftEvents) {\n\t\t\tconst type = nftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tconst val = toHex(e.value);\n\t\t\tif (type === \"nft_transfer_event\") {\n\t\t\t\tevt.nft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_mint_event\") {\n\t\t\t\tevt.nft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_burn_event\") {\n\t\t\t\tevt.nft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t}\n\t\t\tevents.push(evt);\n\t\t}\n\n\t\t// Contract log events\n\t\tconst logEvents = await this.sql`\n SELECT tx_id, event_index, contract_identifier, topic, value\n FROM ${this.sql(SCHEMA)}.contract_logs\n WHERE block_height = ${height} AND canonical = true AND microblock_canonical = true\n ORDER BY event_index\n `;\n\t\tfor (const e of logEvents) {\n\t\t\tevents.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"smart_contract_event\",\n\t\t\t\tsmart_contract_event: {\n\t\t\t\t\tcontract_identifier: e.contract_identifier,\n\t\t\t\t\ttopic: e.topic,\n\t\t\t\t\tvalue: toHex(e.value),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tblock_hash: toHex(block.block_hash),\n\t\t\tblock_height: block.block_height,\n\t\t\tindex_block_hash: toHex(block.index_block_hash),\n\t\t\tparent_block_hash: toHex(block.parent_block_hash),\n\t\t\tparent_index_block_hash: toHex(block.parent_index_block_hash),\n\t\t\tburn_block_hash: toHex(block.burn_block_hash),\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.burn_block_time,\n\t\t\tminer_txid: toHex(block.miner_txid),\n\t\t\ttimestamp: block.block_time,\n\t\t\ttransactions,\n\t\t\tevents,\n\t\t};\n\t}\n\n\t/**\n\t * Fetch multiple blocks in bulk — 6 queries total instead of 6 per block.\n\t * Returns array of NewBlockPayload in height order.\n\t */\n\tasync getBlockBatch(\n\t\theights: number[],\n\t\toptions?: { includeRawTx?: boolean },\n\t): Promise<any[]> {\n\t\tif (heights.length === 0) return [];\n\n\t\t// 1. All blocks in range\n\t\tconst blocks = await this.sql`\n SELECT block_hash, block_height, index_block_hash, parent_block_hash,\n parent_index_block_hash, burn_block_hash, burn_block_height,\n burn_block_time, block_time, miner_txid\n FROM ${this.sql(SCHEMA)}.blocks\n WHERE block_height = ANY(${heights}) AND canonical = true\n `;\n\n\t\tif (blocks.length === 0) return [];\n\t\tconst blockMap = new Map<number, any>();\n\t\tfor (const b of blocks) {\n\t\t\tblockMap.set(b.block_height, { ...b, transactions: [], events: [] });\n\t\t}\n\n\t\t// 2. All transactions\n\t\tconst txs = await this.sql`\n SELECT tx_id, tx_index, type_id, status, sender_address, raw_tx, raw_result, event_count, block_height,\n contract_call_contract_id, contract_call_function_name, smart_contract_contract_id\n FROM ${this.sql(SCHEMA)}.txs\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n ORDER BY block_height, tx_index\n `;\n\t\tfor (const tx of txs) {\n\t\t\tconst block = blockMap.get(tx.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst txType = mapTxTypeId(tx.type_id);\n\t\t\tconst entry: any = {\n\t\t\t\ttxid: toHex(tx.tx_id),\n\t\t\t\traw_tx: options?.includeRawTx ? toHex(tx.raw_tx) : \"0x00\",\n\t\t\t\traw_result: tx.raw_result ? toHex(tx.raw_result) : undefined,\n\t\t\t\tstatus: mapTxStatus(tx.status),\n\t\t\t\ttx_index: tx.tx_index,\n\t\t\t\ttx_type: txType,\n\t\t\t\tsender_address: tx.sender_address,\n\t\t\t};\n\t\t\tif (txType === \"contract_call\" && tx.contract_call_contract_id) {\n\t\t\t\tentry.contract_call = {\n\t\t\t\t\tcontract_id: tx.contract_call_contract_id,\n\t\t\t\t\tfunction_name: tx.contract_call_function_name || \"\",\n\t\t\t\t};\n\t\t\t} else if (txType === \"smart_contract\" && tx.smart_contract_contract_id) {\n\t\t\t\tentry.smart_contract = { contract_id: tx.smart_contract_contract_id };\n\t\t\t}\n\t\t\tblock.transactions.push(entry);\n\t\t}\n\n\t\t// 3. STX events\n\t\tconst stxEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, amount, sender, recipient, memo, block_height\n FROM ${this.sql(SCHEMA)}.stx_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of stxEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = stxEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"stx_transfer_event\") {\n\t\t\t\tevt.stx_transfer_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t\t...(e.memo ? { memo: toHex(e.memo) } : {}),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_mint_event\") {\n\t\t\t\tevt.stx_mint_event = {\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"stx_burn_event\") {\n\t\t\t\tevt.stx_burn_event = {\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 4. STX lock events\n\t\tconst lockEvents = await this.sql`\n SELECT tx_id, event_index, locked_amount, unlock_height, locked_address, block_height\n FROM ${this.sql(SCHEMA)}.stx_lock_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of lockEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tblock.events.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\tstx_lock_event: {\n\t\t\t\t\tlocked_amount: String(e.locked_amount),\n\t\t\t\t\tunlock_height: String(e.unlock_height),\n\t\t\t\t\tlocked_address: e.locked_address,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// 5. FT events\n\t\tconst ftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, amount, sender, recipient, block_height\n FROM ${this.sql(SCHEMA)}.ft_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of ftEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = ftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tif (type === \"ft_transfer_event\") {\n\t\t\t\tevt.ft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_mint_event\") {\n\t\t\t\tevt.ft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t} else if (type === \"ft_burn_event\") {\n\t\t\t\tevt.ft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tamount: String(e.amount),\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 6. NFT events\n\t\tconst nftEvents = await this.sql`\n SELECT tx_id, event_index, asset_event_type_id, asset_identifier, value, sender, recipient, block_height\n FROM ${this.sql(SCHEMA)}.nft_events\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of nftEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tconst type = nftEventType(e.asset_event_type_id);\n\t\t\tconst evt: any = {\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype,\n\t\t\t};\n\t\t\tconst val = toHex(e.value);\n\t\t\tif (type === \"nft_transfer_event\") {\n\t\t\t\tevt.nft_transfer_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_mint_event\") {\n\t\t\t\tevt.nft_mint_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\trecipient: e.recipient || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t} else if (type === \"nft_burn_event\") {\n\t\t\t\tevt.nft_burn_event = {\n\t\t\t\t\tasset_identifier: e.asset_identifier,\n\t\t\t\t\tsender: e.sender || \"\",\n\t\t\t\t\tvalue: val,\n\t\t\t\t};\n\t\t\t}\n\t\t\tblock.events.push(evt);\n\t\t}\n\n\t\t// 7. Contract log events\n\t\tconst logEvents = await this.sql`\n SELECT tx_id, event_index, contract_identifier, topic, value, block_height\n FROM ${this.sql(SCHEMA)}.contract_logs\n WHERE block_height = ANY(${heights}) AND canonical = true AND microblock_canonical = true\n `;\n\t\tfor (const e of logEvents) {\n\t\t\tconst block = blockMap.get(e.block_height);\n\t\t\tif (!block) continue;\n\t\t\tblock.events.push({\n\t\t\t\ttxid: toHex(e.tx_id),\n\t\t\t\tevent_index: e.event_index,\n\t\t\t\tcommitted: true,\n\t\t\t\ttype: \"smart_contract_event\",\n\t\t\t\tsmart_contract_event: {\n\t\t\t\t\tcontract_identifier: e.contract_identifier,\n\t\t\t\t\ttopic: e.topic,\n\t\t\t\t\tvalue: toHex(e.value),\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Build results in height order\n\t\treturn heights\n\t\t\t.filter((h) => blockMap.has(h))\n\t\t\t.map((h) => {\n\t\t\t\tconst b = blockMap.get(h)!;\n\t\t\t\treturn {\n\t\t\t\t\tblock_hash: toHex(b.block_hash),\n\t\t\t\t\tblock_height: b.block_height,\n\t\t\t\t\tindex_block_hash: toHex(b.index_block_hash),\n\t\t\t\t\tparent_block_hash: toHex(b.parent_block_hash),\n\t\t\t\t\tparent_index_block_hash: toHex(b.parent_index_block_hash),\n\t\t\t\t\tburn_block_hash: toHex(b.burn_block_hash),\n\t\t\t\t\tburn_block_height: b.burn_block_height,\n\t\t\t\t\tburn_block_timestamp: b.burn_block_time,\n\t\t\t\t\tminer_txid: toHex(b.miner_txid),\n\t\t\t\t\ttimestamp: b.block_time,\n\t\t\t\t\ttransactions: b.transactions,\n\t\t\t\t\tevents: b.events,\n\t\t\t\t};\n\t\t\t});\n\t}\n\n\tasync close(): Promise<void> {\n\t\tawait this.sql.end();\n\t}\n}\n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,IAAI,MAAM;AAAA,iCACK;AAAA;AAAA,IAE/B,WAAW,KAAK,WAAW;AAAA,MAC1B,MAAM,QAAQ,SAAS,IAAI,EAAE,YAAY;AAAA,MACzC,IAAI,CAAC;AAAA,QAAO;AAAA,MACZ,MAAM,OAAO,KAAK;AAAA,QACjB,MAAM,MAAM,EAAE,KAAK;AAAA,QACnB,aAAa,EAAE;AAAA,QACf,WAAW;AAAA,QACX,MAAM;AAAA,QACN,sBAAsB;AAAA,UACrB,qBAAqB,EAAE;AAAA,UACvB,OAAO,EAAE;AAAA,UACT,OAAO,MAAM,EAAE,KAAK;AAAA,QACrB;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IAGA,OAAO,QACL,OAAO,CAAC,MAAM,SAAS,IAAI,CAAC,CAAC,EAC7B,IAAI,CAAC,MAAM;AAAA,MACX,MAAM,IAAI,SAAS,IAAI,CAAC;AAAA,MACxB,OAAO;AAAA,QACN,YAAY,MAAM,EAAE,UAAU;AAAA,QAC9B,cAAc,EAAE;AAAA,QAChB,kBAAkB,MAAM,EAAE,gBAAgB;AAAA,QAC1C,mBAAmB,MAAM,EAAE,iBAAiB;AAAA,QAC5C,yBAAyB,MAAM,EAAE,uBAAuB;AAAA,QACxD,iBAAiB,MAAM,EAAE,eAAe;AAAA,QACxC,mBAAmB,EAAE;AAAA,QACrB,sBAAsB,EAAE;AAAA,QACxB,YAAY,MAAM,EAAE,UAAU;AAAA,QAC9B,WAAW,EAAE;AAAA,QACb,cAAc,EAAE;AAAA,QAChB,QAAQ,EAAE;AAAA,MACX;AAAA,KACA;AAAA;AAAA,OAGG,MAAK,GAAkB;AAAA,IAC5B,MAAM,KAAK,IAAI,IAAI;AAAA;AAErB;",
|
|
8
|
+
"debugId": "BA4EBAB2A677181864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -18,6 +18,8 @@ interface TransactionsTable {
|
|
|
18
18
|
status: string;
|
|
19
19
|
contract_id: string | null;
|
|
20
20
|
function_name: string | null;
|
|
21
|
+
function_args: Generated<unknown | null>;
|
|
22
|
+
raw_result: Generated<string | null>;
|
|
21
23
|
raw_tx: string;
|
|
22
24
|
created_at: Generated<Date>;
|
|
23
25
|
}
|
|
@@ -277,6 +279,10 @@ interface ReplayTransactionPayload {
|
|
|
277
279
|
tx_index: number;
|
|
278
280
|
tx_type?: string;
|
|
279
281
|
sender_address?: string;
|
|
282
|
+
raw_result?: string | null;
|
|
283
|
+
contract_call?: {
|
|
284
|
+
function_args: string[]
|
|
285
|
+
};
|
|
280
286
|
}
|
|
281
287
|
interface ReplayEventPayload {
|
|
282
288
|
txid: string;
|
|
@@ -33,14 +33,24 @@ class LocalClient {
|
|
|
33
33
|
burn_block_timestamp: block.timestamp,
|
|
34
34
|
miner_txid: "",
|
|
35
35
|
timestamp: block.timestamp,
|
|
36
|
-
transactions: transactions.map((tx) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
transactions: transactions.map((tx) => {
|
|
37
|
+
const entry = {
|
|
38
|
+
txid: tx.tx_id,
|
|
39
|
+
raw_tx: tx.raw_tx,
|
|
40
|
+
status: tx.status,
|
|
41
|
+
tx_index: tx.tx_index,
|
|
42
|
+
tx_type: tx.type,
|
|
43
|
+
sender_address: tx.sender,
|
|
44
|
+
raw_result: tx.raw_result ?? null
|
|
45
|
+
};
|
|
46
|
+
if (tx.function_args) {
|
|
47
|
+
const args = typeof tx.function_args === "string" ? JSON.parse(tx.function_args) : tx.function_args;
|
|
48
|
+
if (Array.isArray(args)) {
|
|
49
|
+
entry.contract_call = { function_args: args };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return entry;
|
|
53
|
+
}),
|
|
44
54
|
events: events.map((evt) => {
|
|
45
55
|
const data = evt.data ?? {};
|
|
46
56
|
const eventType = evt.type;
|
|
@@ -70,5 +80,5 @@ export {
|
|
|
70
80
|
LocalClient
|
|
71
81
|
};
|
|
72
82
|
|
|
73
|
-
//# debugId=
|
|
83
|
+
//# debugId=431DDE218D6D481C64756E2164756E21
|
|
74
84
|
//# sourceMappingURL=local-client.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/node/local-client.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Local replay client — reconstructs NewBlockPayload from our own Postgres.\n *\n * Used for re-orgs, reprocessing, and self-serve replay after genesis sync.\n * Eliminates need for self-hosted Hiro API for blocks already in our DB.\n */\n\nimport type { Kysely } from \"kysely\";\nimport type { Database } from \"../db/types.ts\";\n\n/** Matches the NewBlockPayload shape expected by the indexer's /new_block endpoint */\nexport interface ReplayBlockPayload {\n\tblock_hash: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_timestamp: number;\n\tminer_txid: string;\n\ttimestamp: number;\n\ttransactions: ReplayTransactionPayload[];\n\tevents: ReplayEventPayload[];\n}\n\ninterface ReplayTransactionPayload {\n\ttxid: string;\n\traw_tx: string;\n\tstatus: string;\n\ttx_index: number;\n\ttx_type?: string;\n\tsender_address?: string;\n}\n\ninterface ReplayEventPayload {\n\ttxid: string;\n\tevent_index: number;\n\tcommitted: boolean;\n\ttype: string;\n\t[key: string]: unknown;\n}\n\nexport class LocalClient {\n\t/**\n\t * Reconstruct a NewBlockPayload from local DB for replay.\n\t * Returns null if block not found.\n\t */\n\tasync getBlockForReplay(\n\t\tdb: Kysely<Database>,\n\t\theight: number,\n\t): Promise<ReplayBlockPayload | null> {\n\t\tconst block = await db\n\t\t\t.selectFrom(\"blocks\")\n\t\t\t.selectAll()\n\t\t\t.where(\"height\", \"=\", height)\n\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t.executeTakeFirst();\n\n\t\tif (!block) return null;\n\n\t\tconst transactions = await db\n\t\t\t.selectFrom(\"transactions\")\n\t\t\t.selectAll()\n\t\t\t.where(\"block_height\", \"=\", height)\n\t\t\t.orderBy(\"tx_index\", \"asc\")\n\t\t\t.execute();\n\n\t\tconst events = await db\n\t\t\t.selectFrom(\"events\")\n\t\t\t.selectAll()\n\t\t\t.where(\"block_height\", \"=\", height)\n\t\t\t.orderBy(\"event_index\", \"asc\")\n\t\t\t.execute();\n\n\t\treturn {\n\t\t\tblock_hash: block.hash,\n\t\t\tblock_height: block.height,\n\t\t\t// Not stored in our DB — not needed by parser/deliveries\n\t\t\tindex_block_hash: \"\",\n\t\t\tparent_block_hash: block.parent_hash,\n\t\t\tparent_index_block_hash: \"\",\n\t\t\tburn_block_hash: \"\",\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.timestamp,\n\t\t\tminer_txid: \"\",\n\t\t\ttimestamp: block.timestamp,\n\t\t\ttransactions: transactions.map((tx) =>
|
|
5
|
+
"/**\n * Local replay client — reconstructs NewBlockPayload from our own Postgres.\n *\n * Used for re-orgs, reprocessing, and self-serve replay after genesis sync.\n * Eliminates need for self-hosted Hiro API for blocks already in our DB.\n */\n\nimport type { Kysely } from \"kysely\";\nimport type { Database } from \"../db/types.ts\";\n\n/** Matches the NewBlockPayload shape expected by the indexer's /new_block endpoint */\nexport interface ReplayBlockPayload {\n\tblock_hash: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_timestamp: number;\n\tminer_txid: string;\n\ttimestamp: number;\n\ttransactions: ReplayTransactionPayload[];\n\tevents: ReplayEventPayload[];\n}\n\ninterface ReplayTransactionPayload {\n\ttxid: string;\n\traw_tx: string;\n\tstatus: string;\n\ttx_index: number;\n\ttx_type?: string;\n\tsender_address?: string;\n\traw_result?: string | null;\n\tcontract_call?: { function_args: string[] };\n}\n\ninterface ReplayEventPayload {\n\ttxid: string;\n\tevent_index: number;\n\tcommitted: boolean;\n\ttype: string;\n\t[key: string]: unknown;\n}\n\nexport class LocalClient {\n\t/**\n\t * Reconstruct a NewBlockPayload from local DB for replay.\n\t * Returns null if block not found.\n\t */\n\tasync getBlockForReplay(\n\t\tdb: Kysely<Database>,\n\t\theight: number,\n\t): Promise<ReplayBlockPayload | null> {\n\t\tconst block = await db\n\t\t\t.selectFrom(\"blocks\")\n\t\t\t.selectAll()\n\t\t\t.where(\"height\", \"=\", height)\n\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t.executeTakeFirst();\n\n\t\tif (!block) return null;\n\n\t\tconst transactions = await db\n\t\t\t.selectFrom(\"transactions\")\n\t\t\t.selectAll()\n\t\t\t.where(\"block_height\", \"=\", height)\n\t\t\t.orderBy(\"tx_index\", \"asc\")\n\t\t\t.execute();\n\n\t\tconst events = await db\n\t\t\t.selectFrom(\"events\")\n\t\t\t.selectAll()\n\t\t\t.where(\"block_height\", \"=\", height)\n\t\t\t.orderBy(\"event_index\", \"asc\")\n\t\t\t.execute();\n\n\t\treturn {\n\t\t\tblock_hash: block.hash,\n\t\t\tblock_height: block.height,\n\t\t\t// Not stored in our DB — not needed by parser/deliveries\n\t\t\tindex_block_hash: \"\",\n\t\t\tparent_block_hash: block.parent_hash,\n\t\t\tparent_index_block_hash: \"\",\n\t\t\tburn_block_hash: \"\",\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.timestamp,\n\t\t\tminer_txid: \"\",\n\t\t\ttimestamp: block.timestamp,\n\t\t\ttransactions: transactions.map((tx) => {\n\t\t\t\tconst entry: ReplayTransactionPayload = {\n\t\t\t\t\ttxid: tx.tx_id,\n\t\t\t\t\traw_tx: tx.raw_tx,\n\t\t\t\t\tstatus: tx.status,\n\t\t\t\t\ttx_index: tx.tx_index,\n\t\t\t\t\ttx_type: tx.type,\n\t\t\t\t\tsender_address: tx.sender,\n\t\t\t\t\traw_result: tx.raw_result ?? null,\n\t\t\t\t};\n\t\t\t\t// Include function_args if stored (for contract_call txs)\n\t\t\t\tif (tx.function_args) {\n\t\t\t\t\tconst args = typeof tx.function_args === \"string\"\n\t\t\t\t\t\t? JSON.parse(tx.function_args)\n\t\t\t\t\t\t: tx.function_args;\n\t\t\t\t\tif (Array.isArray(args)) {\n\t\t\t\t\t\tentry.contract_call = { function_args: args };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn entry;\n\t\t\t}),\n\t\t\tevents: events.map((evt) => {\n\t\t\t\tconst data = (evt.data ?? {}) as Record<string, unknown>;\n\t\t\t\tconst eventType = evt.type;\n\n\t\t\t\t// Reconstruct the flat event structure the indexer expects:\n\t\t\t\t// { txid, event_index, committed, type, [type_key]: data }\n\t\t\t\tconst payload: ReplayEventPayload = {\n\t\t\t\t\ttxid: evt.tx_id,\n\t\t\t\t\tevent_index: evt.event_index,\n\t\t\t\t\tcommitted: true,\n\t\t\t\t\ttype: eventType,\n\t\t\t\t};\n\n\t\t\t\t// Attach event-specific data under the correct key\n\t\t\t\tif (eventType && data) {\n\t\t\t\t\tpayload[eventType] = data;\n\t\t\t\t}\n\n\t\t\t\treturn payload;\n\t\t\t}),\n\t\t};\n\t}\n\n\t/** Get highest block height in local DB */\n\tasync getChainTip(db: Kysely<Database>): Promise<number> {\n\t\tconst row = await db\n\t\t\t.selectFrom(\"blocks\")\n\t\t\t.select((eb) => eb.fn.max(\"height\").as(\"max_height\"))\n\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t.executeTakeFirst();\n\t\treturn Number(row?.max_height ?? 0);\n\t}\n\n\t/** Check if a specific block height exists in local DB */\n\tasync hasBlock(db: Kysely<Database>, height: number): Promise<boolean> {\n\t\tconst row = await db\n\t\t\t.selectFrom(\"blocks\")\n\t\t\t.select(\"height\")\n\t\t\t.where(\"height\", \"=\", height)\n\t\t\t.where(\"canonical\", \"=\", true)\n\t\t\t.executeTakeFirst();\n\t\treturn !!row;\n\t}\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;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,GAAG;AAAA,YACxB,MAAM,gBAAgB,EAAE,eAAe,KAAK;AAAA,UAC7C;AAAA,QACD;AAAA,QACA,OAAO;AAAA,OACP;AAAA,MACD,QAAQ,OAAO,IAAI,CAAC,QAAQ;AAAA,QAC3B,MAAM,OAAQ,IAAI,QAAQ,CAAC;AAAA,QAC3B,MAAM,YAAY,IAAI;AAAA,QAItB,MAAM,UAA8B;AAAA,UACnC,MAAM,IAAI;AAAA,UACV,aAAa,IAAI;AAAA,UACjB,WAAW;AAAA,UACX,MAAM;AAAA,QACP;AAAA,QAGA,IAAI,aAAa,MAAM;AAAA,UACtB,QAAQ,aAAa;AAAA,QACtB;AAAA,QAEA,OAAO;AAAA,OACP;AAAA,IACF;AAAA;AAAA,OAIK,YAAW,CAAC,IAAuC;AAAA,IACxD,MAAM,MAAM,MAAM,GAChB,WAAW,QAAQ,EACnB,OAAO,CAAC,OAAO,GAAG,GAAG,IAAI,QAAQ,EAAE,GAAG,YAAY,CAAC,EACnD,MAAM,aAAa,KAAK,IAAI,EAC5B,iBAAiB;AAAA,IACnB,OAAO,OAAO,KAAK,cAAc,CAAC;AAAA;AAAA,OAI7B,SAAQ,CAAC,IAAsB,QAAkC;AAAA,IACtE,MAAM,MAAM,MAAM,GAChB,WAAW,QAAQ,EACnB,OAAO,QAAQ,EACf,MAAM,UAAU,KAAK,MAAM,EAC3B,MAAM,aAAa,KAAK,IAAI,EAC5B,iBAAiB;AAAA,IACnB,OAAO,CAAC,CAAC;AAAA;AAEX;",
|
|
8
|
+
"debugId": "431DDE218D6D481C64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Add function_args and raw_result columns to transactions table.
|
|
5
|
+
* Enables contract_call arg decoding and tx result access in subgraph handlers.
|
|
6
|
+
*/
|
|
7
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
8
|
+
await db.schema
|
|
9
|
+
.alterTable("transactions")
|
|
10
|
+
.addColumn("function_args", "jsonb")
|
|
11
|
+
.execute();
|
|
12
|
+
await db.schema
|
|
13
|
+
.alterTable("transactions")
|
|
14
|
+
.addColumn("raw_result", "text")
|
|
15
|
+
.execute();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
19
|
+
await db.schema
|
|
20
|
+
.alterTable("transactions")
|
|
21
|
+
.dropColumn("function_args")
|
|
22
|
+
.execute();
|
|
23
|
+
await db.schema
|
|
24
|
+
.alterTable("transactions")
|
|
25
|
+
.dropColumn("raw_result")
|
|
26
|
+
.execute();
|
|
27
|
+
}
|