feat: support cursed inscriptions in chainhook client

This commit is contained in:
Rafael Cardenas
2023-06-21 17:39:43 -06:00
parent ea1ff9aab4
commit d7cc5a4410
5 changed files with 25 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@hirosystems/chainhook-client",
"version": "1.0.2",
"version": "1.0.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@hirosystems/chainhook-client",
"version": "1.0.2",
"version": "1.0.3",
"license": "ISC",
"dependencies": {
"@fastify/type-provider-typebox": "^3.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@hirosystems/chainhook-client",
"version": "1.0.2",
"version": "1.0.3",
"description": "Chainhook TypeScript client",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",

View File

@@ -33,7 +33,7 @@ export class ChainhookEventObserver {
* @param predicates - Predicates to register
* @param callback - Function to handle every Chainhook event payload sent by the node
*/
async start(predicates: [ServerPredicate], callback: OnEventCallback): Promise<void> {
async start(predicates: ServerPredicate[], callback: OnEventCallback): Promise<void> {
if (this.fastify) return;
this.fastify = await buildServer(this.serverOpts, this.chainhookOpts, predicates, callback);
await this.fastify.listen({ host: this.serverOpts.hostname, port: this.serverOpts.port });

View File

@@ -33,7 +33,27 @@ export const BitcoinInscriptionTransferredSchema = Type.Object({
});
export type BitcoinInscriptionTransferred = Static<typeof BitcoinInscriptionTransferredSchema>;
export const BitcoinCursedInscriptionRevealedSchema = Type.Object({
content_bytes: Type.String(),
content_type: Type.String(),
content_length: Type.Integer(),
inscription_number: Type.Integer(),
inscription_fee: Type.Integer(),
inscription_id: Type.String(),
inscription_output_value: Type.Integer(),
inscriber_address: Type.String(),
ordinal_number: Type.Integer(),
ordinal_block_height: Type.Integer(),
ordinal_offset: Type.Integer(),
satpoint_post_inscription: Type.String(),
curse_type: Type.String(),
});
export type BitcoinCursedInscriptionRevealed = Static<
typeof BitcoinCursedInscriptionRevealedSchema
>;
export const BitcoinOrdinalOperationSchema = Type.Object({
cursed_inscription_revealed: Type.Optional(BitcoinCursedInscriptionRevealedSchema),
inscription_revealed: Type.Optional(BitcoinInscriptionRevealedSchema),
inscription_transferred: Type.Optional(BitcoinInscriptionTransferredSchema),
});

View File

@@ -73,7 +73,7 @@ export type ServerPredicate = Static<typeof ServerPredicateSchema>;
export async function buildServer(
serverOpts: ServerOptions,
chainhookOpts: ChainhookNodeOptions,
predicates: [ServerPredicate],
predicates: ServerPredicate[],
callback: OnEventCallback
) {
async function waitForNode(this: FastifyInstance) {