-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add unsubscribeByID #4061
Add unsubscribeByID #4061
Conversation
Your Render PR Server URL is https://web3-js-pr-4061.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c2ea2oj2v8p78k79mko0. |
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.
Yea, I shouldn't have created that for you, now it's my PR and I can't request changes or approve xD
test/eth.subscribe.ganache.js
Outdated
.on('connected', function (result) { | ||
assert(result) | ||
assert.equal(1, web3.eth._requestManager.subscriptions.size); | ||
subscription.unsubscribeById(subscription.id); // Stop listening.. |
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.
I don't think adding unsubscribeById
to an instance of the Subscription
class makes sense, since unsubscribe already exists - this would just be adding a semi duplicate method to the class (bloat). Instead, if we can make unsubscribeById
a static method, or similar, and we could have it unsubscribe with just the id
, and not have to have an instance available to call the method from, I could see this being a useful method to add
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.
I put this comment here to reference what I'm talking about
Instead of doing:
subscription = web3.eth.subscribe(...')
subscription.unsubscribeById(...)
It would be cool if you could find a way to do
Subscription.unsubscribeById(...)
Or maybe it would be
web3.eth.subscribe.unsubscribeById(...)
so you don't have to have access to an instance of Subscription
. But maybe what you have already works like that too? Idk, can you tell me? :)
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.
can probably make use of looking through web3.eth._requestManager.subscriptions
and loop through the id
s! Great suggestion
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.
Cool! the request manager was helpful :).
It can now be called with
web3.eth. removeSubscriptionById( id)
Pull Request Test Coverage Report for Build 845165093
💛 - Coveralls |
* adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
* Release/1.3.5 (#3974) * Update changelog * Built dist * Update version numbers * v1.3.5 Co-authored-by: Ubuntu <[email protected]> * Bump underscore (#4051) * bump underscore * update package-locks * bump lcoks again * Release 1.3.6 (#4053) * Update CHANGELOG and ran npm i * Built lib for 1.3.6-rc.0 * v1.3.6-rc.0 * npm i * Built lib for 1.3.6-rc.1 * v1.3.6-rc.1 * 1.3.6-rc.2 (#4059) * npm i && npm audit fix * Manually bump version to 1.3.6-rc.2 * Built lib for 1.3.6-rc.2 * v1.3.6-rc.2 * 1.3.6-rc.2 fixes (#4062) * Manually update dependency versions to 1.3.6-rc.2 * Accidental commit * npm i * Manually update web3 dependency version to 1.3.6-rc.2 * npm i * Built manually for 1.3.6-rc.2 * Update CHANGELOG * Update CHANGELOG.md Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: Gregory Markou <[email protected]> * Add web3-core-helpers as dev dependency * Add web3-core-helpers as dev dependency * Fixing 1.3.6-rc.2 related issues (#4063) * Remove web3-eth-ens as dependency * Regen package-locks and build lib * Remove dtslint from ci scripts (#4064) * Remove web3-eth-ens as dependency * Regen package-locks and build lib * Remove npm run dtslint from build and lint * 1.3.6-rc.2 Fixes (#4065) * Remove web3-eth-ens as dependency * Regen package-locks and build lib * Remove npm run dtslint from build and lint * Add back removed package: web3-eth-ens * npm i * Build lib * Add back npm run dtslint * Update geth-dev-assistant * v1.3.6 Co-authored-by: Gregory Markou <[email protected]> * Add unsubscribeByID (#4061) * adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]> * ignore .md and docs (#4077) * adding berlin tx support (#4109) * add berlin tx support * update install locations * update package name in comment * fix existing tests to support new tx sigining format * remove build * remove old test case * use latest ethereumjs/tx * bump deps and fix test * update hashes * fix messageHash, decoding bug * fix tests * add hack * adding eip2930 and common object * fix lint updating package-lock * fix berlin tx signing and recovery * updating ethereumjs/tx package * updating checksum * removing helper.js * updating changelog and docs * fixing typo Co-authored-by: Gregory Markou <[email protected]> * Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth (#4154) * Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth * Update scripts/e2e.geth.instamine.sh to use v1.10.3 of Geth * Fix typo * Release v1.4.0 (#4118) * npm run build for 1.4.0-rc.0 * v1.4.0-rc.0 * 1.4.0 Geth version downgrade (#4149) * Update pull Geth docker version from stable to pre-london (1.10.3) * Update CHANGELOG * v1.4.0 Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: Gregory Markou <[email protected]>
* adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
* Release/1.3.5 (#3974) * Update changelog * Built dist * Update version numbers * v1.3.5 Co-authored-by: Ubuntu <[email protected]> * Merge conflicts * Merge conflicts * Add unsubscribeByID (#4061) * adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]> * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Update CHANGELOG (#4193) Test don't run when only changes to `CHANGELOG.md` have been made Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
* adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
* Merge conflitcs * Add unsubscribeByID (#4061) * adding function unsubscribe by id * adding an unsubscribe testcase * adding testcase * seperated unsubscribebyid to its own method * adding testcases * adding await * fixing testcases Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]> * ignore .md and docs (#4077) * Merge conflicts * Merge conflicts * Release v1.4.0 (#4118) * npm run build for 1.4.0-rc.0 * v1.4.0-rc.0 * 1.4.0 Geth version downgrade (#4149) * Update pull Geth docker version from stable to pre-london (1.10.3) * Update CHANGELOG * v1.4.0 * remove underscore (#4069) * removed some of the underscore methods in web3-core-method * removed underscore from bzz * adding subscriptions * fixing up test cases * changing variable names * removed underscore from formatters.js * removed underscore from request manager and abi * removing underscore in the rest of the web3 packages * fixing exports * fixing failing testcases * removing underscore from tests * addressing feedback * removing unwanted code from transaction * removing underscore from remaining packages * updating change log * addressing feedback * adding strict equality * efficient short circuiting * fixing test case * Merge conflicts * Update docs 2 (#4188) * add nonce to send options. * add nonce to send options. * Update CHANGELOG.md * linting * updating docs * update web3-shh.rst : whisper-overview broken link (#4170) whisper overview has been moved from https://github.com/ethereum/go-ethereum/wiki/Whisper to https://eth.wiki/concepts/whisper/whisper-overview * [Docs] Fixed a broken link (#4151) Original link gives out a 404, replaced by the closest thing I could find. * Possible typo in docs (#4088) I think the author missed a "this" in the phrase * Typically you will have only one Web3 connection, use const (#3967) Co-authored-by: Gregory Markou <[email protected]> * Removing deprecation notice for HttpProvider (#4008) * Removing deprecation notice for HttpProvider From my view, it is just a provider with less capabilities than websockets, but still widely useful — and widely used as well. @frozeman @nivida @GregTheGreek any thoughts? * Update include_package-core.rst * Update CHANGELOG.md Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: Alex <[email protected]> * [Docs] Updated solidity example to modern syntax (#4147) * [Docs] Updated solidity example to modern syntax Replaced the old constructor function syntax with the modern one, added 'emit' to event calls, added pragma, added a valid bytes32 value and updated the JSON ABI. * [Docs] Fixed a broken link (#1) Original link gives out a 404, replaced by the proper guide. Co-authored-by: Juan Alonso <[email protected]> * Revert "[Docs] Fixed a broken link (#1)" This reverts commit 0de1272. Co-authored-by: Juan Alonso <[email protected]> * added EIP-2718 and EIP-1559 documentation * fixing typo * addressing feedback * changing possible types for maxPriorityFeePerGas * updating maxFeePerGas type * update changelog Co-authored-by: exx8 <[email protected]> Co-authored-by: starwalker00 <[email protected]> Co-authored-by: mongolsteppe <[email protected]> Co-authored-by: João Monteiro <[email protected]> Co-authored-by: William Entriken <[email protected]> Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: Ev <[email protected]> Co-authored-by: Juan Alonso <[email protected]> * eth_feeHistory (EIP 1559) (#4191) * WIP * Add missing fields for test runner * Correct function arguments for getFeeHistory * getFeeHistory tests with correct arguments * Init utils.toNumber function * Rename toNumber test to hexToNumber * Add inputFormatters to getFeeHistory * Rename newestBlock to lastBlock. Update types for blockCount and lastBlock * Add additional tests with different input types * Add missing function export * eth-feehistory docs (#4190) * updating docs * updating example * updating types and adding example of list * Update docs/web3-eth.rst * Update docs/web3-eth.rst * Update docs/web3-eth.rst Co-authored-by: alex <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: alex <[email protected]> * Update CHANGELOG (#4193) Test don't run when only changes to `CHANGELOG.md` have been made * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts * Merge conflicts Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: Gregory Markou <[email protected]> Co-authored-by: exx8 <[email protected]> Co-authored-by: starwalker00 <[email protected]> Co-authored-by: mongolsteppe <[email protected]> Co-authored-by: João Monteiro <[email protected]> Co-authored-by: William Entriken <[email protected]> Co-authored-by: Ev <[email protected]> Co-authored-by: Juan Alonso <[email protected]> Co-authored-by: alex <[email protected]> Co-authored-by: jdevcs <[email protected]>
Seems like the typescript is update for this method |
closes #4007
Addressing this feature,
call
web3.eth.removeSubscriptionById(id)
to unsubscribe by ID