-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from blockfrost/srk/txCBOR
feat(txs): raw TX CBOR
- Loading branch information
Showing
11 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
Binary file removed
BIN
-101 KB
.yarn/cache/@blockfrost-openapi-npm-0.1.63-1c9e96c8eb-a743deeded.zip
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { getSchemaForEndpoint } from '@blockfrost/openapi'; | ||
import { FastifyInstance, FastifyRequest } from 'fastify'; | ||
import { SQLQuery } from '../../../sql/index.js'; | ||
import * as QueryTypes from '../../../types/queries/tx.js'; | ||
import * as ResponseTypes from '../../../types/responses/tx.js'; | ||
import { getDbSync } from '../../../utils/database.js'; | ||
import { handle404 } from '@blockfrost/blockfrost-utils/lib/fastify.js'; | ||
|
||
async function route(fastify: FastifyInstance) { | ||
fastify.route({ | ||
url: '/txs/:hash/cbor', | ||
method: 'GET', | ||
schema: getSchemaForEndpoint('/txs/{hash}/cbor'), | ||
handler: async (request: FastifyRequest<QueryTypes.RequestParameters>, reply) => { | ||
const clientDbSync = await getDbSync(fastify); | ||
|
||
try { | ||
const { rows }: { rows: ResponseTypes.TxCbor[] } = | ||
await clientDbSync.query<QueryTypes.TxCbor>(SQLQuery.get('txs_hash_cbor'), [ | ||
request.params.hash, | ||
]); | ||
|
||
clientDbSync.release(); | ||
|
||
if (rows.length === 0) { | ||
return handle404(reply); | ||
} | ||
|
||
return reply.send(rows[0]); | ||
} catch (error) { | ||
if (clientDbSync) { | ||
clientDbSync.release(); | ||
} | ||
throw error; | ||
} | ||
}, | ||
}); | ||
} | ||
|
||
export default route; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT encode(tx_cbor.bytes, 'hex') as "cbor" | ||
FROM tx_cbor | ||
JOIN tx ON tx_cbor.tx_id = tx.id | ||
WHERE encode(tx.hash, 'hex') = $1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters