@@ -273,29 +273,18 @@ export function prefixedCols(columns: string[], prefix: string): string[] {
273
273
return columns . map ( c => `${ prefix } .${ c } ` ) ;
274
274
}
275
275
276
- /**
277
- * Concatenates column names to use on a query. Necessary when one or more of those columns is complex enough
278
- * so that postgres.js can't figure out how to list it (e.g. abi column, aggregates, partitions, etc.).
279
- * @param sql - SQL client
280
- * @param columns - list of columns
281
- * @returns raw SQL column list string
282
- */
283
- export function unsafeCols ( sql : PgSqlClient , columns : string [ ] ) : postgres . PendingQuery < any > {
284
- return sql . unsafe ( columns . join ( ', ' ) ) ;
285
- }
286
-
287
276
/**
288
277
* Shorthand function that returns a column query to retrieve the smart contract abi when querying transactions
289
278
* that may be of type `contract_call`. Usually used alongside `TX_COLUMNS` or `MEMPOOL_TX_COLUMNS`.
290
279
* @param tableName - Name of the table that will determine the transaction type. Defaults to `txs`.
291
280
* @returns `string` - abi column select statement portion
292
281
*/
293
- export function abiColumn ( tableName : string = 'txs' ) : string {
294
- return `
295
- CASE WHEN ${ tableName } .type_id = ${ DbTxTypeId . ContractCall } THEN (
282
+ export function abiColumn ( sql : PgSqlClient , tableName : string = 'txs' ) : postgres . Fragment {
283
+ return sql `
284
+ CASE WHEN ${ sql ( tableName ) } .type_id = ${ DbTxTypeId . ContractCall } THEN (
296
285
SELECT abi
297
286
FROM smart_contracts
298
- WHERE smart_contracts.contract_id = ${ tableName } .contract_call_contract_id
287
+ WHERE smart_contracts.contract_id = ${ sql ( tableName ) } .contract_call_contract_id
299
288
ORDER BY abi != 'null' DESC, canonical DESC, microblock_canonical DESC, block_height DESC
300
289
LIMIT 1
301
290
) END as abi
0 commit comments