Skip to content

Commit

Permalink
fix: fix webhook event schema (#2391)
Browse files Browse the repository at this point in the history
  • Loading branch information
shineli1984 authored Nov 15, 2024
1 parent ea68cca commit ed81d23
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
59 changes: 59 additions & 0 deletions packages/webhook/sdk/src/event-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */

import { imx } from '@imtbl/generated-clients';

export interface BlockChainMetadata {
log_index: string;
block_number: string;
Expand Down Expand Up @@ -344,3 +346,60 @@ export interface ZkevmTradeCreated {
log_index_in_block: string;
};
}

export enum imxEventName {
imtbl_x_nft_created = '',
imtbl_x_nft_updated = '',
imtbl_x_order_accepted = '',
imtbl_x_order_filled = '',
imtbl_x_order_cancelled = 'imtbl_x_order_cancelled',
imtbl_x_transfer_created = 'imtbl_x_transfer_created',
}

// imtbl_x_nft_created
export interface XNftCreated {
event_name: 'imtbl_x_nft_created';
event_id: string;
chain: string;
data: imx.Asset;
}

// imtbl_x_nft_updated
export interface XNftUpdated {
event_name: 'imtbl_x_nft_updated';
event_id: string;
chain: string;
data: imx.Asset;
}

// imtbl_x_order_accepted
export interface XOrderAccepted {
event_name: 'imtbl_x_order_accepted';
event_id: string;
chain: string;
data: imx.Order;
}

// imtbl_x_order_filled
export interface XOrderFilled {
event_name: 'imtbl_x_order_filled';
event_id: string;
chain: string;
data: imx.Order;
}

// imtbl_x_order_cancelled
export interface XOrderCancelled {
event_name: 'imtbl_x_order_cancelled';
event_id: string;
chain: string;
data: imx.Order;
}

// imtbl_x_transfer_created
export interface XTransferCreated {
event_name: 'imtbl_x_transfer_created';
event_id: string;
chain: string;
data: imx.Transfer;
}
19 changes: 12 additions & 7 deletions packages/webhook/sdk/src/handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import MessageValidator from 'sns-validator';
import { Environment } from '@imtbl/config';
import { imx } from '@imtbl/generated-clients';
import {
XNftCreated,
XNftUpdated,
XOrderAccepted,
XOrderCancelled,
XOrderFilled,
XTransferCreated,
ZkevmActivityBurn, ZkevmActivityDeposit, ZkevmActivityMint, ZkevmActivitySale,
ZkevmActivityTransfer, ZkevmActivityWithdrawal, ZkevmCollectionUpdated, ZkevmMetadataUpdated,
ZkevmMintRequestUpdated, ZkevmNftUpdated, ZkevmOrderUpdated, ZkevmTokenUpdated,
Expand Down Expand Up @@ -29,12 +34,12 @@ export type WebhookHandlers = {
zkEvmTokenUpdated?: (event: ZkevmTokenUpdated) => Promise<void>;
zkEvmOrderUpdated?: (event: ZkevmOrderUpdated) => Promise<void>;
zkEvmTradeCreated?: (event: ZkevmTradeCreated) => Promise<void>;
xNftCreated?: (event: imx.Asset) => Promise<void>;
xNftUpdated?: (event: imx.Asset) => Promise<void>;
xOrderAccepted?: (event: imx.OrderV3) => Promise<void>;
xOrderFilled?: (event: imx.OrderV3) => Promise<void>;
xOrderCancelled?: (event: imx.OrderV3) => Promise<void>;
xTransferCreated?: (event: imx.Transfer) => Promise<void>;
xNftCreated?: (event: XNftCreated) => Promise<void>;
xNftUpdated?: (event: XNftUpdated) => Promise<void>;
xOrderAccepted?: (event: XOrderAccepted) => Promise<void>;
xOrderFilled?: (event: XOrderFilled) => Promise<void>;
xOrderCancelled?: (event: XOrderCancelled) => Promise<void>;
xTransferCreated?: (event: XTransferCreated) => Promise<void>;
all?: (event: any) => Promise<void>;
};

Expand Down

0 comments on commit ed81d23

Please sign in to comment.