-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
15,992 additions
and
6,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
lib | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
root: true, | ||
reportUnusedDisableDirectives: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'prettier'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended' | ||
], | ||
rules: { | ||
'prettier/prettier': 2 | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
## Change Overview | ||
|
||
<!-- Describe the change clearly and succinctly, why it is needed, and what the result of the change will do --> | ||
|
||
## Impact of Change | ||
|
||
<!-- Check all that apply and add other impacts that might not be listed --> | ||
|
||
- [ ] Bug fix | ||
- [ ] External Facing (resolves an issue customers are currently experiencing) | ||
- [ ] Security Impact (fixes a potential vulnerability) | ||
- [ ] External Facing (resolves an issue customers are currently experiencing) | ||
- [ ] Security Impact (fixes a potential vulnerability) | ||
- [ ] Feature | ||
- [ ] Visible Change (changes semver of API surface or other change that would impact user/dev experience) | ||
- [ ] High Usage (impacts a major part of the core workflow for users) | ||
- [ ] Visible Change (changes semver of API surface or other change that would impact user/dev experience) | ||
- [ ] High Usage (impacts a major part of the core workflow for users) | ||
- [ ] Performance Improvement | ||
- [ ] Refactoring | ||
- [ ] Other: *Describe here* | ||
- [ ] Other: _Describe here_ | ||
|
||
## Detailed Technical Description of Change | ||
|
||
<!-- Detail the technical approach and rationale for the change that you are working on. Are there are known limitations to the implementation or usage? --> | ||
|
||
## Testing Approach and Results | ||
|
||
<!-- Outline how you will test the change, provide rationale for whether unit / dev / system tests are needed (or why not), and post the evidence of your testing --> | ||
|
||
## Collateral Work or Changes | ||
|
||
<!-- Provide analysis of the overall impacts caused by your change. Does another system need to be updated to support the change? Does a configuration file need to be updated? etc --> | ||
|
||
## Operational Impact | ||
<!-- Are new metrics available with this change? Are they being logged? Do new dashboards or operational alerts need to be setup? --> | ||
|
||
<!-- Are new metrics available with this change? Are they being logged? Do new dashboards or operational alerts need to be setup? --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
name: code-quality | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
env: | ||
CI: true | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.11.0' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run linters | ||
run: npm run lint:check | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.11.0' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm run test -- --coverage --ci --runInBand | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.11.0' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn check-types |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"files.insertFinalNewline": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,135 @@ | ||
# OpenSea Push Client | ||
|
||
A Javascript SDK for receiving updates from OpenSea pushed over websocket. We currently support the following event types for collections: | ||
[](https://opensource.org/licenses/MIT) | ||
[](https://github.com/prettier/prettier) | ||
|
||
- item listed | ||
- item sold | ||
A Javascript SDK for receiving updates from OpenSea pushed over websocket. We currently support the following event types for collections: | ||
|
||
- item listed | ||
- item sold | ||
- item transferred | ||
- item metadata updates | ||
- item metadata updates | ||
- item cancelled | ||
|
||
This is a best effort delievery messaging system. Messages that are not received due to connection errors will not be re-sent. Messages may be delievered out of order. | ||
This is a best effort delievery messaging system. Messages that are not received due to connection errors will not be re-sent. Messages may be delievered out of order. | ||
|
||
# Setup | ||
# Setup | ||
|
||
Run `nvm use` | ||
And then `npm install` | ||
And then `npm install` | ||
|
||
# Getting Started | ||
|
||
# Getting Started | ||
For our beta test users we are only using basic authentication. To get started, request the basic authentication token and base endpoint from us. Later on we will align authentication with our API. | ||
|
||
For our beta test users we are only using basic authentication. To get started, request the basic authentication token and base endpoint from us. Later on we will align authentication with our API. | ||
## Create a client | ||
|
||
## Start a socket connection | ||
```javascript | ||
import { OpenSeaPushClient } from 'opensea-push-client' | ||
import { WebSocket } from 'ws'; | ||
```javascript | ||
import { OpenSeaPushClient } from '@opensea/pushed-updates-sdk'; | ||
|
||
const client = new OpenSeaPushClient('dummy_token', { | ||
const client = new OpenSeaPushClient({ | ||
apiUrl: 'apiURL', | ||
socketOptions: { | ||
transport: WebSocket | ||
} | ||
token: 'dummyToken' | ||
}); | ||
``` | ||
|
||
After successfully connecting to our websocket it is time to listen to specific events you're interested in! | ||
## Manually connecting to the socket (optional) | ||
|
||
Client will automatically connect to the socket as soon as you subscribe to the first channel. | ||
If you would like to connect to the socket manually (before that), you can do so: | ||
|
||
```javascript | ||
client.connect(); | ||
``` | ||
|
||
## Streaming metadata updates | ||
After successfully connecting to our websocket it is time to listen to specific events you're interested in! | ||
|
||
```javascript | ||
client.subscribeItemMetadataUpdates('collection-slug', (myEvent) => { | ||
// Your use case | ||
console.log(myEvent); | ||
## Streaming metadata updates | ||
|
||
```javascript | ||
client.onItemMetadataUpdated('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
## Streaming item listed events | ||
## Streaming item listed events | ||
|
||
```javascript | ||
client.subscribeItemListedEvents('collection-slug', (myEvent) => { | ||
console.log(myEvent); | ||
```javascript | ||
client.onItemListed('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
## Streaming item sold events | ||
## Streaming item sold events | ||
|
||
```javascript | ||
client.subscribeItemSoldEvents('collection-slug', (myEvent) => { | ||
console.log(myEvent); | ||
```javascript | ||
client.onItemSold('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
## Streaming item transferred events | ||
## Streaming item transferred events | ||
|
||
```javascript | ||
client.subscribeItemTransferredEvents('collection-slug', (myEvent) => { | ||
console.log(myEvent); | ||
```javascript | ||
client.onItemTransferred('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
## Streaming all item events | ||
## Streaming bids and offers | ||
|
||
```javascript | ||
client.onItemReceivedBid('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
|
||
```javascript | ||
client.subscribeAllItemEvents('collection-slug', (myEvent) => { | ||
console.log(myEvent); | ||
client.onItemReceivedOffer('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
## Streaming bids and offers | ||
```javascript | ||
client.subscribeItemReceivedBidEvents('collection-slug', (myEvent) => { | ||
// do something | ||
}) | ||
client.subscribeItemReceivedOfferEvents('collection-slug', (myEvent) => { | ||
// do something | ||
}) | ||
## Streaming multiple event types | ||
|
||
```javascript | ||
client.onEvents( | ||
'collection-slug', | ||
[EventType.ITEM_RECEIVED_OFFER, EventType.ITEM_TRANSFERRED], | ||
(event) => { | ||
// handle event | ||
} | ||
); | ||
``` | ||
|
||
## Streaming auction cancellations events | ||
```javascript | ||
client.subscribeItemCancelledEvents('collection-slug', (myEvent) => { | ||
// do something | ||
}) | ||
## Streaming auction cancellations events | ||
|
||
```javascript | ||
client.onItemCancelled('collection-slug', (event) => { | ||
// handle event | ||
}); | ||
``` | ||
|
||
# Subscribing to events from all collections | ||
# Subscribing to events from all collections | ||
|
||
If you'd like to listen to an event from all collections use wildcard `*` for the `collectionSlug` parameter. | ||
|
||
# Types | ||
|
||
Types are included to work with our event payload objects easier. | ||
|
||
If you'd like to listen to an event from all collections use wildcard `*` for the `collection_slug` parameter. | ||
# Disconnecting | ||
|
||
# Types | ||
## From a specific stream | ||
|
||
Types are included to work with our event payload objects easier. | ||
All subscription methods return a callback function that will unsubscribe from a stream when invoked. | ||
|
||
```javascript | ||
const unsubscribe = client.onItemMetadataUpdated('collection-slug', noop); | ||
|
||
unsubscribe(); | ||
``` | ||
|
||
## From the socket | ||
|
||
```javascript | ||
client.disconnect(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
import type { Config } from '@jest/types'; | ||
|
||
const pack = require('./package'); | ||
|
||
const config: Config.InitialOptions = { | ||
displayName: pack.name, | ||
name: pack.name, | ||
modulePaths: ['<rootDir>/src'], | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom' | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.