Skip to content

Commit

Permalink
fix: add stacks event position to ts client (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored and MicaiahReid committed May 8, 2024
1 parent f3530b7 commit 3c48eeb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
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.8.0",
"version": "1.9.0",
"description": "Chainhook TypeScript client",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion components/client/typescript/src/schemas/stacks/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const StacksTransactionMetadataSchema = Type.Object({
sender: Type.String(),
sponsor: Type.Optional(Type.String()),
success: Type.Boolean(),
contract_abi: Type.Optional(Type.Any()),
});
export type StacksTransactionMetadata = Static<typeof StacksTransactionMetadataSchema>;

Expand All @@ -60,7 +61,7 @@ export type StacksTransaction = Static<typeof StacksTransactionSchema>;

export const StacksEventMetadataSchema = Type.Object({
bitcoin_anchor_block_identifier: BlockIdentifierSchema,
confirm_microblock_identifier: BlockIdentifierSchema,
confirm_microblock_identifier: Nullable(BlockIdentifierSchema),
pox_cycle_index: Type.Integer(),
pox_cycle_length: Type.Integer(),
pox_cycle_position: Type.Integer(),
Expand Down
20 changes: 17 additions & 3 deletions components/client/typescript/src/schemas/stacks/tx_events.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import { Static, Type } from '@sinclair/typebox';

export const StacksTransactionEventPositionSchema = Type.Object({ index: Type.Integer() });
export type StacksTransactionEventPosition = Static<typeof StacksTransactionEventPositionSchema>;

export const StacksTransactionNftMintEventSchema = Type.Object({
type: Type.Literal('NFTMintEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
asset_class_identifier: Type.String(),
asset_identifier: Type.String(),
raw_value: Type.String(),
recipient: Type.String(),
}),
});
export type StacksTransactionNftMintEvent = Static<typeof StacksTransactionNftMintEventSchema>;

export const StacksTransactionNftTransferEventSchema = Type.Object({
type: Type.Literal('NFTTransferEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
raw_value: Type.String(),
asset_identifier: Type.String(),
raw_value: Type.String(),
recipient: Type.String(),
sender: Type.String(),
}),
Expand All @@ -25,16 +30,18 @@ export type StacksTransactionNftTransferEvent = Static<

export const StacksTransactionNftBurnEventSchema = Type.Object({
type: Type.Literal('NFTBurnEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
asset_class_identifier: Type.String(),
asset_identifier: Type.String(),
raw_value: Type.String(),
sender: Type.String(),
}),
});
export type StacksTransactionNftBurnEvent = Static<typeof StacksTransactionNftBurnEventSchema>;

export const StacksTransactionFtTransferEventSchema = Type.Object({
type: Type.Literal('FTTransferEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
asset_identifier: Type.String(),
Expand All @@ -48,6 +55,7 @@ export type StacksTransactionFtTransferEvent = Static<

export const StacksTransactionFtMintEventSchema = Type.Object({
type: Type.Literal('FTMintEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
asset_identifier: Type.String(),
Expand All @@ -58,6 +66,7 @@ export type StacksTransactionFtMintEvent = Static<typeof StacksTransactionFtMint

export const StacksTransactionFtBurnEventSchema = Type.Object({
type: Type.Literal('FTBurnEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
asset_identifier: Type.String(),
Expand All @@ -68,6 +77,7 @@ export type StacksTransactionFtBurnEvent = Static<typeof StacksTransactionFtBurn

export const StacksTransactionSmartContractEventSchema = Type.Object({
type: Type.Literal('SmartContractEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
contract_identifier: Type.String(),
raw_value: Type.String(),
Expand All @@ -80,6 +90,7 @@ export type StacksTransactionSmartContractEvent = Static<

export const StacksTransactionStxTransferEventSchema = Type.Object({
type: Type.Literal('STXTransferEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
sender: Type.String(),
Expand All @@ -92,6 +103,7 @@ export type StacksTransactionStxTransferEvent = Static<

export const StacksTransactionStxMintEventSchema = Type.Object({
type: Type.Literal('STXMintEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
recipient: Type.String(),
Expand All @@ -101,6 +113,7 @@ export type StacksTransactionStxMintEvent = Static<typeof StacksTransactionStxMi

export const StacksTransactionStxLockEventSchema = Type.Object({
type: Type.Literal('STXLockEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
locked_amount: Type.String(),
unlock_height: Type.String(),
Expand All @@ -111,6 +124,7 @@ export type StacksTransactionStxLockEvent = Static<typeof StacksTransactionStxLo

export const StacksTransactionStxBurnEventSchema = Type.Object({
type: Type.Literal('STXBurnEvent'),
position: StacksTransactionEventPositionSchema,
data: Type.Object({
amount: Type.String(),
sender: Type.String(),
Expand Down

0 comments on commit 3c48eeb

Please sign in to comment.