@hirosystems/chainhook-client
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -17,2 +17,3 @@ import { Static } from '@sinclair/typebox'; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -33,40 +34,3 @@ }>; | ||
export type BitcoinInscriptionTransferred = Static<typeof BitcoinInscriptionTransferredSchema>; | ||
export declare const BitcoinCursedInscriptionRevealedSchema: import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>; | ||
export type BitcoinCursedInscriptionRevealed = Static<typeof BitcoinCursedInscriptionRevealedSchema>; | ||
export declare const BitcoinOrdinalOperationSchema: import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -87,2 +51,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -110,20 +75,2 @@ }>>; | ||
ordinal_operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -144,2 +91,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -209,20 +157,2 @@ }>>; | ||
ordinal_operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -243,2 +173,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -319,20 +250,2 @@ }>>; | ||
ordinal_operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -353,2 +266,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -355,0 +269,0 @@ }>>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BitcoinEventSchema = exports.BitcoinTransactionSchema = exports.BitcoinTransactionMetadataSchema = exports.BitcoinOutputSchema = exports.BitcoinOrdinalOperationSchema = exports.BitcoinCursedInscriptionRevealedSchema = exports.BitcoinInscriptionTransferredSchema = exports.BitcoinInscriptionRevealedSchema = void 0; | ||
exports.BitcoinEventSchema = exports.BitcoinTransactionSchema = exports.BitcoinTransactionMetadataSchema = exports.BitcoinOutputSchema = exports.BitcoinOrdinalOperationSchema = exports.BitcoinInscriptionTransferredSchema = exports.BitcoinInscriptionRevealedSchema = void 0; | ||
const typebox_1 = require("@sinclair/typebox"); | ||
@@ -21,2 +21,3 @@ const common_1 = require("../common"); | ||
transfers_pre_inscription: typebox_1.Type.Integer(), | ||
curse_type: (0, common_1.Nullable)(typebox_1.Type.Any()), | ||
tx_index: typebox_1.Type.Integer(), | ||
@@ -39,22 +40,3 @@ }); | ||
}); | ||
exports.BitcoinCursedInscriptionRevealedSchema = typebox_1.Type.Object({ | ||
content_bytes: typebox_1.Type.String(), | ||
content_type: typebox_1.Type.String(), | ||
content_length: typebox_1.Type.Integer(), | ||
inscription_number: typebox_1.Type.Integer(), | ||
inscription_fee: typebox_1.Type.Integer(), | ||
inscription_id: typebox_1.Type.String(), | ||
inscription_output_value: typebox_1.Type.Integer(), | ||
inscription_input_index: typebox_1.Type.Integer(), | ||
inscriber_address: (0, common_1.Nullable)(typebox_1.Type.String()), | ||
ordinal_number: typebox_1.Type.Integer(), | ||
ordinal_block_height: typebox_1.Type.Integer(), | ||
ordinal_offset: typebox_1.Type.Integer(), | ||
satpoint_post_inscription: typebox_1.Type.String(), | ||
transfers_pre_inscription: typebox_1.Type.Integer(), | ||
curse_type: (0, common_1.Nullable)(typebox_1.Type.Any()), | ||
tx_index: typebox_1.Type.Integer(), | ||
}); | ||
exports.BitcoinOrdinalOperationSchema = typebox_1.Type.Object({ | ||
cursed_inscription_revealed: typebox_1.Type.Optional(exports.BitcoinCursedInscriptionRevealedSchema), | ||
inscription_revealed: typebox_1.Type.Optional(exports.BitcoinInscriptionRevealedSchema), | ||
@@ -61,0 +43,0 @@ inscription_transferred: typebox_1.Type.Optional(exports.BitcoinInscriptionTransferredSchema), |
@@ -296,20 +296,2 @@ import { Static } from '@sinclair/typebox'; | ||
ordinal_operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -330,2 +312,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -647,20 +630,2 @@ }>>; | ||
ordinal_operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ | ||
cursed_inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
content_bytes: import("@sinclair/typebox").TString; | ||
content_type: import("@sinclair/typebox").TString; | ||
content_length: import("@sinclair/typebox").TInteger; | ||
inscription_number: import("@sinclair/typebox").TInteger; | ||
inscription_fee: import("@sinclair/typebox").TInteger; | ||
inscription_id: import("@sinclair/typebox").TString; | ||
inscription_output_value: import("@sinclair/typebox").TInteger; | ||
inscription_input_index: import("@sinclair/typebox").TInteger; | ||
inscriber_address: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>; | ||
ordinal_number: import("@sinclair/typebox").TInteger; | ||
ordinal_block_height: import("@sinclair/typebox").TInteger; | ||
ordinal_offset: import("@sinclair/typebox").TInteger; | ||
satpoint_post_inscription: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
}>>; | ||
inscription_revealed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ | ||
@@ -681,2 +646,3 @@ content_bytes: import("@sinclair/typebox").TString; | ||
transfers_pre_inscription: import("@sinclair/typebox").TInteger; | ||
curse_type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TAny, import("@sinclair/typebox").TNull]>; | ||
tx_index: import("@sinclair/typebox").TInteger; | ||
@@ -683,0 +649,0 @@ }>>; |
@@ -19,2 +19,4 @@ /// <reference types="node" /> | ||
body_limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>; | ||
/** Node type: `chainhook` or `ordhook` */ | ||
node_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"chainhook">, import("@sinclair/typebox").TLiteral<"ordhook">]>>; | ||
}>; | ||
@@ -131,3 +133,3 @@ /** Local event server connection and authentication options */ | ||
scope: import("@sinclair/typebox").TLiteral<"contract_call">; | ||
contract_identifier: import("@sinclair/typebox").TString; | ||
contract_identifier: import("@sinclair/typebox").TString; /** Chainhook node connection options */ | ||
method: import("@sinclair/typebox").TString; | ||
@@ -233,3 +235,3 @@ }>, import("@sinclair/typebox").TObject<{ | ||
scope: import("@sinclair/typebox").TLiteral<"contract_call">; | ||
contract_identifier: import("@sinclair/typebox").TString; | ||
contract_identifier: import("@sinclair/typebox").TString; /** Chainhook node connection options */ | ||
method: import("@sinclair/typebox").TString; | ||
@@ -236,0 +238,0 @@ }>, import("@sinclair/typebox").TObject<{ |
@@ -25,2 +25,6 @@ "use strict"; | ||
body_limit: type_provider_typebox_1.Type.Optional(type_provider_typebox_1.Type.Number({ default: 41943040 })), | ||
/** Node type: `chainhook` or `ordhook` */ | ||
node_type: type_provider_typebox_1.Type.Optional(type_provider_typebox_1.Type.Union([type_provider_typebox_1.Type.Literal('chainhook'), type_provider_typebox_1.Type.Literal('ordhook')], { | ||
default: 'chainhook', | ||
})), | ||
}); | ||
@@ -95,7 +99,10 @@ const ChainhookNodeOptionsSchema = type_provider_typebox_1.Type.Object({ | ||
} | ||
logger_1.logger.info(predicates, `ChainhookEventObserver registering predicates at ${chainhookOpts.base_url}`); | ||
const nodeType = serverOpts.node_type ?? 'chainhook'; | ||
const path = nodeType === 'chainhook' ? `/v1/chainhooks` : `/v1/observers`; | ||
const registerUrl = `${chainhookOpts.base_url}${path}`; | ||
logger_1.logger.info(predicates, `ChainhookEventObserver registering predicates at ${registerUrl}`); | ||
for (const predicate of predicates) { | ||
const thenThat = { | ||
http_post: { | ||
url: `${serverOpts.external_base_url}/chainhook/${encodeURIComponent(predicate.uuid)}`, | ||
url: `${serverOpts.external_base_url}/payload`, | ||
authorization_header: `Bearer ${serverOpts.auth_token}`, | ||
@@ -110,3 +117,3 @@ }, | ||
body.networks.testnet.then_that = thenThat; | ||
await (0, undici_1.request)(`${chainhookOpts.base_url}/v1/chainhooks`, { | ||
await (0, undici_1.request)(registerUrl, { | ||
method: 'POST', | ||
@@ -130,4 +137,8 @@ body: JSON.stringify(body), | ||
logger_1.logger.info(`ChainhookEventObserver closing predicates at ${chainhookOpts.base_url}`); | ||
const nodeType = serverOpts.node_type ?? 'chainhook'; | ||
const removals = predicates.map(predicate => new Promise((resolve, reject) => { | ||
(0, undici_1.request)(`${chainhookOpts.base_url}/v1/chainhooks/${predicate.chain}/${encodeURIComponent(predicate.uuid)}`, { | ||
const path = nodeType === 'chainhook' | ||
? `/v1/chainhooks/${predicate.chain}/${encodeURIComponent(predicate.uuid)}` | ||
: `/v1/observers/${encodeURIComponent(predicate.uuid)}`; | ||
(0, undici_1.request)(`${chainhookOpts.base_url}${path}`, { | ||
method: 'DELETE', | ||
@@ -158,7 +169,4 @@ headers: { 'content-type': 'application/json' }, | ||
fastify.addHook('preHandler', isEventAuthorized); | ||
fastify.post('/chainhook/:uuid', { | ||
fastify.post('/payload', { | ||
schema: { | ||
params: type_provider_typebox_1.Type.Object({ | ||
uuid: type_provider_typebox_1.Type.String({ format: 'uuid' }), | ||
}), | ||
body: payload_1.PayloadSchema, | ||
@@ -174,3 +182,3 @@ }, | ||
try { | ||
await callback(request.params.uuid, request.body); | ||
await callback(request.body.chainhook.uuid, request.body); | ||
await reply.code(200).send(); | ||
@@ -195,3 +203,3 @@ } | ||
pluginTimeout: 0, | ||
bodyLimit: serverOpts.body_limit ?? 41943040, // 40MB | ||
bodyLimit: serverOpts.body_limit ?? 41943040, // 40MB default | ||
}).withTypeProvider(); | ||
@@ -198,0 +206,0 @@ if (serverOpts.wait_for_chainhook_node ?? true) { |
{ | ||
"name": "@hirosystems/chainhook-client", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Chainhook TypeScript client", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
280739
4123