@hirosystems/chainhook-client
Version:
Chainhook TypeScript client
95 lines • 4.34 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SerializedPredicateResponseSchema = exports.SerializedPredicateSchema = exports.PredicateStatusSchema = exports.PredicateExpiredDataSchema = exports.PredicateSchema = exports.PredicateHeaderSchema = exports.ThenThatSchema = exports.ThenThatHttpPostSchema = exports.ThenThatFileAppendSchema = void 0;
const typebox_1 = require("@sinclair/typebox");
const if_this_1 = require("./bitcoin/if_this");
const if_this_2 = require("./stacks/if_this");
exports.ThenThatFileAppendSchema = typebox_1.Type.Object({
file_append: typebox_1.Type.Object({
path: typebox_1.Type.String(),
}),
});
exports.ThenThatHttpPostSchema = typebox_1.Type.Object({
http_post: typebox_1.Type.Object({
url: typebox_1.Type.String({ format: 'uri' }),
authorization_header: typebox_1.Type.String(),
}),
});
exports.ThenThatSchema = typebox_1.Type.Union([exports.ThenThatFileAppendSchema, exports.ThenThatHttpPostSchema]);
exports.PredicateHeaderSchema = typebox_1.Type.Object({
uuid: typebox_1.Type.String({ format: 'uuid' }),
name: typebox_1.Type.String(),
version: typebox_1.Type.Integer(),
chain: typebox_1.Type.String(),
});
exports.PredicateSchema = typebox_1.Type.Composite([
exports.PredicateHeaderSchema,
typebox_1.Type.Object({
networks: typebox_1.Type.Object({
mainnet: typebox_1.Type.Optional(typebox_1.Type.Union([if_this_1.BitcoinIfThisThenThatSchema, if_this_2.StacksIfThisThenThatSchema])),
testnet: typebox_1.Type.Optional(typebox_1.Type.Union([if_this_1.BitcoinIfThisThenThatSchema, if_this_2.StacksIfThisThenThatSchema])),
}),
}),
]);
exports.PredicateExpiredDataSchema = typebox_1.Type.Object({
expired_at_block_height: typebox_1.Type.Integer(),
last_evaluated_block_height: typebox_1.Type.Integer(),
last_occurrence: typebox_1.Type.Optional(typebox_1.Type.Integer()),
number_of_blocks_evaluated: typebox_1.Type.Integer(),
number_of_times_triggered: typebox_1.Type.Integer(),
});
exports.PredicateStatusSchema = typebox_1.Type.Union([
typebox_1.Type.Object({
info: typebox_1.Type.Object({
number_of_blocks_to_scan: typebox_1.Type.Integer(),
number_of_blocks_evaluated: typebox_1.Type.Integer(),
number_of_times_triggered: typebox_1.Type.Integer(),
last_occurrence: typebox_1.Type.Optional(typebox_1.Type.Integer()),
last_evaluated_block_height: typebox_1.Type.Integer(),
}),
type: typebox_1.Type.Literal('scanning'),
}),
typebox_1.Type.Object({
info: typebox_1.Type.Object({
last_occurrence: typebox_1.Type.Optional(typebox_1.Type.Integer()),
last_evaluation: typebox_1.Type.Integer(),
number_of_times_triggered: typebox_1.Type.Integer(),
number_of_blocks_evaluated: typebox_1.Type.Integer(),
last_evaluated_block_height: typebox_1.Type.Integer(),
}),
type: typebox_1.Type.Literal('streaming'),
}),
typebox_1.Type.Object({
info: exports.PredicateExpiredDataSchema,
type: typebox_1.Type.Literal('unconfirmed_expiration'),
}),
typebox_1.Type.Object({
info: exports.PredicateExpiredDataSchema,
type: typebox_1.Type.Literal('confirmed_expiration'),
}),
typebox_1.Type.Object({
info: typebox_1.Type.String(),
type: typebox_1.Type.Literal('interrupted'),
}),
typebox_1.Type.Object({
type: typebox_1.Type.Literal('new'),
}),
]);
exports.SerializedPredicateSchema = typebox_1.Type.Object({
chain: typebox_1.Type.Union([typebox_1.Type.Literal('stacks'), typebox_1.Type.Literal('bitcoin')]),
uuid: typebox_1.Type.String(),
network: typebox_1.Type.Union([typebox_1.Type.Literal('mainnet'), typebox_1.Type.Literal('testnet')]),
predicate: typebox_1.Type.Any(),
status: exports.PredicateStatusSchema,
enabled: typebox_1.Type.Boolean(),
});
exports.SerializedPredicateResponseSchema = typebox_1.Type.Union([
typebox_1.Type.Object({
status: typebox_1.Type.Literal(404),
}),
typebox_1.Type.Object({
result: exports.SerializedPredicateSchema,
status: typebox_1.Type.Literal(200),
}),
]);
//# sourceMappingURL=predicate.js.map