mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 22:43:34 +08:00
fix: rosetta block tx sql query not using index_block_hash (#938)
This commit is contained in:
@@ -2845,14 +2845,20 @@ export class PgDataStore
|
||||
}
|
||||
|
||||
async getBlockTxsRows(blockHash: string) {
|
||||
return this.query(async client => {
|
||||
return this.queryTx(async client => {
|
||||
const blockQuery = await this.getBlockInternal(client, { hash: blockHash });
|
||||
if (!blockQuery.found) {
|
||||
throw new Error(`Could not find block by hash ${blockHash}`);
|
||||
}
|
||||
const result = await client.query<ContractTxQueryResult>(
|
||||
`
|
||||
-- getBlockTxsRows
|
||||
SELECT ${TX_COLUMNS}, ${abiColumn()}
|
||||
FROM txs
|
||||
WHERE block_hash = $1 AND canonical = true AND microblock_canonical = true
|
||||
WHERE index_block_hash = $1 AND canonical = true AND microblock_canonical = true
|
||||
ORDER BY microblock_sequence ASC, tx_index ASC
|
||||
`,
|
||||
[hexToBuffer(blockHash)]
|
||||
[hexToBuffer(blockQuery.result.index_block_hash)]
|
||||
);
|
||||
if (result.rowCount === 0) {
|
||||
return { found: false } as const;
|
||||
|
||||
@@ -5042,7 +5042,10 @@ describe('api tests', () => {
|
||||
const blockTxsRows = await api.datastore.getBlockTxsRows(block.block_hash);
|
||||
expect(blockTxsRows.found).toBe(true);
|
||||
const blockTxsRowsResult = blockTxsRows.result as DbTx[];
|
||||
expect(blockTxsRowsResult[6]).toEqual({ ...contractCall, ...{ abi: contractJsonAbi } });
|
||||
expect(blockTxsRowsResult.find(tx => tx.tx_id === contractCall.tx_id)).toEqual({
|
||||
...contractCall,
|
||||
...{ abi: contractJsonAbi },
|
||||
});
|
||||
|
||||
const searchResult8 = await supertest(api.server).get(
|
||||
`/extended/v1/search/0x1232000000000000000000000000000000000000000000000000000000000000?include_metadata`
|
||||
|
||||
Reference in New Issue
Block a user