Skip to content

Commit faeda9a

Browse files
Validation events (#285)
* Add validation event types * fix log message * Bump minor version * Fix linter
1 parent 6e85077 commit faeda9a

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ A Javascript SDK for receiving updates from the OpenSea Stream API - pushed over
1313
- item received offer
1414
- item received bid
1515

16+
Thise types are currently be expiremented with and for now are released on a small number of collections:
17+
18+
- order_invalidate
19+
- order_revalidate
20+
1621
This is a best effort delivery messaging system. Messages that are not received due to connection errors will not be re-sent. Messages may be delievered out of order. This SDK is offered as a beta experience as we work with developers in the ecosystem to make this a more robust and reliable system.
1722

1823
# Installation

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opensea/stream-js",
3-
"version": "0.0.26",
3+
"version": "0.1.0",
44
"description": "An SDK to receive pushed updates from OpenSea over websocket",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/client.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
Callback,
1717
LogLevel,
1818
Network,
19-
OnClientEvent
19+
OnClientEvent,
20+
OrderValidationEvent
2021
} from './types';
2122
import { ENDPOINTS } from './constants';
2223

@@ -208,6 +209,26 @@ export class OpenSeaStreamClient {
208209
return this.on(EventType.TRAIT_OFFER, collectionSlug, callback);
209210
};
210211

212+
public onOrderInvalidate = (
213+
collectionSlug: string,
214+
callback: Callback<OrderValidationEvent>
215+
) => {
216+
this.debug(
217+
`Listening for order invalidation events on "${collectionSlug}"`
218+
);
219+
return this.on(EventType.ORDER_INVALIDATE, collectionSlug, callback);
220+
};
221+
222+
public onOrderRevalidate = (
223+
collectionSlug: string,
224+
callback: Callback<OrderValidationEvent>
225+
) => {
226+
this.debug(
227+
`Listening for order revalidation events on "${collectionSlug}"`
228+
);
229+
return this.on(EventType.ORDER_REVALIDATE, collectionSlug, callback);
230+
};
231+
211232
public onEvents = (
212233
collectionSlug: string,
213234
eventTypes: EventType[],

src/types.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export enum EventType {
4040
ITEM_RECEIVED_BID = 'item_received_bid',
4141
ITEM_CANCELLED = 'item_cancelled',
4242
COLLECTION_OFFER = 'collection_offer',
43-
TRAIT_OFFER = 'trait_offer'
43+
TRAIT_OFFER = 'trait_offer',
44+
ORDER_INVALIDATE = 'order_invalidate',
45+
ORDER_REVALIDATE = 'order_revalidate'
4446
}
4547

4648
interface BaseItemMetadataType {
@@ -236,6 +238,21 @@ export interface TraitOfferEventPayload extends Payload {
236238

237239
export type TraitOfferEvent = BaseStreamMessage<TraitOfferEventPayload>;
238240

241+
export interface OrderValidationEventPayload {
242+
event_timestamp: string;
243+
order_hash: string;
244+
protocol_address: string;
245+
chain: {
246+
name: string;
247+
};
248+
collection: {
249+
slug: string;
250+
};
251+
}
252+
253+
export type OrderValidationEvent =
254+
BaseStreamMessage<OrderValidationEventPayload>;
255+
239256
export type Callback<Event> = (event: Event) => unknown;
240257

241258
export enum LogLevel {

0 commit comments

Comments
 (0)