Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Bitcoin transaction index to typescript client #568

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/client/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/client/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hirosystems/chainhook-client",
"version": "1.7.0",
"version": "1.8.0",
"description": "Chainhook TypeScript client",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
14 changes: 14 additions & 0 deletions components/client/typescript/src/schemas/bitcoin/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TransactionIdentifierSchema,
RosettaOperationSchema,
} from '../common';
import { BitcoinIfThisSchema } from './if_this';

export const BitcoinInscriptionRevealedSchema = Type.Object({
content_bytes: Type.String(),
Expand Down Expand Up @@ -115,12 +116,14 @@ export const BitcoinBrc20OperationSchema = Type.Union([
BitcoinBrc20TransferOperationSchema,
BitcoinBrc20TransferSendOperationSchema,
]);
export type BitcoinBrc20Operation = Static<typeof BitcoinBrc20OperationSchema>;

export const BitcoinTransactionMetadataSchema = Type.Object({
ordinal_operations: Type.Array(BitcoinOrdinalOperationSchema),
brc20_operation: Type.Optional(BitcoinBrc20OperationSchema),
outputs: Type.Optional(Type.Array(BitcoinOutputSchema)),
proof: Nullable(Type.String()),
index: Type.Integer(),
});
export type BitcoinTransactionMetadata = Static<typeof BitcoinTransactionMetadataSchema>;

Expand All @@ -139,3 +142,14 @@ export const BitcoinEventSchema = Type.Object({
metadata: Type.Any(),
});
export type BitcoinEvent = Static<typeof BitcoinEventSchema>;

export const BitcoinPayloadSchema = Type.Object({
apply: Type.Array(BitcoinEventSchema),
rollback: Type.Array(BitcoinEventSchema),
chainhook: Type.Object({
uuid: Type.String(),
predicate: BitcoinIfThisSchema,
is_streaming_blocks: Type.Boolean(),
}),
});
export type BitcoinPayload = Static<typeof BitcoinPayloadSchema>;
18 changes: 3 additions & 15 deletions components/client/typescript/src/schemas/payload.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import { Static, Type } from '@sinclair/typebox';
import { StacksEventSchema } from './stacks/payload';
import { BitcoinEventSchema } from './bitcoin/payload';
import { BitcoinIfThisSchema } from './bitcoin/if_this';
import { StacksIfThisSchema } from './stacks/if_this';
import { StacksPayloadSchema } from './stacks/payload';
import { BitcoinPayloadSchema } from './bitcoin/payload';

const EventArray = Type.Union([Type.Array(StacksEventSchema), Type.Array(BitcoinEventSchema)]);

export const PayloadSchema = Type.Object({
apply: EventArray,
rollback: EventArray,
chainhook: Type.Object({
uuid: Type.String(),
predicate: Type.Union([BitcoinIfThisSchema, StacksIfThisSchema]),
is_streaming_blocks: Type.Boolean(),
}),
});
export const PayloadSchema = Type.Union([BitcoinPayloadSchema, StacksPayloadSchema]);
export type Payload = Static<typeof PayloadSchema>;
12 changes: 12 additions & 0 deletions components/client/typescript/src/schemas/stacks/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '../common';
import { StacksTransactionEventSchema } from './tx_events';
import { StacksTransactionKindSchema } from './tx_kind';
import { StacksIfThisSchema } from './if_this';

export const StacksExecutionCostSchema = Type.Optional(
Type.Object({
Expand Down Expand Up @@ -75,3 +76,14 @@ export const StacksEventSchema = Type.Object({
metadata: StacksEventMetadataSchema,
});
export type StacksEvent = Static<typeof StacksEventSchema>;

export const StacksPayloadSchema = Type.Object({
apply: Type.Array(StacksEventSchema),
rollback: Type.Array(StacksEventSchema),
chainhook: Type.Object({
uuid: Type.String(),
predicate: StacksIfThisSchema,
is_streaming_blocks: Type.Boolean(),
}),
});
export type StacksPayload = Static<typeof StacksPayloadSchema>;
Loading