-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event subscription (TS sdk) #4249
Conversation
@666lcz i know accessing the underlying We could use this approach if we have named events, and i could do like: this.wsClient.on(
'eventNotify',
this.onSocketMesage.bind(this),
); The |
@@ -421,4 +430,15 @@ export class JsonRpcProvider extends Provider { | |||
); | |||
} | |||
} | |||
|
|||
async subscribeEvent( | |||
filter: SuiEventFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the desired behavior if filter == {All: []}
, will it get subscribed all the events in the Network? cc @longbowlu
Co-authored-by: Chris Li <76067158+666lcz@users.noreply.github.com>
Add event subscription & general websocket functionality to TS SDK.
Basic use
Event filter type mirrors the Rust
SuiEventFilter
This shows subscribing to all
DevnetNFT
events.Testing
Easiest way to test the functionality is:
DevNetNFT
events as shown above in Basic Use, and log the results.Socket Messages
As an example, here's the sequence of messages that results from:
Connection Maintanence
We delay connecting until a websocket is needed, to avoid spamming the node with connections.
If the connection gets closed with active subscriptions and we reconnect, we re-subscribe those subscriptions.
We will likely need to add some rpc method for doing keep-alive / heartbeat requests in the future, so we can ensure connections stay open longer.