diff --git a/docs/README.md b/docs/README.md index 7f6dc9c7..c3cc9398 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,6 +13,11 @@ A Javascript SDK for receiving updates from the OpenSea Stream API - pushed over - item received offer - item received bid +Thise types are currently be expiremented with and for now are released on a small number of collections: + +- order_invalidate +- order_revalidate + 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. # Installation diff --git a/package-lock.json b/package-lock.json index dc282b47..42766cc0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@opensea/stream-js", - "version": "0.0.26", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@opensea/stream-js", - "version": "0.0.26", + "version": "0.1.0", "license": "MIT", "dependencies": { "phoenix": "^1.6.15" diff --git a/package.json b/package.json index d93d6c25..39375767 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opensea/stream-js", - "version": "0.0.26", + "version": "0.1.0", "description": "An SDK to receive pushed updates from OpenSea over websocket", "license": "MIT", "author": "OpenSea Developers", diff --git a/src/client.ts b/src/client.ts index 5e2c3cde..382049c5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -16,7 +16,8 @@ import { Callback, LogLevel, Network, - OnClientEvent + OnClientEvent, + OrderValidationEvent } from './types'; import { ENDPOINTS } from './constants'; @@ -208,6 +209,26 @@ export class OpenSeaStreamClient { return this.on(EventType.TRAIT_OFFER, collectionSlug, callback); }; + public onOrderInvalidate = ( + collectionSlug: string, + callback: Callback + ) => { + this.debug( + `Listening for order invalidation events on "${collectionSlug}"` + ); + return this.on(EventType.ORDER_INVALIDATE, collectionSlug, callback); + }; + + public onOrderRevalidate = ( + collectionSlug: string, + callback: Callback + ) => { + this.debug( + `Listening for order revalidation events on "${collectionSlug}"` + ); + return this.on(EventType.ORDER_REVALIDATE, collectionSlug, callback); + }; + public onEvents = ( collectionSlug: string, eventTypes: EventType[], diff --git a/src/types.ts b/src/types.ts index 64c16aa9..4f1f121d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -40,7 +40,9 @@ export enum EventType { ITEM_RECEIVED_BID = 'item_received_bid', ITEM_CANCELLED = 'item_cancelled', COLLECTION_OFFER = 'collection_offer', - TRAIT_OFFER = 'trait_offer' + TRAIT_OFFER = 'trait_offer', + ORDER_INVALIDATE = 'order_invalidate', + ORDER_REVALIDATE = 'order_revalidate' } interface BaseItemMetadataType { @@ -236,6 +238,21 @@ export interface TraitOfferEventPayload extends Payload { export type TraitOfferEvent = BaseStreamMessage; +export interface OrderValidationEventPayload { + event_timestamp: string; + order_hash: string; + protocol_address: string; + chain: { + name: string; + }; + collection: { + slug: string; + }; +} + +export type OrderValidationEvent = + BaseStreamMessage; + export type Callback = (event: Event) => unknown; export enum LogLevel {