Skip to content
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

WIP: WebSockets subscriptions #144

Merged
merged 18 commits into from
Apr 6, 2019
Merged

WIP: WebSockets subscriptions #144

merged 18 commits into from
Apr 6, 2019

Conversation

BaldyAsh
Copy link
Collaborator

@BaldyAsh BaldyAsh commented Apr 1, 2019

Work for #145

@BaldyAsh BaldyAsh added the enhancement New feature or request label Apr 2, 2019
@barrasso
Copy link
Contributor

barrasso commented Apr 2, 2019

Looks great @BaldyAsh!

Can you please show some example usage for this?

For a particular Ethereum address, how can I get:

  • pending transactions
  • incoming/outgoing/internal transactions

Might be best to include it in Usage.md

Thanks

@BaldyAsh
Copy link
Collaborator Author

BaldyAsh commented Apr 2, 2019

@barrasso hi, the work in progress. When I finish all usage info will be added to Usage.md

@BaldyAsh BaldyAsh force-pushed the subscriptions branch 2 times, most recently from b1d5594 to f1811cb Compare April 4, 2019 17:09
@BaldyAsh
Copy link
Collaborator Author

BaldyAsh commented Apr 5, 2019

@barrasso hi, everything is almost done. Currently I'm building frameworks to test them on real project. You can see how to get latest pending transactions using Infura websockets API here https://github.com/matter-labs/web3swift/blob/subscriptions/Documentation/Usage.md#infura-websockets
Also this PR contains some fixes of recent bugs with sending transactions.
When the build is complete, I will push it and you can also try it.

@barrasso
Copy link
Contributor

barrasso commented Apr 5, 2019

@BaldyAsh Great work! 👍🏼

In addition to the Infura subscriptions, is there a method to subscribe to my own custom node via websockets?

For example:

let delegate: Web3SocketDelegate = DelegateClass() // Some delegate class which will receive messages from endpoint
let socketProvider = SocketProvider.connectToSocket("ws://my.ropsten.dnp.dappnode.eth:8546", delegate: delegate)
try! socketProvider.subscribeOnNewPendingTransactions()

@BaldyAsh
Copy link
Collaborator Author

BaldyAsh commented Apr 5, 2019

@barrasso you will be able to use custom node in that way:

let socketProvider = WebsocketProvider.connectToSocket(endpoint: <URL>, delegate: <Web3SocketDelegate>)!

But currently I'm thinking is it a good idea to provide subscribe methods like newPendingTransactions for custom websocket provider by default. Maybe it's better to force user to build his own subscriptions and give him just possibility to send message to websocket via writeMessage, because endpoint API may differ from Infuras' and default methods should not mislead newcomers

@BaldyAsh
Copy link
Collaborator Author

BaldyAsh commented Apr 6, 2019

@barrasso think its done, already tested with frameworks. I'll merge it and create pod. This closes #145 #149 #143 #140 #133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants